headlamp 0.1.25 → 0.1.27
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/cli.cjs +62 -39
- package/dist/cli.cjs.map +3 -3
- package/dist/index.js +62 -39
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -55440,7 +55440,7 @@ var require_lib2 = __commonJS({
|
|
|
55440
55440
|
// src/lib/program.ts
|
|
55441
55441
|
var path15 = __toESM(require("node:path"), 1);
|
|
55442
55442
|
var os4 = __toESM(require("node:os"), 1);
|
|
55443
|
-
var
|
|
55443
|
+
var fsSync5 = __toESM(require("node:fs"), 1);
|
|
55444
55444
|
var fs8 = __toESM(require("node:fs/promises"), 1);
|
|
55445
55445
|
var LibReport = __toESM(require("istanbul-lib-report"), 1);
|
|
55446
55446
|
var Reports = __toESM(require("istanbul-reports"), 1);
|
|
@@ -55452,6 +55452,7 @@ init_args();
|
|
|
55452
55452
|
// src/lib/discovery.ts
|
|
55453
55453
|
var path6 = __toESM(require("node:path"), 1);
|
|
55454
55454
|
var fs3 = __toESM(require("node:fs/promises"), 1);
|
|
55455
|
+
var fsSync2 = __toESM(require("node:fs"), 1);
|
|
55455
55456
|
var os3 = __toESM(require("node:os"), 1);
|
|
55456
55457
|
var import_node_crypto3 = require("node:crypto");
|
|
55457
55458
|
init_env_utils();
|
|
@@ -56139,7 +56140,27 @@ async function discoverJest(jestArgs, opts) {
|
|
|
56139
56140
|
...hasPatterns ? opts.patterns ?? [] : []
|
|
56140
56141
|
];
|
|
56141
56142
|
const jestBin2 = "./node_modules/.bin/jest";
|
|
56142
|
-
const
|
|
56143
|
+
const withAutoConfig = (args, cwd2) => {
|
|
56144
|
+
try {
|
|
56145
|
+
const candidates = [
|
|
56146
|
+
"jest.config.cjs",
|
|
56147
|
+
"jest.config.js",
|
|
56148
|
+
"jest.config.mjs",
|
|
56149
|
+
"jest.config.ts",
|
|
56150
|
+
"jest.ts.config.js",
|
|
56151
|
+
"jest.ts.config.cjs"
|
|
56152
|
+
];
|
|
56153
|
+
for (const name of candidates) {
|
|
56154
|
+
const full = path6.join(cwd2, name);
|
|
56155
|
+
if (fsSync2.existsSync(full) && !args.includes("--config")) {
|
|
56156
|
+
return [...args, "--config", name];
|
|
56157
|
+
}
|
|
56158
|
+
}
|
|
56159
|
+
} catch {
|
|
56160
|
+
}
|
|
56161
|
+
return args;
|
|
56162
|
+
};
|
|
56163
|
+
const raw = await runText(jestBin2, withAutoConfig(listArgs, opts?.cwd ?? process.cwd()), {
|
|
56143
56164
|
cwd: opts?.cwd ?? process.cwd(),
|
|
56144
56165
|
env: safeEnv(process.env, {
|
|
56145
56166
|
CI: "1",
|
|
@@ -56444,7 +56465,7 @@ var compositeBarPct = (summary, hotspots) => {
|
|
|
56444
56465
|
|
|
56445
56466
|
// src/lib/coverage-print.ts
|
|
56446
56467
|
var path9 = __toESM(require("node:path"), 1);
|
|
56447
|
-
var
|
|
56468
|
+
var fsSync3 = __toESM(require("node:fs"), 1);
|
|
56448
56469
|
init_env_utils();
|
|
56449
56470
|
init_exec();
|
|
56450
56471
|
|
|
@@ -56725,7 +56746,7 @@ var printDetailedCoverage = async (opts) => {
|
|
|
56725
56746
|
let src = "";
|
|
56726
56747
|
if (opts.showCode && topBlocks.length > 0) {
|
|
56727
56748
|
try {
|
|
56728
|
-
src =
|
|
56749
|
+
src = fsSync3.readFileSync(abs, "utf8");
|
|
56729
56750
|
} catch {
|
|
56730
56751
|
src = "";
|
|
56731
56752
|
}
|
|
@@ -59667,13 +59688,13 @@ init_config();
|
|
|
59667
59688
|
|
|
59668
59689
|
// src/lib/selection-resolver.ts
|
|
59669
59690
|
var path14 = __toESM(require("node:path"), 1);
|
|
59670
|
-
var
|
|
59691
|
+
var fsSync4 = __toESM(require("node:fs"), 1);
|
|
59671
59692
|
init_env_utils();
|
|
59672
59693
|
init_exec();
|
|
59673
59694
|
var toAbsPosix = (absPath) => path14.resolve(absPath).replace(/\\/g, "/");
|
|
59674
59695
|
var existsFile = (absPath) => {
|
|
59675
59696
|
try {
|
|
59676
|
-
const stat2 =
|
|
59697
|
+
const stat2 = fsSync4.statSync(absPath);
|
|
59677
59698
|
return stat2.isFile();
|
|
59678
59699
|
} catch {
|
|
59679
59700
|
return false;
|
|
@@ -59792,7 +59813,7 @@ var mergeLcov = async () => {
|
|
|
59792
59813
|
const collectLcovs = (dir) => {
|
|
59793
59814
|
const out = [];
|
|
59794
59815
|
try {
|
|
59795
|
-
const entries =
|
|
59816
|
+
const entries = fsSync5.readdirSync(dir, { withFileTypes: true });
|
|
59796
59817
|
for (const entry of entries) {
|
|
59797
59818
|
const full = path15.join(dir, entry.name);
|
|
59798
59819
|
if (entry.isDirectory()) {
|
|
@@ -59845,7 +59866,7 @@ var emitMergedCoverage = async (ui2, opts) => {
|
|
|
59845
59866
|
const listJsons = (dir) => {
|
|
59846
59867
|
const out = [];
|
|
59847
59868
|
try {
|
|
59848
|
-
const entries =
|
|
59869
|
+
const entries = fsSync5.readdirSync(dir, { withFileTypes: true });
|
|
59849
59870
|
for (const entry of entries) {
|
|
59850
59871
|
const full = path15.join(dir, entry.name);
|
|
59851
59872
|
if (entry.isDirectory()) {
|
|
@@ -59864,7 +59885,7 @@ var emitMergedCoverage = async (ui2, opts) => {
|
|
|
59864
59885
|
...listJsons(coverageRoot)
|
|
59865
59886
|
].map((candidatePath) => path15.resolve(candidatePath)).filter((absolutePath, index, arr) => {
|
|
59866
59887
|
const isFirst = arr.indexOf(absolutePath) === index;
|
|
59867
|
-
const exists =
|
|
59888
|
+
const exists = fsSync5.existsSync(absolutePath);
|
|
59868
59889
|
return isFirst && exists;
|
|
59869
59890
|
});
|
|
59870
59891
|
for (const jsonPath of jsonCandidates) {
|
|
@@ -59995,22 +60016,22 @@ var emitMergedCoverage = async (ui2, opts) => {
|
|
|
59995
60016
|
const textPath = path15.resolve("coverage", "merged", "coverage.txt");
|
|
59996
60017
|
const summaryPath = path15.resolve("coverage", "merged", "coverage-summary.txt");
|
|
59997
60018
|
const filesToPrint = [];
|
|
59998
|
-
if (
|
|
60019
|
+
if (fsSync5.existsSync(textPath)) {
|
|
59999
60020
|
filesToPrint.push(textPath);
|
|
60000
60021
|
}
|
|
60001
|
-
if (
|
|
60022
|
+
if (fsSync5.existsSync(summaryPath)) {
|
|
60002
60023
|
filesToPrint.push(summaryPath);
|
|
60003
60024
|
}
|
|
60004
60025
|
if (filesToPrint.length > 0) {
|
|
60005
60026
|
for (const filePath of filesToPrint) {
|
|
60006
60027
|
try {
|
|
60007
|
-
const raw =
|
|
60028
|
+
const raw = fsSync5.readFileSync(filePath, "utf8");
|
|
60008
60029
|
const colored = raw.split(/\r?\n/).map(colorizeIstanbulLine).join("\n");
|
|
60009
60030
|
process.stdout.write(colored.endsWith("\n") ? colored : `${colored}
|
|
60010
60031
|
`);
|
|
60011
60032
|
} catch {
|
|
60012
60033
|
try {
|
|
60013
|
-
const raw =
|
|
60034
|
+
const raw = fsSync5.readFileSync(filePath, "utf8");
|
|
60014
60035
|
process.stdout.write(raw.endsWith("\n") ? raw : `${raw}
|
|
60015
60036
|
`);
|
|
60016
60037
|
} catch {
|
|
@@ -60313,15 +60334,15 @@ var program = async () => {
|
|
|
60313
60334
|
const tryPushIfProd = (absPath) => {
|
|
60314
60335
|
const norm = path15.resolve(absPath).replace(/\\/g, "/");
|
|
60315
60336
|
const isTest = /(^|\/)tests?\//i.test(norm) || /\.(test|spec)\.[tj]sx?$/i.test(norm);
|
|
60316
|
-
if (!isTest &&
|
|
60337
|
+
if (!isTest && fsSync5.existsSync(norm)) {
|
|
60317
60338
|
results.add(norm);
|
|
60318
60339
|
}
|
|
60319
60340
|
};
|
|
60320
|
-
if (isAbs &&
|
|
60341
|
+
if (isAbs && fsSync5.existsSync(token)) {
|
|
60321
60342
|
tryPushIfProd(token);
|
|
60322
60343
|
continue;
|
|
60323
60344
|
}
|
|
60324
|
-
if (candidateFromRoot &&
|
|
60345
|
+
if (candidateFromRoot && fsSync5.existsSync(candidateFromRoot)) {
|
|
60325
60346
|
tryPushIfProd(candidateFromRoot);
|
|
60326
60347
|
continue;
|
|
60327
60348
|
}
|
|
@@ -60360,10 +60381,10 @@ var program = async () => {
|
|
|
60360
60381
|
try {
|
|
60361
60382
|
const baseCfg = path15.resolve("jest.config.js");
|
|
60362
60383
|
const tsCfg = path15.resolve("jest.ts.config.js");
|
|
60363
|
-
if (
|
|
60384
|
+
if (fsSync5.existsSync(baseCfg)) {
|
|
60364
60385
|
projectConfigs.push(baseCfg);
|
|
60365
60386
|
}
|
|
60366
|
-
if (
|
|
60387
|
+
if (fsSync5.existsSync(tsCfg)) {
|
|
60367
60388
|
projectConfigs.push(tsCfg);
|
|
60368
60389
|
}
|
|
60369
60390
|
} catch (err) {
|
|
@@ -60580,7 +60601,7 @@ var program = async () => {
|
|
|
60580
60601
|
const includesSeed = (text) => seeds.some((seed) => text.includes(seed));
|
|
60581
60602
|
const tryRead = (filePath) => {
|
|
60582
60603
|
try {
|
|
60583
|
-
return
|
|
60604
|
+
return fsSync5.readFileSync(filePath, "utf8");
|
|
60584
60605
|
} catch {
|
|
60585
60606
|
return "";
|
|
60586
60607
|
}
|
|
@@ -60591,13 +60612,13 @@ var program = async () => {
|
|
|
60591
60612
|
const exts = ["", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
60592
60613
|
for (const ext of exts) {
|
|
60593
60614
|
const full = ext ? `${cand}${ext}` : cand;
|
|
60594
|
-
if (
|
|
60615
|
+
if (fsSync5.existsSync(full)) {
|
|
60595
60616
|
return full;
|
|
60596
60617
|
}
|
|
60597
60618
|
}
|
|
60598
60619
|
for (const ext of exts) {
|
|
60599
60620
|
const full = path15.join(cand, `index${ext}`);
|
|
60600
|
-
if (
|
|
60621
|
+
if (fsSync5.existsSync(full)) {
|
|
60601
60622
|
return full;
|
|
60602
60623
|
}
|
|
60603
60624
|
}
|
|
@@ -60715,13 +60736,13 @@ var program = async () => {
|
|
|
60715
60736
|
const extensions = ["", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"];
|
|
60716
60737
|
for (const ext of extensions) {
|
|
60717
60738
|
const fullPath = ext ? `${candidate}${ext}` : candidate;
|
|
60718
|
-
if (
|
|
60739
|
+
if (fsSync5.existsSync(fullPath)) {
|
|
60719
60740
|
return fullPath;
|
|
60720
60741
|
}
|
|
60721
60742
|
}
|
|
60722
60743
|
for (const ext of extensions) {
|
|
60723
60744
|
const fullPath = path15.join(candidate, `index${ext}`);
|
|
60724
|
-
if (
|
|
60745
|
+
if (fsSync5.existsSync(fullPath)) {
|
|
60725
60746
|
return fullPath;
|
|
60726
60747
|
}
|
|
60727
60748
|
}
|
|
@@ -60849,12 +60870,14 @@ var program = async () => {
|
|
|
60849
60870
|
const msg = shouldRunJest ? `Jest selected (${sharePct}% of discovered tests; reason: ${forcedByNamePattern ? "name_pattern" : jestDecision.reason})` : `Skipping Jest (${sharePct}% of discovered tests; reason: ${jestDecision.reason})`;
|
|
60850
60871
|
console.info(`Discovery \u2192 jest: ${jestCount}. ${msg}`);
|
|
60851
60872
|
if (!shouldRunJest) {
|
|
60852
|
-
console.
|
|
60873
|
+
console.info(
|
|
60874
|
+
"No matching tests were discovered for either Vitest or Jest. Treating as success."
|
|
60875
|
+
);
|
|
60853
60876
|
console.info(`Jest args: ${[...jestDiscoveryArgs, "--listTests"].join(" ")}`);
|
|
60854
60877
|
console.info(
|
|
60855
60878
|
"Tip: check your -t/--testNamePattern and file path; Jest lists files selected by your patterns."
|
|
60856
60879
|
);
|
|
60857
|
-
process.exit(
|
|
60880
|
+
process.exit(0);
|
|
60858
60881
|
return;
|
|
60859
60882
|
}
|
|
60860
60883
|
console.info(`Run plan \u2192 Jest maybe=${shouldRunJest} (projects=${projectConfigs.length})`);
|
|
@@ -61002,7 +61025,7 @@ var program = async () => {
|
|
|
61002
61025
|
for (let depth = 0; depth < 6; depth += 1) {
|
|
61003
61026
|
try {
|
|
61004
61027
|
const pkg = path15.join(dir, "package.json");
|
|
61005
|
-
if (
|
|
61028
|
+
if (fsSync5.existsSync(pkg)) return dir;
|
|
61006
61029
|
} catch {
|
|
61007
61030
|
}
|
|
61008
61031
|
const parent = path15.dirname(dir);
|
|
@@ -61019,10 +61042,10 @@ var program = async () => {
|
|
|
61019
61042
|
const assetEnvPathSrc = path15.join(srcJestDir, "environment.cjs");
|
|
61020
61043
|
const assetReporterPathSrc = path15.join(srcJestDir, "reporter.cjs");
|
|
61021
61044
|
try {
|
|
61022
|
-
const haveDist =
|
|
61045
|
+
const haveDist = fsSync5.existsSync(assetReporterPathDist) && fsSync5.existsSync(assetEnvPathDist);
|
|
61023
61046
|
const useReporterSrc = haveDist ? assetReporterPathDist : assetReporterPathSrc;
|
|
61024
61047
|
const useEnvSrc = haveDist ? assetEnvPathDist : assetEnvPathSrc;
|
|
61025
|
-
if (!
|
|
61048
|
+
if (!fsSync5.existsSync(useReporterSrc) || !fsSync5.existsSync(useEnvSrc)) {
|
|
61026
61049
|
throw new Error(
|
|
61027
61050
|
`Headlamp jest assets not found. Tried:
|
|
61028
61051
|
${assetReporterPathDist}
|
|
@@ -61034,40 +61057,40 @@ Please build the package or ensure src/jest exists.`
|
|
|
61034
61057
|
}
|
|
61035
61058
|
const needsWrite = (() => {
|
|
61036
61059
|
try {
|
|
61037
|
-
const existing =
|
|
61038
|
-
const desired =
|
|
61060
|
+
const existing = fsSync5.readFileSync(reporterPath, "utf8");
|
|
61061
|
+
const desired = fsSync5.readFileSync(useReporterSrc, "utf8");
|
|
61039
61062
|
return existing !== desired;
|
|
61040
61063
|
} catch {
|
|
61041
61064
|
return true;
|
|
61042
61065
|
}
|
|
61043
61066
|
})();
|
|
61044
61067
|
if (needsWrite) {
|
|
61045
|
-
|
|
61068
|
+
fsSync5.mkdirSync(path15.dirname(reporterPath), { recursive: true });
|
|
61046
61069
|
try {
|
|
61047
|
-
|
|
61070
|
+
fsSync5.copyFileSync(useReporterSrc, reporterPath);
|
|
61048
61071
|
} catch {
|
|
61049
61072
|
}
|
|
61050
61073
|
}
|
|
61051
61074
|
try {
|
|
61052
61075
|
const outOfDate = (() => {
|
|
61053
61076
|
try {
|
|
61054
|
-
const existingEnv =
|
|
61055
|
-
const desiredEnv =
|
|
61077
|
+
const existingEnv = fsSync5.readFileSync(envPath, "utf8");
|
|
61078
|
+
const desiredEnv = fsSync5.readFileSync(useEnvSrc, "utf8");
|
|
61056
61079
|
return existingEnv !== desiredEnv;
|
|
61057
61080
|
} catch {
|
|
61058
61081
|
return true;
|
|
61059
61082
|
}
|
|
61060
61083
|
})();
|
|
61061
61084
|
if (outOfDate) {
|
|
61062
|
-
|
|
61085
|
+
fsSync5.copyFileSync(useEnvSrc, envPath);
|
|
61063
61086
|
}
|
|
61064
61087
|
} catch {
|
|
61065
61088
|
try {
|
|
61066
|
-
|
|
61089
|
+
fsSync5.mkdirSync(path15.dirname(envPath), { recursive: true });
|
|
61067
61090
|
} catch {
|
|
61068
61091
|
}
|
|
61069
61092
|
try {
|
|
61070
|
-
|
|
61093
|
+
fsSync5.copyFileSync(useEnvSrc, envPath);
|
|
61071
61094
|
} catch {
|
|
61072
61095
|
}
|
|
61073
61096
|
}
|
|
@@ -61229,10 +61252,10 @@ Please build the package or ensure src/jest exists.`
|
|
|
61229
61252
|
if (debug2) {
|
|
61230
61253
|
const capturedLen = output.length;
|
|
61231
61254
|
console.info(`jest captured output length=${capturedLen}`);
|
|
61232
|
-
const fileSizeBytes =
|
|
61255
|
+
const fileSizeBytes = fsSync5.existsSync(outJson) ? fsSync5.statSync(outJson).size : -1;
|
|
61233
61256
|
console.info(`bridge json @ ${outJson} size=${fileSizeBytes}`);
|
|
61234
61257
|
}
|
|
61235
|
-
const jsonText =
|
|
61258
|
+
const jsonText = fsSync5.readFileSync(outJson, "utf8");
|
|
61236
61259
|
const parsed = JSON.parse(jsonText);
|
|
61237
61260
|
const bridgeBase = coerceJestJsonToBridge(parsed);
|
|
61238
61261
|
const filteredForNamePattern = (() => {
|