@bookedsolid/rea 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-push +44 -13
- package/README.md +834 -552
- package/dist/cli/doctor.d.ts +12 -0
- package/dist/cli/doctor.js +90 -1
- package/dist/cli/hook.d.ts +7 -0
- package/dist/cli/hook.js +12 -1
- package/dist/cli/install/pre-push.d.ts +21 -10
- package/dist/cli/install/pre-push.js +47 -27
- package/dist/hooks/push-gate/base.d.ts +48 -1
- package/dist/hooks/push-gate/base.js +121 -0
- package/dist/hooks/push-gate/index.d.ts +8 -0
- package/dist/hooks/push-gate/index.js +86 -21
- package/dist/hooks/push-gate/policy.d.ts +18 -4
- package/dist/hooks/push-gate/policy.js +13 -4
- package/dist/policy/loader.d.ts +5 -0
- package/dist/policy/loader.js +1 -0
- package/dist/policy/types.d.ts +44 -2
- package/package.json +1 -1
- package/scripts/tarball-smoke.sh +7 -2
package/.husky/pre-push
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
|
-
# rea:husky-pre-push-gate
|
|
3
|
-
# rea:gate-body-
|
|
2
|
+
# rea:husky-pre-push-gate v3
|
|
3
|
+
# rea:gate-body-v3
|
|
4
4
|
#
|
|
5
5
|
# Husky pre-push hook installed by `rea init` / `rea upgrade`. Do NOT
|
|
6
6
|
# edit by hand — the file is refreshed on every rea upgrade.
|
|
@@ -10,26 +10,57 @@
|
|
|
10
10
|
|
|
11
11
|
set -eu
|
|
12
12
|
|
|
13
|
+
# REA push-gate (0.11.0+). The heavy lifting — git diff resolution, Codex
|
|
14
|
+
# invocation, verdict inference, audit write — lives in
|
|
15
|
+
# `src/hooks/push-gate/` and is invoked via `rea hook push-gate`.
|
|
16
|
+
# This stub only short-circuits on the kill-switch and resolves the rea
|
|
17
|
+
# binary (in priority: project node_modules/.bin/rea → dogfood dist →
|
|
18
|
+
# PATH → npx).
|
|
19
|
+
#
|
|
20
|
+
# The 0.10.x hooks assumed rea was on PATH. Consumers who bootstrap via
|
|
21
|
+
# `npx @bookedsolid/rea init` have no persistent global rea install, so
|
|
22
|
+
# the bare `exec rea` pattern fails with "rea: not found" on push. We
|
|
23
|
+
# resolve against the project-local node_modules/.bin first, then PATH,
|
|
24
|
+
# then fall back to npx so the gate runs in every documented setup.
|
|
25
|
+
|
|
13
26
|
REA_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
|
|
14
27
|
if [ -f "${REA_ROOT}/.rea/HALT" ]; then
|
|
15
|
-
reason=$(awk
|
|
16
|
-
[ -z "${reason:-}" ] && reason=
|
|
17
|
-
printf
|
|
28
|
+
reason=$(awk 'NR==1 { print; exit }' "${REA_ROOT}/.rea/HALT" 2>/dev/null || printf 'unknown')
|
|
29
|
+
[ -z "${reason:-}" ] && reason='unknown'
|
|
30
|
+
printf 'REA HALT: %s\nAll push operations suspended. Run: rea unfreeze\n' "$reason" >&2
|
|
18
31
|
exit 1
|
|
19
32
|
fi
|
|
20
33
|
|
|
21
|
-
|
|
34
|
+
# Dispatch the rea CLI as a positional-args list rather than a string
|
|
35
|
+
# (the 0.11.x `exec $REA_BIN ...` pattern broke when REA_ROOT contained
|
|
36
|
+
# whitespace because the unquoted $REA_BIN expansion underwent word
|
|
37
|
+
# splitting; `/Users/jane/My Projects/repo` produced four argv tokens
|
|
38
|
+
# instead of two). The `set --` form below preserves spaces verbatim.
|
|
39
|
+
#
|
|
40
|
+
# The pre-push stdin carries one line per refspec; `exec` inherits stdin
|
|
41
|
+
# unchanged. $@ on entry carries git's <remote-name> <remote-url>; we
|
|
42
|
+
# preserve those by appending "$@" inside each `set --` arm.
|
|
43
|
+
|
|
22
44
|
if [ -x "${REA_ROOT}/node_modules/.bin/rea" ]; then
|
|
23
|
-
|
|
24
|
-
elif [ -f "${REA_ROOT}/dist/cli/index.js" ]; then
|
|
25
|
-
|
|
45
|
+
set -- "${REA_ROOT}/node_modules/.bin/rea" hook push-gate "$@"
|
|
46
|
+
elif [ -f "${REA_ROOT}/dist/cli/index.js" ] && [ -f "${REA_ROOT}/package.json" ] && grep -q '"name": *"@bookedsolid/rea"' "${REA_ROOT}/package.json" 2>/dev/null; then
|
|
47
|
+
# rea's own repo (dogfood) — the package is not installed under
|
|
48
|
+
# node_modules here because we ARE the package. The built CLI
|
|
49
|
+
# entry point lives at dist/cli/index.js; node runs it directly.
|
|
50
|
+
# Gate this branch on `package.json` declaring `@bookedsolid/rea` so a
|
|
51
|
+
# consumer repo that happens to ship its own `dist/cli/index.js` does
|
|
52
|
+
# not get this hook executing the consumer's unrelated build.
|
|
53
|
+
set -- node "${REA_ROOT}/dist/cli/index.js" hook push-gate "$@"
|
|
26
54
|
elif command -v rea >/dev/null 2>&1; then
|
|
27
|
-
|
|
55
|
+
set -- rea hook push-gate "$@"
|
|
28
56
|
elif command -v npx >/dev/null 2>&1; then
|
|
29
|
-
|
|
57
|
+
# Last resort: npx will resolve the package from npm or the cache.
|
|
58
|
+
# Pass `--no-install` so a rare cache-cold machine surfaces a clear
|
|
59
|
+
# error instead of silently downloading at push time.
|
|
60
|
+
set -- npx --no-install @bookedsolid/rea hook push-gate "$@"
|
|
30
61
|
else
|
|
31
|
-
printf
|
|
62
|
+
printf 'rea: cannot locate the rea CLI. Install locally (`pnpm add -D @bookedsolid/rea`) or globally (`npm i -g @bookedsolid/rea`).\n' >&2
|
|
32
63
|
exit 2
|
|
33
64
|
fi
|
|
34
65
|
|
|
35
|
-
exec
|
|
66
|
+
exec "$@"
|