@hublo/sentinel 1.4.0-alpha.12 → 1.4.0-alpha.14

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.
@@ -16,7 +16,7 @@ import {
16
16
  registerAdapters,
17
17
  resolve,
18
18
  resolveBin
19
- } from "../chunk-KGI2F2QK.js";
19
+ } from "../chunk-YHGCBMKJ.js";
20
20
  import {
21
21
  WORKSPACE_ROOT_MARKER,
22
22
  ensureWorkspacePrep,
@@ -8211,13 +8211,14 @@ function specTypesOperation(cwd) {
8211
8211
  function mockExtendedTypesPath(cwd) {
8212
8212
  try {
8213
8213
  const manifest = createRequire6(join35(cwd, "noop.cjs")).resolve("@hublo/sentinel/package.json");
8214
- const file = join35(dirname7(manifest), "types", "mock-extended.d.ts");
8215
- if (!existsSync29(file)) return void 0;
8216
- const path = relative7(cwd, file);
8217
- return path.startsWith(".") ? path : `./${path}`;
8214
+ const file = join35(dirname7(manifest), MOCK_EXTENDED_TYPES);
8215
+ if (existsSync29(file)) {
8216
+ const path = relative7(cwd, file);
8217
+ return path.startsWith(".") ? path : `./${path}`;
8218
+ }
8218
8219
  } catch {
8219
- return void 0;
8220
8220
  }
8221
+ return `./node_modules/@hublo/sentinel/${MOCK_EXTENDED_TYPES}`;
8221
8222
  }
8222
8223
  function tsconfigFileListOperations(cwd) {
8223
8224
  const operations = [];
@@ -8239,14 +8240,17 @@ function tsconfigFileListOperations(cwd) {
8239
8240
  }
8240
8241
  const include = Array.isArray(config?.include) ? rewriteFileList(config.include) : void 0;
8241
8242
  const exclude = Array.isArray(config?.exclude) ? rewriteFileList(config.exclude) : void 0;
8242
- const withTypes = name === SPEC_TSCONFIG ? withMockExtendedTypes(cwd, include ?? config?.include) : void 0;
8243
- if (include === void 0 && exclude === void 0 && withTypes === void 0) continue;
8243
+ const files = Array.isArray(config?.files) ? rewriteFileList(config.files) : void 0;
8244
+ const withTypes = name === SPEC_TSCONFIG ? withMockExtendedTypes(cwd, files ?? config?.files) : void 0;
8245
+ if (include === void 0 && exclude === void 0 && files === void 0 && withTypes === void 0)
8246
+ continue;
8244
8247
  operations.push({
8245
8248
  kind: "merge-json",
8246
8249
  path: name,
8247
8250
  value: {
8248
- ...withTypes === void 0 ? include === void 0 ? {} : { include } : { include: withTypes },
8249
- ...exclude === void 0 ? {} : { exclude }
8251
+ ...include === void 0 ? {} : { include },
8252
+ ...exclude === void 0 ? {} : { exclude },
8253
+ ...withTypes === void 0 ? files === void 0 ? {} : { files } : { files: withTypes }
8250
8254
  }
8251
8255
  });
8252
8256
  }
@@ -8257,13 +8261,12 @@ function rewriteFileList(entries) {
8257
8261
  const unchanged = rewritten.length === entries.length && rewritten.every((entry, index) => entry === entries[index]);
8258
8262
  return unchanged ? void 0 : rewritten;
8259
8263
  }
8260
- function withMockExtendedTypes(cwd, include) {
8261
- const path = mockExtendedTypesPath(cwd);
8262
- if (path === void 0 || !Array.isArray(include)) return void 0;
8263
- const entries = include;
8264
- if (entries.some((entry) => entry.endsWith("types/mock-extended.d.ts"))) return void 0;
8265
- return [...entries, path];
8264
+ function withMockExtendedTypes(cwd, files) {
8265
+ const entries = Array.isArray(files) ? files : [];
8266
+ if (entries.some((entry) => entry.endsWith(MOCK_EXTENDED_TYPES))) return void 0;
8267
+ return [...entries, mockExtendedTypesPath(cwd)];
8266
8268
  }
8269
+ var MOCK_EXTENDED_TYPES = "types/mock-extended.d.ts";
8267
8270
  var JEST_CONFIG_ENTRY = /(^|\/)jest\.[\w.-]*config\.[cm]?[jt]s$/;
8268
8271
  var TSCONFIG_FILE = /^tsconfig[\w.-]*\.json$/;
8269
8272
  function siblingScriptRewrites(cwd) {
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  registerAdapters,
8
8
  resolve,
9
9
  setDefaultRunner
10
- } from "./chunk-KGI2F2QK.js";
10
+ } from "./chunk-YHGCBMKJ.js";
11
11
  import "./chunk-WLFE5RUU.js";
12
12
  export {
13
13
  BaseAdapter,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hublo/sentinel",
3
- "version": "1.4.0-alpha.12",
3
+ "version": "1.4.0-alpha.14",
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",
@@ -66,6 +66,10 @@
66
66
  "types": "./dist/roles/test/tools/msw.d.ts",
67
67
  "import": "./dist/roles/test/tools/msw.js"
68
68
  },
69
+ "./test/tools/mock-extended": {
70
+ "types": "./dist/roles/test/setup/mock-extended.d.ts",
71
+ "import": "./dist/roles/test/setup/mock-extended.js"
72
+ },
69
73
  "./test/setup/msw-lifecycle": {
70
74
  "types": "./dist/roles/test/setup/msw-lifecycle.d.ts",
71
75
  "import": "./dist/roles/test/setup/msw-lifecycle.js"
@@ -5,19 +5,36 @@
5
5
  * time a migrated module has ONE copy. TypeScript does not read Vite's aliases, so it keeps
6
6
  * resolving the jest package and a migrated spec ends up compiling two worlds at once:
7
7
  *
8
- * the value typeof mockDeep<Db>() -> CalledWithMock<…> extends jest.Mock
8
+ * the value typeof mockDeep<Db>() -> CalledWithMock<…> extends jest.Mock
9
9
  * the spec let spy: MockInstance -> vitest's own type
10
10
  * TS2322 not assignable
11
11
  *
12
12
  * Measured on `apps/nest/microservices/agency`: one error, on a module whose typecheck was clean
13
13
  * before it migrated. 34 files under `libs/` export a type built this way.
14
14
  *
15
- * ## Why here, and not in the module
15
+ * ## Why it re-exports a SUBPATH of sentinel rather than `vitest-mock-extended`
16
16
  *
17
- * The declaration REPLACES the module's types with whatever it re-exports, so it has to name a
18
- * package that resolves from wherever the file sits. `vitest-mock-extended` is sentinel's
19
- * dependency, so a copy of this file placed in an adopting module would resolve nothing and empty
20
- * the module out: measured, `Module '"jest-mock-extended"' has no exported member 'mockDeep'`.
17
+ * Because a bare `vitest-mock-extended` does not resolve from here, which was measured with
18
+ * `--traceResolution` after the first attempt emptied the module out:
19
+ *
20
+ * Resolving module 'vitest-mock-extended' from '…/agency/node_modules/@hublo/sentinel/types/…'
21
+ * Module name 'vitest-mock-extended' was not resolved.
22
+ *
23
+ * The module's `tsconfig.spec.json` names this file by PATH, so TypeScript keeps the symlink path
24
+ * pnpm installed and walks up from there: `…/sentinel/node_modules`, then the module's, then the
25
+ * workspace's. Sentinel's own dependency sits in the store beside its real directory, and none of
26
+ * those three is it. A file reached by RESOLUTION is realpathed into the store instead, and its
27
+ * dependencies are found: same trace, `@hublo/sentinel/test/tools/msw` → `msw` resolved.
28
+ *
29
+ * `skipLibCheck` is on in every module here, so the failed `export *` was silent and what surfaced
30
+ * was an empty module: 18 × `Module '"jest-mock-extended"' has no exported member 'mockDeep'`.
31
+ *
32
+ * ## Why THIS subpath
33
+ *
34
+ * `@hublo/sentinel/test/tools/mock-extended` is the very module the runtime alias points at, so the
35
+ * types a spec compiles against are the ones it runs against, down to the lifecycle helpers the
36
+ * fork adds. Re-exporting `vitest-mock-extended` directly would describe something adjacent to what
37
+ * executes.
21
38
  *
22
39
  * ## Why it does not couple modules to each other
23
40
  *
@@ -31,5 +48,5 @@
31
48
  * module at a time; this keeps the test role the same.
32
49
  */
33
50
  declare module 'jest-mock-extended' {
34
- export * from 'vitest-mock-extended'
51
+ export * from '@hublo/sentinel/test/tools/mock-extended'
35
52
  }