@hublo/sentinel 1.7.0-alpha.6 → 1.7.0-alpha.8

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 (57) hide show
  1. package/README.md +1 -0
  2. package/dist/bin/sentinel.js +25 -87
  3. package/dist/{chunk-DLGBRLUU.js → chunk-EESVRILJ.js} +3 -16
  4. package/dist/chunk-EESVRILJ.js.map +1 -0
  5. package/dist/{chunk-ZNANJEMK.js → chunk-JT7ZMH44.js} +30 -16
  6. package/dist/chunk-JT7ZMH44.js.map +1 -0
  7. package/dist/chunk-LU4E4TVD.js +183 -0
  8. package/dist/chunk-LU4E4TVD.js.map +1 -0
  9. package/dist/{chunk-THTXP2QU.js → chunk-LX7EG6PJ.js} +5 -6
  10. package/dist/chunk-LX7EG6PJ.js.map +1 -0
  11. package/dist/{chunk-4YQXLPJ5.js → chunk-PMRL4MH6.js} +2 -2
  12. package/dist/chunk-PXTU5MPW.js +9 -0
  13. package/dist/chunk-PXTU5MPW.js.map +1 -0
  14. package/dist/{chunk-LNFGVGLE.js → chunk-SWWQ7X7B.js} +11 -23
  15. package/dist/{chunk-LNFGVGLE.js.map → chunk-SWWQ7X7B.js.map} +1 -1
  16. package/dist/{chunk-YRBFCQQI.js → chunk-VZZ3DOC3.js} +2954 -1219
  17. package/dist/{chunk-P6KTBQ2Q.js → chunk-ZASD5YPF.js} +480 -186
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.js +6 -7
  20. package/dist/roles/build/nest/toolchain.d.ts +1 -1
  21. package/dist/roles/build/nest/toolchain.js +2 -6
  22. package/dist/roles/build/nest/toolchain.js.map +1 -1
  23. package/dist/roles/sql/config.d.ts +68 -0
  24. package/dist/roles/sql/config.js +8 -0
  25. package/dist/roles/sql/config.js.map +1 -0
  26. package/dist/roles/static-analysis/config.js +2 -1
  27. package/dist/roles/test/nest/toolchain.d.ts +1 -1
  28. package/dist/roles/test/nest/toolchain.js +2 -3
  29. package/dist/roles/test/nest/toolchain.js.map +1 -1
  30. package/dist/roles/test/react/toolchain.js +2 -3
  31. package/dist/roles/test/react/toolchain.js.map +1 -1
  32. package/dist/roles/test/setup/jest-parity.js +2 -2
  33. package/dist/roles/test/setup/workspace-entry.js +2 -2
  34. package/dist/roles/test/shared-test-config.d.ts +1 -1
  35. package/dist/roles/test/shared-test-config.js +2 -3
  36. package/dist/tsconfig/nest.json +1 -10
  37. package/dist/tsconfig/node.json +1 -11
  38. package/dist/tsconfig/react.json +0 -3
  39. package/dist/{tsconfig-aliases-C_PxuZni.d.ts → tsconfig-aliases-Ce6axdJ4.d.ts} +2 -17
  40. package/dist/{validate-4V3EGTXN.js → validate-QYP7HFSY.js} +2 -4
  41. package/docs/build-adoption.md +0 -7
  42. package/docs/sql-adoption.md +282 -0
  43. package/docs/test-adoption.md +1 -8
  44. package/docs/typescript-adoption.md +13 -96
  45. package/docs/typescript-traces.md +217 -3
  46. package/docs/using-sentinel.md +2 -1
  47. package/package.json +6 -4
  48. package/dist/chunk-DLGBRLUU.js.map +0 -1
  49. package/dist/chunk-H4HAFJFZ.js +0 -79
  50. package/dist/chunk-H4HAFJFZ.js.map +0 -1
  51. package/dist/chunk-THTXP2QU.js.map +0 -1
  52. package/dist/chunk-ZFG6P27V.js +0 -313
  53. package/dist/chunk-ZNANJEMK.js.map +0 -1
  54. package/dist/chunk-ZZMYV576.js +0 -297
  55. package/dist/migrate-X7PB2X7R.js +0 -553
  56. package/dist/tsconfig/legacy.json +0 -21
  57. /package/dist/{chunk-4YQXLPJ5.js.map → chunk-PMRL4MH6.js.map} +0 -0
package/README.md CHANGED
@@ -176,6 +176,7 @@ throwaway run wants. Once a module has adopted, nothing is fetched any more: the
176
176
  - [`docs/typescript-adoption.md`](docs/typescript-adoption.md) — the adoption cheat sheet: the two adoption steps, the command model (verb x type x location), options, reading a report, and troubleshooting.
177
177
  - [`docs/test-adoption.md`](docs/test-adoption.md) — migrating a module from jest to Vitest: the two steps, what the migration rewrites and what it refuses BY NAME, how the baseline gate proves nothing was lost, and the failures worth recognising.
178
178
  - [`docs/static-analysis-adoption.md`](docs/static-analysis-adoption.md) — running the static analysis role on a module: the two steps, the four output shapes, how to read each row and where its threshold comes from, declaring an entry point, and the two limits worth knowing before trusting a number.
179
+ - [`docs/sql-adoption.md`](docs/sql-adoption.md) — checking the migrations, the `Unsafe` calls and the `Prisma.raw` calls a branch adds or changes: the two steps, the 52 rules on by default and the 26 opt-in ones, the three levels in `sql.config.mjs` with an example, sentinel's two notes, and what the role does not read yet.
179
180
  - [`docs/env-adoption.md`](docs/env-adoption.md) — checking a whole repository's env files, contracts and Dockerfiles from its root: the ten rules and which block, the three levels of `SENTINEL_ENV_LEVEL`, the optional `env.config.mjs`, and what changed from the monorepo's `tools/repo-env`.
180
181
  - [`docs/typescript-traces.md`](docs/typescript-traces.md) — a **generated, versioned** reference of live command + output traces (every verb, option, config result and edge case) against the mock monorepo. Regenerate after CLI changes with `pnpm docs:traces`.
181
182
 
@@ -12,20 +12,18 @@ import {
12
12
  presetNotInstalledYet,
13
13
  registerAdapters,
14
14
  resolve
15
- } from "../chunk-YRBFCQQI.js";
16
- import "../chunk-ZZMYV576.js";
15
+ } from "../chunk-VZZ3DOC3.js";
17
16
  import {
18
17
  resolveContext,
19
18
  separateToolArgs
20
- } from "../chunk-P6KTBQ2Q.js";
21
- import "../chunk-ZFG6P27V.js";
19
+ } from "../chunk-ZASD5YPF.js";
22
20
  import {
23
21
  ensureWorkspacePrep,
24
22
  findWorkspaceRoot,
25
23
  inspectWorkspacePrep,
26
24
  readOwnVersion,
27
25
  readProjectPackageJson
28
- } from "../chunk-ZNANJEMK.js";
26
+ } from "../chunk-JT7ZMH44.js";
29
27
  import {
30
28
  DEFAULT_ENV_LEVEL,
31
29
  ENV_LEVELS,
@@ -36,10 +34,11 @@ import {
36
34
  SWEEPABLE_TARGETS,
37
35
  TARGETS,
38
36
  VERBS
39
- } from "../chunk-THTXP2QU.js";
37
+ } from "../chunk-LX7EG6PJ.js";
38
+ import "../chunk-LU4E4TVD.js";
39
+ import "../chunk-PXTU5MPW.js";
40
40
  import "../chunk-4EIY7TTR.js";
41
41
  import "../chunk-O7REVMOC.js";
42
- import "../chunk-H4HAFJFZ.js";
43
42
  import "../chunk-QXFCZON7.js";
44
43
 
45
44
  // bin/sentinel.ts
@@ -550,8 +549,8 @@ sentinel (${type}): ${asMessage(error)}
550
549
  // Only when the FORMAT role actually adopted: a module still formatted by the root
551
550
  // must not be excluded from it.
552
551
  formattedModule: toRun.includes("format") ? module.root : void 0,
553
- // Same rule for the report directory: only when the STATIC ANALYSIS role adopted.
554
- analysedModule: toRun.includes("static-analysis")
552
+ // Same rule for the report directories: only for a role that writes reports and adopted.
553
+ adoptedRoles: toRun
555
554
  });
556
555
  workspace = changes;
557
556
  const prefix = ctx.dryRun ? " dry run: " : " ";
@@ -576,62 +575,6 @@ sentinel (${type}): ${asMessage(error)}
576
575
  return worst;
577
576
  }
578
577
 
579
- // src/cli/run-migrate.ts
580
- async function runMigrate(ctx) {
581
- const { modules, scope } = resolveContext(ctx.cwd, { module: ctx.module, ci: false });
582
- const [module] = modules;
583
- if (scope === "all" || scope === "affected" || module === void 0) {
584
- ctx.fail(
585
- "--migrate writes files: target one module (run from its directory, or pass --module). Migrating every module at once is intentionally not allowed."
586
- );
587
- }
588
- const unsupported = ctx.targets.filter((target) => target !== "typescript");
589
- if (unsupported.length > 0) {
590
- const named = unsupported.map((target) => `--${target}`).join(", ");
591
- process.stdout.write(
592
- ` \xB7 ${named}: not available yet. \`--migrate\` answers \`--typescript\` today, by detaching the module from tsconfig.base.json. Nothing was migrated for ${named}.
593
- `
594
- );
595
- }
596
- if (!ctx.targets.includes("typescript")) return 1;
597
- const { migrateModule } = await import("../migrate-X7PB2X7R.js");
598
- const migration = migrateModule(module.root, {
599
- write: !ctx.dryRun,
600
- workspaceRoot: findWorkspaceRoot(module.root) ?? module.root
601
- });
602
- process.stdout.write(
603
- ctx.json ? `${JSON.stringify({ module: module.name, target: "typescript", ...migration }, null, 2)}
604
- ` : renderMigration(module.name, migration)
605
- );
606
- return migration.outcome === "migrated" || migration.outcome === "proved" || migration.outcome === "skipped" ? 0 : 1;
607
- }
608
- var SHOWN_DIFFERENCES = 20;
609
- function renderMigration(name, migration) {
610
- const mark = migration.outcome === "migrated" || migration.outcome === "proved" ? "\u2713" : migration.outcome === "skipped" ? "\xB7" : "\u2717";
611
- const lines = [` ${mark} ${name} \u2014 ${migration.message}`];
612
- for (const file of migration.files) {
613
- lines.push(` ${file.kept ? "\u2713" : "\xB7"} ${file.file}${file.reason ? `: ${file.reason}` : ""}`);
614
- if (file.aliases !== void 0) {
615
- lines.push(
616
- ` ${file.legacy ? "extends legacy, " : ""}${file.aliases.kept} of ${file.aliases.of} aliases, ${file.resolutions ?? 0} resolutions compared${file.written && file.written.length > 0 ? `, wrote ${file.written.join(", ")}` : ""}`
617
- );
618
- }
619
- const differences = [
620
- ...(file.configDifferences ?? []).map(
621
- (difference) => `${difference.key}: ${difference.before ?? "unset"} -> ${difference.after ?? "unset"}`
622
- ),
623
- ...file.resolutionDifferences ?? []
624
- ];
625
- for (const line of differences.slice(0, SHOWN_DIFFERENCES)) lines.push(` ${line}`);
626
- if (differences.length > SHOWN_DIFFERENCES) {
627
- lines.push(` \u2026 ${differences.length - SHOWN_DIFFERENCES} more, all of them under --json`);
628
- }
629
- }
630
- for (const note of migration.notes) lines.push(` note: ${note}`);
631
- return `${lines.join("\n")}
632
- `;
633
- }
634
-
635
578
  // src/cli/run-validate.ts
636
579
  async function runValidate(ctx) {
637
580
  const { modules } = resolveContext(ctx.cwd, { module: ctx.module, ci: ctx.ci });
@@ -644,7 +587,7 @@ async function runValidate(ctx) {
644
587
  );
645
588
  }
646
589
  if (!ctx.targets.includes("test")) return 1;
647
- const { validateModuleTests } = await import("../validate-4V3EGTXN.js");
590
+ const { validateModuleTests } = await import("../validate-QYP7HFSY.js");
648
591
  const outcomes = modules.flatMap(
649
592
  (module) => validateModuleTests(module.name, module.root)
650
593
  );
@@ -696,15 +639,7 @@ var RULE_BLOCKS = [
696
639
  // The other direction, and listed for the same reason: a rule a module adds to its lint
697
640
  // preset is not drift, so nothing else on the row would ever show it was there.
698
641
  { key: "added", label: "added by the module (kept by --init, not drift):" },
699
- { key: "addedConfig", label: "config added by the module (kept by --init, not drift):" },
700
- // TypeScript's two: an option the preset took over from the base, set to another value by the
701
- // module (kept, so `conformant` cannot show it), and the debt a migrated module takes from
702
- // `legacy`. Both are this module departing from the standard, named.
703
- {
704
- key: "standardOverrides",
705
- label: "differs from the repo standard (kept by --init, not drift):"
706
- },
707
- { key: "legacyCompromises", label: "inherited compromises (debt to remove):" }
642
+ { key: "addedConfig", label: "config added by the module (kept by --init, not drift):" }
708
643
  ];
709
644
  var MAX_INLINE_WIDTH = 60;
