@syntopica/create-baseline 0.10.6 → 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.
Files changed (51) hide show
  1. package/CHANGELOG.md +427 -0
  2. package/baseline-versions.json +5 -5
  3. package/bin/baseline-estate.mjs +63 -19
  4. package/bin/conformance/checkCoverageThresholds.mjs +26 -27
  5. package/bin/conformance/coverageBlockPattern.mjs +1 -0
  6. package/bin/conformance/coverageTestScripts.mjs +26 -0
  7. package/bin/conformance/coverageThresholdPattern.mjs +2 -0
  8. package/bin/conformance/delegatesCoverageTests.mjs +16 -0
  9. package/bin/conformance/isCoverageTestCommand.mjs +19 -0
  10. package/bin/dart/checkDartPins.mjs +39 -0
  11. package/bin/dart/checkGateJobs.mjs +20 -0
  12. package/bin/dart/checkLintsDependency.mjs +28 -0
  13. package/bin/dart/dartJobId.mjs +9 -0
  14. package/bin/dart/lintsSection.mjs +15 -0
  15. package/bin/dart/loadDartContext.mjs +27 -0
  16. package/bin/dart/runDartConformance.mjs +22 -0
  17. package/bin/estate/conformRows.mjs +17 -0
  18. package/bin/estate/findDartConsumers.mjs +25 -0
  19. package/bin/estate/findGoConsumers.mjs +23 -0
  20. package/bin/estate/findProjects.mjs +39 -0
  21. package/bin/estate/findSwiftConsumers.mjs +23 -0
  22. package/bin/estate/formatDartEstate.mjs +15 -0
  23. package/bin/estate/formatEstate.mjs +7 -1
  24. package/bin/estate/formatGoEstate.mjs +14 -0
  25. package/bin/estate/formatSwiftEstate.mjs +14 -0
  26. package/bin/estate/formatToolEstate.mjs +28 -0
  27. package/bin/estate/hasJob.mjs +4 -0
  28. package/bin/estate/pinFinding.mjs +26 -0
  29. package/bin/estate/readText.mjs +11 -0
  30. package/bin/go/checkGoGateJob.mjs +16 -0
  31. package/bin/go/checkGoPin.mjs +21 -0
  32. package/bin/go/goJobId.mjs +9 -0
  33. package/bin/go/loadGoContext.mjs +19 -0
  34. package/bin/go/runGoConformance.mjs +12 -0
  35. package/bin/scaffold/actionPins.mjs +4 -4
  36. package/bin/scaffold/baselineScripts.mjs +5 -1
  37. package/bin/scaffold/ciWorkflow.mjs +70 -9
  38. package/bin/scaffold/hasTaduBacklog.mjs +18 -0
  39. package/bin/scaffold/lefthookConfig.mjs +30 -5
  40. package/bin/scaffold/oxlintConfig.mjs +16 -8
  41. package/bin/scaffold/writeCiWorkflow.mjs +6 -1
  42. package/bin/scaffold/writeMissing.mjs +8 -2
  43. package/bin/swift/checkSwiftGateJob.mjs +16 -0
  44. package/bin/swift/checkSwiftPin.mjs +22 -0
  45. package/bin/swift/loadSwiftContext.mjs +14 -0
  46. package/bin/swift/runSwiftConformance.mjs +12 -0
  47. package/dart-versions.json +4 -0
  48. package/go-versions.json +3 -0
  49. package/package.json +11 -7
  50. package/python-versions.json +1 -1
  51. package/swift-versions.json +3 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,427 @@
