Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions features/src/bun/README.md
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions features/src/bun/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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"]
}
29 changes: 29 additions & 0 deletions features/src/bun/install.sh
Original file line number Diff line number Diff line change
@@ -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!"
1 change: 1 addition & 0 deletions features/test/bun/devcontainer-base-debian.sh
1 change: 1 addition & 0 deletions features/test/bun/devcontainer-base-ubuntu-remote-user.sh
1 change: 1 addition & 0 deletions features/test/bun/devcontainer-base-ubuntu-root.sh
1 change: 1 addition & 0 deletions features/test/bun/official-debian.sh
29 changes: 29 additions & 0 deletions features/test/bun/scenarios.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
13 changes: 13 additions & 0 deletions features/test/bun/test.sh
Original file line number Diff line number Diff line change
@@ -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
Loading