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 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..c3b0f13 --- /dev/null +++ b/src/prompty-dumpty/install.sh @@ -0,0 +1,88 @@ +#!/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) +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 + 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 INSTALLED_VERSION=$(dumpty --version 2>&1); then + echo "Installed version: $INSTALLED_VERSION" + else + echo "Installed version: version check failed" + 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..6f97639 --- /dev/null +++ b/test/prompty-dumpty/alpine.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# This test verifies prompty-dumpty works on Alpine + +set -e + +source dev-container-features-test-lib + +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..a8a8ad1 --- /dev/null +++ b/test/prompty-dumpty/debian.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# This test verifies prompty-dumpty works on Debian + +set -e + +source dev-container-features-test-lib + +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..101731b --- /dev/null +++ b/test/prompty-dumpty/test.sh @@ -0,0 +1,23 @@ +#!/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 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..535c4f6 --- /dev/null +++ b/test/prompty-dumpty/version.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# This test verifies that a specific version can be installed + +set -e + +source dev-container-features-test-lib + +check "dumpty is executable" bash -c "command -v dumpty" + +check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" + +reportResults