headlamp 0.1.9 → 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/dist/index.js CHANGED
@@ -282,12 +282,12 @@ var init_args = __esm({
282
282
  rule.eq("--changed", () => step([ActionBuilders.changed("all")])),
283
283
  rule.startsWith("--changed=", (value) => {
284
284
  const raw = (value.split("=")[1] ?? "").trim().toLowerCase();
285
- const mode = raw === "staged" ? "staged" : raw === "unstaged" ? "unstaged" : "all";
285
+ const mode = raw === "staged" ? "staged" : raw === "unstaged" ? "unstaged" : raw === "branch" ? "branch" : "all";
286
286
  return step([ActionBuilders.changed(mode)]);
287
287
  }),
288
288
  rule.withLookahead("--changed", (_flag, lookahead) => {
289
289
  const raw = String(lookahead).trim().toLowerCase();
290
- const mode = raw === "staged" ? "staged" : raw === "unstaged" ? "unstaged" : "all";
290
+ const mode = raw === "staged" ? "staged" : raw === "unstaged" ? "unstaged" : raw === "branch" ? "branch" : "all";
291
291
  return step([ActionBuilders.changed(mode)], true);
292
292
  }),
293
293
  rule.withLookahead(
@@ -6943,6 +6943,52 @@ var program = async () => {
6943
6943
  return [];
6944
6944
  }
6945
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
+ }
6946
6992
  const staged = mode === "staged" || mode === "all" ? await collect("git", ["diff", "--name-only", "--diff-filter=ACMRTUXB", "--cached"]) : [];
6947
6993
  const unstagedTracked = mode === "unstaged" || mode === "all" ? await collect("git", ["diff", "--name-only", "--diff-filter=ACMRTUXB"]) : [];
6948
6994
  const untracked = mode === "unstaged" || mode === "all" ? await collect("git", ["ls-files", "--others", "--exclude-standard"]) : [];
@@ -7254,6 +7300,23 @@ var program = async () => {
7254
7300
  }
7255
7301
  if (effectiveJestFiles.length === 0) {
7256
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
+ }
7257
7320
  const seeds = prodSelections.map(
7258
7321
  (abs) => path10.relative(repoRoot, abs).replace(/\\/g, "/").replace(/\.(m?[tj]sx?)$/i, "")
7259
7322
  ).flatMap((rel) => {