@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/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")) ?? [];
@@ -1310,7 +1325,6 @@ async function lighthouseAudit(ctx) {
1310
1325
 
1311
1326
  // src/audits/a11y.ts
1312
1327
  import { readFile as readFile5, writeFile as writeFile2, mkdtemp as mkdtemp2, rm as rm2 } from "fs/promises";
1313
- import { tmpdir as tmpdir2 } from "os";
1314
1328
  import { join as join5 } from "path";
1315
1329
 
1316
1330
  // src/configs/playwright-a11y.ts
@@ -1355,7 +1369,7 @@ async function readJsonMaybe2(path) {
1355
1369
  return null;
1356
1370
  }
1357
1371
  }
1358
- function buildPlaywrightConfig(port) {
1372
+ function buildPlaywrightConfig(port, sitePath) {
1359
1373
  return `import { defineConfig } from "@playwright/test";
1360
1374
 
1361
1375
  export default defineConfig({
@@ -1373,8 +1387,13 @@ export default defineConfig({
1373
1387
  // --strictPort: refuse to bump to a different port if ours is taken,
1374
1388
  // so the audit fails loudly instead of probing a zombie.
1375
1389
  // reuseExistingServer:false: never reuse \u2014 we control the lifecycle.
1390
+ // cwd: playwright's default webServer.cwd is the config file's
1391
+ // directory. Our config lives in /tmp so without this override,
1392
+ // "npm run vite:dev" tries to read /tmp/.../package.json and
1393
+ // ENOENTs before vite ever starts. Caltex 2026-05-28 (0.10.5).
1376
1394
  command: "npm run vite:dev -- --port ${port} --strictPort",
1377
1395
  url: "http://localhost:${port}/dev/a11y-fixtures",
1396
+ cwd: ${JSON.stringify(sitePath)},
1378
1397
  reuseExistingServer: false,
1379
1398
  timeout: 120_000,
1380
1399
  },
@@ -1431,12 +1450,12 @@ async function a11yAudit(ctx) {
1431
1450
  const spawn2 = ctx.spawn ?? defaultSpawn;
1432
1451
  const site = ctx.site;
1433
1452
  const label = siteLabel(site);
1434
- const specDir = await mkdtemp2(join5(tmpdir2(), "reddoor-a11y-spec-"));
1453
+ const specDir = await mkdtemp2(join5(site.path, ".reddoor-a11y-spec-"));
1435
1454
  const specPath = join5(specDir, "a11y.spec.ts");
1436
1455
  await writeFile2(specPath, buildSpec(), "utf-8");
1437
1456
  const port = await findFreePort();
1438
1457
  const configPath = join5(specDir, "playwright.config.ts");
1439
- await writeFile2(configPath, buildPlaywrightConfig(port), "utf-8");
1458
+ await writeFile2(configPath, buildPlaywrightConfig(port, site.path), "utf-8");
1440
1459
  const resultsPath = join5(site.path, RESULTS_REL);
1441
1460
  await rm2(join5(site.path, ".reddoor-a11y"), { recursive: true, force: true });
1442
1461
  let raw;
@@ -1615,7 +1634,7 @@ async function resolveSites(input) {
1615
1634
  }
1616
1635
 
1617
1636
  // src/cli/fleet/clone-if-needed.ts
1618
- import { stat, readdir, mkdir } from "fs/promises";
1637
+ import { stat, readdir as readdir2, mkdir } from "fs/promises";
1619
1638
  import { isAbsolute as isAbsolute2, join as join6 } from "path";
1620
1639
  function deriveNameFromRepoUrl(repoUrl) {
1621
1640
  const slash = repoUrl.split("/").pop() ?? repoUrl;
@@ -1643,7 +1662,7 @@ async function isNonEmptyDir(path) {
1643
1662
  try {
1644
1663
  const s = await stat(path);
1645
1664
  if (!s.isDirectory()) return false;
1646
- const entries = await readdir(path);
1665
+ const entries = await readdir2(path);
1647
1666
  return entries.length > 0;
1648
1667
  } catch {
1649
1668
  return false;