Skip to content

Commit cb0991e

Browse files
authored
feat(deno.com): Add feature. (#7)
* feat(`deno.com`): Add feature. * feat(`deno.com`): Fix `curl` dep. * feat(`deno.com`): Fix `curl` dep. * feat(`deno.com`): Fix test.
1 parent 8802d4f commit cb0991e

File tree

6 files changed

+119
-0
lines changed

6 files changed

+119
-0
lines changed

.github/workflows/test.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
features:
1616
- atuin.sh
1717
- btop
18+
- deno.com
1819
- smallstep.com
1920
- starship.rs
2021
baseImage:
@@ -38,6 +39,7 @@ jobs:
3839
features:
3940
- atuin.sh
4041
- btop
42+
- deno.com
4143
- smallstep.com
4244
- starship.rs
4345
steps:
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "deno.com",
3+
"id": "deno.com",
4+
"version": "1.0.0",
5+
"description": "Install \"deno\" binary",
6+
"documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/deno.com",
7+
"options": {
8+
"version": {
9+
"type": "string",
10+
"default": "latest",
11+
"proposals": [
12+
"latest"
13+
],
14+
"description": "Version of \"deno\" to install."
15+
}
16+
}
17+
}

src/deno.com/install.sh

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
set -o errexit
3+
set -o pipefail
4+
set -o noclobber
5+
set -o nounset
6+
set -o allexport
7+
readonly name="deno"
8+
apt_get_cleanup() {
9+
apt-get clean
10+
rm -rf /var/lib/apt/lists/*
11+
}
12+
apt_get_update() {
13+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
14+
echo "Running apt-get update..."
15+
apt-get update -y
16+
fi
17+
}
18+
apt_get_checkinstall() {
19+
if ! dpkg -s "$@" >/dev/null 2>&1; then
20+
apt_get_update
21+
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends --no-install-suggests --option 'Debug::pkgProblemResolver=true' --option 'Debug::pkgAcquire::Worker=1' "$@"
22+
fi
23+
}
24+
check_curl_installed() {
25+
declare -a requiredAptPackagesMissing=()
26+
if ! [ -r '/etc/ssl/certs/ca-certificates.crt' ]; then
27+
requiredAptPackagesMissing+=('ca-certificates')
28+
fi
29+
if ! command -v curl >/dev/null 2>&1; then
30+
requiredAptPackagesMissing+=('curl')
31+
fi
32+
declare -i requiredAptPackagesMissingCount=${#requiredAptPackagesMissing[@]}
33+
if [ $requiredAptPackagesMissingCount -gt 0 ]; then
34+
apt_get_checkinstall "${requiredAptPackagesMissing[@]}"
35+
apt_get_cleanup
36+
fi
37+
}
38+
echo_banner() {
39+
local text="$1"
40+
echo -e "\e[1m\e[97m\e[41m$text\e[0m"
41+
}
42+
install() {
43+
check_curl_installed
44+
if [ "$VERSION" == "latest" ]; then
45+
VERSION="$(curl -s https://dl.deno.land/release-latest.txt)"
46+
fi
47+
apt_get_checkinstall unzip
48+
export DENO_INSTALL="/usr/local"
49+
curl -fsSL https://deno.land/install.sh | sh -s -- -y $VERSION
50+
apt_get_cleanup
51+
}
52+
echo_banner "devcontainer.community"
53+
echo "Installing $name..."
54+
install "$@"
55+
echo "(*) Done!"

test/deno.com/deno.com-debian.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
4+
set -e
5+
6+
# Optional: Import test library bundled with the devcontainer CLI
7+
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
8+
# Provides the 'check' and 'reportResults' commands.
9+
source dev-container-features-test-lib
10+
11+
# Feature-specific tests
12+
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
13+
# check <LABEL> <cmd> [args...]
14+
check "execute command" bash -c "deno --version | grep 'deno'"
15+
16+
# Report results
17+
# If any of the checks above exited with a non-zero exit code, the test will fail.
18+
reportResults

test/deno.com/scenarios.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"deno.com-debian": {
3+
"image": "mcr.microsoft.com/devcontainers/base:debian",
4+
"features": {
5+
"deno.com": {
6+
}
7+
}
8+
}
9+
}

test/deno.com/test.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
4+
set -e
5+
6+
# Optional: Import test library bundled with the devcontainer CLI
7+
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
8+
# Provides the 'check' and 'reportResults' commands.
9+
source dev-container-features-test-lib
10+
11+
# Feature-specific tests
12+
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
13+
# check <LABEL> <cmd> [args...]
14+
check "execute command" bash -c "deno --version | grep 'deno'"
15+
16+
# Report results
17+
# If any of the checks above exited with a non-zero exit code, the test will fail.
18+
reportResults

0 commit comments

Comments
 (0)