-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
72 lines (56 loc) · 1.86 KB
/
install.sh
File metadata and controls
72 lines (56 loc) · 1.86 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
# api-discover installer (POSIX).
# Idempotent. Re-run after `git pull` to refresh symlinks.
set -euo pipefail
say() { printf "\033[34m[install]\033[0m %s\n" "$*"; }
err() { printf "\033[31m[error]\033[0m %s\n" "$*" >&2; }
ok() { printf "\033[32m[ok]\033[0m %s\n" "$*"; }
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BIN_DIR="${HOME}/.local/bin"
mkdir -p "$BIN_DIR"
# --- Prereqs ---
require_cmd() {
if ! command -v "$1" >/dev/null 2>&1; then
err "$1 not found. $2"
exit 1
fi
}
say "Checking prerequisites..."
require_cmd node "Install Node 18+ from https://nodejs.org/"
NODE_MAJOR="$(node -e 'console.log(process.versions.node.split(".")[0])')"
if [ "$NODE_MAJOR" -lt 18 ]; then
err "Node 18+ required, found $(node --version)"
exit 1
fi
ok "Node $(node --version)"
require_cmd python3 "Install Python 3.10+ from https://www.python.org/"
ok "Python $(python3 --version)"
if ! command -v uv >/dev/null 2>&1; then
say "uv not found, installing via the official installer..."
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
fi
ok "uv $(uv --version 2>/dev/null || echo present)"
# --- browser-harness ---
if ! command -v browser-harness >/dev/null 2>&1; then
say "Installing browser-harness via uv..."
uv tool install browser-harness
else
ok "browser-harness already on PATH at $(command -v browser-harness)"
fi
# --- api-discover binary symlink ---
TARGET_LINK="$BIN_DIR/api-discover"
SOURCE_BIN="$REPO_ROOT/bin/api-discover.mjs"
chmod +x "$SOURCE_BIN"
ln -sf "$SOURCE_BIN" "$TARGET_LINK"
ok "Linked api-discover -> $TARGET_LINK"
# --- PATH check ---
case ":$PATH:" in
*":$BIN_DIR:"*) ;;
*)
say "Note: $BIN_DIR is not on PATH. Add to your shell rc:"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
;;
esac
echo ""
ok "Installed. Run 'api-discover doctor' to verify."