Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions features/src/wd/README.md
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
```
15 changes: 15 additions & 0 deletions features/src/wd/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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"]
}
36 changes: 36 additions & 0 deletions features/src/wd/install.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions features/test/wd/devcontainer-base-alpine.sh
1 change: 1 addition & 0 deletions features/test/wd/devcontainer-base-debian.sh
1 change: 1 addition & 0 deletions features/test/wd/official-debian.sh
25 changes: 25 additions & 0 deletions features/test/wd/scenarios.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
41 changes: 41 additions & 0 deletions features/test/wd/test-posix.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions features/test/wd/test.sh
Original file line number Diff line number Diff line change
@@ -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