Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·68 lines (61 loc) · 3.25 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·68 lines (61 loc) · 3.25 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
#!/usr/bin/env bash
# install.sh — installs/updates the docgraph binary via `go install`.
# Usage: bash install.sh
# or: curl -fsSL https://raw.githubusercontent.com/lockyc/docgraph/main/install.sh | bash
#
# The curl URL requires the GitHub repo to be PUBLIC (docgraph is).
#
# docgraph is a Go CLI, not a bundle — this installs a BINARY to the Go bin dir; there
# is no ~/.docgraph clone to manage. It seeds the global config dir but never edits
# ~/.claude/settings.json or any repo's git hook — it prints that wiring as next steps
# (a non-interactive curl|bash must not silently edit global config). Never uses `just`.
set -e
# The /vN suffix is Go's semantic import versioning: a module at major >=2 must
# declare it, or the proxy rejects its tags and `@latest` falls back to the newest
# lower major. It is also the go.mod module line verbatim, so the IN_REPO grep
# below and the @latest install stay one source.
MODULE="github.com/lockyc/docgraph/v3"
command -v go >/dev/null 2>&1 || {
echo "docgraph: Go is required (https://go.dev/dl/). Install it, then re-run." >&2
exit 1
}
command -v git >/dev/null 2>&1 || \
echo "docgraph: warning — git not found on PATH; docgraph shells out to git at runtime." >&2
# IN_REPO when run from a checkout: build the current tree so uncommitted work is installed.
# NOT_IN_REPO: install the published module at @latest.
if [ -f go.mod ] && grep -q "^module $MODULE\$" go.mod 2>/dev/null && [ -f main.go ]; then
echo "Installing docgraph from the current checkout (go install .) ..."
go install .
else
echo "Installing docgraph from $MODULE@latest ..."
go install "$MODULE@latest"
fi
# Resolve the Go bin dir the binary landed in.
BIN_DIR="$(go env GOBIN)"
[ -n "$BIN_DIR" ] || BIN_DIR="$(go env GOPATH)/bin"
[ -n "$BIN_DIR" ] || BIN_DIR="$HOME/go/bin"
# Seed the global config dir (never overwrite existing rules/config).
CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/docgraph"
mkdir -p "$CFG_DIR"
# `docgraph version` prints "docgraph <ver>"; keep just the version token.
# This exec is also LOAD-BEARING beyond the version string — see the cold-exec footgun in
# CLAUDE.md: the first exec of a freshly written binary blocks in dyld for a live
# code-signature assessment (~1s on macOS). Running it here absorbs that while the user is
# already waiting on the install, instead of on their next doc-drift Stop hook. Do not
# "simplify" this to reading the VERSION file — that would silently reinstate the toll.
VERSION="$("$BIN_DIR/docgraph" version 2>/dev/null | awk '{print $NF}' || echo "")"
echo ""
echo "docgraph${VERSION:+ v$VERSION} installed → $BIN_DIR/docgraph"
case ":$PATH:" in
*":$BIN_DIR:"*) ;;
*) echo " warning — $BIN_DIR is not on your PATH; add it so 'docgraph' resolves." >&2 ;;
esac
echo ""
echo "Next steps:"
echo " • Pre-push gate for a repo: run 'docgraph install-hook' inside it."
echo " • doc-drift Stop hook: add '$BIN_DIR/docgraph doc-drift' to the"
echo " Stop hooks array in ~/.claude/settings.json."
echo " • docgraph skill: copy .claude/skills/docgraph/SKILL.md from this repo to"
echo " ~/.claude/skills/docgraph/SKILL.md."
echo " • Leak rules are a global file you curate: $CFG_DIR/leaks.toml"
echo " (schema + 'docgraph leaks-rules' export — see the README leaks section)."