diff --git a/.github/workflows/test-pr.yaml b/.github/workflows/test-pr.yaml index bf3dd24..edb9292 100644 --- a/.github/workflows/test-pr.yaml +++ b/.github/workflows/test-pr.yaml @@ -19,6 +19,7 @@ jobs: devsense: ./**/devsense/** bicep-langserver: ./**/bicep-langserver/** jdtls: ./**/jdtls/** + yazi: ./**/yazi/** test: needs: [detect-changes] @@ -29,10 +30,8 @@ jobs: features: ${{ fromJSON(needs.detect-changes.outputs.features) }} baseImage: [ - "ubuntu:jammy", - "ubuntu:noble", - "debian:12", - "mcr.microsoft.com/devcontainers/base:ubuntu", + "mcr.microsoft.com/devcontainers/base:debian", + "mcr.microsoft.com/devcontainers/base:ubuntu" ] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1bd8e8c..8c31b2f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -17,14 +17,13 @@ jobs: "marksman", "devsense", "bicep-langserver", - "jdtls" + "jdtls", + "yazi" ] baseImage: [ - "ubuntu:jammy", - "ubuntu:noble", - "debian:12", - "mcr.microsoft.com/devcontainers/base:ubuntu", + "mcr.microsoft.com/devcontainers/base:debian", + "mcr.microsoft.com/devcontainers/base:ubuntu" ] steps: - uses: actions/checkout@v4 @@ -47,7 +46,8 @@ jobs: "marksman", "devsense", "bicep-langserver", - "jdtls" + "jdtls", + "yazi" ] steps: - uses: actions/checkout@v4 diff --git a/README.md b/README.md index e0437b3..0dcceb6 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,4 @@ This repository contains features to use within a devcontainer. Currently follow - [marksman](https://github.com/kreemer/features/blob/main/src/marksman/README.md) - [bicep-langserver](https://github.com/kreemer/features/blob/main/src/bicep-langserver/README.md) - [jdtls](https://github.com/kreemer/features/blob/main/src/jdtls/README.md) +- [yazi](https://github.com/kreemer/features/blob/main/src/yazi/README.md) diff --git a/src/yazi/NOTES.md b/src/yazi/NOTES.md new file mode 100644 index 0000000..7a7ac4c --- /dev/null +++ b/src/yazi/NOTES.md @@ -0,0 +1,5 @@ +## OS Support + +This Feature should work on recent versions of Debian/Ubuntu-based distributions with the `apt` package manager installed. + +`bash` is required to execute the `install.sh` script. diff --git a/src/yazi/README.md b/src/yazi/README.md new file mode 100644 index 0000000..cf92396 --- /dev/null +++ b/src/yazi/README.md @@ -0,0 +1,29 @@ + +# Helix (helix) + + + +## Example Usage + +```json +"features": { + "ghcr.io/kreemer/features/helix:1": {} +} +``` + +## Options + +| Options Id | Description | Type | Default Value | +|-----|-----|-----|-----| +| version | Select or enter a version. | string | latest | + +## OS Support + +This Feature should work on recent versions of Debian/Ubuntu-based distributions with the `apt` package manager installed. + +`bash` is required to execute the `install.sh` script. + + +--- + +_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/kreemer/features/blob/main/src/helix/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ diff --git a/src/yazi/devcontainer-feature.json b/src/yazi/devcontainer-feature.json new file mode 100644 index 0000000..9c5549e --- /dev/null +++ b/src/yazi/devcontainer-feature.json @@ -0,0 +1,19 @@ +{ + "id": "yazi", + "version": "1.0.0", + "name": "Yazi", + "documentationURL": "https://github.com/kreemer/features/tree/main/src/yazi", + "options": { + "version": { + "type": "string", + "proposals": [ + "latest" + ], + "default": "latest", + "description": "Select or enter a version." + } + }, + "installsAfter": [ + "ghcr.io/devcontainers/features/common-utils" + ] +} diff --git a/src/yazi/install.sh b/src/yazi/install.sh new file mode 100644 index 0000000..f7f887f --- /dev/null +++ b/src/yazi/install.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +VERSION="${VERSION:-"latest"}" + +USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}" + +set -e + +# Clean up +rm -rf /var/lib/apt/lists/* + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +# Ensure that login shells get the correct path if the user updated the PATH using ENV. +rm -f /etc/profile.d/00-restore-env.sh +echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh +chmod +x /etc/profile.d/00-restore-env.sh + +apt_get_update() +{ + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi +} + + +# Insall Helix if it's missing +if ! yazi -V &> /dev/null ; then + echo "Installing Yazi..." + apt_get_update + apt-get -y install --no-install-recommends jq curl unzip xz-utils ca-certificates libc6 + + if [[ "$VERSION" == "latest" || -z "$VERSION" ]]; then + echo "Fetching latest version..." + VERSION=$(curl -s -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/sxyazi/yazi/releases/latest | jq -r .tag_name ) + fi + + ARCHITECTURE=$(uname -m | sed 's/^arm64$/aarch64/') + IDENTIFIER="yazi-${ARCHITECTURE}-unknown-linux-gnu" + IDENTIFIER_ARCHIVE="${IDENTIFIER}.zip" + + DOWNLOAD_URL=$(curl -s -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/sxyazi/yazi/releases/tags/${VERSION}" | \ + jq -r '.assets | map(select(.name=="'"$IDENTIFIER_ARCHIVE"'"))[0].browser_download_url') + + + if [ -z "$DOWNLOAD_URL" ]; then + echo "Error: Unable to find download URL for $IDENTIFIER and version $VERSION" + exit 1 + fi + + echo "Downloading yazi from: ${DOWNLOAD_URL}" + + curl -s -L -o "/tmp/${IDENTIFIER_ARCHIVE}" "${DOWNLOAD_URL}" + cd /tmp + unzip "${IDENTIFIER_ARCHIVE}" + mv "/tmp/${IDENTIFIER}" /opt/yazi + ln -s /opt/yazi/yazi /usr/local/bin/yazi + + rm -f "/tmp/${IDENTIFIER_ARCHIVE}" +fi + +# Clean up +rm -rf /var/lib/apt/lists/* + +echo "Done!" diff --git a/test/yazi/install_yazi.sh b/test/yazi/install_yazi.sh new file mode 100644 index 0000000..f7f29d3 --- /dev/null +++ b/test/yazi/install_yazi.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Ensure extended version is installed +check "installed" bash -c "yazi -V | grep Yazi" + +# Report result +reportResults diff --git a/test/yazi/scenarios.json b/test/yazi/scenarios.json new file mode 100644 index 0000000..2d515fe --- /dev/null +++ b/test/yazi/scenarios.json @@ -0,0 +1,10 @@ +{ + "install_yazi": { + "image": "mcr.microsoft.com/devcontainers/base", + "features": { + "yazi": { + "version": "latest" + } + } + } +} diff --git a/test/yazi/test.sh b/test/yazi/test.sh new file mode 100644 index 0000000..292a72b --- /dev/null +++ b/test/yazi/test.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "version" yazi -V + +# Report result +reportResults