1
+ # @syntopica/create-baseline
2
+
3
+ ## 0.12.0
4
+
5
+ - The published package now includes `CHANGELOG.md`, so an installed copy
6
+ carries its own release notes. `baseline-changes` (in
7
+ `@syntopica/quality-config`) prints the sections an upgrade passed.
8
+ - The generated `package.json` gets a `changes` script (`baseline-changes`) that
9
+ `check:ci` runs first, so the run after an upgrade prints what changed. Commit
10
+ the `.baseline-versions.json` it writes. Existing repositories add the script
11
+ and the `pnpm changes &&` prefix by hand.
12
+
13
+ - Generated CI workflow and `lefthook.yml` skip the gates on backlog-only
14
+ changes in repositories that keep a tadu backlog (`todo/tadu.json` or
15
+ `TODO.md`), running `tadu doctor .` instead. Output for other repositories is
16
+ unchanged. Adopters running `prettier --check .` must add `todo/` to
17
+ `.prettierignore`.
18
+
19
+ ## 0.11.0
20
+
21
+ - Add Dart, Swift and Go projects to the estate report and check their gate
22
+ versions.
23
+
24
+ - Recognize coverage scripts invoked by CI and report fatal coverage findings.
25
+
26
+ - Resolve the Oxlint configuration from the consumer project and update the
27
+ baseline package pins.
28
+
29
+ ## 0.10.6
30
+
31
+ ### Patch Changes
32
+
33
+ - fix: pin `@syntopica/eslint-config` `^0.10.0`, `@syntopica/quality-config`
34
+ `^0.14.0` and `eslint-plugin-code-policy` `^0.9.0`: the `boundaries` preset
35
+ with `atomic: false`, `knip --production` support and the opt-in dependency
36
+ cruiser module boundaries.
37
+
38
+ ## 0.10.5
39
+
40
+ ### Patch Changes
41
+
42
+ - fix: pin `@syntopica/quality-config` `^0.13.2`, whose knip preset stops
43
+ reporting `type-coverage`, `lefthook` and hosted ESLint peers wrongly.
44
+ - The generated CI workflow pins `actions/checkout` v7, `actions/setup-node` v7,
45
+ `pnpm/action-setup` v6.1.0 and `zizmorcore/zizmor-action` v0.6.4.
46
+
47
+ ## 0.10.4
48
+
49
+ ### Patch Changes
50
+
51
+ - fix: pin `@syntopica/prettier-config` `^0.3.0`, which keeps managed BEGIN/END
52
+ blocks verbatim and wraps the rest of `AGENTS.md` and `CLAUDE.md`.
53
+
54
+ ## 0.10.3
55
+
56
+ ### Patch Changes
57
+
58
+ - fix: pin `@syntopica/quality-config` `^0.13.1`, whose knip preset leaves no
59
+ configuration hints in a CLI-shaped project.
60
+
61
+ ## 0.10.2
62
+
63
+ ### Patch Changes
64
+
65
+ - fix: pin `@syntopica/quality-config` `^0.13.0`, which ships the
66
+ `baseline-hooks-install` bin the templates now call from `prepare`.
67
+
68
+ ## 0.10.1
69
+
70
+ ### Patch Changes
71
+
72
+ - fix: pin `@syntopica/prettier-config` `^0.2.2`. 0.10.0 pinned `^0.2.1`, which
73
+ was tagged but never reached npm, so 0.10.0 was never published either.
74
+
75
+ ## 0.10.0
76
+
77
+ ### Minor Changes
78
+
79
+ - feat!: the scaffolders and `--check` use the `@syntopica` scope. Templates
80
+ install `@syntopica/eslint-config`, `@syntopica/tsconfig`,
81
+ `@syntopica/prettier-config` and `@syntopica/quality-config`, and the tsconfig
82
+ conformance check expects a `@syntopica/tsconfig` preset, so a repository
83
+ still on the `@busirocket` packages reports as non-conformant until it moves.
84
+ - feat!: the Python checks follow the rename to `codeality-py`: the quality
85
+ group depends on `syntopica-codeality-py`, the workflow runs
86
+ `codeality-py gate`, and the lock check reads `python-versions.json`, split
87
+ out of `baseline-versions.json` so `--check` no longer expects a Python
88
+ release among the npm packages.
89
+ - feat: the estate report covers the Python projects. `baseline-estate` prints a
90
+ second table for every project whose pyproject.toml depends on
91
+ `syntopica-codeality-py`, found up to three levels deep. Four columns: the
92
+ quality group is declared, a workflow runs `codeality-py gate` on push, its
93
+ actions are pinned by commit, and uv.lock pins the current release.
94
+ - fix: a nested Python project's workflow is written at the repository root as
95
+ `quality-<project>.yml`, where GitHub reads it, on the checked-out branch
96
+ rather than always `main`.
97
+ - build(security): generated CI workflows check out with
98
+ `persist-credentials: false`.
99
+ - chore: templates pin the current releases of the shared packages.
100
+
101
+ ## 0.9.0
102
+
103
+ ### Minor Changes
104
+
105
+ - feat: two tsconfig conformance checks, and a `tscfg` column in the estate
106
+ matrix.
107
+
108
+ The defect they catch is the expensive kind: a gate that exits 0 while reading
109
+ almost nothing. consumer-g's root `tsconfig.json` referenced three projects
110
+ and its `type-check` script named only two, so `app/`, `proxy.ts` and
111
+ `instrumentation.ts` - the largest surface in the repo - reached `check:ci`
112
+ unchecked for months while the estate report called the repository conformant.
113
+
114
+ `--check` now asserts, first, that every project a solution-style root
115
+ references is reachable from `type-check` (a bare `tsc -b`/`vue-tsc -b`
116
+ passes; a project-scoped one covers only the projects it names), and second,
117
+ that each project tsconfig extends an `@busirocket/tsconfig` preset - judged
118
+ per shape: a single-project root extends a preset directly, a solution root
119
+ must not, because `baseline-type-coverage` walks its `references` and a root
120
+ that extends instead of referencing hides every project behind one.
121
+
122
+ - feat: `--check` asserts the gates are wired, not merely installed.
123
+
124
+ It used to assert that four packages appeared in `package.json`, which it did
125
+ happily for a repository with no CI, a `lint` script that ignored warnings,
126
+ and a `check:ci` that skipped knip, jscpd, dependency-cruiser and
127
+ type-coverage. Adoption was measured by presence, so drift in enforcement was
128
+ invisible by construction.
129
+
130
+ Seven checks now run: the `--max-warnings 0` flag (and a numeric budget
131
+ reported separately, because it is a ratchet rather than an oversight), every
132
+ gate reachable from what CI actually runs, a workflow that fires on push,
133
+ actions pinned to commit SHAs, coverage thresholds that are produced and
134
+ enforced, lefthook installed into `.git/hooks`, and dependency ranges able to
135
+ resolve the pinned baseline.
136
+
137
+ Findings can be waived by id in `baseline.exceptions.json` with a required
138
+ `reason` and an optional, enforced `expires`.
139
+
140
+ - feat: `--fix` repairs the mechanical half.
141
+
142
+ Rewrites the lint flag, appends missing gates to the right `check:*` entry,
143
+ widens a stuck dependency range, writes the CI workflow, and inserts a
144
+ `thresholds` block with `autoUpdate: true` and a floor of zero - vitest's own
145
+ ratchet, so an existing repository enters at the level its suite actually
146
+ reaches instead of turning red on a flat 80.
147
+
148
+ - feat: `create-baseline --write` writes `.github/workflows/ci.yml`.
149
+
150
+ No template shipped one and this tool never wrote one, so every adopter
151
+ hand-rolled CI or skipped it; eight of seventeen had no workflow at all while
152
+ carrying the full gate set as scripts. Four jobs, three commands, every action
153
+ pinned to a commit SHA with the tag kept as a comment. Nothing is written over
154
+ a workflow that already runs the gates, and a repository with unrelated
155
+ workflows is reported rather than given a second pipeline.
156
+
157
+ - feat: `baseline-estate <dir>` - the conformance check over every consumer.
158
+
159
+ One row per repository, one column per class of gate. Formalises the manual
160
+ pre-publish sweep that already caught three defects the templates and the unit
161
+ tests both missed. Exits non-zero when any consumer fails, so it can gate a
162
+ release.
163
+
164
+ - feat: `.oxlintrc.json` and a `lint:fast` script are part of the scaffolded
165
+ wiring, and the generated `lefthook.yml` gains a `commit-msg` hook.
166
+
167
+ ### Patch Changes
168
+
169
+ - fix: the pnpm workspace parser no longer backtracks exponentially.
170
+
171
+ `/^packages:\n((?:\s*-.*\n?)+)/m` lets `\s*` and `.*` exchange characters.
172
+ Replaced with a line loop, which has no backtracking to reason about and says
173
+ what it does. Found by `eslint-plugin-regexp`, newly part of the base config.
174
+
175
+ ## 0.8.1
176
+
177
+ ### Patch Changes
178
+
179
+ - fix: `--check` prints only the packages that are missing.
180
+
181
+ A project missing one package was handed the full eleven-package install line,
182
+ which reads as "you have none of this" and, pasted, re-pins ten packages
183
+ nobody asked to touch.
184
+
185
+ ## 0.8.0
186
+
187
+ ### Minor Changes
188
+
189
+ - feat: read a monorepo's workspace manifests, not just the root one.
190
+
191
+ In a pnpm or npm workspace the per-package dependencies -- eslint-config,
192
+ tsconfig, code-policy -- are declared by each workspace. Reading only the root
193
+ manifest reported every one of them missing: consumer-y, a repo already
194
+ running the whole toolchain across six workspaces, was told it had none of it,
195
+ and the peer check reported "not verified -- not installed here yet" about
196
+ packages that were installed and working.
197
+
198
+ Both now walk the workspaces the repo itself declares, and the peer report
199
+ labels each workspace and suggests `--filter` for it.
200
+
201
+ ## 0.7.0
202
+
203
+ ### Minor Changes
204
+
205
+ - feat: detect TanStack Start and pick its knip preset.
206
+
207
+ A Start app carries both react and vite, so it was detected as `vite-react`
208
+ and scaffolded with entry globs that match nothing in it.
209
+
210
+ ## 0.6.1
211
+
212
+ ### Patch Changes
213
+
214
+ - fix: only mention the Next tsconfig's JSX trap to a Next project. 0.6.0
215
+ printed it to every adopter, including Vite and Nuxt ones the advice cannot
216
+ apply to.
217
+
218
+ ## 0.6.0
219
+
220
+ ### Minor Changes
221
+
222
+ - feat: recognise every filename a gate tool would load, and say so instead of
223
+ writing a file the tool ignores.
224
+
225
+ consumer-m carried a `knip.json` that set `project` to `["tsconfig.json"]`, so
226
+ knip scanned almost nothing: 34 live dependencies reported as unused and 23
227
+ genuinely dead files never found. `--write` checked for `knip.config.ts` and
228
+ `knip.config.js`, saw neither, and wrote the shared factory next to it. Knip
229
+ went on loading the json. The gate stayed broken while looking configured.
230
+
231
+ Each entry now lists every filename its tool actually resolves -- knip's
232
+ seven, lefthook's three, renovate's six, dependency-cruiser's five -- and a
233
+ shadowed config is named in the output with what to do about it, rather than
234
+ skipped in silence.
235
+
236
+ - feat: `--write` names the vitest trap that comes with the shared Next
237
+ tsconfig.
238
+
239
+ `@busirocket/tsconfig/nextjs` sets `jsx: preserve`, which is what Next
240
+ documents: SWC does the transform at build time. Vitest does not go through
241
+ SWC, so every `.tsx` test fails to parse until its own config names the
242
+ runtime -- and on Vite 8 the older `esbuild` block is ignored, so a config
243
+ that used to work silently stops.
244
+
245
+ ## 0.5.2
246
+
247
+ ### Patch Changes
248
+
249
+ - chore: refresh the `@busirocket/prettier-config` pin to `^0.2.0`.
250
+
251
+ ## 0.5.1
252
+
253
+ ### Patch Changes
254
+
255
+ - fix: `--write` adds `prepare: lefthook install` alongside the lefthook config.
256
+
257
+ Without it the generated `lefthook.yml` is inert: the hooks only reach
258
+ `.git/hooks` when `lefthook install` runs. Three repos in a row adopted the
259
+ gates with the file in place and no hook installed, and knip caught it by
260
+ reporting `lefthook` as an unused dependency.
261
+
262
+ The closing note also mentions `ERR_PNPM_IGNORED_BUILDS`, which is how pnpm
263
+ reports the other half of the same problem: lefthook's install script has to
264
+ be allowed for the hooks to be written.
265
+
266
+ ## 0.5.0
267
+
268
+ ### Minor Changes
269
+
270
+ - feat: every mode reports the ESLint peers your config needs and does not have.
271
+
272
+ `@busirocket/eslint-config` ships TypeScript source rather than a build, so
273
+ its imports resolve from the consuming project. pnpm reports a peer mismatch
274
+ as one line among hundreds on install, and the consequence surfaces much later
275
+ as a crash from inside ESLint naming neither the baseline nor the peer.
276
+
277
+ Adopting consumer-u hit three in a row: `@vitest/eslint-plugin` absent,
278
+ `eslint-plugin-tailwindcss` on a prerelease whose `configs.recommended` is
279
+ still eslintrc-format, and `eslint-plugin-boundaries` a major behind the
280
+ schema the shared layer emits. Each took its own diagnosis from an opaque
281
+ stack trace.
282
+
283
+ The subpaths are read from the project's own `eslint.config.*`, so a project
284
+ that never composes `/tailwind` is never told about a Tailwind plugin.
285
+ Manifests are read out of `node_modules` rather than through
286
+ `require.resolve`, because these packages define `exports` without a root or
287
+ `./package.json` entry and resolving either throws while the package is
288
+ installed and working.
289
+
290
+ ## 0.4.1
291
+
292
+ ### Patch Changes
293
+
294
+ - chore: refresh the `@busirocket/eslint-config` pin to `^0.7.3`.
295
+
296
+ ## 0.4.0
297
+
298
+ ### Minor Changes
299
+
300
+ - feat: `create-baseline --write` scaffolds the wiring instead of describing it.
301
+
302
+ The tool could tell you `lefthook.yml` was missing and never write it, so
303
+ every adopting repo hand-wrote the same four files and the same ten scripts.
304
+ Measured across seven real adoptions in one sitting: the only thing that
305
+ varied was the knip preset, which is read off the project's dependencies, and
306
+ which directories to exempt from `no-orphans`.
307
+
308
+ `--write` creates `knip.config.ts`, `lefthook.yml`, `renovate.json` and
309
+ `.dependency-cruiser.cjs` when absent, and adds the baseline scripts
310
+ `package.json` does not already define. Nothing that exists is overwritten and
311
+ re-running is a no-op, so it is safe on a half-adopted repo.
312
+
313
+ - chore: `baseline-versions.json` now pins `dependency-cruiser`, `jiti` and
314
+ `type-coverage`.
315
+
316
+ `--write` generates a `.dependency-cruiser.cjs` that reaches the shared
317
+ factory through jiti, and a `type-coverage` script behind
318
+ `baseline-type-coverage`. Without these three on the install line the
319
+ generated wiring fails on its first run.
320
+
321
+ ## 0.3.9
322
+
323
+ ### Patch Changes
324
+
325
+ - chore: refresh the `@busirocket/quality-config` pin to `^0.7.0`. Derived from
326
+ the workspace by `pnpm sync-versions`.
327
+
328
+ ## 0.3.8
329
+
330
+ ### Patch Changes
331
+
332
+ - chore: refresh the `eslint-plugin-code-policy` and `@busirocket/eslint-config`
333
+ pins. Derived from the workspace by `pnpm sync-versions`.
334
+
335
+ ## 0.3.7
336
+
337
+ ### Patch Changes
338
+
339
+ - chore: refresh the `@busirocket/eslint-config` pin to `^0.7.1`. Derived from
340
+ the workspace by `pnpm sync-versions`; no check was added or removed.
341
+
342
+ ## 0.3.6
343
+
344
+ ### Patch Changes
345
+
346
+ - chore: refresh the `@busirocket/quality-config` pin to `^0.6.1`. Derived from
347
+ the workspace by `pnpm sync-versions`; no check was added or removed.
348
+
349
+ ## 0.3.5
350
+
351
+ ### Patch Changes
352
+
353
+ - chore: refresh the `eslint-plugin-code-policy` pin to `^0.7.2`, which stops
354
+ `file-kind-placement` firing on test files. Derived from the workspace by
355
+ `pnpm sync-versions`; no check was added or removed.
356
+
357
+ ## 0.3.4
358
+
359
+ ### Patch Changes
360
+
361
+ - chore: refresh the pins injected into scaffolded projects.
362
+
363
+ `eslint-plugin-code-policy` `^0.7.0` -> `^0.7.1` and
364
+ `@busirocket/quality-config` `^0.5.0` -> `^0.6.0`, both carrying fixes found
365
+ by running the 0.7.0 / 0.5.0 build against the repos that adopt it. Derived
366
+ from the workspace by `pnpm sync-versions`; no check was added or removed.
367
+
368
+ ## 0.3.3
369
+
370
+ ### Patch Changes
371
+
372
+ - chore: refresh the pins injected into scaffolded projects.
373
+
374
+ `@busirocket/eslint-config` `^0.6.0` -> `^0.7.0`, `eslint-plugin-code-policy`
375
+ `^0.6.0` -> `^0.7.0`, and `@busirocket/quality-config` `^0.4.0` -> `^0.5.0`.
376
+ Derived from the workspace by `pnpm sync-versions`; no check was added or
377
+ removed.
378
+
379
+ ## 0.3.2
380
+
381
+ ### Patch Changes
382
+
383
+ - chore: refresh the pins in `baseline-versions.json`.
384
+
385
+ `@busirocket/eslint-config` to `^0.6.0` and `@busirocket/quality-config` to
386
+ `^0.3.0`. No check was added or removed.
387
+
388
+ ## 0.3.1
389
+
390
+ ### Patch Changes
391
+
392
+ - chore: refresh the pins in `baseline-versions.json`.
393
+
394
+ `@busirocket/quality-config` to `^0.2.0`, `@busirocket/prettier-config` to
395
+ `^0.1.2`, `@busirocket/tsconfig` to `^0.2.1`. No check was added or removed.
396
+
397
+ ## 0.3.0
398
+
399
+ ### Minor Changes
400
+
401
+ - feat: require the quality-gate half of the baseline.
402
+
403
+ `baseline-versions.json` now also pins `@busirocket/quality-config`, `knip`
404
+ and `lefthook`, and `--hard` additionally requires `knip.config.ts`/`.js`,
405
+ `lefthook.yml` and `renovate.json` to exist. A project that passed `--check`
406
+ or `--hard` on 0.2.1 will fail until it adopts those - that is the point of
407
+ the ratchet, but it is a behavior change, not a patch.
408
+
409
+ Pins bumped in the same file: `@busirocket/eslint-config` to `^0.5.0`,
410
+ `eslint-plugin-code-policy` to `^0.6.0`.
411
+
412
+ ### Patch Changes
413
+
414
+ - fix: stop requiring `@busirocket/tsconfig` where it cannot apply.
415
+
416
+ A project whose own `tsconfig.json` extends a config inside a dot-directory -
417
+ build output its framework regenerates, such as Nuxt's
418
+ `./.nuxt/tsconfig.json` - has no insertion point for the shared presets, so
419
+ demanding the dependency only added a package nothing reads, which an
420
+ unused-dependency gate then reports as dead weight.
421
+
422
+ The exemption is narrow: an authored `./tsconfig.base.json` still requires the
423
+ package, so does a project with no `tsconfig.json`, and a `tsconfig.json` that
424
+ cannot be parsed as JSON is treated as authored so an unreadable file never
425
+ silently drops the requirement.
426
+
427
+ - fix: drop the `dependency-cruiser` pin consumers could not meet.
@@ -1,9 +1,9 @@
1
1
  {
2
- "@syntopica/eslint-config": "^0.10.0",
3
- "@syntopica/prettier-config": "^0.3.0",
4
- "@syntopica/tsconfig": "^0.3.1",
5
- "@syntopica/quality-config": "^0.14.0",
6
- "eslint-plugin-code-policy": "^0.9.0",
2
+ "@syntopica/eslint-config": "^0.10.2",
3
+ "@syntopica/prettier-config": "^0.3.1",
4
+ "@syntopica/tsconfig": "^0.3.2",
5
+ "@syntopica/quality-config": "^0.17.0",
6
+ "eslint-plugin-code-policy": "^0.9.2",
7
7
  "dependency-cruiser": "^18.1.1",
8
8
  "jiti": "^2.7.0",
9
9
  "jscpd": "^5.0.14",
@@ -5,11 +5,21 @@ import { argv, cwd, exit } from 'node:process'
5
5
  import { fileURLToPath } from 'node:url'
6
6
 
7
7
  import { runConformance } from './conformance/runConformance.mjs'
8
+ import { runDartConformance } from './dart/runDartConformance.mjs'
9
+ import { conformRows } from './estate/conformRows.mjs'
8
10
  import { findConsumers } from './estate/findConsumers.mjs'
11
+ import { findDartConsumers } from './estate/findDartConsumers.mjs'
12
+ import { findGoConsumers } from './estate/findGoConsumers.mjs'
9
13
  import { findPythonConsumers } from './estate/findPythonConsumers.mjs'
14
+ import { findSwiftConsumers } from './estate/findSwiftConsumers.mjs'
15
+ import { formatDartEstate } from './estate/formatDartEstate.mjs'
10
16
  import { formatEstate } from './estate/formatEstate.mjs'
17
+ import { formatGoEstate } from './estate/formatGoEstate.mjs'
11
18
  import { formatPythonEstate } from './estate/formatPythonEstate.mjs'
19
+ import { formatSwiftEstate } from './estate/formatSwiftEstate.mjs'
20
+ import { runGoConformance } from './go/runGoConformance.mjs'
12
21
  import { runPythonConformance } from './python/runPythonConformance.mjs'
22
+ import { runSwiftConformance } from './swift/runSwiftConformance.mjs'
13
23
 
14
24
  // Formalises the manual pre-publish sweep. Every release of these packages was
15
25
  // already being A/B'd by hand against the repositories that consume them -
@@ -25,11 +35,29 @@ async function main() {
25
35
  const pythonVersions = JSON.parse(
26
36
  await readFile(resolve(PACKAGE_ROOT, 'python-versions.json'), 'utf8'),
27
37
  )
38
+ const dartVersions = JSON.parse(
39
+ await readFile(resolve(PACKAGE_ROOT, 'dart-versions.json'), 'utf8'),
40
+ )
41
+ const swiftVersions = JSON.parse(
42
+ await readFile(resolve(PACKAGE_ROOT, 'swift-versions.json'), 'utf8'),
43
+ )
44
+ const goVersions = JSON.parse(
45
+ await readFile(resolve(PACKAGE_ROOT, 'go-versions.json'), 'utf8'),
46
+ )
28
47
  const today = new Date().toISOString().slice(0, 10)
29
48
 
30
49
  const consumers = await findConsumers(root)
31
50
  const pythonConsumers = await findPythonConsumers(root)
32
- if (!consumers.length && !pythonConsumers.length) {
51
+ const dartConsumers = await findDartConsumers(root)
52
+ const swiftConsumers = await findSwiftConsumers(root)
53
+ const goConsumers = await findGoConsumers(root)
54
+ if (
55
+ !consumers.length &&
56
+ !pythonConsumers.length &&
57
+ !dartConsumers.length &&
58
+ !swiftConsumers.length &&
59
+ !goConsumers.length
60
+ ) {
33
61
  console.log(`baseline-estate: no @syntopica consumers under ${root}.`)
34
62
  return
35
63
  }
@@ -51,26 +79,42 @@ async function main() {
51
79
  // The Python projects are a second table with their own columns: the
52
80
  // audit that added them found nine gates green on one laptop and running
53
81
  // nowhere else, which the JavaScript table could not see at all.
54
- const pythonRows = []
55
- for (const consumer of pythonConsumers) {
56
- try {
57
- const { findings } = await runPythonConformance(
58
- consumer.path,
59
- pythonVersions,
60
- )
61
- pythonRows.push({ name: consumer.name, findings })
62
- } catch (error) {
63
- pythonRows.push({ name: consumer.name, error: String(error.message) })
64
- }
65
- }
66
- if (pythonRows.length) {
67
- if (rows.length) console.log('')
68
- console.log(formatPythonEstate(pythonRows))
82
+ const pythonRows = await conformRows(pythonConsumers, (path) =>
83
+ runPythonConformance(path, pythonVersions),
84
+ )
85
+ // Dart, Swift and Go follow the same shape: their gates live in the root
86
+ // codeality.yml, one job per project, so each table asks whether that job
87
+ // exists and pins a released tool.
88
+ const dartRows = await conformRows(dartConsumers, (path) =>
89
+ runDartConformance(path, dartVersions),
90
+ )
91
+ const swiftRows = await conformRows(swiftConsumers, (path) =>
92
+ runSwiftConformance(path, swiftVersions),
93
+ )
94
+ const goRows = await conformRows(goConsumers, (path) =>
95
+ runGoConformance(path, goVersions),
96
+ )
97
+ const tables = [
98
+ [pythonRows, formatPythonEstate],
99
+ [dartRows, formatDartEstate],
100
+ [swiftRows, formatSwiftEstate],
101
+ [goRows, formatGoEstate],
102
+ ]
103
+ let printed = rows.length > 0
104
+ for (const [tableRows, format] of tables) {
105
+ if (!tableRows.length) continue
106
+ if (printed) console.log('')
107
+ console.log(format(tableRows))
108
+ printed = true
69
109
  }
70
110
 
71
- const failing = [...rows, ...pythonRows].filter(
72
- (row) => row.error || row.findings.some((f) => f.level === 'error'),
73
- )
111
+ const failing = [
112
+ ...rows,
113
+ ...pythonRows,
114
+ ...dartRows,
115
+ ...swiftRows,
116
+ ...goRows,
117
+ ].filter((row) => row.error || row.findings.some((f) => f.level === 'error'))
74
118
  // Exit non-zero so this can gate a release the same way any other check
75
119
  // does. The estate is the release's blast radius; publishing into a red one
76
120
  // is the mistake this is meant to prevent.
@@ -1,5 +1,7 @@
1
- const HAS_THRESHOLDS = /\bthresholds\s*:|\bcoverageThreshold\s*:/
2
- const HAS_COVERAGE_BLOCK = /\bcoverage\s*:\s*\{/g
1
+ import { coverageBlockPattern } from './coverageBlockPattern.mjs'
2
+ import { coverageTestScripts } from './coverageTestScripts.mjs'
3
+ import { coverageThresholdPattern } from './coverageThresholdPattern.mjs'
4
+ import { delegatesCoverageTests } from './delegatesCoverageTests.mjs'
3
5
 
4
6
  /**
5
7
  * Coverage has to be measured, and the measurement has to fail a build.
@@ -19,14 +21,15 @@ const HAS_COVERAGE_BLOCK = /\bcoverage\s*:\s*\{/g
19
21
  * builds red on the first day, and a gate that starts red gets deleted rather
20
22
  * than met.
21
23
  */
22
- export function checkCoverageThresholds({ scripts, testConfig }) {
24
+ export function checkCoverageThresholds(context) {
25
+ const { scripts, testConfig } = context
23
26
  const findings = []
24
- const test = scripts.test
27
+ const tests = coverageTestScripts(context)
25
28
 
26
29
  // A monorepo root runs its suites through the workspaces, and its coverage
27
30
  // configuration lives in each of them. Judging the root would report the
28
31
  // reference implementation as having no tests at all.
29
- if (delegates(scripts)) {
32
+ if (delegatesCoverageTests(scripts)) {
30
33
  return [
31
34
  {
32
35
  id: 'coverage',
@@ -39,26 +42,36 @@ export function checkCoverageThresholds({ scripts, testConfig }) {
39
42
  ]
40
43
  }
41
44
 
42
- if (!test) {
45
+ if (!tests.length) {
43
46
  return [
44
47
  {
45
48
  id: 'coverage',
46
49
  level: 'error',
47
- message: 'no `test` script',
48
- detail: 'Nothing to measure coverage of.',
50
+ message: 'no coverage test script',
51
+ detail:
52
+ 'Expected a `test` script or a Vitest/Jest script reachable from CI.',
49
53
  },
50
54
  ]
51
55
  }
52
56
 
53
- if (!/--coverage\b/.test(test) && !/\bcoverage\b/.test(test)) {
57
+ for (const [name, test] of tests) {
58
+ const measures =
59
+ name === 'test'
60
+ ? /--coverage\b|\bcoverage\b/.test(test)
61
+ : /(?:^|\s)--coverage(?:=true)?(?:\s|$)/.test(test) &&
62
+ !/(?:^|\s)--coverage(?:\.enabled)?(?:=|\s+)false(?:\s|$)/.test(
63
+ test,
64
+ ) &&
65
+ !/(?:^|\s)--no-coverage(?:\.enabled)?(?:\s|$|=)/.test(test)
66
+ if (measures) continue
54
67
  findings.push({
55
68
  id: 'coverage-run',
56
69
  level: 'error',
57
- message: '`test` does not produce a coverage report',
70
+ message: `\`${name}\` does not produce a coverage report`,
58
71
  detail: 'Without `--coverage` the thresholds below are never evaluated.',
59
72
  fix: {
60
73
  kind: 'set-script',
61
- name: 'test',
74
+ name,
62
75
  value: `${test.trim()} --coverage`,
63
76
  },
64
77
  })
@@ -75,9 +88,9 @@ export function checkCoverageThresholds({ scripts, testConfig }) {
75
88
  return findings
76
89
  }
77
90
 
78
- if (HAS_THRESHOLDS.test(testConfig.text)) return findings
91
+ if (coverageThresholdPattern.test(testConfig.text)) return findings
79
92
 
80
- const coverageBlocks = [...testConfig.text.matchAll(HAS_COVERAGE_BLOCK)]
93
+ const coverageBlocks = [...testConfig.text.matchAll(coverageBlockPattern)]
81
94
  findings.push({
82
95
  id: 'coverage-thresholds',
83
96
  level: 'error',
@@ -96,17 +109,3 @@ export function checkCoverageThresholds({ scripts, testConfig }) {
96
109
  })
97
110
  return findings
98
111
  }
99
-
100
- // Whether the project hands its test run to a workspace runner rather than
101
- // running a suite of its own. Matched against every script, not just `test`:
102
- // the baseline repo reaches its suites through `check:ci`, which calls
103
- // `turbo run ... test ...`, and defines no root `test` script at all.
104
- function delegates(scripts) {
105
- return Object.values(scripts).some(
106
- (command) =>
107
- typeof command === 'string' &&
108
- /\b(?:turbo|nx|lerna)\s+run\s+(?:[\w:-]+\s+)*test\b|(?:pnpm|npm|yarn)\s+(?:-r|--recursive)\s+(?:run\s+)?test\b/.test(
109
- command,
110
- ),
111
- )
112
- }
@@ -0,0 +1 @@
1
+ export const coverageBlockPattern = /\bcoverage\s*:\s*\{/g
@@ -0,0 +1,26 @@
1
+ import { ciEntrypoints } from './ciEntrypoints.mjs'
2
+ import { expandScripts } from './expandScripts.mjs'
3
+ import { isCoverageTestCommand } from './isCoverageTestCommand.mjs'
4
+
5
+ // Preserve the conventional test contract; otherwise inspect only named
6
+ // runner commands CI reaches, never unrelated release or Rust test scripts.
7
+ export function coverageTestScripts({
8
+ scripts,
9
+ workflows = [],
10
+ runners = {},
11
+ testConfig,
12
+ }) {
13
+ if (scripts.test) return [['test', scripts.test]]
14
+
15
+ const fromCi = ciEntrypoints(workflows, scripts)
16
+ const entries = fromCi.length
17
+ ? fromCi
18
+ : ['check:ci', 'check:quality', 'check:security']
19
+ const { names } = expandScripts(scripts, entries, runners)
20
+ const tests = []
21
+ for (const name of names) {
22
+ const command = scripts[name] ?? ''
23
+ if (isCoverageTestCommand(command, testConfig)) tests.push([name, command])
24
+ }
25
+ return tests
26
+ }