headlamp 0.1.8 → 0.1.10
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/README.md +49 -0
- package/dist/cli.cjs +109 -12
- package/dist/cli.cjs.map +3 -3
- package/dist/index.js +109 -12
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -52,6 +52,7 @@ var init_args = __esm({
|
|
|
52
52
|
coverage: (coverageValue) => ({ type: "coverage", coverageValue }),
|
|
53
53
|
coverageUi: (value) => ({ type: "coverageUi", value }),
|
|
54
54
|
coverageAbortOnFailure: (value) => ({ type: "coverageAbortOnFailure", value }),
|
|
55
|
+
onlyFailures: (value) => ({ type: "onlyFailures", value }),
|
|
55
56
|
jestArg: (value) => ({ type: "jestArg", value }),
|
|
56
57
|
jestArgs: (values) => ({ type: "jestArgs", values }),
|
|
57
58
|
vitestArg: (value) => ({ type: "vitestArg", value }),
|
|
@@ -205,6 +206,18 @@ var init_args = __esm({
|
|
|
205
206
|
"--coverage.pageFit",
|
|
206
207
|
(_flag, lookahead) => step([ActionBuilders.coveragePageFit(isTruthy(String(lookahead)))], true)
|
|
207
208
|
),
|
|
209
|
+
// --onlyFailures flag (boolean)
|
|
210
|
+
rule.eq("--onlyFailures", () => step([ActionBuilders.onlyFailures(true)])),
|
|
211
|
+
rule.startsWith(
|
|
212
|
+
"--onlyFailures=",
|
|
213
|
+
(value) => step([
|
|
214
|
+
ActionBuilders.onlyFailures(isTruthy((value.split("=")[1] ?? "").trim().toLowerCase()))
|
|
215
|
+
])
|
|
216
|
+
),
|
|
217
|
+
rule.withLookahead(
|
|
218
|
+
"--onlyFailures",
|
|
219
|
+
(_flag, lookahead) => step([ActionBuilders.onlyFailures(isTruthy(String(lookahead)))], true)
|
|
220
|
+
),
|
|
208
221
|
rule.withLookahead(
|
|
209
222
|
"--testPathPattern",
|
|
210
223
|
(flag, lookahead) => step([ActionBuilders.jestArgs([flag, lookahead])], true)
|
|
@@ -269,12 +282,12 @@ var init_args = __esm({
|
|
|
269
282
|
rule.eq("--changed", () => step([ActionBuilders.changed("all")])),
|
|
270
283
|
rule.startsWith("--changed=", (value) => {
|
|
271
284
|
const raw = (value.split("=")[1] ?? "").trim().toLowerCase();
|
|
272
|
-
const mode = raw === "staged" ? "staged" : raw === "unstaged" ? "unstaged" : "all";
|
|
285
|
+
const mode = raw === "staged" ? "staged" : raw === "unstaged" ? "unstaged" : raw === "branch" ? "branch" : "all";
|
|
273
286
|
return step([ActionBuilders.changed(mode)]);
|
|
274
287
|
}),
|
|
275
288
|
rule.withLookahead("--changed", (_flag, lookahead) => {
|
|
276
289
|
const raw = String(lookahead).trim().toLowerCase();
|
|
277
|
-
const mode = raw === "staged" ? "staged" : raw === "unstaged" ? "unstaged" : "all";
|
|
290
|
+
const mode = raw === "staged" ? "staged" : raw === "unstaged" ? "unstaged" : raw === "branch" ? "branch" : "all";
|
|
278
291
|
return step([ActionBuilders.changed(mode)], true);
|
|
279
292
|
}),
|
|
280
293
|
rule.withLookahead(
|
|
@@ -351,6 +364,8 @@ var init_args = __esm({
|
|
|
351
364
|
return { vitest: [], jest: [], coverage: false, coverageUi: action.value };
|
|
352
365
|
case "coverageAbortOnFailure":
|
|
353
366
|
return { vitest: [], jest: [], coverage: false, coverageAbortOnFailure: action.value };
|
|
367
|
+
case "onlyFailures":
|
|
368
|
+
return { vitest: [], jest: [], coverage: false, onlyFailures: action.value };
|
|
354
369
|
case "jestArgs":
|
|
355
370
|
return { vitest: [], jest: action.values, coverage: false };
|
|
356
371
|
case "selectionHint":
|
|
@@ -422,6 +437,7 @@ var init_args = __esm({
|
|
|
422
437
|
...next,
|
|
423
438
|
...right.changed !== void 0 || left.changed !== void 0 ? { changed: right.changed ?? left.changed } : {},
|
|
424
439
|
...right.coverageAbortOnFailure !== void 0 || left.coverageAbortOnFailure !== void 0 ? { coverageAbortOnFailure: right.coverageAbortOnFailure ?? left.coverageAbortOnFailure } : {},
|
|
440
|
+
...right.onlyFailures !== void 0 || left.onlyFailures !== void 0 ? { onlyFailures: right.onlyFailures ?? left.onlyFailures } : {},
|
|
425
441
|
...right.coverageDetail !== void 0 || left.coverageDetail !== void 0 ? { coverageDetail: right.coverageDetail ?? left.coverageDetail } : {},
|
|
426
442
|
...right.coverageShowCode !== void 0 || left.coverageShowCode !== void 0 ? { coverageShowCode: right.coverageShowCode ?? left.coverageShowCode } : {},
|
|
427
443
|
...right.coverageMode !== void 0 || left.coverageMode !== void 0 ? { coverageMode: right.coverageMode ?? left.coverageMode } : {},
|
|
@@ -445,6 +461,7 @@ var init_args = __esm({
|
|
|
445
461
|
let collectCoverage = false;
|
|
446
462
|
let coverageUi = "both";
|
|
447
463
|
let coverageAbortOnFailure = false;
|
|
464
|
+
let onlyFailures = false;
|
|
448
465
|
let coverageShowCode = Boolean(process.stdout.isTTY);
|
|
449
466
|
let coverageMode = "auto";
|
|
450
467
|
const coverageMaxFilesLocalInit = void 0;
|
|
@@ -462,6 +479,7 @@ var init_args = __esm({
|
|
|
462
479
|
collectCoverage ||= contrib.coverage;
|
|
463
480
|
coverageUi = contrib.coverageUi ?? coverageUi;
|
|
464
481
|
coverageAbortOnFailure = contrib.coverageAbortOnFailure ?? coverageAbortOnFailure;
|
|
482
|
+
onlyFailures = contrib.onlyFailures ?? onlyFailures;
|
|
465
483
|
coverageShowCode = contrib.coverageShowCode ?? coverageShowCode;
|
|
466
484
|
const coverageDetailComputed = contrib.coverageDetail ?? (contrib.selection ? "auto" : void 0);
|
|
467
485
|
coverageMode = contrib.coverageMode ?? (contrib.selection ? "compact" : "auto");
|
|
@@ -495,6 +513,7 @@ var init_args = __esm({
|
|
|
495
513
|
collectCoverage,
|
|
496
514
|
coverageUi,
|
|
497
515
|
coverageAbortOnFailure,
|
|
516
|
+
onlyFailures,
|
|
498
517
|
selectionSpecified: Boolean(contrib.selection),
|
|
499
518
|
selectionPaths: [...contrib.selectionPaths ?? []],
|
|
500
519
|
includeGlobs,
|
|
@@ -6280,6 +6299,7 @@ var formatJestOutputVitest = (raw, opts) => {
|
|
|
6280
6299
|
const projectHint = new RegExp(
|
|
6281
6300
|
`(${cwd.replace(/[.*+?^${}()|[\\]\\\\]/g, "\\$&")})|(/gigworx-node/)`
|
|
6282
6301
|
);
|
|
6302
|
+
const onlyFailures = Boolean(opts?.onlyFailures);
|
|
6283
6303
|
const lines = raw.split(/\r?\n/);
|
|
6284
6304
|
const out = [];
|
|
6285
6305
|
const seenFailures = /* @__PURE__ */ new Set();
|
|
@@ -6367,8 +6387,10 @@ var formatJestOutputVitest = (raw, opts) => {
|
|
|
6367
6387
|
continue;
|
|
6368
6388
|
}
|
|
6369
6389
|
seenFiles.add(rel);
|
|
6370
|
-
|
|
6371
|
-
|
|
6390
|
+
if (!(onlyFailures && badge === "PASS")) {
|
|
6391
|
+
const pill = badge === "PASS" ? colorTokens.passPill("PASS") : colorTokens.failPill("FAIL");
|
|
6392
|
+
out.push(`${pill} ${ansi.white(rel)}`);
|
|
6393
|
+
}
|
|
6372
6394
|
lineIndex += 1;
|
|
6373
6395
|
continue;
|
|
6374
6396
|
}
|
|
@@ -6481,14 +6503,21 @@ function renderVitestFromJestJSON(data, opts) {
|
|
|
6481
6503
|
`(${cwd.replace(/[.*+?^${}()|[\\]\\\\]/g, "\\$&")})|(/gigworx-node/)`
|
|
6482
6504
|
);
|
|
6483
6505
|
const ctx = { projectHint, editorCmd: opts?.editorCmd, showStacks: true };
|
|
6506
|
+
const onlyFailures = Boolean(opts?.onlyFailures);
|
|
6484
6507
|
const out = [];
|
|
6485
|
-
|
|
6486
|
-
|
|
6508
|
+
if (!onlyFailures) {
|
|
6509
|
+
out.push(renderRunLine(cwd));
|
|
6510
|
+
out.push("");
|
|
6511
|
+
}
|
|
6487
6512
|
for (const file of data.testResults) {
|
|
6488
6513
|
const rel = file.testFilePath.replace(/\\/g, "/").replace(`${cwd}/`, "");
|
|
6489
6514
|
const failed = file.testResults.filter((assertion) => assertion.status === "failed");
|
|
6490
|
-
|
|
6491
|
-
|
|
6515
|
+
if (!onlyFailures) {
|
|
6516
|
+
out.push(...buildPerFileOverview(rel, file.testResults));
|
|
6517
|
+
}
|
|
6518
|
+
if (!(onlyFailures && failed.length === 0)) {
|
|
6519
|
+
out.push(buildFileBadgeLine(rel, failed.length));
|
|
6520
|
+
}
|
|
6492
6521
|
if (file.failureMessage && failed.length === 0) {
|
|
6493
6522
|
const lines = file.failureMessage.split(/\r?\n/);
|
|
6494
6523
|
const details = linesFromDetails(file.failureDetails);
|
|
@@ -6886,6 +6915,7 @@ var program = async () => {
|
|
|
6886
6915
|
collectCoverage,
|
|
6887
6916
|
coverageUi,
|
|
6888
6917
|
coverageAbortOnFailure,
|
|
6918
|
+
onlyFailures,
|
|
6889
6919
|
selectionSpecified,
|
|
6890
6920
|
selectionPaths,
|
|
6891
6921
|
includeGlobs,
|
|
@@ -6913,6 +6943,52 @@ var program = async () => {
|
|
|
6913
6943
|
return [];
|
|
6914
6944
|
}
|
|
6915
6945
|
};
|
|
6946
|
+
if (mode === "branch") {
|
|
6947
|
+
const resolveDefaultBranch = async () => {
|
|
6948
|
+
const candidates = [];
|
|
6949
|
+
try {
|
|
6950
|
+
const sym = await collect("git", ["symbolic-ref", "refs/remotes/origin/HEAD"]);
|
|
6951
|
+
const headRef = sym.find((ln) => ln.includes("refs/remotes/origin/"));
|
|
6952
|
+
if (headRef) {
|
|
6953
|
+
const m = /refs\/remotes\/(.+)/.exec(headRef);
|
|
6954
|
+
if (m && m[1]) {
|
|
6955
|
+
candidates.push(m[1]);
|
|
6956
|
+
}
|
|
6957
|
+
}
|
|
6958
|
+
} catch {
|
|
6959
|
+
}
|
|
6960
|
+
candidates.push("origin/main", "origin/master");
|
|
6961
|
+
for (const cand of candidates) {
|
|
6962
|
+
const exists = await collect("git", ["rev-parse", "--verify", cand]);
|
|
6963
|
+
if (exists.length > 0) {
|
|
6964
|
+
return cand;
|
|
6965
|
+
}
|
|
6966
|
+
}
|
|
6967
|
+
return void 0;
|
|
6968
|
+
};
|
|
6969
|
+
const defaultBranch = await resolveDefaultBranch();
|
|
6970
|
+
const mergeBase = defaultBranch ? (await collect("git", ["merge-base", "HEAD", defaultBranch]))[0] : void 0;
|
|
6971
|
+
const diffBase = mergeBase ?? "HEAD^";
|
|
6972
|
+
const branchDiff = await collect("git", [
|
|
6973
|
+
"diff",
|
|
6974
|
+
"--name-only",
|
|
6975
|
+
"--diff-filter=ACMRTUXB",
|
|
6976
|
+
diffBase,
|
|
6977
|
+
"HEAD"
|
|
6978
|
+
]);
|
|
6979
|
+
const stagedNow = await collect("git", [
|
|
6980
|
+
"diff",
|
|
6981
|
+
"--name-only",
|
|
6982
|
+
"--diff-filter=ACMRTUXB",
|
|
6983
|
+
"--cached"
|
|
6984
|
+
]);
|
|
6985
|
+
const unstagedNow = await collect("git", ["diff", "--name-only", "--diff-filter=ACMRTUXB"]);
|
|
6986
|
+
const untrackedNow = await collect("git", ["ls-files", "--others", "--exclude-standard"]);
|
|
6987
|
+
const rels2 = Array.from(
|
|
6988
|
+
/* @__PURE__ */ new Set([...branchDiff, ...stagedNow, ...unstagedNow, ...untrackedNow])
|
|
6989
|
+
);
|
|
6990
|
+
return rels2.map((rel) => path10.resolve(cwd, rel).replace(/\\/g, "/")).filter((abs) => !abs.includes("/node_modules/") && !abs.includes("/coverage/"));
|
|
6991
|
+
}
|
|
6916
6992
|
const staged = mode === "staged" || mode === "all" ? await collect("git", ["diff", "--name-only", "--diff-filter=ACMRTUXB", "--cached"]) : [];
|
|
6917
6993
|
const unstagedTracked = mode === "unstaged" || mode === "all" ? await collect("git", ["diff", "--name-only", "--diff-filter=ACMRTUXB"]) : [];
|
|
6918
6994
|
const untracked = mode === "unstaged" || mode === "all" ? await collect("git", ["ls-files", "--others", "--exclude-standard"]) : [];
|
|
@@ -7224,6 +7300,23 @@ var program = async () => {
|
|
|
7224
7300
|
}
|
|
7225
7301
|
if (effectiveJestFiles.length === 0) {
|
|
7226
7302
|
const repoRoot = repoRootForRefinement;
|
|
7303
|
+
if (jestFiles.length === 0) {
|
|
7304
|
+
try {
|
|
7305
|
+
const allAcross = [];
|
|
7306
|
+
for (const cfg of projectConfigs) {
|
|
7307
|
+
const cfgCwd = path10.dirname(cfg);
|
|
7308
|
+
const listed = await discoverJestResilient([...jestDiscoveryArgs, "--config", cfg], {
|
|
7309
|
+
cwd: cfgCwd
|
|
7310
|
+
});
|
|
7311
|
+
allAcross.push(...listed);
|
|
7312
|
+
}
|
|
7313
|
+
const uniqAll = Array.from(new Set(allAcross.map((p) => p.replace(/\\/g, "/"))));
|
|
7314
|
+
if (uniqAll.length > 0) {
|
|
7315
|
+
jestFiles = uniqAll;
|
|
7316
|
+
}
|
|
7317
|
+
} catch {
|
|
7318
|
+
}
|
|
7319
|
+
}
|
|
7227
7320
|
const seeds = prodSelections.map(
|
|
7228
7321
|
(abs) => path10.relative(repoRoot, abs).replace(/\\/g, "/").replace(/\.(m?[tj]sx?)$/i, "")
|
|
7229
7322
|
).flatMap((rel) => {
|
|
@@ -7502,12 +7595,14 @@ var program = async () => {
|
|
|
7502
7595
|
};
|
|
7503
7596
|
pretty = renderVitestFromJestJSON(reordered, {
|
|
7504
7597
|
cwd: repoRootForDiscovery,
|
|
7505
|
-
...editorCmd !== void 0 ? { editorCmd } : {}
|
|
7598
|
+
...editorCmd !== void 0 ? { editorCmd } : {},
|
|
7599
|
+
onlyFailures
|
|
7506
7600
|
});
|
|
7507
7601
|
} catch {
|
|
7508
7602
|
pretty = renderVitestFromJestJSON(bridge, {
|
|
7509
7603
|
cwd: repoRootForDiscovery,
|
|
7510
|
-
...editorCmd !== void 0 ? { editorCmd } : {}
|
|
7604
|
+
...editorCmd !== void 0 ? { editorCmd } : {},
|
|
7605
|
+
onlyFailures
|
|
7511
7606
|
});
|
|
7512
7607
|
}
|
|
7513
7608
|
if (debug) {
|
|
@@ -7524,7 +7619,8 @@ ${preview}${pretty.includes("\n") ? "\n\u2026" : ""}`);
|
|
|
7524
7619
|
}
|
|
7525
7620
|
const renderOpts = {
|
|
7526
7621
|
cwd: repoRootForDiscovery,
|
|
7527
|
-
...editorCmd !== void 0 ? { editorCmd } : {}
|
|
7622
|
+
...editorCmd !== void 0 ? { editorCmd } : {},
|
|
7623
|
+
onlyFailures
|
|
7528
7624
|
};
|
|
7529
7625
|
pretty = formatJestOutputVitest(output, renderOpts);
|
|
7530
7626
|
if (debug) {
|
|
@@ -7590,7 +7686,8 @@ ${preview}${pretty.includes("\n") ? "\n\u2026" : ""}`);
|
|
|
7590
7686
|
}
|
|
7591
7687
|
const text = renderVitestFromJestJSON(unified, {
|
|
7592
7688
|
cwd: repoRootForDiscovery,
|
|
7593
|
-
...editorCmd !== void 0 ? { editorCmd } : {}
|
|
7689
|
+
...editorCmd !== void 0 ? { editorCmd } : {},
|
|
7690
|
+
onlyFailures
|
|
7594
7691
|
});
|
|
7595
7692
|
if (text.trim().length > 0) {
|
|
7596
7693
|
process.stdout.write(text.endsWith("\n") ? text : `${text}
|