Skip to content

[CHANGE] New feature "mise-bun" #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2025
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
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- bitwarden-cli
- bitwarden-secrets-manager
- mise
- mise-bun
- mise-golang
- mise-node
- mise-python
Expand Down Expand Up @@ -66,6 +67,7 @@ jobs:
- bitwarden-secrets-manager
- kamal
- mise
- mise-bun
- mise-golang
- mise-node
- mise-python
Expand Down
25 changes: 25 additions & 0 deletions src/mise-bun/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# Bun (mise) (mise-bun)

Installs Bun via mise-en-place version manager.

## Example Usage

```json
"features": {
"ghcr.io/RouL/devcontainer-features/mise-bun:1": {}
}
```

## Options

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| version | Version to be installed as default. | string | latest |
| extra_versions | Additional versions to be installed. (space separated) | string | - |



---

_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/RouL/devcontainer-features/blob/main/src/mise-bun/devcontainer-feature.json). Add additional notes to a `NOTES.md`._
21 changes: 21 additions & 0 deletions src/mise-bun/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"id": "mise-bun",
"version": "1.0.0",
"name": "Bun (mise)",
"description": "Installs Bun via mise-en-place version manager.",
"dependsOn": {
"ghcr.io/RouL/devcontainer-features/mise:latest": {}
},
"options": {
"version": {
"description": "Version to be installed as default.",
"type": "string",
"default": "latest"
},
"extra_versions": {
"description": "Additional versions to be installed. (space separated)",
"type": "string",
"default": ""
}
}
}
45 changes: 45 additions & 0 deletions src/mise-bun/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/bash
set -e

USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
VERSION="${VERSION:-latest}"

REQUIRED_PACKAGES="build-essential git ca-certificates"

apt_get_update()
{
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update -y
fi
}

check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}

export DEBIAN_FRONTEND=noninteractive

check_packages $REQUIRED_PACKAGES

install() {
su ${USERNAME} -c "mise use --global bun@${VERSION}"
}

echo "(*) Installing Bun (${VERSION}) via mise as default..."

install

for extraVersion in $EXTRA_VERSIONS
do
echo "(*) Installung Bun (${extraVersion}) via mise"
su ${USERNAME} -c "mise install bun@${extraVersion}"
done

# Clean up
rm -rf /var/lib/apt/lists/*

echo "Done!"
8 changes: 8 additions & 0 deletions test/mise-bun/bun1.1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

source dev-container-features-test-lib

check "check default bun == 1.1.*" bash -c "bun --version | grep -E '^1\\.1\\.'"

reportResults
10 changes: 10 additions & 0 deletions test/mise-bun/bun1.2_bun1.1_bun1.0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

source dev-container-features-test-lib

check "check default bun == 1.2.*" bash -c "bun --version | grep -E '^1\\.2\\.'"
check "check bun 1.1.*" bash -c "mise exec bun@1.1 -- bun --version | grep -E '^1\\.1\\.'"
check "check bun 1.0.*" bash -c "mise exec bun@1.0 -- bun --version | grep -E '^1\\.0\\.'"

reportResults
19 changes: 19 additions & 0 deletions test/mise-bun/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"bun1.1": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"mise-bun": {
"version": "1.1"
}
}
},
"bun1.2_bun1.1_bun1.0": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"mise-bun": {
"version": "1.2",
"extra_versions": "1.1 1.0"
}
}
}
}
14 changes: 14 additions & 0 deletions test/mise-bun/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e

sudo apt-get update -y > /dev/null
sudo apt-get install -y curl jq ca-certificates > /dev/null

CURRENT_VERSION="$(curl -L --no-progress-meter https://api.github.com/repos/oven-sh/bun/releases/latest | jq --raw-output '.tag_name')"
CURRENT_VERSION="${CURRENT_VERSION#bun-v}"

source dev-container-features-test-lib

check "check default bun == latest ($CURRENT_VERSION)" bash -c "bun --version | grep -E '^${CURRENT_VERSION//\./\\.}$'"

reportResults