Copying the repo's settings.json over ~/.claude/settings.json would delete most of the operator's settings, so the installer now merges it. The merge and the new settings land together, so no overwriting installer ever deploys them. The merge runs before any other file is deployed, so an invalid settings file stops the install with nothing changed. It writes a complete temporary file and renames it, so a failure cannot truncate the user's settings. Impact: removing a setting from the repo no longer removes it from a machine that already has it. ADR: 0035 Refs: #280 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
63 lines
1.9 KiB
Bash
Executable File
63 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
# shellcheck source=scripts/deploy-manifest.sh
|
|
source "$REPO_ROOT/scripts/deploy-manifest.sh"
|
|
|
|
echo "Installing from $REPO_ROOT..."
|
|
|
|
# First, so an unmergeable file stops the install before anything is deployed.
|
|
for entry in "${DEPLOY_JSON_MERGES[@]}"; do
|
|
dest="$HOME/${entry##*:}"
|
|
mkdir -p "$(dirname "$dest")"
|
|
python3 "$REPO_ROOT/scripts/merge-json.py" "$REPO_ROOT/${entry%%:*}" "$dest"
|
|
done
|
|
|
|
for entry in "${DEPLOY_FILES[@]}"; do
|
|
dest="$HOME/${entry##*:}"
|
|
mkdir -p "$(dirname "$dest")"
|
|
cp "$REPO_ROOT/${entry%%:*}" "$dest"
|
|
done
|
|
|
|
for entry in "${DEPLOY_EXECUTABLES[@]}"; do
|
|
dest="$HOME/${entry##*:}"
|
|
mkdir -p "$(dirname "$dest")"
|
|
cp "$REPO_ROOT/${entry%%:*}" "$dest"
|
|
chmod +x "$dest"
|
|
done
|
|
|
|
for entry in "${DEPLOY_DIRS[@]}"; do
|
|
dest="$HOME/${entry##*:}"
|
|
rm -rf "$dest"
|
|
mkdir -p "$dest"
|
|
cp -r "$REPO_ROOT/${entry%%:*}/." "$dest/"
|
|
done
|
|
|
|
# Install git hooks into the current repo checkout
|
|
HOOKS_SRC="$REPO_ROOT/scripts/git-hooks"
|
|
if [[ -d "$HOOKS_SRC" ]]; then
|
|
# Unset inherited GIT_DIR/GIT_WORK_TREE — set by git when this script runs as
|
|
# a hook (e.g. pre-push), they override -C's directory-based discovery and
|
|
# would resolve against the invoking repo instead of $REPO_ROOT.
|
|
GIT_HOOKS_DIR="$(env -u GIT_DIR -u GIT_WORK_TREE git -C "$REPO_ROOT" rev-parse --git-path hooks)"
|
|
[[ "$GIT_HOOKS_DIR" = /* ]] || GIT_HOOKS_DIR="$REPO_ROOT/$GIT_HOOKS_DIR"
|
|
mkdir -p "$GIT_HOOKS_DIR"
|
|
for hook_file in "$HOOKS_SRC"/*; do
|
|
[[ -f "$hook_file" ]] || continue
|
|
hook_name="$(basename "$hook_file")"
|
|
dest_hook="$GIT_HOOKS_DIR/$hook_name"
|
|
cp "$hook_file" "$dest_hook"
|
|
chmod +x "$dest_hook"
|
|
done
|
|
fi
|
|
|
|
echo ""
|
|
echo "Deployed:"
|
|
for entry in "${DEPLOY_FILES[@]}" "${DEPLOY_JSON_MERGES[@]}" "${DEPLOY_EXECUTABLES[@]}"; do
|
|
echo " ~/${entry##*:}"
|
|
done
|
|
for entry in "${DEPLOY_DIRS[@]}"; do
|
|
echo " ~/${entry##*:}/"
|
|
done
|