diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 869f3db..760ee35 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,6 +15,7 @@ jobs: features: - atuin.sh - btop + - deno.com - smallstep.com - starship.rs baseImage: @@ -38,6 +39,7 @@ jobs: features: - atuin.sh - btop + - deno.com - smallstep.com - starship.rs steps: diff --git a/src/deno.com/devcontainer-feature.json b/src/deno.com/devcontainer-feature.json new file mode 100644 index 0000000..f189b69 --- /dev/null +++ b/src/deno.com/devcontainer-feature.json @@ -0,0 +1,17 @@ +{ + "name": "deno.com", + "id": "deno.com", + "version": "1.0.0", + "description": "Install \"deno\" binary", + "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/deno.com", + "options": { + "version": { + "type": "string", + "default": "latest", + "proposals": [ + "latest" + ], + "description": "Version of \"deno\" to install." + } + } +} \ No newline at end of file diff --git a/src/deno.com/install.sh b/src/deno.com/install.sh new file mode 100755 index 0000000..374a68a --- /dev/null +++ b/src/deno.com/install.sh @@ -0,0 +1,55 @@ +#!/bin/bash +set -o errexit +set -o pipefail +set -o noclobber +set -o nounset +set -o allexport +readonly name="deno" +apt_get_cleanup() { + apt-get clean + rm -rf /var/lib/apt/lists/* +} +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 +} +check_curl_installed() { + declare -a requiredAptPackagesMissing=() + if ! [ -r '/etc/ssl/certs/ca-certificates.crt' ]; then + requiredAptPackagesMissing+=('ca-certificates') + fi + if ! command -v curl >/dev/null 2>&1; then + requiredAptPackagesMissing+=('curl') + fi + declare -i requiredAptPackagesMissingCount=${#requiredAptPackagesMissing[@]} + if [ $requiredAptPackagesMissingCount -gt 0 ]; then + apt_get_checkinstall "${requiredAptPackagesMissing[@]}" + apt_get_cleanup + fi +} +echo_banner() { + local text="$1" + echo -e "\e[1m\e[97m\e[41m$text\e[0m" +} +install() { + check_curl_installed + if [ "$VERSION" == "latest" ]; then + VERSION="$(curl -s https://dl.deno.land/release-latest.txt)" + fi + apt_get_checkinstall unzip + export DENO_INSTALL="/usr/local" + curl -fsSL https://deno.land/install.sh | sh -s -- -y $VERSION + apt_get_cleanup +} +echo_banner "devcontainer.community" +echo "Installing $name..." +install "$@" +echo "(*) Done!" diff --git a/test/deno.com/deno.com-debian.sh b/test/deno.com/deno.com-debian.sh new file mode 100755 index 0000000..087376e --- /dev/null +++ b/test/deno.com/deno.com-debian.sh @@ -0,0 +1,18 @@ +#!/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