@hublo/sentinel 1.7.0-alpha.0 → 1.7.0-alpha.10

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 (49) hide show
  1. package/README.md +2 -0
  2. package/dist/bin/sentinel.js +20 -16
  3. package/dist/{chunk-WMBXYYLD.js → chunk-AWDCC5VJ.js} +2972 -1148
  4. package/dist/{chunk-VVEKPCRY.js → chunk-EESVRILJ.js} +3 -13
  5. package/dist/chunk-EESVRILJ.js.map +1 -0
  6. package/dist/{chunk-ZNANJEMK.js → chunk-JT7ZMH44.js} +30 -16
  7. package/dist/chunk-JT7ZMH44.js.map +1 -0
  8. package/dist/chunk-LU4E4TVD.js +183 -0
  9. package/dist/chunk-LU4E4TVD.js.map +1 -0
  10. package/dist/{chunk-7E6YTTAK.js → chunk-LX7EG6PJ.js} +5 -6
  11. package/dist/chunk-LX7EG6PJ.js.map +1 -0
  12. package/dist/{chunk-4YQXLPJ5.js → chunk-PMRL4MH6.js} +2 -2
  13. package/dist/chunk-PXTU5MPW.js +9 -0
  14. package/dist/chunk-PXTU5MPW.js.map +1 -0
  15. package/dist/chunk-QXFCZON7.js +16 -0
  16. package/dist/chunk-QXFCZON7.js.map +1 -0
  17. package/dist/{chunk-POZDYETY.js → chunk-SWWQ7X7B.js} +12 -22
  18. package/dist/{chunk-POZDYETY.js.map → chunk-SWWQ7X7B.js.map} +1 -1
  19. package/dist/{chunk-EVGG55ZO.js → chunk-ZASD5YPF.js} +93 -88
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +7 -5
  22. package/dist/roles/build/nest/toolchain.d.ts +1 -1
  23. package/dist/roles/build/nest/toolchain.js +3 -6
  24. package/dist/roles/build/nest/toolchain.js.map +1 -1
  25. package/dist/roles/sql/config.d.ts +68 -0
  26. package/dist/roles/sql/config.js +8 -0
  27. package/dist/roles/sql/config.js.map +1 -0
  28. package/dist/roles/static-analysis/config.js +2 -1
  29. package/dist/roles/test/nest/toolchain.d.ts +1 -1
  30. package/dist/roles/test/nest/toolchain.js +3 -3
  31. package/dist/roles/test/react/toolchain.js +3 -3
  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 +3 -3
  36. package/dist/{tsconfig-aliases-C_PxuZni.d.ts → tsconfig-aliases-Ce6axdJ4.d.ts} +2 -17
  37. package/dist/{validate-VWP6YZP5.js → validate-QYP7HFSY.js} +3 -3
  38. package/docs/build-adoption.md +0 -7
  39. package/docs/sql-adoption.md +411 -0
  40. package/docs/test-adoption.md +1 -8
  41. package/docs/typescript-traces.md +216 -2
  42. package/docs/using-sentinel.md +2 -1
  43. package/package.json +6 -1
  44. package/dist/chunk-7E6YTTAK.js.map +0 -1
  45. package/dist/chunk-VVEKPCRY.js.map +0 -1
  46. package/dist/chunk-ZNANJEMK.js.map +0 -1
  47. package/dist/chunk-ZVHUG6CA.js +0 -88
  48. package/dist/chunk-ZVHUG6CA.js.map +0 -1
  49. /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
 
@@ -255,6 +256,7 @@ The rules live in `sentinel`. Each module keeps a **thin, generated stub** per t
255
256
  - **Rules in sentinel** — one source of truth, versioned.
256
257
  - **Thin stubs per module** — the stub is what keeps the **editor working** (VS Code discovers config by file, real-time lint/type/format stay live) and what **nx** uses to infer targets. Stubs are **generated by `sentinel --init`**, never hand-written; swapping a runner regenerates them.
257
258
  - **Drift guard** — sentinel validates that each stub is _only_ the sanctioned `extends`, with nothing of the preset's overridden. Unsanctioned drift is flagged in CI; a genuine exception must be **declared in an allowlist** (visible, reviewed), never silent. One addition is sanctioned, in lint: what the preset does not govern (a rule it does not name, a plugin, jsPlugin or setting it does not set) is the module's own, kept by `--init`, not drift, and listed by `--inspect`; a rule the preset names, set to another value, or an entry that collides with the preset's, is drift ([lint-adoption.md](docs/lint-adoption.md#what---inspect-calls-drift-and-what-it-lists-as-yours)).
