From 629ee55000a07d20f2d27410ca6df03e294b955c Mon Sep 17 00:00:00 2001 From: shokkunrf <19404989+shokkunrf@users.noreply.github.com> Date: Fri, 13 Mar 2026 15:42:53 +0000 Subject: [PATCH] Add bun devcontainer feature --- features/src/bun/README.md | 16 ++++++++++ features/src/bun/devcontainer-feature.json | 9 ++++++ features/src/bun/install.sh | 29 +++++++++++++++++++ features/test/bun/devcontainer-base-debian.sh | 1 + .../devcontainer-base-ubuntu-remote-user.sh | 1 + .../test/bun/devcontainer-base-ubuntu-root.sh | 1 + features/test/bun/official-debian.sh | 1 + features/test/bun/scenarios.json | 29 +++++++++++++++++++ features/test/bun/test.sh | 13 +++++++++ 9 files changed, 100 insertions(+) create mode 100644 features/src/bun/README.md create mode 100644 features/src/bun/devcontainer-feature.json create mode 100644 features/src/bun/install.sh create mode 120000 features/test/bun/devcontainer-base-debian.sh create mode 120000 features/test/bun/devcontainer-base-ubuntu-remote-user.sh create mode 120000 features/test/bun/devcontainer-base-ubuntu-root.sh create mode 120000 features/test/bun/official-debian.sh create mode 100644 features/test/bun/scenarios.json create mode 100644 features/test/bun/test.sh diff --git a/features/src/bun/README.md b/features/src/bun/README.md new file mode 100644 index 0000000..4600bb2 --- /dev/null +++ b/features/src/bun/README.md @@ -0,0 +1,16 @@ +# Bun (bun) + +Installs [Bun](https://bun.com/) JavaScript runtime via the official installer. + +## Usage + +```json +"features": { + "ghcr.io/shokkunrf/devcontainer-features/bun": {} +} +``` + +## Requirements + +- `curl` or `wget` must be available in the container +- `bash` must be available in the container diff --git a/features/src/bun/devcontainer-feature.json b/features/src/bun/devcontainer-feature.json new file mode 100644 index 0000000..01ff3e0 --- /dev/null +++ b/features/src/bun/devcontainer-feature.json @@ -0,0 +1,9 @@ +{ + "id": "bun", + "version": "1.0.0", + "name": "Bun", + "documentationURL": "https://github.com/shokkunrf/devcontainer/tree/develop/features/src/bun/README.md", + "description": "Installs Bun JavaScript runtime via the official installer", + "options": {}, + "installsAfter": ["ghcr.io/devcontainers/features/common-utils"] +} diff --git a/features/src/bun/install.sh b/features/src/bun/install.sh new file mode 100644 index 0000000..1e1afe7 --- /dev/null +++ b/features/src/bun/install.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# References: +# - https://bun.com/docs/installation + +set -eu + +echo "Activating feature 'bun'" + +_install_bun() { + if command -v curl >/dev/null; then + download_cmd="curl -fsSL https://bun.com/install" + elif command -v wget >/dev/null; then + download_cmd="wget -qO- https://bun.com/install" + else + echo "ERROR: curl or wget is required but neither was found!" + return 1 + fi + + # Install as remote user if running as root with non-root remote user + if [ "$(id -u)" = "0" ] && [ -n "${_REMOTE_USER:-}" ] && [ "$_REMOTE_USER" != "root" ]; then + su - "$_REMOTE_USER" -c "$download_cmd | bash" + else + $download_cmd | bash + fi +} + +_install_bun + +echo "Bun installed successfully!" diff --git a/features/test/bun/devcontainer-base-debian.sh b/features/test/bun/devcontainer-base-debian.sh new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/features/test/bun/devcontainer-base-debian.sh @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/features/test/bun/devcontainer-base-ubuntu-remote-user.sh b/features/test/bun/devcontainer-base-ubuntu-remote-user.sh new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/features/test/bun/devcontainer-base-ubuntu-remote-user.sh @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/features/test/bun/devcontainer-base-ubuntu-root.sh b/features/test/bun/devcontainer-base-ubuntu-root.sh new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/features/test/bun/devcontainer-base-ubuntu-root.sh @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/features/test/bun/official-debian.sh b/features/test/bun/official-debian.sh new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/features/test/bun/official-debian.sh @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/features/test/bun/scenarios.json b/features/test/bun/scenarios.json new file mode 100644 index 0000000..b10a777 --- /dev/null +++ b/features/test/bun/scenarios.json @@ -0,0 +1,29 @@ +{ + "official-debian": { + "image": "debian:trixie", + "features": { + "ghcr.io/devcontainers/features/common-utils:2": {}, + "bun": {} + } + }, + "devcontainer-base-debian": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "bun": {} + }, + "remoteUser": "vscode" + }, + "devcontainer-base-ubuntu-root": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "bun": {} + } + }, + "devcontainer-base-ubuntu-remote-user": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "bun": {} + }, + "remoteUser": "vscode" + } +} diff --git a/features/test/bun/test.sh b/features/test/bun/test.sh new file mode 100644 index 0000000..7403816 --- /dev/null +++ b/features/test/bun/test.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "bun is installed" bun --version +check "bun is upgradable" bun upgrade + +# Report result +reportResults