@hublo/sentinel 1.4.0-alpha.5 → 1.4.0-alpha.6
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.js
CHANGED
|
@@ -5611,6 +5611,17 @@ function readTestAdoption(cwd) {
|
|
|
5611
5611
|
};
|
|
5612
5612
|
}
|
|
5613
5613
|
|
|
5614
|
+
// src/roles/test/support-file-name.ts
|
|
5615
|
+
var JEST_PREFIX = "jest.";
|
|
5616
|
+
var VITEST_PREFIX = "vitest.";
|
|
5617
|
+
function vitestSupportName(relative7) {
|
|
5618
|
+
const cut = relative7.lastIndexOf("/");
|
|
5619
|
+
const directory = cut === -1 ? "" : relative7.slice(0, cut + 1);
|
|
5620
|
+
const base = relative7.slice(cut + 1);
|
|
5621
|
+
if (!base.startsWith(JEST_PREFIX)) return relative7;
|
|
5622
|
+
return `${directory}${VITEST_PREFIX}${base.slice(JEST_PREFIX.length)}`;
|
|
5623
|
+
}
|
|
5624
|
+
|
|
5614
5625
|
// src/roles/test/codemod/migrate-file.ts
|
|
5615
5626
|
import { parseSync as parseSync7 } from "oxc-parser";
|
|
5616
5627
|
|
|
@@ -7571,7 +7582,9 @@ function migrateModuleTests(cwd, setupFiles = []) {
|
|
|
7571
7582
|
continue;
|
|
7572
7583
|
}
|
|
7573
7584
|
const migrated = migrateTestFile(join31(cwd, relative7), source, defaultImported);
|
|
7574
|
-
|
|
7585
|
+
const renamedTo = vitestSupportName(relative7);
|
|
7586
|
+
if (!migrated.changed && renamedTo === relative7) continue;
|
|
7587
|
+
if (renamedTo !== relative7) operations.push({ kind: "delete", path: relative7 });
|
|
7575
7588
|
const before = parse3(source);
|
|
7576
7589
|
const after = parse3(migrated.source);
|
|
7577
7590
|
if (before !== void 0 && after !== void 0) {
|
|
@@ -7582,7 +7595,7 @@ function migrateModuleTests(cwd, setupFiles = []) {
|
|
|
7582
7595
|
}
|
|
7583
7596
|
files++;
|
|
7584
7597
|
renamed += migrated.renamed;
|
|
7585
|
-
operations.push({ kind: "write", path:
|
|
7598
|
+
operations.push({ kind: "write", path: renamedTo, contents: migrated.source });
|
|
7586
7599
|
}
|
|
7587
7600
|
for (const relative7 of listTestFiles(cwd)) {
|
|
7588
7601
|
const source = read2(join31(cwd, relative7));
|
|
@@ -7704,11 +7717,11 @@ function ownsMswLifecycle(cwd, reading) {
|
|
|
7704
7717
|
function setupBlock(cwd, reading, msw) {
|
|
7705
7718
|
const declared = [...reading.setupFiles ?? [], ...reading.setupFilesAfterEnv ?? []];
|
|
7706
7719
|
const namedTheRootSetup = declared.some((file) => file.endsWith("jest.setup.after.env.js"));
|
|
7707
|
-
const own = declared.filter((file) => !file.endsWith("jest.setup.after.env.js")).map((file) => `'${withoutRootDir(file)}'`);
|
|
7720
|
+
const own = declared.filter((file) => !file.endsWith("jest.setup.after.env.js")).map((file) => `'${vitestSupportName(withoutRootDir(file))}'`);
|
|
7708
7721
|
const sentinel = [
|
|
7709
7722
|
`'${SENTINEL_TEST_SETUP}'`,
|
|
7710
7723
|
...namedTheRootSetup ? [`'${SENTINEL_WORKSPACE_SETUP}'`] : [],
|
|
7711
|
-
...msw && !ownsMswLifecycle(cwd, reading) ? [`'${SENTINEL_MSW_SETUP}'`] : []
|
|
7724
|
+
...msw && namedTheRootSetup && !ownsMswLifecycle(cwd, reading) ? [`'${SENTINEL_MSW_SETUP}'`] : []
|
|
7712
7725
|
];
|
|
7713
7726
|
return ` setupFiles: [${[...sentinel, ...own].join(", ")}],`;
|
|
7714
7727
|
}
|
|
@@ -7735,7 +7748,7 @@ function timeoutBlock(reading) {
|
|
|
7735
7748
|
}
|
|
7736
7749
|
function globalSetupBlock(reading) {
|
|
7737
7750
|
if (reading.globalSetup === void 0) return "";
|
|
7738
|
-
const files = reading.globalSetup.map((file) => `'${withoutRootDir(file)}'`).join(", ");
|
|
7751
|
+
const files = reading.globalSetup.map((file) => `'${vitestSupportName(withoutRootDir(file))}'`).join(", ");
|
|
7739
7752
|
return ` globalSetup: [${files}],`;
|
|
7740
7753
|
}
|
|
7741
7754
|
function includeBlock(reading) {
|
|
@@ -8175,17 +8188,31 @@ function specTypesOperation(cwd) {
|
|
|
8175
8188
|
return void 0;
|
|
8176
8189
|
}
|
|
8177
8190
|
const types = config?.compilerOptions?.types;
|
|
8178
|
-
|
|
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;
|
|
8179
8195
|
return {
|
|
8180
8196
|
kind: "merge-json",
|
|
8181
8197
|
path: SPEC_TSCONFIG,
|
|
8182
8198
|
value: {
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
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 }
|
|
8186
8207
|
}
|
|
8187
8208
|
};
|
|
8188
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]);
|
|
8213
|
+
return unchanged ? void 0 : rewritten;
|
|
8214
|
+
}
|
|
8215
|
+
var JEST_CONFIG_ENTRY = /(^|\/)jest\.[\w.-]*config\.[cm]?[jt]s$/;
|
|
8189
8216
|
function siblingScriptRewrites(cwd) {
|
|
8190
8217
|
const rewrites = {};
|
|
8191
8218
|
for (const [name, command] of Object.entries(moduleScripts(cwd))) {
|
package/dist/index.js
CHANGED
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.6",
|
|
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",
|