@hublo/sentinel 1.7.0-alpha.10 → 1.7.0-alpha.12
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 +0 -2
- package/dist/bin/sentinel.js +34 -20
- package/dist/{chunk-AWDCC5VJ.js → chunk-2ANSMW2Y.js} +7400 -7545
- package/dist/{chunk-ZASD5YPF.js → chunk-2LLRSWG2.js} +4 -5
- package/dist/{chunk-PMRL4MH6.js → chunk-4YQXLPJ5.js} +2 -2
- package/dist/{chunk-LX7EG6PJ.js → chunk-5I6WUD2U.js} +1 -2
- package/dist/chunk-5I6WUD2U.js.map +1 -0
- package/dist/chunk-TMVKYXZ3.js +18 -0
- package/dist/chunk-TMVKYXZ3.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 +5 -5
- package/dist/roles/arch/config.d.ts +25 -0
- package/dist/roles/arch/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-QYP7HFSY.js → validate-S5I4Z7IO.js} +2 -2
- package/docs/arch-adoption.md +166 -0
- package/docs/static-analysis-adoption.md +1 -1
- package/docs/typescript-traces.md +14 -146
- package/docs/using-sentinel.md +3 -3
- package/package.json +4 -5
- package/dist/chunk-JT7ZMH44.js.map +0 -1
- package/dist/chunk-LU4E4TVD.js +0 -183
- package/dist/chunk-LU4E4TVD.js.map +0 -1
- package/dist/chunk-LX7EG6PJ.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 -411
- /package/dist/{chunk-PMRL4MH6.js.map → chunk-4YQXLPJ5.js.map} +0 -0
- /package/dist/roles/{sql → arch}/config.js.map +0 -0
package/README.md
CHANGED
|
@@ -176,7 +176,6 @@ 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`.
|
|
181
180
|
- [`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
181
|
|
|
@@ -256,7 +255,6 @@ The rules live in `sentinel`. Each module keeps a **thin, generated stub** per t
|
|
|
256
255
|
- **Rules in sentinel** — one source of truth, versioned.
|
|
257
256
|
- **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
257
|
- **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
258
|
- **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
259
|
- **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
260
|
|
package/dist/bin/sentinel.js
CHANGED
|
@@ -12,18 +12,18 @@ import {
|
|
|
12
12
|
presetNotInstalledYet,
|
|
13
13
|
registerAdapters,
|
|
14
14
|
resolve
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-2ANSMW2Y.js";
|
|
16
16
|
import {
|
|
17
17
|
resolveContext,
|
|
18
18
|
separateToolArgs
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-2LLRSWG2.js";
|
|
20
20
|
import {
|
|
21
21
|
ensureWorkspacePrep,
|
|
22
22
|
findWorkspaceRoot,
|
|
23
23
|
inspectWorkspacePrep,
|
|
24
24
|
readOwnVersion,
|
|
25
25
|
readProjectPackageJson
|
|
26
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-ZNANJEMK.js";
|
|
27
27
|
import {
|
|
28
28
|
DEFAULT_ENV_LEVEL,
|
|
29
29
|
ENV_LEVELS,
|
|
@@ -34,8 +34,8 @@ import {
|
|
|
34
34
|
SWEEPABLE_TARGETS,
|
|
35
35
|
TARGETS,
|
|
36
36
|
VERBS
|
|
37
|
-
} from "../chunk-
|
|
38
|
-
import "../chunk-
|
|
37
|
+
} from "../chunk-5I6WUD2U.js";
|
|
38
|
+
import "../chunk-TMVKYXZ3.js";
|
|
39
39
|
import "../chunk-PXTU5MPW.js";
|
|
40
40
|
import "../chunk-4EIY7TTR.js";
|
|
41
41
|
import "../chunk-O7REVMOC.js";
|
|
@@ -484,6 +484,7 @@ async function runInit(ctx) {
|
|
|
484
484
|
outcomes.push(outcome);
|
|
485
485
|
};
|
|
486
486
|
const planned = [];
|
|
487
|
+
const dependenciesBefore = declaredDependencies(module.root);
|
|
487
488
|
let worst = 0;
|
|
488
489
|
for (const type of toRun) {
|
|
489
490
|
try {
|
|
@@ -549,18 +550,21 @@ sentinel (${type}): ${asMessage(error)}
|
|
|
549
550
|
// Only when the FORMAT role actually adopted: a module still formatted by the root
|
|
550
551
|
// must not be excluded from it.
|
|
551
552
|
formattedModule: toRun.includes("format") ? module.root : void 0,
|
|
552
|
-
// Same rule for the report
|
|
553
|
-
|
|
553
|
+
// Same rule for the report directory: only when the STATIC ANALYSIS role adopted.
|
|
554
|
+
analysedModule: toRun.includes("static-analysis")
|
|
554
555
|
});
|
|
555
556
|
workspace = changes;
|
|
556
557
|
const prefix = ctx.dryRun ? " dry run: " : " ";
|
|
557
558
|
for (const change of changes) process.stderr.write(`${prefix}${change}
|
|
558
559
|
`);
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
560
|
+
}
|
|
561
|
+
const hint = installHint(
|
|
562
|
+
workspace.length > 0,
|
|
563
|
+
declaredDependencies(module.root) !== dependenciesBefore
|
|
564
|
+
);
|
|
565
|
+
if (hint !== void 0 && !ctx.dryRun) {
|
|
566
|
+
process.stderr.write(palette(process.stderr).dim(` ${hint}
|
|
567
|
+
`));
|
|
564
568
|
}
|
|
565
569
|
}
|
|
566
570
|
if (ctx.json) {
|
|
@@ -574,6 +578,19 @@ sentinel (${type}): ${asMessage(error)}
|
|
|
574
578
|
}
|
|
575
579
|
return worst;
|
|
576
580
|
}
|
|
581
|
+
function declaredDependencies(root) {
|
|
582
|
+
const { dependencies = {}, devDependencies = {} } = readProjectPackageJson(root);
|
|
583
|
+
const sorted = (map) => Object.entries(map).sort(([a], [b]) => a.localeCompare(b));
|
|
584
|
+
return JSON.stringify([sorted(dependencies), sorted(devDependencies)]);
|
|
585
|
+
}
|
|
586
|
+
function installHint(workspaceChanged, dependenciesChanged) {
|
|
587
|
+
if (!workspaceChanged && !dependenciesChanged) return void 0;
|
|
588
|
+
const what = [
|
|
589
|
+
workspaceChanged ? "the workspace changes" : void 0,
|
|
590
|
+
dependenciesChanged ? "this module's new dependencies" : void 0
|
|
591
|
+
].filter((part) => part !== void 0);
|
|
592
|
+
return `run \`pnpm install\` to apply ${what.join(" and ")}, and commit pnpm-lock.yaml if it changed`;
|
|
593
|
+
}
|
|
577
594
|
|
|
578
595
|
// src/cli/run-validate.ts
|
|
579
596
|
async function runValidate(ctx) {
|
|
@@ -587,7 +604,7 @@ async function runValidate(ctx) {
|
|
|
587
604
|
);
|
|
588
605
|
}
|
|
589
606
|
if (!ctx.targets.includes("test")) return 1;
|
|
590
|
-
const { validateModuleTests } = await import("../validate-
|
|
607
|
+
const { validateModuleTests } = await import("../validate-S5I4Z7IO.js");
|
|
591
608
|
const outcomes = modules.flatMap(
|
|
592
609
|
(module) => validateModuleTests(module.name, module.root)
|
|
593
610
|
);
|
|
@@ -920,7 +937,6 @@ var TARGET_HELP = {
|
|
|
920
937
|
dev: "dev server (long-running: never swept by an unqualified --run)",
|
|
921
938
|
test: "tests",
|
|
922
939
|
"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",
|
|
924
940
|
env: "env files, contracts and Dockerfiles, for the whole repository (run from its root)",
|
|
925
941
|
"runtime-analysis": "Lighthouse, web vitals",
|
|
926
942
|
arch: "architecture boundaries"
|
|
@@ -1103,12 +1119,10 @@ function parseEnvLevel(value) {
|
|
|
1103
1119
|
var envLevel = targets.some((target) => REPOSITORY_TARGETS.includes(target)) ? parseEnvLevel(process.env.SENTINEL_ENV_LEVEL) : DEFAULT_ENV_LEVEL;
|
|
1104
1120
|
var githubActions = process.env.GITHUB_ACTIONS === "true";
|
|
1105
1121
|
var targetsExplicit = !(opts.all || namedTargets.length === 0);
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
);
|
|
1111
|
-
}
|
|
1122
|
+
if (namedTargets.includes("static-analysis") && (verb === "report" || verb === "run" && opts.json)) {
|
|
1123
|
+
program.error(
|
|
1124
|
+
`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.`
|
|
1125
|
+
);
|
|
1112
1126
|
}
|
|
1113
1127
|
var maxDiagnostics = Number(opts.maxDiagnostics);
|
|
1114
1128
|
if (!Number.isInteger(maxDiagnostics) || maxDiagnostics < 0) {
|