From db60771c6a7abbabe9dc1e65649ca3d17e5ad8cd Mon Sep 17 00:00:00 2001 From: claude-hdb Date: Fri, 10 Jul 2026 20:40:07 +0000 Subject: [PATCH] feat: deployor dispatcher + dependency-free test harness --- bin/deployor | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ test/cli.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100755 bin/deployor create mode 100644 test/cli.sh diff --git a/bin/deployor b/bin/deployor new file mode 100755 index 0000000..ed41c69 --- /dev/null +++ b/bin/deployor @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/.." && pwd)" + +usage() { + cat <<'EOF' +usage: deployor [args] + +commands: + bootstrap [--hostname ] [--ts-tag ] + OS plumbing on a pristine Debian box: hardening, unattended-upgrades, + tailscale join. Prompts for a single-use tailnet pre-auth key + (TS_AUTHKEY env overrides the prompt). Run as root. + coolify install --version + Pinned Coolify install (AUTOUPDATE=false). Control-plane box only. + +install/upgrade: + curl -fsSL https://raw.githubusercontent.com/claude-hdb/deployor/main/install.sh | bash +EOF +} + +cmd="${1:-}" +case "$cmd" in + bootstrap) + shift + exec "$ROOT/commands/bootstrap.sh" "$@" + ;; + coolify) + shift + sub="${1:-}" + if [ "$sub" != "install" ]; then + usage >&2 + exit 2 + fi + shift + exec "$ROOT/commands/coolify-install.sh" "$@" + ;; + -h|--help|help) + usage + exit 0 + ;; + "") + usage >&2 + exit 2 + ;; + *) + printf 'deployor: unknown command: %s\n' "$cmd" >&2 + usage >&2 + exit 2 + ;; +esac diff --git a/test/cli.sh b/test/cli.sh new file mode 100644 index 0000000..cb5d25f --- /dev/null +++ b/test/cli.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# Dependency-free CLI assertions. Run: bash test/cli.sh +# Deliberately no `set -e` — the harness asserts on failing commands. +set -u +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +PASS=0 FAIL=0 + +# check +# Runs cmd, asserts exit code and (if non-empty) that combined output +# contains want_substr. +check() { + local desc="$1" want="$2" substr="$3"; shift 3 + local out rc + out="$("$@" 2>&1)"; rc=$? + if [ "$rc" -ne "$want" ]; then + echo "FAIL: $desc — exit $rc, wanted $want" + printf '%s\n' "$out" | sed 's/^/ /' + FAIL=$((FAIL + 1)); return + fi + if [ -n "$substr" ] && ! printf '%s' "$out" | grep -qF "$substr"; then + echo "FAIL: $desc — output missing '$substr'" + printf '%s\n' "$out" | sed 's/^/ /' + FAIL=$((FAIL + 1)); return + fi + echo "ok: $desc"; PASS=$((PASS + 1)) +} + +check "no args shows usage, exit 2" 2 "usage:" "$ROOT/bin/deployor" +check "--help exits 0" 0 "usage:" "$ROOT/bin/deployor" --help +check "help exits 0" 0 "usage:" "$ROOT/bin/deployor" help +check "unknown command exits 2" 2 "unknown command" "$ROOT/bin/deployor" frobnicate +check "bare coolify shows usage, exit 2" 2 "usage:" "$ROOT/bin/deployor" coolify + +echo "---" +echo "$PASS passed, $FAIL failed" +[ "$FAIL" -eq 0 ]