@hublo/sentinel 1.7.0-alpha.25 → 1.7.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/bin/sentinel.js +17 -44
- package/dist/{chunk-CQQENHUZ.js → chunk-D2Z7H3AD.js} +4977 -4080
- package/dist/{chunk-7JTCUK77.js → chunk-F3Q3JQJ6.js} +5 -3
- package/dist/{chunk-ZNANJEMK.js → chunk-JT7ZMH44.js} +30 -16
- package/dist/chunk-JT7ZMH44.js.map +1 -0
- package/dist/{chunk-CSZW7OMC.js → chunk-LX7EG6PJ.js} +6 -8
- package/dist/chunk-LX7EG6PJ.js.map +1 -0
- package/dist/chunk-NGLEGAEN.js +190 -0
- package/dist/chunk-NGLEGAEN.js.map +1 -0
- package/dist/{chunk-4YQXLPJ5.js → chunk-PMRL4MH6.js} +2 -2
- package/dist/chunk-PXTU5MPW.js +9 -0
- package/dist/chunk-PXTU5MPW.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -8
- package/dist/roles/sql/config.d.ts +68 -0
- package/dist/roles/sql/config.js +8 -0
- package/dist/roles/static-analysis/config.js +2 -1
- package/dist/roles/test/setup/jest-parity.js +2 -2
- package/dist/roles/test/setup/workspace-entry.js +2 -2
- package/dist/{validate-GD63SP6M.js → validate-IES226NX.js} +2 -2
- package/docs/sql-adoption.md +598 -0
- package/docs/typescript-traces.md +218 -2
- package/docs/using-sentinel.md +2 -1
- package/package.json +6 -9
- package/dist/chunk-CSZW7OMC.js.map +0 -1
- package/dist/chunk-F5WISUN3.js +0 -17
- package/dist/chunk-F5WISUN3.js.map +0 -1
- package/dist/chunk-FY3P5QPH.js +0 -15
- package/dist/chunk-FY3P5QPH.js.map +0 -1
- package/dist/chunk-NE3IEJBN.js +0 -59
- package/dist/chunk-NE3IEJBN.js.map +0 -1
- package/dist/chunk-VWASE6NN.js +0 -34
- package/dist/chunk-VWASE6NN.js.map +0 -1
- package/dist/chunk-ZNANJEMK.js.map +0 -1
- package/dist/roles/runtime-analysis/config.d.ts +0 -92
- package/dist/roles/runtime-analysis/config.js +0 -10
- package/dist/roles/runtime-analysis/gateway.d.ts +0 -2
- package/dist/roles/runtime-analysis/gateway.js +0 -82
- package/dist/roles/runtime-analysis/gateway.js.map +0 -1
- package/dist/roles/runtime-analysis/mock-api.d.ts +0 -2
- package/dist/roles/runtime-analysis/mock-api.js +0 -43
- package/dist/roles/runtime-analysis/mock-api.js.map +0 -1
- package/docs/runtime-analysis-adoption.md +0 -162
- package/runtime-analysis-deps/load.mjs +0 -6
- package/runtime-analysis-deps/package-lock.json +0 -1766
- package/runtime-analysis-deps/package.json +0 -11
- /package/dist/{chunk-4YQXLPJ5.js.map → chunk-PMRL4MH6.js.map} +0 -0
- /package/dist/roles/{runtime-analysis → sql}/config.js.map +0 -0
package/README.md
CHANGED
|
@@ -176,8 +176,8 @@ 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
|
-
- [`docs/runtime-analysis-adoption.md`](docs/runtime-analysis-adoption.md) — measuring a React front's Core Web Vitals on a pull request: the config key by key, the run on a machine, the CI phases, the browser packages installed only where a measure runs, and how the verdict decides what blocks.
|
|
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
|
|
|
183
183
|
## Architecture: `target → runner → preset`
|
|
@@ -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
|
|
package/dist/bin/sentinel.js
CHANGED
|
@@ -8,24 +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-
|
|
16
|
-
import "../chunk-NE3IEJBN.js";
|
|
17
|
-
import "../chunk-VWASE6NN.js";
|
|
16
|
+
} from "../chunk-D2Z7H3AD.js";
|
|
18
17
|
import {
|
|
19
18
|
resolveContext,
|
|
20
19
|
separateToolArgs
|
|
21
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-F3Q3JQJ6.js";
|
|
22
21
|
import {
|
|
23
22
|
ensureWorkspacePrep,
|
|
24
23
|
findWorkspaceRoot,
|
|
25
24
|
inspectWorkspacePrep,
|
|
26
25
|
readOwnVersion,
|
|
27
26
|
readProjectPackageJson
|
|
28
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-JT7ZMH44.js";
|
|
29
28
|
import {
|
|
30
29
|
DEFAULT_ENV_LEVEL,
|
|
31
30
|
ENV_LEVELS,
|
|
@@ -36,9 +35,9 @@ import {
|
|
|
36
35
|
SWEEPABLE_TARGETS,
|
|
37
36
|
TARGETS,
|
|
38
37
|
VERBS
|
|
39
|
-
} from "../chunk-
|
|
40
|
-
import "../chunk-
|
|
41
|
-
import "../chunk-
|
|
38
|
+
} from "../chunk-LX7EG6PJ.js";
|
|
39
|
+
import "../chunk-NGLEGAEN.js";
|
|
40
|
+
import "../chunk-PXTU5MPW.js";
|
|
42
41
|
import "../chunk-4EIY7TTR.js";
|
|
43
42
|
import "../chunk-O7REVMOC.js";
|
|
44
43
|
import "../chunk-QXFCZON7.js";
|
|
@@ -552,8 +551,8 @@ sentinel (${type}): ${asMessage(error)}
|
|
|
552
551
|
// Only when the FORMAT role actually adopted: a module still formatted by the root
|
|
553
552
|
// must not be excluded from it.
|
|
554
553
|
formattedModule: toRun.includes("format") ? module.root : void 0,
|
|
555
|
-
// Same rule for the report
|
|
556
|
-
|
|
554
|
+
// Same rule for the report directories: only for a role that writes reports and adopted.
|
|
555
|
+
adoptedRoles: toRun
|
|
557
556
|
});
|
|
558
557
|
workspace = changes;
|
|
559
558
|
const prefix = ctx.dryRun ? " dry run: " : " ";
|
|
@@ -606,7 +605,7 @@ async function runValidate(ctx) {
|
|
|
606
605
|
);
|
|
607
606
|
}
|
|
608
607
|
if (!ctx.targets.includes("test")) return 1;
|
|
609
|
-
const { validateModuleTests } = await import("../validate-
|
|
608
|
+
const { validateModuleTests } = await import("../validate-IES226NX.js");
|
|
610
609
|
const outcomes = modules.flatMap(
|
|
611
610
|
(module) => validateModuleTests(module.name, module.root)
|
|
612
611
|
);
|
|
@@ -876,35 +875,6 @@ async function runVerb(ctx) {
|
|
|
876
875
|
return ctx.verb === "run" || ctx.ci ? worstCode : 0;
|
|
877
876
|
}
|
|
878
877
|
|
|
879
|
-
// src/core/repository-root.ts
|
|
880
|
-
import { execFileSync } from "node:child_process";
|
|
881
|
-
import { realpathSync as realpathSync2 } from "node:fs";
|
|
882
|
-
function findRepositoryRoot(cwd2) {
|
|
883
|
-
try {
|
|
884
|
-
const root = execFileSync("git", ["rev-parse", "--show-toplevel"], {
|
|
885
|
-
cwd: cwd2,
|
|
886
|
-
encoding: "utf8",
|
|
887
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
888
|
-
}).trim();
|
|
889
|
-
return root === "" ? void 0 : realpathSync2(root);
|
|
890
|
-
} catch {
|
|
891
|
-
return void 0;
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
function isRepositoryRoot(cwd2, root) {
|
|
895
|
-
try {
|
|
896
|
-
return realpathSync2(cwd2) === root;
|
|
897
|
-
} catch {
|
|
898
|
-
return false;
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
function locateRepository(cwd2) {
|
|
902
|
-
const root = findRepositoryRoot(cwd2);
|
|
903
|
-
if (root === void 0) return { ok: false, reason: "not-a-repository" };
|
|
904
|
-
if (!isRepositoryRoot(cwd2, root)) return { ok: false, reason: "not-the-root", root };
|
|
905
|
-
return { ok: true, root };
|
|
906
|
-
}
|
|
907
|
-
|
|
908
878
|
// src/shared/node-version.ts
|
|
909
879
|
var MIN_NODE = "24.15.0";
|
|
910
880
|
function parts(version) {
|
|
@@ -939,6 +909,7 @@ var TARGET_HELP = {
|
|
|
939
909
|
dev: "dev server (long-running: never swept by an unqualified --run)",
|
|
940
910
|
test: "tests",
|
|
941
911
|
"static-analysis": "duplication, dead code, complexity, import graph, file size, bundle weight",
|
|
912
|
+
sql: "migrations and Unsafe raw SQL calls, in the modules that hold them",
|
|
942
913
|
env: "env files, contracts and Dockerfiles, for the whole repository (run from its root)",
|
|
943
914
|
"runtime-analysis": "Lighthouse, web vitals",
|
|
944
915
|
arch: "architecture boundaries"
|
|
@@ -1121,10 +1092,12 @@ function parseEnvLevel(value) {
|
|
|
1121
1092
|
var envLevel = targets.some((target) => REPOSITORY_TARGETS.includes(target)) ? parseEnvLevel(process.env.SENTINEL_ENV_LEVEL) : DEFAULT_ENV_LEVEL;
|
|
1122
1093
|
var githubActions = process.env.GITHUB_ACTIONS === "true";
|
|
1123
1094
|
var targetsExplicit = !(opts.all || namedTargets.length === 0);
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1095
|
+
for (const reporting of ["static-analysis", "sql"]) {
|
|
1096
|
+
if (namedTargets.includes(reporting) && (verb === "report" || verb === "run" && opts.json)) {
|
|
1097
|
+
program.error(
|
|
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.`
|
|
1099
|
+
);
|
|
1100
|
+
}
|
|
1128
1101
|
}
|
|
1129
1102
|
var maxDiagnostics = Number(opts.maxDiagnostics);
|
|
1130
1103
|
if (!Number.isInteger(maxDiagnostics) || maxDiagnostics < 0) {
|