headlamp 0.1.14 → 0.1.15

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 CHANGED
@@ -83,6 +83,8 @@ npx headlamp --changed --onlyFailures
83
83
  - Effects:
84
84
  - Uses changed production files as seeds to discover related tests by import-graph.
85
85
  - Coverage tables prioritize and annotate files related to selection/changed files.
86
+ - Additional flags:
87
+ - `--changed.depth=<n>`: cap the transitive import scan depth when refining related tests from changed production files. Default: 5. Increase to include more indirectly-related tests (slower), decrease for speed.
86
88
 
87
89
  Examples:
88
90
 
@@ -100,6 +102,16 @@ npx headlamp --changed=branch
100
102
  npx headlamp --coverage --changed=branch
101
103
  ```
102
104
 
105
+ Depth examples:
106
+
107
+ ```bash
108
+ # Scan imports up to 10 levels deep when resolving related tests for changed files
109
+ npx headlamp --changed=all --changed.depth=10
110
+
111
+ # With branch mode
112
+ npx headlamp --changed=branch --changed.depth=12
113
+ ```
114
+
103
115
  ## Coverage flags
104
116
 
105
117
  - `--coverage`: enables coverage collection and prints merged coverage output after test execution. Uses your project's Jest/Vitest setup and reads coverage JSON from Jest.
package/dist/cli.cjs CHANGED
@@ -265,7 +265,8 @@ var init_args = __esm({
265
265
  coverageMaxFiles: (value) => ({ type: "coverageMaxFiles", value }),
266
266
  coverageMaxHotspots: (value) => ({ type: "coverageMaxHotspots", value }),
267
267
  coveragePageFit: (value) => ({ type: "coveragePageFit", value }),
268
- changed: (value) => ({ type: "changed", value })
268
+ changed: (value) => ({ type: "changed", value }),
269
+ changedDepth: (value) => ({ type: "changedDepth", value })
269
270
  };
270
271
  Some = (value) => ({ _tag: "some", value });
271
272
  None = { _tag: "none" };
@@ -486,6 +487,16 @@ var init_args = __esm({
486
487
  const mode = raw === "staged" ? "staged" : raw === "unstaged" ? "unstaged" : raw === "branch" ? "branch" : "all";
487
488
  return step([ActionBuilders.changed(mode)], true);
488
489
  }),
490
+ // --changed.depth flag: maximum transitive import depth for changed selection refinement
491
+ rule.startsWith("--changed.depth=", (value) => {
492
+ const raw = (value.split("=")[1] ?? "").trim();
493
+ const num = Number(raw);
494
+ return step(Number.isFinite(num) && num > 0 ? [ActionBuilders.changedDepth(num)] : []);
495
+ }),
496
+ rule.withLookahead("--changed.depth", (_flag, lookahead) => {
497
+ const num = Number(String(lookahead).trim());
498
+ return step(Number.isFinite(num) && num > 0 ? [ActionBuilders.changedDepth(num)] : [], true);
499
+ }),
489
500
  rule.withLookahead(
490
501
  "-t",
491
502
  (flag, lookahead) => step(
@@ -592,6 +603,8 @@ var init_args = __esm({
592
603
  return { vitest: [], jest: [], coverage: false, coveragePageFit: action.value };
593
604
  case "changed":
594
605
  return { vitest: [], jest: [], coverage: false, changed: action.value };
606
+ case "changedDepth":
607
+ return { vitest: [], jest: [], coverage: false, changedDepth: action.value };
595
608
  case "jestArg":
596
609
  return { vitest: [], jest: [action.value], coverage: false };
597
610
  case "vitestArg":
@@ -632,6 +645,7 @@ var init_args = __esm({
632
645
  return {
633
646
  ...next,
634
647
  ...right.changed !== void 0 || left.changed !== void 0 ? { changed: right.changed ?? left.changed } : {},
648
+ ...right.changedDepth !== void 0 || left.changedDepth !== void 0 ? { changedDepth: right.changedDepth ?? left.changedDepth } : {},
635
649
  ...right.coverageAbortOnFailure !== void 0 || left.coverageAbortOnFailure !== void 0 ? { coverageAbortOnFailure: right.coverageAbortOnFailure ?? left.coverageAbortOnFailure } : {},
636
650
  ...right.onlyFailures !== void 0 || left.onlyFailures !== void 0 ? { onlyFailures: right.onlyFailures ?? left.onlyFailures } : {},
637
651
  ...right.coverageDetail !== void 0 || left.coverageDetail !== void 0 ? { coverageDetail: right.coverageDetail ?? left.coverageDetail } : {},
@@ -722,7 +736,8 @@ var init_args = __esm({
722
736
  coveragePageFit,
723
737
  ...contrib.editorCmd !== void 0 ? { editorCmd: contrib.editorCmd } : {},
724
738
  ...contrib.workspaceRoot !== void 0 ? { workspaceRoot: contrib.workspaceRoot } : {},
725
- ...contrib.changed !== void 0 ? { changed: contrib.changed } : {}
739
+ ...contrib.changed !== void 0 ? { changed: contrib.changed } : {},
740
+ ...contrib.changedDepth !== void 0 ? { changedDepth: contrib.changedDepth } : {}
726
741
  };
727
742
  return out;
728
743
  };
@@ -6468,7 +6483,8 @@ var program = async () => {
6468
6483
  coverageMaxFiles: coverageMaxFilesArg,
6469
6484
  coverageMaxHotspots: coverageMaxHotspotsArg,
6470
6485
  coveragePageFit,
6471
- changed
6486
+ changed,
6487
+ changedDepth
6472
6488
  } = deriveArgs(argv);
6473
6489
  const getChangedFiles = async (mode, cwd) => {
6474
6490
  const collect = async (cmd, args) => {
@@ -6940,7 +6956,7 @@ var program = async () => {
6940
6956
  resolutionCache.set(key, resolved);
6941
6957
  return resolved;
6942
6958
  };
6943
- const MAX_DEPTH = 5;
6959
+ const MAX_DEPTH = Number.isFinite(Number(changedDepth)) && Number(changedDepth) > 0 ? Number(changedDepth) : 5;
6944
6960
  const seen = /* @__PURE__ */ new Set();
6945
6961
  const matchesTransitively = async (absTestPath, depth) => {
6946
6962
  if (depth > MAX_DEPTH) {