@ai-ecoverse/slicc-shared-web 1.30.0 → 1.30.2
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/README.md +4 -4
- package/bin/slicc-install-hooks.sh +19 -10
- package/package.json +1 -1
- package/testing/index.mjs +5 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Configuration shared by SLICC's web repos ([slicc-bios](https://github.com/ai-ec
|
|
|
13
13
|
| `bin/` | `slicc-lint` runs every check below plus Biome and, if the repo has one, `typecheck`. Every step prints its own `<step>: PASS …` line, and slicc-lint checks for it: a step that exits 0 without one fails the run with exit 70 (`slicc-lint: FAIL <step> (no PASS line from it)`), so a check that silently stops early can't pass. The last line, `slicc-lint: PASS`, comes only after every step has printed its PASS, and a gate can require it. `slicc-lint-comments` runs the [slicc no-comment checker](https://github.com/ai-ecoverse/slicc/tree/main/packages/dev-tools/no-comment) at a pinned commit, allowing AGENTS.md and [`# renovate:` annotations](#versions-pinned-in-workflow-files) in workflow and action files. `slicc-agents-md`, `slicc-no-unit-tests` and `slicc-diff-cover` complete the set, and `slicc-unit-cover` is the diff-coverage hook. `slicc-minidump <file.dmp>...` prints a crash dump's stack, described [below](#crash-dumps). `slicc-memory-peak` prints the job's [memory peak](#memory-peak). `slicc-install-hooks` installs the hooks into [this worktree's own directory](#one-hooks-directory-per-worktree), and on Windows does nothing and exits 0, so `npm ci` works there | `lint`: `slicc-lint`, and the hooks above |
|
|
14
14
|
| `pnpmfile.mjs` | pnpm's counterpart to the Renovate preset: an `updateConfig` hook that adds `@ai-ecoverse/*` to `minimumReleaseAgeExclude`, so pnpm 12 doesn't hold back our own fresh releases (`ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION`) while third-party packages keep its age check | in a repo with a pnpm lockfile, as a [config dependency](https://pnpm.io/config-dependencies) in `pnpm-workspace.yaml`: `configDependencies: { '@ai-ecoverse/slicc-shared-web': X.Y.Z }` plus `pnpmfile: node_modules/.pnpm-config/@ai-ecoverse/slicc-shared-web/pnpmfile.mjs` |
|
|
15
15
|
| `harness/` | The CDP integration-test harness, described [below](#integration-test-harness) | `import { launch } from '@ai-ecoverse/slicc-shared-web/harness'`, and `--test-global-setup=node_modules/@ai-ecoverse/slicc-shared-web/harness/global.mjs` |
|
|
16
|
-
| `testing/` | Git fixtures that pass the AI git wrapper: `initFixtureRepo(dir, { hooks })` inits a throwaway repo with its own identity, no signing and no template hooks (`hooks: false` sets `core.hooksPath` to `/dev/null`), and `commitAll(dir, message)` stages with `git add -A -- :/`
|
|
16
|
+
| `testing/` | Git fixtures that pass the AI git wrapper: `initFixtureRepo(dir, { hooks })` inits a throwaway repo with its own identity, no signing and no template hooks (`hooks: false` sets `core.hooksPath` to `/dev/null`), `commit(dir, message)` commits what is staged without `--no-verify`, and `commitAll(dir, message)` stages with `git add -A -- :/` first, all ignoring global and system git config, so a global `core.hooksPath` never runs in the fixture. Use them instead of `git add -A`, `git add .` or `--no-verify` in a test, which the wrapper refuses when an AI tool runs the suite | `import { commitAll, initFixtureRepo } from '@ai-ecoverse/slicc-shared-web/testing'` |
|
|
17
17
|
|
|
18
18
|
Install it from npm, and pin the reusable workflow to the matching `vX.Y.Z` tag. Renovate keeps both current without the usual waiting period:
|
|
19
19
|
|
|
@@ -215,12 +215,12 @@ Without it, every worktree of a repo shares `.git/hooks/` with the main clone, a
|
|
|
215
215
|
|
|
216
216
|
and the PR commits the `.githooks/` directory that the first `npm install` writes.
|
|
217
217
|
|
|
218
|
-
- **What it does:** sets one shared, relative `core.hooksPath` of `.githooks` (`<dir>/.githooks` for a package in a subdirectory of the repo),
|
|
218
|
+
- **What it does:** sets one shared, relative `core.hooksPath` of `.githooks` (`<dir>/.githooks` for a package in a subdirectory of the repo), writes a hook into this worktree's gitignored `node_modules/.git-hooks/` for every git hook in the config `lefthook dump` prints, `extends` included, and a shim into `.githooks/` for each one that has none yet. Each hook runs `lefthook run --no-auto-install <hook>` with the lefthook binary from its own `node_modules/`, found relative to the hook, so lefthook never tries to sync hooks into `core.hooksPath`. It sets no git config from the command line or the environment, so the AI git wrapper lets it run. It never overwrites an existing shim. Git resolves a relative `core.hooksPath` against the top of the worktree a commit runs in, so each worktree runs its own committed shim, and the shim runs that worktree's own `node_modules/.git-hooks/<hook>`. No `extensions.worktreeConfig`, no per-worktree config, and `core.bare` stays where it is, so worktrees of a bare repo work too. Running it again changes nothing.
|
|
219
219
|
- **Hooks are never shared:** whatever another worktree installs later, removing a worktree removes only its own hooks, and a moved checkout keeps working. Lefthook's own `postinstall` refuses the custom `core.hooksPath`, writes nothing and doesn't fail the install, and git never reads `.git/hooks/` once `core.hooksPath` is set, so `allowScripts` needs no entry for lefthook.
|
|
220
220
|
- **A worktree that never ran `npm install`** fails every commit with `pre-commit: run npm install`, since its shim finds no `node_modules/.git-hooks/pre-commit`.
|
|
221
221
|
- **A checkout without the committed `.githooks/`** (a branch cut before the rollout PR) has no shim, so its commits run no hooks until it merges or rebases onto the rollout.
|
|
222
|
-
- **A hook type added to `lefthook.yml` later** needs `npm install` again in each worktree, and its new shim committed
|
|
223
|
-
- **
|
|
222
|
+
- **A hook type added to `lefthook.yml` later** needs `npm install` again in each worktree, and its new shim committed.
|
|
223
|
+
- **Don't unset `core.hooksPath`** when `lefthook install` suggests it: that sends every worktree back to the shared `.git/hooks/`.
|
|
224
224
|
- **Clones set up by the previous version** (2.1.1, 1.29.3), which set an absolute per-worktree `core.hooksPath` into a `worktree-hooks/` directory: it unsets that in the current worktree's `config.worktree`. It leaves `extensions.worktreeConfig` and the moved `core.bare` alone.
|
|
225
225
|
- **Outside a git checkout** (a packed tarball, say) it does nothing and exits 0.
|
|
226
226
|
|
|
@@ -8,16 +8,25 @@ if [ -f "$own" ]; then
|
|
|
8
8
|
esac
|
|
9
9
|
fi
|
|
10
10
|
git config core.hooksPath "$(git rev-parse --show-prefix).githooks"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
config="$(lefthook dump)"
|
|
12
|
+
githooks=" applypatch-msg pre-applypatch post-applypatch pre-commit pre-merge-commit prepare-commit-msg commit-msg post-commit pre-rebase post-checkout post-merge pre-push pre-receive update proc-receive post-receive post-update reference-transaction push-to-checkout pre-auto-gc post-rewrite sendemail-validate fsmonitor-watchman p4-changelist p4-prepare-changelist p4-post-changelist p4-pre-submit post-index-change "
|
|
13
|
+
mkdir -p node_modules/.git-hooks .githooks
|
|
14
|
+
for name in $(printf '%s\n' "$config" | sed -n 's/^\([a-z][a-z0-9-]*\):.*/\1/p'); do
|
|
15
|
+
case "$githooks" in *" $name "*) ;; *) continue ;; esac
|
|
16
|
+
hook="node_modules/.git-hooks/$name"
|
|
17
|
+
sed "s/@HOOK@/$name/g" >"$hook" <<'HOOK'
|
|
18
|
+
#!/bin/sh
|
|
19
|
+
if [ "${LEFTHOOK_VERBOSE:-}" = 1 ] || [ "${LEFTHOOK_VERBOSE:-}" = true ]; then set -x; fi
|
|
20
|
+
modules="$(cd "${0%/*}/.." && pwd -P)"
|
|
21
|
+
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
|
22
|
+
cpu="$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')"
|
|
23
|
+
lefthook="$modules/lefthook-$os-$cpu/bin/lefthook"
|
|
24
|
+
[ -x "$lefthook" ] || lefthook="$modules/.bin/lefthook"
|
|
25
|
+
[ -x "$lefthook" ] || { echo "@HOOK@: run npm install" >&2; exit 1; }
|
|
26
|
+
exec "$lefthook" run --no-auto-install "@HOOK@" "$@"
|
|
27
|
+
HOOK
|
|
28
|
+
chmod +x "$hook"
|
|
29
|
+
[ ! -e ".githooks/$name" ] || continue
|
|
21
30
|
cat >".githooks/$name" <<'SHIM'
|
|
22
31
|
#!/bin/sh
|
|
23
32
|
hook="${0%/*}/../node_modules/.git-hooks/${0##*/}"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-shared-web",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.2",
|
|
4
4
|
"description": "Shared Renovate, Biome, TypeScript, lefthook and GitHub Actions configuration, plus the CDP integration-test harness, for SLICC's web repos",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
package/testing/index.mjs
CHANGED
|
@@ -20,7 +20,11 @@ export function initFixtureRepo(dir, { hooks = true } = {}) {
|
|
|
20
20
|
if (!hooks) git(dir, 'config', 'core.hooksPath', devNull);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export function commit(dir, message) {
|
|
24
|
+
git(dir, 'commit', '-q', '--allow-empty', '-m', message);
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
export function commitAll(dir, message) {
|
|
24
28
|
git(dir, 'add', '-A', '--', ':/');
|
|
25
|
-
|
|
29
|
+
commit(dir, message);
|
|
26
30
|
}
|