@ai-ecoverse/slicc-shared-web 1.29.4 → 1.29.5
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 +8 -5
- package/bin/slicc-install-hooks.sh +25 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Configuration shared by SLICC's web repos ([slicc-bios](https://github.com/ai-ec
|
|
|
8
8
|
| `.github/workflows/node-ci.yml` | Reusable CI: `npm ci`, lint, Chromium's system libraries, integration tests, hotspots and the stack of every crash dump in the job summary, coverage/profiles/screenshots/crash dumps as artifacts. The browser itself comes from each repo's `pretest` | `jobs: { ci: { uses: ai-ecoverse/slicc-shared-web/.github/workflows/node-ci.yml@vX.Y.Z } }` |
|
|
9
9
|
| `biome.json` | Formatter settings and slicc's strict linter: cognitive complexity ≤ 25, functions ≤ 150 lines, no unused variables or imports, no floating or misused promises, naming conventions, `import type`/`export type`. Test files under `test/` get slicc's test exemptions | `biome.json`: `{ "extends": ["@ai-ecoverse/slicc-shared-web/biome"] }` |
|
|
10
10
|
| `tsconfig.json` | TypeScript base for Node's type stripping | `tsconfig.json`: `{ "extends": "@ai-ecoverse/slicc-shared-web/tsconfig.json", "include": ["src/**/*.ts"] }` |
|
|
11
|
-
| `lefthook.yml` | Pre-commit hooks: Biome, typecheck, no comments, no unit tests in git, AGENTS.md, and diff coverage over [only the unit tests the change reaches](#which-unit-tests-a-commit-runs) | `lefthook.yml`: `extends: [node_modules/@ai-ecoverse/slicc-shared-web/lefthook.yml]`, and `prepare`: `slicc-install-hooks` ([one hooks directory per worktree](#one-hooks-directory-per-worktree)) |
|
|
11
|
+
| `lefthook.yml` | Pre-commit hooks: Biome, typecheck, no comments, no unit tests in git, AGENTS.md, and diff coverage over [only the unit tests the change reaches](#which-unit-tests-a-commit-runs) | `lefthook.yml`: `extends: [node_modules/@ai-ecoverse/slicc-shared-web/lefthook.yml]`, and `prepare`: `slicc-install-hooks` plus the committed `.githooks/` it writes ([one hooks directory per worktree](#one-hooks-directory-per-worktree)) |
|
|
12
12
|
| `mcr.config.mjs` | Unit-test coverage for JS and TS sources (`.js`, `.mjs`, `.cjs`, `.ts`, `.mts`, `.cts`) in `src/` or the `slicc.unitSources` directories (TS types are stripped first), written to `coverage/unit/lcov.info`. Every source file is in it, tested or not, and paths are matched relative to the repo root, so a checkout under a dot-directory such as `~/.bb/` still reports untested files to diff coverage. With `SLICC_UNIT_TESTS` set, `node --test` runs only those files ([below](#which-unit-tests-a-commit-runs)) | `test:unit`: `mcr -c node_modules/@ai-ecoverse/slicc-shared-web/mcr.config.mjs node --test 'test/unit/**/*.test.mjs'` |
|
|
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) | `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` |
|
|
@@ -206,15 +206,18 @@ jobs:
|
|
|
206
206
|
|
|
207
207
|
## One hooks directory per worktree
|
|
208
208
|
|
|
209
|
-
Without it, every worktree of a repo shares `.git/hooks/` with the main clone, and each `lefthook install` repoints that one hook at its own worktree's lefthook, so a commit anywhere runs with whichever worktree installed last, until that worktree is deleted. A repo
|
|
209
|
+
Without it, every worktree of a repo shares `.git/hooks/` with the main clone, and each `lefthook install` repoints that one hook at its own worktree's lefthook, so a commit anywhere runs with whichever worktree installed last, until that worktree is deleted. A repo rolls it out in one PR: `package.json` installs the hooks with
|
|
210
210
|
|
|
211
211
|
```json
|
|
212
212
|
"prepare": "slicc-install-hooks"
|
|
213
213
|
```
|
|
214
214
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
- **
|
|
215
|
+
and the PR commits the `.githooks/` directory that the first `npm install` writes.
|
|
216
|
+
|
|
217
|
+
- **What it does:** sets one shared, relative `core.hooksPath` of `.githooks` (`<dir>/.githooks` for a package in a subdirectory of the repo), runs `lefthook install --force` with its output pointed at this worktree's gitignored `node_modules/.git-hooks/`, and writes a shim into `.githooks/` for every hook lefthook installed that has none yet. 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.
|
|
218
|
+
- **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.
|
|
219
|
+
- **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`.
|
|
220
|
+
- **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.
|
|
218
221
|
- **Outside a git checkout** (a packed tarball, say) it does nothing and exits 0.
|
|
219
222
|
|
|
220
223
|
## Which unit tests a commit runs
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
set -eu
|
|
3
|
-
git rev-parse --
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
git config --file "$
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ] || exit 0
|
|
4
|
+
own="$(git rev-parse --path-format=absolute --git-dir)/config.worktree"
|
|
5
|
+
if [ -f "$own" ]; then
|
|
6
|
+
case "$(git config --file "$own" --get-all core.hooksPath || true)" in
|
|
7
|
+
*worktree-hooks*) git config --file "$own" --unset-all core.hooksPath ;;
|
|
8
|
+
esac
|
|
9
|
+
fi
|
|
10
|
+
git config core.hooksPath "$(git rev-parse --show-prefix).githooks"
|
|
11
|
+
n="${GIT_CONFIG_COUNT:-0}"
|
|
12
|
+
(
|
|
13
|
+
export "GIT_CONFIG_COUNT=$((n + 1))" "GIT_CONFIG_KEY_$n=core.hooksPath" "GIT_CONFIG_VALUE_$n=$(pwd -P)/node_modules/.git-hooks"
|
|
14
|
+
lefthook install --force "$@"
|
|
15
|
+
)
|
|
16
|
+
mkdir -p .githooks
|
|
17
|
+
for hook in node_modules/.git-hooks/*; do
|
|
18
|
+
name="${hook##*/}"
|
|
19
|
+
case "$name" in *.*) continue ;; esac
|
|
20
|
+
if [ ! -f "$hook" ] || [ -e ".githooks/$name" ]; then continue; fi
|
|
21
|
+
cat >".githooks/$name" <<'SHIM'
|
|
22
|
+
#!/bin/sh
|
|
23
|
+
hook="${0%/*}/../node_modules/.git-hooks/${0##*/}"
|
|
24
|
+
[ -x "$hook" ] || { echo "${0##*/}: run npm install" >&2; exit 1; }
|
|
25
|
+
exec "$hook" "$@"
|
|
26
|
+
SHIM
|
|
27
|
+
chmod +x ".githooks/$name"
|
|
10
28
|
done
|
|
11
|
-
hooks="$(git rev-parse --absolute-git-dir)/worktree-hooks"
|
|
12
|
-
git config extensions.worktreeConfig true
|
|
13
|
-
git config --worktree core.hooksPath "$hooks"
|
|
14
|
-
exec lefthook install "$@"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-shared-web",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.5",
|
|
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",
|