From 45224cd7955a463dfc2ce77a3798f5139acf9aa2 Mon Sep 17 00:00:00 2001 From: Ross Miles <78015348+rosstaco@users.noreply.github.com> Date: Sat, 15 Nov 2025 12:10:03 +0000 Subject: [PATCH 1/3] Add prompty-dumpty feature with installation scripts and tests - Implemented installation script for prompty-dumpty CLI tool - Added devcontainer-feature.json and README for feature documentation - Created test scripts for Alpine and Debian environments - Updated scenarios.json to include testing configurations - Enhanced .gitignore and devcontainer.json for new feature integration --- .devcontainer/devcontainer.json | 5 +- .gitignore | 1 + docs/prompty-dumpty-plan.md | 17 ++++ src/prompty-dumpty/README.md | 37 +++++++++ src/prompty-dumpty/devcontainer-feature.json | 14 ++++ src/prompty-dumpty/install.sh | 83 ++++++++++++++++++++ test/prompty-dumpty/alpine.sh | 15 ++++ test/prompty-dumpty/debian.sh | 15 ++++ test/prompty-dumpty/scenarios.json | 22 ++++++ test/prompty-dumpty/test.sh | 25 ++++++ test/prompty-dumpty/version.sh | 15 ++++ 11 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 docs/prompty-dumpty-plan.md create mode 100644 src/prompty-dumpty/README.md create mode 100644 src/prompty-dumpty/devcontainer-feature.json create mode 100755 src/prompty-dumpty/install.sh create mode 100755 test/prompty-dumpty/alpine.sh create mode 100755 test/prompty-dumpty/debian.sh create mode 100644 test/prompty-dumpty/scenarios.json create mode 100755 test/prompty-dumpty/test.sh create mode 100755 test/prompty-dumpty/version.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7201fd5..dbf002a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -19,7 +19,10 @@ }, "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {}, - "ghcr.io/jsburckhardt/devcontainer-features/just:1": {} + "ghcr.io/jsburckhardt/devcontainer-features/just:1": {}, + "ghcr.io/rosstaco/devcontainer-features/microsoft-security-devops-cli:1": { + "version": "latest" + } }, "remoteUser": "node", "updateContentCommand": "npm install -g @devcontainers/cli" diff --git a/.gitignore b/.gitignore index 56aa77b..4216330 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ # Feature tarballs for local testing .devcontainer/*.tgz +.DS_Store \ No newline at end of file diff --git a/docs/prompty-dumpty-plan.md b/docs/prompty-dumpty-plan.md new file mode 100644 index 0000000..75e541a --- /dev/null +++ b/docs/prompty-dumpty-plan.md @@ -0,0 +1,17 @@ +# Plan: prompty-dumpty DevContainer Feature + +Install prompty-dumpty (v0.6.2 current) Python package system-wide using pip3 with `--break-system-packages` flag. The CLI command `dumpty` will be available globally after installation. + +## Steps + +1. **Create feature structure** at `src/prompty-dumpty/` with `devcontainer-feature.json` (id: "prompty-dumpty", version option only with default "latest", no `installsAfter` or installPath), `README.md` documenting the `dumpty` command, and `.gitignore` + +2. **Write install script** at `src/prompty-dumpty/install.sh` with `set -e` for fail-fast behavior, detect package manager (apt/apk/yum), install `python3-pip` if missing, run `pip3 install prompty-dumpty --break-system-packages` (latest) or `pip3 install prompty-dumpty==VERSION --break-system-packages` (specific version like 0.6.2) + +3. **Add verification and output** using `command -v dumpty` to verify installation, run `dumpty --version`, display colored success message with installation details following `src/microsoft-security-devops-cli/install.sh` colored output pattern + +4. **Create test suite** at `test/prompty-dumpty/` with `test.sh` (installs latest, verifies `dumpty` exists), `version.sh` (installs version 0.6.2 specifically), and `scenarios.json` testing both scenarios on debian/ubuntu base images + +## Further Considerations + +None - ready to implement with fail-fast on errors and pip's default install paths. diff --git a/src/prompty-dumpty/README.md b/src/prompty-dumpty/README.md new file mode 100644 index 0000000..55dc1f9 --- /dev/null +++ b/src/prompty-dumpty/README.md @@ -0,0 +1,37 @@ + +# Prompty Dumpty (prompty-dumpty) + +Installs prompty-dumpty CLI tool for managing prompty files + +## Example Usage + +```json +"features": { + "ghcr.io/rosstaco/devcontainer-features/prompty-dumpty:1": {} +} +``` + +## Options + +| Options Id | Description | Type | Default Value | +|-----|-----|-----|-----| +| version | Version of prompty-dumpty to install. Use 'latest' or a specific version like '0.6.2' | string | latest | + +## Usage + +After installation, the `dumpty` command will be available: + +```bash +dumpty --help +dumpty --version +``` + +## Notes + +This feature installs prompty-dumpty system-wide using pip3 with the `--break-system-packages` flag, which is appropriate for containerized development environments. Python 3 is assumed to be present in the base image. + +For more information about prompty-dumpty, visit: https://pypi.org/project/prompty-dumpty/ + +--- + +_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/rosstaco/devcontainer-features/blob/main/src/prompty-dumpty/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ diff --git a/src/prompty-dumpty/devcontainer-feature.json b/src/prompty-dumpty/devcontainer-feature.json new file mode 100644 index 0000000..60221ff --- /dev/null +++ b/src/prompty-dumpty/devcontainer-feature.json @@ -0,0 +1,14 @@ +{ + "id": "prompty-dumpty", + "version": "1.0.0", + "name": "Prompty Dumpty", + "description": "Installs prompty-dumpty CLI tool for managing prompty files", + "documentationURL": "https://github.com/rosstaco/devcontainer-features/tree/main/src/prompty-dumpty", + "options": { + "version": { + "type": "string", + "default": "latest", + "description": "Version of prompty-dumpty to install. Use 'latest' or a specific version like '0.6.2'" + } + } +} diff --git a/src/prompty-dumpty/install.sh b/src/prompty-dumpty/install.sh new file mode 100755 index 0000000..c55198f --- /dev/null +++ b/src/prompty-dumpty/install.sh @@ -0,0 +1,83 @@ +#!/bin/bash +set -e + +# Prompty Dumpty installation script for devcontainer features +# https://pypi.org/project/prompty-dumpty/ + +VERSION="${VERSION:-latest}" + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +echo -e "${GREEN}Installing prompty-dumpty...${NC}" + +# Ensure pip is available +if ! command -v pip3 &> /dev/null; then + echo "Installing python3-pip..." + export DEBIAN_FRONTEND=noninteractive + if command -v apt-get &> /dev/null; then + apt-get update && apt-get install -y --no-install-recommends python3-pip + elif command -v apk &> /dev/null; then + apk add --no-cache py3-pip + elif command -v yum &> /dev/null; then + yum install -y python3-pip + else + echo -e "${RED}Could not install python3-pip. Please install it manually.${NC}" + exit 1 + fi +fi + +# Build pip install command +if [ "$VERSION" = "latest" ]; then + echo "Installing latest version..." + PIP_PACKAGE="prompty-dumpty" +else + echo "Installing version: $VERSION" + PIP_PACKAGE="prompty-dumpty==$VERSION" +fi + +# Check if pip supports --break-system-packages flag (pip >= 23.0) +PIP_SUPPORTS_BREAK_SYSTEM=$(pip3 install --help 2>&1 | grep -q "break-system-packages" && echo "yes" || echo "no") + +# Install prompty-dumpty with appropriate flags +if [ "$PIP_SUPPORTS_BREAK_SYSTEM" = "yes" ]; then + echo "Running: pip3 install $PIP_PACKAGE --break-system-packages" + if ! pip3 install "$PIP_PACKAGE" --break-system-packages; then + echo -e "${RED}Failed to install prompty-dumpty${NC}" + exit 1 + fi +else + echo "Running: pip3 install $PIP_PACKAGE" + if ! pip3 install "$PIP_PACKAGE"; then + echo -e "${RED}Failed to install prompty-dumpty${NC}" + exit 1 + fi +fi + +echo -e "${GREEN}prompty-dumpty installed successfully${NC}" + +# Verify installation +if ! command -v dumpty &> /dev/null; then + echo -e "${YELLOW}Warning: dumpty command not found in PATH${NC}" + echo -e "${YELLOW}You may need to restart your shell or source your shell configuration${NC}" +else + echo -e "${GREEN}dumpty installation verified successfully${NC}" + + # Try to get version info + if dumpty --version &> /dev/null; then + INSTALLED_VERSION=$(dumpty --version 2>&1 || echo "version unknown") + echo "Installed version: $INSTALLED_VERSION" + fi +fi + +echo "" +echo -e "${GREEN}========================================${NC}" +echo -e "${GREEN}Installation complete!${NC}" +echo -e "${GREEN}========================================${NC}" +echo "" +echo "The 'dumpty' command is now available." +echo "" +echo "For more information: https://pypi.org/project/prompty-dumpty/" diff --git a/test/prompty-dumpty/alpine.sh b/test/prompty-dumpty/alpine.sh new file mode 100755 index 0000000..a09a2b4 --- /dev/null +++ b/test/prompty-dumpty/alpine.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# This test verifies prompty-dumpty works on Alpine + +set -e + +source dev-container-features-test-lib + +check "dumpty is installed" which dumpty + +check "dumpty is executable" bash -c "command -v dumpty" + +check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" + +reportResults diff --git a/test/prompty-dumpty/debian.sh b/test/prompty-dumpty/debian.sh new file mode 100755 index 0000000..35f0f20 --- /dev/null +++ b/test/prompty-dumpty/debian.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# This test verifies prompty-dumpty works on Debian + +set -e + +source dev-container-features-test-lib + +check "dumpty is installed" which dumpty + +check "dumpty is executable" bash -c "command -v dumpty" + +check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" + +reportResults diff --git a/test/prompty-dumpty/scenarios.json b/test/prompty-dumpty/scenarios.json new file mode 100644 index 0000000..db67976 --- /dev/null +++ b/test/prompty-dumpty/scenarios.json @@ -0,0 +1,22 @@ +{ + "version": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "prompty-dumpty": { + "version": "0.6.2" + } + } + }, + "debian": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "prompty-dumpty": {} + } + }, + "alpine": { + "image": "mcr.microsoft.com/devcontainers/base:alpine", + "features": { + "prompty-dumpty": {} + } + } +} diff --git a/test/prompty-dumpty/test.sh b/test/prompty-dumpty/test.sh new file mode 100755 index 0000000..a70d0fa --- /dev/null +++ b/test/prompty-dumpty/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# This test file will be executed against an auto-generated devcontainer.json that +# includes the 'prompty-dumpty' Feature with no options. +# +# Thus, the value of all options will fall back to the default value in the +# Feature's 'devcontainer-feature.json'. +# +# These scripts are run as 'root' by default. Although that can be changed +# with the '--remote-user' flag. + +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +# Feature-specific tests +check "dumpty is installed" which dumpty + +check "dumpty is executable" bash -c "command -v dumpty" + +check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" + +# Report results +reportResults diff --git a/test/prompty-dumpty/version.sh b/test/prompty-dumpty/version.sh new file mode 100755 index 0000000..0bee446 --- /dev/null +++ b/test/prompty-dumpty/version.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# This test verifies that a specific version can be installed + +set -e + +source dev-container-features-test-lib + +check "dumpty is installed" which dumpty + +check "dumpty is executable" bash -c "command -v dumpty" + +check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" + +reportResults From 1673afc59d3ed2cc500e36a8e964bea38401a484 Mon Sep 17 00:00:00 2001 From: Ross Miles <78015348+rosstaco@users.noreply.github.com> Date: Sat, 15 Nov 2025 12:12:25 +0000 Subject: [PATCH 2/3] Add prompty-dumpty to CI test feature matrix --- .github/workflows/test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b34cf22..3921583 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,6 +15,7 @@ jobs: features: - ohmyposh - microsoft-security-devops-cli + - prompty-dumpty baseImage: - debian:latest - ubuntu:latest @@ -36,6 +37,7 @@ jobs: features: - ohmyposh - microsoft-security-devops-cli + - prompty-dumpty steps: - uses: actions/checkout@v4 From 78b8c634220ab90fd9ab029a6e5f1f545c4b7d74 Mon Sep 17 00:00:00 2001 From: Ross Miles <78015348+rosstaco@users.noreply.github.com> Date: Sat, 15 Nov 2025 12:20:00 +0000 Subject: [PATCH 3/3] Fix Copilot review feedback: remove redundant checks and fix set -e compatibility --- .devcontainer/devcontainer.json | 5 +---- src/prompty-dumpty/install.sh | 11 ++++++++--- test/prompty-dumpty/alpine.sh | 2 -- test/prompty-dumpty/debian.sh | 2 -- test/prompty-dumpty/test.sh | 2 -- test/prompty-dumpty/version.sh | 2 -- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index dbf002a..7201fd5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -19,10 +19,7 @@ }, "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {}, - "ghcr.io/jsburckhardt/devcontainer-features/just:1": {}, - "ghcr.io/rosstaco/devcontainer-features/microsoft-security-devops-cli:1": { - "version": "latest" - } + "ghcr.io/jsburckhardt/devcontainer-features/just:1": {} }, "remoteUser": "node", "updateContentCommand": "npm install -g @devcontainers/cli" diff --git a/src/prompty-dumpty/install.sh b/src/prompty-dumpty/install.sh index c55198f..c3b0f13 100755 --- a/src/prompty-dumpty/install.sh +++ b/src/prompty-dumpty/install.sh @@ -40,7 +40,11 @@ else fi # Check if pip supports --break-system-packages flag (pip >= 23.0) -PIP_SUPPORTS_BREAK_SYSTEM=$(pip3 install --help 2>&1 | grep -q "break-system-packages" && echo "yes" || echo "no") +if pip3 install --help 2>&1 | grep -q "break-system-packages"; then + PIP_SUPPORTS_BREAK_SYSTEM="yes" +else + PIP_SUPPORTS_BREAK_SYSTEM="no" +fi # Install prompty-dumpty with appropriate flags if [ "$PIP_SUPPORTS_BREAK_SYSTEM" = "yes" ]; then @@ -67,9 +71,10 @@ else echo -e "${GREEN}dumpty installation verified successfully${NC}" # Try to get version info - if dumpty --version &> /dev/null; then - INSTALLED_VERSION=$(dumpty --version 2>&1 || echo "version unknown") + if INSTALLED_VERSION=$(dumpty --version 2>&1); then echo "Installed version: $INSTALLED_VERSION" + else + echo "Installed version: version check failed" fi fi diff --git a/test/prompty-dumpty/alpine.sh b/test/prompty-dumpty/alpine.sh index a09a2b4..6f97639 100755 --- a/test/prompty-dumpty/alpine.sh +++ b/test/prompty-dumpty/alpine.sh @@ -6,8 +6,6 @@ set -e source dev-container-features-test-lib -check "dumpty is installed" which dumpty - check "dumpty is executable" bash -c "command -v dumpty" check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" diff --git a/test/prompty-dumpty/debian.sh b/test/prompty-dumpty/debian.sh index 35f0f20..a8a8ad1 100755 --- a/test/prompty-dumpty/debian.sh +++ b/test/prompty-dumpty/debian.sh @@ -6,8 +6,6 @@ set -e source dev-container-features-test-lib -check "dumpty is installed" which dumpty - check "dumpty is executable" bash -c "command -v dumpty" check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" diff --git a/test/prompty-dumpty/test.sh b/test/prompty-dumpty/test.sh index a70d0fa..101731b 100755 --- a/test/prompty-dumpty/test.sh +++ b/test/prompty-dumpty/test.sh @@ -15,8 +15,6 @@ set -e source dev-container-features-test-lib # Feature-specific tests -check "dumpty is installed" which dumpty - check "dumpty is executable" bash -c "command -v dumpty" check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" diff --git a/test/prompty-dumpty/version.sh b/test/prompty-dumpty/version.sh index 0bee446..535c4f6 100755 --- a/test/prompty-dumpty/version.sh +++ b/test/prompty-dumpty/version.sh @@ -6,8 +6,6 @@ set -e source dev-container-features-test-lib -check "dumpty is installed" which dumpty - check "dumpty is executable" bash -c "command -v dumpty" check "dumpty version command works" bash -c "dumpty --version 2>&1 || true"