@reddoorla/maintenance 0.10.5 → 0.10.6

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/cli/bin.js CHANGED
@@ -1104,7 +1104,7 @@ async function securityAudit(ctx) {
1104
1104
  }
1105
1105
 
1106
1106
  // src/audits/lighthouse.ts
1107
- import { readFile as readFile4, writeFile, mkdtemp, rm } from "fs/promises";
1107
+ import { readFile as readFile4, writeFile, mkdtemp, rm, readdir } from "fs/promises";
1108
1108
  import { tmpdir } from "os";
1109
1109
  import { join as join4 } from "path";
1110
1110
 
@@ -1201,6 +1201,21 @@ async function readJsonMaybe(path) {
1201
1201
  return null;
1202
1202
  }
1203
1203
  }
1204
+ async function readLhrEntries(resultsDir) {
1205
+ const files = await readdir(resultsDir).catch(() => []);
1206
+ const entries = [];
1207
+ for (const f of files) {
1208
+ if (!f.startsWith("lhr-") || !f.endsWith(".json")) continue;
1209
+ const lhr = await readJsonMaybe(join4(resultsDir, f));
1210
+ if (!lhr || !lhr.categories) continue;
1211
+ const summary = {};
1212
+ for (const [k, v] of Object.entries(lhr.categories)) {
1213
+ if (typeof v?.score === "number") summary[k] = v.score;
1214
+ }
1215
+ entries.push({ url: lhr.requestedUrl, summary });
1216
+ }
1217
+ return entries;
1218
+ }
1204
1219
  function averageSummaries(entries) {
1205
1220
  if (entries.length === 0) return {};
1206
1221
  const sums = {};
@@ -1274,13 +1289,13 @@ async function lighthouseAudit(ctx) {
1274
1289
  throw err;
1275
1290
  }
1276
1291
  await rm(configDir, { recursive: true, force: true });
1277
- const manifest = await readJsonMaybe(join4(resultsDir, "manifest.json"));
1278
- if (!manifest || manifest.length === 0) {
1292
+ const manifest = await readLhrEntries(resultsDir);
1293
+ if (manifest.length === 0) {
1279
1294
  return {
1280
1295
  audit: "lighthouse",
1281
1296
  site: label,
1282
1297
  status: "fail",
1283
- summary: `lighthouse: no manifest written (exit ${raw.code})${raw.stderr ? ` \u2014 ${raw.stderr.slice(0, 200)}` : ""}`
1298
+ summary: `lighthouse: no lhr-*.json written (exit ${raw.code})${raw.stderr ? ` \u2014 ${raw.stderr.slice(0, 200)}` : ""}`
1284
1299
  };
1285
1300
  }
1286
1301
  const assertionResults = await readJsonMaybe(join4(resultsDir, "assertion-results.json")) ?? [];
@@ -1355,7 +1370,7 @@ async function readJsonMaybe2(path) {
1355
1370
  return null;
1356
1371
  }
1357
1372
  }
1358
- function buildPlaywrightConfig(port) {
1373
+ function buildPlaywrightConfig(port, sitePath) {
1359
1374
  return `import { defineConfig } from "@playwright/test";
1360
1375
 
1361
1376
  export default defineConfig({
@@ -1373,8 +1388,13 @@ export default defineConfig({
1373
1388
  // --strictPort: refuse to bump to a different port if ours is taken,
1374
1389
  // so the audit fails loudly instead of probing a zombie.
1375
1390
  // reuseExistingServer:false: never reuse \u2014 we control the lifecycle.
1391
+ // cwd: playwright's default webServer.cwd is the config file's
1392
+ // directory. Our config lives in /tmp so without this override,
1393
+ // "npm run vite:dev" tries to read /tmp/.../package.json and
1394
+ // ENOENTs before vite ever starts. Caltex 2026-05-28 (0.10.5).
1376
1395
  command: "npm run vite:dev -- --port ${port} --strictPort",
1377
1396
  url: "http://localhost:${port}/dev/a11y-fixtures",
1397
+ cwd: ${JSON.stringify(sitePath)},
1378
1398
  reuseExistingServer: false,
1379
1399
  timeout: 120_000,
1380
1400
  },
@@ -1436,7 +1456,7 @@ async function a11yAudit(ctx) {
1436
1456
  await writeFile2(specPath, buildSpec(), "utf-8");
1437
1457
  const port = await findFreePort();
1438
1458
  const configPath = join5(specDir, "playwright.config.ts");
1439
- await writeFile2(configPath, buildPlaywrightConfig(port), "utf-8");
1459
+ await writeFile2(configPath, buildPlaywrightConfig(port, site.path), "utf-8");
1440
1460
  const resultsPath = join5(site.path, RESULTS_REL);
1441
1461
  await rm2(join5(site.path, ".reddoor-a11y"), { recursive: true, force: true });
1442
1462
  let raw;
@@ -1615,7 +1635,7 @@ async function resolveSites(input) {
1615
1635
  }
1616
1636
 
1617
1637
  // src/cli/fleet/clone-if-needed.ts
1618
- import { stat, readdir, mkdir } from "fs/promises";
1638
+ import { stat, readdir as readdir2, mkdir } from "fs/promises";
1619
1639
  import { isAbsolute as isAbsolute2, join as join6 } from "path";
1620
1640
  function deriveNameFromRepoUrl(repoUrl) {
1621
1641
  const slash = repoUrl.split("/").pop() ?? repoUrl;
@@ -1643,7 +1663,7 @@ async function isNonEmptyDir(path) {
1643
1663
  try {
1644
1664
  const s = await stat(path);
1645
1665
  if (!s.isDirectory()) return false;
1646
- const entries = await readdir(path);
1666
+ const entries = await readdir2(path);
1647
1667
  return entries.length > 0;
1648
1668
  } catch {
1649
1669
  return false;