feat(installer): install via managed manifest with non-interactive params (Bash)
Bash equivalent of the PowerShell installer change: delegates to sync_managed_destination, adds --client/--platform for non-interactive runs (falling back to the existing interactive prompts when omitted), and requires --update-plugins to update already-installed plugins instead of doing so by default. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
f72af0ee39
commit
e617a2477a
+49
-44
@@ -2,71 +2,76 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
dry_run=false
|
dry_run=false
|
||||||
for argument in "$@"; do
|
client=""
|
||||||
[ "$argument" != "--dry-run" ] || dry_run=true
|
platform=""
|
||||||
|
update_plugins=false
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
--dry-run) dry_run=true; shift ;;
|
||||||
|
--update-plugins) update_plugins=true; shift ;;
|
||||||
|
--client) client=${2:?--client requires a value}; shift 2 ;;
|
||||||
|
--platform) platform=${2:?--platform requires a value}; shift 2 ;;
|
||||||
|
*) printf 'Unknown argument: %s\n' "$1" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
|
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
|
||||||
. "$root/scripts/lib/plugins.sh"
|
. "$root/scripts/lib/plugins.sh"
|
||||||
|
. "$root/scripts/lib/manifest.sh"
|
||||||
bash "$root/scripts/build.sh"
|
bash "$root/scripts/build.sh"
|
||||||
generated="$root/generated"
|
generated="$root/generated"
|
||||||
[ -d "$generated" ] || { printf 'Generated output is missing after a successful build.\n' >&2; exit 1; }
|
[ -d "$generated" ] || { printf 'Generated output is missing after a successful build.\n' >&2; exit 1; }
|
||||||
|
|
||||||
printf 'Select target platform:\n1) Windows\n2) Linux\n'
|
if [ -z "$platform" ]; then
|
||||||
while :; do
|
printf 'Select target platform:\n1) Windows\n2) Linux\n'
|
||||||
|
while :; do
|
||||||
read -r -p 'Selection [1-2] ' platform_selection
|
read -r -p 'Selection [1-2] ' platform_selection
|
||||||
case "$platform_selection" in 1) platform=windows; break;; 2) platform=linux; break;; esac
|
case "$platform_selection" in 1) platform=windows; break;; 2) platform=linux; break;; esac
|
||||||
done
|
done
|
||||||
printf 'Select installation target:\n1) Codex\n2) Claude\n3) Both\n'
|
else
|
||||||
while :; do
|
case "$platform" in
|
||||||
|
windows|Windows) platform=windows ;;
|
||||||
|
linux|Linux) platform=linux ;;
|
||||||
|
*) printf 'Unknown --platform value: %s (expected windows or linux)\n' "$platform" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$client" ]; then
|
||||||
|
printf 'Select installation target:\n1) Codex\n2) Claude\n3) Both\n'
|
||||||
|
while :; do
|
||||||
read -r -p 'Selection [1-3] ' selection
|
read -r -p 'Selection [1-3] ' selection
|
||||||
case "$selection" in 1|2|3) break;; esac
|
case "$selection" in 1) client=codex; break;; 2) client=claude; break;; 3) client=both; break;; esac
|
||||||
done
|
done
|
||||||
|
else
|
||||||
|
case "$client" in
|
||||||
|
codex|Codex) client=codex ;;
|
||||||
|
claude|Claude) client=claude ;;
|
||||||
|
both|Both) client=both ;;
|
||||||
|
*) printf 'Unknown --client value: %s (expected codex, claude, or both)\n' "$client" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
stamp=$(date +%Y%m%d-%H%M%S)
|
stamp=$(date +%Y%m%d-%H%M%S)
|
||||||
home_path=${HOME:?HOME is required}
|
home_path=${HOME:?HOME is required}
|
||||||
|
shell_command=bash
|
||||||
|
windows_shell_command='powershell -NoProfile -ExecutionPolicy Bypass -File'
|
||||||
|
|
||||||
targets=()
|
targets=()
|
||||||
case "$selection" in
|
case "$client" in
|
||||||
1|3) targets+=("$generated/codex-$platform|$home_path/.codex" "$generated/codex-$platform/skills|$home_path/.agents/skills");;
|
codex|both) targets+=("$generated/codex-$platform|$home_path/.codex" "$generated/codex-$platform/skills|$home_path/.agents/skills");;
|
||||||
esac
|
esac
|
||||||
case "$selection" in
|
case "$client" in
|
||||||
2|3) targets+=("$generated/claude-$platform|$home_path/.claude");;
|
claude|both) targets+=("$generated/claude-$platform|$home_path/.claude");;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
for target_pair in "${targets[@]}"; do
|
for target_pair in "${targets[@]}"; do
|
||||||
source=${target_pair%%|*}
|
source=${target_pair%%|*}
|
||||||
destination=${target_pair#*|}
|
destination=${target_pair#*|}
|
||||||
while IFS= read -r -d '' source_file; do
|
ai_config_root=$destination
|
||||||
relative=${source_file#"$source/"}
|
command -v cygpath >/dev/null && ai_config_root=$(cygpath -m "$destination")
|
||||||
target="$destination/$relative"
|
sync_managed_destination "$source" "$destination" "$stamp" "$ai_config_root" "$shell_command" "$windows_shell_command" "$dry_run"
|
||||||
if "$dry_run"; then printf 'DRYRUN %s -> %s\n' "$source_file" "$target"; continue; fi
|
|
||||||
if [ -f "$target" ]; then
|
|
||||||
backup="$destination/backups/$relative.$stamp"
|
|
||||||
mkdir -p "$(dirname -- "$backup")"
|
|
||||||
cp "$target" "$backup"
|
|
||||||
fi
|
|
||||||
mkdir -p "$(dirname -- "$target")"
|
|
||||||
content=$(<"$source_file")
|
|
||||||
if [[ "$content" == *'__AI_CONFIG_ROOT__'* || "$content" == *'__HOOK_COMMAND__'* || "$content" == *'__WINDOWS_HOOK_COMMAND__'* ]]; then
|
|
||||||
replacement=$destination
|
|
||||||
if command -v cygpath >/dev/null; then replacement=$(cygpath -m "$destination"); fi
|
|
||||||
content=${content//__AI_CONFIG_ROOT__/$replacement}
|
|
||||||
content=${content//__HOOK_COMMAND__/bash}
|
|
||||||
content=${content//__WINDOWS_HOOK_COMMAND__/bash}
|
|
||||||
content=${content//__HOOK_SCRIPT__/flashbang.sh}
|
|
||||||
content=${content//__WINDOWS_HOOK_SCRIPT__/flashbang.sh}
|
|
||||||
printf '%s' "$content" > "$target"
|
|
||||||
else
|
|
||||||
cp "$source_file" "$target"
|
|
||||||
fi
|
|
||||||
printf 'INSTALL %s\n' "$target"
|
|
||||||
done < <(find "$source" -type f -print0)
|
|
||||||
done
|
done
|
||||||
|
|
||||||
client_selection=both
|
install_configured_plugins "$root" "$client" "$dry_run" "$update_plugins"
|
||||||
case "$selection" in
|
|
||||||
1) client_selection=codex;;
|
|
||||||
2) client_selection=claude;;
|
|
||||||
esac
|
|
||||||
install_configured_plugins "$root" "$client_selection" "$dry_run" true
|
|
||||||
|
|
||||||
if "$dry_run"; then printf 'PASS install dry-run\n'; else printf 'PASS install\n'; fi
|
if "$dry_run"; then printf 'PASS install dry-run\n'; else printf 'PASS install\n'; fi
|
||||||
|
|||||||
Reference in New Issue
Block a user