@hublo/sentinel 1.4.0-alpha.7 → 1.4.0-alpha.9

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.
@@ -4,3 +4,4 @@ import '@vitejs/plugin-react';
4
4
  import 'nitro/vite';
5
5
  import 'vite-plugin-svgr';
6
6
  import 'vite';
7
+ import 'msw';
@@ -16,7 +16,7 @@ import {
16
16
  registerAdapters,
17
17
  resolve,
18
18
  resolveBin
19
- } from "../chunk-KDKOKRS2.js";
19
+ } from "../chunk-L7WS36XV.js";
20
20
  import {
21
21
  WORKSPACE_ROOT_MARKER,
22
22
  ensureWorkspacePrep,
@@ -5481,7 +5481,7 @@ function testTarget(options) {
5481
5481
  }
5482
5482
 
5483
5483
  // src/roles/test/jest-migration.ts
5484
- import { existsSync as existsSync29, readFileSync as readFileSync28 } from "fs";
5484
+ import { existsSync as existsSync29, readFileSync as readFileSync28, readdirSync as readdirSync8 } from "fs";
5485
5485
  import { join as join35 } from "path";
5486
5486
 
5487
5487
  // src/roles/test/codemod/migrate-module.ts
@@ -7217,6 +7217,8 @@ ${text}` });
7217
7217
  // src/roles/test/codemod/repoint-msw.ts
7218
7218
  import { parseSync as parseSync6 } from "oxc-parser";
7219
7219
  var SENTINEL_MSW_SERVER = "@hublo/sentinel/test/msw";
7220
+ var SENTINEL_MSW_API = "@hublo/sentinel/test/tools/msw";
7221
+ var MSW_PACKAGE = /^msw$/;
7220
7222
  var MSW_SERVER_MODULE = /(^|\/)msw\/server$/;
7221
7223
  function importsServer(declaration) {
7222
7224
  return (declaration.specifiers ?? []).some((specifier) => {
@@ -7233,14 +7235,20 @@ function repointMswServer(fileName, source) {
7233
7235
  if (node.type !== "ImportDeclaration") return;
7234
7236
  const specifier = node.source;
7235
7237
  if (specifier?.value === void 0) return;
7236
- if (!MSW_SERVER_MODULE.test(specifier.value) || !importsServer(node)) return;
7237
- edits.push({ start: specifier.start, end: specifier.end });
7238
+ const isServer = MSW_SERVER_MODULE.test(specifier.value) && importsServer(node);
7239
+ const isPackage2 = MSW_PACKAGE.test(specifier.value);
7240
+ if (!isServer && !isPackage2) return;
7241
+ edits.push({
7242
+ start: specifier.start,
7243
+ end: specifier.end,
7244
+ to: isServer ? SENTINEL_MSW_SERVER : SENTINEL_MSW_API
7245
+ });
7238
7246
  });
7239
7247
  if (edits.length === 0) return { source, repointed: false };
7240
7248
  let rewritten = source;
7241
7249
  for (const edit of edits.sort((left, right) => right.start - left.start)) {
7242
7250
  const quote = source[edit.start] === '"' ? '"' : "'";
7243
- rewritten = rewritten.slice(0, edit.start) + `${quote}${SENTINEL_MSW_SERVER}${quote}` + rewritten.slice(edit.end);
7251
+ rewritten = rewritten.slice(0, edit.start) + `${quote}${edit.to}${quote}` + rewritten.slice(edit.end);
7244
7252
  }
7245
7253
  return { source: rewritten, repointed: true };
7246
7254
  }
@@ -8188,31 +8196,56 @@ function specTypesOperation(cwd) {
8188
8196
  return void 0;
8189
8197
  }
8190
8198
  const types = config?.compilerOptions?.types;
8191
- const include = config?.include;
8192
- const rewrittenInclude = Array.isArray(include) ? rewriteSpecInclude(include) : void 0;
8193
- const typesChanged = Array.isArray(types) && types.includes("jest");
8194
- if (!typesChanged && rewrittenInclude === void 0) return void 0;
8199
+ if (!Array.isArray(types) || !types.includes("jest")) return void 0;
8195
8200
  return {
8196
8201
  kind: "merge-json",
8197
8202
  path: SPEC_TSCONFIG,
8198
8203
  value: {
8199
- ...typesChanged ? {
8200
- compilerOptions: {
8201
- types: types.map(
8202
- (entry) => entry === "jest" ? VITEST_GLOBAL_TYPES : entry
8203
- )
8204
- }
8205
- } : {},
8206
- ...rewrittenInclude === void 0 ? {} : { include: rewrittenInclude }
8204
+ compilerOptions: {
8205
+ types: types.map((entry) => entry === "jest" ? VITEST_GLOBAL_TYPES : entry)
8206
+ }
8207
8207
  }
8208
8208
  };
8209
8209
  }
8210
- function rewriteSpecInclude(include) {
8211
- const rewritten = include.filter((entry) => typeof entry !== "string" || !JEST_CONFIG_ENTRY.test(entry)).map((entry) => typeof entry === "string" ? vitestSupportName(entry) : entry);
8212
- const unchanged = rewritten.length === include.length && rewritten.every((entry, index) => entry === include[index]);
8210
+ function tsconfigFileListOperations(cwd) {
8211
+ const operations = [];
8212
+ let names;
8213
+ try {
8214
+ names = readdirSync8(cwd).filter((name) => TSCONFIG_FILE.test(name));
8215
+ } catch {
8216
+ return operations;
8217
+ }
8218
+ for (const name of names) {
8219
+ let config;
8220
+ try {
8221
+ config = parseJsonc(
8222
+ readFileSync28(join35(cwd, name), "utf8"),
8223
+ name
8224
+ );
8225
+ } catch {
8226
+ continue;
8227
+ }
8228
+ const include = Array.isArray(config?.include) ? rewriteFileList(config.include) : void 0;
8229
+ const exclude = Array.isArray(config?.exclude) ? rewriteFileList(config.exclude) : void 0;
8230
+ if (include === void 0 && exclude === void 0) continue;
8231
+ operations.push({
8232
+ kind: "merge-json",
8233
+ path: name,
8234
+ value: {
8235
+ ...include === void 0 ? {} : { include },
8236
+ ...exclude === void 0 ? {} : { exclude }
8237
+ }
8238
+ });
8239
+ }
8240
+ return operations;
8241
+ }
8242
+ function rewriteFileList(entries) {
8243
+ const rewritten = entries.filter((entry) => typeof entry !== "string" || !JEST_CONFIG_ENTRY.test(entry)).map((entry) => typeof entry === "string" ? vitestSupportName(entry) : entry);
8244
+ const unchanged = rewritten.length === entries.length && rewritten.every((entry, index) => entry === entries[index]);
8213
8245
  return unchanged ? void 0 : rewritten;
8214
8246
  }
8215
8247
  var JEST_CONFIG_ENTRY = /(^|\/)jest\.[\w.-]*config\.[cm]?[jt]s$/;
8248
+ var TSCONFIG_FILE = /^tsconfig[\w.-]*\.json$/;
8216
8249
  function siblingScriptRewrites(cwd) {
8217
8250
  const rewrites = {};
8218
8251
  for (const [name, command] of Object.entries(moduleScripts(cwd))) {
@@ -8278,6 +8311,7 @@ function planJestMigration(context, adoption) {
8278
8311
  })),
8279
8312
  ...migration.operations,
8280
8313
  ...specTypes === void 0 ? [] : [specTypes],
8314
+ ...tsconfigFileListOperations(context.cwd),
8281
8315
  manifestOperation(context.cwd, { ...scripts, ...siblings }),
8282
8316
  ...prepared.flatMap(
8283
8317
  ({ mode }) => nxTargetOperations({
@@ -9800,7 +9834,7 @@ function applyPlan(cwd, plan4) {
9800
9834
  }
9801
9835
 
9802
9836
  // src/core/config/preset-evidence.ts
9803
- import { existsSync as existsSync33, readdirSync as readdirSync8, readFileSync as readFileSync34 } from "fs";
9837
+ import { existsSync as existsSync33, readdirSync as readdirSync9, readFileSync as readFileSync34 } from "fs";
9804
9838
  import { join as join40 } from "path";
9805
9839
  var PATH_SIGNALS = [
9806
9840
  {
@@ -9829,7 +9863,7 @@ function sourceImports(cwd, pattern) {
9829
9863
  const dir = stack.pop();
9830
9864
  let entries;
9831
9865
  try {
9832
- entries = readdirSync8(dir, { withFileTypes: true });
9866
+ entries = readdirSync9(dir, { withFileTypes: true });
9833
9867
  } catch {
9834
9868
  continue;
9835
9869
  }
@@ -9867,7 +9901,7 @@ function dependencyNames(cwd) {
9867
9901
  function declaresJsx(cwd) {
9868
9902
  let entries;
9869
9903
  try {
9870
- entries = readdirSync8(cwd).filter(
9904
+ entries = readdirSync9(cwd).filter(
9871
9905
  (name) => name.startsWith("tsconfig") && name.endsWith(".json")
9872
9906
  );
9873
9907
  } catch {
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  registerAdapters,
8
8
  resolve,
9
9
  setDefaultRunner
10
- } from "./chunk-KDKOKRS2.js";
10
+ } from "./chunk-L7WS36XV.js";
11
11
  import "./chunk-WLFE5RUU.js";
12
12
  export {
13
13
  BaseAdapter,
@@ -0,0 +1 @@
1
+ export * from 'msw';
@@ -0,0 +1,3 @@
1
+ // src/roles/test/tools/msw.ts
2
+ export * from "msw";
3
+ //# sourceMappingURL=msw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/roles/test/tools/msw.ts"],"sourcesContent":["/**\n * msw, from the copy sentinel governs, with nothing else in the box.\n *\n * ## Why a second entry, beside `test/msw`\n *\n * `@hublo/sentinel/test/msw` hands back the SERVER, and evaluating it starts that server. That is\n * right for the one import the codemod repoints, and wrong for every other: a spec that only wants\n * `rest` would be made to listen. Measured on `apps/nest/microservices/agency`, pointing all five\n * of its msw imports at that entry took a green suite to 444 failures, requests reaching the real\n * network because the interception had moved.\n *\n * So this file is the other half: the msw API, no server, no side effect.\n *\n * ## What it buys\n *\n * A Vite alias already gives the module ONE copy at run time. TypeScript does not read Vite\n * aliases, so it keeps resolving `msw` the way Node would, and a migrated module compiles two\n * copies: the handlers a spec builds with `rest` carry the workspace's declarations while the\n * `server` they are handed to carries sentinel's.\n *\n * TS2345 RestHandler<MockedRequest<DefaultBodyType>> is not assignable to\n * RequestHandler<RequestHandlerDefaultInfo, MockedRequest<DefaultBodyType>, ...>\n *\n * 19 of those on `agency`, a module whose typecheck was clean before it migrated and whose 535\n * tests are green. The version is the same on both sides, 1.3.3; what differs is the pnpm peer\n * set, so they are two physical copies with two sets of declarations.\n *\n * An import that BOTH tools follow closes that, where an alias only one of them reads cannot.\n *\n * ## Why `tools/`, and not a file named after one package\n *\n * Héla, 2026-09-24: a place for the cases that have this shape, not a special case for msw. The\n * shape is \"a package sentinel SHIPS whose values cross between its code and the module's\". msw is\n * the first; `vitest-mock-extended` is the other one aliased today for the same reason.\n */\nexport * from 'msw'\n"],"mappings":";AAmCA,cAAc;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hublo/sentinel",
3
- "version": "1.4.0-alpha.7",
3
+ "version": "1.4.0-alpha.9",
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",
@@ -62,6 +62,10 @@
62
62
  "types": "./dist/roles/test/setup/msw-server.d.ts",
63
63
  "import": "./dist/roles/test/setup/msw-server.js"
64
64
  },
65
+ "./test/tools/msw": {
66
+ "types": "./dist/roles/test/tools/msw.d.ts",
67
+ "import": "./dist/roles/test/tools/msw.js"
68
+ },
65
69
  "./test/setup/msw-lifecycle": {
66
70
  "types": "./dist/roles/test/setup/msw-lifecycle.d.ts",
67
71
  "import": "./dist/roles/test/setup/msw-lifecycle.js"