Skip to content

Commit 3d05f4c

Browse files
authored
feat(webinstall.dev): Add feature. (#15)
* feat(`webinstall.dev`): Add feature. * feat(`webinstall.dev`): Fix `devcontainer-feature.json`.
1 parent c5a18ac commit 3d05f4c

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

.github/workflows/test.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
- pkgx.sh
2121
- smallstep.com
2222
- starship.rs
23+
- webinstall.dev
2324
- zellij.dev
2425
baseImage:
2526
- debian:latest
@@ -47,6 +48,7 @@ jobs:
4748
- pkgx.sh
4849
- smallstep.com
4950
- starship.rs
51+
- webinstall.dev
5052
- zellij.dev
5153
steps:
5254
- uses: actions/checkout@v4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "webinstall.dev",
3+
"id": "webinstall.dev",
4+
"version": "1.0.0",
5+
"description": "Install \"webi\" binary",
6+
"documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/webinstall.dev",
7+
"options": {
8+
"version": {
9+
"type": "string",
10+
"default": "latest",
11+
"proposals": [
12+
"latest"
13+
],
14+
"description": "Version of \"webi\" to install."
15+
}
16+
}
17+
}

src/webinstall.dev/install.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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="asdf"
8+
apt_get_update() {
9+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
10+
echo "Running apt-get update..."
11+
apt-get update -y
12+
fi
13+
}
14+
apt_get_checkinstall() {
15+
if ! dpkg -s "$@" >/dev/null 2>&1; then
16+
apt_get_update
17+
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends --no-install-suggests --option 'Debug::pkgProblemResolver=true' --option 'Debug::pkgAcquire::Worker=1' "$@"
18+
fi
19+
}
20+
apt_get_cleanup() {
21+
apt-get clean
22+
rm -rf /var/lib/apt/lists/*
23+
}
24+
echo_banner() {
25+
local text="$1"
26+
echo -e "\e[1m\e[97m\e[41m$text\e[0m"
27+
}
28+
install() {
29+
apt_get_checkinstall curl ca-certificates
30+
su $_REMOTE_USER -c "curl -sS https://webi.sh/webi | sh"
31+
apt_get_cleanup
32+
}
33+
echo_banner "devcontainer.community"
34+
echo "Installing $name..."
35+
install "$@"
36+
echo "(*) Done!"

test/webinstall.dev/test.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
15+
check "execute command" bash -c "webi --version | grep 'webi'"
16+
17+
# Report results
18+
# If any of the checks above exited with a non-zero exit code, the test will fail.
19+
reportResults

0 commit comments

Comments
 (0)