-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·40 lines (32 loc) · 1.1 KB
/
install.sh
File metadata and controls
executable file
·40 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
set -euo pipefail
REPO="https://github.com/xstelea/radix-context.git"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Remote mode: clone to temp dir when context/ isn't alongside script (e.g. curl | bash)
if [ ! -d "$SCRIPT_DIR/context" ]; then
_tmpdir=$(mktemp -d)
trap 'rm -rf "$_tmpdir"' EXIT
echo "Cloning radix-context..."
git clone --depth 1 "$REPO" "$_tmpdir/repo" >/dev/null 2>&1
SCRIPT_DIR="$_tmpdir/repo"
fi
TARGET="${1:-.}"
if [ ! -d "$TARGET" ]; then
echo "error: directory '$TARGET' does not exist"
exit 1
fi
TARGET="$(cd "$TARGET" && pwd)"
# Copy context directory
mkdir -p "$TARGET/context"
cp -r "$SCRIPT_DIR/context/"* "$TARGET/context/"
echo "copy: context/ -> $TARGET/context/ ($(ls "$SCRIPT_DIR/context/" | wc -l | tr -d ' ') files)"
# Copy or append AGENTS.md
if [ -f "$TARGET/AGENTS.md" ]; then
echo "" >> "$TARGET/AGENTS.md"
cat "$SCRIPT_DIR/AGENTS.md" >> "$TARGET/AGENTS.md"
echo "append: AGENTS.md -> $TARGET/AGENTS.md"
else
cp "$SCRIPT_DIR/AGENTS.md" "$TARGET/AGENTS.md"
echo "copy: AGENTS.md -> $TARGET/AGENTS.md"
fi
echo "done: installed into $TARGET"