710
645
  function renderValue(key, value, p) {
@@ -985,6 +920,7 @@ var TARGET_HELP = {
985
920
  dev: "dev server (long-running: never swept by an unqualified --run)",
986
921
  test: "tests",
987
922
  "static-analysis": "duplication, dead code, complexity, import graph, file size, bundle weight",
923
+ sql: "migrations and Unsafe raw SQL calls, in the modules that hold them",
988
924
  env: "env files, contracts and Dockerfiles, for the whole repository (run from its root)",
989
925
  "runtime-analysis": "Lighthouse, web vitals",
990
926
  arch: "architecture boundaries"
@@ -993,16 +929,13 @@ program.name("sentinel").description("One CLI that guards code health: presets,
993
929
  "before",
994
930
  [
995
931
  "A check composes: verb + type + location.",
996
- " verb what to do: --run --inspect --report --status --init --migrate --validate",
932
+ " verb what to do: --run --inspect --report --status --init --validate (--migrate: planned)",
997
933
  " type which check: --lint --typescript ... (omit = all types; or --all)",
998
934
  " where run from a MODULE dir \u2192 that module; from the ROOT \u2192 --module <name>,",
999
935
  " --ci (affected), or all modules. --init targets one module only.",
1000
936
  ""
1001
937
  ].join("\n")
1002
- ).option("--run", "execute the target tool").option("--inspect", "show the resolved configuration").option("--init", "set up a module: write its config stubs + the workspace prep it needs").option(
1003
- "--migrate",
1004
- "change an already-initialized setup: --typescript detaches the module from tsconfig.base.json"
1005
- ).option(
938
+ ).option("--run", "execute the target tool").option("--inspect", "show the resolved configuration").option("--init", "set up a module: write its config stubs + the workspace prep it needs").option("--migrate", "planned: change an already-initialized setup (not available yet)").option(
1006
939
  "--validate",
1007
940
  "prove a migration kept the suite: record the reference, then compare against it"
1008
941
  ).option("--report", "deprecated: use --run --json").option("--status", "deprecated: use --inspect").option(
@@ -1170,10 +1103,12 @@ function parseEnvLevel(value) {
1170
1103
  var envLevel = targets.some((target) => REPOSITORY_TARGETS.includes(target)) ? parseEnvLevel(process.env.SENTINEL_ENV_LEVEL) : DEFAULT_ENV_LEVEL;
1171
1104
  var githubActions = process.env.GITHUB_ACTIONS === "true";
1172
1105
  var targetsExplicit = !(opts.all || namedTargets.length === 0);
1173
- if (namedTargets.includes("static-analysis") && (verb === "report" || verb === "run" && opts.json)) {
1174
- program.error(
1175
- `sentinel: --static-analysis writes its own report, so ${verb === "report" ? "--report" : "--json"} has nothing to add to it. Run it bare for the console report, or with --output json|html|markdown for the files.`
1176
- );
1106
+ for (const reporting of ["static-analysis", "sql"]) {
1107
+ if (namedTargets.includes(reporting) && (verb === "report" || verb === "run" && opts.json)) {
1108
+ program.error(
1109
+ `sentinel: --${reporting} writes its own report, so ${verb === "report" ? "--report" : "--json"} has nothing to add to it. Run it bare for the console report, or with --output json|html|markdown for the files.`
1110
+ );
1111
+ }
1177
1112
  }
1178
1113
  var maxDiagnostics = Number(opts.maxDiagnostics);
1179
1114
  if (!Number.isInteger(maxDiagnostics) || maxDiagnostics < 0) {
@@ -1181,8 +1116,8 @@ if (!Number.isInteger(maxDiagnostics) || maxDiagnostics < 0) {
1181
1116
  `--max-diagnostics must be a non-negative integer (0 = no cap); got ${JSON.stringify(opts.maxDiagnostics)}.`
1182
1117
  );
1183
1118
  }
1184
- if (opts.dryRun && verb !== "init" && verb !== "migrate") {
1185
- program.error("--dry-run only applies to --init and --migrate (the read verbs never write).");
1119
+ if (opts.dryRun && verb !== "init") {
1120
+ program.error("--dry-run only applies to --init (the read verbs never write).");
1186
1121
  }
1187
1122
  if (opts.rehearse && !opts.dryRun) {
1188
1123
  program.error(
@@ -1208,6 +1143,9 @@ async function exitWithoutTruncating(code) {
1208
1143
  await new Promise((resolve2) => stream.once("drain", () => resolve2()));
1209
1144
  }
1210
1145
  async function main() {
1146
+ if (verb === "migrate") {
1147
+ program.error("--migrate is planned and not available yet; use --init to set a module up.");
1148
+ }
1211
1149
  const context = {
1212
1150
  verb,
1213
1151
  cwd,
@@ -1232,7 +1170,7 @@ async function main() {
1232
1170
  githubActions,
1233
1171
  fail: (message) => program.error(message)
1234
1172
  };
1235
- const exitCode = verb === "init" ? await runInit(context) : verb === "validate" ? await runValidate(context) : verb === "migrate" ? await runMigrate(context) : await runVerb(context);
1173
+ const exitCode = verb === "init" ? await runInit(context) : verb === "validate" ? await runValidate(context) : await runVerb(context);
1236
1174
  await exitWithoutTruncating(exitCode);
1237
1175
  }
1238
1176
  main().catch((error) => {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  decoratorMetadata,
3
3
  tsconfigAliases
4
- } from "./chunk-LNFGVGLE.js";
4
+ } from "./chunk-SWWQ7X7B.js";
5
5
 
6
6
  // src/roles/test/shared-test-config.ts
7
7
  import { existsSync } from "node:fs";
@@ -311,20 +311,7 @@ function baseConfig(options) {
311
311
  find: /^jest-mock-extended$/,
312
312
  replacement: mockExtendedAdapterPath() ?? vitestMockExtendedPath()
313
313
  },
314
- /*
315
- * The chain the module's specs type-check against, and the workspace base only when that
316
- * chain declares no `paths`. `tsconfig.app.json` sits between the two for the React shape:
317
- * the three React apps of the monorepo have NO `tsconfig.spec.json`, and their
318
- * `tsconfig.json` holds only `references`, so their `paths` reach them through
319
- * `tsconfig.app.json`. ⚠️ None of them calls `reactTestConfig` today: they import only
320
- * `defineConfig` and `mergeConfig` and keep their own Vite alias table, so this line is
321
- * what a React module gets on the day it adopts the factory, not something they run now.
322
- * Measured on the monorepo: 0 callers of `reactTestConfig`, 32 of `nestTestConfig`.
323
- */
324
- ...tsconfigAliases(workspaceRoot, {
325
- moduleRoot: root,
326
- candidates: ["tsconfig.spec.json", "tsconfig.app.json", "tsconfig.json"]
327
- })
314
+ ...tsconfigAliases(workspaceRoot)
328
315
  ]
329
316
  },
330
317
  test: {
@@ -618,4 +605,4 @@ export {
618
605
  jestExportConditions,
619
606
  sharedTestConfig
620
607
  };
621
- //# sourceMappingURL=chunk-DLGBRLUU.js.map
608
+ //# sourceMappingURL=chunk-EESVRILJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/roles/test/shared-test-config.ts","../src/roles/test/isolation-split.ts","../src/roles/test/msw-server-redirect.ts","../src/roles/test/react/jest-export-conditions.ts"],"sourcesContent":["/**\n * The Vitest config a Nest module gets, as one call instead of forty lines copied 133 times.\n *\n * The React family needed none of this: those modules already had a Vitest config, so adoption\n * moved its imports and changed nothing else. The Jest family has no config at all, so one has to\n * be WRITTEN, and writing the same four decisions into 133 files is how they drift. A module that\n * genuinely differs still can: `overrides` is merged over the base, the same shape `nestService`\n * uses on the build side.\n *\n * Every line below was established by running a real suite, not by reading a guide. `mission` is\n * the reference: 387 specs, the module the build role refused for having its own webpack config,\n * and the one with the only `isolateModules` in the repo.\n */\nimport { existsSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport type { Alias as ViteAlias, AliasOptions } from 'vite'\nimport type { ViteUserConfig } from 'vitest/config'\n\nimport { decoratorMetadata } from '../build/nest/decorator-metadata.js'\nimport { tsconfigAliases } from '../build/nest/tsconfig-aliases.js'\nimport type { Alias } from '../build/nest/tsconfig-aliases.js'\n\nimport { asIsolationSplit } from './isolation-split.js'\nimport { mswServerRedirect } from './msw-server-redirect.js'\nimport { jestExportConditions } from './react/jest-export-conditions.js'\n\n/** Which family this config is for: it decides the three things that are not shared. */\nexport type TestFlavour = 'nest' | 'react'\n\nexport interface SharedTestOptions {\n /** Which family this config is for. It decides the three things that are not shared. */\n flavour?: TestFlavour\n /** The module's own directory: where its specs live and what its config is relative to. */\n root: string\n /** The workspace root, which is where `tsconfig.base.json` and its path aliases are. */\n workspaceRoot: string\n /**\n * Lower decorators with TypeScript before oxc sees them, for a module that needs it.\n *\n * ⚠️ Written by `--init --test` from the module's own sources, never by hand, because the\n * condition is not a preference: it is whether a decorator sits on an `abstract` class member,\n * the one construct oxc does not reproduce. See `generate-config.ts` for the measurement.\n *\n * Off by default, and that default is the measured one: on\n * `apps/nest/microservices/mission`, 715 of 716 decorated files need nothing, and running the\n * plugin for all of them took the suite from 98s to 249s.\n */\n lowerDecoratorsWithTypeScript?: boolean\n /**\n * Let the files of this suite share a worker instead of each getting its own registry.\n *\n * Off by default, which is Vitest's own default and jest's semantics. Turning it off buys the\n * whole of `./setup/file-boundary.js` and `./isolation-split.js`: measured on\n * `front-components`, 44.6s isolated against 11.0s split, with all 1418 tests green and the\n * same result across ten shuffled file orders.\n *\n * A module takes it deliberately, and proves it with `--validate`, because the switch is the one\n * thing in this preset that changes what a suite MEANS: a file can see what an earlier file left\n * behind, and only running the suite can say whether any of them does.\n */\n isolate?: boolean\n /** Merged over the base. For what a module genuinely needs to differ on, nothing else. */\n overrides?: ViteUserConfig\n}\n\n/** A file shipped beside this module in the build, or nothing when running from source. */\nfunction siblingFile(relative: string): string | undefined {\n /*\n * ⚠️ Several candidates, because the EMITTED layout is not ours to predict. This file is imported\n * by two toolchains, so the bundler extracts it into a shared chunk at the package root, and it\n * does so even when it is declared as its own entry (the entry then only re-exports the chunk).\n * A single `import.meta.url`-relative path therefore resolves differently depending on where the\n * bundler decided to put the code.\n *\n * That is not theoretical: it silently broke the jest-mock-extended and msw-server adapters, and\n * `apps/cloud/shift-offer` went from 83/83 to 56/83 with \"The property X is not defined on the\n * object\" — a mockDeep shape error that names nothing near the cause. The alias had quietly\n * fallen back to the raw fork.\n *\n * So the file is LOOKED FOR rather than computed, and the first one that exists wins.\n */\n const candidates = [\n relative,\n `roles/test/${relative.replace(/^\\.\\//, '')}`,\n `../${relative.replace(/^\\.\\//, '')}`,\n ]\n for (const candidate of candidates) {\n try {\n const sibling = fileURLToPath(new URL(candidate, import.meta.url))\n if (existsSync(sibling)) return sibling\n } catch {\n continue\n }\n }\n return undefined\n}\n\n/** A package resolved from SENTINEL, so the module gets the copy the setup uses. */\nfunction resolveFrom(specifier: string): string | undefined {\n try {\n return fileURLToPath(import.meta.resolve(specifier))\n } catch {\n try {\n return createRequire(import.meta.url).resolve(specifier)\n } catch {\n return undefined\n }\n }\n}\n\n/**\n * sentinel's own adapter around the fork, which the alias points at when it has been built.\n *\n * The adapter only makes a deep mock answer `in` and `getOwnPropertyDescriptor`, which Vitest's\n * `spyOn` asks and jest's did not; `mock-extended.ts` carries the measurement. Resolved as a\n * sibling file rather than by specifier, because it is not a package.\n *\n * Falls back to the fork itself when there is no build beside this module, which is the case while\n * sentinel's own suite runs from `src`. The alias then behaves exactly as it did before the\n * adapter existed, so a missing build degrades instead of throwing.\n */\nfunction mockExtendedAdapterPath(): string | undefined {\n return siblingFile('./setup/mock-extended.js')\n}\n\n/**\n * The ABSOLUTE path of the Vitest fork, resolved from sentinel rather than named.\n *\n * A bare specifier in an alias is resolved by Vite against the IMPORTER, which here is a spec file\n * inside the adopted module. `vitest-mock-extended` is sentinel's dependency, not the module's, so\n * under pnpm's isolated layout the module cannot see it and the alias points at nothing.\n *\n * Measured on `apps/cloud/agency`: three suites died with \"Cannot find package\n * 'jest-mock-extended'\" while the fork sat in the store, installed and unreachable. Same class of\n * defect as the axios alias below, and the same fix: resolve it where it actually is.\n *\n * Falls back to the bare name, which keeps the previous behaviour rather than throwing while a\n * config is being built.\n */\nfunction vitestMockExtendedPath(): string {\n /*\n * `import.meta.resolve` and not `createRequire().resolve`: the latter follows the `require`\n * condition and hands back the package's CJS entry, whose first line requires `vitest`. Vitest\n * refuses that outright (\"Vitest cannot be imported in a CommonJS module using require()\"), so\n * the alias resolved correctly and then failed one step later. Measured on `apps/cloud/agency`.\n */\n try {\n return fileURLToPath(import.meta.resolve('vitest-mock-extended'))\n } catch {\n try {\n return createRequire(import.meta.url).resolve('vitest-mock-extended')\n } catch {\n return 'vitest-mock-extended'\n }\n }\n}\n\n/**\n * The ONE msw copy a module's tests share with the server that listens.\n *\n * sentinel ships msw so that a module stands alone, and the codemod repoints the SPEC files to it.\n * Helpers are not spec files, so they keep `import { rest } from 'msw'` and build their handlers\n * with the WORKSPACE's copy while the server that listens was built with sentinel's. Same version,\n * two physical instances, and a handler registered on one is invisible to the other.\n *\n * Measured on `apps/cloud/shift-offer`, whose `setup-mocks.ts` registers every handler its suites\n * rely on: 19 tests failed on `captured a request without a matching request handler` for a URL the\n * helper had a handler for. The repo has 159 non-spec files importing msw, and 2 importing the\n * workspace's server directly, so this is not one module's habit.\n *\n * Aliased rather than codemodded, for the same reason as `jest-mock-extended` above: it lets an\n * UNMIGRATED shared helper keep working inside a migrated module, which is what makes the\n * per-module plan possible at all. `^msw$` only: `msw/node` stays the package's own, and it is\n * sentinel's setup that imports it.\n */\n/** sentinel's own server file, the one its setup starts listening on. */\nfunction mswServerFile(): string | undefined {\n return siblingFile('./setup/msw-server.js')\n}\n\n/**\n * `next-i18next` pointed at its ESM build, so the repo gets ONE `react-i18next`.\n *\n * ## Two builds of one package are two React contexts\n *\n * The package declares `main: dist/commonjs/index.js` and `module: dist/esm/index.js`, and NO\n * `exports` map. Vite externalises it, so NODE resolves it, and Node reads `main`: the CommonJS\n * build, which `require`s react-i18next's CommonJS build. The test's provider comes from\n * `@front/tests`, which is workspace source, so Vite resolves ITS `react-i18next` to the ESM\n * build. Same package, same single installed copy, two module instances, two React contexts:\n *\n * react-i18next:: useTranslation: You will need to pass in an i18next instance\n * by using initReactI18next { code: 'NO_I18NEXT_INSTANCE' }\n *\n * The component is inside the provider and still sees nothing. Under jest everything was\n * CommonJS, so there was one copy and the question never arose.\n *\n * ⚠️ `server.deps.inline` does NOT fix it, measured, including `inline: true`: inlining changes\n * who transforms the file, not which entry point `main` names. The alias names the entry.\n *\n * Measured on this repository: **533 files in 4 modules** import `next-i18next`, 500 of them in\n * `front-legacy`. Proven on `libs/front/logic`: 2 failures before, 23 of 23 after.\n */\nfunction nextI18nextAlias(root: string, workspaceRoot: string): Alias[] {\n for (const base of [root, workspaceRoot]) {\n const esm = join(base, 'node_modules', 'next-i18next', 'dist', 'esm', 'index.js')\n if (existsSync(esm)) return [{ find: /^next-i18next$/, replacement: esm }]\n }\n return []\n}\n\nfunction mswAliases(): Alias[] {\n const server = mswServerFile()\n const own = resolveFrom('msw')\n return [\n ...(own === undefined ? [] : [{ find: /^msw$/, replacement: own }]),\n ...(server === undefined ? [] : [{ find: /^@hublo\\/test\\/msw\\/server$/, replacement: server }]),\n ]\n}\n\n/**\n * One PHYSICAL axios, resolved from the MODULE and not from sentinel.\n *\n * pnpm installs axios twice here, same 1.17.0, differing only by a peer. The service client\n * resolves one copy and a provider's `import { AxiosError } from 'axios'` the other, so\n * `if (!(error instanceof AxiosError)) throw error` answers false on a genuine axios error and\n * rethrows it raw. The test then fails on the WRAPPER being absent, naming nothing near the cause.\n *\n * `resolve.dedupe` does NOT fix this, and neither does `deps.inline`: dedupe settles bare\n * specifiers, not two physical paths. The alias has to name the path.\n *\n * The module's OWN `node_modules`, checked directly rather than resolved.\n *\n * `createRequire(...).resolve()` was the first version and it is wrong twice. It walks UP the\n * tree, so a module without axios would be aliased to a PARENT's copy, which is the opposite of\n * pinning its own. And because it consults ambient resolution, the answer depends on where the\n * process runs: it correctly found nothing from a plain CLI run and found something under Vitest,\n * which is how a test of it became a test of its environment.\n *\n * pnpm links a module's direct dependencies into `<module>/node_modules`, so that path is both the\n * right answer and a deterministic one.\n *\n * Measured on `mission`: 378 passing suites to 381 of 387.\n *\n * ## ⚠️ And the workspace root when the module has none of its own\n *\n * The first version stopped there and returned nothing for a module without its own axios, on the\n * reasoning that pinning it to a PARENT's copy is the opposite of pinning its own. That reasoning\n * has an blind spot: a module with no copy of its own does not thereby have no axios PROBLEM. It\n * receives one through its dependencies, and it is still importing it two ways.\n *\n * Measured in `apps/nest/backends-for-frontends/backoffice`, which declares no axios, under this\n * very preset with no alias:\n *\n * the ESM AxiosError === the CJS AxiosError false\n * a CJS error instanceof the CJS class true\n * a CJS error instanceof the ESM class FALSE\n *\n * `@nestjs/axios` is externalised, so Node loads it and it throws the CJS class; the provider does\n * `import { AxiosError } from 'axios'` through Vite and gets the ESM one. Its\n * `if (error instanceof AxiosError) throw new RemoteBackendException(...)` therefore answers false\n * on a genuine axios error and rethrows it raw, and the test fails on the WRAPPER being absent,\n * naming nothing near the cause. Four modules reported it: `admin`, `backoffice`, `mission`,\n * `institution`.\n *\n * So: the module's own copy first, the workspace root second, nearest wins. That is the same shape\n * as `luxonAlias` above, and for the same reason: when a module has nothing of its own, the copy\n * it actually uses is the one to pin. Absent axios everywhere is still not an error.\n */\n/**\n * ONE physical luxon, for the same reason as axios: `Settings` is per-copy state.\n *\n * The setup pins `Settings.defaultZone = 'utc'`, which the root jest setup did for every suite in\n * the repo. It was reaching the copy `require` resolves, the CJS build, while the tests import the\n * one Vite resolves, the ESM build. Two instances, two `Settings`, and the pin landed on the one\n * nobody read.\n *\n * Measured on `libs/cloud/events-notifications`: the suite ran in `Europe/Paris`, so every date\n * came out two hours off and 12 assertions compared timestamps that differed by exactly that.\n *\n * luxon sits at the workspace root here rather than in each module, so both places are checked,\n * nearest first. Absent luxon is not an error: most modules have none.\n */\nfunction luxonAlias(root: string, workspaceRoot: string): Alias[] {\n for (const base of [root, workspaceRoot]) {\n const manifest = join(base, 'node_modules', 'luxon', 'package.json')\n if (existsSync(manifest)) return [{ find: /^luxon$/, replacement: dirname(manifest) }]\n }\n return []\n}\n\nfunction axiosAlias(root: string, workspaceRoot: string): Alias[] {\n for (const base of [root, workspaceRoot]) {\n const manifest = join(base, 'node_modules', 'axios', 'package.json')\n if (existsSync(manifest)) return [{ find: /^axios$/, replacement: dirname(manifest) }]\n }\n return []\n}\n\n/**\n * A generated Prisma client's runtime, resolved to the file the package actually ships.\n *\n * The generated client reaches its own runtime by package name, and the package's `exports` map\n * answers differently depending on which condition asks:\n *\n * \"./runtime/library\": { \"require\": \"./runtime/library.js\", // shipped\n * \"import\": \"./runtime/library.mjs\" } // NOT shipped\n *\n * jest asked as CJS and got the file. Vitest resolves the same specifier under `import`, is sent\n * to a `.mjs` that does not exist, and the spec file does not load at all, so its tests go missing\n * rather than failing. Node itself spells the answer out: \"Did you mean to import\n * .../runtime/library.js?\".\n *\n * Measured on `apps/nest/microservices/client-management` (1 file) and\n * `apps/nest/microservices/institution` (3 files), on two different generated clients. This repo\n * generates 31 of them, all with the same manifest, so this is a property of the generator rather\n * than of a module.\n *\n * Written as a pattern with a back-reference, not one entry per client: the module does not know\n * which clients its dependencies pull in, and enumerating 31 names would go stale the day a\n * thirty-second schema is added.\n *\n * ⚠️ Not a workaround for a mistake of ours. The package declares a target it does not ship, and\n * pointing at the shipped file is what `require` already did. Nothing else changes: the `.js` IS\n * the runtime, in the same package, at the version installed.\n */\nfunction prismaRuntimeAlias(workspaceRoot: string): Alias[] {\n const prisma = join(workspaceRoot, 'node_modules', '@prisma')\n if (!existsSync(prisma)) return []\n\n return [\n {\n find: /^@prisma\\/([^/]+)\\/runtime\\/library$/,\n replacement: join(prisma, '$1', 'runtime', 'library.js'),\n },\n ]\n}\n\n/**\n * The base every Nest module gets. Four decisions, each with its measurement.\n */\nfunction baseConfig(options: SharedTestOptions): ViteUserConfig {\n const { root, workspaceRoot } = options\n\n return {\n /*\n * NO decorator-metadata plugin, and that is a measured removal rather than an omission.\n *\n * Nest reads constructor parameter types from `emitDecoratorMetadata`, so this preset used to\n * run the BUILD role's SWC plugin to emit it, on the premise that the bundler does not. That\n * premise was true of esbuild and is false of Vite 8, which transforms with oxc: oxc lowers the\n * decorators itself and emits the metadata, provided a tsconfig with `experimentalDecorators`\n * applies to the file.\n *\n * Measured five times before removing it. On `apps/nest/microservices/mission`, with and\n * without the plugin, the output is strictly identical for `@Injectable()` constructors\n * (including a service caught in a two-file import CYCLE, all 8 parameters resolved), for route\n * handler parameters and return types, and for DTO properties; the suite then passes in 98s\n * instead of 249s. Confirmed by a direct `Reflect.getMetadata` probe on\n * `apps/nest/backends-for-frontends/admin` and on `libs/nest/starter`, and by two A/B runs\n * through this very preset: `agency-notification` (100 tests) identical with and without, and\n * `grid-leave` (3335 tests) identical without.\n *\n * One caveat that the same measurement produced, and which belongs to the CONSUMER rather than\n * here: a property typed by an interface or by a type-alias imported with `import type` emits\n * `Object`. That is `emitDecoratorMetadata`'s own behaviour, identical with and without the\n * plugin, not a Vite regression.\n *\n * The BUILD role keeps its plugin. Its context differs, it feeds a shipped artefact, and\n * removing it there needs its own proof.\n *\n * ⚠️ ONE construct escapes oxc, and the exception is why this line is a condition rather than\n * an empty array: a decorator on an `abstract` class member. swc emitted it, oxc erases the\n * member and the decorator with it, silently. There is exactly one such member in this repo,\n * so `lowerDecoratorsWithTypeScript` buys the plugin back for that module alone.\n */\n /*\n * `jestExportConditions` is UNCONDITIONAL, and it is the one plugin every migrated module gets.\n *\n * jest resolved with `['node', 'require', 'default']`, read off the installed `@nx/jest/preset`\n * rather than off its documentation. `development` was never in that list, so a package\n * shipping a separate development build loaded its PRODUCTION file. Vite's own conditions carry\n * `development|production`, so `@emotion/cache` loads `emotion-cache.development.cjs.js`, whose\n * extra stylis plugin calls `console.error(':first-child is potentially unsafe...')`, and with\n * `jest-fail-on-console` in the setup that console call IS a failure.\n *\n * Measured on `libs/front/components`: 2 of its 3 remaining failures, both green again with\n * this. `apps/front/front-legacy` has 100 over 26 files from the same cause.\n *\n * Unconditional rather than reserved for a jsdom module, because it is not a statement about\n * the DOM: it is what this migration is for, running the suite the way the runner it was\n * written for ran it. It changes nothing for a module with no dual-published dependency, which\n * is why nest and cloud were measured identical without it.\n */\n plugins: [\n jestExportConditions(),\n /*\n * The alias beside it covers a file naming the workspace's msw server by its package\n * specifier. This covers the one that reaches the same module RELATIVELY, which an alias\n * cannot: `./server` is a spelling thousands of unrelated files use, so the redirect is\n * decided on the resolved path instead. See `msw-server-redirect.ts` for the measurement.\n */\n ...(mswServerFile() === undefined\n ? []\n : [mswServerRedirect(mswServerFile() as string, workspaceRoot)]),\n ...(options.lowerDecoratorsWithTypeScript ? [decoratorMetadata({ root })] : []),\n ],\n\n /*\n * The proviso in the paragraph above, made unconditional.\n *\n * oxc lowers decorators from the tsconfig that applies to the file, so a file belonging to NO\n * tsconfig `include` is lowered as if it used the STANDARD decorators, and comes out of Vite as\n * invalid JavaScript. Not merely without metadata: the file fails to parse, and every file that\n * imports it disappears with it.\n *\n * Measured on `apps/nest/microservices/mission`, where ONE uncovered helper,\n * `src/app/test/mission.test-wrapper.ts`, took down 158 of 416 test files. Reproduced on a\n * three-file case: covered file fine, uncovered file `SyntaxError: Invalid or unexpected\n * token`, and this option alone turns it into the same output the covered file gets, metadata\n * included.\n *\n * Declared here rather than left to each module's tsconfig `include`, because the alternative\n * is asking 107 teams to find which of their files no tsconfig covers, which is the work this\n * role exists to do for them.\n *\n * Two things the same measurement established, both deliberate:\n *\n * - it OVERRIDES the tsconfig, it is not a default the tsconfig refines. A file under a\n * tsconfig saying `emitDecoratorMetadata: false` gets metadata anyway. Acceptable because\n * this is the NEST preset and a Nest module is legacy decorators by definition: no tsconfig\n * under `apps/nest`, `libs/nest`, `apps/cloud` or `libs/cloud` sets either option to false.\n * - it needs no polyfill. Without `reflect-metadata` loaded, nothing throws, the metadata is\n * simply unreadable, exactly as before.\n */\n oxc: { decorator: { legacy: true, emitDecoratorMetadata: true } },\n\n resolve: {\n alias: [\n ...axiosAlias(root, workspaceRoot),\n ...luxonAlias(root, workspaceRoot),\n ...nextI18nextAlias(root, workspaceRoot),\n /*\n * Nest only, and measured: 1186 files under `apps/nest` and `libs/nest` mention `@prisma/`,\n * and ZERO under `apps/front` and `libs/front`. A React module paying for an alias to a\n * client it never generates is noise in a file someone has to read.\n */\n ...(options.flavour === 'nest' ? prismaRuntimeAlias(workspaceRoot) : []),\n ...mswAliases(),\n /*\n * `jest-mock-extended` loads `@jest/globals`, which refuses to run outside jest. 2491\n * files import it, 104 of them under `libs/` as SHARED helpers, so migrating those helpers\n * breaks every module still on jest and leaving them breaks every module moved to Vitest.\n * Old and new therefore do not cohabit on shared helpers, which would have killed the\n * per-module plan.\n *\n * This one line removes the constraint: an unmigrated helper resolves to the Vitest fork\n * inside an adopted module and keeps resolving to the jest one everywhere else.\n * `vitest-mock-extended@5.1.1` is a fork of the same package and exports the same names.\n *\n * Measured on `mission`: failing suites went from 159 to 10.\n */\n {\n find: /^jest-mock-extended$/,\n replacement: mockExtendedAdapterPath() ?? vitestMockExtendedPath(),\n },\n ...tsconfigAliases(workspaceRoot),\n ],\n },\n\n test: {\n globals: true,\n environment: 'node',\n root,\n\n /*\n * The per-test budget, widened from Vitest's 5000 ms default.\n *\n * ⚠️ NOT because the migration made anything slower. Measured on the same machine, the same\n * files, both runners:\n *\n * regulation-balance, first test jest 2283 ms vitest 2411 ms\n * prisma-breaking-change-detector jest 2558 ms vitest 2363 ms\n * planning-requirement, first test vitest 1972 ms\n *\n * Vitest is within 6% on the slowest and FASTER on the others, and faster overall on every\n * file (regulation-balance: 3.40 s under jest, 2.23 s under vitest). What these tests have\n * in common is that they pay a one-off cost inside a test: loading a Nest module graph, or\n * spawning a Prisma CLI process. Against 5000 ms that is a margin of about TWO, and a shared\n * CI agent running three tasks at once eats it. All three timed out on CI under Vitest; on\n * that evidence jest was simply on the lucky side of the same line.\n *\n * 15000 ms is six times the slowest measured test, so an agent three times slower than this\n * machine still has a factor of two in hand.\n *\n * ⚠️ What it costs, said plainly: a test that HANGS now takes 15 s to fail instead of 5. It\n * hides nothing else, since a hang still fails. A module that declared its own budget keeps\n * it, because the module's own config is merged over this one.\n */\n testTimeout: 15_000,\n /*\n * The same budget for hooks. jest's one `testTimeout` covered both; Vitest splits them and\n * defaults `hookTimeout` to 10 s, which is how `mission`'s `beforeAll` container start was\n * cut off at 10012 ms. A hook doing the work a test does needs the budget a test has.\n */\n hookTimeout: 15_000,\n /*\n * What the repo's jest preset actually matched, copied rather than approximated:\n * `**\\/?(*.)+(spec|test).[jt]s?(x)`.\n *\n * Both NAMES, because jest ran both: `**\\/*.spec.ts` alone read green while missing three\n * `.test.ts` files and 23 tests, with nothing saying so. And all four EXTENSIONS, for the\n * same reason one notch further out. Measured over the repo's 7063 test files:\n *\n * .ts 5844 .tsx 1108 .js 99 .mjs/.cjs 12\n *\n * The `.ts`-only form cost nothing on nest and cloud, which have none of the others, and it\n * cost `libs/front/api` three files and 13 tests on the first front module it met. Half the\n * front's test files are `.tsx`.\n *\n * `.mjs` and `.cjs` are deliberately OUT: jest's `[jt]s?(x)` does not match them either, and\n * Vitest's own default include does. Running a file the reference never ran is as wrong as\n * skipping one it did.\n */\n include: ['**/*.spec.[jt]s?(x)', '**/*.test.[jt]s?(x)'],\n /*\n * Kept, and it is not a performance knob. Nest registers metadata as an import SIDE EFFECT:\n * a decorator writes into a catalog when its module loads. Sharing a module registry across\n * files lets one suite see what another registered, and the failure appears in whichever\n * file happens to run second.\n */\n /*\n * Nest only. A Nest module registers metadata as an import SIDE EFFECT, so sharing a module\n * registry across files lets one suite see what another registered. A React module has no\n * such catalog, and isolation is not free.\n */\n ...(options.flavour === 'nest' ? { isolate: true } : {}),\n /*\n * Concurrency, transposed from what this repo does today rather than chosen.\n *\n * Every jest target inherits `configurations.ci = { ci: true, runInBand: true }` from the\n * `@nx/jest:jest` key in `nx.json`, and CI invokes every test target with\n * `--configuration=ci`. So on CI every suite in this repo runs ONE FILE AT A TIME today. That\n * key belongs to the jest executor and cannot be touched, because the workspace is mixed: it\n * still serves the modules that have not moved.\n *\n * ⚠️ And it is CI-ONLY. A local run omits `--configuration=ci`, so jest runs files in\n * PARALLEL on a developer's machine. A flat `fileParallelism: false` here would make local\n * runs slower than jest, which loses something the module had. Hence the condition rather\n * than the constant: parallel locally, one file at a time on CI, which is jest on both sides.\n *\n * Measured on three files that each hold the clock for 400ms and record their interval:\n *\n * default files overlap, 402ms\n * fileParallelism: false no overlap, 1442ms\n * maxWorkers: 1 no overlap, 1423ms\n *\n * Both candidates give the property that matters. `fileParallelism` is the one that says what\n * the module MEANS (\"do not run my files at the same time\"); `maxWorkers` is a pool size, and\n * it is what a module asking for a CAP gets instead (three BFFs ask for 4).\n *\n * A module that declared its own concurrency overrides this, in both environments, exactly as\n * it does today.\n */\n /*\n * ⚠️ PARALLEL on CI too, since 26/09, and that reverses what the note above decided.\n *\n * The transposition was faithful and expensive. Measured on `libs/front/components`, 1418\n * tests green on every line, on the repo's own 4-core agents:\n *\n * jest, as CI runs it 158.7 s\n * vitest serial, the transposition 644.5 s 4.1x slower\n * vitest, 3 workers 324.7 s 2.05x slower\n *\n * Serialising costs vitest far more than it costs jest, because vitest re-evaluates the\n * module graph per file through Vite's SSR runner: 555 ms of `import` and 478 ms of\n * `environment` per file against 139 ms of actual tests. Parallelism does not remove that\n * cost, it pays it on several cores at once.\n *\n * Every other documented lever was measured and does nothing or breaks the suite:\n * `deps.optimizer.ssr`, `NODE_COMPILE_CACHE` and `fsModuleCache` all cache TRANSFORMATION\n * where the cost is EVALUATION; `pool: threads` is noise; `vmThreads` collapses into\n * `no-isolate` when serial and fails 473 tests; `--no-isolate` fails 351.\n *\n * ⚠️ And NO worker cap, which is deliberate after reading vitest's own sizing:\n *\n * getDefaultThreadsCount: config.watch ? max(numCpus / 2, 1) : max(numCpus - 1, 1)\n *\n * `cores - 1` is 3 on this repo's 4-core agents, which is exactly the pool the 324.7 s above\n * was measured with, and 9 on a 10-core laptop. Pinning a number would slow every developer\n * to serve the agent, and a percentage would only re-describe a default that already adapts.\n * So one variable changes here and the tool keeps sizing its own pool.\n *\n * Memory was the reason to hesitate and it was measured rather than assumed: a full jsdom\n * run holds 1.1 GB at three workers and 1.9 GB at six, on agents with 32 GB. The OOM this\n * repo suffered was three nx tasks near 7.45 GB each, which is not what a test worker costs.\n *\n * A module that declares its own concurrency still overrides this, as before.\n */\n fileParallelism: true,\n\n /*\n * ⚠️ Sentinel's own setup files go through VITE, not round it, and that is load-bearing.\n *\n * Vitest externalizes anything under `node_modules`, so an installed `@hublo/sentinel` is\n * loaded by Node while the module's own code is served by Vite. The two then hold DIFFERENT\n * instances of the same package, and a setup whose whole job is to mutate per-copy state\n * mutates a copy nobody reads.\n *\n * Measured on `apps/nest/microservices/agency`, with the published 1.4.0-alpha.4:\n *\n * zone of the copy sentinel pinned UTC\n * zone of the copy the test imports Europe/Paris\n * same object false\n *\n * Six tests that passed under jest failed, all comparing `DateTime.now().toISO()` against a\n * date the provider had serialised: identical instants, one rendered `+02:00` and the other\n * `Z`. The root jest setup pinned `Settings.defaultZone = 'utc'` and 97 modules named it, so\n * this is not one module's edge case.\n *\n * ⚠️ It hid for a whole campaign because the harness SYMLINKS sentinel to its source tree.\n * The resolved path then holds no `node_modules`, Vitest inlines it, and the pin lands on the\n * right copy: 96 modules reported IDENTIQUE while the real install was red. An instrument\n * that installs the package differently from a team does not measure what a team will see.\n *\n * The narrow form `/@hublo\\/sentinel\\/dist\\/roles\\//` was tried and does NOT work: the pin\n * itself lives in a shared chunk at the dist root, which stays external. It has to be the\n * whole package.\n *\n * ## ⚠️ And `vitest` itself, for the same reason one level further out\n *\n * Inlining sentinel is not enough: its own `import { expect } from 'vitest'` still leaves\n * through Node, which loads a SECOND instance of the runner. The snapshot client is\n * per-instance state, so the instance the test file uses was never set up for that file:\n *\n * Error: The snapshot state for '…/asyncapi.module.spec.ts' is not found.\n * Did you call 'SnapshotClient.setup()'?\n *\n * Isolated to the smallest possible case: an EMPTY setup file under `node_modules` passes,\n * and the same file containing nothing but `import { expect } from 'vitest'` fails, while\n * the identical import from a setup file INSIDE the module passes. So it is the location,\n * not the import, and the remedy has to reach the import too.\n *\n * Measured on `libs/nest/asyncapi`: sentinel alone 1 failed of 13, sentinel and `vitest`\n * 13 passed, 525 ms against 570 ms. Not a trade.\n */\n server: { deps: { inline: [/@hublo\\/sentinel/, 'vitest'] } },\n },\n }\n}\n\n/**\n * Vite accepts `alias` as an ARRAY or as an object map, and the two do not combine.\n *\n * The array form is the one that matters here: only it takes a RegExp `find`, which both the axios\n * and the `jest-mock-extended` aliases need. A module overriding with the object form gets its\n * entries converted rather than dropped, because silently losing an override is worse than a shape\n * the caller did not expect.\n */\nfunction asAliasArray(alias: AliasOptions | undefined): ViteAlias[] {\n if (alias === undefined) return []\n if (Array.isArray(alias)) return alias as ViteAlias[]\n return Object.entries(alias as Record<string, string>).map(([find, replacement]) => ({\n find,\n replacement,\n }))\n}\n\n/** A `test.server` block, named off Vitest's own type so the merge cannot drift from it. */\ntype TestServer = NonNullable<ViteUserConfig['test']>['server']\n\n/** The config, with the module's own overrides merged over it. */\nexport function sharedTestConfig(\n options: SharedTestOptions & { flavour: TestFlavour },\n): ViteUserConfig {\n return withIsolationChoice(mergedConfig(options), options)\n}\n\n/**\n * The isolation the module asked for, and everything that has to come with it.\n *\n * Two things travel together and neither works alone: the file boundary, which gives back per\n * file what a shared worker leaks, and the split, which keeps isolation for the files that mock a\n * module. See `./setup/file-boundary.js` and `./isolation-split.js` for what each measured.\n */\nfunction withIsolationChoice(\n config: ViteUserConfig,\n options: SharedTestOptions & { flavour: TestFlavour },\n): ViteUserConfig {\n if (options.isolate !== false) return config\n\n /*\n * Nest does not get this, and the refusal is measured rather than cautious.\n *\n * What it would buy: `agency`, 120 files and 539 tests, goes from 43s to 40s and uses the same\n * peak memory. Seven percent, where the same change takes a jsdom module from 44.6s to 13s,\n * because a Nest suite's cost is its test bodies and a React suite's cost is re-evaluating its\n * import graph once per file.\n *\n * What it would cost is written a few lines up, where `isolate: true` is set for this flavour:\n * Nest registers metadata as an import SIDE EFFECT, so a decorator writes into a catalog when\n * its module loads and a shared registry lets one suite see what another registered. Refused\n * rather than ignored, because a module that asked for it and silently did not get it would\n * read its own config as a lie.\n */\n if (options.flavour === 'nest') {\n throw new Error(\n 'sentinel test: `isolate: false` is not available for a Nest suite. Nest registers its ' +\n 'metadata as an import side effect, so sharing a module registry lets one suite see what ' +\n 'another registered. Measured on `agency`, it would save 7% (43s to 40s) where a React ' +\n 'module saves 71%, so the trade is not worth making. Remove the option.',\n )\n }\n\n const bracketed: ViteUserConfig = {\n ...config,\n test: {\n ...config.test,\n /*\n * The boundary brackets the module's own setup files rather than joining them. The closing\n * entry has to run after the module's, because what it records as \"infrastructure\" is\n * whatever the setup files built, and `setupFiles` order is the only way to say \"last\".\n */\n setupFiles: [\n '@hublo/sentinel/test/setup/file-boundary',\n ...asSetupList(config.test?.setupFiles),\n '@hublo/sentinel/test/setup/file-boundary-close',\n ],\n },\n }\n\n return asIsolationSplit(bracketed, options.root)\n}\n\n/** `setupFiles` accepts a string or a list; the boundary needs a list either way. */\nfunction asSetupList(setupFiles: unknown): string[] {\n if (typeof setupFiles === 'string') return [setupFiles]\n if (Array.isArray(setupFiles)) return setupFiles as string[]\n return []\n}\n\n/** The base with the module's own overrides merged over it. */\nfunction mergedConfig(options: SharedTestOptions & { flavour: TestFlavour }): ViteUserConfig {\n const base = baseConfig(options)\n if (options.overrides === undefined) return base\n // Shallow by section rather than a deep merge helper: the three sections a module overrides in\n // practice are `test`, `resolve` and `plugins`, and a deep merge would silently concatenate\n // arrays a module meant to replace.\n return {\n ...base,\n ...options.overrides,\n plugins: [...(base.plugins ?? []), ...(options.overrides.plugins ?? [])],\n resolve: {\n ...base.resolve,\n ...options.overrides.resolve,\n /*\n * The module's own aliases come after sentinel's, and in a Vite alias ARRAY the FIRST match\n * wins. So sentinel's win, which is the opposite of what this comment used to claim.\n *\n * ⚠️ The order is corrected here rather than in the code, because changing it would flip a\n * behaviour that nothing exercises. Every alias sentinel adds is ANCHORED to one exact\n * specifier: `^axios$`, `^luxon$`, `^msw$`, `^jest-mock-extended$` and\n * `^@prisma/<x>/runtime/library$`. A module's own entry collides only by naming the identical\n * string, and measured across every `jest.config*` in the repo, none does: the closest are\n * `@front/type/axios` and `@front/api/msw-handlers` in `front-legacy`, different specifiers\n * in the one module this role refuses anyway.\n *\n * So today the order decides nothing, and all 97 migrations were measured with it this way\n * round. Reversing it on a hypothesis would be a silent behaviour change bought with nothing.\n * What was actually wrong was a comment promising a module it could win, which a reader would\n * have relied on.\n */\n alias: [\n ...asAliasArray(base.resolve?.alias),\n ...asAliasArray(options.overrides.resolve?.alias),\n ],\n },\n test: {\n ...base.test,\n ...options.overrides.test,\n /*\n * ⚠️ `server.deps.inline` is the one key inside `test` that must not be REPLACED.\n *\n * The shallow spread above is right for everything else: a module overriding `environment`\n * or `testTimeout` means to replace it. But the base uses this list to put sentinel's own\n * setup inside Vite's graph, and a module declares its own entries there for its workspace\n * packages. Dropping either half breaks something silently, and the halves have nothing to\n * do with each other, so they are concatenated.\n *\n * Measured on `libs/front/api`, which declares `['@front/runtime-config', '@segment/snippet']`\n * and would otherwise have discarded the base's entry and lost the timezone pin with it.\n */\n server: mergeServerDeps(base.test?.server, options.overrides.test?.server),\n },\n }\n}\n\n/** Two `server` blocks, with their `deps.inline` lists joined rather than one winning. */\nfunction mergeServerDeps(base: TestServer, override: TestServer): TestServer {\n if (base === undefined) return override\n if (override === undefined) return base\n\n const inline = [\n ...(asInlineArray(base.deps?.inline) ?? []),\n ...(asInlineArray(override.deps?.inline) ?? []),\n ]\n return {\n ...base,\n ...override,\n deps: { ...base.deps, ...override.deps, ...(inline.length > 0 ? { inline } : {}) },\n }\n}\n\n/** `inline` is a list or the literal `true`, and `true` cannot be concatenated with anything. */\nfunction asInlineArray(inline: unknown): (string | RegExp)[] | undefined {\n return Array.isArray(inline) ? (inline as (string | RegExp)[]) : undefined\n}\n","/**\n * Turning one config into two projects, so that most files can share a worker and the few that\n * cannot keep their isolation.\n *\n * ## Why a split rather than one setting\n *\n * Isolation is what makes a Vitest run expensive: every test file re-evaluates the whole import\n * graph. Measured on `front-components`, 230 files and 1418 tests, same machine, same session:\n *\n * jest, files in parallel 15.9 s\n * Vitest, isolated 44.6 s\n * Vitest, this split 11.0 s\n *\n * `./setup/file-boundary.js` gives back, by hand, everything a shared worker would otherwise leak.\n * One thing it cannot give back is a module that has already been evaluated. `vi.mock` has to be\n * in place BEFORE the module it replaces is imported, so a file declaring a mock cannot be handed\n * a registry another file already filled, and no hook can undo that after the fact.\n *\n * So those files, and only those, keep isolation. Measured on `front-components`, 13 of 230, which\n * is 6%. The two projects run in one command and report as one run.\n *\n * ## Why the split is read, not declared\n *\n * A list a module maintains by hand goes stale the first time someone adds a test, and it goes\n * stale silently: the file still runs, it just runs in the wrong project, and what it then breaks\n * lands on an unrelated file. Reading the sources costs one `readFileSync` per test file, measured\n * at a few milliseconds for 230, and it cannot drift.\n *\n * `jest.mock` counts as well as `vi.mock`: a module can be adopted before its codemod has run, and\n * `./setup/jest-global.js` makes the `jest` global work, so the call is real. `doMock` is spelled\n * out rather than folded into an optional `do` prefix, which is how the first version missed it:\n * the M is capital, and a case-insensitive flag would have matched a variable called `domock`.\n */\nimport { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport { globSync } from 'tinyglobby'\nimport type { ViteUserConfig } from 'vitest/config'\n\n/**\n * The call that forces a file to keep its isolation.\n *\n * Deliberately not anchored to the start of a line: `vi.mock` is hoisted by Vitest wherever it\n * sits, including inside a `describe`. A match inside a comment or a string costs that one file\n * its share of the speed-up and nothing else, which is the right way round for a heuristic that\n * decides isolation.\n */\nconst DECLARES_A_MODULE_MOCK = /\\b(?:vi|jest)\\.(?:mock|doMock)\\s*\\(/\n\n/**\n * The test files under `root` that `include` selects, relative to `root`, in a stable order.\n *\n * ⚠️ `tinyglobby`, not `node:fs`'s `globSync`, which lands in Node 22. Chosen when the floor was\n * Node 20.12: under Node 20 every call here threw `TypeError: globSync is not a function`, 8 tests\n * of 1747. The floor is now `engines.node` >=24.15.0 (`src/shared/node-version.ts`), where the\n * built-in exists; `tinyglobby` stays, it is what Vitest itself globs with and already ships.\n *\n * ⚠️ A glob swap decides WHICH files get isolated, so the two were compared rather than assumed\n * equal: 5 pattern shapes against 4 real modules, 20 combinations, identical file sets every\n * time, up to a 1463-file case. Only the option name differs, `exclude` becoming `ignore`.\n */\nexport function testFilesUnder(root: string, include: readonly string[]): string[] {\n return globSync([...include], { cwd: root, ignore: ['**/node_modules/**'] })\n .map(String)\n .sort()\n}\n\n/** Those of `files` that declare a module mock, and those that do not. */\nexport function splitByModuleMock(\n root: string,\n files: readonly string[],\n): { mocked: string[]; shared: string[] } {\n const mocked: string[] = []\n const shared: string[] = []\n\n for (const file of files) {\n const source = readSource(join(root, file))\n if (source !== undefined && DECLARES_A_MODULE_MOCK.test(source)) mocked.push(file)\n else shared.push(file)\n }\n\n return { mocked, shared }\n}\n\n/**\n * `config`, expressed as two projects: everything in a shared worker, the module-mocking files\n * isolated.\n *\n * The base is SPREAD into each project rather than reached through Vitest's `extends`. Measured:\n * `extends` merges with `mergeConfig`, which concatenates arrays, so each project's `include` came\n * back as the base's patterns plus its own and both projects ran all 230 files, reporting 460\n * files and 2836 tests for a module that has 230 and 1418. The count is what caught it; the run\n * was green and nearly the right duration.\n */\nexport function asIsolationSplit(config: ViteUserConfig, root: string): ViteUserConfig {\n const include = config.test?.include ?? []\n const files = testFilesUnder(root, include)\n\n // Nothing to split, and an empty `include` would make a project run the default patterns\n // instead of nothing at all.\n if (files.length === 0) return { ...config, test: { ...config.test, isolate: false } }\n\n const { mocked, shared } = splitByModuleMock(root, files)\n\n return {\n ...config,\n test: {\n // Kept at the root, where a project cannot answer for the whole run.\n coverage: config.test?.coverage,\n projects: [project(config, 'shared', shared, false), project(config, 'mocked', mocked, true)],\n },\n }\n}\n\nfunction project(\n config: ViteUserConfig,\n name: string,\n include: string[],\n isolate: boolean,\n): ViteUserConfig {\n return {\n ...config,\n test: {\n ...config.test,\n name,\n include,\n isolate,\n /*\n * A project with nothing to run is still cheaper than a conditional here: Vitest starts it,\n * finds no file and reports none. Leaving both projects in place keeps the shape of the\n * config the same for every module, which is what makes a generated config reviewable.\n */\n coverage: undefined,\n },\n }\n}\n\nfunction readSource(path: string): string | undefined {\n try {\n return readFileSync(path, 'utf8')\n } catch {\n // A file that vanished between the glob and the read is not this function's problem to report:\n // Vitest will say so itself, by name, when it fails to run it.\n return undefined\n }\n}\n","/**\n * Send every importer of the workspace's msw server to the one that actually listens.\n *\n * ## The gap an alias cannot close\n *\n * The generated config already aliases `@hublo/test/msw/server`, which covers a file naming the\n * server by its package specifier. It cannot cover a file that reaches the same module by a\n * RELATIVE path, because an alias matches the spelling of the import and `./server` is a spelling\n * thousands of unrelated files use.\n *\n * That gap is not hypothetical. `libs/nest/tests/src/msw/create-handlers.ts` exports\n * `createMswHandler`, whose body calls `server.use(...)` on `./server`. So a migrated module gets\n * its handlers registered on the WORKSPACE's server while sentinel's is the one listening, and the\n * request arrives unmatched.\n *\n * Measured on `apps/nest/microservices/institution`, its only consumer:\n *\n * jest 2958 passed\n * vitest, without this 2957 passed, 1 failed\n * the failure Worker Webservice transformTemporaryPersonToWorker\n * onUnhandledRequest, raised by sentinel's copy\n *\n * ## Why here rather than in that file\n *\n * One line in `create-handlers.ts` would also fix it. Héla, 2026-09-24: the fix belongs in what we\n * OWN. A config sentinel generates reaches every module that adopts, today and later, and asks\n * nothing of a team whose shared lib happens to sit in the path. Editing their file fixes one\n * import and leaves the next one to be discovered by whoever writes it.\n *\n * ## Why the RESOLVED path, which is narrower than it looks\n *\n * This matches what the import turned out to BE, not how it was written, so `./server`,\n * `../msw/server` and `@hublo/test/msw/server` are one case rather than three. The pattern is the\n * same convention the codemod already uses to repoint a server import: a file whose path ends in\n * `msw/server`. It is checked against the resolved id only, so a module's own `./server` that has\n * nothing to do with msw is never touched.\n *\n * ## What it does NOT do\n *\n * Redirect anything outside the workspace. A `msw/server` inside `node_modules` is a package's own\n * business, and sentinel's own server file is skipped so the redirect cannot point at itself.\n */\nimport type { Plugin } from 'vite'\n\n/** The convention: a module whose path ends in `msw/server`, whatever extension it carries. */\nconst WORKSPACE_MSW_SERVER = /(^|\\/)msw\\/server\\.[cm]?[jt]sx?$/\n\n/**\n * @param serverFile sentinel's own server, the one its setup starts listening on.\n * @param workspaceRoot the boundary: nothing outside it is redirected.\n */\nexport function mswServerRedirect(serverFile: string, workspaceRoot: string): Plugin {\n return {\n name: 'sentinel:msw-server-redirect',\n // Before the resolver settles on the workspace file, since the point is to replace it.\n enforce: 'pre',\n async resolveId(source, importer, options) {\n // Our own file, and anything already pointing at it: nothing to do, and no self-recursion.\n if (source === serverFile) return undefined\n\n const resolved = await this.resolve(source, importer, { ...options, skipSelf: true })\n if (resolved === null || resolved.external) return undefined\n\n const id = resolved.id\n if (!id.startsWith(workspaceRoot)) return undefined\n if (id.includes('/node_modules/')) return undefined\n if (!WORKSPACE_MSW_SERVER.test(id)) return undefined\n\n return serverFile\n },\n }\n}\n","/**\n * Resolve packages the way jest did, for a suite that was written against jest's resolution.\n *\n * ## What jest resolved, measured rather than remembered\n *\n * Every suite in this repo ran through `@nx/jest/preset`, whose\n * `testEnvironmentOptions.customExportConditions` is exactly `['node', 'require', 'default']`\n * (read off the installed preset, not off its documentation). `development` was never in that\n * list, so a package shipping a separate development build behind that condition loaded its\n * PRODUCTION file under jest.\n *\n * Vitest resolves with Vite's conditions instead, and its default carries the\n * `development|production` token. Measured on a bare config, the resolved list is\n * `['node', 'development|production']`. `@emotion/cache` then loads\n * `emotion-cache.development.cjs.js`, whose extra stylis plugin calls\n * `console.error(':first-child is potentially unsafe...')`.\n *\n * With `jest-fail-on-console` in the setup, that console call IS a failure: **100 tests over 26\n * files on `apps/front/front-legacy`**, every one of them green under jest. `libs/front/components`\n * hits the same root cause on one test.\n *\n * ## Why a plugin and not a config line\n *\n * Declaring `ssr.resolve.conditions: ['node']` does nothing: Vite merges config arrays by\n * CONCATENATION, so Vitest's default is appended straight back. The token has to come off the\n * RESOLVED config, which is what `configResolved` is for.\n *\n * This is the same shape as the other thing that cannot be declared: a module cannot reproduce\n * `customExportConditions` either, because the list it asks for is PREFIXED to Vite's defaults\n * rather than substituted for them.\n *\n * ## The three lists are one array\n *\n * Measured on Vite 8: `config.resolve.conditions`, `config.ssr.resolve.conditions` and\n * `config.environments.ssr.resolve.conditions` are the SAME array object, so stripping one strips\n * all three. All three are stripped anyway. Relying on an aliasing that nothing promises is how a\n * silent regression arrives on a Vite upgrade, and the cost of being explicit is two lines.\n *\n * ## ⚠️ What this deliberately hides, said out loud\n *\n * emotion's warning is REAL: `libs/front/components` is consumed by a Next app, and a\n * `:first-child` selector is genuinely unsafe when the markup is rendered server-side. Restoring\n * jest's resolution puts that warning back out of sight.\n *\n * It is hidden here on purpose all the same, because a migration that also turns 100 green tests\n * red cannot be told apart from a migration that broke something. The baseline gate compares test\n * names, and it has no way to know which reds are progress. The selector belongs to the module's\n * owners as its own piece of work, with its own ticket, not as a side effect of changing runner.\n */\nimport type { Plugin } from 'vite'\n\n/**\n * The tokens jest never had.\n *\n * Both spellings, because the resolved config carries `development|production` (Vite's own\n * placeholder, replaced per environment) while a config written by hand may carry `development`.\n */\nconst ABSENT_UNDER_JEST = new Set(['development', 'development|production'])\n\n/** Remove them in place, since the resolved config is what the resolver will read. */\nfunction stripInPlace(conditions: string[] | undefined): void {\n if (conditions === undefined) return\n\n for (let index = conditions.length - 1; index >= 0; index -= 1) {\n const condition = conditions[index]\n if (condition !== undefined && ABSENT_UNDER_JEST.has(condition)) conditions.splice(index, 1)\n }\n}\n\n/**\n * Add to `plugins` in a module whose suite was written against jest's resolution.\n *\n * Not applied by the preset for everyone: it is a MIGRATION aid, and a module that was always on\n * Vitest never had jest's resolution to go back to. A module adopts it the day it migrates, and\n * can drop it the day its suite no longer depends on the production build.\n */\nexport function jestExportConditions(): Plugin {\n return {\n name: 'sentinel:jest-export-conditions',\n configResolved(config) {\n const environments = config as unknown as {\n environments?: { ssr?: { resolve?: { conditions?: string[] } } }\n }\n\n stripInPlace(config.resolve?.conditions as string[] | undefined)\n stripInPlace(config.ssr?.resolve?.conditions as string[] | undefined)\n stripInPlace(environments.environments?.ssr?.resolve?.conditions)\n },\n }\n}\n"],"m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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAkBrB,OAAO;AAAA,QACL,GAAG,aAAa,KAAK,SAAS,KAAK;AAAA,QACnC,GAAG,aAAa,QAAQ,UAAU,SAAS,KAAK;AAAA,MAClD;AAAA,IACF;AAAA,IACA,MAAM;AAAA,MACJ,GAAG,KAAK;AAAA,MACR,GAAG,QAAQ,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAarB,QAAQ,gBAAgB,KAAK,MAAM,QAAQ,QAAQ,UAAU,MAAM,MAAM;AAAA,IAC3E;AAAA,EACF;AACF;AAGA,SAAS,gBAAgB,MAAkB,UAAkC;AAC3E,MAAI,SAAS,OAAW,QAAO;AAC/B,MAAI,aAAa,OAAW,QAAO;AAEnC,QAAM,SAAS;AAAA,IACb,GAAI,cAAc,KAAK,MAAM,MAAM,KAAK,CAAC;AAAA,IACzC,GAAI,cAAc,SAAS,MAAM,MAAM,KAAK,CAAC;AAAA,EAC/C;AACA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH,MAAM,EAAE,GAAG,KAAK,MAAM,GAAG,SAAS,MAAM,GAAI,OAAO,SAAS,IAAI,EAAE,OAAO,IAAI,CAAC,EAAG;AAAA,EACnF;AACF;AAGA,SAAS,cAAc,QAAkD;AACvE,SAAO,MAAM,QAAQ,MAAM,IAAK,SAAiC;AACnE;","names":["join","join"]}
@@ -180,9 +180,19 @@ function ensureReleaseAgeAllowList(root, dryRun) {
180
180
  return `allow-listed ${own} under ${RELEASE_AGE_KEY} in ${WORKSPACE_YAML}`;
181
181
  }
182
182
  var GIT_IGNORE = ".gitignore";
183
- var REPORT_DIR_NAME = "static-analysis-report";
184
- var REPORT_PATTERN = `${REPORT_DIR_NAME}/`;
185
- var REPORT_HEADER = "# @hublo/sentinel: static analysis reports, written inside each module";
183
+ var REPORT_DIRS = {
184
+ "static-analysis": {
185
+ dir: "static-analysis-report",
186
+ header: "# @hublo/sentinel: static analysis reports, written inside each module",
187
+ label: "the static analysis role"
188
+ },
189
+ sql: {
190
+ dir: "sql-report",
191
+ header: "# @hublo/sentinel: sql reports, written inside each module",
192
+ label: "the sql role"
193
+ }
194
+ };
195
+ var ignores = (text, dir) => text.split("\n").some((line) => line.trim().replace(/^\//, "").replace(/\/$/, "") === dir);
186
196
  var PRETTIER_IGNORE = ".prettierignore";
187
197
  var EXCLUSION_HEADER = "# @hublo/sentinel: modules formatted by oxfmt, not by the root Prettier";
188
198
  var ROOT_PRETTIER_CONFIGS = [
@@ -230,19 +240,21 @@ ${pattern}
230
240
  }
231
241
  return `excluded ${rel} from the root Prettier (${PRETTIER_IGNORE}): it formats itself now`;
232
242
  }
233
- function ensureReportIgnored(root, dryRun) {
243
+ function ensureReportIgnored(root, role, dryRun) {
244
+ const entry = REPORT_DIRS[role];
245
+ if (entry === void 0) return void 0;
246
+ const pattern = `${entry.dir}/`;
234
247
  const path = join2(root, GIT_IGNORE);
235
248
  const existing = existsSync2(path) ? readFileSync2(path, "utf8") : "";
236
- const already = existing.split("\n").some((line) => line.trim().replace(/^\//, "").replace(/\/$/, "") === REPORT_DIR_NAME);
237
- if (already) return void 0;
238
- if (dryRun) return `would ignore ${REPORT_PATTERN} in the root ${GIT_IGNORE}`;
249
+ if (ignores(existing, entry.dir)) return void 0;
250
+ if (dryRun) return `would ignore ${pattern} in the root ${GIT_IGNORE}`;
239
251
  const prefix = existing.trim() === "" ? "" : `${existing.replace(/\n*$/, "")}
240
252
 
241
253
  `;
242
- writeFileSync(path, `${prefix}${REPORT_HEADER}
243
- ${REPORT_PATTERN}
254
+ writeFileSync(path, `${prefix}${entry.header}
255
+ ${pattern}
244
256
  `);
245
- return `ignored ${REPORT_PATTERN} in the root ${GIT_IGNORE}`;
257
+ return `ignored ${pattern} in the root ${GIT_IGNORE}`;
246
258
  }
247
259
  function ensureWorkspacePrep(opts) {
248
260
  const dryRun = Boolean(opts.dryRun);
@@ -250,7 +262,7 @@ function ensureWorkspacePrep(opts) {
250
262
  ensureI18nextSingleton(opts.root, dryRun),
251
263
  ensureReleaseAgeAllowList(opts.root, dryRun),
252
264
  opts.formattedModule === void 0 ? void 0 : ensureFormatterExclusion(opts.root, opts.formattedModule, dryRun),
253
- opts.analysedModule === true ? ensureReportIgnored(opts.root, dryRun) : void 0
265
+ ...Object.keys(REPORT_DIRS).filter((role) => opts.adoptedRoles?.includes(role) === true).map((role) => ensureReportIgnored(opts.root, role, dryRun))
254
266
  ].filter((message) => message !== void 0);
255
267
  }
256
268
  function inspectWorkspacePrep(root) {
@@ -283,11 +295,13 @@ function inspectWorkspacePrep(root) {
283
295
  }
284
296
  const ignorePath = join2(root, GIT_IGNORE);
285
297
  if (existsSync2(ignorePath)) {
286
- const ignored = readFileSync2(ignorePath, "utf8").split("\n").some((line) => line.trim().replace(/^\//, "").replace(/\/$/, "") === REPORT_DIR_NAME);
287
- if (ignored) {
298
+ const ignoreText = readFileSync2(ignorePath, "utf8");
299
+ for (const [role, entry] of Object.entries(REPORT_DIRS)) {
300
+ if (!ignores(ignoreText, entry.dir)) continue;
301
+ const pattern = `${entry.dir}/`;
288
302
  entries.push({
289
- rule: `${GIT_IGNORE} \u2192 ${REPORT_PATTERN}`,
290
- reason: `the static analysis role writes its json and html into \`<module>/${REPORT_PATTERN}\`, and one unanchored line at the root covers every module instead of creating a \`${GIT_IGNORE}\` in each one. Unlike the override above it changes no resolution and no build, so a stale one costs a single unused line. It retires when no module declares a \`static-analysis\` script any more, which the adoption report counts and this read deliberately does not: it would have to sweep every module.`
303
+ rule: `${GIT_IGNORE} \u2192 ${pattern}`,
304
+ reason: `${entry.label} writes its report files into \`<module>/${pattern}\`, and one unanchored line at the root covers every module instead of creating a \`${GIT_IGNORE}\` in each one. Unlike the override above it changes no resolution and no build, so a stale one costs a single unused line. It retires when no module declares a \`${role}\` script any more, which the adoption report counts and this read deliberately does not: it would have to sweep every module.`
291
305
  });
292
306
  }
293
307
  }
@@ -318,4 +332,4 @@ export {
318
332
  ensureWorkspacePrep,
319
333
  inspectWorkspacePrep
320
334
  };
321
- //# sourceMappingURL=chunk-ZNANJEMK.js.map
335
+ //# sourceMappingURL=chunk-JT7ZMH44.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shared/package-json.ts","../src/core/settings.ts","../src/core/workspace-prep.ts"],"sourcesContent":["/**\n * package.json helpers, shared by the CLI and the engine.\n */\nimport { existsSync, readFileSync } from 'node:fs'\nimport { basename, dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/**\n * sentinel's OWN version, for `--version`. We must NOT use\n * `process.env.npm_package_version`, that is the version of whatever script\n * invoked us (an app's package.json, or nothing). Instead walk up from this\n * module to the nearest package.json, which is always sentinel's own, whether\n * running from source or the bundled dist.\n */\n/**\n * sentinel's OWN name + version, read by walking up from this module to the nearest\n * package.json. Used both for `--version` and to pin the exact dependency `--init`\n * writes into an adopted module, so a module always references the version that adopted it.\n */\nexport function readOwnPackage(): { name: string; version: string; bin?: string } {\n let dir = dirname(fileURLToPath(import.meta.url))\n for (;;) {\n const pkgPath = join(dir, 'package.json')\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as {\n name?: string\n version?: string\n bin?: string | Record<string, string>\n }\n if (typeof pkg.version === 'string') {\n // The bin PATH, not the command name: a package that adopts itself has to invoke\n // its own build output, because the `.bin` shim does not exist yet (see below).\n const bin = typeof pkg.bin === 'string' ? pkg.bin : Object.values(pkg.bin ?? {})[0]\n return { name: pkg.name ?? '@hublo/sentinel', version: pkg.version, bin }\n }\n } catch {\n // Malformed package.json; keep walking up.\n }\n }\n const parent = dirname(dir)\n if (parent === dir) return { name: '@hublo/sentinel', version: '0.0.0' } // filesystem root\n dir = parent\n }\n}\n\nexport function readOwnVersion(): string {\n return readOwnPackage().version\n}\n\n/**\n * The directory sentinel's own `package.json` sits in, for the files it SHIPS beside its code.\n *\n * ⛔ Walked up to, never computed from a count of `..`. The emitted layout is not ours to predict:\n * `tsup` bundles the source into chunks whose depth has nothing to do with the source tree's, and\n * it moves code between them from one build to the next. A relative path from `import.meta.url` is\n * therefore right in `src/` and wrong in `dist/`, which is exactly the failure\n * `roles/test/shared-test-config.ts` records at length after it cost a module 83 passing tests.\n *\n * Measured here: `plugins/sonar-cognitive.js` resolved through a four-segment relative path existed\n * when run from source and did not after the build, and the only symptom was the whole size pass\n * reporting \"oxlint could not be run\".\n */\nexport function ownPackageDir(): string {\n let dir = dirname(fileURLToPath(import.meta.url))\n for (;;) {\n if (existsSync(join(dir, 'package.json'))) return dir\n const parent = dirname(dir)\n if (parent === dir) return dir\n dir = parent\n }\n}\n\n/**\n * Read a module's package.json for framework detection; tolerant of a missing or\n * malformed file (returns `{}`, so detection falls through to the `node` default).\n */\nexport function readProjectPackageJson(dir: string): {\n /** The package name, which is also what nx calls the project when there is no `project.json`. */\n name?: string\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n /**\n * How the module's `.js`/`.ts` files are loaded. It decides whether a Vite config can import\n * an ESM-only package at all, which is why the build role reads it before rewriting one.\n */\n type?: string\n /**\n * What nx alone needs per target, which every role writes here and none could read back.\n *\n * Typed loosely on purpose: this reader is shared by every role and each one knows the shape of\n * its own target. Declared at all because a role that WRITES a block and then has to cast to\n * read it is one refactor away from reading a key it never wrote.\n */\n nx?: { targets?: Record<string, Record<string, unknown>> }\n /**\n * The npm scripts, which several roles read to know what a module can DO rather than what it is.\n *\n * ⚠️ Added when the bundle pass had to tell two silences apart: a module that declares a build\n * and produced no manifest is a defect to act on, a module that declares none has nothing to\n * measure. Without this the two shared one sentence, and it told a front team their application\n * ships no bundle.\n */\n scripts?: Record<string, string>\n} {\n const path = join(dir, 'package.json')\n if (!existsSync(path)) return {}\n try {\n return JSON.parse(readFileSync(path, 'utf8')) as Record<string, never>\n } catch {\n process.stderr.write(`sentinel: could not parse ${path}; ignoring for detection.\\n`)\n return {}\n }\n}\n\n/**\n * The nx project name for a module, read from its `project.json`, or undefined if\n * there is none/unreadable. Used when `--init` has to scaffold a `package.json`\n * for a module that only has a `project.json` (common for nx apps/services): the\n * scaffolded file borrows this name so it is a valid, uniquely-named workspace\n * package. Reusable by any tool that scaffolds, not just TypeScript.\n */\nexport function readNxProjectName(dir: string): string | undefined {\n const path = join(dir, 'project.json')\n if (!existsSync(path)) return undefined\n try {\n const parsed = JSON.parse(readFileSync(path, 'utf8')) as { name?: unknown }\n return typeof parsed.name === 'string' ? parsed.name : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * What nx calls this module, resolved the way nx itself resolves it.\n *\n * The precedence is `project.json`, then `package.json`, then the directory, and only the\n * first and last of those were being consulted. A module with no `project.json` therefore\n * answered with its DIRECTORY while nx answered with its package name, and the two disagree\n * in the real repo: `apps/front/hr-management` is `front-hr-management` to nx, as is\n * `apps/front/storybook-app`.\n *\n * That gap is not cosmetic, because this name is what `--module` is matched against. The\n * `serve` script `--init` writes carries `--module <name>`, so a module in that shape was\n * adopted with a script naming a project the workspace does not contain, and `pnpm run serve`\n * failed the day it was adopted with nothing having reported it.\n *\n * One function so the two ends cannot drift again: whoever WRITES the name and whoever\n * RESOLVES it now read the same source.\n */\nexport function moduleName(dir: string): string {\n const declared = readProjectPackageJson(dir).name\n return readNxProjectName(dir) ?? (declared === undefined ? basename(dir) : declared)\n}\n","/**\n * Tunable settings: the knobs you would actually change. The fixed vocabulary and\n * its types live in `domain.ts`.\n *\n * Note: the preset is DETECTED from a module's dependencies (see\n * `detect-framework.ts`), deterministically, `node` when no framework dep is present.\n * `--preset` overrides the detection (recommended for `--init`, since hoisted deps\n * can make detection return `node`). The detection table lives in `detect-framework.ts`.\n */\n\n/** A file that marks a workspace root; sentinel refuses to operate there. */\nexport const WORKSPACE_ROOT_MARKER = 'nx.json'\n\n/**\n * How many structured diagnostics a report embeds per module, when the caller does not say.\n *\n * A cap, not a limit on what is counted: the totals stay exact and `diagnosticsTruncated`\n * says when rows were dropped, so a bounded envelope never reads as a clean module. Shared\n * by every role, because a consumer reading `--json` across roles should not have to learn\n * a different cap for each one. `--max-diagnostics 0` means no cap.\n */\nexport const DEFAULT_MAX_DIAGNOSTICS = 100\n","/**\n * Workspace-level preparation that `--init` applies once, at the workspace root, so an\n * adopted module actually installs and resolves cleanly. `--init` writes a module's own\n * files; this is the small, deliberate exception where it also touches the root, because\n * \"set this module up\" is not honest if the workspace it lives in cannot then install or\n * resolve it.\n *\n * Kept intentionally narrow (YAGNI): it applies the specific fixes a workspace's OWN\n * config shows it needs, and is a no-op everywhere else. It is NOT a speculative dedupe\n * engine, when a second, different case appears we generalize from real cases instead of\n * predicting them. The two fixes today:\n *\n * - i18next singleton override. If the root declares a second TypeScript via the\n * `@typescript/native` alias (a repo mid-migration running two TypeScripts), adopting a\n * module re-resolves pnpm and i18next, which carries an optional type-only `typescript`\n * peer, forks into two peer-keyed variants. That forks react-i18next into two React\n * contexts and breaks translation-singleton tests. Pinning i18next's `typescript` peer\n * to the declared TS collapses it to one. Read from the root's own declaration, so it\n * tracks the version and disappears (no-op) once the migration removes the second TS.\n * Written to `pnpm-workspace.yaml`, the only place current pnpm reads overrides from.\n *\n * - release-age allow-list. If the root uses pnpm's `minimumReleaseAgeExclude` gate, a\n * freshly published sentinel is younger than the gate and will not install; allow-list\n * it. Only touched when the gate is actually configured.\n *\n * - root formatter exclusion. A module that has adopted the FORMAT role is formatted by\n * oxfmt, from its own config. The root Prettier does not know that and still owns every\n * file in the repo, so `nx format:write` or `prettier --write .` from the root reformats\n * the module back to the ROOT's style, and the next `pnpm run format` in the module\n * reverses it. Two formatters fighting over the same files, with whichever ran last\n * winning, is the exact state adoption removes INSIDE a module, and it has to be removed\n * at the root too. So the module is excluded in the root `.prettierignore` as it adopts,\n * and the root's own config is otherwise untouched: it still serves every module that has\n * not migrated.\n *\n * All three edits are idempotent and defensive: absent the trigger (no second TypeScript, no\n * release-age gate, no root Prettier) each is skipped, so the step is safe on any workspace.\n */\nimport { existsSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, join, relative } from 'node:path'\n\nimport { readOwnPackage } from '../shared/package-json.js'\n\nimport { WORKSPACE_ROOT_MARKER } from './settings.js'\n\nconst OVERRIDE_KEY = 'i18next>typescript'\nconst NATIVE_TS_ALIAS = '@typescript/native' // `npm:typescript@^7.x`: a workspace's second, real TS\nconst WORKSPACE_YAML = 'pnpm-workspace.yaml'\nconst RELEASE_AGE_KEY = 'minimumReleaseAgeExclude'\nconst LIST_ITEM = /^(\\s*)-\\s+(.*?)\\s*$/\nconst MAP_ENTRY = /^(\\s+)(.*?):\\s+(.*?)\\s*$/\n/** A line yaml ignores inside a block: blank, or a comment at any indentation. */\nconst BLANK_OR_COMMENT = /^\\s*(#.*)?$/\n/** A value's trailing ` # comment`, kept apart so an update rewrites the value and nothing else. */\nconst INLINE_COMMENT = /^(.*?)(\\s+#.*)?$/\n\ninterface RootPackageJson {\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n pnpm?: { overrides?: Record<string, string> }\n}\n\n/** Walk up from a module directory to the workspace root (the dir holding the marker). */\nexport function findWorkspaceRoot(startDir: string): string | undefined {\n let dir = startDir\n for (;;) {\n if (existsSync(join(dir, WORKSPACE_ROOT_MARKER))) return dir\n const parent = dirname(dir)\n if (parent === dir) return undefined\n dir = parent\n }\n}\n\n/**\n * The TypeScript version to pin i18next's peer to, read from the root's own\n * `@typescript/native` alias (`npm:typescript@^7.0.2` -> `7.0.2`). Returns undefined when\n * the alias is absent (no second TypeScript, so no fork to fix).\n */\nfunction declaredNativeTs(pkg: RootPackageJson): string | undefined {\n const spec = pkg.dependencies?.[NATIVE_TS_ALIAS] ?? pkg.devDependencies?.[NATIVE_TS_ALIAS]\n if (!spec) return undefined\n const version = spec.slice(spec.lastIndexOf('@') + 1).replace(/^[\\^~>=<\\s]+/, '')\n return version || undefined\n}\n\n/**\n * Ensure the i18next singleton override matches the declared second TypeScript. No-op when\n * the workspace runs a single TypeScript (no `@typescript/native`). Returns a message when\n * it changed (or would change, under dryRun), else undefined.\n *\n * The override is written to `pnpm-workspace.yaml`, never to `package.json#pnpm`: pnpm 11\n * stopped reading the `pnpm` field and does so SILENTLY, with no warning and no deprecation\n * (pnpm/pnpm#11536), so an override left in `package.json` is simply not applied. The yaml is\n * read by pnpm 10 and 11 alike (https://pnpm.io/settings), which is why there is one target\n * here rather than a version-dependent fallback.\n */\nfunction ensureI18nextSingleton(root: string, dryRun: boolean): string | undefined {\n const pkgPath = join(root, 'package.json')\n if (!existsSync(pkgPath)) return undefined\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as RootPackageJson\n const want = declaredNativeTs(pkg)\n if (!want) return undefined // single TypeScript: nothing forks\n\n const yamlPath = join(root, WORKSPACE_YAML)\n if (!existsSync(yamlPath)) return undefined // no workspace file: nowhere pnpm would read it\n const lines = readFileSync(yamlPath, 'utf8').split('\\n')\n const entry = findOverrideEntry(lines)\n if (entry.inline) {\n // Said, not skipped silently: the fork this override prevents is still there.\n return `did not pin ${OVERRIDE_KEY} to ${want}: \\`overrides:\\` in ${WORKSPACE_YAML} is written inline, add \\`${OVERRIDE_KEY}: ${want}\\` to it by hand (i18next singleton)`\n }\n if (entry.valueIdx !== undefined && entry.value === want) return undefined // already pinned\n if (dryRun) return `would pin ${OVERRIDE_KEY} to ${want} in ${WORKSPACE_YAML} (i18next singleton)`\n\n applyOverride(lines, entry, want)\n writeFileSync(yamlPath, lines.join('\\n'))\n return `pinned ${OVERRIDE_KEY} to ${want} in ${WORKSPACE_YAML} (i18next singleton)`\n}\n\n/** Where the override sits in the yaml, if at all, plus where a new one would be inserted. */\ninterface OverrideEntry {\n /** Index of the `OVERRIDE_KEY` line, when the key is already declared. */\n valueIdx?: number\n /** Its current value, unquoted, without an inline comment. */\n value?: string\n /** The key exactly as the file spells it (quoted or not), so an update keeps that spelling. */\n rawKey?: string\n /** The value's inline comment, with its leading whitespace, so an update keeps it. */\n comment?: string\n /** Index of the `overrides:` key line, when the block exists. */\n blockIdx?: number\n /** Index of the block's last entry, so an insertion keeps the block contiguous. */\n lastEntryIdx?: number\n /** Indentation the block's entries use. */\n indent: string\n /** `overrides:` is written inline (`overrides: {}`): a line edit cannot add to it safely. */\n inline?: boolean\n}\n\nconst unquote = (text: string): string => text.replace(/^['\"]|['\"]$/g, '')\nconst indentOf = (line: string): number => line.length - line.trimStart().length\n\n/**\n * The indexes of the lines that belong to the top-level block opened at `keyIdx`, blank lines and\n * comments left out.\n *\n * ⚠️ A comment or a blank line never ends a block, at any indentation: yaml ignores both, and the\n * monorepo's `overrides:` OPENS with a two-line comment. An earlier scan stopped at the first line\n * that was not an entry, so on that file it never saw `i18next>typescript`, 85 entries down, and\n * wrote it a second time: a duplicate mapping key, which yaml rejects and `pnpm run format` failed\n * on. The block ends at the first other line indented no deeper than the key. A list may sit at\n * the key's own indentation (`key:` then `- item`), so `sameIndentItems` keeps those lines in.\n */\nfunction blockLines(lines: string[], keyIdx: number, sameIndentItems = false): number[] {\n const keyIndent = indentOf(lines[keyIdx] ?? '')\n const inside: number[] = []\n for (let i = keyIdx + 1; i < lines.length; i++) {\n const line = lines[i] ?? ''\n if (BLANK_OR_COMMENT.test(line)) continue\n const indent = indentOf(line)\n const ownItem = sameIndentItems && indent === keyIndent && /^\\s*-(\\s|$)/.test(line)\n if (indent <= keyIndent && !ownItem) break // the next key: the block ended\n inside.push(i)\n }\n return inside\n}\n\n/**\n * Locate the `overrides:` block and the i18next key inside it. A targeted text read rather\n * than a yaml parse, for the same reason `ensureReleaseAgeAllowList` does it: this file is\n * hand-maintained and round-tripping it through a parser would drop its comments and ordering.\n */\nfunction findOverrideEntry(lines: string[]): OverrideEntry {\n const blockIdx = lines.findIndex((line) => /^overrides:\\s*(#.*)?$/.test(line))\n if (blockIdx === -1) {\n // Declared, but inline (`overrides: {}`). Opening a second block would be a duplicate key.\n const inline = lines.some((line) => /^overrides:\\s*[^\\s#]/.test(line))\n return inline ? { indent: ' ', inline } : { indent: ' ' }\n }\n\n const inside = blockLines(lines, blockIdx)\n // The entries are the lines at the block's own indentation; anything deeper continues one.\n const entryIndent = inside.length > 0 ? indentOf(lines[inside[0] ?? blockIdx] ?? '') : 2\n let lastEntryIdx = blockIdx\n let entry: Omit<OverrideEntry, 'blockIdx' | 'lastEntryIdx' | 'indent'> = {}\n for (const i of inside) {\n lastEntryIdx = i // past a continuation line too, so an insertion never splits an entry\n const match = lines[i]?.match(MAP_ENTRY)\n if (!match || indentOf(lines[i] ?? '') !== entryIndent) continue\n const rawKey = match[2] ?? ''\n if (entry.valueIdx !== undefined || unquote(rawKey) !== OVERRIDE_KEY) continue\n const [, value = '', comment] = (match[3] ?? '').match(INLINE_COMMENT) ?? []\n entry = { valueIdx: i, value: unquote(value), rawKey, comment }\n }\n return { ...entry, blockIdx, lastEntryIdx, indent: ' '.repeat(entryIndent) }\n}\n\n/** Update the key in place, append it to an existing block, or open a block at the end. */\nfunction applyOverride(lines: string[], entry: OverrideEntry, want: string): void {\n if (entry.valueIdx !== undefined) {\n // Only the value changes: the key keeps its spelling, the value its inline comment.\n lines[entry.valueIdx] =\n `${entry.indent}${entry.rawKey ?? `'${OVERRIDE_KEY}'`}: ${want}${entry.comment ?? ''}`\n return\n }\n const line = `${entry.indent}'${OVERRIDE_KEY}': ${want}`\n if (entry.lastEntryIdx !== undefined) {\n lines.splice(entry.lastEntryIdx + 1, 0, line)\n return\n }\n // No `overrides:` block at all: open one, keeping a single trailing newline.\n while (lines.length > 0 && lines[lines.length - 1] === '') lines.pop()\n lines.push('overrides:', line, '')\n}\n\n/**\n * Ensure sentinel is allow-listed under `minimumReleaseAgeExclude` so a fresh publish\n * installs. No-op when the workspace has no such gate. Targeted text edit so comments and\n * formatting are preserved. Returns a message when it changed (or would), else undefined.\n */\nfunction ensureReleaseAgeAllowList(root: string, dryRun: boolean): string | undefined {\n const yamlPath = join(root, WORKSPACE_YAML)\n if (!existsSync(yamlPath)) return undefined\n const own = readOwnPackage().name\n const lines = readFileSync(yamlPath, 'utf8').split('\\n')\n const keyIdx = lines.findIndex((line) => line.replace(/\\s+$/, '') === `${RELEASE_AGE_KEY}:`)\n if (keyIdx === -1) return undefined // no release-age gate in use\n\n // The whole list, comments included: the same early stop as the overrides scan listed\n // sentinel a second time below a comment (see `blockLines`).\n let lastItemIdx = keyIdx\n let indent = ' '\n for (const i of blockLines(lines, keyIdx, true)) {\n lastItemIdx = i\n const match = lines[i]?.match(LIST_ITEM)\n if (!match) continue\n indent = match[1] ?? indent\n const [, item = ''] = (match[2] ?? '').match(INLINE_COMMENT) ?? []\n if (unquote(item) === own) return undefined // already listed\n }\n if (dryRun) return `would allow-list ${own} under ${RELEASE_AGE_KEY}`\n\n lines.splice(lastItemIdx + 1, 0, `${indent}- '${own}'`)\n writeFileSync(yamlPath, lines.join('\\n'))\n return `allow-listed ${own} under ${RELEASE_AGE_KEY} in ${WORKSPACE_YAML}`\n}\n\n/** The root ignore file Prettier reads, and the section sentinel owns inside it. */\nconst GIT_IGNORE = '.gitignore'\n/**\n * The roles that write report files inside a module, the directory each writes, and the header\n * its root ignore line carries. One entry per role, so a new role that writes reports adds a row\n * here and nothing else: the write, the read and the inspection below all walk this table.\n *\n * ⚠️ The static analysis header is kept byte for byte: workspaces adopted before this table hold\n * that exact line, and a reworded header would read as a missing one.\n */\nconst REPORT_DIRS: Readonly<Record<string, { dir: string; header: string; label: string }>> = {\n 'static-analysis': {\n dir: 'static-analysis-report',\n header: '# @hublo/sentinel: static analysis reports, written inside each module',\n label: 'the static analysis role',\n },\n sql: {\n dir: 'sql-report',\n header: '# @hublo/sentinel: sql reports, written inside each module',\n label: 'the sql role',\n },\n}\n\n/** Is `dir` ignored by a line of `text`, in whichever spelling a human may have used? */\nconst ignores = (text: string, dir: string): boolean =>\n text.split('\\n').some((line) => line.trim().replace(/^\\//, '').replace(/\\/$/, '') === dir)\nconst PRETTIER_IGNORE = '.prettierignore'\nconst EXCLUSION_HEADER = '# @hublo/sentinel: modules formatted by oxfmt, not by the root Prettier'\n\n/** Root Prettier configs. Their presence is what makes an exclusion meaningful. */\nconst ROOT_PRETTIER_CONFIGS = [\n '.prettierrc',\n '.prettierrc.json',\n '.prettierrc.json5',\n '.prettierrc.yml',\n '.prettierrc.yaml',\n '.prettierrc.js',\n '.prettierrc.cjs',\n '.prettierrc.mjs',\n 'prettier.config.js',\n 'prettier.config.cjs',\n 'prettier.config.mjs',\n]\n\n/**\n * Exclude a module that now formats itself from the ROOT Prettier.\n *\n * Written as a directory pattern anchored at the root (`/apps/front/x/`), which is what\n * gitignore syntax means by \"this exact directory\", so a module cannot accidentally exclude a\n * same-named directory somewhere else.\n *\n * Skipped entirely when the root has no Prettier at all: there is then nothing to conflict\n * with, and creating an ignore file for a tool the workspace does not use would be noise.\n */\nfunction ensureFormatterExclusion(\n root: string,\n moduleDir: string,\n dryRun: boolean,\n): string | undefined {\n const rel = relative(root, moduleDir).replaceAll('\\\\', '/')\n if (rel === '' || rel.startsWith('..')) return undefined // the root itself, or outside it\n\n const ignorePath = join(root, PRETTIER_IGNORE)\n const hasPrettier =\n existsSync(ignorePath) || ROOT_PRETTIER_CONFIGS.some((name) => existsSync(join(root, name)))\n if (!hasPrettier) return undefined\n\n const pattern = `/${rel}/`\n const existing = existsSync(ignorePath) ? readFileSync(ignorePath, 'utf8') : ''\n const lines = existing.split('\\n')\n // Already excluded, in whichever spelling a human may have used.\n if (lines.some((line) => line.trim().replace(/\\/$/, '') === pattern.replace(/\\/$/, ''))) {\n return undefined\n }\n if (dryRun) return `would exclude ${rel} from the root Prettier (${PRETTIER_IGNORE})`\n\n const headerIdx = lines.findIndex((line) => line.trim() === EXCLUSION_HEADER)\n if (headerIdx === -1) {\n const prefix = existing.trim() === '' ? '' : `${existing.replace(/\\n*$/, '')}\\n\\n`\n writeFileSync(ignorePath, `${prefix}${EXCLUSION_HEADER}\\n${pattern}\\n`)\n } else {\n // Keep the managed section together and sorted, so the list stays readable as it grows\n // to 150 entries and a diff shows one added line rather than a reshuffle.\n let end = headerIdx + 1\n while (end < lines.length && lines[end]?.trim().startsWith('/')) end += 1\n const managed = [...lines.slice(headerIdx + 1, end), pattern].sort()\n writeFileSync(\n ignorePath,\n [...lines.slice(0, headerIdx + 1), ...managed, ...lines.slice(end)].join('\\n'),\n )\n }\n return `excluded ${rel} from the root Prettier (${PRETTIER_IGNORE}): it formats itself now`\n}\n\n/**\n * Apply every workspace-level fix the given root needs. Returns the human-readable\n * messages for what changed (empty when nothing did). Under dryRun nothing is written and\n * the messages describe what would change.\n *\n * `formattedModule` is the module that just adopted the FORMAT role, when one did. Absent\n * for an `--init` that adopted neither lint nor format (`--init --typescript`, say), because\n * a module that has not adopted the formatter must keep being formatted by the root. There is\n * no lint-only `--init` any more: naming lint adopts format with it (see `run-init`), so the\n * module that gets oxlint also gets oxfmt and this exclusion.\n */\n/**\n * Ignore the static analysis report directory, once, at the ROOT.\n *\n * ## Why the root and not each module\n *\n * The role writes its json and html into `<module>/static-analysis-report/`, so the obvious place\n * for the rule is the module. It was there first, and it was wrong twice over: it CREATES a\n * `.gitignore` in a module that had none, which is a structural change to someone else's module for\n * one line, and it repeats that line once per adopting module. The root already ignores output this\n * way, with `/dist` and `/coverage`.\n *\n * ⚠️ The pattern is deliberately NOT anchored. `/dist` matches only the root's `dist`; the report\n * directory lives inside a module, so `static-analysis-report/` has to match at any depth. Getting\n * that backwards would leave every adopting module with an untracked directory, which is the exact\n * defect this guards against.\n *\n * ## Why this root write is not the dangerous kind\n *\n * The comment on `inspectWorkspacePrep` is right that root writes are what nobody sees afterwards,\n * and the i18next override earned that warning: it re-resolved a module from a pull request that\n * touched none of its files. An ignore line changes no resolution, no build and no install. If it\n * ever goes stale the cost is one unused line, which is why it is reported rather than feared.\n */\nfunction ensureReportIgnored(root: string, role: string, dryRun: boolean): string | undefined {\n const entry = REPORT_DIRS[role]\n if (entry === undefined) return undefined\n const pattern = `${entry.dir}/`\n const path = join(root, GIT_IGNORE)\n const existing = existsSync(path) ? readFileSync(path, 'utf8') : ''\n if (ignores(existing, entry.dir)) return undefined\n if (dryRun) return `would ignore ${pattern} in the root ${GIT_IGNORE}`\n\n const prefix = existing.trim() === '' ? '' : `${existing.replace(/\\n*$/, '')}\\n\\n`\n writeFileSync(path, `${prefix}${entry.header}\\n${pattern}\\n`)\n return `ignored ${pattern} in the root ${GIT_IGNORE}`\n}\n\nexport function ensureWorkspacePrep(opts: {\n root: string\n dryRun?: boolean\n formattedModule?: string\n /** The roles that adopted on this run: a role writing reports earns its ignore line. */\n adoptedRoles?: readonly string[]\n}): string[] {\n const dryRun = Boolean(opts.dryRun)\n return [\n ensureI18nextSingleton(opts.root, dryRun),\n ensureReleaseAgeAllowList(opts.root, dryRun),\n opts.formattedModule === undefined\n ? undefined\n : ensureFormatterExclusion(opts.root, opts.formattedModule, dryRun),\n ...Object.keys(REPORT_DIRS)\n .filter((role) => opts.adoptedRoles?.includes(role) === true)\n .map((role) => ensureReportIgnored(opts.root, role, dryRun)),\n ].filter((message): message is string => message !== undefined)\n}\n\n/**\n * One standing change sentinel has made to the workspace ROOT, and whether it is still earned.\n *\n * This exists because the three root writes are the only thing sentinel does that nobody can\n * see afterwards. `--init` announces each one on the run that makes it, and then it is a line\n * in someone else's file forever. Two consequences already bit us.\n *\n * The `i18next>typescript` override re-resolved `apps/front/console` from a PR that touched no\n * file under it, so CODEOWNERS pulled nobody and its owners learned about it afterwards.\n *\n * And every one of them is TEMPORARY with its removal condition written in prose. That failed\n * three times in one week: `SENTINEL_TAG=alpha` in the migration-page workflow kept building\n * with a pre-release long after 1.1.0 went stable and reported `Format 0/439` for 15 adopted\n * modules; ADR 0042 and its RFC both sat mid-flight past their deadline; and this release-age\n * exclusion is still waiting on \"once sentinel's release cadence settles\". Nothing failed when\n * any of them expired, because a comment cannot fail.\n *\n * So each entry carries the condition that JUSTIFIES it, evaluated now rather than described.\n * A trigger that has gone away makes the entry dead config, and dead config is something a\n * command can say out loud instead of something a reader has to notice.\n *\n * Read-only, and offline: it inspects the same files `--init` writes and nothing else. What it\n * deliberately does NOT claim is anything needing the npm registry — whether a published\n * version is old enough to clear the release-age gate is not knowable from the repo, so it is\n * stated as the standing exemption it is rather than guessed at.\n */\nexport interface WorkspacePrepEntry {\n /** `rule` to match the shape the shared renderer already prints as a labelled block. */\n rule: string\n /** What it does, whether its trigger still holds, and what would retire it. */\n reason: string\n}\n\n/** The root-level changes sentinel maintains here, each with its justification checked now. */\nexport function inspectWorkspacePrep(root: string): WorkspacePrepEntry[] {\n const entries: WorkspacePrepEntry[] = []\n // Tolerant, unlike the write path above, and the difference is deliberate. `--init` should\n // fail loudly on a root it cannot parse, because it is about to edit it. `--inspect` is a\n // read verb that sweeps 441 modules, and one malformed root file must not take the whole\n // sweep down: the modules still have honest answers to give. Caught by its own test.\n let pkg: RootPackageJson = {}\n const pkgPath = join(root, 'package.json')\n if (existsSync(pkgPath)) {\n try {\n pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as RootPackageJson\n } catch {\n pkg = {}\n }\n }\n\n const yamlPath = join(root, WORKSPACE_YAML)\n const yaml = existsSync(yamlPath) ? readFileSync(yamlPath, 'utf8') : undefined\n\n const pinned = yaml === undefined ? undefined : findOverrideEntry(yaml.split('\\n')).value\n if (pinned !== undefined) {\n const stillForks = declaredNativeTs(pkg)\n entries.push({\n rule: `${WORKSPACE_YAML} → overrides.${OVERRIDE_KEY}`,\n reason:\n stillForks === undefined\n ? `pinned to ${pinned}, but the root no longer declares ${NATIVE_TS_ALIAS}, so nothing ` +\n `forks any more. This override is now dead config and can be removed.`\n : `pinned to ${pinned}, matching the second TypeScript the root declares ` +\n `(${NATIVE_TS_ALIAS}). It re-resolves i18next for EVERY module that depends on it, ` +\n `not only adopted ones. It retires with the second TypeScript.`,\n })\n }\n\n // A copy left in `package.json#pnpm` by an older sentinel, or by hand. Reported because it\n // is INERT rather than redundant: pnpm 11 dropped the `pnpm` field with no warning\n // (pnpm/pnpm#11536), so it reads as protection that is not applied.\n const legacy = pkg.pnpm?.overrides?.[OVERRIDE_KEY]\n if (legacy !== undefined) {\n entries.push({\n rule: `package.json → pnpm.overrides.${OVERRIDE_KEY}`,\n reason:\n `pinned to ${legacy}, but pnpm 11 no longer reads the \\`pnpm\\` field of package.json ` +\n `and says nothing about it, so this override is not applied. Move it to ` +\n `${WORKSPACE_YAML} under \\`overrides:\\`, which pnpm 10 and 11 both read.`,\n })\n }\n\n const ignorePath = join(root, GIT_IGNORE)\n if (existsSync(ignorePath)) {\n const ignoreText = readFileSync(ignorePath, 'utf8')\n for (const [role, entry] of Object.entries(REPORT_DIRS)) {\n if (!ignores(ignoreText, entry.dir)) continue\n const pattern = `${entry.dir}/`\n entries.push({\n rule: `${GIT_IGNORE} → ${pattern}`,\n reason:\n `${entry.label} writes its report files into ` +\n `\\`<module>/${pattern}\\`, and one unanchored line at the root covers every module ` +\n `instead of creating a \\`${GIT_IGNORE}\\` in each one. Unlike the override above it changes ` +\n `no resolution and no build, so a stale one costs a single unused line. It retires when no ` +\n `module declares a \\`${role}\\` script any more, which the adoption report counts ` +\n `and this read deliberately does not: it would have to sweep every module.`,\n })\n }\n }\n\n const own = readOwnPackage().name\n if (yaml !== undefined) {\n const listed = new RegExp(`^\\\\s*-\\\\s*['\"]?${own.replace('/', '\\\\/')}['\"]?\\\\s*$`, 'm').test(yaml)\n if (listed) {\n const gated = new RegExp(`^\\\\s*minimumReleaseAge\\\\s*:`, 'm').test(yaml)\n entries.push({\n rule: `${WORKSPACE_YAML} → ${RELEASE_AGE_KEY}: ${own}`,\n reason: gated\n ? `${own} is exempt from this workspace's release-age gate, so a freshly published ` +\n `version installs instead of being held. That is a standing exemption from a ` +\n `supply-chain control: the exposure is one bump wide, since the version is pinned ` +\n `and the lockfile carries its integrity, so a re-publish of the same version does ` +\n `not pass. Retire it once a bump can simply wait out the window.`\n : `${own} is allow-listed, but this workspace no longer sets minimumReleaseAge, so ` +\n `there is no gate to be exempt from. This entry is now dead config and can be removed.`,\n })\n }\n }\n\n return entries\n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