@hublo/sentinel 1.7.0-alpha.14 → 1.7.0-alpha.15

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 (32) hide show
  1. package/README.md +2 -1
  2. package/dist/bin/sentinel.js +9 -37
  3. package/dist/{chunk-TA4OTQMH.js → chunk-A6O73W5P.js} +6844 -5337
  4. package/dist/{chunk-FEDI4HHE.js → chunk-AVT5FSPO.js} +5 -3
  5. package/dist/{chunk-XTBHIKFG.js → chunk-JT7ZMH44.js} +5 -5
  6. package/dist/chunk-JT7ZMH44.js.map +1 -0
  7. package/dist/{chunk-BBNABWZ6.js → chunk-LX7EG6PJ.js} +2 -2
  8. package/dist/chunk-LX7EG6PJ.js.map +1 -0
  9. package/dist/chunk-NGLEGAEN.js +190 -0
  10. package/dist/chunk-NGLEGAEN.js.map +1 -0
  11. package/dist/{chunk-J2RMARWP.js → chunk-PMRL4MH6.js} +2 -2
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +5 -5
  14. package/dist/roles/sql/config.d.ts +68 -0
  15. package/dist/roles/sql/config.js +8 -0
  16. package/dist/roles/static-analysis/config.js +1 -1
  17. package/dist/roles/test/setup/jest-parity.js +2 -2
  18. package/dist/roles/test/setup/workspace-entry.js +2 -2
  19. package/dist/{validate-4VTJ7GMI.js → validate-B5567Z7X.js} +2 -2
  20. package/docs/sql-adoption.md +513 -0
  21. package/docs/typescript-traces.md +142 -138
  22. package/docs/using-sentinel.md +2 -1
  23. package/package.json +5 -4
  24. package/dist/chunk-5NBNAIFJ.js +0 -73
  25. package/dist/chunk-5NBNAIFJ.js.map +0 -1
  26. package/dist/chunk-BBNABWZ6.js.map +0 -1
  27. package/dist/chunk-XTBHIKFG.js.map +0 -1
  28. package/dist/roles/code-churn/config.d.ts +0 -59
  29. package/dist/roles/code-churn/config.js +0 -8
  30. package/docs/code-churn-adoption.md +0 -150
  31. /package/dist/{chunk-J2RMARWP.js.map → chunk-PMRL4MH6.js.map} +0 -0
  32. /package/dist/roles/{code-churn → sql}/config.js.map +0 -0
