diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e629ab3..846235e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -57,6 +57,7 @@ jobs: - strix - colibri - gitai + - floci baseImage: - debian:latest - ubuntu:latest diff --git a/README.md b/README.md index cb9efb6..f90fe38 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ This repository contains a _collection_ of Features. | strix | https://github.com/usestrix/strix | Open-source AI penetration testing tool to find and fix your app's vulnerabilities. | | colibri | https://github.com/JustVugg/colibri | Run GLM-5.2 (744B MoE) on a consumer machine — pure C, zero deps, experts streamed from disk. | | gitai | https://github.com/git-ai-project/git-ai | A Git extension for tracking AI-generated code through every commit, merge, rebase, cherry-pick, etc. | +| floci | https://github.com/floci-io/floci-cli | Official CLI for managing Floci local cloud emulators. | @@ -809,3 +810,20 @@ Running `git-ai` inside the built container will print the version of the Git AI ```bash git-ai --version ``` + +### `floci` + +Running `floci` inside the built container provides the official CLI for managing Floci local cloud emulators. + +```jsonc +{ + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "ghcr.io/jsburckhardt/devcontainer-features/floci:1": {} + } +} +``` + +```bash +floci --version +``` diff --git a/src/floci/devcontainer-feature.json b/src/floci/devcontainer-feature.json new file mode 100644 index 0000000..ecb9b1b --- /dev/null +++ b/src/floci/devcontainer-feature.json @@ -0,0 +1,13 @@ +{ + "name": "floci", + "id": "floci", + "version": "1.0.0", + "description": "Official CLI for managing Floci local cloud emulators.", + "options": { + "version": { + "type": "string", + "default": "latest", + "description": "Version of floci to install (for example, latest or 0.2.3)." + } + } +} diff --git a/src/floci/install.sh b/src/floci/install.sh new file mode 100755 index 0000000..9bc942d --- /dev/null +++ b/src/floci/install.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Variables +REPO_OWNER="floci-io" +REPO_NAME="floci-cli" +BINARY_NAME="floci" +VERSION="${VERSION:-latest}" + +# Root check +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 + +# Clean up +rm -rf /var/lib/apt/lists/* + +check_packages() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists -mindepth 1 -maxdepth 1 | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi + apt-get -y install --no-install-recommends "$@" + fi +} + +# Ensure required packages are installed +check_packages curl jq ca-certificates + +# Query the latest GitHub release, falling back to the releases list if needed. +get_latest_version() { + local response version + + response="$(curl -fsSL "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest" || true)" + version="$(printf '%s' "$response" | jq -r '.tag_name // empty' 2>/dev/null || true)" + + if [ -z "$version" ]; then + response="$(curl -fsSL "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases?per_page=1" || true)" + version="$(printf '%s' "$response" | jq -r '.[0].tag_name // empty' 2>/dev/null || true)" + fi + + printf '%s\n' "$version" +} + +# Resolve version +if [ -z "$VERSION" ] || [ "$VERSION" = "latest" ]; then + VERSION="$(get_latest_version)" + if [ -z "$VERSION" ]; then + echo "Failed to resolve the latest floci version from the GitHub API." >&2 + exit 1 + fi + echo "No version provided or latest specified, installing the latest version: $VERSION" +else + echo "Installing floci version: $VERSION" +fi + +# Upstream publishes floci-{linux,darwin}-{amd64,arm64} binaries. +OS_RAW="$(uname -s)" +case "$OS_RAW" in + Linux) OS="linux" ;; + Darwin) OS="darwin" ;; + *) echo "Unsupported OS: $OS_RAW" >&2; exit 1 ;; +esac + +ARCH_RAW="$(uname -m)" +case "$ARCH_RAW" in + x86_64|amd64) ARCH="amd64" ;; + aarch64|arm64) ARCH="arm64" ;; + *) echo "Unsupported architecture: $ARCH_RAW" >&2; exit 1 ;; +esac + +ASSET_NAME="${BINARY_NAME}-${OS}-${ARCH}" +DOWNLOAD_URL="https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/${VERSION}/${ASSET_NAME}" +TMP_DIR="$(mktemp -d)" + +cleanup() { + rm -rf "$TMP_DIR" + rm -rf /var/lib/apt/lists/* +} +trap cleanup EXIT + +cd "$TMP_DIR" +echo "Downloading $BINARY_NAME from $DOWNLOAD_URL" +curl -fsSL -o "$BINARY_NAME" "$DOWNLOAD_URL" +chmod +x "$BINARY_NAME" +mv "$BINARY_NAME" /usr/local/bin/ + +# Verify installation +echo "Verifying installation" +"$BINARY_NAME" --version diff --git a/test/_global/all-tools.sh b/test/_global/all-tools.sh index 726fa82..647a221 100755 --- a/test/_global/all-tools.sh +++ b/test/_global/all-tools.sh @@ -46,5 +46,6 @@ check "officecli" officecli --version check "strix" strix --version check "colibri" bash -c "command -v colibri" check "gitai" git-ai --version +check "floci" floci --version reportResults diff --git a/test/_global/floci-specific-version.sh b/test/_global/floci-specific-version.sh new file mode 100755 index 0000000..dd1a3ea --- /dev/null +++ b/test/_global/floci-specific-version.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +source dev-container-features-test-lib + +check "floci with specific version" /bin/bash -c "floci --version | grep 'floci 0.2.3'" + +reportResults diff --git a/test/_global/scenarios.json b/test/_global/scenarios.json index f1dd3ab..a914909 100644 --- a/test/_global/scenarios.json +++ b/test/_global/scenarios.json @@ -47,7 +47,8 @@ "officecli": {}, "strix": {}, "colibri": {}, - "gitai": {} + "gitai": {}, + "floci": {} } }, "flux-specific-version": { @@ -399,5 +400,13 @@ "version": "v1.6.21" } } + }, + "floci-specific-version": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "floci": { + "version": "0.2.3" + } + } } } diff --git a/test/floci/test.sh b/test/floci/test.sh new file mode 100755 index 0000000..63373fa --- /dev/null +++ b/test/floci/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +source dev-container-features-test-lib + +check "floci" floci --version + +reportResults