summaryrefslogtreecommitdiff
path: root/scripts/setup.sh
blob: a4a03fa5948272a7f3084f08e28e349d098d5f7f (plain)
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
#!/usr/bin/env bash
# Install Playwright + Chromium for icloud-note under ~/.config/icloud-notes
set -euo pipefail

REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
CONFIG_DIR="${ICLOUD_NOTES_CONFIG:-$HOME/.config/icloud-notes}"
SKILL_SCRIPT="$REPO_ROOT/scripts/icloud-note.mjs"
BIN="$HOME/.local/bin/icloud-note"
AGENTS_SKILL="$HOME/.agents/skills/iphone-icloud-notes"
CURSOR_SKILL="$HOME/.cursor/skills/iphone-icloud-notes"

mkdir -p "$CONFIG_DIR" "$HOME/.local/bin" "$HOME/.agents/skills" "$HOME/.cursor/skills"
chmod 700 "$CONFIG_DIR"

cd "$CONFIG_DIR"
if [[ ! -f package.json ]]; then
  npm init -y >/dev/null
fi

npm install playwright@latest
npx playwright install chromium

cat > "$BIN" <<EOF
#!/usr/bin/env bash
exec node "$SKILL_SCRIPT" "\$@"
EOF
chmod 755 "$BIN" "$SKILL_SCRIPT" "$REPO_ROOT/scripts/setup.sh"

# Point agent skill dirs at this repo (source of truth)
ln -sfn "$REPO_ROOT" "$AGENTS_SKILL"
ln -sfn "$REPO_ROOT" "$CURSOR_SKILL"

echo "ok: playwright installed in $CONFIG_DIR"
echo "ok: wrapper $BIN"
echo "ok: skill linked -> $REPO_ROOT"
echo "Next: icloud-note login"