package/README.md CHANGED
@@ -176,7 +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/code-churn-adoption.md`](docs/code-churn-adoption.md) — the code churn role: the share of a module's new lines rewritten or deleted within 21 days, read from main's git history; adopting it, what it reads, how to read the figure, what it does not say, and how it was validated against `git blame`.
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.
180
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`.
181
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`.
182
182
 
@@ -256,6 +256,7 @@ The rules live in `sentinel`. Each module keeps a **thin, generated stub** per t
256
256
  - **Rules in sentinel** — one source of truth, versioned.
257
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.
258
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)).
259
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.
260
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.
261
262
 
@@ -8,22 +8,23 @@ import {
8
8
  declaredPresetFor,
9
9
  describeFramework,
10
10
  dispatch,
11
+ locateRepository,
11
12
  palette,
12
13
  presetNotInstalledYet,
13
14
  registerAdapters,
14
15
  resolve
15
- } from "../chunk-TA4OTQMH.js";
16
+ } from "../chunk-A6O73W5P.js";
16
17
  import {
17
18
  resolveContext,
18
19
  separateToolArgs
19
- } from "../chunk-FEDI4HHE.js";
20
+ } from "../chunk-AVT5FSPO.js";
20
21
  import {
21
22
  ensureWorkspacePrep,
22
23
  findWorkspaceRoot,
23
24
  inspectWorkspacePrep,
24
25
  readOwnVersion,
25
26
  readProjectPackageJson
26
- } from "../chunk-XTBHIKFG.js";
27
+ } from "../chunk-JT7ZMH44.js";
27
28
  import {
28
29
  DEFAULT_ENV_LEVEL,
29
30
  ENV_LEVELS,
@@ -34,8 +35,8 @@ import {
34
35
  SWEEPABLE_TARGETS,
35
36
  TARGETS,
36
37
  VERBS
37
- } from "../chunk-BBNABWZ6.js";
38
- import "../chunk-5NBNAIFJ.js";
38
+ } from "../chunk-LX7EG6PJ.js";
39
+ import "../chunk-NGLEGAEN.js";
39
40
  import "../chunk-PXTU5MPW.js";
40
41
  import "../chunk-4EIY7TTR.js";
41
42
  import "../chunk-O7REVMOC.js";
@@ -604,7 +605,7 @@ async function runValidate(ctx) {
604
605
  );
605
606
  }
606
607
  if (!ctx.targets.includes("test")) return 1;
607
- const { validateModuleTests } = await import("../validate-4VTJ7GMI.js");
608
+ const { validateModuleTests } = await import("../validate-B5567Z7X.js");
608
609
  const outcomes = modules.flatMap(
609
610
  (module) => validateModuleTests(module.name, module.root)
610
611
  );
@@ -874,35 +875,6 @@ async function runVerb(ctx) {
874
875
  return ctx.verb === "run" || ctx.ci ? worstCode : 0;
875
876
  }
876
877
 
877
- // src/core/repository-root.ts
878
- import { execFileSync } from "node:child_process";
879
- import { realpathSync as realpathSync2 } from "node:fs";
880
- function findRepositoryRoot(cwd2) {
881
- try {
882
- const root = execFileSync("git", ["rev-parse", "--show-toplevel"], {
883
- cwd: cwd2,
884
- encoding: "utf8",
885
- stdio: ["ignore", "pipe", "ignore"]
886
- }).trim();
887
- return root === "" ? void 0 : realpathSync2(root);
888
- } catch {
889
- return void 0;
890
- }
891
- }
892
- function isRepositoryRoot(cwd2, root) {
893
- try {
894
- return realpathSync2(cwd2) === root;
895
- } catch {
896
- return false;
897
- }
898
- }
899
- function locateRepository(cwd2) {
900
- const root = findRepositoryRoot(cwd2);
901
- if (root === void 0) return { ok: false, reason: "not-a-repository" };
902
- if (!isRepositoryRoot(cwd2, root)) return { ok: false, reason: "not-the-root", root };
903
- return { ok: true, root };
904
- }
905
-
906
878
  // src/shared/node-version.ts
907
879
  var MIN_NODE = "24.15.0";
908
880
  function parts(version) {
@@ -937,7 +909,7 @@ var TARGET_HELP = {
937
909
  dev: "dev server (long-running: never swept by an unqualified --run)",
938
910
  test: "tests",
939
911
  "static-analysis": "duplication, dead code, complexity, import graph, file size, bundle weight",
940
- "code-churn": "the share of new lines rewritten or deleted within weeks, read from git history",
912
+ sql: "migrations and Unsafe raw SQL calls, in the modules that hold them",
941
913
  env: "env files, contracts and Dockerfiles, for the whole repository (run from its root)",
942
914
  "runtime-analysis": "Lighthouse, web vitals",
943
915
  arch: "architecture boundaries"
@@ -1120,7 +1092,7 @@ function parseEnvLevel(value) {
1120
1092
  var envLevel = targets.some((target) => REPOSITORY_TARGETS.includes(target)) ? parseEnvLevel(process.env.SENTINEL_ENV_LEVEL) : DEFAULT_ENV_LEVEL;
1121
1093
  var githubActions = process.env.GITHUB_ACTIONS === "true";
1122
1094
  var targetsExplicit = !(opts.all || namedTargets.length === 0);
1123
- for (const reporting of ["static-analysis", "code-churn"]) {
1095
+ for (const reporting of ["static-analysis", "sql"]) {
1124
1096
  if (namedTargets.includes(reporting) && (verb === "report" || verb === "run" && opts.json)) {
1125
1097
  program.error(
1126
1098
  `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.`