259
+ - **Adopt first, then run the module's own** — every analysis tool starts with an adoption (`--init`: its config file, its scripts, the pinned devDependency); after it, the developer, the CI and an AI run the module's script, so all three use the same version. `static-analysis` and `sql` are the reference implementations ([CONTRIBUTING.md](CONTRIBUTING.md#an-analysis-role-adopt-first-then-everyone-runs-the-modules-own)).
258
260
  - **Per-module install** — `@hublo/sentinel` is added per module, so adoption is **gradual** (migrate lot by lot; a module can adopt sentinel while its neighbour still uses the old config). Root configs are removed only once the **last** module has migrated.
259
261
  - **Runner binaries** (`eslint`, `typescript`, `vite`, `vitest`, …) are **resolved from the adopting module** at run time (sentinel looks for the tool in the module, then falls back to `PATH`), so the editor and nx keep using the exact binary the project already installs. sentinel does **not** declare them as dependencies today, so it does not pin their versions: the module still owns its own `typescript`. Having sentinel dictate those versions (as peer dependencies, so the whole toolchain rides the sentinel version) is the intended end state, and it lands with the tool tickets that actually bundle a runner.
260
262
 
@@ -12,17 +12,18 @@ import {
12
12
  presetNotInstalledYet,
13
13
  registerAdapters,
14
14
  resolve
15
- } from "../chunk-WMBXYYLD.js";
15
+ } from "../chunk-AWDCC5VJ.js";
16
16
  import {
17
- resolveContext
18
- } from "../chunk-EVGG55ZO.js";
17
+ resolveContext,
18
+ separateToolArgs
19
+ } from "../chunk-ZASD5YPF.js";
19
20
  import {
20
21
  ensureWorkspacePrep,
21
22
  findWorkspaceRoot,
22
23
  inspectWorkspacePrep,
23
24
  readOwnVersion,
24
25
  readProjectPackageJson
25
- } from "../chunk-ZNANJEMK.js";
26
+ } from "../chunk-JT7ZMH44.js";
26
27
  import {
27
28
  DEFAULT_ENV_LEVEL,
28
29
  ENV_LEVELS,
@@ -33,10 +34,12 @@ import {
33
34
  SWEEPABLE_TARGETS,
34
35
  TARGETS,
35
36
  VERBS
36
- } from "../chunk-7E6YTTAK.js";
37
+ } from "../chunk-LX7EG6PJ.js";
38
+ import "../chunk-LU4E4TVD.js";
39
+ import "../chunk-PXTU5MPW.js";
37
40
  import "../chunk-4EIY7TTR.js";
38
41
  import "../chunk-O7REVMOC.js";
39
- import "../chunk-ZVHUG6CA.js";
42
+ import "../chunk-QXFCZON7.js";
40
43
 
41
44
  // bin/sentinel.ts
42
45
  import { program } from "commander";
@@ -546,8 +549,8 @@ sentinel (${type}): ${asMessage(error)}
546
549
  // Only when the FORMAT role actually adopted: a module still formatted by the root
547
550
  // must not be excluded from it.
548
551
  formattedModule: toRun.includes("format") ? module.root : void 0,
549
- // Same rule for the report directory: only when the STATIC ANALYSIS role adopted.
550
- analysedModule: toRun.includes("static-analysis")
552
+ // Same rule for the report directories: only for a role that writes reports and adopted.
553
+ adoptedRoles: toRun
551
554
  });
552
555
  workspace = changes;
553
556
  const prefix = ctx.dryRun ? " dry run: " : " ";
@@ -584,7 +587,7 @@ async function runValidate(ctx) {
584
587
  );
585
588
  }
586
589
  if (!ctx.targets.includes("test")) return 1;
587
- const { validateModuleTests } = await import("../validate-VWP6YZP5.js");
590
+ const { validateModuleTests } = await import("../validate-QYP7HFSY.js");
588
591
  const outcomes = modules.flatMap(
589
592
  (module) => validateModuleTests(module.name, module.root)
590
593
  );
@@ -908,9 +911,7 @@ if (!nodeCheck.ok) {
908
911
  process.exit(1);
909
912
  }
910
913
  registerAdapters();
911
- var separator = process.argv.indexOf("--");
912
- var toolArgs = separator === -1 ? [] : process.argv.slice(separator + 1);
913
- var cliArgv = separator === -1 ? process.argv : process.argv.slice(0, separator);
914
+ var { cliArgv, toolArgs } = separateToolArgs(process.argv);
914
915
  var TARGET_HELP = {
915
916
  lint: "linting",
916
917
  format: "formatting",
@@ -919,6 +920,7 @@ var TARGET_HELP = {
919
920
  dev: "dev server (long-running: never swept by an unqualified --run)",
920
921
  test: "tests",
921
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",
922
924
  env: "env files, contracts and Dockerfiles, for the whole repository (run from its root)",
923
925
  "runtime-analysis": "Lighthouse, web vitals",
924
926
  arch: "architecture boundaries"
@@ -1101,10 +1103,12 @@ function parseEnvLevel(value) {
1101
1103
  var envLevel = targets.some((target) => REPOSITORY_TARGETS.includes(target)) ? parseEnvLevel(process.env.SENTINEL_ENV_LEVEL) : DEFAULT_ENV_LEVEL;
1102
1104
  var githubActions = process.env.GITHUB_ACTIONS === "true";
1103
1105
  var targetsExplicit = !(opts.all || namedTargets.length === 0);
1104
- if (namedTargets.includes("static-analysis") && (verb === "report" || verb === "run" && opts.json)) {
1105
- program.error(
1106
- `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.`
1107
- );
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
+ }
1108
1112
  }
1109
1113
  var maxDiagnostics = Number(opts.maxDiagnostics);
1110
1114
  if (!Number.isInteger(maxDiagnostics) || maxDiagnostics < 0) {