headlamp 0.1.29 → 0.1.31
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 +114 -1
- package/dist/cli.cjs.map +3 -3
- package/dist/index.js +114 -1
- package/dist/index.js.map +3 -3
- package/package.json +9 -1
package/dist/cli.cjs
CHANGED
|
@@ -60898,6 +60898,8 @@ var program = async () => {
|
|
|
60898
60898
|
let jestExitCode = 0;
|
|
60899
60899
|
const allBridgeJson = [];
|
|
60900
60900
|
const executedTestFilesSet = /* @__PURE__ */ new Set();
|
|
60901
|
+
const coverageFailureLines = [];
|
|
60902
|
+
let anyTestFailed = false;
|
|
60901
60903
|
if (shouldRunJest) {
|
|
60902
60904
|
console.info("Starting Jest (no Vitest targets)\u2026");
|
|
60903
60905
|
await runJestBootstrap(bootstrapCommand);
|
|
@@ -61486,6 +61488,17 @@ ${stripFooter(rawAlso)}`.trimEnd();
|
|
|
61486
61488
|
} catch {
|
|
61487
61489
|
}
|
|
61488
61490
|
pretty = stripFooter(pretty);
|
|
61491
|
+
try {
|
|
61492
|
+
const simpleOut = stripAnsiSimple(output);
|
|
61493
|
+
const lines = simpleOut.split(/\r?\n/).map((ln2) => ln2.trim()).filter(Boolean);
|
|
61494
|
+
const matches = lines.filter(
|
|
61495
|
+
(ln2) => /Coverage for (Statements|Branches|Functions|Lines)/i.test(ln2) && /does not meet/i.test(ln2)
|
|
61496
|
+
);
|
|
61497
|
+
for (const m3 of matches) {
|
|
61498
|
+
if (!coverageFailureLines.includes(m3)) coverageFailureLines.push(m3);
|
|
61499
|
+
}
|
|
61500
|
+
} catch {
|
|
61501
|
+
}
|
|
61489
61502
|
if (pretty.trim().length > 0) {
|
|
61490
61503
|
if (useTty) {
|
|
61491
61504
|
process.stdout.write("\n");
|
|
@@ -61550,6 +61563,7 @@ ${stripFooter(rawAlso)}`.trimEnd();
|
|
|
61550
61563
|
} catch {
|
|
61551
61564
|
}
|
|
61552
61565
|
const showStacks = Boolean(unified.aggregated?.numFailedTests > 0);
|
|
61566
|
+
anyTestFailed = Number(unified.aggregated?.numFailedTests ?? 0) > 0;
|
|
61553
61567
|
let text = renderVitestFromJestJSON(
|
|
61554
61568
|
unified,
|
|
61555
61569
|
makeCtx(
|
|
@@ -61568,7 +61582,7 @@ ${stripFooter(rawAlso)}`.trimEnd();
|
|
|
61568
61582
|
}
|
|
61569
61583
|
}
|
|
61570
61584
|
const finalExitCode = jestExitCode;
|
|
61571
|
-
if (
|
|
61585
|
+
if (coverageAbortOnFailure && finalExitCode !== 0 && anyTestFailed) {
|
|
61572
61586
|
process.exit(finalExitCode);
|
|
61573
61587
|
return;
|
|
61574
61588
|
}
|
|
@@ -61591,6 +61605,105 @@ ${stripFooter(rawAlso)}`.trimEnd();
|
|
|
61591
61605
|
executedTests: Array.from(executedTestFilesSet)
|
|
61592
61606
|
};
|
|
61593
61607
|
await emitMergedCoverage(coverageUi, mergedOptsBase);
|
|
61608
|
+
if (finalExitCode !== 0 && !anyTestFailed) {
|
|
61609
|
+
try {
|
|
61610
|
+
const header = `${ansi.red("Coverage thresholds not met")}`;
|
|
61611
|
+
process.stdout.write(`
|
|
61612
|
+
${header}
|
|
61613
|
+
`);
|
|
61614
|
+
const summaryTxt = (() => {
|
|
61615
|
+
try {
|
|
61616
|
+
const summaryPath = path16.resolve("coverage", "merged", "coverage-summary.txt");
|
|
61617
|
+
if (fsSync4.existsSync(summaryPath)) return fsSync4.readFileSync(summaryPath, "utf8");
|
|
61618
|
+
} catch {
|
|
61619
|
+
}
|
|
61620
|
+
try {
|
|
61621
|
+
const textPath = path16.resolve("coverage", "merged", "coverage.txt");
|
|
61622
|
+
if (fsSync4.existsSync(textPath)) return fsSync4.readFileSync(textPath, "utf8");
|
|
61623
|
+
} catch {
|
|
61624
|
+
}
|
|
61625
|
+
return "";
|
|
61626
|
+
})();
|
|
61627
|
+
const mergedBody = stripAnsiSimple(summaryTxt);
|
|
61628
|
+
const pctRe = /(Statements|Branches|Functions|Lines)\s*:\s*(\d+(?:\.\d+)?)%/g;
|
|
61629
|
+
const percents = /* @__PURE__ */ new Map();
|
|
61630
|
+
{
|
|
61631
|
+
let m3;
|
|
61632
|
+
while (m3 = pctRe.exec(mergedBody)) {
|
|
61633
|
+
const label = String(m3[1]);
|
|
61634
|
+
const pct = Number(m3[2]);
|
|
61635
|
+
if (!Number.isNaN(pct)) percents.set(label, pct);
|
|
61636
|
+
}
|
|
61637
|
+
}
|
|
61638
|
+
const thresholds = /* @__PURE__ */ new Map();
|
|
61639
|
+
try {
|
|
61640
|
+
const firstCfg = Array.isArray(projectConfigs) && projectConfigs.length ? projectConfigs[0] : void 0;
|
|
61641
|
+
if (firstCfg && fsSync4.existsSync(firstCfg)) {
|
|
61642
|
+
const cfgText = fsSync4.readFileSync(firstCfg, "utf8");
|
|
61643
|
+
const blockRe = /coverageThreshold\s*:\s*\{[\s\S]*?global\s*:\s*\{([\s\S]*?)\}/m;
|
|
61644
|
+
const m3 = blockRe.exec(cfgText);
|
|
61645
|
+
if (m3) {
|
|
61646
|
+
const blk = m3[1] || "";
|
|
61647
|
+
const pick = (key) => {
|
|
61648
|
+
const r4 = new RegExp(`${key}\\s*:\\s*(\\d+)`, "i");
|
|
61649
|
+
const mm = r4.exec(blk);
|
|
61650
|
+
return mm ? Number(mm[1]) : void 0;
|
|
61651
|
+
};
|
|
61652
|
+
const st = pick("statements");
|
|
61653
|
+
const br = pick("branches");
|
|
61654
|
+
const fn2 = pick("functions");
|
|
61655
|
+
const ln2 = pick("lines");
|
|
61656
|
+
if (typeof st === "number") thresholds.set("Statements", st);
|
|
61657
|
+
if (typeof br === "number") thresholds.set("Branches", br);
|
|
61658
|
+
if (typeof fn2 === "number") thresholds.set("Functions", fn2);
|
|
61659
|
+
if (typeof ln2 === "number") thresholds.set("Lines", ln2);
|
|
61660
|
+
}
|
|
61661
|
+
}
|
|
61662
|
+
} catch {
|
|
61663
|
+
}
|
|
61664
|
+
const labels = [
|
|
61665
|
+
"Statements",
|
|
61666
|
+
"Branches",
|
|
61667
|
+
"Functions",
|
|
61668
|
+
"Lines"
|
|
61669
|
+
];
|
|
61670
|
+
let printedAny = false;
|
|
61671
|
+
for (const label of labels) {
|
|
61672
|
+
const pct = percents.get(label);
|
|
61673
|
+
const need = thresholds.get(label);
|
|
61674
|
+
if (typeof pct === "number" && typeof need === "number") {
|
|
61675
|
+
printedAny = true;
|
|
61676
|
+
if (pct >= need) {
|
|
61677
|
+
process.stdout.write(`${ansi.green(` ${label}: ${pct.toFixed(2)}% \u2265 ${need}%`)}
|
|
61678
|
+
`);
|
|
61679
|
+
} else {
|
|
61680
|
+
const delta = (need - pct).toFixed(2);
|
|
61681
|
+
process.stdout.write(
|
|
61682
|
+
`${ansi.red(` ${label}: ${pct.toFixed(2)}% < ${need}% (short ${delta}%)`)}
|
|
61683
|
+
`
|
|
61684
|
+
);
|
|
61685
|
+
}
|
|
61686
|
+
}
|
|
61687
|
+
}
|
|
61688
|
+
if (!printedAny) {
|
|
61689
|
+
if (coverageFailureLines.length > 0) {
|
|
61690
|
+
for (const line of coverageFailureLines)
|
|
61691
|
+
process.stdout.write(`${ansi.red(" - ")}${line}
|
|
61692
|
+
`);
|
|
61693
|
+
} else {
|
|
61694
|
+
process.stdout.write(
|
|
61695
|
+
`${ansi.red(" - Coverage failed. See tables above and jest coverageThreshold.")}`
|
|
61696
|
+
);
|
|
61697
|
+
process.stdout.write("\n");
|
|
61698
|
+
}
|
|
61699
|
+
}
|
|
61700
|
+
} catch {
|
|
61701
|
+
}
|
|
61702
|
+
}
|
|
61703
|
+
}
|
|
61704
|
+
if (coverageAbortOnFailure && finalExitCode !== 0) {
|
|
61705
|
+
process.exit(finalExitCode);
|
|
61706
|
+
return;
|
|
61594
61707
|
}
|
|
61595
61708
|
process.exit(finalExitCode);
|
|
61596
61709
|
};
|