-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathattribution
More file actions
executable file
·81 lines (69 loc) · 2.44 KB
/
Copy pathattribution
File metadata and controls
executable file
·81 lines (69 loc) · 2.44 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
73
74
75
76
77
78
79
80
81
#!/bin/bash
set -euo pipefail
# attribution — regenerate each app's attribution report.
#
# A report lists every third-party work an app is built with, each carrying its
# license notice inline, and lands in that app's own resources for the About
# screen to decode. It is generated rather than hand-kept, which is the point: a
# hand-maintained list silently goes stale the moment some *other* module adds a
# dependency, whereas a re-run picks it up wherever it landed.
#
# Each app declares its own sources in an attribution-sources.json; the generic
# reporting lives in CreditKit. Re-run after adding or bumping a package, after
# `./sync-agents --update` moves a pinned skill, or after changing
# `.agents/development-tools.json`, and commit the result.
#
# Needs network and an authenticated `gh` (notices are read at the pinned
# revision, so the text shipped is the one governing the code actually in use).
cd "$(dirname "$0")"
GENERATOR="Shared/CreditKit/Tools/generate-attribution.rb"
# One entry per app that ships a report.
CONFIGS=(
"Where/Where/attribution-sources.json"
)
usage() {
cat <<'USAGE'
Usage:
./attribution [config ...]
./attribution --check [config ...]
./attribution --list
./attribution --help
Regenerates the attribution report for each configured app. With no arguments,
regenerates every app's report; pass a config path to do just one.
--check Verify each committed report still matches what the repo declares,
without writing anything. Runs offline and needs no gh, so CI can
gate on it — which is what stops a stale report from shipping.
USAGE
}
case "${1-}" in
-h | --help)
usage
exit 0
;;
--list)
printf '%s\n' "${CONFIGS[@]}"
exit 0
;;
esac
check=""
if [ "${1-}" = "--check" ]; then
check="--check"
shift
fi
# Only a regenerating run reads notices off GitHub; --check is entirely local.
if [ -z "$check" ] && ! command -v gh >/dev/null 2>&1; then
echo "attribution: needs the GitHub CLI (gh) to read license notices" >&2
exit 1
fi
if [ "$#" -gt 0 ]; then
targets=("$@")
else
targets=("${CONFIGS[@]}")
fi
# The pinned Ruby via mise when available, since the repo pins one; the system
# Ruby otherwise, so a bare checkout can still run this.
if command -v mise >/dev/null 2>&1; then
mise exec -- ruby "$GENERATOR" ${check:+"$check"} "${targets[@]}"
else
ruby "$GENERATOR" ${check:+"$check"} "${targets[@]}"
fi