@hublo/sentinel 1.4.0-alpha.8 → 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.
- package/dist/bin/sentinel.d.ts +1 -0
- package/dist/bin/sentinel.js +1 -1
- package/dist/{chunk-QP37G2HO.js → chunk-L7WS36XV.js} +11 -3
- package/dist/index.js +1 -1
- package/dist/roles/test/tools/msw.d.ts +1 -0
- package/dist/roles/test/tools/msw.js +3 -0
- package/dist/roles/test/tools/msw.js.map +1 -0
- package/package.json +5 -1
package/dist/bin/sentinel.d.ts
CHANGED
package/dist/bin/sentinel.js
CHANGED
|
@@ -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
|
-
|
|
7237
|
-
|
|
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}${
|
|
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
|
}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'msw';
|
|
@@ -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.
|
|
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"
|