@reddoorla/maintenance 0.15.0 → 0.16.0

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.
@@ -8,6 +8,20 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
 
11
+ // src/util/credentials.ts
12
+ import { readFileSync } from "fs";
13
+ import { homedir } from "os";
14
+ import { join as join6 } from "path";
15
+ function defaultCredentialsPath() {
16
+ const base = process.env.XDG_CONFIG_HOME ?? join6(homedir(), ".config");
17
+ return join6(base, "reddoor-maint", "credentials.env");
18
+ }
19
+ var init_credentials = __esm({
20
+ "src/util/credentials.ts"() {
21
+ "use strict";
22
+ }
23
+ });
24
+
11
25
  // src/reports/airtable/client.ts
12
26
  var client_exports = {};
13
27
  __export(client_exports, {
@@ -15,11 +29,19 @@ __export(client_exports, {
15
29
  readAirtableConfig: () => readAirtableConfig
16
30
  });
17
31
  import Airtable from "airtable";
32
+ function missing(name) {
33
+ return Object.assign(
34
+ new Error(
35
+ `${name} not set. Export it in your shell or put it in ${defaultCredentialsPath()} as ${name}=...`
36
+ ),
37
+ { exitCode: 2 }
38
+ );
39
+ }
18
40
  function readAirtableConfig() {
19
41
  const apiKey = process.env.AIRTABLE_PAT;
20
42
  const baseId = process.env.AIRTABLE_BASE_ID;
21
- if (!apiKey) throw Object.assign(new Error("AIRTABLE_PAT not set"), { exitCode: 2 });
22
- if (!baseId) throw Object.assign(new Error("AIRTABLE_BASE_ID not set"), { exitCode: 2 });
43
+ if (!apiKey) throw missing("AIRTABLE_PAT");
44
+ if (!baseId) throw missing("AIRTABLE_BASE_ID");
23
45
  return { apiKey, baseId };
24
46
  }
25
47
  function openBase(cfg) {
@@ -28,6 +50,7 @@ function openBase(cfg) {
28
50
  var init_client = __esm({
29
51
  "src/reports/airtable/client.ts"() {
30
52
  "use strict";
53
+ init_credentials();
31
54
  }
32
55
  });
33
56
 
@@ -178,7 +201,7 @@ __export(lighthouse_airtable_exports, {
178
201
  resolveSlugFromCwd: () => resolveSlugFromCwd
179
202
  });
180
203
  import { readFile as readFile7 } from "fs/promises";
181
- import { join as join7 } from "path";
204
+ import { join as join8 } from "path";
182
205
  function hasRealScores(result) {
183
206
  if (result.audit !== "lighthouse") return false;
184
207
  const details = result.details ?? {};
@@ -203,7 +226,7 @@ function lighthouseScoresFromResult(result) {
203
226
  }
204
227
  async function resolveSlugFromCwd(cwd) {
205
228
  try {
206
- const pkgPath = join7(cwd, "package.json");
229
+ const pkgPath = join8(cwd, "package.json");
207
230
  const raw = await readFile7(pkgPath, "utf-8");
208
231
  const pkg = JSON.parse(raw);
209
232
  if (!pkg.name) throw new Error("package.json has no 'name' field");
@@ -1209,7 +1232,7 @@ async function resolveSites(input) {
1209
1232
 
1210
1233
  // src/cli/fleet/clone-if-needed.ts
1211
1234
  import { stat, readdir as readdir2, mkdir } from "fs/promises";
1212
- import { isAbsolute as isAbsolute2, join as join6 } from "path";
1235
+ import { isAbsolute as isAbsolute2, join as join7 } from "path";
1213
1236
  function deriveNameFromRepoUrl(repoUrl) {
1214
1237
  const slash = repoUrl.split("/").pop() ?? repoUrl;
1215
1238
  return slash.replace(/\.git$/, "");
@@ -1250,7 +1273,7 @@ async function cloneIfNeeded(site, opts) {
1250
1273
  const name = site.name ?? deriveNameFromRepoUrl(site.repoUrl);
1251
1274
  assertSafeName(name);
1252
1275
  assertSafeRepoUrl(site.repoUrl);
1253
- const target = join6(opts.workdir, name);
1276
+ const target = join7(opts.workdir, name);
1254
1277
  await mkdir(opts.workdir, { recursive: true });
1255
1278
  if (await isNonEmptyDir(target)) {
1256
1279
  return { ...site, name, path: target };