From b5c2d375f3bcc181f5f15608a335026030b91452 Mon Sep 17 00:00:00 2001 From: Sebastian Steins <592313+sebst@users.noreply.github.com> Date: Sun, 13 Oct 2024 11:07:24 +0200 Subject: [PATCH] feat(`bun.sh`): Add feature. --- .github/workflows/test.yaml | 2 ++ src/bun.sh/devcontainer-feature.json | 17 +++++++++++++ src/bun.sh/install.sh | 36 ++++++++++++++++++++++++++++ test/bun.sh/test.sh | 19 +++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 src/bun.sh/devcontainer-feature.json create mode 100755 src/bun.sh/install.sh create mode 100755 test/bun.sh/test.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9beaa49..e79a1ad 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,6 +16,7 @@ jobs: - asdf-vm.com - atuin.sh - btop + - bun.sh - deno.com - pkgx.sh - smallstep.com @@ -43,6 +44,7 @@ jobs: - asdf-vm.com - atuin.sh - btop + - bun.sh - deno.com - pkgx.sh - smallstep.com diff --git a/src/bun.sh/devcontainer-feature.json b/src/bun.sh/devcontainer-feature.json new file mode 100644 index 0000000..d09e2b8 --- /dev/null +++ b/src/bun.sh/devcontainer-feature.json @@ -0,0 +1,17 @@ +{ + "name": "bun.sh", + "id": "bun.sh", + "version": "1.0.0", + "description": "Install \"bun\" binary", + "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/bun.sh", + "options": { + "version": { + "type": "string", + "default": "latest", + "proposals": [ + "latest" + ], + "description": "Currently unused." + } + } +} \ No newline at end of file diff --git a/src/bun.sh/install.sh b/src/bun.sh/install.sh new file mode 100755 index 0000000..d9c6510 --- /dev/null +++ b/src/bun.sh/install.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -o errexit +set -o pipefail +set -o noclobber +set -o nounset +set -o allexport +readonly name="bun" +apt_get_update() { + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi +} +apt_get_checkinstall() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + apt_get_update + DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends --no-install-suggests --option 'Debug::pkgProblemResolver=true' --option 'Debug::pkgAcquire::Worker=1' "$@" + fi +} +apt_get_cleanup() { + apt-get clean + rm -rf /var/lib/apt/lists/* +} +echo_banner() { + local text="$1" + echo -e "\e[1m\e[97m\e[41m$text\e[0m" +} +install() { + apt_get_checkinstall unzip curl ca-certificates + su $_REMOTE_USER -c "curl -fsSL https://bun.sh/install | bash" + apt_get_cleanup +} +echo_banner "devcontainer.community" +echo "Installing $name..." +install "$@" +echo "(*) Done!" diff --git a/test/bun.sh/test.sh b/test/bun.sh/test.sh new file mode 100755 index 0000000..8a06625 --- /dev/null +++ b/test/bun.sh/test.sh @@ -0,0 +1,19 @@ +#!/bin/bash + + +set -e + +# Optional: Import test library bundled with the devcontainer CLI +# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib +# Provides the 'check' and 'reportResults' commands. +source dev-container-features-test-lib + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. Syntax is... +# check