headlamp 0.1.11 → 0.1.12

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
@@ -735,7 +735,9 @@ __export(fast_related_exports, {
735
735
  findRelatedTestsFast: () => findRelatedTestsFast
736
736
  });
737
737
  import * as path3 from "node:path";
738
+ import * as os2 from "node:os";
738
739
  import * as fs from "node:fs/promises";
740
+ import { createHash } from "node:crypto";
739
741
  var TailSegmentCount, EmptyCount, JsonIndentSpaces, DEFAULT_TEST_GLOBS, findRelatedTestsFast, cachedRelated;
740
742
  var init_fast_related = __esm({
741
743
  "src/lib/fast-related.ts"() {
@@ -788,9 +790,7 @@ var init_fast_related = __esm({
788
790
  }
789
791
  const args = ["-n", "-l", "-S", "-F"];
790
792
  testGlobs.forEach((globPattern) => args.push("-g", globPattern));
791
- excludeGlobs.forEach(
792
- (excludeGlobPattern) => args.push("-g", `!${excludeGlobPattern}`)
793
- );
793
+ excludeGlobs.forEach((excludeGlobPattern) => args.push("-g", `!${excludeGlobPattern}`));
794
794
  seeds.forEach((seedToken) => args.push("-e", seedToken));
795
795
  let raw = "";
796
796
  try {
@@ -802,9 +802,7 @@ var init_fast_related = __esm({
802
802
  }
803
803
  const lines = raw.split(/\r?\n/).map((lineText) => lineText.trim()).filter(Boolean);
804
804
  const looksLikeTest = (pathText) => /\.(test|spec)\.[tj]sx?$/i.test(pathText) || /(^|\/)tests?\//i.test(pathText);
805
- const absolute = lines.map(
806
- (relativePath) => path3.resolve(repoRoot, relativePath).replace(/\\/g, "/")
807
- ).filter(looksLikeTest);
805
+ const absolute = lines.map((relativePath) => path3.resolve(repoRoot, relativePath).replace(/\\/g, "/")).filter(looksLikeTest);
808
806
  const uniq = Array.from(new Set(absolute));
809
807
  const results = [];
810
808
  await Promise.all(
@@ -819,17 +817,15 @@ var init_fast_related = __esm({
819
817
  return results;
820
818
  };
821
819
  cachedRelated = async (opts) => {
822
- const cacheDir = path3.join(opts.repoRoot, ".cache");
820
+ const cacheRoot = process.env.HEADLAMP_CACHE_DIR || path3.join(os2.tmpdir(), "headlamp-cache");
821
+ const repoKey = createHash("sha1").update(path3.resolve(opts.repoRoot)).digest("hex").slice(0, 12);
822
+ const cacheDir = path3.join(cacheRoot, repoKey);
823
823
  const cacheFile = path3.join(cacheDir, "relevant-tests.json");
824
824
  let head = "nogit";
825
825
  try {
826
- const raw = await runText(
827
- "git",
828
- ["-C", opts.repoRoot, "rev-parse", "--short", "HEAD"],
829
- {
830
- env: safeEnv(process.env, {})
831
- }
832
- );
826
+ const raw = await runText("git", ["-C", opts.repoRoot, "rev-parse", "--short", "HEAD"], {
827
+ env: safeEnv(process.env, {})
828
+ });
833
829
  head = raw.trim() || "nogit";
834
830
  } catch {
835
831
  head = "nogit";
@@ -861,10 +857,7 @@ var init_fast_related = __esm({
861
857
  try {
862
858
  const next = { ...bag, [key]: Array.from(new Set(recomputed)) };
863
859
  await fs.mkdir(cacheDir, { recursive: true });
864
- await fs.writeFile(
865
- cacheFile,
866
- JSON.stringify(next, null, JsonIndentSpaces)
867
- );
860
+ await fs.writeFile(cacheFile, JSON.stringify(next, null, JsonIndentSpaces));
868
861
  } catch {
869
862
  }
870
863
  return recomputed;
@@ -7415,7 +7408,7 @@ init_env_utils();
7415
7408
  init_exec();
7416
7409
  init_args();
7417
7410
  import * as path11 from "node:path";
7418
- import * as os2 from "node:os";
7411
+ import * as os3 from "node:os";
7419
7412
  import * as fsSync3 from "node:fs";
7420
7413
  import * as fs7 from "node:fs/promises";
7421
7414
  import * as LibReport from "istanbul-lib-report";
@@ -8574,7 +8567,7 @@ var program = async () => {
8574
8567
  (absTestPath) => executedTestFilesSet.add(path11.resolve(absTestPath).replace(/\\/g, "/"))
8575
8568
  );
8576
8569
  const outJson = path11.join(
8577
- os2.tmpdir(),
8570
+ os3.tmpdir(),
8578
8571
  `jest-bridge-${Date.now()}-${Math.random().toString(36).slice(2)}.json`
8579
8572
  );
8580
8573
  const reporterPath = path11.resolve("scripts/jest-vitest-bridge.cjs");