smart_ide/scripts/install-anythingllm-post-merge-hook.sh
Nicolas Cantu 088eab84b7 Platform docs, services, ia_dev submodule, smart_ide project config
- Add ia_dev submodule (projects/smart_ide on forge 4nk)
- Document APIs, orchestrator, gateway, local-office, rollout
- Add systemd/scripts layout; relocate setup scripts
- Remove obsolete nginx/enso-only docs from this repo scope
2026-04-03 16:07:58 +02:00

43 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <path-to-git-repo> [<path-to-smart_ide>]" >&2
exit 1
fi
REPO=$(cd "$1" && pwd)
SMART_IDE_ROOT=${2:-}
if [[ -z "$SMART_IDE_ROOT" ]]; then
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
SMART_IDE_ROOT=$(cd "$SCRIPT_DIR/.." && pwd)
fi
SYNC_DIR="$SMART_IDE_ROOT/scripts/anythingllm-pull-sync"
HOOK="$REPO/.git/hooks/post-merge"
if [[ ! -d "$REPO/.git" ]]; then
echo "Not a git repository: $REPO" >&2
exit 1
fi
if [[ ! -f "$SYNC_DIR/sync.mjs" ]]; then
echo "Missing $SYNC_DIR/sync.mjs" >&2
exit 1
fi
mkdir -p "$(dirname "$HOOK")"
cat >"$HOOK" <<EOF
#!/usr/bin/env sh
# Installed by install-anythingllm-post-merge-hook.sh — AnythingLLM upload after pull (post-merge)
REPO_ROOT=\$(git rev-parse --show-toplevel)
if [ -f "\${HOME}/.config/4nk/anythingllm-sync.env" ]; then
# shellcheck source=/dev/null
. "\${HOME}/.config/4nk/anythingllm-sync.env"
fi
exec node "$SYNC_DIR/sync.mjs" --repo-root "\$REPO_ROOT"
EOF
chmod +x "$HOOK"
echo "Installed post-merge hook: $HOOK"
echo "Run: (cd $SYNC_DIR && npm install) if node_modules is missing."