Skip to content

Commit 93affb0

Browse files
Copilotjsburckhardt
andcommitted
feat: add just feature implementation
Co-authored-by: jsburckhardt <[email protected]>
1 parent 03ac79e commit 93affb0

9 files changed

Lines changed: 194 additions & 1 deletion

File tree

.github/workflows/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
- uv
2929
- codex
3030
- bat
31+
- just
3132
baseImage:
3233
- debian:latest
3334
- ubuntu:latest

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This repository contains a _collection_ of Features.
2121
| Gitleaks | https://gitleaks.io/ | Gitleaks is a SAST tool for detecting and preventing hardcoded secrets like passwords, api keys, and tokens in git repos. Gitleaks is an easy-to-use, all-in-one solution for detecting secrets, past or present, in your code. |
2222
| Zarf | https://zarf.dev/ | Zarf eliminates the complexity of air gap software delivery for Kubernetes clusters and cloud-native workloads using a declarative packaging strategy to support DevSecOps in offline and semi-connected environments. |
2323
| jnv | https://github.com/ynqa/jnv | jnv is designed for navigating JSON, offering an interactive JSON viewer and jq filter editor. |
24+
| just | https://github.com/casey/just | A command runner. Just is a handy way to save and run project-specific commands. |
2425
| UV/UVX | https://docs.astral.sh/uv/ | An extremely fast Python package and project manager, written in Rust. A single tool to replace pip, pip-tools, pipx, poetry, pyenv, virtualenv, and more. |
2526
| Ruff | https://docs.astral.sh/ruff/ | An extremely fast Python linter and code formatter, written in Rust. |
2627
| Codex-cli | https://github.com/openai/codex | Codex CLI is an experimental project under active development. |

src/just/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# just (just)
2+
3+
A command runner. Just is a handy way to save and run project-specific commands.
4+
5+
## Example Usage
6+
7+
```json
8+
"features": {
9+
"ghcr.io/jsburckhardt/devcontainer-features/just:1": {}
10+
}
11+
```
12+
13+
## Options
14+
15+
| Options Id | Description | Type | Default Value |
16+
|-----|-----|-----|-----|
17+
| version | Version of just to install from GitHub releases e.g. 1.22.0 | string | latest |
18+
19+
20+
21+
---
22+
23+
_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/jsburckhardt/devcontainer-features/blob/main/src/just/devcontainer-feature.json). Add additional notes to a `NOTES.md`._

src/just/devcontainer-feature.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "just",
3+
"id": "just",
4+
"version": "1.0.0",
5+
"description": "A command runner. Just is a handy way to save and run project-specific commands.",
6+
"options": {
7+
"version": {
8+
"type": "string",
9+
"default": "latest",
10+
"description": "Version of just to install from GitHub releases e.g. 1.22.0"
11+
}
12+
}
13+
}

