@hublo/sentinel 1.7.0-alpha.1 → 1.7.0-alpha.2
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 +74 -13
- package/dist/chunk-4UUL4SEW.js +50 -0
- package/dist/{chunk-XGMMTX2N.js → chunk-DLGBRLUU.js} +2 -2
- package/dist/{chunk-7CRRGBHI.js → chunk-EETHWJBF.js} +78 -21
- package/dist/{chunk-ZVHUG6CA.js → chunk-H4HAFJFZ.js} +4 -13
- package/dist/chunk-H4HAFJFZ.js.map +1 -0
- package/dist/{chunk-POZDYETY.js → chunk-LNFGVGLE.js} +5 -3
- package/dist/{chunk-POZDYETY.js.map → chunk-LNFGVGLE.js.map} +1 -1
- package/dist/chunk-QXFCZON7.js +16 -0
- package/dist/chunk-QXFCZON7.js.map +1 -0
- package/dist/{chunk-7E6YTTAK.js → chunk-THTXP2QU.js} +1 -1
- package/dist/chunk-THTXP2QU.js.map +1 -0
- package/dist/{chunk-4HYOGCOX.js → chunk-Z3JI7ZWX.js} +158 -199
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -4
- package/dist/migrate-NI33SXZD.js +517 -0
- package/dist/roles/build/nest/toolchain.js +3 -2
- 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.js +4 -3
- package/dist/roles/test/nest/toolchain.js.map +1 -1
- package/dist/roles/test/react/toolchain.js +4 -3
- package/dist/roles/test/react/toolchain.js.map +1 -1
- package/dist/roles/test/shared-test-config.js +4 -3
- package/dist/tsconfig/legacy.json +21 -0
- package/dist/tsconfig/nest.json +10 -1
- package/dist/tsconfig/node.json +11 -1
- package/dist/tsconfig/react.json +3 -0
- package/dist/{validate-LMGBKN6L.js → validate-LRHF63AW.js} +4 -2
- package/docs/typescript-adoption.md +52 -13
- package/docs/typescript-traces.md +1 -1
- package/package.json +4 -1
- package/dist/chunk-7E6YTTAK.js.map +0 -1
- package/dist/chunk-ZVHUG6CA.js.map +0 -1
- /package/dist/{chunk-XGMMTX2N.js.map → chunk-DLGBRLUU.js.map} +0 -0
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
binFromOwnInstall,
|
|
3
|
+
binSearchPath,
|
|
4
|
+
resolveBin
|
|
5
|
+
} from "./chunk-4UUL4SEW.js";
|
|
1
6
|
import {
|
|
2
7
|
DEFAULT_MAX_DIAGNOSTICS,
|
|
3
8
|
WORKSPACE_ROOT_MARKER,
|
|
@@ -13,9 +18,11 @@ import {
|
|
|
13
18
|
import {
|
|
14
19
|
WORKSPACE_TSCONFIG,
|
|
15
20
|
chainPaths,
|
|
16
|
-
effectivePaths
|
|
21
|
+
effectivePaths
|
|
22
|
+
} from "./chunk-H4HAFJFZ.js";
|
|
23
|
+
import {
|
|
17
24
|
parseJsonc
|
|
18
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-QXFCZON7.js";
|
|
19
26
|
|
|
20
27
|
// src/core/base-adapter.ts
|
|
21
28
|
var BaseAdapter = class {
|
|
@@ -401,53 +408,9 @@ function moduleEnvironment(cwd) {
|
|
|
401
408
|
// src/roles/test/reference.ts
|
|
402
409
|
import { execFileSync } from "node:child_process";
|
|
403
410
|
import { createHash } from "node:crypto";
|
|
404
|
-
import { existsSync as
|
|
411
|
+
import { existsSync as existsSync5, mkdirSync, mkdtempSync, readFileSync as readFileSync5, rmSync, writeFileSync } from "node:fs";
|
|
405
412
|
import { tmpdir } from "node:os";
|
|
406
|
-
import { join as
|
|
407
|
-
|
|
408
|
-
// src/shared/resolve-bin.ts
|
|
409
|
-
import { existsSync as existsSync5 } from "node:fs";
|
|
410
|
-
import { createRequire } from "node:module";
|
|
411
|
-
import { delimiter, dirname, join as join5 } from "node:path";
|
|
412
|
-
var require2 = createRequire(import.meta.url);
|
|
413
|
-
function resolveBin(fromDir, name) {
|
|
414
|
-
let dir = fromDir;
|
|
415
|
-
for (; ; ) {
|
|
416
|
-
const candidate = join5(dir, "node_modules", ".bin", name);
|
|
417
|
-
if (existsSync5(candidate)) return candidate;
|
|
418
|
-
const parent = dirname(dir);
|
|
419
|
-
if (parent === dir) return void 0;
|
|
420
|
-
dir = parent;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
function binFromOwnInstall(packageName, binName) {
|
|
424
|
-
try {
|
|
425
|
-
const manifest = require2.resolve(`${packageName}/package.json`);
|
|
426
|
-
const bin = require2(manifest).bin;
|
|
427
|
-
const relative8 = typeof bin === "string" ? bin : bin?.[binName];
|
|
428
|
-
if (!relative8) return void 0;
|
|
429
|
-
const executable = join5(dirname(manifest), relative8);
|
|
430
|
-
return existsSync5(executable) ? executable : void 0;
|
|
431
|
-
} catch {
|
|
432
|
-
return void 0;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
function binSearchPath(cwd) {
|
|
436
|
-
return [`${cwd}${delimiter}node_modules/.bin (and parents)`, "sentinel's own install"].join(
|
|
437
|
-
" then "
|
|
438
|
-
);
|
|
439
|
-
}
|
|
440
|
-
function scriptPath(cwd, path) {
|
|
441
|
-
const bins = [];
|
|
442
|
-
let dir = cwd;
|
|
443
|
-
for (; ; ) {
|
|
444
|
-
bins.push(join5(dir, "node_modules", ".bin"));
|
|
445
|
-
const parent = dirname(dir);
|
|
446
|
-
if (parent === dir) break;
|
|
447
|
-
dir = parent;
|
|
448
|
-
}
|
|
449
|
-
return [...bins, path].filter(Boolean).join(delimiter);
|
|
450
|
-
}
|
|
413
|
+
import { join as join5, resolve as resolve2 } from "node:path";
|
|
451
414
|
|
|
452
415
|
// src/roles/test/baseline.ts
|
|
453
416
|
function readSnapshot(report) {
|
|
@@ -715,7 +678,7 @@ function describeComparison(comparison) {
|
|
|
715
678
|
// src/roles/test/reference.ts
|
|
716
679
|
function referencePath(cwd, suite) {
|
|
717
680
|
const key = createHash("sha256").update(`${resolve2(cwd)}\0${suite}`).digest("hex").slice(0, 16);
|
|
718
|
-
return
|
|
681
|
+
return join5(tmpdir(), "sentinel-test-reference", `${key}.json`);
|
|
719
682
|
}
|
|
720
683
|
function suiteOf(config) {
|
|
721
684
|
const base = config.replace(/^(jest|vitest)\./, "").replace(/\.[cm]?[jt]s$/, "");
|
|
@@ -726,9 +689,9 @@ function runJest(cwd, config) {
|
|
|
726
689
|
const bin = resolveBin(cwd, "jest");
|
|
727
690
|
if (bin === void 0) return void 0;
|
|
728
691
|
const root = findWorkspaceRoot(cwd) ?? cwd;
|
|
729
|
-
const out =
|
|
692
|
+
const out = join5(mkdtempSync(join5(tmpdir(), "sentinel-reference-")), "jest.json");
|
|
730
693
|
try {
|
|
731
|
-
execFileSync(bin, ["-c",
|
|
694
|
+
execFileSync(bin, ["-c", join5(cwd, config), "--json", `--outputFile=${out}`, "--silent"], {
|
|
732
695
|
cwd: root,
|
|
733
696
|
/*
|
|
734
697
|
* ⚠️ The module's environment, not the shell's, and this is what made the reference lie.
|
|
@@ -743,7 +706,7 @@ function runJest(cwd, config) {
|
|
|
743
706
|
});
|
|
744
707
|
} catch {
|
|
745
708
|
}
|
|
746
|
-
if (!
|
|
709
|
+
if (!existsSync5(out)) return void 0;
|
|
747
710
|
try {
|
|
748
711
|
return JSON.parse(readFileSync5(out, "utf8"));
|
|
749
712
|
} catch {
|
|
@@ -776,7 +739,7 @@ function captureReference(cwd, config) {
|
|
|
776
739
|
snapshot
|
|
777
740
|
};
|
|
778
741
|
const path = referencePath(cwd, suiteOf(config));
|
|
779
|
-
mkdirSync(
|
|
742
|
+
mkdirSync(join5(path, ".."), { recursive: true });
|
|
780
743
|
writeFileSync(path, `${JSON.stringify(stored, void 0, 2)}
|
|
781
744
|
`);
|
|
782
745
|
return {
|
|
@@ -785,7 +748,7 @@ function captureReference(cwd, config) {
|
|
|
785
748
|
};
|
|
786
749
|
}
|
|
787
750
|
function hasReference(cwd, suite) {
|
|
788
|
-
return
|
|
751
|
+
return existsSync5(referencePath(cwd, suite));
|
|
789
752
|
}
|
|
790
753
|
function compareAgainstReference(cwd, suite, report) {
|
|
791
754
|
const path = referencePath(cwd, suite);
|
|
@@ -815,9 +778,9 @@ function resolveVitest(cwd) {
|
|
|
815
778
|
|
|
816
779
|
// src/roles/test/adapters/vitest/vitest.adapter.ts
|
|
817
780
|
import { spawnSync } from "node:child_process";
|
|
818
|
-
import { existsSync as
|
|
781
|
+
import { existsSync as existsSync24, mkdtempSync as mkdtempSync3, readFileSync as readFileSync25, writeFileSync as writeFileSync2 } from "node:fs";
|
|
819
782
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
820
|
-
import { isAbsolute as isAbsolute2, join as
|
|
783
|
+
import { isAbsolute as isAbsolute2, join as join31, relative as relative7, resolve as resolve10 } from "node:path";
|
|
821
784
|
|
|
822
785
|
// src/roles/test/ordering-is-a-permutation.ts
|
|
823
786
|
function isAnImport(line) {
|
|
@@ -842,15 +805,15 @@ function lineLostByTheFixer(before, after) {
|
|
|
842
805
|
}
|
|
843
806
|
|
|
844
807
|
// src/core/config/nx-target.ts
|
|
845
|
-
import { existsSync as
|
|
846
|
-
import { join as
|
|
808
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
809
|
+
import { join as join7 } from "node:path";
|
|
847
810
|
|
|
848
811
|
// src/core/config/project-json.ts
|
|
849
|
-
import { existsSync as
|
|
850
|
-
import { join as
|
|
812
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6 } from "node:fs";
|
|
813
|
+
import { join as join6 } from "node:path";
|
|
851
814
|
function projectTargets(cwd) {
|
|
852
|
-
const path =
|
|
853
|
-
if (!
|
|
815
|
+
const path = join6(cwd, "project.json");
|
|
816
|
+
if (!existsSync6(path)) return void 0;
|
|
854
817
|
try {
|
|
855
818
|
return JSON.parse(readFileSync6(path, "utf8")).targets;
|
|
856
819
|
} catch {
|
|
@@ -903,7 +866,7 @@ function nxTargetOperations(options) {
|
|
|
903
866
|
if (names.length === 0) return [];
|
|
904
867
|
const targets = withTeamInputs(cwd, options.targets);
|
|
905
868
|
const operations = [];
|
|
906
|
-
if (
|
|
869
|
+
if (existsSync7(join7(cwd, "project.json"))) {
|
|
907
870
|
operations.push({
|
|
908
871
|
kind: "remove-json-keys",
|
|
909
872
|
path: "project.json",
|
|
@@ -1007,24 +970,24 @@ function rewriteToolchainImports(toolchain, source, fileName) {
|
|
|
1007
970
|
}
|
|
1008
971
|
|
|
1009
972
|
// src/roles/test/jest-migration.ts
|
|
1010
|
-
import { existsSync as
|
|
1011
|
-
import { createRequire as
|
|
1012
|
-
import { dirname as
|
|
973
|
+
import { existsSync as existsSync18, readFileSync as readFileSync20, readdirSync as readdirSync6 } from "node:fs";
|
|
974
|
+
import { createRequire as createRequire4 } from "node:module";
|
|
975
|
+
import { dirname as dirname11, join as join24, relative as relative6 } from "node:path";
|
|
1013
976
|
|
|
1014
977
|
// src/roles/test/codemod/migrate-module.ts
|
|
1015
978
|
import { readdirSync as readdirSync4, readFileSync as readFileSync15, statSync as statSync5 } from "node:fs";
|
|
1016
|
-
import { join as
|
|
979
|
+
import { join as join17 } from "node:path";
|
|
1017
980
|
import { parseSync as parseSync9 } from "oxc-parser";
|
|
1018
981
|
|
|
1019
982
|
// src/roles/test/msw-lifecycle.ts
|
|
1020
|
-
import { existsSync as
|
|
1021
|
-
import { join as
|
|
983
|
+
import { existsSync as existsSync8, readFileSync as readFileSync7 } from "node:fs";
|
|
984
|
+
import { join as join8 } from "node:path";
|
|
1022
985
|
var ROOT_SETUP = "jest.setup.after.env.js";
|
|
1023
986
|
function ownsMswLifecycle(cwd, setupFiles) {
|
|
1024
987
|
for (const raw of setupFiles) {
|
|
1025
988
|
if (raw.endsWith(ROOT_SETUP)) continue;
|
|
1026
|
-
const file =
|
|
1027
|
-
if (!
|
|
989
|
+
const file = join8(cwd, raw.replaceAll("<rootDir>/", "").replaceAll("<rootDir>", "."));
|
|
990
|
+
if (!existsSync8(file)) continue;
|
|
1028
991
|
try {
|
|
1029
992
|
if (/\.listen\s*\(/.test(readFileSync7(file, "utf8"))) return true;
|
|
1030
993
|
} catch {
|
|
@@ -1046,7 +1009,7 @@ function vitestSupportName(relative8) {
|
|
|
1046
1009
|
}
|
|
1047
1010
|
|
|
1048
1011
|
// src/roles/test/codemod/inherited-automocks.ts
|
|
1049
|
-
import { existsSync as
|
|
1012
|
+
import { existsSync as existsSync9, readFileSync as readFileSync8 } from "node:fs";
|
|
1050
1013
|
import { resolve as resolve3 } from "node:path";
|
|
1051
1014
|
|
|
1052
1015
|
// src/shared/ast.ts
|
|
@@ -1090,7 +1053,7 @@ function inheritedAutomocks(cwd, setupFiles, parse6) {
|
|
|
1090
1053
|
for (const named of setupFiles) {
|
|
1091
1054
|
const path = resolve3(cwd, named.replace("<rootDir>/", "./"));
|
|
1092
1055
|
if (path.startsWith(`${cwd}/`)) continue;
|
|
1093
|
-
if (!
|
|
1056
|
+
if (!existsSync9(path)) continue;
|
|
1094
1057
|
let source;
|
|
1095
1058
|
try {
|
|
1096
1059
|
source = readFileSync8(path, "utf8");
|
|
@@ -1359,7 +1322,7 @@ ${source}`;
|
|
|
1359
1322
|
}
|
|
1360
1323
|
|
|
1361
1324
|
// src/roles/test/codemod/migrate-file.ts
|
|
1362
|
-
import { dirname as
|
|
1325
|
+
import { dirname as dirname7 } from "node:path";
|
|
1363
1326
|
import { parseSync as parseSync8 } from "oxc-parser";
|
|
1364
1327
|
|
|
1365
1328
|
// src/roles/test/codemod/edits.ts
|
|
@@ -2145,9 +2108,9 @@ function asyncifyEdits(source, fn) {
|
|
|
2145
2108
|
}
|
|
2146
2109
|
|
|
2147
2110
|
// src/roles/test/codemod/named-rules.ts
|
|
2148
|
-
import { existsSync as
|
|
2149
|
-
import { createRequire
|
|
2150
|
-
import { dirname as
|
|
2111
|
+
import { existsSync as existsSync10, readFileSync as readFileSync10 } from "node:fs";
|
|
2112
|
+
import { createRequire } from "node:module";
|
|
2113
|
+
import { dirname as dirname2, join as join10 } from "node:path";
|
|
2151
2114
|
|
|
2152
2115
|
// src/roles/test/codemod/namespace-import.ts
|
|
2153
2116
|
function sameModule(specifier) {
|
|
@@ -2217,7 +2180,7 @@ function namespaceBindings(program) {
|
|
|
2217
2180
|
|
|
2218
2181
|
// src/roles/test/codemod/static-import-for-require.ts
|
|
2219
2182
|
import { readFileSync as readFileSync9, statSync } from "node:fs";
|
|
2220
|
-
import { dirname
|
|
2183
|
+
import { dirname, join as join9, resolve as resolve4 } from "node:path";
|
|
2221
2184
|
import { parseSync as parseSync4 } from "oxc-parser";
|
|
2222
2185
|
|
|
2223
2186
|
// src/shared/module-resolution.ts
|
|
@@ -2234,11 +2197,11 @@ var RESOLVABLE_EXTENSIONS = [
|
|
|
2234
2197
|
|
|
2235
2198
|
// src/roles/test/codemod/static-import-for-require.ts
|
|
2236
2199
|
function resolveRelative(fromFile, specifier) {
|
|
2237
|
-
const base = resolve4(
|
|
2200
|
+
const base = resolve4(dirname(fromFile), specifier);
|
|
2238
2201
|
const candidates = [
|
|
2239
2202
|
base,
|
|
2240
2203
|
...RESOLVABLE_EXTENSIONS.map((extension) => `${base}${extension}`),
|
|
2241
|
-
...RESOLVABLE_EXTENSIONS.map((extension) =>
|
|
2204
|
+
...RESOLVABLE_EXTENSIONS.map((extension) => join9(base, `index${extension}`))
|
|
2242
2205
|
];
|
|
2243
2206
|
for (const candidate of candidates) {
|
|
2244
2207
|
try {
|
|
@@ -2440,24 +2403,24 @@ function isCommonJsPackage(fromFile, specifier) {
|
|
|
2440
2403
|
if (specifier.startsWith(".") || specifier.startsWith("/")) return false;
|
|
2441
2404
|
let resolved;
|
|
2442
2405
|
try {
|
|
2443
|
-
resolved =
|
|
2406
|
+
resolved = createRequire(fromFile).resolve(specifier);
|
|
2444
2407
|
} catch {
|
|
2445
2408
|
return false;
|
|
2446
2409
|
}
|
|
2447
2410
|
if (!resolved.includes(`${"/"}node_modules${"/"}`)) return false;
|
|
2448
2411
|
if (resolved.endsWith(".mjs")) return false;
|
|
2449
2412
|
if (resolved.endsWith(".cjs")) return true;
|
|
2450
|
-
let dir =
|
|
2413
|
+
let dir = dirname2(resolved);
|
|
2451
2414
|
for (let depth = 0; depth < 12; depth += 1) {
|
|
2452
|
-
const manifest =
|
|
2453
|
-
if (
|
|
2415
|
+
const manifest = join10(dir, "package.json");
|
|
2416
|
+
if (existsSync10(manifest)) {
|
|
2454
2417
|
try {
|
|
2455
2418
|
return JSON.parse(readFileSync10(manifest, "utf8")).type !== "module";
|
|
2456
2419
|
} catch {
|
|
2457
2420
|
return false;
|
|
2458
2421
|
}
|
|
2459
2422
|
}
|
|
2460
|
-
const parent =
|
|
2423
|
+
const parent = dirname2(dir);
|
|
2461
2424
|
if (parent === dir) break;
|
|
2462
2425
|
dir = parent;
|
|
2463
2426
|
}
|
|
@@ -3328,8 +3291,8 @@ function propagateAwait(fileName, source, original, elsewhere = /* @__PURE__ */
|
|
|
3328
3291
|
|
|
3329
3292
|
// src/roles/test/codemod/reexport-barrel-mock.ts
|
|
3330
3293
|
import { readFileSync as readFileSync11, readdirSync as readdirSync2, statSync as statSync2 } from "node:fs";
|
|
3331
|
-
import { createRequire as
|
|
3332
|
-
import { dirname as
|
|
3294
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
3295
|
+
import { dirname as dirname3, join as join11 } from "node:path";
|
|
3333
3296
|
var PACKAGE_SUBPATH = /^(@[^/]+\/[^/]+|[^@.][^/]*)\/(.+)$/;
|
|
3334
3297
|
var PURE_REEXPORT = /^module\.exports\s*=\s*require\(\s*(['"])([^'"]+)\1\s*\)\s*;?$/;
|
|
3335
3298
|
function mockCalls(program) {
|
|
@@ -3357,14 +3320,14 @@ function mockCalls(program) {
|
|
|
3357
3320
|
}
|
|
3358
3321
|
function packageRoot(fromFile, name) {
|
|
3359
3322
|
try {
|
|
3360
|
-
return
|
|
3323
|
+
return dirname3(createRequire2(fromFile).resolve(`${name}/package.json`));
|
|
3361
3324
|
} catch {
|
|
3362
3325
|
return void 0;
|
|
3363
3326
|
}
|
|
3364
3327
|
}
|
|
3365
3328
|
function resolveFrom(fromFile, specifier) {
|
|
3366
3329
|
try {
|
|
3367
|
-
return
|
|
3330
|
+
return createRequire2(fromFile).resolve(specifier);
|
|
3368
3331
|
} catch {
|
|
3369
3332
|
return void 0;
|
|
3370
3333
|
}
|
|
@@ -3381,7 +3344,7 @@ function barrelsFor(fromFile, name, target) {
|
|
|
3381
3344
|
const aliases = [];
|
|
3382
3345
|
for (const entry of entries) {
|
|
3383
3346
|
if (!entry.endsWith(".js")) continue;
|
|
3384
|
-
const path =
|
|
3347
|
+
const path = join11(root, entry);
|
|
3385
3348
|
let body;
|
|
3386
3349
|
try {
|
|
3387
3350
|
if (!statSync2(path).isFile()) continue;
|
|
@@ -3484,17 +3447,17 @@ function rewriteRunnerArtefactNames(source, program) {
|
|
|
3484
3447
|
}
|
|
3485
3448
|
|
|
3486
3449
|
// src/roles/test/codemod/setup-static-imports.ts
|
|
3487
|
-
import { dirname as
|
|
3450
|
+
import { dirname as dirname5, resolve as resolve7 } from "node:path";
|
|
3488
3451
|
|
|
3489
3452
|
// src/core/context.ts
|
|
3490
|
-
import { existsSync as
|
|
3491
|
-
import { dirname as
|
|
3453
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
3454
|
+
import { dirname as dirname4, join as join13, resolve as resolve5 } from "node:path";
|
|
3492
3455
|
|
|
3493
3456
|
// src/core/discover-modules.ts
|
|
3494
3457
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
3495
3458
|
import { mkdtempSync as mkdtempSync2, readFileSync as readFileSync12, rmSync as rmSync2 } from "node:fs";
|
|
3496
3459
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
3497
|
-
import { join as
|
|
3460
|
+
import { join as join12 } from "node:path";
|
|
3498
3461
|
function runNx(cwd, args) {
|
|
3499
3462
|
const nx = resolveBin(cwd, "nx") ?? "nx";
|
|
3500
3463
|
try {
|
|
@@ -3512,8 +3475,8 @@ function runNx(cwd, args) {
|
|
|
3512
3475
|
}
|
|
3513
3476
|
}
|
|
3514
3477
|
function readGraph(cwd) {
|
|
3515
|
-
const dir = mkdtempSync2(
|
|
3516
|
-
const file =
|
|
3478
|
+
const dir = mkdtempSync2(join12(tmpdir2(), "sentinel-nx-"));
|
|
3479
|
+
const file = join12(dir, "graph.json");
|
|
3517
3480
|
try {
|
|
3518
3481
|
runNx(cwd, ["graph", "--file", file]);
|
|
3519
3482
|
const parsed = JSON.parse(readFileSync12(file, "utf8"));
|
|
@@ -3525,7 +3488,7 @@ function readGraph(cwd) {
|
|
|
3525
3488
|
}
|
|
3526
3489
|
return Object.entries(nodes).map(([name, node]) => ({
|
|
3527
3490
|
name,
|
|
3528
|
-
root:
|
|
3491
|
+
root: join12(cwd, node.data.root)
|
|
3529
3492
|
}));
|
|
3530
3493
|
} finally {
|
|
3531
3494
|
rmSync2(dir, { recursive: true, force: true });
|
|
@@ -3566,20 +3529,20 @@ ${raw.slice(0, 300)}`
|
|
|
3566
3529
|
// src/core/context.ts
|
|
3567
3530
|
var MODULE_MARKERS = ["package.json", "project.json"];
|
|
3568
3531
|
function isModuleDir(cwd) {
|
|
3569
|
-
return MODULE_MARKERS.some((marker) =>
|
|
3532
|
+
return MODULE_MARKERS.some((marker) => existsSync11(join13(cwd, marker)));
|
|
3570
3533
|
}
|
|
3571
3534
|
function findModuleRoot(startDir, workspaceRoot) {
|
|
3572
3535
|
let dir = resolve5(startDir);
|
|
3573
3536
|
for (; ; ) {
|
|
3574
3537
|
if (workspaceRoot !== void 0 && dir === resolve5(workspaceRoot)) return void 0;
|
|
3575
3538
|
if (isModuleDir(dir)) return dir;
|
|
3576
|
-
const parent =
|
|
3539
|
+
const parent = dirname4(dir);
|
|
3577
3540
|
if (parent === dir) return void 0;
|
|
3578
3541
|
dir = parent;
|
|
3579
3542
|
}
|
|
3580
3543
|
}
|
|
3581
3544
|
function resolveContext(cwd, opts) {
|
|
3582
|
-
const atRoot =
|
|
3545
|
+
const atRoot = existsSync11(join13(cwd, WORKSPACE_ROOT_MARKER));
|
|
3583
3546
|
if (!atRoot && isModuleDir(cwd)) {
|
|
3584
3547
|
if (opts.module) {
|
|
3585
3548
|
throw new Error(
|
|
@@ -3607,15 +3570,15 @@ function resolveContext(cwd, opts) {
|
|
|
3607
3570
|
}
|
|
3608
3571
|
|
|
3609
3572
|
// src/roles/test/codemod/workspace-specifier.ts
|
|
3610
|
-
import { existsSync as
|
|
3611
|
-
import { join as
|
|
3573
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
3574
|
+
import { join as join14, relative as relative2, resolve as resolve6 } from "node:path";
|
|
3612
3575
|
var EXTENSIONS = ["", ".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", "/index.ts", "/index.js"];
|
|
3613
3576
|
var SPEC_TSCONFIGS = ["tsconfig.spec.json", "tsconfig.app.json", "tsconfig.json"];
|
|
3614
3577
|
function pathsFor(workspaceRoot, moduleRoot) {
|
|
3615
3578
|
try {
|
|
3616
3579
|
if (moduleRoot !== void 0) return effectivePaths(moduleRoot, workspaceRoot, SPEC_TSCONFIGS);
|
|
3617
|
-
const file =
|
|
3618
|
-
if (!
|
|
3580
|
+
const file = join14(workspaceRoot, WORKSPACE_TSCONFIG);
|
|
3581
|
+
if (!existsSync12(file)) return void 0;
|
|
3619
3582
|
const found = chainPaths(file);
|
|
3620
3583
|
return found && { ...found, fromWorkspaceFallback: false };
|
|
3621
3584
|
} catch {
|
|
@@ -3668,7 +3631,7 @@ function requireCall(source, node) {
|
|
|
3668
3631
|
}
|
|
3669
3632
|
function importable(written, fileName, workspaceRoot) {
|
|
3670
3633
|
if (!written.startsWith(".")) return written;
|
|
3671
|
-
const fileDir =
|
|
3634
|
+
const fileDir = dirname5(fileName);
|
|
3672
3635
|
const moduleRoot = findModuleRoot(fileDir, workspaceRoot) ?? fileDir;
|
|
3673
3636
|
const target = resolve7(fileDir, written);
|
|
3674
3637
|
if (target.startsWith(`${moduleRoot}/`)) return written;
|
|
@@ -3785,15 +3748,15 @@ function rewriteMockFactoryGenerics(source, program) {
|
|
|
3785
3748
|
|
|
3786
3749
|
// src/roles/test/codemod/spy-on-internal-call.ts
|
|
3787
3750
|
import { readFileSync as readFileSync13, statSync as statSync3 } from "node:fs";
|
|
3788
|
-
import { dirname as
|
|
3751
|
+
import { dirname as dirname6, join as join15, relative as relative3, resolve as resolve8 } from "node:path";
|
|
3789
3752
|
import { parseSync as parseSync7 } from "oxc-parser";
|
|
3790
3753
|
function resolveRelative2(fromFile, specifier) {
|
|
3791
3754
|
if (!specifier.startsWith(".")) return void 0;
|
|
3792
|
-
const base = resolve8(
|
|
3755
|
+
const base = resolve8(dirname6(fromFile), specifier);
|
|
3793
3756
|
const candidates = [
|
|
3794
3757
|
base,
|
|
3795
3758
|
...RESOLVABLE_EXTENSIONS.map((extension) => `${base}${extension}`),
|
|
3796
|
-
...RESOLVABLE_EXTENSIONS.map((extension) =>
|
|
3759
|
+
...RESOLVABLE_EXTENSIONS.map((extension) => join15(base, `index${extension}`))
|
|
3797
3760
|
];
|
|
3798
3761
|
for (const candidate of candidates) {
|
|
3799
3762
|
try {
|
|
@@ -3926,7 +3889,7 @@ function importOf(program, local) {
|
|
|
3926
3889
|
return void 0;
|
|
3927
3890
|
}
|
|
3928
3891
|
function respell(fromFile, target) {
|
|
3929
|
-
const path = relative3(
|
|
3892
|
+
const path = relative3(dirname6(fromFile), target).replaceAll("\\", "/").replace(/\.(?:m|c)?[jt]sx?$/, "").replace(/\/index$/, "");
|
|
3930
3893
|
return path.startsWith(".") ? path : `./${path}`;
|
|
3931
3894
|
}
|
|
3932
3895
|
function namesInUse2(program) {
|
|
@@ -4239,7 +4202,7 @@ function migrateTestFile(fileName, source, defaultImported = /* @__PURE__ */ new
|
|
|
4239
4202
|
fileName,
|
|
4240
4203
|
source,
|
|
4241
4204
|
beforeStatic,
|
|
4242
|
-
findWorkspaceRoot(
|
|
4205
|
+
findWorkspaceRoot(dirname7(fileName))
|
|
4243
4206
|
);
|
|
4244
4207
|
source = statics.source;
|
|
4245
4208
|
const original = statics.rewritten === 0 ? beforeStatic : parse3(fileName, source);
|
|
@@ -4377,8 +4340,8 @@ function migrateTestFile(fileName, source, defaultImported = /* @__PURE__ */ new
|
|
|
4377
4340
|
}
|
|
4378
4341
|
|
|
4379
4342
|
// src/roles/test/codemod/test-support-files.ts
|
|
4380
|
-
import { existsSync as
|
|
4381
|
-
import { dirname as
|
|
4343
|
+
import { existsSync as existsSync13, readFileSync as readFileSync14, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
|
|
4344
|
+
import { dirname as dirname8, join as join16, relative as relative4, resolve as resolve9 } from "node:path";
|
|
4382
4345
|
var THE_SHIM_CANNOT_ANSWER = [/\brequire\s*\(/, /\bjest\.(?:fn|Mock|SpyInstance)\s*</];
|
|
4383
4346
|
var SKIPPED = /* @__PURE__ */ new Set(["node_modules", "dist", "coverage", ".git", ".vite"]);
|
|
4384
4347
|
var TEST_FILE2 = /[.-](spec|test)\.[cm]?[jt]sx?$/;
|
|
@@ -4398,14 +4361,14 @@ function relativeSpecifiers2(source) {
|
|
|
4398
4361
|
return found;
|
|
4399
4362
|
}
|
|
4400
4363
|
function resolveSpecifier(fromFile, specifier) {
|
|
4401
|
-
const base = resolve9(
|
|
4402
|
-
if (
|
|
4364
|
+
const base = resolve9(dirname8(fromFile), specifier);
|
|
4365
|
+
if (existsSync13(base) && statSync4(base).isFile()) return base;
|
|
4403
4366
|
for (const extension of EXTENSIONS2) {
|
|
4404
|
-
if (
|
|
4367
|
+
if (existsSync13(`${base}${extension}`)) return `${base}${extension}`;
|
|
4405
4368
|
}
|
|
4406
4369
|
for (const extension of EXTENSIONS2) {
|
|
4407
|
-
const index =
|
|
4408
|
-
if (
|
|
4370
|
+
const index = join16(base, `index${extension}`);
|
|
4371
|
+
if (existsSync13(index)) return index;
|
|
4409
4372
|
}
|
|
4410
4373
|
return void 0;
|
|
4411
4374
|
}
|
|
@@ -4422,9 +4385,9 @@ function moduleSources(cwd) {
|
|
|
4422
4385
|
}
|
|
4423
4386
|
for (const entry of entries) {
|
|
4424
4387
|
if (entry.isDirectory()) {
|
|
4425
|
-
if (!SKIPPED.has(entry.name)) stack.push(
|
|
4388
|
+
if (!SKIPPED.has(entry.name)) stack.push(join16(dir, entry.name));
|
|
4426
4389
|
} else if (SOURCE_FILE.test(entry.name)) {
|
|
4427
|
-
found.push(
|
|
4390
|
+
found.push(join16(dir, entry.name));
|
|
4428
4391
|
}
|
|
4429
4392
|
}
|
|
4430
4393
|
}
|
|
@@ -4444,7 +4407,7 @@ function setupFilesInside(cwd, named) {
|
|
|
4444
4407
|
const full = resolve9(cwd, withoutToken);
|
|
4445
4408
|
const inside = relative4(cwd, full);
|
|
4446
4409
|
if (inside.startsWith("..") || inside === "") continue;
|
|
4447
|
-
if (!
|
|
4410
|
+
if (!existsSync13(full)) continue;
|
|
4448
4411
|
kept.push(inside.replaceAll("\\", "/"));
|
|
4449
4412
|
}
|
|
4450
4413
|
return kept;
|
|
@@ -4508,7 +4471,7 @@ function defaultImportedSpecifiers(cwd) {
|
|
|
4508
4471
|
}
|
|
4509
4472
|
for (const entry of entries) {
|
|
4510
4473
|
if (SKIPPED2.has(entry)) continue;
|
|
4511
|
-
const path =
|
|
4474
|
+
const path = join17(dir, entry);
|
|
4512
4475
|
let directory;
|
|
4513
4476
|
try {
|
|
4514
4477
|
directory = statSync5(path).isDirectory();
|
|
@@ -4540,13 +4503,13 @@ function migrateModuleTests(cwd, setupFiles = []) {
|
|
|
4540
4503
|
const defaultImported = defaultImportedSpecifiers(cwd);
|
|
4541
4504
|
const asyncHelpers = /* @__PURE__ */ new Set();
|
|
4542
4505
|
for (const relative8 of listTestSupportFiles(cwd, setupFiles)) {
|
|
4543
|
-
const source = read3(
|
|
4506
|
+
const source = read3(join17(cwd, relative8));
|
|
4544
4507
|
if (source === void 0) {
|
|
4545
4508
|
blockers.push({ file: relative8, reason: "this file could not be read" });
|
|
4546
4509
|
continue;
|
|
4547
4510
|
}
|
|
4548
4511
|
const migrated = migrateTestFile(
|
|
4549
|
-
|
|
4512
|
+
join17(cwd, relative8),
|
|
4550
4513
|
source,
|
|
4551
4514
|
defaultImported,
|
|
4552
4515
|
/* @__PURE__ */ new Set(),
|
|
@@ -4565,8 +4528,8 @@ function migrateModuleTests(cwd, setupFiles = []) {
|
|
|
4565
4528
|
const renamedTo = vitestSupportName(relative8);
|
|
4566
4529
|
if (!migrated.changed && renamedTo === relative8) continue;
|
|
4567
4530
|
if (renamedTo !== relative8) operations.push({ kind: "delete", path: relative8 });
|
|
4568
|
-
const before = parse4(
|
|
4569
|
-
const after = parse4(
|
|
4531
|
+
const before = parse4(join17(cwd, relative8), source);
|
|
4532
|
+
const after = parse4(join17(cwd, relative8), migrated.source);
|
|
4570
4533
|
if (before !== void 0 && after !== void 0) {
|
|
4571
4534
|
const wasAsync = asyncFunctionNames(before);
|
|
4572
4535
|
for (const name of asyncFunctionNames(after)) {
|
|
@@ -4575,17 +4538,17 @@ function migrateModuleTests(cwd, setupFiles = []) {
|
|
|
4575
4538
|
}
|
|
4576
4539
|
files++;
|
|
4577
4540
|
renamed += migrated.renamed;
|
|
4578
|
-
const contents = /\bvi\./.test(migrated.source) ? injectViImport(
|
|
4541
|
+
const contents = /\bvi\./.test(migrated.source) ? injectViImport(join17(cwd, renamedTo), migrated.source) : migrated.source;
|
|
4579
4542
|
operations.push({ kind: "write", path: renamedTo, contents });
|
|
4580
4543
|
}
|
|
4581
4544
|
for (const relative8 of listTestFiles(cwd)) {
|
|
4582
|
-
const source = read3(
|
|
4545
|
+
const source = read3(join17(cwd, relative8));
|
|
4583
4546
|
if (source === void 0) {
|
|
4584
4547
|
blockers.push({ file: relative8, reason: "this file could not be read" });
|
|
4585
4548
|
continue;
|
|
4586
4549
|
}
|
|
4587
4550
|
const migrated = migrateTestFile(
|
|
4588
|
-
|
|
4551
|
+
join17(cwd, relative8),
|
|
4589
4552
|
source,
|
|
4590
4553
|
defaultImported,
|
|
4591
4554
|
asyncHelpers,
|
|
@@ -4620,7 +4583,7 @@ function migrateModuleTests(cwd, setupFiles = []) {
|
|
|
4620
4583
|
|
|
4621
4584
|
// src/roles/test/nest/generate-config.ts
|
|
4622
4585
|
import { readdirSync as readdirSync5, readFileSync as readFileSync16, statSync as statSync6 } from "node:fs";
|
|
4623
|
-
import { join as
|
|
4586
|
+
import { join as join18, relative as relative5 } from "node:path";
|
|
4624
4587
|
import { parseSync as parseSync10 } from "oxc-parser";
|
|
4625
4588
|
var NEST_TEST_PRESET_SPECIFIER = "@hublo/sentinel/test/nest";
|
|
4626
4589
|
var REACT_TEST_PRESET_SPECIFIER = "@hublo/sentinel/test/react";
|
|
@@ -4667,7 +4630,7 @@ function readModuleTraits(cwd) {
|
|
|
4667
4630
|
}
|
|
4668
4631
|
for (const entry of entries) {
|
|
4669
4632
|
if (SKIPPED3.has(entry)) continue;
|
|
4670
|
-
const path =
|
|
4633
|
+
const path = join18(dir, entry);
|
|
4671
4634
|
let directory;
|
|
4672
4635
|
try {
|
|
4673
4636
|
directory = statSync6(path).isDirectory();
|
|
@@ -4822,8 +4785,8 @@ ${overrides.join("\n")}
|
|
|
4822
4785
|
}
|
|
4823
4786
|
|
|
4824
4787
|
// src/roles/test/nest/read-jest-config.ts
|
|
4825
|
-
import { existsSync as
|
|
4826
|
-
import { join as
|
|
4788
|
+
import { existsSync as existsSync14, readFileSync as readFileSync17 } from "node:fs";
|
|
4789
|
+
import { join as join19 } from "node:path";
|
|
4827
4790
|
var CARRIED = [
|
|
4828
4791
|
"testEnvironment",
|
|
4829
4792
|
"coverageDirectory",
|
|
@@ -5013,7 +4976,7 @@ function extendedConfig(source, cwd) {
|
|
|
5013
4976
|
(name) => name.replace(/^\.\//, "")
|
|
5014
4977
|
);
|
|
5015
4978
|
const file = candidates.find(
|
|
5016
|
-
(name) => /^jest[\w.-]*\.(ts|js)$/.test(name) &&
|
|
4979
|
+
(name) => /^jest[\w.-]*\.(ts|js)$/.test(name) && existsSync14(join19(cwd, name))
|
|
5017
4980
|
);
|
|
5018
4981
|
if (file === void 0) continue;
|
|
5019
4982
|
if (!new RegExp(String.raw`\{\s*\.\.\.${binding}\b`).test(source)) continue;
|
|
@@ -5040,11 +5003,11 @@ function sideEffects(source, extended) {
|
|
|
5040
5003
|
return found;
|
|
5041
5004
|
}
|
|
5042
5005
|
function readJestConfig(cwd, named) {
|
|
5043
|
-
const file = named ?? JEST_CONFIG_FILES.find((name) =>
|
|
5044
|
-
if (file === void 0 || !
|
|
5006
|
+
const file = named ?? JEST_CONFIG_FILES.find((name) => existsSync14(join19(cwd, name)));
|
|
5007
|
+
if (file === void 0 || !existsSync14(join19(cwd, file))) return void 0;
|
|
5045
5008
|
let source;
|
|
5046
5009
|
try {
|
|
5047
|
-
source = readFileSync17(
|
|
5010
|
+
source = readFileSync17(join19(cwd, file), "utf8");
|
|
5048
5011
|
} catch {
|
|
5049
5012
|
return { file, refusals: [`${file} could not be read`], notes: [] };
|
|
5050
5013
|
}
|
|
@@ -5125,8 +5088,8 @@ function readJestConfig(cwd, named) {
|
|
|
5125
5088
|
}
|
|
5126
5089
|
|
|
5127
5090
|
// src/roles/test/nest/run-modes.ts
|
|
5128
|
-
import { existsSync as
|
|
5129
|
-
import { basename as basename2, join as
|
|
5091
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
5092
|
+
import { basename as basename2, join as join20 } from "node:path";
|
|
5130
5093
|
var JEST_EXECUTOR = "@nx/jest:jest";
|
|
5131
5094
|
var PRIMARY_CONFIG_FILE = "vitest.config.mts";
|
|
5132
5095
|
var PRIMARY_TARGET = "test";
|
|
@@ -5147,7 +5110,7 @@ function runModes(cwd, fallback) {
|
|
|
5147
5110
|
const jestConfig = entry.options?.jestConfig;
|
|
5148
5111
|
if (jestConfig === void 0) continue;
|
|
5149
5112
|
const name = configName(jestConfig);
|
|
5150
|
-
if (!
|
|
5113
|
+
if (!existsSync15(join20(cwd, name))) continue;
|
|
5151
5114
|
declared.push({
|
|
5152
5115
|
target,
|
|
5153
5116
|
jestConfig: name,
|
|
@@ -5172,12 +5135,12 @@ function runModes(cwd, fallback) {
|
|
|
5172
5135
|
}
|
|
5173
5136
|
|
|
5174
5137
|
// src/roles/test/written-file-formatter.ts
|
|
5175
|
-
import { existsSync as
|
|
5176
|
-
import { dirname as
|
|
5138
|
+
import { existsSync as existsSync17 } from "node:fs";
|
|
5139
|
+
import { dirname as dirname10, join as join23 } from "node:path";
|
|
5177
5140
|
|
|
5178
5141
|
// src/roles/format/read-adoption.ts
|
|
5179
|
-
import { existsSync as
|
|
5180
|
-
import { join as
|
|
5142
|
+
import { existsSync as existsSync16, readFileSync as readFileSync18 } from "node:fs";
|
|
5143
|
+
import { join as join21 } from "node:path";
|
|
5181
5144
|
|
|
5182
5145
|
// src/roles/format/config-policy.ts
|
|
5183
5146
|
var FORMAT_CONFIG_FILE = ".oxfmtrc.json";
|
|
@@ -5284,8 +5247,8 @@ function sameValue(a, b) {
|
|
|
5284
5247
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
5285
5248
|
}
|
|
5286
5249
|
function readFormatAdoption(cwd) {
|
|
5287
|
-
const path =
|
|
5288
|
-
if (!
|
|
5250
|
+
const path = join21(cwd, FORMAT_CONFIG_FILE);
|
|
5251
|
+
if (!existsSync16(path)) return NOT_ADOPTED(null);
|
|
5289
5252
|
let parsed;
|
|
5290
5253
|
try {
|
|
5291
5254
|
parsed = parseJsonc(readFileSync18(path, "utf8"), FORMAT_CONFIG_FILE);
|
|
@@ -5333,8 +5296,8 @@ function readFormatAdoption(cwd) {
|
|
|
5333
5296
|
|
|
5334
5297
|
// src/roles/format/resolve-oxfmt.ts
|
|
5335
5298
|
import { readFileSync as readFileSync19 } from "node:fs";
|
|
5336
|
-
import { createRequire as
|
|
5337
|
-
import { dirname as
|
|
5299
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
5300
|
+
import { dirname as dirname9, join as join22 } from "node:path";
|
|
5338
5301
|
function resolveOxfmt(cwd) {
|
|
5339
5302
|
return resolveBin(cwd, "oxfmt") ?? binFromOwnInstall("oxfmt", "oxfmt");
|
|
5340
5303
|
}
|
|
@@ -5362,8 +5325,8 @@ function configSchema() {
|
|
|
5362
5325
|
}
|
|
5363
5326
|
function readConfigSchema() {
|
|
5364
5327
|
try {
|
|
5365
|
-
const manifest =
|
|
5366
|
-
const schemaPath =
|
|
5328
|
+
const manifest = createRequire3(import.meta.url).resolve("oxfmt/package.json");
|
|
5329
|
+
const schemaPath = join22(dirname9(manifest), "configuration_schema.json");
|
|
5367
5330
|
return JSON.parse(readFileSync19(schemaPath, "utf8"));
|
|
5368
5331
|
} catch {
|
|
5369
5332
|
return void 0;
|
|
@@ -5389,9 +5352,9 @@ function prettierConfigFrom(cwd) {
|
|
|
5389
5352
|
let dir = cwd;
|
|
5390
5353
|
for (; ; ) {
|
|
5391
5354
|
for (const name of PRETTIER_CONFIGS) {
|
|
5392
|
-
if (
|
|
5355
|
+
if (existsSync17(join23(dir, name))) return join23(dir, name);
|
|
5393
5356
|
}
|
|
5394
|
-
const parent =
|
|
5357
|
+
const parent = dirname10(dir);
|
|
5395
5358
|
if (parent === dir) return void 0;
|
|
5396
5359
|
dir = parent;
|
|
5397
5360
|
}
|
|
@@ -5419,8 +5382,8 @@ function writtenFileFormatter(cwd) {
|
|
|
5419
5382
|
var SPEC_TSCONFIG = "tsconfig.spec.json";
|
|
5420
5383
|
var VITEST_GLOBAL_TYPES = "vitest/globals";
|
|
5421
5384
|
function specTypesOperation(cwd) {
|
|
5422
|
-
const path =
|
|
5423
|
-
if (!
|
|
5385
|
+
const path = join24(cwd, SPEC_TSCONFIG);
|
|
5386
|
+
if (!existsSync18(path)) return void 0;
|
|
5424
5387
|
let config;
|
|
5425
5388
|
try {
|
|
5426
5389
|
config = parseJsonc(
|
|
@@ -5443,8 +5406,8 @@ function specTypesOperation(cwd) {
|
|
|
5443
5406
|
};
|
|
5444
5407
|
}
|
|
5445
5408
|
function specTypesCleanupOperation(cwd) {
|
|
5446
|
-
const path =
|
|
5447
|
-
if (!
|
|
5409
|
+
const path = join24(cwd, SPEC_TSCONFIG);
|
|
5410
|
+
if (!existsSync18(path)) return void 0;
|
|
5448
5411
|
let config;
|
|
5449
5412
|
try {
|
|
5450
5413
|
config = parseJsonc(
|
|
@@ -5466,9 +5429,9 @@ function specTypesCleanupOperation(cwd) {
|
|
|
5466
5429
|
}
|
|
5467
5430
|
function shippedTypesPath(cwd, declaration) {
|
|
5468
5431
|
try {
|
|
5469
|
-
const manifest =
|
|
5470
|
-
const file =
|
|
5471
|
-
if (
|
|
5432
|
+
const manifest = createRequire4(join24(cwd, "noop.cjs")).resolve("@hublo/sentinel/package.json");
|
|
5433
|
+
const file = join24(dirname11(manifest), declaration);
|
|
5434
|
+
if (existsSync18(file)) {
|
|
5472
5435
|
const path = relative6(cwd, file);
|
|
5473
5436
|
return path.startsWith(".") ? path : `./${path}`;
|
|
5474
5437
|
}
|
|
@@ -5487,7 +5450,7 @@ function helpersStillCallingJest(cwd) {
|
|
|
5487
5450
|
return;
|
|
5488
5451
|
}
|
|
5489
5452
|
for (const entry of entries) {
|
|
5490
|
-
const path =
|
|
5453
|
+
const path = join24(dir, entry.name);
|
|
5491
5454
|
if (entry.isDirectory()) {
|
|
5492
5455
|
if (!skip.has(entry.name)) walk2(path);
|
|
5493
5456
|
continue;
|
|
@@ -5534,7 +5497,7 @@ function tsconfigFileListOperations(cwd) {
|
|
|
5534
5497
|
let config;
|
|
5535
5498
|
try {
|
|
5536
5499
|
config = parseJsonc(
|
|
5537
|
-
readFileSync20(
|
|
5500
|
+
readFileSync20(join24(cwd, name), "utf8"),
|
|
5538
5501
|
name
|
|
5539
5502
|
);
|
|
5540
5503
|
} catch {
|
|
@@ -5949,12 +5912,12 @@ function plan(context) {
|
|
|
5949
5912
|
}
|
|
5950
5913
|
|
|
5951
5914
|
// src/roles/test/written-file-linter.ts
|
|
5952
|
-
import { existsSync as
|
|
5953
|
-
import { join as
|
|
5915
|
+
import { existsSync as existsSync23 } from "node:fs";
|
|
5916
|
+
import { join as join30 } from "node:path";
|
|
5954
5917
|
|
|
5955
5918
|
// src/roles/lint/module-baseline.ts
|
|
5956
|
-
import { existsSync as
|
|
5957
|
-
import { join as
|
|
5919
|
+
import { existsSync as existsSync19, readFileSync as readFileSync21 } from "node:fs";
|
|
5920
|
+
import { join as join25 } from "node:path";
|
|
5958
5921
|
|
|
5959
5922
|
// src/roles/lint/oxlint-rule-owners.json
|
|
5960
5923
|
var oxlint_rule_owners_default = {
|
|
@@ -6696,8 +6659,8 @@ function describeHolds(holds) {
|
|
|
6696
6659
|
return `held ${holds.length} rule(s) at \`warn\` for this module, covering ${total} violation(s) that were already there: ${listed}${rest}. They are written to ${LINT_BASELINE_FILE}, they still report, and they return to \`error\` once fixed and re-initialized`;
|
|
6697
6660
|
}
|
|
6698
6661
|
function heldRules(cwd) {
|
|
6699
|
-
const path =
|
|
6700
|
-
if (!
|
|
6662
|
+
const path = join25(cwd, LINT_BASELINE_FILE);
|
|
6663
|
+
if (!existsSync19(path)) return [];
|
|
6701
6664
|
try {
|
|
6702
6665
|
const parsed = parseJsonc(readFileSync21(path, "utf8"), LINT_BASELINE_FILE);
|
|
6703
6666
|
const scoped = (parsed.overrides ?? []).flatMap((override) => Object.keys(override.rules ?? {}));
|
|
@@ -6748,11 +6711,11 @@ function lintTarget() {
|
|
|
6748
6711
|
|
|
6749
6712
|
// src/roles/lint/read-adoption.ts
|
|
6750
6713
|
import { readFileSync as readFileSync24 } from "node:fs";
|
|
6751
|
-
import { join as
|
|
6714
|
+
import { join as join28 } from "node:path";
|
|
6752
6715
|
|
|
6753
6716
|
// src/core/config/read-adoption.ts
|
|
6754
|
-
import { existsSync as
|
|
6755
|
-
import { join as
|
|
6717
|
+
import { existsSync as existsSync21, readFileSync as readFileSync23 } from "node:fs";
|
|
6718
|
+
import { join as join27 } from "node:path";
|
|
6756
6719
|
|
|
6757
6720
|
// src/core/config/owned-keys.ts
|
|
6758
6721
|
function presetOwnedKeys(config, permitted, presetSets) {
|
|
@@ -6767,8 +6730,8 @@ function localOnlyKeys(config, permitted, presetSets) {
|
|
|
6767
6730
|
}
|
|
6768
6731
|
|
|
6769
6732
|
// src/core/config/resolve-config-target.ts
|
|
6770
|
-
import { existsSync as
|
|
6771
|
-
import { join as
|
|
6733
|
+
import { existsSync as existsSync20, readFileSync as readFileSync22 } from "node:fs";
|
|
6734
|
+
import { join as join26 } from "node:path";
|
|
6772
6735
|
function readExtends(absolutePath) {
|
|
6773
6736
|
let parsed;
|
|
6774
6737
|
try {
|
|
@@ -6786,8 +6749,8 @@ function resolveConfigTarget(moduleDir, { candidates, markers, fallback }) {
|
|
|
6786
6749
|
let existing;
|
|
6787
6750
|
let existingExtendsSomething = false;
|
|
6788
6751
|
for (const candidate of candidates) {
|
|
6789
|
-
const absolutePath =
|
|
6790
|
-
if (!
|
|
6752
|
+
const absolutePath = join26(moduleDir, candidate);
|
|
6753
|
+
if (!existsSync20(absolutePath)) continue;
|
|
6791
6754
|
const chain = readExtends(absolutePath);
|
|
6792
6755
|
if (existing === void 0) {
|
|
6793
6756
|
existing = candidate;
|
|
@@ -6820,12 +6783,12 @@ var NOT_ADOPTED2 = (configFile, unreadable = null) => ({
|
|
|
6820
6783
|
});
|
|
6821
6784
|
function readAdoption(cwd, options) {
|
|
6822
6785
|
const target = resolveConfigTarget(cwd, options);
|
|
6823
|
-
if (target.reason === "none" || !
|
|
6786
|
+
if (target.reason === "none" || !existsSync21(join27(cwd, target.path))) {
|
|
6824
6787
|
return NOT_ADOPTED2(target.reason === "none" ? null : target.path);
|
|
6825
6788
|
}
|
|
6826
6789
|
let parsed;
|
|
6827
6790
|
try {
|
|
6828
|
-
parsed = parseJsonc(readFileSync23(
|
|
6791
|
+
parsed = parseJsonc(readFileSync23(join27(cwd, target.path), "utf8"), target.path);
|
|
6829
6792
|
} catch (error) {
|
|
6830
6793
|
const reason = error instanceof Error ? error.message : String(error);
|
|
6831
6794
|
return NOT_ADOPTED2(target.path, `${target.path} could not be parsed (${reason})`);
|
|
@@ -9509,7 +9472,7 @@ function readModuleAdditions(cwd) {
|
|
|
9509
9472
|
if (preset === void 0 || adoption.configFile === null) return NO_ADDITIONS;
|
|
9510
9473
|
try {
|
|
9511
9474
|
const config = parseJsonc(
|
|
9512
|
-
readFileSync24(
|
|
9475
|
+
readFileSync24(join28(cwd, adoption.configFile), "utf8"),
|
|
9513
9476
|
adoption.configFile
|
|
9514
9477
|
);
|
|
9515
9478
|
if (typeof config !== "object" || config === null || Array.isArray(config)) {
|
|
@@ -9526,15 +9489,15 @@ function readModuleAdditions(cwd) {
|
|
|
9526
9489
|
}
|
|
9527
9490
|
|
|
9528
9491
|
// src/roles/lint/resolve-oxlint.ts
|
|
9529
|
-
import { existsSync as
|
|
9530
|
-
import { createRequire as
|
|
9531
|
-
import { delimiter
|
|
9492
|
+
import { existsSync as existsSync22 } from "node:fs";
|
|
9493
|
+
import { createRequire as createRequire5 } from "node:module";
|
|
9494
|
+
import { delimiter, dirname as dirname12, join as join29 } from "node:path";
|
|
9532
9495
|
import { fileURLToPath } from "node:url";
|
|
9533
9496
|
var PACKAGE_OF = {
|
|
9534
9497
|
oxlint: "oxlint",
|
|
9535
9498
|
tsgolint: "oxlint-tsgolint"
|
|
9536
9499
|
};
|
|
9537
|
-
var
|
|
9500
|
+
var require2 = createRequire5(import.meta.url);
|
|
9538
9501
|
function resolveOxlint(cwd, name = "oxlint") {
|
|
9539
9502
|
return resolveBin(cwd, name) ?? binFromOwnInstall(PACKAGE_OF[name], name);
|
|
9540
9503
|
}
|
|
@@ -9544,7 +9507,7 @@ function canRunTypeAware(cwd) {
|
|
|
9544
9507
|
function oxlintPath(cwd, env) {
|
|
9545
9508
|
const shim = tsgolintShim(cwd);
|
|
9546
9509
|
if (!shim) return env.PATH;
|
|
9547
|
-
return [
|
|
9510
|
+
return [dirname12(shim), env.PATH].filter(Boolean).join(delimiter);
|
|
9548
9511
|
}
|
|
9549
9512
|
function tsgolintShim(cwd) {
|
|
9550
9513
|
const fromModule = resolveBin(cwd, "tsgolint");
|
|
@@ -9552,19 +9515,19 @@ function tsgolintShim(cwd) {
|
|
|
9552
9515
|
const candidates = [];
|
|
9553
9516
|
for (const owner of ["oxlint-tsgolint", "oxlint"]) {
|
|
9554
9517
|
try {
|
|
9555
|
-
const packageDir =
|
|
9556
|
-
candidates.push(
|
|
9557
|
-
candidates.push(
|
|
9518
|
+
const packageDir = dirname12(require2.resolve(`${owner}/package.json`));
|
|
9519
|
+
candidates.push(join29(packageDir, "node_modules", ".bin", "tsgolint"));
|
|
9520
|
+
candidates.push(join29(packageDir, "..", ".bin", "tsgolint"));
|
|
9558
9521
|
} catch {
|
|
9559
9522
|
}
|
|
9560
9523
|
}
|
|
9561
9524
|
try {
|
|
9562
|
-
const ownRoot =
|
|
9563
|
-
candidates.push(
|
|
9525
|
+
const ownRoot = dirname12(require2.resolve("@hublo/sentinel/package.json"));
|
|
9526
|
+
candidates.push(join29(ownRoot, "node_modules", ".bin", "tsgolint"));
|
|
9564
9527
|
} catch {
|
|
9565
|
-
candidates.push(resolveBin(
|
|
9528
|
+
candidates.push(resolveBin(dirname12(fileURLToPath(import.meta.url)), "tsgolint") ?? "");
|
|
9566
9529
|
}
|
|
9567
|
-
return candidates.find((candidate) => candidate !== "" &&
|
|
9530
|
+
return candidates.find((candidate) => candidate !== "" && existsSync22(candidate));
|
|
9568
9531
|
}
|
|
9569
9532
|
function oxlintSearchPath(cwd) {
|
|
9570
9533
|
return binSearchPath(cwd);
|
|
@@ -9578,7 +9541,7 @@ function writtenFileLinter(cwd) {
|
|
|
9578
9541
|
return { bin: oxlint, args: ["--fix"], origin: "this module's own oxlint config" };
|
|
9579
9542
|
}
|
|
9580
9543
|
}
|
|
9581
|
-
const config = ESLINT_CONFIG_FILES.map((name) =>
|
|
9544
|
+
const config = ESLINT_CONFIG_FILES.map((name) => join30(cwd, name)).find((path) => existsSync23(path));
|
|
9582
9545
|
const eslint = resolveBin(cwd, "eslint");
|
|
9583
9546
|
if (config !== void 0 && eslint !== void 0) {
|
|
9584
9547
|
return {
|
|
@@ -9726,12 +9689,12 @@ var VitestAdapter = class _VitestAdapter extends BaseAdapter {
|
|
|
9726
9689
|
const linter = writtenFileLinter(ctx.cwd);
|
|
9727
9690
|
if (linter === void 0) return;
|
|
9728
9691
|
const workspaceRoot = findWorkspaceRoot(ctx.cwd) ?? ctx.cwd;
|
|
9729
|
-
const fromRoot = (file) => relative7(workspaceRoot,
|
|
9692
|
+
const fromRoot = (file) => relative7(workspaceRoot, join31(ctx.cwd, file));
|
|
9730
9693
|
let unsettled = 0;
|
|
9731
9694
|
const reverted = [];
|
|
9732
9695
|
for (let at = 0; at < written.length; at += FORMAT_BATCH) {
|
|
9733
9696
|
const batch = written.slice(at, at + FORMAT_BATCH);
|
|
9734
|
-
const before = new Map(batch.map((file) => [file, readIfPossible(
|
|
9697
|
+
const before = new Map(batch.map((file) => [file, readIfPossible(join31(ctx.cwd, file))]));
|
|
9735
9698
|
const pass = spawnSync(linter.bin, [...linter.args, ...batch.map(fromRoot)], {
|
|
9736
9699
|
cwd: workspaceRoot,
|
|
9737
9700
|
encoding: "utf8"
|
|
@@ -9740,11 +9703,11 @@ var VitestAdapter = class _VitestAdapter extends BaseAdapter {
|
|
|
9740
9703
|
for (const file of batch) {
|
|
9741
9704
|
const was = before.get(file);
|
|
9742
9705
|
if (was === void 0) continue;
|
|
9743
|
-
const now = readIfPossible(
|
|
9706
|
+
const now = readIfPossible(join31(ctx.cwd, file));
|
|
9744
9707
|
if (now === void 0 || now === was) continue;
|
|
9745
9708
|
const lost = lineLostByTheFixer(was, now);
|
|
9746
9709
|
if (lost === void 0) continue;
|
|
9747
|
-
writeFileSync2(
|
|
9710
|
+
writeFileSync2(join31(ctx.cwd, file), was);
|
|
9748
9711
|
reverted.push(`${file}: \`${lost.slice(0, 80)}\``);
|
|
9749
9712
|
}
|
|
9750
9713
|
}
|
|
@@ -9823,7 +9786,7 @@ var VitestAdapter = class _VitestAdapter extends BaseAdapter {
|
|
|
9823
9786
|
metrics: { ..._VitestAdapter.NOTHING_TO_REPORT, error: "vitest not available" }
|
|
9824
9787
|
};
|
|
9825
9788
|
}
|
|
9826
|
-
const out =
|
|
9789
|
+
const out = join31(mkdtempSync3(join31(tmpdir3(), "sentinel-test-report-")), "vitest.json");
|
|
9827
9790
|
const { cwd: runFrom, options, env } = fromWorkspaceRoot(ctx.cwd, [], []);
|
|
9828
9791
|
const result = spawnSync(bin, ["run", ...options, "--reporter=json", `--outputFile=${out}`], {
|
|
9829
9792
|
cwd: runFrom,
|
|
@@ -9838,7 +9801,7 @@ var VitestAdapter = class _VitestAdapter extends BaseAdapter {
|
|
|
9838
9801
|
metrics: { ..._VitestAdapter.NOTHING_TO_REPORT, error: result.error.message }
|
|
9839
9802
|
};
|
|
9840
9803
|
}
|
|
9841
|
-
if (!
|
|
9804
|
+
if (!existsSync24(out)) {
|
|
9842
9805
|
return {
|
|
9843
9806
|
ok: false,
|
|
9844
9807
|
code: 1,
|
|
@@ -9970,10 +9933,6 @@ export {
|
|
|
9970
9933
|
BaseAdapter,
|
|
9971
9934
|
splitToolArgs,
|
|
9972
9935
|
separateToolArgs,
|
|
9973
|
-
resolveBin,
|
|
9974
|
-
binFromOwnInstall,
|
|
9975
|
-
binSearchPath,
|
|
9976
|
-
scriptPath,
|
|
9977
9936
|
nxTargetOperations,
|
|
9978
9937
|
FORMAT_CONFIG_FILE,
|
|
9979
9938
|
FORMAT_SCRIPT_NAME,
|