@reddoorla/maintenance 0.11.0 → 0.11.2

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
@@ -142,11 +142,20 @@ var init_airtable = __esm({
142
142
  // src/audits/lighthouse-airtable.ts
143
143
  var lighthouse_airtable_exports = {};
144
144
  __export(lighthouse_airtable_exports, {
145
+ hasRealScores: () => hasRealScores,
145
146
  lighthouseScoresFromResult: () => lighthouseScoresFromResult,
146
147
  resolveSlugFromCwd: () => resolveSlugFromCwd
147
148
  });
148
149
  import { readFile as readFile7 } from "fs/promises";
149
150
  import { join as join7 } from "path";
151
+ function hasRealScores(result) {
152
+ if (result.audit !== "lighthouse") return false;
153
+ const details = result.details ?? {};
154
+ const summary = details.summary ?? {};
155
+ return LIGHTHOUSE_CATEGORIES.some(
156
+ (k) => typeof summary[k] === "number" && !Number.isNaN(summary[k])
157
+ );
158
+ }
150
159
  function lighthouseScoresFromResult(result) {
151
160
  if (result.audit !== "lighthouse") {
152
161
  throw new Error(`Expected a 'lighthouse' AuditResult, got '${result.audit}'`);
@@ -175,10 +184,12 @@ async function resolveSlugFromCwd(cwd) {
175
184
  );
176
185
  }
177
186
  }
187
+ var LIGHTHOUSE_CATEGORIES;
178
188
  var init_lighthouse_airtable = __esm({
179
189
  "src/audits/lighthouse-airtable.ts"() {
180
190
  "use strict";
181
191
  init_websites();
192
+ LIGHTHOUSE_CATEGORIES = ["performance", "accessibility", "best-practices", "seo"];
182
193
  }
183
194
  });
184
195
 
@@ -1735,7 +1746,7 @@ async function runAuditCommand(site, opts) {
1735
1746
  if (opts.writeAirtable !== void 0) {
1736
1747
  const { openBase: openBase2, readAirtableConfig: readAirtableConfig2 } = await Promise.resolve().then(() => (init_client(), client_exports));
1737
1748
  const { listWebsites: listWebsites2, updateScores: updateScores2, siteSlug: siteSlug2 } = await Promise.resolve().then(() => (init_websites(), websites_exports));
1738
- const { lighthouseScoresFromResult: lighthouseScoresFromResult2, resolveSlugFromCwd: resolveSlugFromCwd2 } = await Promise.resolve().then(() => (init_lighthouse_airtable(), lighthouse_airtable_exports));
1749
+ const { lighthouseScoresFromResult: lighthouseScoresFromResult2, hasRealScores: hasRealScores2, resolveSlugFromCwd: resolveSlugFromCwd2 } = await Promise.resolve().then(() => (init_lighthouse_airtable(), lighthouse_airtable_exports));
1739
1750
  const slug = typeof opts.writeAirtable === "string" && opts.writeAirtable.length > 0 ? opts.writeAirtable : await resolveSlugFromCwd2(cwd);
1740
1751
  const lhResult = results.find((r) => r.audit === "lighthouse");
1741
1752
  if (!lhResult) {
@@ -1746,10 +1757,10 @@ async function runAuditCommand(site, opts) {
1746
1757
  { exitCode: 2 }
1747
1758
  );
1748
1759
  }
1749
- if (lhResult.status === "fail") {
1760
+ if (!hasRealScores2(lhResult)) {
1750
1761
  throw Object.assign(
1751
1762
  new Error(
1752
- `Lighthouse audit failed; refusing to write scores to Airtable. Summary: ${lhResult.summary}`
1763
+ `Lighthouse audit produced no scores; refusing to write to Airtable. Summary: ${lhResult.summary}`
1753
1764
  ),
1754
1765
  { exitCode: 1 }
1755
1766
  );