src/just/install.sh

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/usr/bin/env bash
2+
3+
# Variables
4+
REPO_OWNER="casey"
5+
REPO_NAME="just"
6+
BINARY_NAME="just"
7+
JUST_VERSION="${VERSION:-"latest"}"
8+
GITHUB_API_REPO_URL="https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases"
9+
10+
set -e
11+
12+
if [ "$(id -u)" -ne 0 ]; then
13+
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
14+
exit 1
15+
fi
16+
17+
# Clean up
18+
rm -rf /var/lib/apt/lists/*
19+
20+
# Checks if packages are installed and installs them if not
21+
check_packages() {
22+
if ! dpkg -s "$@" >/dev/null 2>&1; then
23+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
24+
echo "Running apt-get update..."
25+
apt-get update -y
26+
fi
27+
apt-get -y install --no-install-recommends "$@"
28+
fi
29+
}
30+
31+
# Make sure we have curl and jq
32+
check_packages curl jq ca-certificates
33+
34+
# Function to get the latest version from GitHub API
35+
get_latest_version() {
36+
curl -s "${GITHUB_API_REPO_URL}/latest" | jq -r ".tag_name"
37+
}
38+
39+
# Check if a version is passed as an argument
40+
if [ -z "$JUST_VERSION" ] || [ "$JUST_VERSION" == "latest" ]; then
41+
# No version provided, get the latest version
42+
JUST_VERSION=$(get_latest_version)
43+
echo "No version provided or 'latest' specified, installing the latest version: $JUST_VERSION"
44+
else
45+
echo "Installing version from environment variable: $JUST_VERSION"
46+
fi
47+
48+
# Determine the OS and architecture
49+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
50+
ARCH=$(uname -m)
51+
52+
case "$ARCH" in
53+
x86_64)
54+
ARCH="x86_64"
55+
;;
56+
i686)
57+
ARCH="i686"
58+
;;
59+
aarch64)
60+
ARCH="aarch64"
61+
;;
62+
armv7l)
63+
ARCH="armv7"
64+
;;
65+
*)
66+
echo "ERROR: Unsupported architecture: $ARCH"
67+
exit 1
68+
;;
69+
esac
70+
71+
case "$OS" in
72+
linux)
73+
TARGET="${ARCH}-unknown-linux-musl"
74+
;;
75+
*)
76+
echo "ERROR: Unsupported OS: $OS"
77+
exit 1
78+
;;
79+
esac
80+
81+
# Construct download URL
82+
DOWNLOAD_URL="https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/${JUST_VERSION}/just-${JUST_VERSION}-${TARGET}.tar.gz"
83+
84+
echo "Downloading just from: ${DOWNLOAD_URL}"
85+
86+
# Create temporary directory
87+
TMP_DIR=$(mktemp -d)
88+
cd "$TMP_DIR"
89+
90+
# Download and extract
91+
curl -L -o "just.tar.gz" "${DOWNLOAD_URL}"
92+
tar -xzf "just.tar.gz"
93+
94+
# Find the extracted directory (it might be just 'just' or contain version info)
95+
EXTRACTED_DIR=$(find . -type d -name "*just*" | head -1)
96+
if [ -z "$EXTRACTED_DIR" ]; then
97+
# Maybe the binary is directly in the archive
98+
if [ -f "just" ]; then
99+
EXTRACTED_DIR="."
100+
else
101+
echo "ERROR: Could not find extracted just directory or binary"
102+
exit 1
103+
fi
104+
fi
105+
106+
# Move the binary to /usr/local/bin
107+
echo "Installing just..."
108+
if [ -f "${EXTRACTED_DIR}/just" ]; then
109+
mv "${EXTRACTED_DIR}/just" /usr/local/bin/
110+
elif [ -f "just" ]; then
111+
mv "just" /usr/local/bin/
112+
else
113+
echo "ERROR: Could not find just binary"
114+
exit 1
115+
fi
116+
117+
# Make sure it's executable
118+
chmod +x /usr/local/bin/just
119+
120+
# Cleanup
121+
cd - || exit
122+
rm -rf "$TMP_DIR"
123+
124+
# Clean up
125+
rm -rf /var/lib/apt/lists/*
126+
127+
# Verify installation
128+
echo "Verifying installation..."
129+
just --version
130+
131+
echo "Done!"

test/_global/all-tools.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ check "ruff" ruff --version
1616
check "jnv" jnv -V
1717
check "zarf" zarf version
1818
check "codex" codex --version
19+
check "just" just --version
1920

2021
reportResults
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e
4+
source dev-container-features-test-lib
5+
check "just with specific version" /bin/bash -c "just --version | grep '1.42.0'"
6+
7+
reportResults

test/_global/scenarios.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"skopeo": {},
1818
"uv": {},
1919
"zarf": {},
20-
"codex": {}
20+
"codex": {},
21+
"just": {}
2122
}
2223
},
2324
"flux-specific-version": {
@@ -129,5 +130,13 @@
129130
"version": "v0.25.0"
130131
}
131132
}
133+
},
134+
"just-specific-version": {
135+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
136+
"features": {
137+
"just": {
138+
"version": "1.42.0"
139+
}
140+
}
132141
}
133142
}

test/just/test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
check "just" just --version
7+
reportResults

0 commit comments

Comments
 (0)