@hublo/sentinel 1.7.0-alpha.6 → 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 -96
- 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-X7PB2X7R.js +0 -553
- package/dist/tsconfig/legacy.json +0 -21
package/dist/chunk-ZFG6P27V.js
DELETED
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
parseJsonc
|
|
3
|
-
} from "./chunk-QXFCZON7.js";
|
|
4
|
-
|
|
5
|
-
// src/shared/resolve-bin.ts
|
|
6
|
-
import { existsSync } from "node:fs";
|
|
7
|
-
import { createRequire } from "node:module";
|
|
8
|
-
import { delimiter, dirname, join } from "node:path";
|
|
9
|
-
var require2 = createRequire(import.meta.url);
|
|
10
|
-
function resolveBin(fromDir, name) {
|
|
11
|
-
let dir = fromDir;
|
|
12
|
-
for (; ; ) {
|
|
13
|
-
const candidate = join(dir, "node_modules", ".bin", name);
|
|
14
|
-
if (existsSync(candidate)) return candidate;
|
|
15
|
-
const parent = dirname(dir);
|
|
16
|
-
if (parent === dir) return void 0;
|
|
17
|
-
dir = parent;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function binFromOwnInstall(packageName, binName) {
|
|
21
|
-
try {
|
|
22
|
-
const manifest = require2.resolve(`${packageName}/package.json`);
|
|
23
|
-
const bin = require2(manifest).bin;
|
|
24
|
-
const relative = typeof bin === "string" ? bin : bin?.[binName];
|
|
25
|
-
if (!relative) return void 0;
|
|
26
|
-
const executable = join(dirname(manifest), relative);
|
|
27
|
-
return existsSync(executable) ? executable : void 0;
|
|
28
|
-
} catch {
|
|
29
|
-
return void 0;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function binSearchPath(cwd) {
|
|
33
|
-
return [`${cwd}${delimiter}node_modules/.bin (and parents)`, "sentinel's own install"].join(
|
|
34
|
-
" then "
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
function scriptPath(cwd, path) {
|
|
38
|
-
const bins = [];
|
|
39
|
-
let dir = cwd;
|
|
40
|
-
for (; ; ) {
|
|
41
|
-
bins.push(join(dir, "node_modules", ".bin"));
|
|
42
|
-
const parent = dirname(dir);
|
|
43
|
-
if (parent === dir) break;
|
|
44
|
-
dir = parent;
|
|
45
|
-
}
|
|
46
|
-
return [...bins, path].filter(Boolean).join(delimiter);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// src/roles/test/written-file-formatter.ts
|
|
50
|
-
import { existsSync as existsSync3 } from "node:fs";
|
|
51
|
-
import { dirname as dirname3, join as join4 } from "node:path";
|
|
52
|
-
|
|
53
|
-
// src/roles/format/read-adoption.ts
|
|
54
|
-
import { existsSync as existsSync2, readFileSync } from "node:fs";
|
|
55
|
-
import { join as join2 } from "node:path";
|
|
56
|
-
|
|
57
|
-
// src/roles/format/config-policy.ts
|
|
58
|
-
var FORMAT_CONFIG_FILE = ".oxfmtrc.json";
|
|
59
|
-
var FORMAT_SCRIPT_NAME = "format";
|
|
60
|
-
var PROVENANCE_KEY = "$sentinel";
|
|
61
|
-
var PERMITTED_LOCAL_KEYS = [
|
|
62
|
-
"useTabs",
|
|
63
|
-
"tabWidth",
|
|
64
|
-
"printWidth",
|
|
65
|
-
"semi",
|
|
66
|
-
"singleQuote",
|
|
67
|
-
"jsxSingleQuote",
|
|
68
|
-
"trailingComma",
|
|
69
|
-
"quoteProps",
|
|
70
|
-
"bracketSpacing",
|
|
71
|
-
"bracketSameLine",
|
|
72
|
-
"arrowParens",
|
|
73
|
-
"endOfLine",
|
|
74
|
-
"objectWrap",
|
|
75
|
-
"proseWrap",
|
|
76
|
-
"experimentalOperatorPosition"
|
|
77
|
-
];
|
|
78
|
-
var ALWAYS_LOCAL_KEYS = ["ignorePatterns", "overrides"];
|
|
79
|
-
var OWNED_WHEN_SET_KEYS = ["sortImports"];
|
|
80
|
-
var FORMAT_DEFAULT_IGNORES = ["**/*.toml"];
|
|
81
|
-
var PRETTIER_CONFIG_FILES = [
|
|
82
|
-
".prettierrc",
|
|
83
|
-
".prettierrc.json",
|
|
84
|
-
".prettierrc.json5",
|
|
85
|
-
".prettierrc.yml",
|
|
86
|
-
".prettierrc.yaml",
|
|
87
|
-
".prettierrc.js",
|
|
88
|
-
".prettierrc.cjs",
|
|
89
|
-
".prettierrc.mjs",
|
|
90
|
-
"prettier.config.js",
|
|
91
|
-
"prettier.config.cjs",
|
|
92
|
-
"prettier.config.mjs"
|
|
93
|
-
];
|
|
94
|
-
function formatTargets() {
|
|
95
|
-
return {
|
|
96
|
-
[FORMAT_SCRIPT_NAME]: {
|
|
97
|
-
cache: true,
|
|
98
|
-
inputs: ["default", `{projectRoot}/${FORMAT_CONFIG_FILE}`]
|
|
99
|
-
},
|
|
100
|
-
[`${FORMAT_SCRIPT_NAME}:fix`]: { cache: false }
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// src/roles/format/presets/base.json
|
|
105
|
-
var base_default = {
|
|
106
|
-
printWidth: 80,
|
|
107
|
-
semi: false,
|
|
108
|
-
singleQuote: true,
|
|
109
|
-
trailingComma: "all",
|
|
110
|
-
sortPackageJson: false,
|
|
111
|
-
sortImports: false
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// src/roles/format/presets/nest-imports.json
|
|
115
|
-
var nest_imports_default = {
|
|
116
|
-
customGroups: [
|
|
117
|
-
{
|
|
118
|
-
groupName: "workspace",
|
|
119
|
-
elementNamePattern: ["@hublo/**", "@shared/**", "@front/**", "@network/**"]
|
|
120
|
-
}
|
|
121
|
-
],
|
|
122
|
-
groups: ["builtin", "external", "workspace", ["parent", "index"], "sibling"],
|
|
123
|
-
newlinesBetween: true,
|
|
124
|
-
order: "asc",
|
|
125
|
-
ignoreCase: false
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
// src/roles/format/preset-data.ts
|
|
129
|
-
var FORMAT_PRESETS = ["base", "svelte", "nest"];
|
|
130
|
-
function hasFormatPreset(name) {
|
|
131
|
-
return FORMAT_PRESETS.includes(name);
|
|
132
|
-
}
|
|
133
|
-
function formatPresetName(declared) {
|
|
134
|
-
if (declared === "svelte") return "svelte";
|
|
135
|
-
if (declared === "nest") return "nest";
|
|
136
|
-
return "base";
|
|
137
|
-
}
|
|
138
|
-
function formatPresetFor(preset) {
|
|
139
|
-
const base = base_default;
|
|
140
|
-
const name = formatPresetName(preset);
|
|
141
|
-
if (name === "svelte") return { ...base, svelte: true };
|
|
142
|
-
if (name === "nest") return { ...base, sortImports: nest_imports_default };
|
|
143
|
-
return base;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// src/roles/format/read-adoption.ts
|
|
147
|
-
var NOT_ADOPTED = (configFile, unreadable = null) => ({
|
|
148
|
-
configFile,
|
|
149
|
-
preset: null,
|
|
150
|
-
adopted: false,
|
|
151
|
-
conformant: false,
|
|
152
|
-
drift: [],
|
|
153
|
-
local: {},
|
|
154
|
-
presetVersion: null,
|
|
155
|
-
effective: {},
|
|
156
|
-
unreadable
|
|
157
|
-
});
|
|
158
|
-
function sameValue(a, b) {
|
|
159
|
-
return JSON.stringify(a) === JSON.stringify(b);
|
|
160
|
-
}
|
|
161
|
-
function readFormatAdoption(cwd) {
|
|
162
|
-
const path = join2(cwd, FORMAT_CONFIG_FILE);
|
|
163
|
-
if (!existsSync2(path)) return NOT_ADOPTED(null);
|
|
164
|
-
let parsed;
|
|
165
|
-
try {
|
|
166
|
-
parsed = parseJsonc(readFileSync(path, "utf8"), FORMAT_CONFIG_FILE);
|
|
167
|
-
} catch (error) {
|
|
168
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
169
|
-
return NOT_ADOPTED(FORMAT_CONFIG_FILE, `${FORMAT_CONFIG_FILE} could not be parsed (${reason})`);
|
|
170
|
-
}
|
|
171
|
-
const provenance = parsed[PROVENANCE_KEY];
|
|
172
|
-
if (!provenance || typeof provenance.preset !== "string") return NOT_ADOPTED(FORMAT_CONFIG_FILE);
|
|
173
|
-
if (!hasFormatPreset(provenance.preset)) {
|
|
174
|
-
return NOT_ADOPTED(
|
|
175
|
-
FORMAT_CONFIG_FILE,
|
|
176
|
-
`${FORMAT_CONFIG_FILE} declares the format preset "${provenance.preset}", which sentinel does not ship (shipped: ${FORMAT_PRESETS.join(", ")}). Re-run \`sentinel --init --format\`.`
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
const declaredLocal = Array.isArray(provenance.local) ? provenance.local : [];
|
|
180
|
-
const preset = formatPresetFor(provenance.preset);
|
|
181
|
-
const drift = [];
|
|
182
|
-
const local = {};
|
|
183
|
-
for (const [key, expected] of Object.entries(preset)) {
|
|
184
|
-
if (declaredLocal.includes(key)) {
|
|
185
|
-
local[key] = parsed[key];
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
if (!(key in parsed) || !sameValue(parsed[key], expected)) drift.push(key);
|
|
189
|
-
}
|
|
190
|
-
for (const key of declaredLocal) {
|
|
191
|
-
if (!(key in preset)) local[key] = parsed[key];
|
|
192
|
-
}
|
|
193
|
-
for (const key of ALWAYS_LOCAL_KEYS) {
|
|
194
|
-
if (key in parsed) local[key] = parsed[key];
|
|
195
|
-
}
|
|
196
|
-
return {
|
|
197
|
-
configFile: FORMAT_CONFIG_FILE,
|
|
198
|
-
preset: provenance.preset,
|
|
199
|
-
adopted: true,
|
|
200
|
-
conformant: drift.length === 0,
|
|
201
|
-
drift,
|
|
202
|
-
local,
|
|
203
|
-
presetVersion: typeof provenance.version === "string" ? provenance.version : null,
|
|
204
|
-
effective: parsed,
|
|
205
|
-
unreadable: null
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// src/roles/format/resolve-oxfmt.ts
|
|
210
|
-
import { readFileSync as readFileSync2 } from "node:fs";
|
|
211
|
-
import { createRequire as createRequire2 } from "node:module";
|
|
212
|
-
import { dirname as dirname2, join as join3 } from "node:path";
|
|
213
|
-
function resolveOxfmt(cwd) {
|
|
214
|
-
return resolveBin(cwd, "oxfmt") ?? binFromOwnInstall("oxfmt", "oxfmt");
|
|
215
|
-
}
|
|
216
|
-
function oxfmtRejects(key, value) {
|
|
217
|
-
const schema = configSchema();
|
|
218
|
-
const property = schema?.properties?.[key];
|
|
219
|
-
if (!property) return false;
|
|
220
|
-
const definition = resolveRef(schema, property);
|
|
221
|
-
if (Array.isArray(definition.enum)) return !definition.enum.includes(value);
|
|
222
|
-
if (definition.type === "boolean") return typeof value !== "boolean";
|
|
223
|
-
if (definition.type === "integer" || definition.type === "number")
|
|
224
|
-
return typeof value !== "number";
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
function resolveRef(schema, node) {
|
|
228
|
-
const ref = node.$ref ?? node.allOf?.[0]?.$ref;
|
|
229
|
-
const name = ref?.startsWith("#/definitions/") ? ref.slice("#/definitions/".length) : void 0;
|
|
230
|
-
return (name ? schema.definitions?.[name] : void 0) ?? node;
|
|
231
|
-
}
|
|
232
|
-
var cachedSchema;
|
|
233
|
-
function configSchema() {
|
|
234
|
-
if (cachedSchema !== void 0) return cachedSchema ?? void 0;
|
|
235
|
-
cachedSchema = readConfigSchema() ?? null;
|
|
236
|
-
return cachedSchema ?? void 0;
|
|
237
|
-
}
|
|
238
|
-
function readConfigSchema() {
|
|
239
|
-
try {
|
|
240
|
-
const manifest = createRequire2(import.meta.url).resolve("oxfmt/package.json");
|
|
241
|
-
const schemaPath = join3(dirname2(manifest), "configuration_schema.json");
|
|
242
|
-
return JSON.parse(readFileSync2(schemaPath, "utf8"));
|
|
243
|
-
} catch {
|
|
244
|
-
return void 0;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// src/roles/test/written-file-formatter.ts
|
|
249
|
-
var PRETTIER_CONFIGS = [
|
|
250
|
-
".prettierrc",
|
|
251
|
-
".prettierrc.json",
|
|
252
|
-
".prettierrc.json5",
|
|
253
|
-
".prettierrc.yaml",
|
|
254
|
-
".prettierrc.yml",
|
|
255
|
-
".prettierrc.js",
|
|
256
|
-
".prettierrc.cjs",
|
|
257
|
-
".prettierrc.mjs",
|
|
258
|
-
".prettierrc.toml",
|
|
259
|
-
"prettier.config.js",
|
|
260
|
-
"prettier.config.cjs",
|
|
261
|
-
"prettier.config.mjs"
|
|
262
|
-
];
|
|
263
|
-
function prettierConfigFrom(cwd) {
|
|
264
|
-
let dir = cwd;
|
|
265
|
-
for (; ; ) {
|
|
266
|
-
for (const name of PRETTIER_CONFIGS) {
|
|
267
|
-
if (existsSync3(join4(dir, name))) return join4(dir, name);
|
|
268
|
-
}
|
|
269
|
-
const parent = dirname3(dir);
|
|
270
|
-
if (parent === dir) return void 0;
|
|
271
|
-
dir = parent;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
function writtenFileFormatter(cwd) {
|
|
275
|
-
if (readFormatAdoption(cwd).configFile !== null) {
|
|
276
|
-
const oxfmt = resolveOxfmt(cwd);
|
|
277
|
-
if (oxfmt !== void 0) {
|
|
278
|
-
return { bin: oxfmt, args: ["--write"], origin: "this module's own oxfmt config" };
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
const config = prettierConfigFrom(cwd);
|
|
282
|
-
const prettier = resolveBin(cwd, "prettier");
|
|
283
|
-
if (config !== void 0 && prettier !== void 0) {
|
|
284
|
-
return {
|
|
285
|
-
bin: prettier,
|
|
286
|
-
args: ["--write", "--log-level", "warn"],
|
|
287
|
-
origin: `the workspace's Prettier`
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
return void 0;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export {
|
|
294
|
-
resolveBin,
|
|
295
|
-
binFromOwnInstall,
|
|
296
|
-
binSearchPath,
|
|
297
|
-
scriptPath,
|
|
298
|
-
FORMAT_CONFIG_FILE,
|
|
299
|
-
FORMAT_SCRIPT_NAME,
|
|
300
|
-
PROVENANCE_KEY,
|
|
301
|
-
PERMITTED_LOCAL_KEYS,
|
|
302
|
-
ALWAYS_LOCAL_KEYS,
|
|
303
|
-
OWNED_WHEN_SET_KEYS,
|
|
304
|
-
FORMAT_DEFAULT_IGNORES,
|
|
305
|
-
PRETTIER_CONFIG_FILES,
|
|
306
|
-
formatTargets,
|
|
307
|
-
formatPresetName,
|
|
308
|
-
formatPresetFor,
|
|
309
|
-
readFormatAdoption,
|
|
310
|
-
resolveOxfmt,
|
|
311
|
-
oxfmtRejects,
|
|
312
|
-
writtenFileFormatter
|
|
313
|
-
};
|
package/dist/chunk-ZZMYV576.js
DELETED
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
// src/roles/typescript/compare.ts
|
|
2
|
-
var STRICT_FAMILY = [
|
|
3
|
-
"alwaysStrict",
|
|
4
|
-
"noImplicitAny",
|
|
5
|
-
"noImplicitThis",
|
|
6
|
-
"strictBindCallApply",
|
|
7
|
-
"strictBuiltinIteratorReturn",
|
|
8
|
-
"strictFunctionTypes",
|
|
9
|
-
"strictNullChecks",
|
|
10
|
-
"strictPropertyInitialization",
|
|
11
|
-
"useUnknownInCatchVariables"
|
|
12
|
-
];
|
|
13
|
-
var CASE_INSENSITIVE = /* @__PURE__ */ new Set([
|
|
14
|
-
"jsx",
|
|
15
|
-
"lib",
|
|
16
|
-
"module",
|
|
17
|
-
"moduleDetection",
|
|
18
|
-
"moduleResolution",
|
|
19
|
-
"target"
|
|
20
|
-
]);
|
|
21
|
-
function targetYear(target) {
|
|
22
|
-
const name = typeof target === "string" ? target.toLowerCase() : "es5";
|
|
23
|
-
if (name === "esnext") return Number.MAX_SAFE_INTEGER;
|
|
24
|
-
const year = Number(name.replace(/^es/, ""));
|
|
25
|
-
return Number.isFinite(year) ? year : 5;
|
|
26
|
-
}
|
|
27
|
-
function comparable(key, value) {
|
|
28
|
-
const json = JSON.stringify(value) ?? "undefined";
|
|
29
|
-
return CASE_INSENSITIVE.has(key) ? json.toLowerCase() : json;
|
|
30
|
-
}
|
|
31
|
-
function appliedOptions(config) {
|
|
32
|
-
const options = new Map(Object.entries(config.compilerOptions ?? {}));
|
|
33
|
-
options.delete("paths");
|
|
34
|
-
const derive = (key, value) => {
|
|
35
|
-
if (!options.has(key)) options.set(key, value);
|
|
36
|
-
};
|
|
37
|
-
if (options.get("strict") === true) for (const key of STRICT_FAMILY) derive(key, true);
|
|
38
|
-
derive("allowJs", false);
|
|
39
|
-
if (options.get("esModuleInterop") === true) derive("allowSyntheticDefaultImports", true);
|
|
40
|
-
if (options.get("verbatimModuleSyntax") === true) derive("isolatedModules", true);
|
|
41
|
-
if (options.get("isolatedModules") === true) derive("preserveConstEnums", true);
|
|
42
|
-
derive("useDefineForClassFields", targetYear(options.get("target")) >= 2022);
|
|
43
|
-
return new Map([...options].map(([key, value]) => [key, comparable(key, value)]));
|
|
44
|
-
}
|
|
45
|
-
function diffConfigs(before, after) {
|
|
46
|
-
const was = appliedOptions(before);
|
|
47
|
-
const now = appliedOptions(after);
|
|
48
|
-
const differences = [];
|
|
49
|
-
for (const key of /* @__PURE__ */ new Set([...was.keys(), ...now.keys()])) {
|
|
50
|
-
if (was.get(key) !== now.get(key)) {
|
|
51
|
-
differences.push({ key: `compilerOptions.${key}`, before: was.get(key), after: now.get(key) });
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
for (const key of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) {
|
|
55
|
-
if (key === "compilerOptions") continue;
|
|
56
|
-
const left = JSON.stringify(before[key]);
|
|
57
|
-
const right = JSON.stringify(after[key]);
|
|
58
|
-
if (left !== right) differences.push({ key, before: left, after: right });
|
|
59
|
-
}
|
|
60
|
-
return differences;
|
|
61
|
-
}
|
|
62
|
-
function remainder(effective, layers, ownKeys) {
|
|
63
|
-
const applied = appliedOptions(effective);
|
|
64
|
-
const given = appliedOptions(layers);
|
|
65
|
-
const written = [];
|
|
66
|
-
for (const [key, value] of applied) {
|
|
67
|
-
if (ownKeys.has(key) || given.get(key) === value) continue;
|
|
68
|
-
written.push({ key, value: effective.compilerOptions?.[key] ?? JSON.parse(value) });
|
|
69
|
-
}
|
|
70
|
-
return written;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// src/roles/typescript/presets/legacy.json
|
|
74
|
-
var legacy_default = {
|
|
75
|
-
$schema: "https://json.schemastore.org/tsconfig",
|
|
76
|
-
compilerOptions: {
|
|
77
|
-
noImplicitAny: false,
|
|
78
|
-
noImplicitThis: false,
|
|
79
|
-
strictBindCallApply: false,
|
|
80
|
-
strictFunctionTypes: false,
|
|
81
|
-
strictPropertyInitialization: false,
|
|
82
|
-
useUnknownInCatchVariables: false,
|
|
83
|
-
ignoreDeprecations: "6.0",
|
|
84
|
-
experimentalDecorators: true,
|
|
85
|
-
emitDecoratorMetadata: true,
|
|
86
|
-
declaration: false,
|
|
87
|
-
types: ["vite/client", "@types/segment-analytics"],
|
|
88
|
-
importHelpers: true,
|
|
89
|
-
sourceMap: true
|
|
90
|
-
},
|
|
91
|
-
notes: {
|
|
92
|
-
purpose: "the compromises tsconfig.base.json applied to every module, kept in one place so a module that stops extending the base loses nothing (sentinel#147). Placed LEFT of the stack preset, where the base was, so the stack preset keeps winning wherever both set an option",
|
|
93
|
-
who: "added only by `--migrate --typescript`, never by `--init`: a new module is born with the full strict set, and a module that has paid this debt removes one `extends` line",
|
|
94
|
-
strict: "the six opt-outs below turn off parts of `strict`, which the shared layer sets; the base had them for every module",
|
|
95
|
-
ignoreDeprecations: "temporary by nature: it silences the TypeScript 6 deprecations the base still relies on",
|
|
96
|
-
react: "`declaration`, `types`, the decorator flags, `importHelpers` and `sourceMap` are what the base gave react modules that the react preset does not set. `types` moves whole: an array is replaced, never merged, so splitting it between two presets would lose an entry",
|
|
97
|
-
types: "`vite/client` and `@types/segment-analytics` are the base's, kept as they were: on react they apply, on nest and node the stack preset's `types: [node]` wins, exactly as it did over the base. Not a choice for a backend, a copy of the debt, to clean up with it"
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// src/roles/typescript/presets/nest.json
|
|
102
|
-
var nest_default = {
|
|
103
|
-
compilerOptions: {
|
|
104
|
-
module: "esnext",
|
|
105
|
-
moduleResolution: "bundler",
|
|
106
|
-
types: ["node"],
|
|
107
|
-
experimentalDecorators: true,
|
|
108
|
-
emitDecoratorMetadata: true,
|
|
109
|
-
declaration: true,
|
|
110
|
-
sourceMap: true,
|
|
111
|
-
importHelpers: true,
|
|
112
|
-
target: "es2021",
|
|
113
|
-
lib: ["es2023", "dom"]
|
|
114
|
-
},
|
|
115
|
-
notes: {
|
|
116
|
-
module: "the backends are webpack-bundled and tsc only typechecks, so the module format is the bundler's concern; `bundler` resolution is what the repo already uses, and the only Node-friendly option TS7 still accepts since it removed classic `node`",
|
|
117
|
-
target: "raised from tsconfig.base.json (sentinel#147) with the value every nest module already applied: `es2021`. Same value, so `useDefineForClassFields` does not flip (TS2612), which is why it was left to the base before. Moving it to a newer target is its own change, measured on its own",
|
|
118
|
-
lib: "raised from tsconfig.base.json (sentinel#147) as the base had it, DOM included: narrowing `lib` drops DOM types some modules use (GLfloat), so that is its own change",
|
|
119
|
-
importHelpers: "raised from tsconfig.base.json (sentinel#147): `true` in every module of this stack, through the base"
|
|
120
|
-
},
|
|
121
|
-
fromBase: ["importHelpers", "target", "lib"]
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
// src/roles/typescript/presets/node.json
|
|
125
|
-
var node_default = {
|
|
126
|
-
compilerOptions: {
|
|
127
|
-
module: "esnext",
|
|
128
|
-
moduleResolution: "bundler",
|
|
129
|
-
types: ["node"],
|
|
130
|
-
declaration: true,
|
|
131
|
-
importHelpers: true,
|
|
132
|
-
target: "es2021",
|
|
133
|
-
lib: ["es2023", "dom"],
|
|
134
|
-
sourceMap: true
|
|
135
|
-
},
|
|
136
|
-
notes: {
|
|
137
|
-
module: "esnext/bundler like the react and nest presets, matching a monorepo whose libs are bundler-resolved in practice. NOT NodeNext: that would force its stricter ESM rules onto libs the repo resolves through a bundler",
|
|
138
|
-
target: "raised from tsconfig.base.json (sentinel#147) with the value every node module already applied: `es2021`. Same value, so `useDefineForClassFields` does not flip (TS2612), which is why it was left to the base before. Moving it to a newer target is its own change, measured on its own",
|
|
139
|
-
lib: "raised from tsconfig.base.json (sentinel#147) as the base had it, DOM included: narrowing `lib` drops DOM types some modules use (GLfloat), so that is its own change",
|
|
140
|
-
importHelpers: "raised from tsconfig.base.json (sentinel#147): `true` in every module of this stack, through the base",
|
|
141
|
-
sourceMap: "raised from tsconfig.base.json (sentinel#147): `true` in every node module, through the base; nest already set it"
|
|
142
|
-
},
|
|
143
|
-
fromBase: ["importHelpers", "target", "lib", "sourceMap"]
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
// src/roles/typescript/presets/react.json
|
|
147
|
-
var react_default = {
|
|
148
|
-
compilerOptions: {
|
|
149
|
-
target: "ES2023",
|
|
150
|
-
lib: ["ES2023", "DOM", "DOM.Iterable"],
|
|
151
|
-
module: "ESNext",
|
|
152
|
-
moduleResolution: "bundler",
|
|
153
|
-
jsx: "react-jsx",
|
|
154
|
-
useDefineForClassFields: true,
|
|
155
|
-
isolatedModules: true,
|
|
156
|
-
moduleDetection: "force",
|
|
157
|
-
noEmit: true,
|
|
158
|
-
noUncheckedSideEffectImports: true
|
|
159
|
-
},
|
|
160
|
-
notes: {
|
|
161
|
-
noEmit: "vite owns the build; tsc only typechecks here"
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// src/roles/typescript/presets/shared.json
|
|
166
|
-
var shared_default = {
|
|
167
|
-
$schema: "https://json.schemastore.org/tsconfig",
|
|
168
|
-
compilerOptions: {
|
|
169
|
-
strict: true,
|
|
170
|
-
noFallthroughCasesInSwitch: true,
|
|
171
|
-
forceConsistentCasingInFileNames: true,
|
|
172
|
-
esModuleInterop: true,
|
|
173
|
-
skipLibCheck: true,
|
|
174
|
-
verbatimModuleSyntax: true,
|
|
175
|
-
resolveJsonModule: true,
|
|
176
|
-
skipDefaultLibCheck: true
|
|
177
|
-
},
|
|
178
|
-
deferred: {
|
|
179
|
-
noImplicitAny: {
|
|
180
|
-
phase: 2,
|
|
181
|
-
reason: "the implicit-any migration (TS70xx)"
|
|
182
|
-
},
|
|
183
|
-
noUnusedLocals: {
|
|
184
|
-
phase: 2,
|
|
185
|
-
reason: "unused-local cleanup (TS6133)"
|
|
186
|
-
},
|
|
187
|
-
noUnusedParameters: {
|
|
188
|
-
phase: 2,
|
|
189
|
-
reason: "unused-parameter cleanup (TS6133)"
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
notes: {
|
|
193
|
-
verbatimModuleSyntax: "raised from tsconfig.base.json (HUB-43866, sentinel#147): every sentinel module applied `true` through the base, so a module that stops extending it keeps it. A module that sets `false` itself keeps its own value, and `--init` does not strip it (see fromBase)",
|
|
194
|
-
resolveJsonModule: "raised from tsconfig.base.json (sentinel#147): `true` in all 113 sentinel modules, through the base",
|
|
195
|
-
skipDefaultLibCheck: "raised from tsconfig.base.json (sentinel#147): `true` in all 113 sentinel modules, through the base"
|
|
196
|
-
},
|
|
197
|
-
fromBase: ["verbatimModuleSyntax", "resolveJsonModule", "skipDefaultLibCheck"]
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
// src/roles/typescript/preset-data.ts
|
|
201
|
-
var SHARED = shared_default;
|
|
202
|
-
var LAYERS = {
|
|
203
|
-
nest: nest_default,
|
|
204
|
-
node: node_default,
|
|
205
|
-
react: react_default
|
|
206
|
-
};
|
|
207
|
-
var LEGACY = legacy_default;
|
|
208
|
-
var LEGACY_LAYER = "legacy";
|
|
209
|
-
var SHIPPED_PRESETS = Object.keys(LAYERS).sort();
|
|
210
|
-
var DEFERRED_RULES = Object.entries(SHARED.deferred ?? {}).map(([rule, entry]) => ({ rule, phase: entry.phase, reason: entry.reason })).sort((left, right) => left.rule.localeCompare(right.rule));
|
|
211
|
-
function validate() {
|
|
212
|
-
for (const { rule, phase, reason } of DEFERRED_RULES) {
|
|
213
|
-
if (!Number.isInteger(phase) || phase < 2) {
|
|
214
|
-
throw new Error(
|
|
215
|
-
`deferred rule "${rule}" has phase ${phase}; a deferred rule is scheduled for phase 2 or later`
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
if (reason.trim() === "") {
|
|
219
|
-
throw new Error(
|
|
220
|
-
`deferred rule "${rule}" has no reason; --inspect reports it and would say nothing`
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
if (rule in SHARED.compilerOptions) {
|
|
224
|
-
throw new Error(
|
|
225
|
-
`"${rule}" is deferred and also set by the shared layer; it would be announced as not enforced while being enforced`
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
for (const [preset, layer] of Object.entries(LAYERS)) {
|
|
229
|
-
if (layer && rule in layer.compilerOptions) {
|
|
230
|
-
throw new Error(
|
|
231
|
-
`"${rule}" is deferred and also set by the ${preset} preset; it would be announced as not enforced while being enforced`
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
validate();
|
|
238
|
-
function tsLegacyLayer() {
|
|
239
|
-
return {
|
|
240
|
-
...LEGACY.$schema === void 0 ? {} : { $schema: LEGACY.$schema },
|
|
241
|
-
compilerOptions: { ...LEGACY.compilerOptions }
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
function raisedFromBase(preset) {
|
|
245
|
-
return [...SHARED.fromBase ?? [], ...LAYERS[preset]?.fromBase ?? []];
|
|
246
|
-
}
|
|
247
|
-
function hasShippedPreset(preset) {
|
|
248
|
-
return preset in LAYERS;
|
|
249
|
-
}
|
|
250
|
-
function tsPresetFor(preset) {
|
|
251
|
-
const layer = LAYERS[preset];
|
|
252
|
-
if (!layer) throw new Error(`no TypeScript preset ships for preset "${preset}"`);
|
|
253
|
-
return {
|
|
254
|
-
...SHARED.$schema === void 0 ? {} : { $schema: SHARED.$schema },
|
|
255
|
-
compilerOptions: { ...SHARED.compilerOptions, ...layer.compilerOptions }
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// src/roles/typescript/legacy.ts
|
|
260
|
-
var BASE_FILE = "tsconfig.base.json";
|
|
261
|
-
var LEGACY_ENTRY = `@hublo/sentinel/typescript/${LEGACY_LAYER}`;
|
|
262
|
-
function isLegacyEntry(entry) {
|
|
263
|
-
return entry === LEGACY_ENTRY;
|
|
264
|
-
}
|
|
265
|
-
var STACK_PRESET_PATTERN = new RegExp(
|
|
266
|
-
`^@hublo\\/sentinel\\/(?:typescript|tsconfig)\\/(?!${LEGACY_LAYER}$)[a-z-]+$`
|
|
267
|
-
);
|
|
268
|
-
function isBaseEntry(entry) {
|
|
269
|
-
return entry === BASE_FILE || entry.endsWith(`/${BASE_FILE}`);
|
|
270
|
-
}
|
|
271
|
-
function isStackPresetEntry(entry) {
|
|
272
|
-
return STACK_PRESET_PATTERN.test(entry);
|
|
273
|
-
}
|
|
274
|
-
function extendsList(config) {
|
|
275
|
-
const value = config.extends;
|
|
276
|
-
if (typeof value === "string") return [value];
|
|
277
|
-
return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
export {
|
|
281
|
-
comparable,
|
|
282
|
-
appliedOptions,
|
|
283
|
-
diffConfigs,
|
|
284
|
-
remainder,
|
|
285
|
-
SHIPPED_PRESETS,
|
|
286
|
-
DEFERRED_RULES,
|
|
287
|
-
tsLegacyLayer,
|
|
288
|
-
raisedFromBase,
|
|
289
|
-
hasShippedPreset,
|
|
290
|
-
tsPresetFor,
|
|
291
|
-
LEGACY_ENTRY,
|
|
292
|
-
isLegacyEntry,
|
|
293
|
-
STACK_PRESET_PATTERN,
|
|
294
|
-
isBaseEntry,
|
|
295
|
-
isStackPresetEntry,
|
|
296
|
-
extendsList
|
|
297
|
-
};
|