@hublo/sentinel 1.6.0 → 1.7.0-alpha.1

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.
@@ -12,10 +12,11 @@ import {
12
12
  presetNotInstalledYet,
13
13
  registerAdapters,
14
14
  resolve
15
- } from "../chunk-RZJWYVVG.js";
15
+ } from "../chunk-7CRRGBHI.js";
16
16
  import {
17
- resolveContext
18
- } from "../chunk-L3TOPT5G.js";
17
+ resolveContext,
18
+ separateToolArgs
19
+ } from "../chunk-4HYOGCOX.js";
19
20
  import {
20
21
  ensureWorkspacePrep,
21
22
  findWorkspaceRoot,
@@ -36,7 +37,7 @@ import {
36
37
  } from "../chunk-7E6YTTAK.js";
37
38
  import "../chunk-4EIY7TTR.js";
38
39
  import "../chunk-O7REVMOC.js";
39
- import "../chunk-QXFCZON7.js";
40
+ import "../chunk-ZVHUG6CA.js";
40
41
 
41
42
  // bin/sentinel.ts
42
43
  import { program } from "commander";
@@ -584,7 +585,7 @@ async function runValidate(ctx) {
584
585
  );
585
586
  }
586
587
  if (!ctx.targets.includes("test")) return 1;
587
- const { validateModuleTests } = await import("../validate-LJHUF3OQ.js");
588
+ const { validateModuleTests } = await import("../validate-LMGBKN6L.js");
588
589
  const outcomes = modules.flatMap(
589
590
  (module) => validateModuleTests(module.name, module.root)
590
591
  );
@@ -908,9 +909,7 @@ if (!nodeCheck.ok) {
908
909
  process.exit(1);
909
910
  }
910
911
  registerAdapters();
911
- var separator = process.argv.indexOf("--");
912
- var toolArgs = separator === -1 ? [] : process.argv.slice(separator + 1);
913
- var cliArgv = separator === -1 ? process.argv : process.argv.slice(0, separator);
912
+ var { cliArgv, toolArgs } = separateToolArgs(process.argv);
914
913
  var TARGET_HELP = {
915
914
  lint: "linting",
916
915
  format: "formatting",
@@ -11,8 +11,11 @@ import {
11
11
  matchesTsconfigPattern
12
12
  } from "./chunk-O7REVMOC.js";
13
13
  import {
14
+ WORKSPACE_TSCONFIG,
15
+ chainPaths,
16
+ effectivePaths,
14
17
  parseJsonc
15
- } from "./chunk-QXFCZON7.js";
18
+ } from "./chunk-ZVHUG6CA.js";
16
19
 
17
20
  // src/core/base-adapter.ts
18
21
  var BaseAdapter = class {
@@ -27,12 +30,39 @@ var BaseAdapter = class {
27
30
  }
28
31
  };
29
32
 
33
+ // src/core/config/tool-args.ts
34
+ import { existsSync } from "node:fs";
35
+ import { isAbsolute, resolve } from "node:path";
36
+ function splitToolArgs(cwd, toolArgs = [], { valueFlags = [] } = {}) {
37
+ const takesValue = new Set(valueFlags);
38
+ const options = [];
39
+ const paths = [];
40
+ let previousTakesValue = false;
41
+ for (const arg of toolArgs) {
42
+ const looksLikeOption = arg.startsWith("-");
43
+ const target = isAbsolute(arg) ? arg : resolve(cwd, arg);
44
+ if (!previousTakesValue && !looksLikeOption && existsSync(target)) paths.push(arg);
45
+ else options.push(arg);
46
+ previousTakesValue = !arg.includes("=") && takesValue.has(arg);
47
+ }
48
+ return { options, paths };
49
+ }
50
+ function separateToolArgs(argv) {
51
+ const separator = argv.indexOf("--");
52
+ if (separator === -1) return { cliArgv: [...argv], toolArgs: [] };
53
+ const rest = argv.slice(separator + 1);
54
+ return {
55
+ cliArgv: argv.slice(0, separator),
56
+ toolArgs: rest[0] === "--" ? rest.slice(1) : rest
57
+ };
58
+ }
59
+
30
60
  // src/roles/test/read-adoption.ts
31
- import { existsSync as existsSync2, readFileSync as readFileSync3, readdirSync } from "node:fs";
61
+ import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync } from "node:fs";
32
62
  import { join as join3, relative } from "node:path";
33
63
 
34
64
  // src/core/config/manifest.ts
35
- import { existsSync, readFileSync } from "node:fs";
65
+ import { existsSync as existsSync2, readFileSync } from "node:fs";
36
66
  import { basename, join } from "node:path";
