@hublo/sentinel 1.4.0-alpha.43 → 1.4.0-alpha.44

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.
@@ -15,10 +15,10 @@ import {
15
15
  palette,
16
16
  registerAdapters,
17
17
  resolve
18
- } from "../chunk-TAJD75KN.js";
18
+ } from "../chunk-ZSPDXVQL.js";
19
19
  import {
20
20
  resolveContext
21
- } from "../chunk-TIOMI3YB.js";
21
+ } from "../chunk-RO626QTL.js";
22
22
  import "../chunk-O7REVMOC.js";
23
23
  import "../chunk-QXFCZON7.js";
24
24
  import {
@@ -145,7 +145,7 @@ async function runValidate(ctx) {
145
145
  );
146
146
  }
147
147
  if (!ctx.targets.includes("test")) return 1;
148
- const { validateModuleTests } = await import("../validate-EDNRJHTG.js");
148
+ const { validateModuleTests } = await import("../validate-UIOW5VEV.js");
149
149
  const outcomes = modules.flatMap(
150
150
  (module) => validateModuleTests(module.name, module.root)
151
151
  );
@@ -367,9 +367,9 @@ function binFromOwnInstall(packageName, binName) {
367
367
  try {
368
368
  const manifest = require2.resolve(`${packageName}/package.json`);
369
369
  const bin = require2(manifest).bin;
370
- const relative6 = typeof bin === "string" ? bin : bin?.[binName];
371
- if (!relative6) return void 0;
372
- const executable = join5(dirname(manifest), relative6);
370
+ const relative7 = typeof bin === "string" ? bin : bin?.[binName];
371
+ if (!relative7) return void 0;
372
+ const executable = join5(dirname(manifest), relative7);
373
373
  return existsSync4(executable) ? executable : void 0;
374
374
  } catch {
375
375
  return void 0;
@@ -748,7 +748,7 @@ function resolveVitest(cwd) {
748
748
  // src/roles/test/adapters/vitest/vitest.adapter.ts
749
749
  import { spawnSync } from "node:child_process";
750
750
  import { readFileSync as readFileSync24, writeFileSync as writeFileSync2 } from "node:fs";
751
- import { isAbsolute as isAbsolute2, join as join30, resolve as resolve9 } from "node:path";
751
+ import { isAbsolute as isAbsolute2, join as join30, relative as relative6, resolve as resolve9 } from "node:path";
752
752
 
753
753
  // src/core/config/tool-args.ts
754
754
  import { existsSync as existsSync6 } from "node:fs";
@@ -769,11 +769,14 @@ function splitToolArgs(cwd, toolArgs = [], { valueFlags = [] } = {}) {
769
769
  }
770
770
 
771
771
  // src/roles/test/ordering-is-a-permutation.ts
772
+ function isAnImport(line) {
773
+ return /^import\b/.test(line) || /^export\s+(?:\*|\{)[^;]*\bfrom\b/.test(line);
774
+ }
772
775
  function lineCounts(source) {
773
776
  const counts = /* @__PURE__ */ new Map();
774
777
  for (const line of source.split("\n")) {
775
778
  const trimmed = line.trim();
776
- if (trimmed === "") continue;
779
+ if (trimmed === "" || isAnImport(trimmed)) continue;
777
780
  counts.set(trimmed, (counts.get(trimmed) ?? 0) + 1);
778
781
  }
779
782
  return counts;
@@ -947,11 +950,11 @@ function ownsMswLifecycle(cwd, setupFiles) {
947
950
  // src/roles/test/support-file-name.ts
948
951
  var JEST_PREFIX = "jest.";
949
952
  var VITEST_PREFIX = "vitest.";
950
- function vitestSupportName(relative6) {
951
- const cut = relative6.lastIndexOf("/");
952
- const directory = cut === -1 ? "" : relative6.slice(0, cut + 1);
953
- const base = relative6.slice(cut + 1);
954
- if (!base.startsWith(JEST_PREFIX)) return relative6;
953
+ function vitestSupportName(relative7) {
954
+ const cut = relative7.lastIndexOf("/");
955
+ const directory = cut === -1 ? "" : relative7.slice(0, cut + 1);
956
+ const base = relative7.slice(cut + 1);
957
+ if (!base.startsWith(JEST_PREFIX)) return relative7;
955
958
  return `${directory}${VITEST_PREFIX}${base.slice(JEST_PREFIX.length)}`;
956
959
  }
957
960
 
@@ -2121,8 +2124,8 @@ function reachesBack(fromFile, specifier) {
2121
2124
  } catch {
2122
2125
  continue;
2123
2126
  }
2124
- for (const relative6 of relativeSpecifiers(source)) {
2125
- const next = resolveRelative(file, relative6);
2127
+ for (const relative7 of relativeSpecifiers(source)) {
2128
+ const next = resolveRelative(file, relative7);
2126
2129
  if (next !== void 0) stack.push(next);
2127
2130
  }
2128
2131
  }
@@ -4000,14 +4003,14 @@ function migrateModuleTests(cwd, setupFiles = []) {
4000
4003
  let hoisted = 0;
4001
4004
  const defaultImported = defaultImportedSpecifiers(cwd);
4002
4005
  const asyncHelpers = /* @__PURE__ */ new Set();
4003
- for (const relative6 of listTestSupportFiles(cwd, setupFiles)) {
4004
- const source = read2(join17(cwd, relative6));
4006
+ for (const relative7 of listTestSupportFiles(cwd, setupFiles)) {
4007
+ const source = read2(join17(cwd, relative7));
4005
4008
  if (source === void 0) {
4006
- blockers.push({ file: relative6, reason: "this file could not be read" });
4009
+ blockers.push({ file: relative7, reason: "this file could not be read" });
4007
4010
  continue;
4008
4011
  }
4009
4012
  const migrated = migrateTestFile(
4010
- join17(cwd, relative6),
4013
+ join17(cwd, relative7),
4011
4014
  source,
4012
4015
  defaultImported,
4013
4016
  /* @__PURE__ */ new Set(),
@@ -4015,19 +4018,19 @@ function migrateModuleTests(cwd, setupFiles = []) {
4015
4018
  );
4016
4019
  for (const member of migrated.unhandled) {
4017
4020
  blockers.push({
4018
- file: `${relative6}:${member.line}`,
4021
+ file: `${relative7}:${member.line}`,
4019
4022
  reason: member.rule === void 0 ? `${member.member} has no rule, and guessing one is how a suite goes green for the wrong reason` : `${member.member} needs ${member.rule}`
4020
4023
  });
4021
4024
  }
4022
4025
  for (const refusal of migrated.refusals) {
4023
- blockers.push({ file: relative6, reason: refusal.reason });
4026
+ blockers.push({ file: relative7, reason: refusal.reason });
4024
4027
  }
4025
4028
  collected.push(...migrated.warnings);
4026
- const renamedTo = vitestSupportName(relative6);
4027
- if (!migrated.changed && renamedTo === relative6) continue;
4028
- if (renamedTo !== relative6) operations.push({ kind: "delete", path: relative6 });
4029
- const before = parse3(join17(cwd, relative6), source);
4030
- const after = parse3(join17(cwd, relative6), migrated.source);
4029
+ const renamedTo = vitestSupportName(relative7);
4030
+ if (!migrated.changed && renamedTo === relative7) continue;
4031
+ if (renamedTo !== relative7) operations.push({ kind: "delete", path: relative7 });
4032
+ const before = parse3(join17(cwd, relative7), source);
4033
+ const after = parse3(join17(cwd, relative7), migrated.source);
4031
4034
  if (before !== void 0 && after !== void 0) {
4032
4035
  const wasAsync = asyncFunctionNames(before);
4033
4036
  for (const name of asyncFunctionNames(after)) {
@@ -4039,14 +4042,14 @@ function migrateModuleTests(cwd, setupFiles = []) {
4039
4042
  const contents = /\bvi\./.test(migrated.source) ? injectViImport(join17(cwd, renamedTo), migrated.source) : migrated.source;
4040
4043
  operations.push({ kind: "write", path: renamedTo, contents });
4041
4044
  }
4042
- for (const relative6 of listTestFiles(cwd)) {
4043
- const source = read2(join17(cwd, relative6));
4045
+ for (const relative7 of listTestFiles(cwd)) {
4046
+ const source = read2(join17(cwd, relative7));
4044
4047
  if (source === void 0) {
4045
- blockers.push({ file: relative6, reason: "this file could not be read" });
4048
+ blockers.push({ file: relative7, reason: "this file could not be read" });
4046
4049
  continue;
4047
4050
  }
4048
4051
  const migrated = migrateTestFile(
4049
- join17(cwd, relative6),
4052
+ join17(cwd, relative7),
4050
4053
  source,
4051
4054
  defaultImported,
4052
4055
  asyncHelpers,
@@ -4054,24 +4057,24 @@ function migrateModuleTests(cwd, setupFiles = []) {
4054
4057
  );
4055
4058
  for (const member of migrated.unhandled) {
4056
4059
  blockers.push({
4057
- file: `${relative6}:${member.line}`,
4060
+ file: `${relative7}:${member.line}`,
4058
4061
  reason: member.rule === void 0 ? `${member.member} has no rule, and guessing one is how a suite goes green for the wrong reason` : `${member.member} needs ${member.rule}`
4059
4062
  });
4060
4063
  }
4061
4064
  collected.push(...migrated.warnings);
4062
4065
  for (const refusal of migrated.refusals) {
4063
- blockers.push({ file: relative6, reason: refusal.reason });
4066
+ blockers.push({ file: relative7, reason: refusal.reason });
4064
4067
  }
4065
4068
  if (!migrated.changed) continue;
4066
4069
  files++;
4067
4070
  renamed += migrated.renamed;
4068
4071
  if (migrated.hoisted.length > 0) hoisted++;
4069
4072
  const withInheritedMocks = declaredInheritedMocks(
4070
- join17(cwd, relative6),
4073
+ join17(cwd, relative7),
4071
4074
  migrated.source,
4072
4075
  inherited
4073
4076
  );
4074
- operations.push({ kind: "write", path: relative6, contents: withInheritedMocks });
4077
+ operations.push({ kind: "write", path: relative7, contents: withInheritedMocks });
4075
4078
  }
4076
4079
  const warnings = [...new Set(collected)];
4077
4080
  return blockers.length > 0 ? { operations: [], files, renamed, hoisted, blockers, warnings } : { operations, files, renamed, hoisted, blockers: [], warnings };
@@ -5673,13 +5676,15 @@ var VitestAdapter = class extends BaseAdapter {
5673
5676
  fixWithTheModulesLinter(ctx, written) {
5674
5677
  const linter = writtenFileLinter(ctx.cwd);
5675
5678
  if (linter === void 0) return;
5679
+ const workspaceRoot = findWorkspaceRoot(ctx.cwd) ?? ctx.cwd;
5680
+ const fromRoot = (file) => relative6(workspaceRoot, join30(ctx.cwd, file));
5676
5681
  let unsettled = 0;
5677
5682
  const reverted = [];
5678
5683
  for (let at = 0; at < written.length; at += FORMAT_BATCH) {
5679
5684
  const batch = written.slice(at, at + FORMAT_BATCH);
5680
5685
  const before = new Map(batch.map((file) => [file, readIfPossible(join30(ctx.cwd, file))]));
5681
- const pass = spawnSync(linter.bin, [...linter.args, ...batch], {
5682
- cwd: ctx.cwd,
5686
+ const pass = spawnSync(linter.bin, [...linter.args, ...batch.map(fromRoot)], {
5687
+ cwd: workspaceRoot,
5683
5688
  encoding: "utf8"
5684
5689
  });
5685
5690
  if (pass.status !== 0) unsettled += 1;
@@ -53,7 +53,7 @@ import {
53
53
  selfCommand,
54
54
  splitToolArgs,
55
55
  walk
56
- } from "./chunk-TIOMI3YB.js";
56
+ } from "./chunk-RO626QTL.js";
57
57
  import {
58
58
  parseJsonc
59
59
  } from "./chunk-QXFCZON7.js";
package/dist/index.js CHANGED
@@ -6,10 +6,10 @@ import {
6
6
  registerAdapters,
7
7
  resolve,
8
8
  setDefaultRunner
9
- } from "./chunk-TAJD75KN.js";
9
+ } from "./chunk-ZSPDXVQL.js";
10
10
  import {
11
11
  BaseAdapter
12
- } from "./chunk-TIOMI3YB.js";
12
+ } from "./chunk-RO626QTL.js";
13
13
  import "./chunk-O7REVMOC.js";
14
14
  import "./chunk-QXFCZON7.js";
15
15
  import "./chunk-NW6UHNYX.js";
@@ -7,7 +7,7 @@ import {
7
7
  readTestAdoption,
8
8
  resolveVitest,
9
9
  suiteOf
10
- } from "./chunk-TIOMI3YB.js";
10
+ } from "./chunk-RO626QTL.js";
11
11
  import "./chunk-O7REVMOC.js";
12
12
  import "./chunk-QXFCZON7.js";
13
13
  import "./chunk-NW6UHNYX.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hublo/sentinel",
3
- "version": "1.4.0-alpha.43",
3
+ "version": "1.4.0-alpha.44",
4
4
  "description": "One CLI that guards code health across Hublo repos: shared lint/typescript/build/test presets, static & dynamic analysis, and architecture checks.",
5
5
  "type": "module",
6
6
  "license": "MIT",