@hublo/sentinel 1.7.0-alpha.24 → 1.7.0-alpha.25
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 +1 -2
- package/dist/bin/sentinel.js +44 -17
- package/dist/{chunk-PMRL4MH6.js → chunk-4YQXLPJ5.js} +2 -2
- package/dist/{chunk-F3Q3JQJ6.js → chunk-7JTCUK77.js} +3 -5
- package/dist/{chunk-EQQMY6NH.js → chunk-CQQENHUZ.js} +4310 -5188
- package/dist/{chunk-LX7EG6PJ.js → chunk-CSZW7OMC.js} +8 -6
- package/dist/chunk-CSZW7OMC.js.map +1 -0
- package/dist/chunk-F5WISUN3.js +17 -0
- package/dist/chunk-F5WISUN3.js.map +1 -0
- package/dist/chunk-FY3P5QPH.js +15 -0
- package/dist/chunk-FY3P5QPH.js.map +1 -0
- package/dist/chunk-NE3IEJBN.js +59 -0
- package/dist/chunk-NE3IEJBN.js.map +1 -0
- package/dist/chunk-VWASE6NN.js +34 -0
- package/dist/chunk-VWASE6NN.js.map +1 -0
- package/dist/{chunk-JT7ZMH44.js → chunk-ZNANJEMK.js} +16 -30
- package/dist/chunk-ZNANJEMK.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -6
- package/dist/roles/runtime-analysis/config.d.ts +92 -0
- package/dist/roles/runtime-analysis/config.js +10 -0
- package/dist/roles/runtime-analysis/gateway.d.ts +2 -0
- package/dist/roles/runtime-analysis/gateway.js +82 -0
- package/dist/roles/runtime-analysis/gateway.js.map +1 -0
- package/dist/roles/runtime-analysis/mock-api.d.ts +2 -0
- package/dist/roles/runtime-analysis/mock-api.js +43 -0
- package/dist/roles/runtime-analysis/mock-api.js.map +1 -0
- package/dist/roles/static-analysis/config.js +1 -2
- package/dist/roles/test/setup/jest-parity.js +2 -2
- package/dist/roles/test/setup/workspace-entry.js +2 -2
- package/dist/{validate-IES226NX.js → validate-GD63SP6M.js} +2 -2
- package/docs/runtime-analysis-adoption.md +162 -0
- package/docs/typescript-traces.md +2 -218
- package/docs/using-sentinel.md +1 -2
- package/package.json +9 -6
- package/runtime-analysis-deps/load.mjs +6 -0
- package/runtime-analysis-deps/package-lock.json +1766 -0
- package/runtime-analysis-deps/package.json +11 -0
- package/dist/chunk-JT7ZMH44.js.map +0 -1
- package/dist/chunk-LX7EG6PJ.js.map +0 -1
- package/dist/chunk-NGLEGAEN.js +0 -190
- package/dist/chunk-NGLEGAEN.js.map +0 -1
- package/dist/chunk-PXTU5MPW.js +0 -9
- package/dist/chunk-PXTU5MPW.js.map +0 -1
- package/dist/roles/sql/config.d.ts +0 -68
- package/dist/roles/sql/config.js +0 -8
- package/docs/sql-adoption.md +0 -598
- /package/dist/{chunk-PMRL4MH6.js.map → chunk-4YQXLPJ5.js.map} +0 -0
- /package/dist/roles/{sql → runtime-analysis}/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.
|
|
180
179
|
- [`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,7 +256,6 @@ 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)).
|
|
260
259
|
- **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.
|
|
261
260
|
- **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.
|
|
262
261
|
|
package/dist/bin/sentinel.js
CHANGED
|
@@ -8,23 +8,24 @@ import {
|
|
|
8
8
|
declaredPresetFor,
|
|
9
9
|
describeFramework,
|
|
10
10
|
dispatch,
|
|
11
|
-
locateRepository,
|
|
12
11
|
palette,
|
|
13
12
|
presetNotInstalledYet,
|
|
14
13
|
registerAdapters,
|
|
15
14
|
resolve
|
|
16
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-CQQENHUZ.js";
|
|
16
|
+
import "../chunk-NE3IEJBN.js";
|
|
17
|
+
import "../chunk-VWASE6NN.js";
|
|
17
18
|
import {
|
|
18
19
|
resolveContext,
|
|
19
20
|
separateToolArgs
|
|
20
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-7JTCUK77.js";
|
|
21
22
|
import {
|
|
22
23
|
ensureWorkspacePrep,
|
|
23
24
|
findWorkspaceRoot,
|
|
24
25
|
inspectWorkspacePrep,
|
|
25
26
|
readOwnVersion,
|
|
26
27
|
readProjectPackageJson
|
|
27
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-ZNANJEMK.js";
|
|
28
29
|
import {
|
|
29
30
|
DEFAULT_ENV_LEVEL,
|
|
30
31
|
ENV_LEVELS,
|
|
@@ -35,9 +36,9 @@ import {
|
|
|
35
36
|
SWEEPABLE_TARGETS,
|
|
36
37
|
TARGETS,
|
|
37
38
|
VERBS
|
|
38
|
-
} from "../chunk-
|
|
39
|
-
import "../chunk-
|
|
40
|
-
import "../chunk-
|
|
39
|
+
} from "../chunk-CSZW7OMC.js";
|
|
40
|
+
import "../chunk-FY3P5QPH.js";
|
|
41
|
+
import "../chunk-F5WISUN3.js";
|
|
41
42
|
import "../chunk-4EIY7TTR.js";
|
|
42
43
|
import "../chunk-O7REVMOC.js";
|
|
43
44
|
import "../chunk-QXFCZON7.js";
|
|
@@ -551,8 +552,8 @@ sentinel (${type}): ${asMessage(error)}
|
|
|
551
552
|
// Only when the FORMAT role actually adopted: a module still formatted by the root
|
|
552
553
|
// must not be excluded from it.
|
|
553
554
|
formattedModule: toRun.includes("format") ? module.root : void 0,
|
|
554
|
-
// Same rule for the report
|
|
555
|
-
|
|
555
|
+
// Same rule for the report directory: only when the STATIC ANALYSIS role adopted.
|
|
556
|
+
analysedModule: toRun.includes("static-analysis")
|
|
556
557
|
});
|
|
557
558
|
workspace = changes;
|
|
558
559
|
const prefix = ctx.dryRun ? " dry run: " : " ";
|
|
@@ -605,7 +606,7 @@ async function runValidate(ctx) {
|
|
|
605
606
|
);
|
|
606
607
|
}
|
|
607
608
|
if (!ctx.targets.includes("test")) return 1;
|
|
608
|
-
const { validateModuleTests } = await import("../validate-
|
|
609
|
+
const { validateModuleTests } = await import("../validate-GD63SP6M.js");
|
|
609
610
|
const outcomes = modules.flatMap(
|
|
610
611
|
(module) => validateModuleTests(module.name, module.root)
|
|
611
612
|
);
|
|
@@ -875,6 +876,35 @@ async function runVerb(ctx) {
|
|
|
875
876
|
return ctx.verb === "run" || ctx.ci ? worstCode : 0;
|
|
876
877
|
}
|
|
877
878
|
|
|
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
|
+
|
|
878
908
|
// src/shared/node-version.ts
|
|
879
909
|
var MIN_NODE = "24.15.0";
|
|
880
910
|
function parts(version) {
|
|
@@ -909,7 +939,6 @@ var TARGET_HELP = {
|
|
|
909
939
|
dev: "dev server (long-running: never swept by an unqualified --run)",
|
|
910
940
|
test: "tests",
|
|
911
941
|
"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",
|
|
913
942
|
env: "env files, contracts and Dockerfiles, for the whole repository (run from its root)",
|
|
914
943
|
"runtime-analysis": "Lighthouse, web vitals",
|
|
915
944
|
arch: "architecture boundaries"
|
|
@@ -1092,12 +1121,10 @@ function parseEnvLevel(value) {
|
|
|
1092
1121
|
var envLevel = targets.some((target) => REPOSITORY_TARGETS.includes(target)) ? parseEnvLevel(process.env.SENTINEL_ENV_LEVEL) : DEFAULT_ENV_LEVEL;
|
|
1093
1122
|
var githubActions = process.env.GITHUB_ACTIONS === "true";
|
|
1094
1123
|
var targetsExplicit = !(opts.all || namedTargets.length === 0);
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
);
|
|
1100
|
-
}
|
|
1124
|
+
if (namedTargets.includes("static-analysis") && (verb === "report" || verb === "run" && opts.json)) {
|
|
1125
|
+
program.error(
|
|
1126
|
+
`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.`
|
|
1127
|
+
);
|
|
1101
1128
|
}
|
|
1102
1129
|
var maxDiagnostics = Number(opts.maxDiagnostics);
|
|
1103
1130
|
if (!Number.isInteger(maxDiagnostics) || maxDiagnostics < 0) {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-ELZHIN6E.js";
|
|
4
4
|
import {
|
|
5
5
|
findWorkspaceRoot
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZNANJEMK.js";
|
|
7
7
|
|
|
8
8
|
// src/roles/test/setup/workspace.ts
|
|
9
9
|
function isMissingModule(error) {
|
|
@@ -60,4 +60,4 @@ export {
|
|
|
60
60
|
installWorkspaceSetup,
|
|
61
61
|
pinWorkspaceTimezone
|
|
62
62
|
};
|
|
63
|
-
//# sourceMappingURL=chunk-
|
|
63
|
+
//# sourceMappingURL=chunk-4YQXLPJ5.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
readNxProjectName,
|
|
7
7
|
readOwnPackage,
|
|
8
8
|
readProjectPackageJson
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZNANJEMK.js";
|
|
10
10
|
import {
|
|
11
11
|
matchesTsconfigPattern
|
|
12
12
|
} from "./chunk-O7REVMOC.js";
|
|
@@ -10024,12 +10024,10 @@ export {
|
|
|
10024
10024
|
oxlintPath,
|
|
10025
10025
|
oxlintSearchPath,
|
|
10026
10026
|
walk,
|
|
10027
|
-
MEMBER_TYPES,
|
|
10028
|
-
writtenFileFormatter,
|
|
10029
|
-
findModuleRoot,
|
|
10030
|
-
resolveContext,
|
|
10031
10027
|
RESOLVABLE_EXTENSIONS,
|
|
10028
|
+
writtenFileFormatter,
|
|
10032
10029
|
readTestAdoption,
|
|
10030
|
+
resolveContext,
|
|
10033
10031
|
moduleEnvironment,
|
|
10034
10032
|
suiteOf,
|
|
10035
10033
|
captureReference,
|