From f2516121156aee575fe1da7bad86ac80c1976cbb Mon Sep 17 00:00:00 2001 From: shokkunrf <19404989+shokkunrf@users.noreply.github.com> Date: Sat, 28 Feb 2026 04:42:47 +0000 Subject: [PATCH] Add wd devcontainer feature --- features/src/wd/README.md | 39 +++++++++++++++++++ features/src/wd/devcontainer-feature.json | 15 +++++++ features/src/wd/install.sh | 36 +++++++++++++++++ features/test/wd/devcontainer-base-alpine.sh | 1 + features/test/wd/devcontainer-base-debian.sh | 1 + features/test/wd/official-debian.sh | 1 + features/test/wd/scenarios.json | 25 ++++++++++++ features/test/wd/test-posix.sh | 41 ++++++++++++++++++++ features/test/wd/test.sh | 12 ++++++ 9 files changed, 171 insertions(+) create mode 100644 features/src/wd/README.md create mode 100644 features/src/wd/devcontainer-feature.json create mode 100644 features/src/wd/install.sh create mode 120000 features/test/wd/devcontainer-base-alpine.sh create mode 120000 features/test/wd/devcontainer-base-debian.sh create mode 120000 features/test/wd/official-debian.sh create mode 100644 features/test/wd/scenarios.json create mode 100644 features/test/wd/test-posix.sh create mode 100644 features/test/wd/test.sh diff --git a/features/src/wd/README.md b/features/src/wd/README.md new file mode 100644 index 0000000..9871291 --- /dev/null +++ b/features/src/wd/README.md @@ -0,0 +1,39 @@ +# wd + +Installs [wd](https://github.com/shokkunrf/wd) via the official installer, a CLI tool for managing git worktrees with devcontainer support. + +## Usage + +```json +{ + "features": { + "ghcr.io/shokkunrf/devcontainer-features/wd": {} + } +} +``` + +## Options + +| Option | Type | Default | Description | +| --------- | ------ | ---------- | ------------------------------------------------------------------------------------ | +| `version` | string | `"latest"` | Version of wd to install (e.g., `v1.1.1`). Use `latest` for the most recent release. | + +## Requirements + +- `curl` or `wget` +- `git` + +## Examples + +Install a specific version: + +```json +{ + "features": { + "ghcr.io/devcontainers/features/git": {}, + "ghcr.io/shokkunrf/devcontainer-features/wd": { + "version": "v1.1.1" + } + } +} +``` diff --git a/features/src/wd/devcontainer-feature.json b/features/src/wd/devcontainer-feature.json new file mode 100644 index 0000000..f1737a6 --- /dev/null +++ b/features/src/wd/devcontainer-feature.json @@ -0,0 +1,15 @@ +{ + "id": "wd", + "version": "1.0.0", + "name": "wd", + "documentationURL": "https://github.com/shokkunrf/devcontainer/blob/develop/features/src/wd/README.md", + "description": "Installs wd, a git worktree management tool", + "options": { + "version": { + "type": "string", + "default": "latest", + "description": "Version of wd to install (e.g., 'v1.1.1'). Use 'latest' for the most recent release." + } + }, + "installsAfter": ["ghcr.io/devcontainers/features/common-utils"] +} diff --git a/features/src/wd/install.sh b/features/src/wd/install.sh new file mode 100644 index 0000000..1860ea4 --- /dev/null +++ b/features/src/wd/install.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# References: +# - https://github.com/shokkunrf/wd + +set -eu + +echo "Activating feature 'wd'" + +VERSION="${VERSION:-latest}" + +# Validate version format +if [ "$VERSION" != "latest" ]; then + case "$VERSION" in + v[0-9]*) ;; # e.g., v1.0.0, v1.1.1 + *) + echo "ERROR: Invalid version format: '$VERSION'" + echo "Expected 'latest' or a version tag (e.g., 'v1.1.0')." + exit 1 + ;; + esac +fi + +if [ "$VERSION" = "latest" ]; then + _url="https://github.com/shokkunrf/wd/releases/latest/download/install.sh" +else + _url="https://github.com/shokkunrf/wd/releases/download/$VERSION/install.sh" +fi + +if command -v curl >/dev/null 2>&1; then + curl -fsSL "$_url" | sh +elif command -v wget >/dev/null 2>&1; then + wget -qO- "$_url" | sh +else + echo "ERROR: curl or wget is required but not found!" + exit 1 +fi diff --git a/features/test/wd/devcontainer-base-alpine.sh b/features/test/wd/devcontainer-base-alpine.sh new file mode 120000 index 0000000..b9cd53f --- /dev/null +++ b/features/test/wd/devcontainer-base-alpine.sh @@ -0,0 +1 @@ +test-posix.sh \ No newline at end of file diff --git a/features/test/wd/devcontainer-base-debian.sh b/features/test/wd/devcontainer-base-debian.sh new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/features/test/wd/devcontainer-base-debian.sh @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/features/test/wd/official-debian.sh b/features/test/wd/official-debian.sh new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/features/test/wd/official-debian.sh @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/features/test/wd/scenarios.json b/features/test/wd/scenarios.json new file mode 100644 index 0000000..2e4be4c --- /dev/null +++ b/features/test/wd/scenarios.json @@ -0,0 +1,25 @@ +{ + "official-debian": { + "image": "debian:trixie", + "features": { + "ghcr.io/devcontainers/features/common-utils": {}, + "wd": {} + } + }, + "devcontainer-base-debian": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "wd": { + "version": "v1.1.1" + } + }, + "remoteUser": "vscode" + }, + "devcontainer-base-alpine": { + "image": "mcr.microsoft.com/devcontainers/base:alpine", + "features": { + "wd": {} + }, + "remoteUser": "vscode" + } +} diff --git a/features/test/wd/test-posix.sh b/features/test/wd/test-posix.sh new file mode 100644 index 0000000..306bee1 --- /dev/null +++ b/features/test/wd/test-posix.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# POSIX-compliant test script (no bash required) + +set -e + +FAILED="" + +check() { + LABEL="$1" + shift + printf '\n\n' + printf "🔄 Testing '%s'\n" "$LABEL" + printf '\033[37m\n' + if "$@"; then + printf '\n\n' + printf "✅ Passed '%s'!\n" "$LABEL" + return 0 + else + printf '\n\n' + printf "❌ %s check failed.\n" "$LABEL" >&2 + FAILED="$FAILED $LABEL" + return 1 + fi +} + +reportResults() { + printf '\n\n' + if [ -n "$FAILED" ]; then + printf "💥 Failed tests:%s\n" "$FAILED" >&2 + exit 1 + else + printf 'Test Passed!\n' + exit 0 + fi +} + +# Definition specific tests +check "wd is installed" wd --version + +# Report result +reportResults diff --git a/features/test/wd/test.sh b/features/test/wd/test.sh new file mode 100644 index 0000000..b928fad --- /dev/null +++ b/features/test/wd/test.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "wd is installed" wd --version + +# Report result +reportResults