37
67
  function moduleScripts(cwd) {
38
68
  try {
@@ -75,7 +105,7 @@ function manifestOperation(cwd, scripts) {
75
105
  scripts,
76
106
  devDependencies: { [own.name]: isSelfAdoption(cwd) ? "link:." : own.version }
77
107
  };
78
- if (existsSync(join(cwd, "package.json"))) {
108
+ if (existsSync2(join(cwd, "package.json"))) {
79
109
  return { kind: "merge-json", path: "package.json", value };
80
110
  }
81
111
  return {
@@ -204,15 +234,15 @@ var JEST_CONFIG_FILES = [
204
234
  "jest.integration-config.ts"
205
235
  ];
206
236
  function testConfigFile(cwd) {
207
- return TEST_CONFIG_FILES.find((name) => existsSync2(join3(cwd, name)));
237
+ return TEST_CONFIG_FILES.find((name) => existsSync3(join3(cwd, name)));
208
238
  }
209
239
  function jestConfigFiles(cwd) {
210
- return JEST_CONFIG_FILES.filter((name) => existsSync2(join3(cwd, name)));
240
+ return JEST_CONFIG_FILES.filter((name) => existsSync3(join3(cwd, name)));
211
241
  }
212
242
  function rootJestConfigFiles(cwd) {
213
243
  const root = findWorkspaceRoot(cwd);
214
244
  if (root === void 0 || root === cwd) return [];
215
- return JEST_CONFIG_FILES.filter((name) => existsSync2(join3(root, name)));
245
+ return JEST_CONFIG_FILES.filter((name) => existsSync3(join3(root, name)));
216
246
  }
217
247
  var TEST_FILE = /[.-](spec|test)\.[cm]?[jt]sx?$/;
218
248
  var NOT_WALKED = /* @__PURE__ */ new Set(["node_modules", "dist", "coverage", ".git", ".nx", ".turbo"]);
@@ -328,7 +358,7 @@ function hasLostItsSuite(cwd, adoption) {
328
358
  }
329
359
 
330
360
  // src/roles/test/module-env.ts
331
- import { existsSync as existsSync3, readFileSync as readFileSync4 } from "node:fs";
361
+ import { existsSync as existsSync4, readFileSync as readFileSync4 } from "node:fs";
332
362
  import { join as join4 } from "node:path";
333
363
  var CASCADE = [".env", ".env.test"];
334
364
  var MODULE_CASCADE = [".env", ".env.local", ".env.test"];
@@ -360,7 +390,7 @@ function moduleEnvironment(cwd) {
360
390
  ...MODULE_CASCADE.map((name) => [join4(cwd, name), `<module>/${name}`])
361
391
  ];
362
392
  for (const [path, label] of files) {
363
- if (!existsSync3(path)) continue;
393
+ if (!existsSync4(path)) continue;
364
394
  loaded.push(label);
365
395
  Object.assign(added, parse(path));
366
396
  }
@@ -371,12 +401,12 @@ function moduleEnvironment(cwd) {
371
401
  // src/roles/test/reference.ts
372
402
  import { execFileSync } from "node:child_process";
373
403
  import { createHash } from "node:crypto";
374
- import { existsSync as existsSync5, mkdirSync, mkdtempSync, readFileSync as readFileSync5, rmSync, writeFileSync } from "node:fs";
404
+ import { existsSync as existsSync6, mkdirSync, mkdtempSync, readFileSync as readFileSync5, rmSync, writeFileSync } from "node:fs";
375
405
  import { tmpdir } from "node:os";
376
- import { join as join6, resolve } from "node:path";
406
+ import { join as join6, resolve as resolve2 } from "node:path";
377
407
 
378
408
  // src/shared/resolve-bin.ts
379
- import { existsSync as existsSync4 } from "node:fs";
409
+ import { existsSync as existsSync5 } from "node:fs";
380
410
  import { createRequire } from "node:module";
381
411
  import { delimiter, dirname, join as join5 } from "node:path";
382
412
  var require2 = createRequire(import.meta.url);
@@ -384,7 +414,7 @@ function resolveBin(fromDir, name) {
384
414
  let dir = fromDir;
385
415
  for (; ; ) {
386
416
  const candidate = join5(dir, "node_modules", ".bin", name);
387
- if (existsSync4(candidate)) return candidate;
417
+ if (existsSync5(candidate)) return candidate;
388
418
  const parent = dirname(dir);
389
419
  if (parent === dir) return void 0;
390
420
  dir = parent;
@@ -397,7 +427,7 @@ function binFromOwnInstall(packageName, binName) {
397
427
  const relative8 = typeof bin === "string" ? bin : bin?.[binName];
398
428
  if (!relative8) return void 0;
399
429
  const executable = join5(dirname(manifest), relative8);
400
- return existsSync4(executable) ? executable : void 0;
430
+ return existsSync5(executable) ? executable : void 0;
401
431
  } catch {
402
432
  return void 0;
403
433
  }
@@ -684,7 +714,7 @@ function describeComparison(comparison) {
684
714
 
685
715
  // src/roles/test/reference.ts
686
716
  function referencePath(cwd, suite) {
687
- const key = createHash("sha256").update(`${resolve(cwd)}\0${suite}`).digest("hex").slice(0, 16);
717
+ const key = createHash("sha256").update(`${resolve2(cwd)}\0${suite}`).digest("hex").slice(0, 16);
688
718
  return join6(tmpdir(), "sentinel-test-reference", `${key}.json`);
689
719
  }
690
720
  function suiteOf(config) {
@@ -713,7 +743,7 @@ function runJest(cwd, config) {
713
743
  });
714
744
  } catch {
715
745
  }
716
- if (!existsSync5(out)) return void 0;
746
+ if (!existsSync6(out)) return void 0;
717
747
  try {
718
748
  return JSON.parse(readFileSync5(out, "utf8"));
719
749
  } catch {
@@ -755,7 +785,7 @@ function captureReference(cwd, config) {
755
785
  };
756
786
  }
757
787
  function hasReference(cwd, suite) {
758
- return existsSync5(referencePath(cwd, suite));
788
+ return existsSync6(referencePath(cwd, suite));
759
789
  }
760
790
  function compareAgainstReference(cwd, suite, report) {
761
791
  const path = referencePath(cwd, suite);
@@ -785,28 +815,10 @@ function resolveVitest(cwd) {
785
815
 
786
816
  // src/roles/test/adapters/vitest/vitest.adapter.ts
787
817
  import { spawnSync } from "node:child_process";
788
- import { existsSync as existsSync25, mkdtempSync as mkdtempSync3, readFileSync as readFileSync26, writeFileSync as writeFileSync2 } from "node:fs";
818
+ import { existsSync as existsSync25, mkdtempSync as mkdtempSync3, readFileSync as readFileSync25, writeFileSync as writeFileSync2 } from "node:fs";
789
819
  import { tmpdir as tmpdir3 } from "node:os";
790
820
  import { isAbsolute as isAbsolute2, join as join32, relative as relative7, resolve as resolve10 } from "node:path";
791
821
 
792
- // src/core/config/tool-args.ts
793
- import { existsSync as existsSync6 } from "node:fs";
794
- import { isAbsolute, resolve as resolve2 } from "node:path";
795
- function splitToolArgs(cwd, toolArgs = [], { valueFlags = [] } = {}) {
796
- const takesValue = new Set(valueFlags);
797
- const options = [];
798
- const paths = [];
799
- let previousTakesValue = false;
800
- for (const arg of toolArgs) {
801
- const looksLikeOption = arg.startsWith("-");
802
- const target = isAbsolute(arg) ? arg : resolve2(cwd, arg);
803
- if (!previousTakesValue && !looksLikeOption && existsSync6(target)) paths.push(arg);
804
- else options.push(arg);
805
- previousTakesValue = !arg.includes("=") && takesValue.has(arg);
806
- }
807
- return { options, paths };
808
- }
809
-
810
822
  // src/roles/test/ordering-is-a-permutation.ts
811
823
  function isAnImport(line) {
812
824
  return /^import\b/.test(line) || /^export\s+(?:\*|\{)[^;]*\bfrom\b/.test(line);
@@ -995,12 +1007,12 @@ function rewriteToolchainImports(toolchain, source, fileName) {
995
1007
  }
996
1008
 
997
1009
  // src/roles/test/jest-migration.ts
998
- import { existsSync as existsSync19, readFileSync as readFileSync21, readdirSync as readdirSync6 } from "node:fs";
1010
+ import { existsSync as existsSync19, readFileSync as readFileSync20, readdirSync as readdirSync6 } from "node:fs";
999
1011
  import { createRequire as createRequire5 } from "node:module";
1000
1012
  import { dirname as dirname12, join as join25, relative as relative6 } from "node:path";
1001
1013
 
1002
1014
  // src/roles/test/codemod/migrate-module.ts
1003
- import { readdirSync as readdirSync4, readFileSync as readFileSync16, statSync as statSync5 } from "node:fs";
1015
+ import { readdirSync as readdirSync4, readFileSync as readFileSync15, statSync as statSync5 } from "node:fs";
1004
1016
  import { join as join18 } from "node:path";
1005
1017
  import { parseSync as parseSync9 } from "oxc-parser";
1006
1018
 
@@ -3595,37 +3607,40 @@ function resolveContext(cwd, opts) {
3595
3607
  }
3596
3608
 
3597
3609
  // src/roles/test/codemod/workspace-specifier.ts
3598
- import { existsSync as existsSync13, readFileSync as readFileSync13 } from "node:fs";
3610
+ import { existsSync as existsSync13 } from "node:fs";
3599
3611
  import { join as join15, relative as relative2, resolve as resolve6 } from "node:path";
3600
3612
  var EXTENSIONS = ["", ".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", "/index.ts", "/index.js"];
3601
- function pathEntries(workspaceRoot) {
3602
- const file = join15(workspaceRoot, "tsconfig.base.json");
3603
- if (!existsSync13(file)) return [];
3604
- let paths;
3613
+ var SPEC_TSCONFIGS = ["tsconfig.spec.json", "tsconfig.app.json", "tsconfig.json"];
3614
+ function pathsFor(workspaceRoot, moduleRoot) {
3605
3615
  try {
3606
- paths = parseJsonc(
3607
- readFileSync13(file, "utf8"),
3608
- "tsconfig.base.json"
3609
- )?.compilerOptions?.paths;
3616
+ if (moduleRoot !== void 0) return effectivePaths(moduleRoot, workspaceRoot, SPEC_TSCONFIGS);
3617
+ const file = join15(workspaceRoot, WORKSPACE_TSCONFIG);
3618
+ if (!existsSync13(file)) return void 0;
3619
+ const found = chainPaths(file);
3620
+ return found && { ...found, fromWorkspaceFallback: false };
3610
3621
  } catch {
3611
- return [];
3622
+ return void 0;
3612
3623
  }
3624
+ }
3625
+ function pathEntries(workspaceRoot, moduleRoot) {
3626
+ const found = pathsFor(workspaceRoot, moduleRoot);
3627
+ if (found === void 0) return [];
3613
3628
  const entries = [];
3614
- for (const [key, targets] of Object.entries(paths ?? {})) {
3629
+ for (const [key, targets] of Object.entries(found.paths)) {
3615
3630
  const target = targets[0];
3616
3631
  if (target === void 0) continue;
3617
3632
  const wildcard = key.endsWith("/*") && target.endsWith("/*");
3618
3633
  entries.push({
3619
3634
  key: wildcard ? key.slice(0, -2) : key,
3620
- target: resolve6(workspaceRoot, wildcard ? target.slice(0, -2) : target),
3635
+ target: resolve6(found.baseDirectory, wildcard ? target.slice(0, -2) : target),
3621
3636
  wildcard
3622
3637
  });
3623
3638
  }
3624
3639
  return entries.sort((left, right) => right.target.length - left.target.length);
3625
3640
  }
3626
- function workspaceSpecifier(workspaceRoot, file) {
3641
+ function workspaceSpecifier(workspaceRoot, file, moduleRoot) {
3627
3642
  const absolute = resolve6(file);
3628
- for (const entry of pathEntries(workspaceRoot)) {
3643
+ for (const entry of pathEntries(workspaceRoot, moduleRoot)) {
3629
3644
  if (!entry.wildcard) {
3630
3645
  if (EXTENSIONS.some((extension) => `${entry.target}${extension}` === absolute)) {
3631
3646
  return entry.key;
@@ -3658,7 +3673,7 @@ function importable(written, fileName, workspaceRoot) {
3658
3673
  const target = resolve7(fileDir, written);
3659
3674
  if (target.startsWith(`${moduleRoot}/`)) return written;
3660
3675
  if (workspaceRoot === void 0) return void 0;
3661
- return workspaceSpecifier(workspaceRoot, target);
3676
+ return workspaceSpecifier(workspaceRoot, target, moduleRoot);
3662
3677
  }
3663
3678
  function statement(fileName, source, node, specifier, written) {
3664
3679
  if (node.type === "ExpressionStatement") return `import '${specifier}'`;
@@ -3769,7 +3784,7 @@ function rewriteMockFactoryGenerics(source, program) {
3769
3784
  }
3770
3785
 
3771
3786
  // src/roles/test/codemod/spy-on-internal-call.ts
3772
- import { readFileSync as readFileSync14, statSync as statSync3 } from "node:fs";
3787
+ import { readFileSync as readFileSync13, statSync as statSync3 } from "node:fs";
3773
3788
  import { dirname as dirname7, join as join16, relative as relative3, resolve as resolve8 } from "node:path";
3774
3789
  import { parseSync as parseSync7 } from "oxc-parser";
3775
3790
  function resolveRelative2(fromFile, specifier) {
@@ -3790,7 +3805,7 @@ function resolveRelative2(fromFile, specifier) {
3790
3805
  }
3791
3806
  function read(path) {
3792
3807
  try {
3793
- return readFileSync14(path, "utf8");
3808
+ return readFileSync13(path, "utf8");
3794
3809
  } catch {
3795
3810
  return void 0;
3796
3811
  }
@@ -4345,7 +4360,7 @@ function migrateTestFile(fileName, source, defaultImported = /* @__PURE__ */ new
4345
4360
  */
4346
4361
  ...statics.refusals.map((specifier) => ({
4347
4362
  binding: specifier,
4348
- reason: `\`require('${specifier}')\` reaches another project, and \`tsconfig.base.json\` declares no path for it. A static import of a relative path is refused by nx, and \`await import()\` would make it a dynamic dependency, which forbids every static import of that project across this module. Add a \`paths\` entry for it, or move the file inside this project.`
4363
+ reason: `\`require('${specifier}')\` reaches another project, and no \`paths\` entry covers it, in this module's tsconfig or in \`tsconfig.base.json\`. A static import of a relative path is refused by nx, and \`await import()\` would make it a dynamic dependency, which forbids every static import of that project across this module. Add a \`paths\` entry for it, or move the file inside this project.`
4349
4364
  })),
4350
4365
  ...fakeTimers.refusals,
4351
4366
  ...hoist.refusals,
@@ -4362,7 +4377,7 @@ function migrateTestFile(fileName, source, defaultImported = /* @__PURE__ */ new
4362
4377
  }
4363
4378
 
4364
4379
  // src/roles/test/codemod/test-support-files.ts
4365
- import { existsSync as existsSync14, readFileSync as readFileSync15, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
4380
+ import { existsSync as existsSync14, readFileSync as readFileSync14, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
4366
4381
  import { dirname as dirname9, join as join17, relative as relative4, resolve as resolve9 } from "node:path";
4367
4382
  var THE_SHIM_CANNOT_ANSWER = [/\brequire\s*\(/, /\bjest\.(?:fn|Mock|SpyInstance)\s*</];
4368
4383
  var SKIPPED = /* @__PURE__ */ new Set(["node_modules", "dist", "coverage", ".git", ".vite"]);
@@ -4417,7 +4432,7 @@ function moduleSources(cwd) {
4417
4432
  }
4418
4433
  function read2(path) {
4419
4434
  try {
4420
- return readFileSync15(path, "utf8");
4435
+ return readFileSync14(path, "utf8");
4421
4436
  } catch {
4422
4437
  return void 0;
4423
4438
  }
@@ -4475,7 +4490,7 @@ function parse4(fileName, source) {
4475
4490
  }
4476
4491
  function read3(path) {
4477
4492
  try {
4478
- return readFileSync16(path, "utf8");
4493
+ return readFileSync15(path, "utf8");
4479
4494
  } catch {
4480
4495
  return void 0;
4481
4496
  }
@@ -4604,7 +4619,7 @@ function migrateModuleTests(cwd, setupFiles = []) {
4604
4619
  }
4605
4620
 
4606
4621
  // src/roles/test/nest/generate-config.ts
4607
- import { readdirSync as readdirSync5, readFileSync as readFileSync17, statSync as statSync6 } from "node:fs";
4622
+ import { readdirSync as readdirSync5, readFileSync as readFileSync16, statSync as statSync6 } from "node:fs";
4608
4623
  import { join as join19, relative as relative5 } from "node:path";
4609
4624
  import { parseSync as parseSync10 } from "oxc-parser";
4610
4625
  var NEST_TEST_PRESET_SPECIFIER = "@hublo/sentinel/test/nest";
@@ -4666,7 +4681,7 @@ function readModuleTraits(cwd) {
4666
4681
  if (!/\.tsx?$/.test(entry)) continue;
4667
4682
  let source;
4668
4683
  try {
4669
- source = readFileSync17(path, "utf8");
4684
+ source = readFileSync16(path, "utf8");
4670
4685
  } catch {
4671
4686
  continue;
4672
4687
  }
@@ -4807,7 +4822,7 @@ ${overrides.join("\n")}
4807
4822
  }
4808
4823
 
4809
4824
  // src/roles/test/nest/read-jest-config.ts
4810
- import { existsSync as existsSync15, readFileSync as readFileSync18 } from "node:fs";
4825
+ import { existsSync as existsSync15, readFileSync as readFileSync17 } from "node:fs";
4811
4826
  import { join as join20 } from "node:path";
4812
4827
  var CARRIED = [
4813
4828
  "testEnvironment",
@@ -5029,7 +5044,7 @@ function readJestConfig(cwd, named) {
5029
5044
  if (file === void 0 || !existsSync15(join20(cwd, file))) return void 0;
5030
5045
  let source;
5031
5046
  try {
5032
- source = readFileSync18(join20(cwd, file), "utf8");
5047
+ source = readFileSync17(join20(cwd, file), "utf8");
5033
5048
  } catch {
5034
5049
  return { file, refusals: [`${file} could not be read`], notes: [] };
5035
5050
  }
@@ -5161,7 +5176,7 @@ import { existsSync as existsSync18 } from "node:fs";
5161
5176
  import { dirname as dirname11, join as join24 } from "node:path";
5162
5177
 
5163
5178
  // src/roles/format/read-adoption.ts
5164
- import { existsSync as existsSync17, readFileSync as readFileSync19 } from "node:fs";
5179
+ import { existsSync as existsSync17, readFileSync as readFileSync18 } from "node:fs";
5165
5180
  import { join as join22 } from "node:path";
5166
5181
 
5167
5182
  // src/roles/format/config-policy.ts
@@ -5273,7 +5288,7 @@ function readFormatAdoption(cwd) {
5273
5288
  if (!existsSync17(path)) return NOT_ADOPTED(null);
5274
5289
  let parsed;
5275
5290
  try {
5276
- parsed = parseJsonc(readFileSync19(path, "utf8"), FORMAT_CONFIG_FILE);
5291
+ parsed = parseJsonc(readFileSync18(path, "utf8"), FORMAT_CONFIG_FILE);
5277
5292
  } catch (error) {
5278
5293
  const reason = error instanceof Error ? error.message : String(error);
5279
5294
  return NOT_ADOPTED(FORMAT_CONFIG_FILE, `${FORMAT_CONFIG_FILE} could not be parsed (${reason})`);
@@ -5317,7 +5332,7 @@ function readFormatAdoption(cwd) {
5317
5332
  }
5318
5333
 
5319
5334
  // src/roles/format/resolve-oxfmt.ts
5320
- import { readFileSync as readFileSync20 } from "node:fs";
5335
+ import { readFileSync as readFileSync19 } from "node:fs";
5321
5336
  import { createRequire as createRequire4 } from "node:module";
5322
5337
  import { dirname as dirname10, join as join23 } from "node:path";
5323
5338
  function resolveOxfmt(cwd) {
@@ -5349,7 +5364,7 @@ function readConfigSchema() {
5349
5364
  try {
5350
5365
  const manifest = createRequire4(import.meta.url).resolve("oxfmt/package.json");
5351
5366
  const schemaPath = join23(dirname10(manifest), "configuration_schema.json");
5352
- return JSON.parse(readFileSync20(schemaPath, "utf8"));
5367
+ return JSON.parse(readFileSync19(schemaPath, "utf8"));
5353
5368
  } catch {
5354
5369
  return void 0;
5355
5370
  }
@@ -5409,7 +5424,7 @@ function specTypesOperation(cwd) {
5409
5424
  let config;
5410
5425
  try {
5411
5426
  config = parseJsonc(
5412
- readFileSync21(path, "utf8"),
5427
+ readFileSync20(path, "utf8"),
5413
5428
  SPEC_TSCONFIG
5414
5429
  );
5415
5430
  } catch {
@@ -5433,7 +5448,7 @@ function specTypesCleanupOperation(cwd) {
5433
5448
  let config;
5434
5449
  try {
5435
5450
  config = parseJsonc(
5436
- readFileSync21(path, "utf8"),
5451
+ readFileSync20(path, "utf8"),
5437
5452
  SPEC_TSCONFIG
5438
5453
  );
5439
5454
  } catch {
@@ -5482,7 +5497,7 @@ function helpersStillCallingJest(cwd) {
5482
5497
  if (/^(jest|vitest)\./.test(entry.name)) continue;
5483
5498
  let source;
5484
5499
  try {
5485
- source = readFileSync21(path, "utf8");
5500
+ source = readFileSync20(path, "utf8");
5486
5501
  } catch {
5487
5502
  continue;
5488
5503
  }
@@ -5519,7 +5534,7 @@ function tsconfigFileListOperations(cwd) {
5519
5534
  let config;
5520
5535
  try {
5521
5536
  config = parseJsonc(
5522
- readFileSync21(join25(cwd, name), "utf8"),
5537
+ readFileSync20(join25(cwd, name), "utf8"),
5523
5538
  name
5524
5539
  );
5525
5540
  } catch {
@@ -5938,7 +5953,7 @@ import { existsSync as existsSync24 } from "node:fs";
5938
5953
  import { join as join31 } from "node:path";
5939
5954
 
5940
5955
  // src/roles/lint/module-baseline.ts
5941
- import { existsSync as existsSync20, readFileSync as readFileSync22 } from "node:fs";
5956
+ import { existsSync as existsSync20, readFileSync as readFileSync21 } from "node:fs";
5942
5957
  import { join as join26 } from "node:path";
5943
5958
 
5944
5959
  // src/roles/lint/oxlint-rule-owners.json
@@ -6617,8 +6632,38 @@ function holdsFrom(errorCounts, presetSpellings = /* @__PURE__ */ new Map()) {
6617
6632
  }
6618
6633
  return [...counts].map(([rule, count]) => ({ rule, count })).sort((left, right) => right.count - left.count || left.rule.localeCompare(right.rule));
6619
6634
  }
6620
- function renderBaseline(holds, version) {
6621
- const entries = holds.map(({ rule }) => ` ${JSON.stringify(rule)}: "warn"`).join(",\n");
6635
+ var isEnforced = (entry) => (Array.isArray(entry) ? entry[0] : entry) === "error";
6636
+ var atWarn = (entry) => Array.isArray(entry) && entry.length > 1 ? ["warn", ...entry.slice(1)] : "warn";
6637
+ function heldIn(rules, holds) {
6638
+ const byRule = new Map(
6639
+ Object.entries(rules).map(([rule, entry]) => [canonicalRuleName(rule), { rule, entry }])
6640
+ );
6641
+ return holds.flatMap((hold) => {
6642
+ const found = byRule.get(canonicalRuleName(hold.rule));
6643
+ return found && isEnforced(found.entry) ? [[found.rule, atWarn(found.entry)]] : [];
6644
+ });
6645
+ }
6646
+ function renderBaseline(holds, version, preset = { rules: {} }) {
6647
+ const scoped = (preset.overrides ?? []).map(({ files, rules: rules2 }) => ({ files, rules: Object.fromEntries(heldIn(rules2, holds)) })).filter(({ rules: rules2 }) => Object.keys(rules2).length > 0);
6648
+ const heldInOverride = new Set(
6649
+ scoped.flatMap(({ rules: rules2 }) => Object.keys(rules2).map((rule) => canonicalRuleName(rule)))
6650
+ );
6651
+ const topLevel = new Map(
6652
+ heldIn(preset.rules, holds).map((held) => [canonicalRuleName(held[0]), held])
6653
+ );
6654
+ const rules = Object.fromEntries(
6655
+ holds.flatMap(({ rule }) => {
6656
+ const canonical = canonicalRuleName(rule);
6657
+ const held = topLevel.get(canonical);
6658
+ if (held) return [held];
6659
+ return heldInOverride.has(canonical) ? [] : [[rule, "warn"]];
6660
+ })
6661
+ );
6662
+ const body = JSON.stringify(
6663
+ { rules, ...scoped.length > 0 ? { overrides: scoped } : {} },
6664
+ null,
6665
+ 2
6666
+ ).slice(2);
6622
6667
  return [
6623
6668
  "{",
6624
6669
  ` // Written by @hublo/sentinel@${version}. Do not edit by hand: \`sentinel --init --lint\``,
@@ -6635,10 +6680,7 @@ function renderBaseline(holds, version) {
6635
6680
  " //",
6636
6681
  " // `sentinel --inspect --lint` lists what is held; `sentinel --run --lint --json` counts",
6637
6682
  " // what is left, per rule. Fix them and re-run `--init --lint` to get the severity back.",
6638
- ' "rules": {',
6639
- entries,
6640
- " }",
6641
- "}",
6683
+ body,
6642
6684
  ""
6643
6685
  ].join("\n");
6644
6686
  }
@@ -6657,11 +6699,9 @@ function heldRules(cwd) {
6657
6699
  const path = join26(cwd, LINT_BASELINE_FILE);
6658
6700
  if (!existsSync20(path)) return [];
6659
6701
  try {
6660
- const parsed = parseJsonc(
6661
- readFileSync22(path, "utf8"),
6662
- LINT_BASELINE_FILE
6663
- );
6664
- return Object.keys(parsed.rules ?? {});
6702
+ const parsed = parseJsonc(readFileSync21(path, "utf8"), LINT_BASELINE_FILE);
6703
+ const scoped = (parsed.overrides ?? []).flatMap((override) => Object.keys(override.rules ?? {}));
6704
+ return [.../* @__PURE__ */ new Set([...Object.keys(parsed.rules ?? {}), ...scoped])];
6665
6705
  } catch {
6666
6706
  return [];
6667
6707
  }
@@ -6707,11 +6747,11 @@ function lintTarget() {
6707
6747
  }
6708
6748
 
6709
6749
  // src/roles/lint/read-adoption.ts
6710
- import { readFileSync as readFileSync25 } from "node:fs";
6750
+ import { readFileSync as readFileSync24 } from "node:fs";
6711
6751
  import { join as join29 } from "node:path";
6712
6752
 
6713
6753
  // src/core/config/read-adoption.ts
6714
- import { existsSync as existsSync22, readFileSync as readFileSync24 } from "node:fs";
6754
+ import { existsSync as existsSync22, readFileSync as readFileSync23 } from "node:fs";
6715
6755
  import { join as join28 } from "node:path";
6716
6756
 
6717
6757
  // src/core/config/owned-keys.ts
@@ -6727,12 +6767,12 @@ function localOnlyKeys(config, permitted, presetSets) {
6727
6767
  }
6728
6768
 
6729
6769
  // src/core/config/resolve-config-target.ts
6730
- import { existsSync as existsSync21, readFileSync as readFileSync23 } from "node:fs";
6770
+ import { existsSync as existsSync21, readFileSync as readFileSync22 } from "node:fs";
6731
6771
  import { join as join27 } from "node:path";
6732
6772
  function readExtends(absolutePath) {
6733
6773
  let parsed;
6734
6774
  try {
6735
- parsed = parseJsonc(readFileSync23(absolutePath, "utf8"), absolutePath);
6775
+ parsed = parseJsonc(readFileSync22(absolutePath, "utf8"), absolutePath);
6736
6776
  } catch {
6737
6777
  return [];
6738
6778
  }
@@ -6785,7 +6825,7 @@ function readAdoption(cwd, options) {
6785
6825
  }
6786
6826
  let parsed;
6787
6827
  try {
6788
- parsed = parseJsonc(readFileSync24(join28(cwd, target.path), "utf8"), target.path);
6828
+ parsed = parseJsonc(readFileSync23(join28(cwd, target.path), "utf8"), target.path);
6789
6829
  } catch (error) {
6790
6830
  const reason = error instanceof Error ? error.message : String(error);
6791
6831
  return NOT_ADOPTED2(target.path, `${target.path} could not be parsed (${reason})`);
@@ -9469,7 +9509,7 @@ function readModuleAdditions(cwd) {
9469
9509
  if (preset === void 0 || adoption.configFile === null) return NO_ADDITIONS;
9470
9510
  try {
9471
9511
  const config = parseJsonc(
9472
- readFileSync25(join29(cwd, adoption.configFile), "utf8"),
9512
+ readFileSync24(join29(cwd, adoption.configFile), "utf8"),
9473
9513
  adoption.configFile
9474
9514
  );
9475
9515
  if (typeof config !== "object" || config === null || Array.isArray(config)) {
@@ -9560,7 +9600,7 @@ var FORMATTABLE = /\.(m|c)?(j|t)sx?$|\.json$/;
9560
9600
  var FORMAT_BATCH = 25;
9561
9601
  function readIfPossible(path) {
9562
9602
  try {
9563
- return readFileSync26(path, "utf8");
9603
+ return readFileSync25(path, "utf8");
9564
9604
  } catch {
9565
9605
  return void 0;
9566
9606
  }
@@ -9807,7 +9847,7 @@ var VitestAdapter = class _VitestAdapter extends BaseAdapter {
9807
9847
  }
9808
9848
  let parsed;
9809
9849
  try {
9810
- parsed = JSON.parse(readFileSync26(out, "utf8"));
9850
+ parsed = JSON.parse(readFileSync25(out, "utf8"));
9811
9851
  } catch {
9812
9852
  return {
9813
9853
  ok: false,
@@ -9929,6 +9969,7 @@ export {
9929
9969
  projectTargets,
9930
9970
  BaseAdapter,
9931
9971
  splitToolArgs,
9972
+ separateToolArgs,
9932
9973
  resolveBin,
9933
9974
  binFromOwnInstall,
9934
9975
  binSearchPath,