mandrel 2.86.0 → 2.87.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/.agents/docs/configuration.md +32 -12
- package/.agents/schemas/agentrc.schema.json +7 -7
- package/.agents/scripts/coverage-capture.js +23 -3
- package/.agents/scripts/lib/baselines/bundle-size-scorer.js +115 -0
- package/.agents/scripts/lib/baselines/coverage-updater-cli.js +129 -28
- package/.agents/scripts/lib/baselines/crap-updater-cli.js +31 -10
- package/.agents/scripts/lib/baselines/duplication-scanner.js +25 -1
- package/.agents/scripts/lib/baselines/refresh-service.js +55 -19
- package/.agents/scripts/lib/config/gates/coverage.schema.js +1 -1
- package/.agents/scripts/lib/config/gates/shared.js +1 -1
- package/.agents/scripts/lib/config/quality.js +6 -2
- package/.agents/scripts/lib/coverage-baseline.js +7 -6
- package/.agents/scripts/lib/coverage-capture.js +44 -0
- package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
- package/.agents/scripts/lib/observability/source-classifier.js +1 -0
- package/.agents/scripts/lib/orchestration/check-baselines/phases/evaluate.js +29 -2
- package/.agents/scripts/update-bundle-size-baseline.js +56 -0
- package/.agents/scripts/update-coverage-baseline.js +16 -41
- package/.agents/scripts/update-duplication-baseline.js +13 -3
- package/docs/CHANGELOG.md +7 -0
- package/package.json +7 -1
|
@@ -169,8 +169,8 @@ Everything `/mandrel-deliver` and `single-story-close` consume: worktree isolati
|
|
|
169
169
|
| `quality.gates.coverage.tolerance.kind` | Yes | `"absolute"` \| `"percent"` | — | Whether `value` is read as raw metric units (`absolute`) or as a percentage of the baseline (`percent`). |
|
|
170
170
|
| `quality.gates.coverage.tolerance.value` | Yes | `number` | — | The tolerance magnitude. 0 means no drift is allowed. |
|
|
171
171
|
| `quality.gates.coverage.floors` | No | `object<map>` | `{"*":{"lines":90,"branches":85,"functions":90}}` | Workspace-keyed absolute floors: `{ "<workspace>": { "<metric>": number } }`. `"*"` is the project-wide catch-all; the metric keyset is open so per-rollup keys flow through without each gate enumerating them. Floors are absolute — unlike `tolerance`, they are enforced regardless of the baseline. |
|
|
172
|
-
| `quality.gates.coverage.components` | No | `object<map>` | — | Per-gate component map — component name to the glob list whose
|
|
173
|
-
| `quality.gates.coverage.coveragePath` | No | `string` | `"coverage/coverage-final.json"` | Repo-relative path to the Istanbul `coverage-final.json` the capture step writes and the gate reads. |
|
|
172
|
+
| `quality.gates.coverage.components` | No | `object<map>` | — | Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors["*"]`. Defaults to `{ "*": ["**"] }` at the resolver layer. |
|
|
173
|
+
| `quality.gates.coverage.coveragePath` | No | `string` | `"coverage/coverage-final.json"` | Repo-relative path to the Istanbul `coverage-final.json` the capture step writes and the gate reads. The capture contract: `npm run test:coverage` MUST write Istanbul per-file JSON (the `json` reporter) here — the coverage and CRAP refreshes both read it. A `json-summary` (`coverage-summary.json`) alone cannot feed them, so a green capture that leaves no file here fails and a full-scope refresh refuses to run. |
|
|
174
174
|
| `quality.gates.coverage.captureScope` | No | `"full"` \| `"affected"` | `"full"` | What coverage-capture runs. `full` (default) runs `npm run test:coverage`. `affected` runs the consumer-owned `npm run test:coverage:affected` with the base ref in `MANDREL_COVERAGE_BASE_REF`, merges its rows over the prior artifact and stamps it `affected`; baseline rows the scoped run did not measure are treated as unmeasured, never removed. Falls back to `full` with a warning when the script is absent. Meant for consumers whose CI already enforces coverage on the full suite. |
|
|
175
175
|
| `quality.gates.coverage.timeoutMs` | No | `integer` | `600000` | Kill bound (ms) for one full-suite run — the coverage capture, the close-validation full-suite gate and the full-suite lock-wait budget all read it. The clock starts at spawn, never while queued on the host lock; a suite that signals `MANDREL_SUITE_READY_FILE` gets a fresh bound for its test phase, so worst-case wall is lock wait + 2 × timeoutMs. On expiry the run exits 124 so callers can tell a hang from a failure. |
|
|
176
176
|
| `quality.gates.crap` | No | `object` | — | CRAP (Change Risk Anti-Pattern) ratchet — per-method cyclomatic complexity joined against per-method coverage. |
|
|
@@ -180,7 +180,7 @@ Everything `/mandrel-deliver` and `single-story-close` consume: worktree isolati
|
|
|
180
180
|
| `quality.gates.crap.tolerance.kind` | Yes | `"absolute"` \| `"percent"` | — | Whether `value` is read as raw metric units (`absolute`) or as a percentage of the baseline (`percent`). |
|
|
181
181
|
| `quality.gates.crap.tolerance.value` | Yes | `number` | — | The tolerance magnitude. 0 means no drift is allowed. |
|
|
182
182
|
| `quality.gates.crap.floors` | No | `object<map>` | `{"*":{"max":30,"p95":20,"methodsAbove20":50}}` | Workspace-keyed absolute floors: `{ "<workspace>": { "<metric>": number } }`. `"*"` is the project-wide catch-all; the metric keyset is open so per-rollup keys flow through without each gate enumerating them. Floors are absolute — unlike `tolerance`, they are enforced regardless of the baseline. |
|
|
183
|
-
| `quality.gates.crap.components` | No | `object<map>` | — | Per-gate component map — component name to the glob list whose
|
|
183
|
+
| `quality.gates.crap.components` | No | `object<map>` | — | Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors["*"]`. Defaults to `{ "*": ["**"] }` at the resolver layer. |
|
|
184
184
|
| `quality.gates.crap.targetDirs` | No | `string[]` or `{ append?, prepend? }` | `["src"]` | Directories whose JS sources the CRAP gate scores. Mandrel ships a `src/`-centric default; projects whose executable code lives elsewhere (e.g. this repo's `.agents/scripts/`) override here. The framework default is intentionally not auto-discovered, so an override is the explicit, auditable signal. |
|
|
185
185
|
| `quality.gates.crap.newMethodCeiling` | No | `integer` | `30` | Hard CRAP ceiling applied to a method the diff introduces. A new method above it fails the gate regardless of the baseline. |
|
|
186
186
|
| `quality.gates.crap.requireCoverage` | No | `boolean` | `true` | When true, the gate refuses to score without a coverage artifact rather than silently reporting complexity-only rows. |
|
|
@@ -197,7 +197,7 @@ Everything `/mandrel-deliver` and `single-story-close` consume: worktree isolati
|
|
|
197
197
|
| `quality.gates.maintainability.tolerance.kind` | Yes | `"absolute"` \| `"percent"` | — | Whether `value` is read as raw metric units (`absolute`) or as a percentage of the baseline (`percent`). |
|
|
198
198
|
| `quality.gates.maintainability.tolerance.value` | Yes | `number` | — | The tolerance magnitude. 0 means no drift is allowed. |
|
|
199
199
|
| `quality.gates.maintainability.floors` | No | `object<map>` | `{"*":{"min":70}}` | Workspace-keyed absolute floors: `{ "<workspace>": { "<metric>": number } }`. `"*"` is the project-wide catch-all; the metric keyset is open so per-rollup keys flow through without each gate enumerating them. Floors are absolute — unlike `tolerance`, they are enforced regardless of the baseline. |
|
|
200
|
-
| `quality.gates.maintainability.components` | No | `object<map>` | — | Per-gate component map — component name to the glob list whose
|
|
200
|
+
| `quality.gates.maintainability.components` | No | `object<map>` | — | Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors["*"]`. Defaults to `{ "*": ["**"] }` at the resolver layer. |
|
|
201
201
|
| `quality.gates.maintainability.targetDirs` | No | `string[]` or `{ append?, prepend? }` | `[]` | Directories whose JS sources the maintainability gate scores. Mandrel ships a `src/`-centric default; projects whose executable code lives elsewhere (e.g. this repo's `.agents/scripts/` plus `tests/`) override here. The framework default is intentionally not auto-discovered, so an override is the explicit, auditable signal. |
|
|
202
202
|
| `quality.gates.maintainability.ignoreGlobs` | No | `array<string>` | `[]` | Minimatch glob patterns matched against the canonicalised repo-relative path of each discovered file. Files matching any pattern are excluded from MI discovery before scoring. Orthogonal to `components` (grouping) — a file excluded here never appears in any component bucket. Absent or empty preserves the existing IGNORED_DIRS-only behaviour (Story #3217). |
|
|
203
203
|
| `quality.gates.mutation` | No | `object` | — | Stryker mutation-score ratchet. Off in practice for most consumers — the baseline kind is registered but no framework path runs Stryker. |
|
|
@@ -207,7 +207,7 @@ Everything `/mandrel-deliver` and `single-story-close` consume: worktree isolati
|
|
|
207
207
|
| `quality.gates.mutation.tolerance.kind` | Yes | `"absolute"` \| `"percent"` | — | Whether `value` is read as raw metric units (`absolute`) or as a percentage of the baseline (`percent`). |
|
|
208
208
|
| `quality.gates.mutation.tolerance.value` | Yes | `number` | — | The tolerance magnitude. 0 means no drift is allowed. |
|
|
209
209
|
| `quality.gates.mutation.floors` | No | `object<map>` | `{"*":{"score":60}}` | Workspace-keyed absolute floors: `{ "<workspace>": { "<metric>": number } }`. `"*"` is the project-wide catch-all; the metric keyset is open so per-rollup keys flow through without each gate enumerating them. Floors are absolute — unlike `tolerance`, they are enforced regardless of the baseline. |
|
|
210
|
-
| `quality.gates.mutation.components` | No | `object<map>` | — | Per-gate component map — component name to the glob list whose
|
|
210
|
+
| `quality.gates.mutation.components` | No | `object<map>` | — | Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors["*"]`. Defaults to `{ "*": ["**"] }` at the resolver layer. |
|
|
211
211
|
| `quality.gates.bundle-size` | No | `object` | — | Built-artifact size ratchet for web targets. Off by default — it needs declared bundles. |
|
|
212
212
|
| `quality.gates.bundle-size.enabled` | No | `boolean` | `false` | When false, the checker exits 0 with a skip line and the gate is reported as `skipped`, never omitted. |
|
|
213
213
|
| `quality.gates.bundle-size.baselinePath` | No | `string` | `"baselines/bundle-size.json"` | Repo-root-relative path to the gate's committed baseline artifact. |
|
|
@@ -215,7 +215,7 @@ Everything `/mandrel-deliver` and `single-story-close` consume: worktree isolati
|
|
|
215
215
|
| `quality.gates.bundle-size.tolerance.kind` | Yes | `"absolute"` \| `"percent"` | — | Whether `value` is read as raw metric units (`absolute`) or as a percentage of the baseline (`percent`). |
|
|
216
216
|
| `quality.gates.bundle-size.tolerance.value` | Yes | `number` | — | The tolerance magnitude. 0 means no drift is allowed. |
|
|
217
217
|
| `quality.gates.bundle-size.floors` | No | `object<map>` | `{"*":{}}` | Workspace-keyed absolute floors: `{ "<workspace>": { "<metric>": number } }`. `"*"` is the project-wide catch-all; the metric keyset is open so per-rollup keys flow through without each gate enumerating them. Floors are absolute — unlike `tolerance`, they are enforced regardless of the baseline. |
|
|
218
|
-
| `quality.gates.bundle-size.components` | No | `object<map>` | — | Per-gate component map — component name to the glob list whose
|
|
218
|
+
| `quality.gates.bundle-size.components` | No | `object<map>` | — | Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors["*"]`. Defaults to `{ "*": ["**"] }` at the resolver layer. |
|
|
219
219
|
| `quality.gates.bundle-size.bundles[]` | No | `array<object>` | `[]` | The artifacts to weigh. Empty means the gate has nothing to do. Each item has: name, path, limit. |
|
|
220
220
|
| `quality.gates.duplication` | No | `object` | — | Code-duplication (DRY) gate (Story #3664). Shares the gate base and adds the scan-scope extras: the `targetDirs` the duplication scanner walks, the jscpd `formats` it reads there, and `ignoreGlobs` to exclude files from the scan. |
|
|
221
221
|
| `quality.gates.duplication.enabled` | No | `boolean` | `false` | When false, the checker exits 0 with a skip line and the gate is reported as `skipped`, never omitted. |
|
|
@@ -224,7 +224,7 @@ Everything `/mandrel-deliver` and `single-story-close` consume: worktree isolati
|
|
|
224
224
|
| `quality.gates.duplication.tolerance.kind` | Yes | `"absolute"` \| `"percent"` | — | Whether `value` is read as raw metric units (`absolute`) or as a percentage of the baseline (`percent`). |
|
|
225
225
|
| `quality.gates.duplication.tolerance.value` | Yes | `number` | — | The tolerance magnitude. 0 means no drift is allowed. |
|
|
226
226
|
| `quality.gates.duplication.floors` | No | `object<map>` | `{"*":{"percentage":25}}` | Workspace-keyed absolute floors: `{ "<workspace>": { "<metric>": number } }`. `"*"` is the project-wide catch-all; the metric keyset is open so per-rollup keys flow through without each gate enumerating them. Floors are absolute — unlike `tolerance`, they are enforced regardless of the baseline. |
|
|
227
|
-
| `quality.gates.duplication.components` | No | `object<map>` | — | Per-gate component map — component name to the glob list whose
|
|
227
|
+
| `quality.gates.duplication.components` | No | `object<map>` | — | Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors["*"]`. Defaults to `{ "*": ["**"] }` at the resolver layer. |
|
|
228
228
|
| `quality.gates.duplication.targetDirs` | No | `string[]` or `{ append?, prepend? }` | `["src"]` | Directories whose sources — the languages `formats` selects — the duplication (DRY) gate scans for copy-paste clones. Mandrel ships a `src/`-centric default; projects whose executable code lives elsewhere (e.g. this repo's `.agents/scripts/`) override here. The framework default is intentionally not auto-discovered, so an override is the explicit, auditable signal (Story #3664). |
|
|
229
229
|
| `quality.gates.duplication.formats` | No | `array<string>` | `["javascript","jsx","typescript","tsx"]` | jscpd format names the duplication (DRY) gate scans under `targetDirs`. The default covers JavaScript, JSX, TypeScript and TSX; jscpd's `javascript` format alone reads only `.js`/`.es`/`.es6`/`.mjs`/`.cjs`. Names are jscpd's own vocabulary and are not restricted here. Widening the set adds rows, so re-seat the baseline with `npm run duplication:reanchor` after changing it. |
|
|
230
230
|
| `quality.gates.duplication.ignoreGlobs` | No | `array<string>` | `[]` | Minimatch glob patterns matched against the canonicalised repo-relative path of each discovered file. Files matching any pattern are excluded from duplication discovery before scanning. Orthogonal to `components` (grouping). Absent or empty preserves the existing behaviour (Story #3664). |
|
|
@@ -363,10 +363,30 @@ A config still carrying the retired key is a hard validation failure; the
|
|
|
363
363
|
`enabled` / `baselinePath` / `tolerance` (`{ kind, value }`) /
|
|
364
364
|
`floors` (`{ <workspace>: { <metric>: <number> } }`) /
|
|
365
365
|
`components` (`{ <component>: [<glob>] }`). The `crap` / `maintainability` /
|
|
366
|
-
`duplication` `targetDirs` default `["src"]`.
|
|
367
|
-
|
|
368
|
-
|
|
366
|
+
`duplication` `targetDirs` default `["src"]`. `components` slices the floor
|
|
367
|
+
check: `check-baselines` reports one rollup per component that matches a
|
|
368
|
+
row and holds it to `floors.<component>` (else `floors["*"]`), so a
|
|
369
|
+
component below its floor breaches even when the whole-repo `*` rollup
|
|
370
|
+
passes. The `bundle-size` gate has **no** `refreshTag`: its baseline is
|
|
371
|
+
generated by `node .agents/scripts/update-bundle-size-baseline.js` (always a
|
|
372
|
+
full refresh, never a build), and an intentional growth is acknowledged with
|
|
373
|
+
the one-shot `BUNDLE_SIZE_REFRESH=1` env var, not a config knob
|
|
369
374
|
(see [`quality-gates.md` § Bundle-size ratchet](https://github.com/dsj1984/mandrel/blob/main/docs/quality-gates.md#bundle-size-ratchet--one-shot-refreshacknowledge-story-151)).
|
|
375
|
+
- **Coverage capture contract.** `npm run test:coverage` (and
|
|
376
|
+
`test:coverage:affected`) MUST write Istanbul per-file JSON — the `json`
|
|
377
|
+
reporter's `coverage-final.json` — at `quality.gates.coverage.coveragePath`.
|
|
378
|
+
That one artifact feeds both the coverage and the CRAP refresh; a
|
|
379
|
+
`json-summary` (`coverage-summary.json`) alone cannot. With c8, list
|
|
380
|
+
`json` in `reporter`; with Vitest or Jest, add `json` to the coverage
|
|
381
|
+
reporters. `coverage-capture.js` fails a green run that leaves no artifact
|
|
382
|
+
there (and writes no capture stamp), and a full-scope coverage or CRAP
|
|
383
|
+
refresh with no artifact exits non-zero naming the path.
|
|
384
|
+
- **Duplication needs jscpd.** The duplication gate scans with `jscpd` 4, an
|
|
385
|
+
**optional peer dependency** of `mandrel`: a project that enables
|
|
386
|
+
`quality.gates.duplication` installs it itself — `npm i -D jscpd@^4`.
|
|
387
|
+
Without it, `update-duplication-baseline.js` exits non-zero naming that
|
|
388
|
+
command; `check-baselines` evaluates the committed baseline and does not
|
|
389
|
+
need jscpd.
|
|
370
390
|
Extend the list-valued gate keys with the deep-merge extender form (see
|
|
371
391
|
[How to extend](#how-to-extend)).
|
|
372
392
|
|
|
@@ -504,9 +524,9 @@ the lint ratchet, and the CRAP/MI gates.
|
|
|
504
524
|
| --------------------------------- | ------------------------------------ | ---------------------------------------------------------------------- |
|
|
505
525
|
| `baselines/coverage.json` | `update-coverage-baseline.js` | `node .agents/scripts/update-coverage-baseline.js` |
|
|
506
526
|
| `baselines/crap.json` | `update-crap-baseline.js` | `npm run crap:update` |
|
|
507
|
-
| `baselines/duplication.json` | `update-duplication-baseline.js` | `node .agents/scripts/update-duplication-baseline.js`
|
|
527
|
+
| `baselines/duplication.json` | `update-duplication-baseline.js` | `node .agents/scripts/update-duplication-baseline.js` (needs `jscpd@^4` installed) |
|
|
508
528
|
| `baselines/maintainability.json` | `update-maintainability-baseline.js` | `npm run maintainability:update` |
|
|
509
|
-
| `baselines/bundle-size.json` |
|
|
529
|
+
| `baselines/bundle-size.json` | `update-bundle-size-baseline.js` | Build first, then `node .agents/scripts/update-bundle-size-baseline.js`; for an intentional growth, run the check with `BUNDLE_SIZE_REFRESH=1` (see [Bundle-size ratchet](https://github.com/dsj1984/mandrel/blob/main/docs/quality-gates.md#bundle-size-ratchet--one-shot-refreshacknowledge-story-151)) |
|
|
510
530
|
|
|
511
531
|
These files are the contract — read by every gate (Story close, push hook, CI)
|
|
512
532
|
and regenerated only via tagged `baseline-refresh:` commits with a non-empty
|
|
@@ -622,7 +622,7 @@
|
|
|
622
622
|
},
|
|
623
623
|
"components": {
|
|
624
624
|
"type": "object",
|
|
625
|
-
"description": "Per-gate component map — component name to the glob list whose
|
|
625
|
+
"description": "Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors[\"*\"]`. Defaults to `{ \"*\": [\"**\"] }` at the resolver layer.",
|
|
626
626
|
"additionalProperties": {
|
|
627
627
|
"type": "array",
|
|
628
628
|
"items": {
|
|
@@ -637,7 +637,7 @@
|
|
|
637
637
|
"pattern": "([;&|`]|\\$\\()"
|
|
638
638
|
},
|
|
639
639
|
"minLength": 1,
|
|
640
|
-
"description": "Repo-relative path to the Istanbul `coverage-final.json` the capture step writes and the gate reads.",
|
|
640
|
+
"description": "Repo-relative path to the Istanbul `coverage-final.json` the capture step writes and the gate reads. The capture contract: `npm run test:coverage` MUST write Istanbul per-file JSON (the `json` reporter) here — the coverage and CRAP refreshes both read it. A `json-summary` (`coverage-summary.json`) alone cannot feed them, so a green capture that leaves no file here fails and a full-scope refresh refuses to run.",
|
|
641
641
|
"default": "coverage/coverage-final.json"
|
|
642
642
|
},
|
|
643
643
|
"captureScope": {
|
|
@@ -715,7 +715,7 @@
|
|
|
715
715
|
},
|
|
716
716
|
"components": {
|
|
717
717
|
"type": "object",
|
|
718
|
-
"description": "Per-gate component map — component name to the glob list whose
|
|
718
|
+
"description": "Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors[\"*\"]`. Defaults to `{ \"*\": [\"**\"] }` at the resolver layer.",
|
|
719
719
|
"additionalProperties": {
|
|
720
720
|
"type": "array",
|
|
721
721
|
"items": {
|
|
@@ -862,7 +862,7 @@
|
|
|
862
862
|
},
|
|
863
863
|
"components": {
|
|
864
864
|
"type": "object",
|
|
865
|
-
"description": "Per-gate component map — component name to the glob list whose
|
|
865
|
+
"description": "Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors[\"*\"]`. Defaults to `{ \"*\": [\"**\"] }` at the resolver layer.",
|
|
866
866
|
"additionalProperties": {
|
|
867
867
|
"type": "array",
|
|
868
868
|
"items": {
|
|
@@ -970,7 +970,7 @@
|
|
|
970
970
|
},
|
|
971
971
|
"components": {
|
|
972
972
|
"type": "object",
|
|
973
|
-
"description": "Per-gate component map — component name to the glob list whose
|
|
973
|
+
"description": "Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors[\"*\"]`. Defaults to `{ \"*\": [\"**\"] }` at the resolver layer.",
|
|
974
974
|
"additionalProperties": {
|
|
975
975
|
"type": "array",
|
|
976
976
|
"items": {
|
|
@@ -1037,7 +1037,7 @@
|
|
|
1037
1037
|
},
|
|
1038
1038
|
"components": {
|
|
1039
1039
|
"type": "object",
|
|
1040
|
-
"description": "Per-gate component map — component name to the glob list whose
|
|
1040
|
+
"description": "Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors[\"*\"]`. Defaults to `{ \"*\": [\"**\"] }` at the resolver layer.",
|
|
1041
1041
|
"additionalProperties": {
|
|
1042
1042
|
"type": "array",
|
|
1043
1043
|
"items": {
|
|
@@ -1134,7 +1134,7 @@
|
|
|
1134
1134
|
},
|
|
1135
1135
|
"components": {
|
|
1136
1136
|
"type": "object",
|
|
1137
|
-
"description": "Per-gate component map — component name to the glob list whose
|
|
1137
|
+
"description": "Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors[\"*\"]`. Defaults to `{ \"*\": [\"**\"] }` at the resolver layer.",
|
|
1138
1138
|
"additionalProperties": {
|
|
1139
1139
|
"type": "array",
|
|
1140
1140
|
"items": {
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* when the gate is off, no changed file is under `crap.targetDirs`, or the
|
|
5
5
|
* content-digest stamp matches; otherwise run `test:coverage` (or, under
|
|
6
6
|
* `coverage.captureScope: "affected"`, the consumer's `test:coverage:affected`)
|
|
7
|
-
* behind the host-level full-suite lock and stamp on success.
|
|
7
|
+
* behind the host-level full-suite lock and stamp on success. A green run that
|
|
8
|
+
* leaves no artifact at `coveragePath` fails (exit 1) and is never stamped.
|
|
8
9
|
*
|
|
9
10
|
* `--require-credited` must stay an argument, never a config read: as policy
|
|
10
11
|
* it also refused the depositing run, leaving no path that could deposit.
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
creditedCapture,
|
|
22
23
|
filterFilesUnderTargets,
|
|
23
24
|
isCoverageFresh,
|
|
25
|
+
requireCaptureArtifact,
|
|
24
26
|
runCapture,
|
|
25
27
|
writeCaptureStamp,
|
|
26
28
|
} from './lib/coverage-capture.js';
|
|
@@ -67,6 +69,7 @@ export function parseArgs(argv) {
|
|
|
67
69
|
* computeContentDigestImpl?: typeof computeContentDigest,
|
|
68
70
|
* writeCaptureStampImpl?: typeof writeCaptureStamp,
|
|
69
71
|
* filterFilesUnderTargetsImpl?: typeof filterFilesUnderTargets,
|
|
72
|
+
* coverageArtifactExistsImpl?: (absPath: string) => boolean,
|
|
70
73
|
* logger?: { info: Function, warn: Function, error: Function },
|
|
71
74
|
* lockOptions?: object,
|
|
72
75
|
* env?: Record<string, string|undefined>,
|
|
@@ -85,6 +88,7 @@ export async function runCoverageCapture(argv = process.argv, deps = {}) {
|
|
|
85
88
|
computeContentDigestImpl = computeContentDigest,
|
|
86
89
|
writeCaptureStampImpl = writeCaptureStamp,
|
|
87
90
|
filterFilesUnderTargetsImpl = filterFilesUnderTargets,
|
|
91
|
+
coverageArtifactExistsImpl,
|
|
88
92
|
logger = Logger,
|
|
89
93
|
lockOptions = {},
|
|
90
94
|
env = process.env,
|
|
@@ -110,8 +114,10 @@ export async function runCoverageCapture(argv = process.argv, deps = {}) {
|
|
|
110
114
|
onLockProgress: lockHooks.onLockProgress,
|
|
111
115
|
...lockOptions,
|
|
112
116
|
});
|
|
113
|
-
const credited =
|
|
114
|
-
|
|
117
|
+
const credited = artifactCheckedCapture(locked, {
|
|
118
|
+
args,
|
|
119
|
+
crap,
|
|
120
|
+
existsSync: coverageArtifactExistsImpl,
|
|
115
121
|
logger,
|
|
116
122
|
});
|
|
117
123
|
let timings = null;
|
|
@@ -142,6 +148,20 @@ export async function runCoverageCapture(argv = process.argv, deps = {}) {
|
|
|
142
148
|
return code;
|
|
143
149
|
}
|
|
144
150
|
|
|
151
|
+
/**
|
|
152
|
+
* The credited runner, failing a green run that wrote no artifact.
|
|
153
|
+
*
|
|
154
|
+
* @param {Function} locked
|
|
155
|
+
* @param {{ args: object, crap: object, existsSync?: Function, logger: object }} opts
|
|
156
|
+
* @returns {(opts: object) => Promise<number>}
|
|
157
|
+
*/
|
|
158
|
+
function artifactCheckedCapture(locked, { args, crap, existsSync, logger }) {
|
|
159
|
+
return requireCaptureArtifact(
|
|
160
|
+
creditedCapture(locked, { requireCredited: args.requireCredited, logger }),
|
|
161
|
+
{ cwd: args.cwd, coveragePath: crap.coveragePath, existsSync, logger },
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
145
165
|
/** @returns {number|null} The exit code when no capture may run. */
|
|
146
166
|
function refusal({
|
|
147
167
|
crap,
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default scorer for the bundle-size baseline: weigh each declared
|
|
3
|
+
* `gates['bundle-size'].bundles[]` artifact on disk. It never builds the
|
|
4
|
+
* project — the artifacts must already exist.
|
|
5
|
+
*
|
|
6
|
+
* Row shape (kinds/bundle-size.js): `{ bundle, rawKb, gzippedKb }`, where a
|
|
7
|
+
* bundle's size is the sum over every file its `path` glob matches.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import nodeFs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { gzipSync } from 'node:zlib';
|
|
13
|
+
import { Minimatch } from 'minimatch';
|
|
14
|
+
|
|
15
|
+
/** Directories a bundle glob never descends into. */
|
|
16
|
+
const SKIPPED_DIRS = new Set(['.git', 'node_modules']);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {number} bytes
|
|
20
|
+
* @returns {number} KB, two decimals.
|
|
21
|
+
*/
|
|
22
|
+
function toKb(bytes) {
|
|
23
|
+
return Number((bytes / 1024).toFixed(2));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The leading glob-free directory of a POSIX pattern — the walk root.
|
|
28
|
+
*
|
|
29
|
+
* @param {string[]} segments
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
function staticBase(segments) {
|
|
33
|
+
const firstMagic = segments.findIndex((s) => /[*?[\]{}()!]/.test(s));
|
|
34
|
+
const base =
|
|
35
|
+
firstMagic === -1 ? segments.slice(0, -1) : segments.slice(0, firstMagic);
|
|
36
|
+
return base.join('/');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {string} absDir
|
|
41
|
+
* @param {typeof nodeFs} fs
|
|
42
|
+
* @returns {string[]} Absolute file paths under `absDir`.
|
|
43
|
+
*/
|
|
44
|
+
function walkFiles(absDir, fs) {
|
|
45
|
+
if (!fs.existsSync(absDir)) return [];
|
|
46
|
+
const out = [];
|
|
47
|
+
for (const entry of fs.readdirSync(absDir, { withFileTypes: true })) {
|
|
48
|
+
const abs = path.join(absDir, entry.name);
|
|
49
|
+
if (entry.isDirectory()) {
|
|
50
|
+
if (!SKIPPED_DIRS.has(entry.name)) out.push(...walkFiles(abs, fs));
|
|
51
|
+
} else if (entry.isFile()) {
|
|
52
|
+
out.push(abs);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Repo-relative files a bundle `path` (literal or glob) matches, sorted.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} pattern
|
|
62
|
+
* @param {string} cwd
|
|
63
|
+
* @param {typeof nodeFs} fs
|
|
64
|
+
* @returns {string[]} Absolute paths.
|
|
65
|
+
*/
|
|
66
|
+
function resolveBundleFiles(pattern, cwd, fs = nodeFs) {
|
|
67
|
+
const posix = pattern.replace(/\\/g, '/').replace(/^\.\//, '');
|
|
68
|
+
const matcher = new Minimatch(posix, { dot: true });
|
|
69
|
+
if (!matcher.hasMagic()) {
|
|
70
|
+
const abs = path.resolve(cwd, posix);
|
|
71
|
+
return fs.existsSync(abs) && fs.statSync(abs).isFile() ? [abs] : [];
|
|
72
|
+
}
|
|
73
|
+
const base = staticBase(posix.split('/'));
|
|
74
|
+
return walkFiles(path.resolve(cwd, base), fs)
|
|
75
|
+
.filter((abs) =>
|
|
76
|
+
matcher.match(path.relative(cwd, abs).split(path.sep).join('/')),
|
|
77
|
+
)
|
|
78
|
+
.sort();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @param {{ name: string, path: string }} bundle
|
|
83
|
+
* @param {string} cwd
|
|
84
|
+
* @param {typeof nodeFs} fs
|
|
85
|
+
* @returns {{ bundle: string, rawKb: number, gzippedKb: number }}
|
|
86
|
+
*/
|
|
87
|
+
function measureBundle(bundle, cwd, fs) {
|
|
88
|
+
const files = resolveBundleFiles(bundle.path, cwd, fs);
|
|
89
|
+
if (files.length === 0) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`[bundle-size] declared bundle "${bundle.name}" matches no file at "${bundle.path}" — build the project before refreshing; an unbuilt artifact is never recorded as 0 KB.`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
let raw = 0;
|
|
95
|
+
let gzipped = 0;
|
|
96
|
+
for (const abs of files) {
|
|
97
|
+
const bytes = fs.readFileSync(abs);
|
|
98
|
+
raw += bytes.length;
|
|
99
|
+
gzipped += gzipSync(bytes).length;
|
|
100
|
+
}
|
|
101
|
+
return { bundle: bundle.name, rawKb: toKb(raw), gzippedKb: toKb(gzipped) };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @param {{ cwd: string, quality?: object, fs?: typeof nodeFs }} opts
|
|
106
|
+
* @returns {(files: string[], opts: object) => object[]}
|
|
107
|
+
*/
|
|
108
|
+
export function buildBundleSizeScorer({ cwd, quality, fs = nodeFs } = {}) {
|
|
109
|
+
const declared = quality?.gates?.['bundle-size']?.bundles;
|
|
110
|
+
const bundles = Array.isArray(declared) ? declared : [];
|
|
111
|
+
return (_files, opts) => {
|
|
112
|
+
const effectiveCwd = opts?.cwd ?? cwd ?? process.cwd();
|
|
113
|
+
return bundles.map((bundle) => measureBundle(bundle, effectiveCwd, fs));
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -1,13 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `update-coverage-baseline` CLI's testable logic. The scorer stays
|
|
3
3
|
* bespoke (not the refresh-service default) because it logs when the coverage
|
|
4
|
-
* artifact is missing
|
|
5
|
-
*
|
|
4
|
+
* artifact is missing on a scoped refresh; a full-scope refresh rethrows, since
|
|
5
|
+
* `refreshBaseline` has no empty-rows guard and would write an empty baseline.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import { createRequire } from 'node:module';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { getBaselineEpsilon } from '../config/quality.js';
|
|
12
|
+
import {
|
|
13
|
+
buildScopePredicate,
|
|
14
|
+
readCoverageFinal,
|
|
15
|
+
scoreCoverageFinal,
|
|
16
|
+
} from '../coverage-baseline.js';
|
|
8
17
|
import { Logger } from '../Logger.js';
|
|
9
18
|
import { parseDiffScopeFlag } from './diff-scope-cli.js';
|
|
10
19
|
|
|
20
|
+
/** CommonJS `require`, for the `.c8rc.cjs` scope config. */
|
|
21
|
+
const require = createRequire(import.meta.url);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The c8 include/exclude scope from `<cwd>/.c8rc.cjs` — the one
|
|
25
|
+
* environment-bound step, which the scorer takes as a seam so a test never
|
|
26
|
+
* touches a real config. A consumer measuring with another runner has no
|
|
27
|
+
* `.c8rc.cjs`: that is an unscoped artifact, mirroring the refresh-service
|
|
28
|
+
* default scorer.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} cwd
|
|
31
|
+
* @returns {{ include?: string[], exclude?: string[] }}
|
|
32
|
+
*/
|
|
33
|
+
export function loadC8ScopeConfig(cwd) {
|
|
34
|
+
const c8rcPath = path.resolve(cwd, '.c8rc.cjs');
|
|
35
|
+
if (!fs.existsSync(c8rcPath)) return {};
|
|
36
|
+
return require(c8rcPath);
|
|
37
|
+
}
|
|
38
|
+
|
|
11
39
|
/**
|
|
12
40
|
* Throws when both scope flags are present.
|
|
13
41
|
*
|
|
@@ -25,6 +53,22 @@ export function resolveCoverageUpdaterScope(argv = []) {
|
|
|
25
53
|
return { fullScope, diffScopeRef };
|
|
26
54
|
}
|
|
27
55
|
|
|
56
|
+
/**
|
|
57
|
+
* A full-scope refresh rethrows a read failure — over zero rows it would
|
|
58
|
+
* write an empty baseline; a scoped one logs it and yields `null`.
|
|
59
|
+
*
|
|
60
|
+
* @returns {object|null}
|
|
61
|
+
*/
|
|
62
|
+
function readOrReport(readCoverage, cwd, opts, logger) {
|
|
63
|
+
try {
|
|
64
|
+
return readCoverage(cwd);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
if (opts?.fullScope) throw err;
|
|
67
|
+
logger.error(`[Coverage] ❌ ${err.message}`);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
28
72
|
/**
|
|
29
73
|
* Narrows to the c8 include/exclude scope, and in diff mode to the in-scope
|
|
30
74
|
* files so untouched rows are preserved rather than re-scored.
|
|
@@ -34,20 +78,14 @@ export function resolveCoverageUpdaterScope(argv = []) {
|
|
|
34
78
|
* score: Function, logger?: object}} deps
|
|
35
79
|
* @returns {(files: string[], opts: object) => object[]}
|
|
36
80
|
*/
|
|
37
|
-
|
|
81
|
+
function buildCoverageUpdaterScorer(
|
|
38
82
|
cwd,
|
|
39
83
|
{ readCoverage, loadScope, buildScope, score, logger = Logger } = {},
|
|
40
84
|
) {
|
|
41
85
|
return (files, opts) => {
|
|
42
86
|
const effectiveCwd = opts?.cwd ?? cwd;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
raw = readCoverage(effectiveCwd);
|
|
46
|
-
} catch (err) {
|
|
47
|
-
logger.error(`[Coverage] ❌ ${err.message}`);
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
|
|
87
|
+
const raw = readOrReport(readCoverage, effectiveCwd, opts, logger);
|
|
88
|
+
if (raw === null) return [];
|
|
51
89
|
const c8Config = loadScope(effectiveCwd);
|
|
52
90
|
const scores = score({
|
|
53
91
|
raw,
|
|
@@ -57,25 +95,88 @@ export function buildCoverageUpdaterScorer(
|
|
|
57
95
|
exclude: c8Config.exclude ?? [],
|
|
58
96
|
}),
|
|
59
97
|
});
|
|
98
|
+
return projectScoredRows(scores, files, opts, logger);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
60
101
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Baseline rows from per-file scores; in diff mode only the in-scope files,
|
|
104
|
+
* so untouched rows are preserved rather than re-scored.
|
|
105
|
+
*
|
|
106
|
+
* @param {Record<string, object>} scores
|
|
107
|
+
* @param {string[]} files
|
|
108
|
+
* @param {{ fullScope?: boolean } | undefined} opts
|
|
109
|
+
* @param {{ info: Function }} logger
|
|
110
|
+
* @returns {object[]}
|
|
111
|
+
*/
|
|
112
|
+
function projectScoredRows(scores, files, opts, logger) {
|
|
113
|
+
const inScope =
|
|
114
|
+
!opts?.fullScope && Array.isArray(files) && files.length > 0
|
|
115
|
+
? new Set(files)
|
|
116
|
+
: null;
|
|
117
|
+
const rows = Object.entries(scores)
|
|
118
|
+
.filter(([relPath]) => inScope === null || inScope.has(relPath))
|
|
119
|
+
.map(([relPath, s]) => ({
|
|
120
|
+
path: relPath,
|
|
121
|
+
lines: s?.lines ?? 0,
|
|
122
|
+
branches: s?.branches ?? 0,
|
|
123
|
+
functions: s?.functions ?? 0,
|
|
124
|
+
}));
|
|
125
|
+
logger.info(
|
|
126
|
+
`[Coverage] Scored ${Object.keys(scores).length} file(s)${inScope ? ` (${rows.length} in scope)` : ''}.`,
|
|
127
|
+
);
|
|
128
|
+
return rows;
|
|
129
|
+
}
|
|
65
130
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
131
|
+
/**
|
|
132
|
+
* The configured artifact the refresh reads and the baseline it writes —
|
|
133
|
+
* `coveragePath` / `baselinePath` from the resolved coverage gate, never a
|
|
134
|
+
* hardcoded default.
|
|
135
|
+
*
|
|
136
|
+
* @param {{ coveragePath: string, baselinePath: string }} coverageGate
|
|
137
|
+
* @param {string} cwd
|
|
138
|
+
* @returns {{ coveragePath: string, baselinePath: string,
|
|
139
|
+
* absBaselinePath: string, readCoverage: (dir: string) => object }}
|
|
140
|
+
*/
|
|
141
|
+
export function coverageUpdaterTargets({ coveragePath, baselinePath }, cwd) {
|
|
142
|
+
return {
|
|
143
|
+
coveragePath,
|
|
144
|
+
baselinePath,
|
|
145
|
+
absBaselinePath: path.resolve(cwd, baselinePath),
|
|
146
|
+
readCoverage: (dir) => readCoverageFinal(dir, { coveragePath }),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
74
149
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
150
|
+
/**
|
|
151
|
+
* `refreshBaseline` options for the coverage updater. `deps` substitutes the
|
|
152
|
+
* scorer's scope and scoring seams so a test never touches a real artifact.
|
|
153
|
+
*
|
|
154
|
+
* @param {string} cwd
|
|
155
|
+
* @param {{ absBaselinePath: string, readCoverage: Function }} targets
|
|
156
|
+
* @param {{ loadScope?: Function, buildScope?: Function, score?: Function,
|
|
157
|
+
* logger?: object }} [deps]
|
|
158
|
+
* @returns {object}
|
|
159
|
+
*/
|
|
160
|
+
export function buildCoverageRefreshOpts(
|
|
161
|
+
cwd,
|
|
162
|
+
{ absBaselinePath, readCoverage },
|
|
163
|
+
{
|
|
164
|
+
loadScope = loadC8ScopeConfig,
|
|
165
|
+
buildScope = buildScopePredicate,
|
|
166
|
+
score = scoreCoverageFinal,
|
|
167
|
+
logger,
|
|
168
|
+
} = {},
|
|
169
|
+
) {
|
|
170
|
+
return {
|
|
171
|
+
kind: 'coverage',
|
|
172
|
+
writePath: absBaselinePath,
|
|
173
|
+
epsilon: getBaselineEpsilon('coverage'),
|
|
174
|
+
scorer: buildCoverageUpdaterScorer(cwd, {
|
|
175
|
+
readCoverage,
|
|
176
|
+
loadScope,
|
|
177
|
+
buildScope,
|
|
178
|
+
score,
|
|
179
|
+
logger,
|
|
180
|
+
}),
|
|
80
181
|
};
|
|
81
182
|
}
|
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { getBaselines, getQuality, resolveConfig } from '../config-resolver.js';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
isCoverageFresh,
|
|
12
|
+
missingCoverageArtifactMessage,
|
|
13
|
+
} from '../coverage-capture.js';
|
|
11
14
|
import { loadCoverage as loadCoverageDefault } from '../coverage-utils.js';
|
|
12
15
|
import { checkResolutionFloor, scanAndScore } from '../crap-utils.js';
|
|
13
16
|
import { Logger } from '../Logger.js';
|
|
@@ -134,8 +137,32 @@ function reportScanSummary(summary, logger = Logger) {
|
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
140
|
+
* No artifact under `requireCoverage`: a full-scope refresh throws naming the
|
|
141
|
+
* capture contract (zero rows would write an empty baseline); a scoped one
|
|
142
|
+
* warns and yields no rows.
|
|
143
|
+
*
|
|
144
|
+
* @param {string} coverageAbs
|
|
145
|
+
* @param {{ coveragePath: string }} options
|
|
146
|
+
* @param {{ fullScope?: boolean } | undefined} opts
|
|
147
|
+
* @param {{ warn: Function }} logger
|
|
148
|
+
* @returns {object[]}
|
|
149
|
+
*/
|
|
150
|
+
function noCoverageRows(coverageAbs, options, opts, logger) {
|
|
151
|
+
if (opts?.fullScope) {
|
|
152
|
+
throw new Error(`[CRAP] ${missingCoverageArtifactMessage(coverageAbs)}`);
|
|
153
|
+
}
|
|
154
|
+
logger.warn(
|
|
155
|
+
`[CRAP] ⚠ No coverage artifact at ${options.coveragePath}. All files will be skipped under requireCoverage=true.`,
|
|
156
|
+
);
|
|
157
|
+
logger.warn(
|
|
158
|
+
"[CRAP] ⚠ Run 'npm run test:coverage' before 'npm run crap:update'.",
|
|
159
|
+
);
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Fails closed on a missing coverage artifact under `requireCoverage` (throws
|
|
165
|
+
* on a full-scope refresh; warns with no rows on a scoped one) and on a resolution rate below the floor (throws before anything is
|
|
139
166
|
* written: a broken join is wrong, not sparse).
|
|
140
167
|
*
|
|
141
168
|
* @param {ReturnType<typeof resolveCrapUpdaterOptions>} options
|
|
@@ -153,13 +180,7 @@ export function buildCrapUpdaterScorer(
|
|
|
153
180
|
: path.resolve(effectiveCwd, options.coveragePath);
|
|
154
181
|
const coverage = loadCoverage(coverageAbs);
|
|
155
182
|
if (!coverage && options.requireCoverage) {
|
|
156
|
-
logger
|
|
157
|
-
`[CRAP] ⚠ No coverage artifact at ${options.coveragePath}. All files will be skipped under requireCoverage=true.`,
|
|
158
|
-
);
|
|
159
|
-
logger.warn(
|
|
160
|
-
"[CRAP] ⚠ Run 'npm run test:coverage' before 'npm run crap:update'.",
|
|
161
|
-
);
|
|
162
|
-
return [];
|
|
183
|
+
return noCoverageRows(coverageAbs, options, opts, logger);
|
|
163
184
|
}
|
|
164
185
|
|
|
165
186
|
const summary = await scan({
|