@theholocron/cli 5.0.0-alpha.436 → 5.0.0-alpha.438

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.mjs CHANGED
@@ -1126,6 +1126,17 @@ const registry = createCommandRegistry([
1126
1126
  authCheckEntry,
1127
1127
  authListEntry,
1128
1128
  authExportEntry,
1129
+ {
1130
+ name: "export requests",
1131
+ description: "Write the repo's request collections in each tooling provider's own format, under a git-ignored folder",
1132
+ positionals: [],
1133
+ skipOptions: [
1134
+ "yes",
1135
+ "to",
1136
+ "out"
1137
+ ],
1138
+ supportsDryRun: true
1139
+ },
1129
1140
  githubAppCreateEntry,
1130
1141
  {
1131
1142
  name: "new tunnel",
@@ -2297,6 +2308,7 @@ const COMMAND_CONTEXTS = {
2297
2308
  "remove token": "global",
2298
2309
  "list tokens": "global",
2299
2310
  "export tokens": "workspace",
2311
+ "export requests": "workspace",
2300
2312
  "new github-app": "global",
2301
2313
  "check token": "global",
2302
2314
  "publish bump-versions": "global",
@@ -6804,7 +6816,7 @@ async function runDoctorDns(input) {
6804
6816
  });
6805
6817
  else if (!loader.has("dns")) {
6806
6818
  const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
6807
- for (const zone of zones) rows.push(row$12(zone, "skip", why));
6819
+ for (const zone of zones) rows.push(row$13(zone, "skip", why));
6808
6820
  for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
6809
6821
  } else {
6810
6822
  const dns = loader.get("dns");
@@ -6826,7 +6838,7 @@ async function runDoctorDns(input) {
6826
6838
  ...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
6827
6839
  };
6828
6840
  }
6829
- function row$12(zone, status, detail, problems = []) {
6841
+ function row$13(zone, status, detail, problems = []) {
6830
6842
  return {
6831
6843
  id: `dns-${zone}`,
6832
6844
  title: `${zone} records exist`,
@@ -6855,7 +6867,7 @@ async function checkDomain(dns, deploy, project, hostname) {
6855
6867
  return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
6856
6868
  }
6857
6869
  }
6858
- async function checkZone(dns, zone, wanted, rowOf = (...args) => row$12(zone, ...args)) {
6870
+ async function checkZone(dns, zone, wanted, rowOf = (...args) => row$13(zone, ...args)) {
6859
6871
  try {
6860
6872
  const have = await dns.listRecords(zone);
6861
6873
  const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
@@ -6990,7 +7002,7 @@ function installationSettingsUrl(account, id) {
6990
7002
  return `https://github.com/settings/installations/${id}`;
6991
7003
  }
6992
7004
  // src/commands/doctor-github-app/app-rows.ts
6993
- const row$11 = (name, what, problems, ok) => ({
7005
+ const row$12 = (name, what, problems, ok) => ({
6994
7006
  id: `${name}:${what}`,
6995
7007
  title: `${name}: ${what}`,
6996
7008
  status: problems.length > 0 ? "fail" : "ok",
@@ -7017,9 +7029,9 @@ function appRows(name, manifest, app, installations) {
7017
7029
  return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
7018
7030
  });
7019
7031
  return [
7020
- row$11(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
7021
- row$11(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
7022
- row$11(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
7032
+ row$12(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
7033
+ row$12(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
7034
+ row$12(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
7023
7035
  ];
7024
7036
  }
7025
7037
  // src/commands/doctor-github-app/parse-manifest.ts
@@ -7077,7 +7089,7 @@ async function runDoctorGitHubApp(input) {
7077
7089
  assertPluginsResolvable$1(loader, "doctor github-app");
7078
7090
  }
7079
7091
  const rows = [];
7080
- if (instances.length === 0) rows.push(row$10("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
7092
+ if (instances.length === 0) rows.push(row$11("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
7081
7093
  for (const instance of instances) rows.push(...await checkInstance(instance, loader, input));
7082
7094
  printCheckRows(rows, print);
7083
7095
  const summary = summariseChecks(rows);
@@ -7094,7 +7106,7 @@ async function runDoctorGitHubApp(input) {
7094
7106
  ...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
7095
7107
  };
7096
7108
  }
7097
- function row$10(name, what, status, detail) {
7109
+ function row$11(name, what, status, detail) {
7098
7110
  return {
7099
7111
  id: `${name}:${what}`,
7100
7112
  title: `${name}: ${what}`,
@@ -7135,19 +7147,19 @@ async function checkInstance(instance, loader, input) {
7135
7147
  try {
7136
7148
  manifest = parseManifest(readManifest(instance.manifest));
7137
7149
  } catch (err) {
7138
- return [row$10(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
7150
+ return [row$11(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
7139
7151
  }
7140
7152
  const read = await readCredentials(instance, loader);
7141
- if ("reason" in read) return [row$10(name, "reachable", "skip", read.reason)];
7153
+ if ("reason" in read) return [row$11(name, "reachable", "skip", read.reason)];
7142
7154
  const api = input.api ?? defaultApi;
7143
7155
  const secrets = [read.creds.privateKey];
7144
7156
  try {
7145
7157
  const app = await api.getApp(read.creds);
7146
7158
  const installations = await api.listAppInstallations(read.creds);
7147
7159
  const owner = app.owner ? `, owned by ${app.owner.login}` : "";
7148
- return [row$10(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
7160
+ return [row$11(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
7149
7161
  } catch (err) {
7150
- return [row$10(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
7162
+ return [row$11(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
7151
7163
  }
7152
7164
  }
7153
7165
  // src/commands/doctor-github-app/doctor-github-app.command.ts
@@ -7214,7 +7226,7 @@ function datasetTargets(config) {
7214
7226
  * dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
7215
7227
  * a name, a token or a response that cannot be read is a skip with the reason.
7216
7228
  */
7217
- const row$9 = (id, title, status, detail, problems = []) => ({
7229
+ const row$10 = (id, title, status, detail, problems = []) => ({
7218
7230
  id,
7219
7231
  title,
7220
7232
  status,
@@ -7231,7 +7243,7 @@ async function runDoctorLogs(input) {
7231
7243
  if (!loader.has("logs")) {
7232
7244
  const failure = loader.loadFailures().find((f) => f.key === "logs");
7233
7245
  const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
7234
- rows.push(row$9("logs", "logs", "skip", why));
7246
+ rows.push(row$10("logs", "logs", "skip", why));
7235
7247
  } else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
7236
7248
  printCheckRows(rows, print);
7237
7249
  const summary = summariseChecks(rows);
@@ -7255,38 +7267,38 @@ async function checkLogs(logs, targets) {
7255
7267
  for (const target of targets) {
7256
7268
  const id = `logs:dataset:${target.id}`;
7257
7269
  const title = `dataset for ${target.label}`;
7258
- if (!target.name) rows.push(row$9(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
7259
- else if (!token.usable) rows.push(row$9(id, title, "skip", `${target.name}: not checked, the token is not usable`));
7260
- else if (!logs.readDataset) rows.push(row$9(id, title, "skip", `${logs.providerName} cannot read a dataset`));
7270
+ if (!target.name) rows.push(row$10(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
7271
+ else if (!token.usable) rows.push(row$10(id, title, "skip", `${target.name}: not checked, the token is not usable`));
7272
+ else if (!logs.readDataset) rows.push(row$10(id, title, "skip", `${logs.providerName} cannot read a dataset`));
7261
7273
  else rows.push(...await checkDataset(logs, target, target.name, id, title));
7262
7274
  }
7263
7275
  const org = resolveValue$2(["AXIOM_ORG"], void 0, { prefix: PREFIX });
7264
- rows.push(org ? row$9("logs:org", "organization", "ok", `${PREFIX}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$9("logs:org", "organization", "skip", `${PREFIX}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links and check-dispatched need it`));
7276
+ rows.push(org ? row$10("logs:org", "organization", "ok", `${PREFIX}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$10("logs:org", "organization", "skip", `${PREFIX}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links and check-dispatched need it`));
7265
7277
  return rows;
7266
7278
  }
7267
7279
  /** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
7268
7280
  async function checkToken$1(logs) {
7269
7281
  const title = "token is accepted";
7270
7282
  if (!logs.checkToken) return {
7271
- row: row$9("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
7283
+ row: row$10("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
7272
7284
  usable: true
7273
7285
  };
7274
7286
  try {
7275
7287
  const result = await logs.checkToken();
7276
7288
  if (result.ok) return {
7277
- row: row$9("logs:token", title, "ok", `${logs.providerName} accepts the token`),
7289
+ row: row$10("logs:token", title, "ok", `${logs.providerName} accepts the token`),
7278
7290
  usable: true
7279
7291
  };
7280
7292
  const reason = result.reason ?? `${logs.providerName} refused the token`;
7281
7293
  return {
7282
- row: row$9("logs:token", title, "fail", reason, [reason]),
7294
+ row: row$10("logs:token", title, "fail", reason, [reason]),
7283
7295
  usable: false
7284
7296
  };
7285
7297
  } catch (err) {
7286
7298
  const noToken = missingTokenReason(err);
7287
7299
  const detail = noToken ?? `could not check the token: ${describeError(err)}`;
7288
7300
  return {
7289
- row: row$9("logs:token", title, "skip", detail),
7301
+ row: row$10("logs:token", title, "skip", detail),
7290
7302
  usable: noToken === void 0
7291
7303
  };
7292
7304
  }
@@ -7296,13 +7308,13 @@ async function checkDataset(logs, target, name, id, title) {
7296
7308
  const found = await logs.readDataset(name);
7297
7309
  if (!found.exists) {
7298
7310
  const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
7299
- return [row$9(id, title, "fail", `${name} does not exist`, [problem])];
7311
+ return [row$10(id, title, "fail", `${name} does not exist`, [problem])];
7300
7312
  }
7301
7313
  const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
7302
- return [row$9(id, title, "ok", `${name} exists`), row$9(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
7314
+ return [row$10(id, title, "ok", `${name} exists`), row$10(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
7303
7315
  } catch (err) {
7304
7316
  const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
7305
- return [row$9(id, title, "skip", detail)];
7317
+ return [row$10(id, title, "skip", detail)];
7306
7318
  }
7307
7319
  }
7308
7320
  // src/commands/doctor-logs/doctor-logs.command.ts
@@ -10244,7 +10256,7 @@ const info = (id, title, noun, extras) => ({
10244
10256
  detail: `info: ${extras.length} ${noun} not in the template (never deleted)`,
10245
10257
  problems: extras
10246
10258
  });
10247
- const row$8 = (id, title, problems, ok) => ({
10259
+ const row$9 = (id, title, problems, ok) => ({
10248
10260
  id,
10249
10261
  title,
10250
10262
  status: problems.length > 0 ? "fail" : "ok",
@@ -10280,19 +10292,19 @@ function viewProblems(want, found) {
10280
10292
  function boardRows(boardName, template, state) {
10281
10293
  const id = `project:${boardName}`;
10282
10294
  const rows = [];
10283
- rows.push(row$8(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
10295
+ rows.push(row$9(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
10284
10296
  const extraStatuses = state.statuses.filter((s) => !template.statuses.some((t) => t.name === s));
10285
10297
  if (extraStatuses.length > 0) rows.push(info(`${id}:extra-statuses`, `${boardName}: extra statuses`, "status(es)", extraStatuses));
10286
- for (const want of template.fields) rows.push(row$8(`${id}:field:${want.name}`, `${boardName}: field ${want.name}`, fieldProblems(want, state.fields.find((f) => f.name === want.name)), want.options ? `${want.options.length} options in order` : want.type));
10298
+ for (const want of template.fields) rows.push(row$9(`${id}:field:${want.name}`, `${boardName}: field ${want.name}`, fieldProblems(want, state.fields.find((f) => f.name === want.name)), want.options ? `${want.options.length} options in order` : want.type));
10287
10299
  const extraFields = state.fields.filter((f) => !template.fields.some((t) => t.name === f.name));
10288
10300
  if (extraFields.length > 0) rows.push(info(`${id}:extra-fields`, `${boardName}: extra fields`, "field(s)", extraFields.map((f) => f.name)));
10289
- for (const want of template.views) rows.push(row$8(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
10301
+ for (const want of template.views) rows.push(row$9(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
10290
10302
  const extraViews = state.views.filter((v) => !template.views.some((t) => t.name === v.name));
10291
10303
  if (extraViews.length > 0) rows.push(info(`${id}:extra-views`, `${boardName}: extra views`, "view(s)", extraViews.map((v) => v.name)));
10292
10304
  for (const name of template.rules ?? []) {
10293
10305
  const found = state.rules.find((r) => r.name === name);
10294
10306
  const problems = !found ? [`missing rule ${name}`] : found.enabled ? [] : [`rule ${name} is off`];
10295
- rows.push(row$8(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
10307
+ rows.push(row$9(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
10296
10308
  }
10297
10309
  return rows;
10298
10310
  }
@@ -10352,7 +10364,7 @@ function itemRows(boardName, items) {
10352
10364
  * never fail the run. A template file that does not read is a failure naming the file. `--post [channel]` shares the
10353
10365
  * failing rows through the `notifications` provider's bot, like `doctor notifications --post`.
10354
10366
  */
10355
- const row$7 = (id, title, status, detail, problems = []) => ({
10367
+ const row$8 = (id, title, status, detail, problems = []) => ({
10356
10368
  id,
10357
10369
  title,
10358
10370
  status,
@@ -10406,14 +10418,14 @@ async function checkBoards(input, loader) {
10406
10418
  loader,
10407
10419
  ...input.io ? { io: input.io } : {}
10408
10420
  });
10409
- if (!opened.ok) return [row$7("project", "project", opened.kind, opened.reason, opened.problems)];
10421
+ if (!opened.ok) return [row$8("project", "project", opened.kind, opened.reason, opened.problems)];
10410
10422
  const { projects, owner, boards, templates, templateProblems } = opened.context;
10411
10423
  const rows = templateProblems.map((problem) => {
10412
10424
  /* v8 ignore next -- split always returns at least one element; the fallback only satisfies noUncheckedIndexedAccess */
10413
10425
  const file = problem.split(": ")[0] ?? problem;
10414
- return row$7(`project:template:${file}`, `template file ${file}`, "fail", problem);
10426
+ return row$8(`project:template:${file}`, `template file ${file}`, "fail", problem);
10415
10427
  });
10416
- if (boards.length === 0) return [...rows, row$7("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
10428
+ if (boards.length === 0) return [...rows, row$8("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
10417
10429
  for (const declared of boards) {
10418
10430
  const template = templates[declared.template];
10419
10431
  const title = `${declared.name}: board exists and is open`;
@@ -10421,18 +10433,18 @@ async function checkBoards(input, loader) {
10421
10433
  const board = await projects.find(owner, declared.name);
10422
10434
  if (!board) {
10423
10435
  const closed = (await projects.list(owner)).some((b) => b.name === declared.name && b.closed);
10424
- rows.push(row$7(`project:${declared.name}`, title, "fail", closed ? "the board is closed" : "no open board has this name", [closed ? "reopen it, or run `holocron setup project` to make a new one" : "run `holocron setup project`"]));
10436
+ rows.push(row$8(`project:${declared.name}`, title, "fail", closed ? "the board is closed" : "no open board has this name", [closed ? "reopen it, or run `holocron setup project` to make a new one" : "run `holocron setup project`"]));
10425
10437
  continue;
10426
10438
  }
10427
- rows.push(row$7(`project:${declared.name}`, title, "ok", board.url));
10439
+ rows.push(row$8(`project:${declared.name}`, title, "ok", board.url));
10428
10440
  if (!template) {
10429
- rows.push(row$7(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
10441
+ rows.push(row$8(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
10430
10442
  continue;
10431
10443
  }
10432
10444
  rows.push(...boardRows(declared.name, template, await projects.read(owner, board)));
10433
- rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$7(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
10445
+ rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$8(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
10434
10446
  } catch (err) {
10435
- rows.push(row$7(`project:${declared.name}`, title, "fail", describeError(err)));
10447
+ rows.push(row$8(`project:${declared.name}`, title, "fail", describeError(err)));
10436
10448
  }
10437
10449
  }
10438
10450
  return rows;
@@ -11106,19 +11118,19 @@ async function runDoctorRepo(input) {
11106
11118
  const rows = [];
11107
11119
  if (!loader.has("source")) {
11108
11120
  const why = whyMissing(loader, "source", "no `source` provider to read the repository with");
11109
- for (const check of checks) rows.push(row$6(check, { skip: why }));
11121
+ for (const check of checks) rows.push(row$7(check, { skip: why }));
11110
11122
  } else {
11111
11123
  const source = loader.get("source");
11112
11124
  for (const check of checks) {
11113
11125
  if (typeof source[check.needs] !== "function") {
11114
- rows.push(row$6(check, { skip: `provider does not implement ${check.needs}` }));
11126
+ rows.push(row$7(check, { skip: `provider does not implement ${check.needs}` }));
11115
11127
  continue;
11116
11128
  }
11117
11129
  try {
11118
- rows.push(row$6(check, await check.run(source)));
11130
+ rows.push(row$7(check, await check.run(source)));
11119
11131
  } catch (err) {
11120
11132
  const noToken = missingTokenReason(err);
11121
- if (noToken !== void 0) rows.push(row$6(check, { skip: noToken }));
11133
+ if (noToken !== void 0) rows.push(row$7(check, { skip: noToken }));
11122
11134
  else rows.push({
11123
11135
  id: check.id,
11124
11136
  title: check.title,
@@ -11144,7 +11156,7 @@ async function runDoctorRepo(input) {
11144
11156
  ...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
11145
11157
  };
11146
11158
  }
11147
- function row$6(check, result) {
11159
+ function row$7(check, result) {
11148
11160
  const { id, title } = check;
11149
11161
  if ("skip" in result) return {
11150
11162
  id,
@@ -11667,7 +11679,7 @@ function providerGroup(providerName) {
11667
11679
  }
11668
11680
  // src/commands/doctor-secrets/credentials-rows.ts
11669
11681
  /** A row for the provider as a whole, or for one of its variables when `name` is given. */
11670
- function row$5(provider, status, detail, name) {
11682
+ function row$6(provider, status, detail, name) {
11671
11683
  return name === void 0 ? {
11672
11684
  id: provider,
11673
11685
  title: provider,
@@ -11692,10 +11704,10 @@ async function credentialsRows(input) {
11692
11704
  const { loader } = input;
11693
11705
  const { resolved } = input.loaded;
11694
11706
  if (!resolved.providers.credentials) return {
11695
- rows: input.asked ? [row$5("credentials", "skip", "no `credentials` provider is configured")] : [],
11707
+ rows: input.asked ? [row$6("credentials", "skip", "no `credentials` provider is configured")] : [],
11696
11708
  places: []
11697
11709
  };
11698
- const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$5(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
11710
+ const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$6(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
11699
11711
  const places = [];
11700
11712
  if (!loader.has("credentials")) return {
11701
11713
  rows,
@@ -11707,7 +11719,7 @@ async function credentialsRows(input) {
11707
11719
  const tuple = tuples.find((t) => t.provider === impl.providerName);
11708
11720
  const explicit = tuple && credentialsEnvironment(tuple, resolved);
11709
11721
  if (!explicit && !derivesEnvironment(impl.providerName)) {
11710
- rows.push(row$5(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
11722
+ rows.push(row$6(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
11711
11723
  continue;
11712
11724
  }
11713
11725
  try {
@@ -11719,7 +11731,7 @@ async function credentialsRows(input) {
11719
11731
  rows.push(...checked.rows);
11720
11732
  places.push(...checked.places);
11721
11733
  } catch (err) {
11722
- rows.push(row$5(impl.providerName, "fail", errorMessage(err)));
11734
+ rows.push(row$6(impl.providerName, "fail", errorMessage(err)));
11723
11735
  }
11724
11736
  }
11725
11737
  return {
@@ -11735,17 +11747,17 @@ async function credentialsRows(input) {
11735
11747
  async function checkProvider(impl, candidates, expected, synced) {
11736
11748
  const provider = impl.providerName;
11737
11749
  if (!impl.inspect) return {
11738
- rows: [row$5(provider, "skip", "cannot list the variables without reading their values")],
11750
+ rows: [row$6(provider, "skip", "cannot list the variables without reading their values")],
11739
11751
  places: []
11740
11752
  };
11741
11753
  if (expected.length === 0) return {
11742
- rows: [row$5(provider, "skip", "no configured plugin lists the tokens it takes")],
11754
+ rows: [row$6(provider, "skip", "no configured plugin lists the tokens it takes")],
11743
11755
  places: []
11744
11756
  };
11745
11757
  const inspect = impl.inspect.bind(impl);
11746
11758
  try {
11747
11759
  const { found, missing } = await tryEnvironments(candidates, inspect);
11748
- const rows = missing.map((name) => row$5(provider, "fail", `${provider} has no Environment named "${name}"`));
11760
+ const rows = missing.map((name) => row$6(provider, "fail", `${provider} has no Environment named "${name}"`));
11749
11761
  const group = providerGroup(provider);
11750
11762
  const unreadPlaces = missing.map((name) => ({
11751
11763
  column: {
@@ -11768,9 +11780,9 @@ async function checkProvider(impl, candidates, expected, synced) {
11768
11780
  const have = (name) => found.some((f) => f.result.names.includes(name));
11769
11781
  let present = 0;
11770
11782
  for (const { name, optional } of expected) if (have(name)) present++;
11771
- else if (optional) rows.push(row$5(provider, "skip", `optional, not set in ${where}`, name));
11772
- else rows.push(row$5(provider, "fail", `missing from ${where}`, name));
11773
- if (present > 0) rows.push(row$5(provider, "ok", `${present} of ${expected.length} tokens present in ${where}`, "tokens"));
11783
+ else if (optional) rows.push(row$6(provider, "skip", `optional, not set in ${where}`, name));
11784
+ else rows.push(row$6(provider, "fail", `missing from ${where}`, name));
11785
+ if (present > 0) rows.push(row$6(provider, "ok", `${present} of ${expected.length} tokens present in ${where}`, "tokens"));
11774
11786
  const names = new Set(expected.map((e) => e.name));
11775
11787
  const places = [];
11776
11788
  const missingRequired = expected.filter((e) => !e.optional && !have(e.name)).map((e) => e.name);
@@ -11809,7 +11821,7 @@ async function checkProvider(impl, candidates, expected, synced) {
11809
11821
  };
11810
11822
  } catch (err) {
11811
11823
  return {
11812
- rows: [row$5(provider, "fail", errorMessage(err))],
11824
+ rows: [row$6(provider, "fail", errorMessage(err))],
11813
11825
  places: []
11814
11826
  };
11815
11827
  }
@@ -12683,7 +12695,7 @@ async function variableRows(loader, config, org) {
12683
12695
  if (!loader.has("source")) {
12684
12696
  const why = whyMissing(loader, "source", "no `source` provider to read them with");
12685
12697
  for (const check of checks) {
12686
- rows.push(row$4(check, { skip: why }));
12698
+ rows.push(row$5(check, { skip: why }));
12687
12699
  observations.push({
12688
12700
  scope: check.scope,
12689
12701
  unread: why
@@ -12693,7 +12705,7 @@ async function variableRows(loader, config, org) {
12693
12705
  const source = loader.get("source");
12694
12706
  for (const check of checks) try {
12695
12707
  const result = await check.run(source);
12696
- rows.push(row$4(check, result));
12708
+ rows.push(row$5(check, result));
12697
12709
  observations.push("skip" in result ? {
12698
12710
  scope: check.scope,
12699
12711
  unread: result.skip
@@ -12704,7 +12716,7 @@ async function variableRows(loader, config, org) {
12704
12716
  } catch (err) {
12705
12717
  const noToken = missingTokenReason(err);
12706
12718
  if (noToken !== void 0) {
12707
- rows.push(row$4(check, { skip: noToken }));
12719
+ rows.push(row$5(check, { skip: noToken }));
12708
12720
  observations.push({
12709
12721
  scope: check.scope,
12710
12722
  unread: noToken
@@ -12730,7 +12742,7 @@ async function variableRows(loader, config, org) {
12730
12742
  observations
12731
12743
  };
12732
12744
  }
12733
- function row$4(check, result) {
12745
+ function row$5(check, result) {
12734
12746
  const { id, title } = check;
12735
12747
  if ("skip" in result) return {
12736
12748
  id,
@@ -12820,7 +12832,7 @@ function describeExpiry(expiresAt, now) {
12820
12832
  *
12821
12833
  * What a token may do is not checked: GitHub does not return a fine-grained token's permissions.
12822
12834
  */
12823
- function row$3(id, status, detail) {
12835
+ function row$4(id, status, detail) {
12824
12836
  return {
12825
12837
  id: `verify:${id}`,
12826
12838
  title: `verify ${id}`,
@@ -12848,12 +12860,12 @@ async function verifyRows(input) {
12848
12860
  try {
12849
12861
  module = await importer(pkg);
12850
12862
  } catch (err) {
12851
- rows.push(row$3(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
12863
+ rows.push(row$4(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
12852
12864
  continue;
12853
12865
  }
12854
12866
  for (const token of module.tokens ?? []) rows.push(await checkToken(token, module, env, readToken, now()));
12855
12867
  }
12856
- if (rows.length === 0) rows.push(row$3("tokens", "skip", "no configured plugin lists the tokens it takes"));
12868
+ if (rows.length === 0) rows.push(row$4("tokens", "skip", "no configured plugin lists the tokens it takes"));
12857
12869
  return rows;
12858
12870
  }
12859
12871
  /**
@@ -12866,30 +12878,30 @@ async function loadCredentials(input) {
12866
12878
  try {
12867
12879
  await input.loader.load();
12868
12880
  } catch (err) {
12869
- return [row$3("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
12881
+ return [row$4("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
12870
12882
  }
12871
- return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$3(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
12883
+ return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$4(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
12872
12884
  }
12873
12885
  async function checkToken(token, module, env, readToken, now) {
12874
12886
  const { keyringKey, envName, vendorEnvName } = token;
12875
12887
  const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
12876
12888
  const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
12877
12889
  const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
12878
- if (!value) return row$3(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
12890
+ if (!value) return row$4(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
12879
12891
  const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
12880
- if (!verify) return row$3(keyringKey, "skip", "set, but its plugin cannot verify it");
12892
+ if (!verify) return row$4(keyringKey, "skip", "set, but its plugin cannot verify it");
12881
12893
  const from = fromEnv ?? stored?.source ?? "keyring";
12882
12894
  try {
12883
12895
  const verified = await verify(value);
12884
- if (!verified.ok) return row$3(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
12896
+ if (!verified.ok) return row$4(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
12885
12897
  const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
12886
- if (!expiry) return row$3(keyringKey, "ok", `${verified.subject} (${from})`);
12898
+ if (!expiry) return row$4(keyringKey, "ok", `${verified.subject} (${from})`);
12887
12899
  return expiry.soon ? {
12888
- ...row$3(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
12900
+ ...row$4(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
12889
12901
  problems: [`${expiry.text}: renew it`]
12890
- } : row$3(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
12902
+ } : row$4(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
12891
12903
  } catch (err) {
12892
- return row$3(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
12904
+ return row$4(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
12893
12905
  }
12894
12906
  }
12895
12907
  // src/commands/doctor-secrets/doctor-secrets.ts
@@ -13991,11 +14003,198 @@ const authExportCommand = {
13991
14003
  })).status === "fail") process.exitCode = 1;
13992
14004
  }
13993
14005
  };
14006
+ // src/commands/requests-export/resolve-export-dir/resolve-export-dir.ts
14007
+ /** Whether `path` is `folder` itself or somewhere below it. */
14008
+ const within = (path, folder) => {
14009
+ const rel = relative(folder, path);
14010
+ return !(rel === ".." || rel.startsWith(`..${sep}`));
14011
+ };
14012
+ /**
14013
+ * The folder one provider's export is written to: `<out>/<provider>`, where `out` is `--out`, else `.export` beside the
14014
+ * first collection file (`requests/.export/postman`, git-ignored). The folder is refused when it is, or contains, a
14015
+ * source file's folder: an export never writes where the source files are, so it cannot overwrite the one source.
14016
+ * A folder below the source folder is fine.
14017
+ */
14018
+ function resolveExportDir(input) {
14019
+ const { repoRoot, provider, files, out } = input;
14020
+ const first = files[0];
14021
+ let parent;
14022
+ if (out !== void 0) parent = resolve(repoRoot, out);
14023
+ else if (first !== void 0) parent = join(dirname(resolve(repoRoot, first)), ".export");
14024
+ else return {
14025
+ ok: false,
14026
+ message: "it names no collection file, so there is no folder to put `.export` next to"
14027
+ };
14028
+ const dir = join(parent, provider);
14029
+ for (const file of files) if (within(dirname(resolve(repoRoot, file)), dir)) return {
14030
+ ok: false,
14031
+ message: `${dir} is, or holds, the folder of ${file}; an export never writes there`
14032
+ };
14033
+ return {
14034
+ ok: true,
14035
+ dir
14036
+ };
14037
+ }
14038
+ // src/commands/requests-export/run-requests-export/run-requests-export.ts
14039
+ /**
14040
+ * `holocron export requests` — writes the repo's request collections in each `tooling` provider's own format.
14041
+ *
14042
+ * The repo's `collectionFiles` / `envFiles` stay the one source. For each `tooling` provider the config names (or only
14043
+ * `--to`), the command reads those two options from the provider's entry and calls the optional `Tooling.export` with
14044
+ * them and an output folder, `<out>/<provider>`; by default `.export` beside the first collection file, which is
14045
+ * git-ignored (`resolveExportDir()` refuses a folder that is, or holds, the folder of a source file). A provider with
14046
+ * no `export`, or an entry with no `collectionFiles`, is a skipped row. What the conversion could not carry across is
14047
+ * listed under the provider's row and does not fail the run. It writes files, so it asks first unless `--dry-run` (the
14048
+ * files are converted and listed, nothing is written) or `--yes` (without a terminal it refuses instead).
14049
+ */
14050
+ const row$3 = (id, status, detail, problems = []) => ({
14051
+ id,
14052
+ title: id,
14053
+ status,
14054
+ detail,
14055
+ problems
14056
+ });
14057
+ /** A provider option that is a list of file names; anything else reads as none. */
14058
+ const fileList = (value) => Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
14059
+ async function runRequestsExport(input) {
14060
+ /* v8 ignore next -- the console is only used outside tests, which inject `print` */
14061
+ const print = input.print ?? ((line) => console.log(line));
14062
+ const dryRun = Boolean(input.context.dryRun);
14063
+ const { repoRoot } = input.context;
14064
+ const finish = (rows) => {
14065
+ printCheckRows(rows, print);
14066
+ const summary = summariseChecks(rows);
14067
+ printCheckSummary(summary, print);
14068
+ return {
14069
+ status: summary.fail > 0 ? "fail" : "ok",
14070
+ rows
14071
+ };
14072
+ };
14073
+ print(style.header(`Holocron export requests${dryRun ? " (dry-run)" : ""}`));
14074
+ print("");
14075
+ const entry = input.loaded.resolved.providers.tooling;
14076
+ const tuples = entry?.cardinality === "many" ? entry.tuples : [];
14077
+ if (tuples.length === 0) return finish([row$3("tooling", "fail", "the config has no `tooling` provider to export for")]);
14078
+ const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
14079
+ if (chosen.length === 0) return finish([row$3(input.to, "fail", `not a \`tooling\` provider of this config (${tuples.map((t) => t.provider).join(", ")})`)]);
14080
+ /* v8 ignore start -- the real loader is only built outside tests, which always inject one */
14081
+ const loader = input.loader ?? new PluginLoader({
14082
+ ...input.loaded.resolved,
14083
+ providers: { tooling: {
14084
+ cardinality: "many",
14085
+ tuples: chosen
14086
+ } }
14087
+ }, input.context);
14088
+ /* v8 ignore stop */
14089
+ await loader.load();
14090
+ assertPluginsResolvable$1(loader, "export requests");
14091
+ const loaded = loader.has("tooling") ? loader.get("tooling") : [];
14092
+ const rows = [];
14093
+ const targets = [];
14094
+ for (const tuple of chosen) {
14095
+ const id = tuple.provider;
14096
+ const tool = loaded.find((t) => t.providerName === id);
14097
+ if (!tool) {
14098
+ const failure = loader.loadFailures().find((f) => f.key === "tooling" && f.provider === id);
14099
+ rows.push(row$3(id, "fail", `the provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`));
14100
+ continue;
14101
+ }
14102
+ if (!tool.export) {
14103
+ rows.push(row$3(id, "skip", "has no export: it reads the repo's files as they are"));
14104
+ continue;
14105
+ }
14106
+ const collectionFiles = fileList(tuple.options.collectionFiles);
14107
+ const envFiles = fileList(tuple.options.envFiles);
14108
+ if (collectionFiles.length === 0) {
14109
+ rows.push(row$3(id, "skip", "names no `collectionFiles`, so there is nothing to export"));
14110
+ continue;
14111
+ }
14112
+ const dir = resolveExportDir({
14113
+ repoRoot,
14114
+ provider: id,
14115
+ files: [...collectionFiles, ...envFiles],
14116
+ ...input.out !== void 0 ? { out: input.out } : {}
14117
+ });
14118
+ if (!dir.ok) {
14119
+ rows.push(row$3(id, "fail", dir.message));
14120
+ continue;
14121
+ }
14122
+ targets.push({
14123
+ provider: id,
14124
+ collectionFiles,
14125
+ envFiles,
14126
+ outDir: dir.dir,
14127
+ tool
14128
+ });
14129
+ }
14130
+ if (targets.length === 0) return finish(rows);
14131
+ if (!dryRun && !input.yes) {
14132
+ if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`\`export requests\` writes files for ${targets.length} provider(s); pass --yes to run it without asking, or --dry-run to preview`);
14133
+ if (!await (input.confirm ?? ((message) => confirm({
14134
+ message,
14135
+ default: false
14136
+ })))(`Write the exports for ${targets.map((t) => t.provider).join(", ")}?`)) {
14137
+ print(` ${style.skip("cancelled; nothing was written")}`);
14138
+ return {
14139
+ status: "cancelled",
14140
+ rows: []
14141
+ };
14142
+ }
14143
+ }
14144
+ for (const { tool, provider, collectionFiles, envFiles, outDir } of targets) try {
14145
+ const result = await tool.export({
14146
+ collectionFiles,
14147
+ envFiles,
14148
+ outDir,
14149
+ repoRoot,
14150
+ ...dryRun ? { dryRun: true } : {}
14151
+ });
14152
+ const where = relative(repoRoot, outDir);
14153
+ const files = result.files.length > 0 ? ` (${result.files.join(", ")})` : "";
14154
+ rows.push(row$3(provider, "ok", `${dryRun ? "would write" : "wrote"} ${result.files.length} file(s) to ${where}${files}`, result.issues.map((issue) => `issue in ${issue.file}: ${issue.message}`)));
14155
+ } catch (err) {
14156
+ rows.push(row$3(provider, "fail", describeError(err)));
14157
+ }
14158
+ return finish(rows.sort((a, b) => a.id.localeCompare(b.id)));
14159
+ }
14160
+ // src/commands/requests-export/requests-export.command.ts
14161
+ const requestsExportCommand = {
14162
+ command: "requests",
14163
+ describe: "Write the request collections in each tooling provider's own format, never into the source folder",
14164
+ builder: (y) => y.option("to", {
14165
+ type: "string",
14166
+ describe: "Export only for this tooling provider (default: every one that can export)"
14167
+ }).option("out", {
14168
+ type: "string",
14169
+ describe: "The folder to write under, one folder per provider (default: `.export` next to the collection files, which is git-ignored)"
14170
+ }).option("yes", {
14171
+ type: "boolean",
14172
+ describe: "Write without asking (required without a terminal)"
14173
+ }),
14174
+ handler: async (argv) => {
14175
+ const tokens = tokenContext$1(argv.token);
14176
+ if (!tokens) return;
14177
+ const loaded = await loadConfig(argv.cwd);
14178
+ applyResolvedConfig(argv, loaded.resolved);
14179
+ if ((await runRequestsExport({
14180
+ loaded,
14181
+ context: {
14182
+ repoRoot: argv.cwd,
14183
+ dryRun: argv.dryRun,
14184
+ ...tokens,
14185
+ org: resolveOrg(argv, loaded.resolved)
14186
+ },
14187
+ ...argv.to ? { to: argv.to } : {},
14188
+ ...argv.out ? { out: argv.out } : {},
14189
+ ...argv.yes ? { yes: true } : {}
14190
+ })).status === "fail") process.exitCode = 1;
14191
+ }
14192
+ };
13994
14193
  // src/commands/export/export.command.ts
13995
14194
  const exportCommand = {
13996
14195
  command: "export",
13997
- describe: "Export the stored tokens to move them into a credentials environment",
13998
- builder: (y) => y.command(authExportCommand).command(groupMenu$1("export")),
14196
+ describe: "Export the stored tokens, or the request collections, to use them elsewhere",
14197
+ builder: (y) => y.command(authExportCommand).command(requestsExportCommand).command(groupMenu$1("export")),
13999
14198
  handler: () => {}
14000
14199
  };
14001
14200
  // src/commands/skills/skills.args.ts