@reddoorla/maintenance 0.10.1 → 0.10.3

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
@@ -284,12 +284,37 @@ var init_reports = __esm({
284
284
 
285
285
  // src/reports/maintenance-email/assets/index.ts
286
286
  import { readFile as readFile13 } from "fs/promises";
287
+ import { existsSync as existsSync2 } from "fs";
287
288
  import { dirname as dirname2, join as join21 } from "path";
288
289
  import { fileURLToPath as fileURLToPath2 } from "url";
290
+ function resolveAssetsDir() {
291
+ if (cachedAssetsDir) return cachedAssetsDir;
292
+ let dir = dirname2(fileURLToPath2(import.meta.url));
293
+ while (true) {
294
+ const srcCandidate = join21(dir, "src", "reports", "maintenance-email", "assets", "check.png");
295
+ if (existsSync2(srcCandidate)) {
296
+ cachedAssetsDir = dirname2(srcCandidate);
297
+ return cachedAssetsDir;
298
+ }
299
+ const distCandidate = join21(dir, "dist", "reports", "maintenance-email", "assets", "check.png");
300
+ if (existsSync2(distCandidate)) {
301
+ cachedAssetsDir = dirname2(distCandidate);
302
+ return cachedAssetsDir;
303
+ }
304
+ const parent = dirname2(dir);
305
+ if (parent === dir) {
306
+ throw new Error(
307
+ `loadBundledImages: could not locate maintenance-email assets dir by walking up from ${fileURLToPath2(import.meta.url)}. Checked both src/ and dist/ layouts.`
308
+ );
309
+ }
310
+ dir = parent;
311
+ }
312
+ }
289
313
  async function loadBundledImages() {
314
+ const assetsDir = resolveAssetsDir();
290
315
  const [check, blurred] = await Promise.all([
291
- readFile13(join21(here, "check.png")),
292
- readFile13(join21(here, "blurredTests.jpg"))
316
+ readFile13(join21(assetsDir, "check.png")),
317
+ readFile13(join21(assetsDir, "blurredTests.jpg"))
293
318
  ]);
294
319
  return {
295
320
  check: {
@@ -306,13 +331,13 @@ async function loadBundledImages() {
306
331
  }
307
332
  };
308
333
  }
309
- var here, CHECK_CID, BLURRED_CID;
334
+ var CHECK_CID, BLURRED_CID, cachedAssetsDir;
310
335
  var init_assets = __esm({
311
336
  "src/reports/maintenance-email/assets/index.ts"() {
312
337
  "use strict";
313
- here = dirname2(fileURLToPath2(import.meta.url));
314
338
  CHECK_CID = "rd-check-png";
315
339
  BLURRED_CID = "rd-blurred-tests-jpg";
340
+ cachedAssetsDir = null;
316
341
  }
317
342
  });
318
343
 
@@ -1357,7 +1382,12 @@ async function a11yAudit(ctx) {
1357
1382
  try {
1358
1383
  raw = await spawn2("npx", ["--yes", "playwright", "test", "--reporter=line", specPath], {
1359
1384
  cwd: site.path,
1360
- env: { ...process.env, REDDOOR_A11Y_OUTPUT: resultsPath }
1385
+ env: { ...process.env, REDDOOR_A11Y_OUTPUT: resultsPath },
1386
+ // playwright on a cold tree downloads Chrome, boots the site's dev
1387
+ // server, and runs axe over every configured route. The shared 30 s
1388
+ // default in runAudits is fine for deps/lint/security but starves
1389
+ // playwright (mirrors the lighthouse fix shipped earlier).
1390
+ timeoutMs: 5 * 6e4
1361
1391
  });
1362
1392
  } catch (err) {
1363
1393
  await rm2(specDir, { recursive: true, force: true });
@@ -2498,7 +2528,7 @@ function injectRestIntoProps(scriptBody) {
2498
2528
  if (!match) return scriptBody;
2499
2529
  const destructured = match[1] ?? "";
2500
2530
  if (/\.\.\.\s*\w+/.test(destructured)) return scriptBody;
2501
- const trimmed = destructured.trim();
2531
+ const trimmed = destructured.trim().replace(/,\s*$/, "");
2502
2532
  const newDestructured = trimmed === "" ? " ...rest " : ` ${trimmed}, ...rest `;
2503
2533
  let replacement;
2504
2534
  if (match[2] !== void 0) {
@@ -2940,8 +2970,8 @@ import { fileURLToPath } from "url";
2940
2970
  import { dirname, join as join18 } from "path";
2941
2971
  function selfPackageVersion(callerImportMetaUrl) {
2942
2972
  try {
2943
- const here3 = dirname(fileURLToPath(callerImportMetaUrl));
2944
- const raw = readFileSync(join18(here3, "..", "..", "package.json"), "utf-8");
2973
+ const here2 = dirname(fileURLToPath(callerImportMetaUrl));
2974
+ const raw = readFileSync(join18(here2, "..", "..", "package.json"), "utf-8");
2945
2975
  const pkg = JSON.parse(raw);
2946
2976
  return pkg.version ?? "0.0.0";
2947
2977
  } catch {
@@ -3498,8 +3528,8 @@ function resolvePackageVersion(fromDir) {
3498
3528
  }
3499
3529
 
3500
3530
  // src/cli/bin.ts
3501
- var here2 = dirname5(fileURLToPath3(import.meta.url));
3502
- var version = resolvePackageVersion(here2);
3531
+ var here = dirname5(fileURLToPath3(import.meta.url));
3532
+ var version = resolvePackageVersion(here);
3503
3533
  var AUDIT_DESCRIPTIONS = {
3504
3534
  deps: "Diff site package.json against the bundled baseline version map.",
3505
3535
  lighthouse: "Run @lhci/cli autorun using the canonical lighthouserc.",