@reddoorla/maintenance 0.10.5 → 0.10.7

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
@@ -335,7 +335,7 @@ async function securityAudit(ctx) {
335
335
  }
336
336
 
337
337
  // src/audits/lighthouse.ts
338
- import { readFile as readFile4, writeFile, mkdtemp, rm } from "fs/promises";
338
+ import { readFile as readFile4, writeFile, mkdtemp, rm, readdir } from "fs/promises";
339
339
  import { tmpdir } from "os";
340
340
  import { join as join4 } from "path";
341
341
 
@@ -432,6 +432,21 @@ async function readJsonMaybe(path) {
432
432
  return null;
433
433
  }
434
434
  }
435
+ async function readLhrEntries(resultsDir) {
436
+ const files = await readdir(resultsDir).catch(() => []);
437
+ const entries = [];
438
+ for (const f of files) {
439
+ if (!f.startsWith("lhr-") || !f.endsWith(".json")) continue;
440
+ const lhr = await readJsonMaybe(join4(resultsDir, f));
441
+ if (!lhr || !lhr.categories) continue;
442
+ const summary = {};
443
+ for (const [k, v] of Object.entries(lhr.categories)) {
444
+ if (typeof v?.score === "number") summary[k] = v.score;
445
+ }
446
+ entries.push({ url: lhr.requestedUrl, summary });
447
+ }
448
+ return entries;
449
+ }
435
450
  function averageSummaries(entries) {
436
451
  if (entries.length === 0) return {};
437
452
  const sums = {};
@@ -505,13 +520,13 @@ async function lighthouseAudit(ctx) {
505
520
  throw err;
506
521
  }
507
522
  await rm(configDir, { recursive: true, force: true });
508
- const manifest = await readJsonMaybe(join4(resultsDir, "manifest.json"));
509
- if (!manifest || manifest.length === 0) {
523
+ const manifest = await readLhrEntries(resultsDir);
524
+ if (manifest.length === 0) {
510
525
  return {
511
526
  audit: "lighthouse",
512
527
  site: label,
513
528
  status: "fail",
514
- summary: `lighthouse: no manifest written (exit ${raw.code})${raw.stderr ? ` \u2014 ${raw.stderr.slice(0, 200)}` : ""}`
529
+ summary: `lighthouse: no lhr-*.json written (exit ${raw.code})${raw.stderr ? ` \u2014 ${raw.stderr.slice(0, 200)}` : ""}`
515
530
  };
516
531
  }
517
532
  const assertionResults = await readJsonMaybe(join4(resultsDir, "assertion-results.json")) ?? [];
@@ -541,7 +556,6 @@ async function lighthouseAudit(ctx) {
541
556
 
542
557
  // src/audits/a11y.ts
543
558
  import { readFile as readFile5, writeFile as writeFile2, mkdtemp as mkdtemp2, rm as rm2 } from "fs/promises";
544
- import { tmpdir as tmpdir2 } from "os";
545
559
  import { join as join5 } from "path";
546
560
 
547
561
  // src/configs/playwright-a11y.ts
@@ -586,7 +600,7 @@ async function readJsonMaybe2(path) {
586
600
  return null;
587
601
  }
588
602
  }
589
- function buildPlaywrightConfig(port) {
603
+ function buildPlaywrightConfig(port, sitePath) {
590
604
  return `import { defineConfig } from "@playwright/test";
591
605
 
592
606
  export default defineConfig({
@@ -604,8 +618,13 @@ export default defineConfig({
604
618
  // --strictPort: refuse to bump to a different port if ours is taken,
605
619
  // so the audit fails loudly instead of probing a zombie.
606
620
  // reuseExistingServer:false: never reuse \u2014 we control the lifecycle.
621
+ // cwd: playwright's default webServer.cwd is the config file's
622
+ // directory. Our config lives in /tmp so without this override,
623
+ // "npm run vite:dev" tries to read /tmp/.../package.json and
624
+ // ENOENTs before vite ever starts. Caltex 2026-05-28 (0.10.5).
607
625
  command: "npm run vite:dev -- --port ${port} --strictPort",
608
626
  url: "http://localhost:${port}/dev/a11y-fixtures",
627
+ cwd: ${JSON.stringify(sitePath)},
609
628
  reuseExistingServer: false,
610
629
  timeout: 120_000,
611
630
  },
@@ -662,12 +681,12 @@ async function a11yAudit(ctx) {
662
681
  const spawn2 = ctx.spawn ?? defaultSpawn;
663
682
  const site = ctx.site;
664
683
  const label = siteLabel(site);
665
- const specDir = await mkdtemp2(join5(tmpdir2(), "reddoor-a11y-spec-"));
684
+ const specDir = await mkdtemp2(join5(site.path, ".reddoor-a11y-spec-"));
666
685
  const specPath = join5(specDir, "a11y.spec.ts");
667
686
  await writeFile2(specPath, buildSpec(), "utf-8");
668
687
  const port = await findFreePort();
669
688
  const configPath = join5(specDir, "playwright.config.ts");
670
- await writeFile2(configPath, buildPlaywrightConfig(port), "utf-8");
689
+ await writeFile2(configPath, buildPlaywrightConfig(port, site.path), "utf-8");
671
690
  const resultsPath = join5(site.path, RESULTS_REL);
672
691
  await rm2(join5(site.path, ".reddoor-a11y"), { recursive: true, force: true });
673
692
  let raw;