@hublo/sentinel 1.7.0-alpha.19 → 1.7.0-alpha.20
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 -0
- package/dist/bin/sentinel.js +16 -41
- package/dist/{chunk-2LLRSWG2.js → chunk-AVT5FSPO.js} +7 -5
- package/dist/{chunk-YVUPZJCX.js → chunk-B3Y7F7BA.js} +8125 -8107
- package/dist/{chunk-ZNANJEMK.js → chunk-JT7ZMH44.js} +30 -16
- package/dist/chunk-JT7ZMH44.js.map +1 -0
- package/dist/{chunk-5I6WUD2U.js → chunk-LX7EG6PJ.js} +2 -1
- 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/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/roles/sql/config.d.ts +68 -0
- package/dist/roles/sql/config.js +8 -0
- package/dist/roles/static-analysis/config.js +1 -1
- package/dist/roles/test/setup/jest-parity.js +2 -2
- package/dist/roles/test/setup/workspace-entry.js +2 -2
- package/dist/{validate-S5I4Z7IO.js → validate-B5567Z7X.js} +2 -2
- package/docs/sql-adoption.md +552 -0
- package/docs/typescript-traces.md +146 -14
- package/docs/using-sentinel.md +3 -3
- package/package.json +5 -6
- package/dist/chunk-5I6WUD2U.js.map +0 -1
- package/dist/chunk-TMVKYXZ3.js +0 -18
- package/dist/chunk-TMVKYXZ3.js.map +0 -1
- package/dist/chunk-ZNANJEMK.js.map +0 -1
- package/dist/roles/arch/config.d.ts +0 -25
- package/dist/roles/arch/config.js +0 -8
- package/docs/arch-adoption.md +0 -201
- /package/dist/{chunk-4YQXLPJ5.js.map → chunk-PMRL4MH6.js.map} +0 -0
- /package/dist/roles/{arch → sql}/config.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
|
|
package/dist/bin/sentinel.js
CHANGED
|
@@ -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-
|
|
16
|
+
} from "../chunk-B3Y7F7BA.js";
|
|
16
17
|
import {
|
|
17
18
|
resolveContext,
|
|
18
19
|
separateToolArgs
|
|
19
|
-
} from "../chunk-
|
|
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-
|
|
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-
|
|
38
|
-
import "../chunk-
|
|
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";
|
|
@@ -550,8 +551,8 @@ sentinel (${type}): ${asMessage(error)}
|
|
|
550
551
|
// Only when the FORMAT role actually adopted: a module still formatted by the root
|
|
551
552
|
// must not be excluded from it.
|
|
552
553
|
formattedModule: toRun.includes("format") ? module.root : void 0,
|
|
553
|
-
// Same rule for the report
|
|
554
|
-
|
|
554
|
+
// Same rule for the report directories: only for a role that writes reports and adopted.
|
|
555
|
+
adoptedRoles: toRun
|
|
555
556
|
});
|
|
556
557
|
workspace = changes;
|
|
557
558
|
const prefix = ctx.dryRun ? " dry run: " : " ";
|
|
@@ -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-
|
|
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,6 +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",
|
|
912
|
+
sql: "migrations and Unsafe raw SQL calls, in the modules that hold them",
|
|
940
913
|
env: "env files, contracts and Dockerfiles, for the whole repository (run from its root)",
|
|
941
914
|
"runtime-analysis": "Lighthouse, web vitals",
|
|
942
915
|
arch: "architecture boundaries"
|
|
@@ -1119,10 +1092,12 @@ function parseEnvLevel(value) {
|
|
|
1119
1092
|
var envLevel = targets.some((target) => REPOSITORY_TARGETS.includes(target)) ? parseEnvLevel(process.env.SENTINEL_ENV_LEVEL) : DEFAULT_ENV_LEVEL;
|
|
1120
1093
|
var githubActions = process.env.GITHUB_ACTIONS === "true";
|
|
1121
1094
|
var targetsExplicit = !(opts.all || namedTargets.length === 0);
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
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
|
+
}
|
|
1126
1101
|
}
|
|
1127
1102
|
var maxDiagnostics = Number(opts.maxDiagnostics);
|
|
1128
1103
|
if (!Number.isInteger(maxDiagnostics) || maxDiagnostics < 0) {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
readNxProjectName,
|
|
7
7
|
readOwnPackage,
|
|
8
8
|
readProjectPackageJson
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JT7ZMH44.js";
|
|
10
10
|
import {
|
|
11
11
|
matchesTsconfigPattern
|
|
12
12
|
} from "./chunk-O7REVMOC.js";
|
|
@@ -9956,20 +9956,19 @@ function fromWorkspaceRoot(moduleDir, options, paths) {
|
|
|
9956
9956
|
}
|
|
9957
9957
|
|
|
9958
9958
|
export {
|
|
9959
|
-
BaseAdapter,
|
|
9960
9959
|
moduleScripts,
|
|
9961
9960
|
selfCommand,
|
|
9962
9961
|
adoptedPackageName,
|
|
9963
9962
|
manifestOperation,
|
|
9964
9963
|
projectTargets,
|
|
9965
|
-
|
|
9966
|
-
RESOLVABLE_EXTENSIONS,
|
|
9964
|
+
BaseAdapter,
|
|
9967
9965
|
splitToolArgs,
|
|
9968
9966
|
separateToolArgs,
|
|
9969
9967
|
resolveBin,
|
|
9970
9968
|
binFromOwnInstall,
|
|
9971
9969
|
binSearchPath,
|
|
9972
9970
|
scriptPath,
|
|
9971
|
+
nxTargetOperations,
|
|
9973
9972
|
FORMAT_CONFIG_FILE,
|
|
9974
9973
|
FORMAT_SCRIPT_NAME,
|
|
9975
9974
|
PROVENANCE_KEY,
|
|
@@ -10025,9 +10024,12 @@ export {
|
|
|
10025
10024
|
oxlintPath,
|
|
10026
10025
|
oxlintSearchPath,
|
|
10027
10026
|
walk,
|
|
10027
|
+
MEMBER_TYPES,
|
|
10028
10028
|
writtenFileFormatter,
|
|
10029
|
-
|
|
10029
|
+
RESOLVABLE_EXTENSIONS,
|
|
10030
|
+
findModuleRoot,
|
|
10030
10031
|
resolveContext,
|
|
10032
|
+
readTestAdoption,
|
|
10031
10033
|
moduleEnvironment,
|
|
10032
10034
|
suiteOf,
|
|
10033
10035
|
captureReference,
|