@hublo/sentinel 1.7.0-alpha.5 → 1.7.0-alpha.7
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/dist/bin/sentinel.js +13 -80
- package/dist/{chunk-P6KTBQ2Q.js → chunk-2LLRSWG2.js} +481 -188
- package/dist/{chunk-THTXP2QU.js → chunk-7E6YTTAK.js} +1 -1
- package/dist/chunk-7E6YTTAK.js.map +1 -0
- package/dist/{chunk-DLGBRLUU.js → chunk-EESVRILJ.js} +3 -16
- package/dist/chunk-EESVRILJ.js.map +1 -0
- package/dist/{chunk-YRBFCQQI.js → chunk-NSILXJWF.js} +7002 -5697
- package/dist/{chunk-LNFGVGLE.js → chunk-SWWQ7X7B.js} +11 -23
- package/dist/{chunk-LNFGVGLE.js.map → chunk-SWWQ7X7B.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -6
- package/dist/roles/build/nest/toolchain.d.ts +1 -1
- package/dist/roles/build/nest/toolchain.js +2 -6
- package/dist/roles/build/nest/toolchain.js.map +1 -1
- package/dist/roles/static-analysis/config.js +1 -1
- package/dist/roles/test/nest/toolchain.d.ts +1 -1
- package/dist/roles/test/nest/toolchain.js +2 -3
- package/dist/roles/test/nest/toolchain.js.map +1 -1
- package/dist/roles/test/react/toolchain.js +2 -3
- package/dist/roles/test/react/toolchain.js.map +1 -1
- package/dist/roles/test/shared-test-config.d.ts +1 -1
- package/dist/roles/test/shared-test-config.js +2 -3
- package/dist/tsconfig/nest.json +1 -10
- package/dist/tsconfig/node.json +1 -11
- package/dist/tsconfig/react.json +0 -3
- package/dist/{tsconfig-aliases-C_PxuZni.d.ts → tsconfig-aliases-Ce6axdJ4.d.ts} +2 -17
- package/dist/{validate-4V3EGTXN.js → validate-S5I4Z7IO.js} +1 -3
- package/docs/arch-adoption.md +146 -0
- package/docs/build-adoption.md +0 -7
- package/docs/test-adoption.md +1 -8
- package/docs/typescript-adoption.md +13 -92
- package/docs/typescript-traces.md +89 -7
- package/docs/using-sentinel.md +3 -2
- package/package.json +1 -4
- package/dist/chunk-DLGBRLUU.js.map +0 -1
- package/dist/chunk-H4HAFJFZ.js +0 -79
- package/dist/chunk-H4HAFJFZ.js.map +0 -1
- package/dist/chunk-THTXP2QU.js.map +0 -1
- package/dist/chunk-ZFG6P27V.js +0 -313
- package/dist/chunk-ZZMYV576.js +0 -297
- package/dist/migrate-5N7IPVF5.js +0 -550
- package/dist/tsconfig/legacy.json +0 -21
|
@@ -25,27 +25,12 @@ interface Alias {
|
|
|
25
25
|
find: RegExp;
|
|
26
26
|
replacement: string;
|
|
27
27
|
}
|
|
28
|
-
/** Read the module's own chain rather than one workspace file. */
|
|
29
|
-
interface ModuleAliasSource {
|
|
30
|
-
/** The module's directory, where its tsconfig lives. */
|
|
31
|
-
moduleRoot: string;
|
|
32
|
-
/** Its tsconfig names to try, most specific first, relative to `moduleRoot`. */
|
|
33
|
-
candidates?: readonly (string | undefined)[];
|
|
34
|
-
}
|
|
35
28
|
/**
|
|
36
|
-
*
|
|
29
|
+
* Read the mappings from the workspace's base tsconfig.
|
|
37
30
|
*
|
|
38
31
|
* Longest pattern first, because Vite takes the first alias that matches and the mappings
|
|
39
32
|
* overlap by design: `@front/theme/node` must not be swallowed by `@front/theme`.
|
|
40
|
-
*
|
|
41
|
-
* Two ways to call it, and the first is kept for what it always did:
|
|
42
|
-
* - `tsconfigAliases(workspaceRoot)` or with a file name: that one workspace file, read on its
|
|
43
|
-
* own, its targets relative to `workspaceRoot`. Unchanged, because it is exported from the
|
|
44
|
-
* `build/nest` and `test/nest` toolchains and a module's config may call it.
|
|
45
|
-
* - `tsconfigAliases(workspaceRoot, { moduleRoot })`: the module's own chain, the way tsc reads
|
|
46
|
-
* it, falling back to the workspace base when the chain declares no `paths`. See
|
|
47
|
-
* `shared/tsconfig-paths.ts` for the rules and why the fallback is a transition.
|
|
48
33
|
*/
|
|
49
|
-
declare
|
|
34
|
+
declare const tsconfigAliases: (workspaceRoot: string, file?: string) => Alias[];
|
|
50
35
|
|
|
51
36
|
export { type Alias as A, type DecoratorMetadataOptions as D, decoratorMetadata as d, tsconfigAliases as t };
|
|
@@ -7,11 +7,9 @@ import {
|
|
|
7
7
|
readTestAdoption,
|
|
8
8
|
resolveVitest,
|
|
9
9
|
suiteOf
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-ZFG6P27V.js";
|
|
10
|
+
} from "./chunk-2LLRSWG2.js";
|
|
12
11
|
import "./chunk-ZNANJEMK.js";
|
|
13
12
|
import "./chunk-O7REVMOC.js";
|
|
14
|
-
import "./chunk-H4HAFJFZ.js";
|
|
15
13
|
import "./chunk-QXFCZON7.js";
|
|
16
14
|
|
|
17
15
|
// src/roles/test/validate.ts
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Architecture check adoption cheat sheet
|
|
2
|
+
|
|
3
|
+
`sentinel --arch` checks a module against an architecture decision of its repository: which
|
|
4
|
+
folder may import which, which names a view may not import, which calls a view may not make. A
|
|
5
|
+
new violation of a rule at `error` fails the run; what the module already had when it adopted is
|
|
6
|
+
recorded and never fails it.
|
|
7
|
+
|
|
8
|
+
## Adopt a module in one step
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
cd apps/front/host-admin
|
|
12
|
+
sentinel --init --arch
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Nothing to choose. The repository's `sentinel.arch.json` says which decision governs this module,
|
|
16
|
+
and `--init` writes:
|
|
17
|
+
|
|
18
|
+
| File | What it holds |
|
|
19
|
+
| -------------------- | ------------------------------------------------------------------------------------- |
|
|
20
|
+
| `arch.config.json` | the rule set this module follows, and any rule the module turned to `warn` or `off` |
|
|
21
|
+
| `arch.baseline.json` | the violations the module already has, one per line |
|
|
22
|
+
| `package.json` | the `arch` script and its nx target (cached, invalidated by the rule set and the map) |
|
|
23
|
+
|
|
24
|
+
If the map applies no decision to the module, `--init` says so and writes nothing.
|
|
25
|
+
|
|
26
|
+
## Everyday use
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
sentinel --run --arch # fails on a new violation of a rule at error
|
|
30
|
+
sentinel --run --arch --fix # also drops baseline entries that were fixed
|
|
31
|
+
sentinel --run --arch --output json,markdown # also writes arch-report/arch.json and arch.md
|
|
32
|
+
sentinel --inspect --arch # the rule set, and each rule's level here
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
A run prints the files per role (a role with no file usually means a path with a typo in the
|
|
36
|
+
rule set), then one line per rule, then each NEW violation with its file, what it reaches and the
|
|
37
|
+
section of the decision that forbids it:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
architecture ADR 0050: the vertical feature slice is the unit of frontend architecture 5543 files
|
|
41
|
+
✗ G1 A view or route never calls a query client: fetching goes through a hook. 1 new, 4 known
|
|
42
|
+
src/modules/contracts-settings/.../ContractTypesPage.tsx → @tanstack/react-query#useQuery
|
|
43
|
+
why: RFC #19934, Governance readiness, G1
|
|
44
|
+
✓ G2a The api layer never imports a view, not even a type. 0 new, 3 known
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## The baseline
|
|
48
|
+
|
|
49
|
+
Each violation is recorded by what it is: the rule, the file that breaks it, what it reaches. Not
|
|
50
|
+
a count, because a count lets one violation be fixed and another be added in the same change
|
|
51
|
+
without anything moving.
|
|
52
|
+
|
|
53
|
+
- A run never adds to it. Accepting a new violation is an edit of `arch.baseline.json`, in review.
|
|
54
|
+
- `--run --fix` removes what was fixed, so the same violation cannot come back unseen.
|
|
55
|
+
- A re-run of `--init` shrinks it and never grows it, with one exception: a rule the decision
|
|
56
|
+
ADDED since the baseline was taken. The baseline records the rules it measured, so a new rule's
|
|
57
|
+
violations show as `pending` (never failing) until `--init` adopts that rule with what it finds.
|
|
58
|
+
- A file that cannot be parsed fails the run, and its entries are kept: an unread file proves
|
|
59
|
+
nothing was fixed.
|
|
60
|
+
|
|
61
|
+
## Turning a rule down in one module
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"rules": "../../../docs/adr/0050-frontend-vertical-feature-slices.rules.json",
|
|
66
|
+
"severity": { "G3": "warn" }
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`warn` reports without failing, `off` skips the rule. A name that is not a rule of the set is
|
|
71
|
+
refused, so a typo cannot leave a rule at `error` while you believe it is a warning.
|
|
72
|
+
|
|
73
|
+
## For the repository: the rules and the map
|
|
74
|
+
|
|
75
|
+
The rules belong to the repository that took the decision, next to its ADR, so a decision and
|
|
76
|
+
its check change in the same pull request and this package needs no release.
|
|
77
|
+
|
|
78
|
+
A rule set (`docs/adr/0050-....rules.json`), in dependency-cruiser's vocabulary plus `roles`:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"name": "ADR 0050: ...",
|
|
83
|
+
"exclude": ["^(?!src/)", "\\.(test|spec|stories)\\.[cm]?[jt]sx?$"],
|
|
84
|
+
"roles": [
|
|
85
|
+
{ "name": "route", "path": "^src/routes/" },
|
|
86
|
+
{ "name": "api", "path": ["(^|/)(services|queries|mutations)/"] },
|
|
87
|
+
{ "name": "view", "path": "\\.(tsx|svelte)$", "exports": "component" }
|
|
88
|
+
],
|
|
89
|
+
"forbidden": [
|
|
90
|
+
{
|
|
91
|
+
"name": "G2a",
|
|
92
|
+
"severity": "error",
|
|
93
|
+
"comment": "The api layer never imports a view.",
|
|
94
|
+
"from": { "role": "api" },
|
|
95
|
+
"to": { "role": "view" }
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Roles are decided first match wins, by path (regular expressions relative to the module) and,
|
|
102
|
+
for `exports: "component"`, by the file's default or same-named export. A file no role matches is
|
|
103
|
+
`unclassified`: counted, never flagged. A role must have a `path` or `exports`.
|
|
104
|
+
|
|
105
|
+
An import is followed to the file that DEFINES each imported name, through barrels
|
|
106
|
+
(`export { x } from`, `export * from`), and that file's role is what a rule reads. Aliases come from
|
|
107
|
+
the workspace's `tsconfig.base.json`, the module's own `tsconfig.json`, and SvelteKit's `$lib` and
|
|
108
|
+
`kit.alias`. An alias that resolves to nothing is reported, not taken for a package.
|
|
109
|
+
|
|
110
|
+
Which kind of rule a `to` makes:
|
|
111
|
+
|
|
112
|
+
| `to` | Forbids |
|
|
113
|
+
| ---------------------------------------------------------------- | ----------------------------------------------------------------------- |
|
|
114
|
+
| `role` / `path` (`pathNot`, `dependencyTypesNot: ["type-only"]`) | importing a file of that side, inside the module or in a shared library |
|
|
115
|
+
| `module` + `names` | importing those names from that package, as a value |
|
|
116
|
+
| `calls` (+ `module`, a regular expression) | calling those globals, or importing a matching client as a value |
|
|
117
|
+
|
|
118
|
+
The map (`sentinel.arch.json`, at the workspace root), first match wins:
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"decisions": [
|
|
123
|
+
{
|
|
124
|
+
"modules": ["apps/front/hr-management"],
|
|
125
|
+
"rules": "docs/adr/0050-....rules.json",
|
|
126
|
+
"severity": { "G3": "warn" }
|
|
127
|
+
},
|
|
128
|
+
{ "modules": ["apps/front/*", "libs/front/*"], "rules": "docs/adr/0050-....rules.json" }
|
|
129
|
+
],
|
|
130
|
+
"notices": [{ "modules": ["apps/nest/backends-for-frontends/planning"], "text": "..." }]
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
A decision's `severity` is written at a module's first adoption only; after that the level is the
|
|
135
|
+
team's. Notices are said at adoption and change nothing.
|
|
136
|
+
|
|
137
|
+
A rule set, a map or a module config with a defect is refused before anything runs.
|
|
138
|
+
|
|
139
|
+
## What the role will not do
|
|
140
|
+
|
|
141
|
+
- Analyse a module whose files did not change: in CI, the modules analysed are those whose own
|
|
142
|
+
files a pull request touches. A shared library that changes can create a violation in a module
|
|
143
|
+
downstream that is not analysed then.
|
|
144
|
+
- Read markup: a `.svelte` file is checked through its `<script>` blocks.
|
|
145
|
+
- Decide a design question no file and import can answer (is this the right boundary for a
|
|
146
|
+
feature). Those stay with the reviewers, as the decisions themselves say.
|
package/docs/build-adoption.md
CHANGED
|
@@ -466,13 +466,6 @@ export default nestService({
|
|
|
466
466
|
Or drop to the pieces, which the same entry point exports individually: `decoratorMetadata`,
|
|
467
467
|
`nodeManifest`, `tsconfigAliases`, plus Vite's `defineConfig`, `loadEnv` and `mergeConfig`.
|
|
468
468
|
|
|
469
|
-
**Which aliases a service is bundled with.** `nestService` reads the module's own tsconfig chain
|
|
470
|
-
(`tsconfig`, then `tsconfig.app.json`, then `tsconfig.json`), the way tsc reads it, so a service
|
|
471
|
-
that declares its own `paths` is bundled with the aliases it type-checks with. When the chain
|
|
472
|
-
declares no `paths`, it falls back to `tsconfig.base.json`, which is what it always read: a service
|
|
473
|
-
that still extends the base sees no change. The fallback is a transition, not the end state.
|
|
474
|
-
`tsconfigAliases(workspaceRoot)` called on its own still reads that one workspace file. One difference with tsc 7 is deliberate: a `baseUrl` in the chain is honoured, as ts-jest, Vite and TypeScript 5 and 6 read it, so a chain whose `baseUrl` is not the directory of the file declaring `paths` resolves differently at runtime than in the typecheck. None exists in the monorepo today.
|
|
475
|
-
|
|
476
469
|
# Both families
|
|
477
470
|
|
|
478
471
|
## Svelte modules, and what they need first
|
package/docs/test-adoption.md
CHANGED
|
@@ -138,17 +138,10 @@ The wall is decorator metadata: Nest resolves a constructor's parameters from
|
|
|
138
138
|
```ts
|
|
139
139
|
plugins: [decoratorMetadata({ root: here })],
|
|
140
140
|
resolve: { alias: [{ find: /^jest-mock-extended$/, replacement: 'vitest-mock-extended' },
|
|
141
|
-
...tsconfigAliases(workspaceRoot
|
|
141
|
+
...tsconfigAliases(workspaceRoot)] },
|
|
142
142
|
test: { globals: true, environment: 'node', isolate: true },
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
**The aliases are the module's, read the way tsc reads them.** `tsconfigAliases` follows the
|
|
146
|
-
module's own tsconfig chain (`tsconfig.spec.json`, then `tsconfig.app.json`, then `tsconfig.json`), so a module that declares
|
|
147
|
-
its own `paths` is tested with the aliases it type-checks with. When the chain declares no `paths`,
|
|
148
|
-
it falls back to `tsconfig.base.json`, which is what it always read: a module that still extends
|
|
149
|
-
the base sees no change. That fallback is a transition. Once no module extends the base, a module
|
|
150
|
-
without `paths` has no aliases, as in tsc. The rules are in `src/shared/tsconfig-paths.ts`. One difference with tsc 7 is deliberate: a `baseUrl` in the chain is honoured, as ts-jest, Vite and TypeScript 5 and 6 read it, so a chain whose `baseUrl` is not the directory of the file declaring `paths` resolves differently at runtime than in the typecheck. None exists in the monorepo today.
|
|
151
|
-
|
|
152
145
|
**`isolate` stays `true`**, whatever the performance note in Vitest's docs suggests. Jest gives each
|
|
153
146
|
test file a fresh module registry and `isolate: true` reproduces that. Nest registers metadata as an
|
|
154
147
|
import SIDE EFFECT, a decorator writing into a catalog when its module loads, so a shared registry
|
|
@@ -33,7 +33,7 @@ pnpm install
|
|
|
33
33
|
| `--run` | dev, everyday | **yes** (tsc) | executes the check, pass/fail. This is your `typecheck` script. |
|
|
34
34
|
| `--inspect` | dev, everyday | no (reads config) | the resolved config: preset, target, and which rules are deferred |
|
|
35
35
|
| `--init` | dev, once to adopt | writes files | the tsconfig stub, the `typecheck` script, the pinned dep, + workspace prep |
|
|
36
|
-
| `--migrate` |
|
|
36
|
+
| `--migrate` | planned | not available yet | reserved for changing an already-initialized setup (later ticket) |
|
|
37
37
|
| `--report` | **deprecated** | — | use `--run --json`: same work, same envelope |
|
|
38
38
|
| `--status` | **deprecated** | — | use `--inspect`, which absorbed it |
|
|
39
39
|
|
|
@@ -43,83 +43,13 @@ pnpm install
|
|
|
43
43
|
> the two above, because they answered the same two questions in a different shape. Both still
|
|
44
44
|
> run and print a notice telling you what to use instead.
|
|
45
45
|
|
|
46
|
-
**Location** (any verb): from a module dir → that module; from the root → `--module <name>`, `--ci` (affected), or all modules. `--init`
|
|
46
|
+
**Location** (any verb): from a module dir → that module; from the root → `--module <name>`, `--ci` (affected), or all modules. `--init` writes, so it targets one module only.
|
|
47
47
|
|
|
48
48
|
**Your tsconfig extends exactly one preset.** The options every stack shares are flattened into
|
|
49
49
|
each published preset at build time, so `@hublo/sentinel/tsconfig/react` is self-contained and
|
|
50
50
|
there is nothing to stack under it. The shared layer lives in the repo as
|
|
51
51
|
`src/roles/typescript/presets/shared.json`; it is ours and is never published on its own.
|
|
52
52
|
|
|
53
|
-
The one addition is `@hublo/sentinel/typescript/legacy`, and it is not a preset: it is the debt
|
|
54
|
-
a module carried through `tsconfig.base.json` (the six strict opt-outs, `ignoreDeprecations`,
|
|
55
|
-
and for react the decorator flags, `declaration: false` and `types`). Only `--migrate
|
|
56
|
-
--typescript` adds it, LEFT of the stack preset where the base was, so the stack preset keeps
|
|
57
|
-
winning; `--init` never does, so a new module is born with the full strict set.
|
|
58
|
-
|
|
59
|
-
## Detach a module from `tsconfig.base.json`
|
|
60
|
-
|
|
61
|
-
Run from an **adopted** module's directory (its tsconfig extends a sentinel preset), once its
|
|
62
|
-
`@hublo/sentinel` is the version that ships `legacy`:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
sentinel --migrate --typescript --dry-run # prove it and write nothing
|
|
66
|
-
sentinel --migrate --typescript # prove it and keep the result
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
It replaces the base in `extends` with `legacy` (when the module has those compromises), keeps
|
|
70
|
-
the stack preset, and writes only what depends on the module: `outDir`, `rootDir`, `exclude`,
|
|
71
|
-
and the `paths` entries tsc reports having MATCHED (`--traceResolution`), the setup and config
|
|
72
|
-
files no tsconfig compiles included. Measured on 113 modules (sentinel#147), that is all that is
|
|
73
|
-
left once the presets carry the base's standards.
|
|
74
|
-
|
|
75
|
-
It is all or nothing. Every tsconfig of the module that extends the base is proved first, each
|
|
76
|
-
rewritten and put back in turn, and the module's files are written only when tsc agrees on every
|
|
77
|
-
one of them, on both:
|
|
78
|
-
|
|
79
|
-
- `--showConfig` of every tsconfig of the folder applies the same options, `paths` aside. Applied,
|
|
80
|
-
not printed: the base printed `alwaysStrict`, `allowJs: false` and `isolatedModules`, and the
|
|
81
|
-
presets leave them to `strict`, the default and `verbatimModuleSyntax`. Same compilation,
|
|
82
|
-
different output, so the comparison derives those options the way tsc does
|
|
83
|
-
(`src/roles/typescript/compare.ts`);
|
|
84
|
-
- every module and type reference tsc resolves, file by file, lands on the same file.
|
|
85
|
-
|
|
86
|
-
A kept tsconfig is then formatted with the style the module states (its `.oxfmtrc.json`, else
|
|
87
|
-
the workspace's Prettier), the same rule `--init --test` follows: whitespace only, after tsc agreed.
|
|
88
|
-
|
|
89
|
-
It refuses, and writes nothing, for:
|
|
90
|
-
|
|
91
|
-
- a module not adopted yet (run `--init --typescript` first);
|
|
92
|
-
- a module with one tsconfig that extends the base without a sentinel preset, even when the others
|
|
93
|
-
are proved (`partly-adopted`). On the monorepo that is `tsconfig.acceptance.json` in `contract`
|
|
94
|
-
and `network`. Detaching the rest would leave the module compiling two ways, still on the base.
|
|
95
|
-
`--init` adopts the main tsconfig only, so the fix is to add the stack preset to that file's
|
|
96
|
-
`extends`, or to make it extend the adopted tsconfig;
|
|
97
|
-
- a tsconfig with comments;
|
|
98
|
-
- a module whose installed sentinel has no `legacy`, or resolves it from another install than its
|
|
99
|
-
stack preset;
|
|
100
|
-
- a tsconfig tsc cannot read (`error`, naming what tsc said), or a program that compiles files and
|
|
101
|
-
whose trace yields no resolution at all (`no-trace`): every program resolves at least its type
|
|
102
|
-
references, the smallest of the monorepo's 111 traces 447, so none means the trace was not read.
|
|
103
|
-
|
|
104
|
-
A nested folder that is a module of its own is named and left to its own run. Each refusal carries a
|
|
105
|
-
`refusal` code in `--json` (`not-adopted`, `partly-adopted`, `comments`, `no-legacy`,
|
|
106
|
-
`several-installs`, `no-trace`, `disagrees`, `error`).
|
|
107
|
-
|
|
108
|
-
`--dry-run` writes nothing either, but each tsconfig is rewritten on disk for the time of its proof.
|
|
109
|
-
A watcher (the Nx daemon, tsserver, a dev server) can see it come and go.
|
|
110
|
-
|
|
111
|
-
Once migrated, `--inspect` lists the compromises the module takes from `legacy` under
|
|
112
|
-
`inherited compromises (debt to remove)`: the options the stack preset does not set and the module
|
|
113
|
-
does not set itself, the ones that apply, each against the value the standard would apply
|
|
114
|
-
(`noImplicitAny — false, where the standard says true, inherited from …/legacy`). `--json` carries
|
|
115
|
-
the same lists as data: `standardOverrides` and `legacyCompromises`, each item with `rule`,
|
|
116
|
-
`value` and `standard`. The debt left the base, and stays
|
|
117
|
-
visible module by module until the module removes the `legacy` line.
|
|
118
|
-
|
|
119
|
-
What it does not prove is tsc's view only: the Nx project graph still reads the root base's
|
|
120
|
-
`paths`, and esbuild and Vite resolve each file through its nearest tsconfig. The base stays
|
|
121
|
-
until every module is detached, and the module's own build, test and lint are its proof.
|
|
122
|
-
|
|
123
53
|
## Everyday use (developers)
|
|
124
54
|
|
|
125
55
|
```bash
|
|
@@ -138,17 +68,17 @@ sentinel --inspect --typescript # adoption + conformity coverage
|
|
|
138
68
|
|
|
139
69
|
## Options
|
|
140
70
|
|
|
141
|
-
| Option | What it does
|
|
142
|
-
| ----------------------- |
|
|
143
|
-
| `--preset <name>` | override detection (`react` / `nest` / `svelte` / `node`); recommended for `--init`
|
|
144
|
-
| `--module <name>` | from the root, scope to one module
|
|
145
|
-
| `--ci` | from the root, only affected modules; non-zero exit on failure
|
|
146
|
-
| `--json` | machine-readable envelope on stdout, for every verb; progress goes to stderr
|
|
147
|
-
| `--max-diagnostics <n>` | cap the diagnostics embedded per module in `--run --json` (`0` = no cap)
|
|
148
|
-
| `--dry-run` | preview what `--init` would write,
|
|
149
|
-
| `--rehearse` | with `--dry-run`: run the autofix passes in a copy and name the source they rewrite
|
|
150
|
-
| `--runner <tool>` | override the default runner
|
|
151
|
-
| `-- <tool options>` | `--run` only, one type named: everything after `--` goes to tsc itself (see below)
|
|
71
|
+
| Option | What it does |
|
|
72
|
+
| ----------------------- | ----------------------------------------------------------------------------------- |
|
|
73
|
+
| `--preset <name>` | override detection (`react` / `nest` / `svelte` / `node`); recommended for `--init` |
|
|
74
|
+
| `--module <name>` | from the root, scope to one module |
|
|
75
|
+
| `--ci` | from the root, only affected modules; non-zero exit on failure |
|
|
76
|
+
| `--json` | machine-readable envelope on stdout, for every verb; progress goes to stderr |
|
|
77
|
+
| `--max-diagnostics <n>` | cap the diagnostics embedded per module in `--run --json` (`0` = no cap) |
|
|
78
|
+
| `--dry-run` | preview what `--init` would write, changing nothing |
|
|
79
|
+
| `--rehearse` | with `--dry-run`: run the autofix passes in a copy and name the source they rewrite |
|
|
80
|
+
| `--runner <tool>` | override the default runner |
|
|
81
|
+
| `-- <tool options>` | `--run` only, one type named: everything after `--` goes to tsc itself (see below) |
|
|
152
82
|
|
|
153
83
|
## Measuring a deferred rule
|
|
154
84
|
|
|
@@ -253,12 +183,3 @@ it would hand it to the workspace tsconfig this module extends
|
|
|
253
183
|
```
|
|
254
184
|
|
|
255
185
|
It is not reported as drift by `--inspect` either, so a module that legitimately overrides the base does not read as non-conformant forever.
|
|
256
|
-
|
|
257
|
-
Not drift, but not hidden either: `--inspect` lists it under `differs from the repo standard`,
|
|
258
|
-
with both values. An option a preset took over from the base (`fromBase`) and that the module
|
|
259
|
-
sets to another value is this module departing from the standard, and that is worth seeing:
|
|
260
|
-
|
|
261
|
-
```
|
|
262
|
-
differs from the repo standard (kept by --init, not drift):
|
|
263
|
-
• verbatimModuleSyntax — false, where the nest preset says true
|
|
264
|
-
```
|
|
@@ -236,11 +236,11 @@ $ sentinel --report --json 2>/dev/null
|
|
|
236
236
|
"typescript",
|
|
237
237
|
"build",
|
|
238
238
|
"test",
|
|
239
|
-
"static-analysis"
|
|
239
|
+
"static-analysis",
|
|
240
|
+
"arch"
|
|
240
241
|
],
|
|
241
242
|
"skipped": [
|
|
242
|
-
"runtime-analysis"
|
|
243
|
-
"arch"
|
|
243
|
+
"runtime-analysis"
|
|
244
244
|
],
|
|
245
245
|
"results": [
|
|
246
246
|
{
|
|
@@ -319,6 +319,16 @@ $ sentinel --report --json 2>/dev/null
|
|
|
319
319
|
"preset": null,
|
|
320
320
|
"conformant": false
|
|
321
321
|
},
|
|
322
|
+
{
|
|
323
|
+
"project": "svelte-app",
|
|
324
|
+
"target": "arch",
|
|
325
|
+
"flavour": "svelte",
|
|
326
|
+
"ok": true,
|
|
327
|
+
"status": "ok",
|
|
328
|
+
"adopted": false,
|
|
329
|
+
"preset": null,
|
|
330
|
+
"conformant": false
|
|
331
|
+
},
|
|
322
332
|
{
|
|
323
333
|
"project": "bff-admin",
|
|
324
334
|
"target": "lint",
|
|
@@ -395,6 +405,16 @@ $ sentinel --report --json 2>/dev/null
|
|
|
395
405
|
"preset": null,
|
|
396
406
|
"conformant": false
|
|
397
407
|
},
|
|
408
|
+
{
|
|
409
|
+
"project": "bff-admin",
|
|
410
|
+
"target": "arch",
|
|
411
|
+
"flavour": "nest",
|
|
412
|
+
"ok": true,
|
|
413
|
+
"status": "ok",
|
|
414
|
+
"adopted": false,
|
|
415
|
+
"preset": null,
|
|
416
|
+
"conformant": false
|
|
417
|
+
},
|
|
398
418
|
{
|
|
399
419
|
"project": "react-app",
|
|
400
420
|
"target": "lint",
|
|
@@ -471,6 +491,16 @@ $ sentinel --report --json 2>/dev/null
|
|
|
471
491
|
"preset": null,
|
|
472
492
|
"conformant": false
|
|
473
493
|
},
|
|
494
|
+
{
|
|
495
|
+
"project": "react-app",
|
|
496
|
+
"target": "arch",
|
|
497
|
+
"flavour": "react",
|
|
498
|
+
"ok": true,
|
|
499
|
+
"status": "ok",
|
|
500
|
+
"adopted": false,
|
|
501
|
+
"preset": null,
|
|
502
|
+
"conformant": false
|
|
503
|
+
},
|
|
474
504
|
{
|
|
475
505
|
"project": "utils",
|
|
476
506
|
"target": "lint",
|
|
@@ -534,6 +564,16 @@ $ sentinel --report --json 2>/dev/null
|
|
|
534
564
|
"adopted": false,
|
|
535
565
|
"preset": null,
|
|
536
566
|
"conformant": false
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
"project": "utils",
|
|
570
|
+
"target": "arch",
|
|
571
|
+
"flavour": "node",
|
|
572
|
+
"ok": true,
|
|
573
|
+
"status": "ok",
|
|
574
|
+
"adopted": false,
|
|
575
|
+
"preset": null,
|
|
576
|
+
"conformant": false
|
|
537
577
|
}
|
|
538
578
|
]
|
|
539
579
|
}
|
|
@@ -566,11 +606,11 @@ $ sentinel --report --all --json 2>/dev/null
|
|
|
566
606
|
"typescript",
|
|
567
607
|
"build",
|
|
568
608
|
"test",
|
|
569
|
-
"static-analysis"
|
|
609
|
+
"static-analysis",
|
|
610
|
+
"arch"
|
|
570
611
|
],
|
|
571
612
|
"skipped": [
|
|
572
|
-
"runtime-analysis"
|
|
573
|
-
"arch"
|
|
613
|
+
"runtime-analysis"
|
|
574
614
|
],
|
|
575
615
|
"results": [
|
|
576
616
|
{
|
|
@@ -649,6 +689,16 @@ $ sentinel --report --all --json 2>/dev/null
|
|
|
649
689
|
"preset": null,
|
|
650
690
|
"conformant": false
|
|
651
691
|
},
|
|
692
|
+
{
|
|
693
|
+
"project": "svelte-app",
|
|
694
|
+
"target": "arch",
|
|
695
|
+
"flavour": "svelte",
|
|
696
|
+
"ok": true,
|
|
697
|
+
"status": "ok",
|
|
698
|
+
"adopted": false,
|
|
699
|
+
"preset": null,
|
|
700
|
+
"conformant": false
|
|
701
|
+
},
|
|
652
702
|
{
|
|
653
703
|
"project": "bff-admin",
|
|
654
704
|
"target": "lint",
|
|
@@ -725,6 +775,16 @@ $ sentinel --report --all --json 2>/dev/null
|
|
|
725
775
|
"preset": null,
|
|
726
776
|
"conformant": false
|
|
727
777
|
},
|
|
778
|
+
{
|
|
779
|
+
"project": "bff-admin",
|
|
780
|
+
"target": "arch",
|
|
781
|
+
"flavour": "nest",
|
|
782
|
+
"ok": true,
|
|
783
|
+
"status": "ok",
|
|
784
|
+
"adopted": false,
|
|
785
|
+
"preset": null,
|
|
786
|
+
"conformant": false
|
|
787
|
+
},
|
|
728
788
|
{
|
|
729
789
|
"project": "react-app",
|
|
730
790
|
"target": "lint",
|
|
@@ -801,6 +861,16 @@ $ sentinel --report --all --json 2>/dev/null
|
|
|
801
861
|
"preset": null,
|
|
802
862
|
"conformant": false
|
|
803
863
|
},
|
|
864
|
+
{
|
|
865
|
+
"project": "react-app",
|
|
866
|
+
"target": "arch",
|
|
867
|
+
"flavour": "react",
|
|
868
|
+
"ok": true,
|
|
869
|
+
"status": "ok",
|
|
870
|
+
"adopted": false,
|
|
871
|
+
"preset": null,
|
|
872
|
+
"conformant": false
|
|
873
|
+
},
|
|
804
874
|
{
|
|
805
875
|
"project": "utils",
|
|
806
876
|
"target": "lint",
|
|
@@ -864,6 +934,16 @@ $ sentinel --report --all --json 2>/dev/null
|
|
|
864
934
|
"adopted": false,
|
|
865
935
|
"preset": null,
|
|
866
936
|
"conformant": false
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
"project": "utils",
|
|
940
|
+
"target": "arch",
|
|
941
|
+
"flavour": "node",
|
|
942
|
+
"ok": true,
|
|
943
|
+
"status": "ok",
|
|
944
|
+
"adopted": false,
|
|
945
|
+
"preset": null,
|
|
946
|
+
"conformant": false
|
|
867
947
|
}
|
|
868
948
|
]
|
|
869
949
|
}
|
|
@@ -1026,7 +1106,7 @@ $ sentinel --report --all --typescript
|
|
|
1026
1106
|
|
|
1027
1107
|
```console
|
|
1028
1108
|
$ sentinel --run --typescript --dry-run --module bff-admin
|
|
1029
|
-
--dry-run only applies to --init
|
|
1109
|
+
--dry-run only applies to --init (the read verbs never write).
|
|
1030
1110
|
(run "sentinel --help" for usage)
|
|
1031
1111
|
# exit: 1
|
|
1032
1112
|
```
|
|
@@ -1223,6 +1303,7 @@ $ sentinel --init --dry-run
|
|
|
1223
1303
|
+ }
|
|
1224
1304
|
+ }
|
|
1225
1305
|
+ }
|
|
1306
|
+
arch: no sentinel.arch.json at the workspace root: the repository has not said which decision applies where.
|
|
1226
1307
|
dry run: no files written
|
|
1227
1308
|
materialized the nest format preset into .oxfmtrc.json (@hublo/sentinel@<version>). oxfmt has no `extends`, so the values live here; `sentinel --status --format` reports modules left behind by a preset change
|
|
1228
1309
|
|
|
@@ -1461,6 +1542,7 @@ $ sentinel --init --dry-run --rehearse
|
|
|
1461
1542
|
+ }
|
|
1462
1543
|
+ }
|
|
1463
1544
|
+ }
|
|
1545
|
+
arch: no sentinel.arch.json at the workspace root: the repository has not said which decision applies where.
|
|
1464
1546
|
dry run: no files written
|
|
1465
1547
|
materialized the nest format preset into .oxfmtrc.json (@hublo/sentinel@<version>). oxfmt has no `extends`, so the values live here; `sentinel --status --format` reports modules left behind by a preset change
|
|
1466
1548
|
|
package/docs/using-sentinel.md
CHANGED
|
@@ -5,8 +5,9 @@ migrating a module see [`lint-adoption.md`](lint-adoption.md),
|
|
|
5
5
|
[`format-adoption.md`](format-adoption.md),
|
|
6
6
|
[`typescript-adoption.md`](typescript-adoption.md),
|
|
7
7
|
[`build-adoption.md`](build-adoption.md),
|
|
8
|
-
[`test-adoption.md`](test-adoption.md)
|
|
9
|
-
[`static-analysis-adoption.md`](static-analysis-adoption.md)
|
|
8
|
+
[`test-adoption.md`](test-adoption.md),
|
|
9
|
+
[`static-analysis-adoption.md`](static-analysis-adoption.md) and
|
|
10
|
+
[`arch-adoption.md`](arch-adoption.md). The reference gate `--test` runs a
|
|
10
11
|
migration against is in `test-adoption.md`, not the static-analysis page.
|
|
11
12
|
|
|
12
13
|
## The grid
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hublo/sentinel",
|
|
3
|
-
"version": "1.7.0-alpha.
|
|
3
|
+
"version": "1.7.0-alpha.7",
|
|
4
4
|
"description": "One CLI that guards code health across Hublo repos: shared lint/typescript/build/test presets, static & dynamic analysis, and architecture checks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,9 +30,6 @@
|
|
|
30
30
|
"./typescript/node": {
|
|
31
31
|
"default": "./dist/tsconfig/node.json"
|
|
32
32
|
},
|
|
33
|
-
"./typescript/legacy": {
|
|
34
|
-
"default": "./dist/tsconfig/legacy.json"
|
|
35
|
-
},
|
|
36
33
|
"./tsconfig/react": {
|
|
37
34
|
"default": "./dist/tsconfig/react.json"
|
|
38
35
|
},
|