@theholocron/cli 5.0.0-alpha.483 → 5.0.0-alpha.485
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/README.md +2 -1
- package/dist/cli.mjs +532 -177
- package/dist/cli.mjs.map +1 -1
- package/dist/{index-UQEV2tGX.d.mts → index-CTidqzKv.d.mts} +36 -2
- package/dist/index.d.mts +2 -2
- package/dist/plugin/capabilities.d.mts +2 -2
- package/dist/presets.d.mts +1 -1
- package/package.json +10 -10
package/dist/cli.mjs
CHANGED
|
@@ -110,6 +110,7 @@ const COMMAND_CONTEXTS = {
|
|
|
110
110
|
"doctor logs": "workspace",
|
|
111
111
|
"doctor wiki": "workspace",
|
|
112
112
|
"doctor errors": "workspace",
|
|
113
|
+
"doctor workers": "workspace",
|
|
113
114
|
"doctor github-app": "workspace",
|
|
114
115
|
"move issues": "workspace",
|
|
115
116
|
"apply properties": "workspace",
|
|
@@ -541,6 +542,14 @@ const doctorWikiEntry = {
|
|
|
541
542
|
skipOptions: ["all", "repo"],
|
|
542
543
|
supportsDryRun: false
|
|
543
544
|
};
|
|
545
|
+
// src/commands/doctor-workers/doctor-workers.entry.ts
|
|
546
|
+
const doctorWorkersEntry = {
|
|
547
|
+
name: "doctor workers",
|
|
548
|
+
description: "Check the declared Workers and deployment projects: they exist, route and deploy healthily (read-only)",
|
|
549
|
+
positionals: [],
|
|
550
|
+
skipOptions: ["all", "repo"],
|
|
551
|
+
supportsDryRun: false
|
|
552
|
+
};
|
|
544
553
|
// src/commands/github-app-create/github-app-create.entry.ts
|
|
545
554
|
const githubAppCreateEntry = {
|
|
546
555
|
name: "new github-app",
|
|
@@ -1358,6 +1367,7 @@ const registry = createCommandRegistry([
|
|
|
1358
1367
|
doctorLogsEntry,
|
|
1359
1368
|
doctorWikiEntry,
|
|
1360
1369
|
doctorErrorsEntry,
|
|
1370
|
+
doctorWorkersEntry,
|
|
1361
1371
|
projectMoveEntry,
|
|
1362
1372
|
repoPropertiesApplyEntry,
|
|
1363
1373
|
migrateIssueEntry,
|
|
@@ -7445,7 +7455,7 @@ async function runDoctorDns(input) {
|
|
|
7445
7455
|
});
|
|
7446
7456
|
else if (!loader.has("dns")) {
|
|
7447
7457
|
const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
|
|
7448
|
-
for (const zone of zones) rows.push(row$
|
|
7458
|
+
for (const zone of zones) rows.push(row$23(zone, "skip", why));
|
|
7449
7459
|
for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
|
|
7450
7460
|
} else {
|
|
7451
7461
|
const dns = loader.get("dns");
|
|
@@ -7467,7 +7477,7 @@ async function runDoctorDns(input) {
|
|
|
7467
7477
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
7468
7478
|
};
|
|
7469
7479
|
}
|
|
7470
|
-
function row$
|
|
7480
|
+
function row$23(zone, status, detail, problems = []) {
|
|
7471
7481
|
return {
|
|
7472
7482
|
id: `dns-${zone}`,
|
|
7473
7483
|
title: `${zone} records exist`,
|
|
@@ -7496,7 +7506,7 @@ async function checkDomain(dns, deploy, project, hostname) {
|
|
|
7496
7506
|
return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
|
|
7497
7507
|
}
|
|
7498
7508
|
}
|
|
7499
|
-
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$
|
|
7509
|
+
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$23(zone, ...args)) {
|
|
7500
7510
|
try {
|
|
7501
7511
|
const have = await dns.listRecords(zone);
|
|
7502
7512
|
const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
|
|
@@ -7611,11 +7621,11 @@ const doctorEnvironmentsCommand = {
|
|
|
7611
7621
|
* The error tracker projects the config declares: every project a notifications layout's `relay.errors.projects`
|
|
7612
7622
|
* sends alerts from, in order, each once.
|
|
7613
7623
|
*/
|
|
7614
|
-
function declaredProjects(layouts) {
|
|
7624
|
+
function declaredProjects$1(layouts) {
|
|
7615
7625
|
return [...new Set(layouts.flatMap((layout) => layout.relay?.errors?.projects ?? []))];
|
|
7616
7626
|
}
|
|
7617
7627
|
// src/commands/doctor-errors/errors-rows.ts
|
|
7618
|
-
const row$
|
|
7628
|
+
const row$22 = (id, title, status, detail, problems = []) => ({
|
|
7619
7629
|
id,
|
|
7620
7630
|
title,
|
|
7621
7631
|
status,
|
|
@@ -7632,27 +7642,27 @@ function errorsRows(found, providerName) {
|
|
|
7632
7642
|
const orgSlug = found.org.slug;
|
|
7633
7643
|
if (!found.org.exists) {
|
|
7634
7644
|
const problem = `${providerName} has no organization named ${orgSlug}; check the \`org\` option of the \`errors\` provider`;
|
|
7635
|
-
const rows = [row$
|
|
7636
|
-
for (const project of found.projects) rows.push(row$
|
|
7645
|
+
const rows = [row$22("errors:org", "organization exists", "fail", `${orgSlug} not found`, [problem])];
|
|
7646
|
+
for (const project of found.projects) rows.push(row$22(`errors:project:${project.slug}`, `project ${project.slug} exists`, "skip", "not checked: no organization"));
|
|
7637
7647
|
return rows;
|
|
7638
7648
|
}
|
|
7639
|
-
const rows = [row$
|
|
7649
|
+
const rows = [row$22("errors:org", "organization exists", "ok", `${orgSlug} (${found.org.name ?? orgSlug})`)];
|
|
7640
7650
|
if (found.projects.length === 0) {
|
|
7641
|
-
rows.push(row$
|
|
7651
|
+
rows.push(row$22("errors:projects", "declared projects", "skip", "none declared: no `relay.errors.projects` in a layout"));
|
|
7642
7652
|
return rows;
|
|
7643
7653
|
}
|
|
7644
7654
|
for (const project of found.projects) {
|
|
7645
7655
|
const slug = project.slug;
|
|
7646
7656
|
if (!project.exists) {
|
|
7647
7657
|
const problem = `no project ${slug} in ${found.org.slug}; create it in ${providerName}`;
|
|
7648
|
-
rows.push(row$
|
|
7658
|
+
rows.push(row$22(`errors:project:${slug}`, `project ${slug} exists`, "fail", "not found", [problem]), row$22(`errors:dsn:${slug}`, `project ${slug} has a key`, "skip", "not checked: no project"), row$22(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "skip", "not checked: no project"));
|
|
7649
7659
|
continue;
|
|
7650
7660
|
}
|
|
7651
|
-
rows.push(row$
|
|
7652
|
-
rows.push(project.hasDsn ? row$
|
|
7653
|
-
if (project.alertRules === void 0) rows.push(row$
|
|
7654
|
-
else if (project.alertRules === 0) rows.push(row$
|
|
7655
|
-
else rows.push(row$
|
|
7661
|
+
rows.push(row$22(`errors:project:${slug}`, `project ${slug} exists`, "ok", slug));
|
|
7662
|
+
rows.push(project.hasDsn ? row$22(`errors:dsn:${slug}`, `project ${slug} has a key`, "ok", "a client key (DSN) exists") : row$22(`errors:dsn:${slug}`, `project ${slug} has a key`, "fail", "no client key", [`${slug} has no client key, so an SDK has no DSN to send to; add one in ${providerName}`]));
|
|
7663
|
+
if (project.alertRules === void 0) rows.push(row$22(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "skip", found.alertsUnreadable ? `could not read the alert rules: ${found.alertsUnreadable}` : "not read"));
|
|
7664
|
+
else if (project.alertRules === 0) rows.push(row$22(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "fail", "no enabled rule", [`no enabled alert rule watches ${slug}, so its errors reach no one`]));
|
|
7665
|
+
else rows.push(row$22(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "ok", `${project.alertRules} enabled rule(s)`));
|
|
7656
7666
|
}
|
|
7657
7667
|
return rows;
|
|
7658
7668
|
}
|
|
@@ -7690,7 +7700,7 @@ async function runDoctorErrors(input) {
|
|
|
7690
7700
|
else {
|
|
7691
7701
|
const layouts = (loader.has("notifications") ? loader.get("notifications") : []).flatMap((p) => p.layout ? [p.layout] : []);
|
|
7692
7702
|
try {
|
|
7693
|
-
rows = errorsRows(await errors.inspect({ projects: declaredProjects(layouts) }), errors.providerName);
|
|
7703
|
+
rows = errorsRows(await errors.inspect({ projects: declaredProjects$1(layouts) }), errors.providerName);
|
|
7694
7704
|
} catch (err) {
|
|
7695
7705
|
rows = [skip$1(missingTokenReason(err) ?? `could not read ${errors.providerName}: ${describeError(err)}`)];
|
|
7696
7706
|
}
|
|
@@ -7755,7 +7765,7 @@ function installationSettingsUrl(account, id) {
|
|
|
7755
7765
|
return `https://github.com/settings/installations/${id}`;
|
|
7756
7766
|
}
|
|
7757
7767
|
// src/commands/doctor-github-app/app-rows.ts
|
|
7758
|
-
const row$
|
|
7768
|
+
const row$21 = (name, what, problems, ok) => ({
|
|
7759
7769
|
id: `${name}:${what}`,
|
|
7760
7770
|
title: `${name}: ${what}`,
|
|
7761
7771
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -7782,9 +7792,9 @@ function appRows(name, manifest, app, installations) {
|
|
|
7782
7792
|
return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
|
|
7783
7793
|
});
|
|
7784
7794
|
return [
|
|
7785
|
-
row$
|
|
7786
|
-
row$
|
|
7787
|
-
row$
|
|
7795
|
+
row$21(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
|
|
7796
|
+
row$21(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
|
|
7797
|
+
row$21(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
|
|
7788
7798
|
];
|
|
7789
7799
|
}
|
|
7790
7800
|
// src/commands/doctor-github-app/parse-manifest.ts
|
|
@@ -7842,7 +7852,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
7842
7852
|
assertPluginsResolvable(loader, "doctor github-app");
|
|
7843
7853
|
}
|
|
7844
7854
|
const rows = [];
|
|
7845
|
-
if (instances.length === 0) rows.push(row$
|
|
7855
|
+
if (instances.length === 0) rows.push(row$20("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
|
|
7846
7856
|
for (const instance of instances) rows.push(...await checkInstance(instance, loader, input));
|
|
7847
7857
|
printCheckRows(rows, print);
|
|
7848
7858
|
const summary = summariseChecks(rows);
|
|
@@ -7859,7 +7869,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
7859
7869
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
7860
7870
|
};
|
|
7861
7871
|
}
|
|
7862
|
-
function row$
|
|
7872
|
+
function row$20(name, what, status, detail) {
|
|
7863
7873
|
return {
|
|
7864
7874
|
id: `${name}:${what}`,
|
|
7865
7875
|
title: `${name}: ${what}`,
|
|
@@ -7900,19 +7910,19 @@ async function checkInstance(instance, loader, input) {
|
|
|
7900
7910
|
try {
|
|
7901
7911
|
manifest = parseManifest(readManifest(instance.manifest));
|
|
7902
7912
|
} catch (err) {
|
|
7903
|
-
return [row$
|
|
7913
|
+
return [row$20(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
|
|
7904
7914
|
}
|
|
7905
7915
|
const read = await readCredentials(instance, loader);
|
|
7906
|
-
if ("reason" in read) return [row$
|
|
7916
|
+
if ("reason" in read) return [row$20(name, "reachable", "skip", read.reason)];
|
|
7907
7917
|
const api = input.api ?? defaultApi;
|
|
7908
7918
|
const secrets = [read.creds.privateKey];
|
|
7909
7919
|
try {
|
|
7910
7920
|
const app = await api.getApp(read.creds);
|
|
7911
7921
|
const installations = await api.listAppInstallations(read.creds);
|
|
7912
7922
|
const owner = app.owner ? `, owned by ${app.owner.login}` : "";
|
|
7913
|
-
return [row$
|
|
7923
|
+
return [row$20(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
|
|
7914
7924
|
} catch (err) {
|
|
7915
|
-
return [row$
|
|
7925
|
+
return [row$20(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
|
|
7916
7926
|
}
|
|
7917
7927
|
}
|
|
7918
7928
|
// src/commands/doctor-github-app/doctor-github-app.command.ts
|
|
@@ -7979,7 +7989,7 @@ function datasetTargets(config) {
|
|
|
7979
7989
|
* dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
|
|
7980
7990
|
* a dataset the token may not see (403), a name, a token or a response that cannot be read is a skip with the reason.
|
|
7981
7991
|
*/
|
|
7982
|
-
const row$
|
|
7992
|
+
const row$19 = (id, title, status, detail, problems = []) => ({
|
|
7983
7993
|
id,
|
|
7984
7994
|
title,
|
|
7985
7995
|
status,
|
|
@@ -7996,7 +8006,7 @@ async function runDoctorLogs(input) {
|
|
|
7996
8006
|
if (!loader.has("logs")) {
|
|
7997
8007
|
const failure = loader.loadFailures().find((f) => f.key === "logs");
|
|
7998
8008
|
const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
|
|
7999
|
-
rows.push(row$
|
|
8009
|
+
rows.push(row$19("logs", "logs", "skip", why));
|
|
8000
8010
|
} else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
|
|
8001
8011
|
printCheckRows(rows, print);
|
|
8002
8012
|
const summary = summariseChecks(rows);
|
|
@@ -8020,38 +8030,38 @@ async function checkLogs(logs, targets) {
|
|
|
8020
8030
|
for (const target of targets) {
|
|
8021
8031
|
const id = `logs:dataset:${target.id}`;
|
|
8022
8032
|
const title = `dataset for ${target.label}`;
|
|
8023
|
-
if (!target.name) rows.push(row$
|
|
8024
|
-
else if (!token.usable) rows.push(row$
|
|
8025
|
-
else if (!logs.readDataset) rows.push(row$
|
|
8033
|
+
if (!target.name) rows.push(row$19(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
|
|
8034
|
+
else if (!token.usable) rows.push(row$19(id, title, "skip", `${target.name}: not checked, the token is not usable`));
|
|
8035
|
+
else if (!logs.readDataset) rows.push(row$19(id, title, "skip", `${logs.providerName} cannot read a dataset`));
|
|
8026
8036
|
else rows.push(...await checkDataset(logs, target, target.name, id, title));
|
|
8027
8037
|
}
|
|
8028
8038
|
const org = resolveValue$1(["AXIOM_ORG"], void 0, { prefix: PREFIX$1 });
|
|
8029
|
-
rows.push(org ? row$
|
|
8039
|
+
rows.push(org ? row$19("logs:org", "organization", "ok", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$19("logs:org", "organization", "skip", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links need it`));
|
|
8030
8040
|
return rows;
|
|
8031
8041
|
}
|
|
8032
8042
|
/** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
|
|
8033
8043
|
async function checkToken$1(logs, dataset) {
|
|
8034
8044
|
const title = "token is accepted";
|
|
8035
8045
|
if (!logs.checkToken) return {
|
|
8036
|
-
row: row$
|
|
8046
|
+
row: row$19("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
|
|
8037
8047
|
usable: true
|
|
8038
8048
|
};
|
|
8039
8049
|
try {
|
|
8040
8050
|
const result = await logs.checkToken(dataset);
|
|
8041
8051
|
if (result.ok) return {
|
|
8042
|
-
row: row$
|
|
8052
|
+
row: row$19("logs:token", title, "ok", `${logs.providerName} accepts the token`),
|
|
8043
8053
|
usable: true
|
|
8044
8054
|
};
|
|
8045
8055
|
const reason = result.reason ?? `${logs.providerName} refused the token`;
|
|
8046
8056
|
return {
|
|
8047
|
-
row: row$
|
|
8057
|
+
row: row$19("logs:token", title, "fail", reason, [reason]),
|
|
8048
8058
|
usable: false
|
|
8049
8059
|
};
|
|
8050
8060
|
} catch (err) {
|
|
8051
8061
|
const noToken = missingTokenReason(err);
|
|
8052
8062
|
const detail = noToken ?? `could not check the token: ${describeError(err)}`;
|
|
8053
8063
|
return {
|
|
8054
|
-
row: row$
|
|
8064
|
+
row: row$19("logs:token", title, "skip", detail),
|
|
8055
8065
|
usable: noToken === void 0
|
|
8056
8066
|
};
|
|
8057
8067
|
}
|
|
@@ -8061,17 +8071,17 @@ async function checkDataset(logs, target, name, id, title) {
|
|
|
8061
8071
|
const found = await logs.readDataset(name);
|
|
8062
8072
|
if (found.forbidden) {
|
|
8063
8073
|
const why = `${name}: not visible to this token (${logs.providerName} refused the read; it may also not exist)`;
|
|
8064
|
-
return [row$
|
|
8074
|
+
return [row$19(id, title, "skip", why)];
|
|
8065
8075
|
}
|
|
8066
8076
|
if (!found.exists) {
|
|
8067
8077
|
const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
|
|
8068
|
-
return [row$
|
|
8078
|
+
return [row$19(id, title, "fail", `${name} does not exist`, [problem])];
|
|
8069
8079
|
}
|
|
8070
8080
|
const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
|
|
8071
|
-
return [row$
|
|
8081
|
+
return [row$19(id, title, "ok", `${name} exists`), row$19(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
|
|
8072
8082
|
} catch (err) {
|
|
8073
8083
|
const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
|
|
8074
|
-
return [row$
|
|
8084
|
+
return [row$19(id, title, "skip", detail)];
|
|
8075
8085
|
}
|
|
8076
8086
|
}
|
|
8077
8087
|
// src/commands/doctor-logs/doctor-logs.command.ts
|
|
@@ -9373,7 +9383,7 @@ const CHANNEL_ID = "monitoring-alert-channel";
|
|
|
9373
9383
|
const CHANNEL_TITLE = "monitoring alert channel posts through the feed webhook";
|
|
9374
9384
|
const SUBSCRIPTIONS_ID = "monitoring-subscriptions";
|
|
9375
9385
|
const SUBSCRIPTIONS_TITLE = "monitoring alert channel is subscribed to the checks routed to it";
|
|
9376
|
-
const same$
|
|
9386
|
+
const same$5 = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
9377
9387
|
const shown$5 = (s) => sanitizeDetail(s);
|
|
9378
9388
|
const skipAll = (reason) => [
|
|
9379
9389
|
skipRow$1(WEBHOOK_ID$1, WEBHOOK_TITLE$1, reason),
|
|
@@ -9401,14 +9411,14 @@ async function monitoringFeedChecks(input) {
|
|
|
9401
9411
|
let channelSkip;
|
|
9402
9412
|
for (const { channel, feed } of fed) {
|
|
9403
9413
|
const names = monitoringFeed(channel.name, feed, monitoring);
|
|
9404
|
-
const where = found.channels.find((c) => same$
|
|
9414
|
+
const where = found.channels.find((c) => same$5(c.name, channel.name));
|
|
9405
9415
|
const hookId = where?.webhookIds?.[names.webhook.toLowerCase()];
|
|
9406
|
-
const named = where?.webhooks.some((w) => same$
|
|
9416
|
+
const named = where?.webhooks.some((w) => same$5(w, names.webhook)) ?? false;
|
|
9407
9417
|
const label = `#${shown$5(channel.name)}`;
|
|
9408
9418
|
if (!where) webhookProblems.push(`${label}: no channel to hold the feed webhook`);
|
|
9409
9419
|
else if (where.webhooksError) webhookProblems.push(`${label}: could not list its webhooks (${shown$5(where.webhooksError)})`);
|
|
9410
9420
|
else if (!named) webhookProblems.push(`${label}: no webhook named ${shown$5(names.webhook)}`);
|
|
9411
|
-
else if (feedAvatarOf(layout, feed, monitoring).length > 0 && !where.webhookAvatars?.some((w) => same$
|
|
9421
|
+
else if (feedAvatarOf(layout, feed, monitoring).length > 0 && !where.webhookAvatars?.some((w) => same$5(w, names.webhook))) webhookProblems.push(`${label}: webhook ${shown$5(names.webhook)} has no picture`);
|
|
9412
9422
|
if (channelSkip !== void 0) continue;
|
|
9413
9423
|
if (!monitoring.inspectAlertChannel) {
|
|
9414
9424
|
channelSkip = `the \`${monitoring.providerName}\` provider cannot read its alert channels`;
|
|
@@ -10112,7 +10122,7 @@ async function postDoctorReport(notifications, channel, report, name = "notifica
|
|
|
10112
10122
|
const FORUM_TITLE = "pull request feed forum exists";
|
|
10113
10123
|
const TAGS_TITLE = "pull request feed forum has the tags of every state";
|
|
10114
10124
|
const BOT_TITLE = "bot can post in the pull request feed forum and manage its threads";
|
|
10115
|
-
const same$
|
|
10125
|
+
const same$4 = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
10116
10126
|
const shown$3 = (s) => sanitizeDetail(s);
|
|
10117
10127
|
/**
|
|
10118
10128
|
* The steps of `doctor notifications` for the pull-request feed (`feeds.prs`): the forum is there (in its category, as a
|
|
@@ -10140,7 +10150,7 @@ function prFeedChecks(input) {
|
|
|
10140
10150
|
const botProblems = [];
|
|
10141
10151
|
for (const { cat, channel } of fed) {
|
|
10142
10152
|
const name = shown$3(channel.name);
|
|
10143
|
-
const have = found.channels.find((c) => same$
|
|
10153
|
+
const have = found.channels.find((c) => same$4(c.name, channel.name) && c.category !== void 0 && same$4(c.category, cat));
|
|
10144
10154
|
if (!have) {
|
|
10145
10155
|
forumProblems.push(`#${name}: missing from ${shown$3(cat)}`);
|
|
10146
10156
|
continue;
|
|
@@ -10149,7 +10159,7 @@ function prFeedChecks(input) {
|
|
|
10149
10159
|
forumProblems.push(`#${name}: is a text channel, not a forum; delete it so \`setup\` can make it again`);
|
|
10150
10160
|
continue;
|
|
10151
10161
|
}
|
|
10152
|
-
for (const tag of PR_FEED_TAGS) if (!have.tags?.some((t) => same$
|
|
10162
|
+
for (const tag of PR_FEED_TAGS) if (!have.tags?.some((t) => same$4(t.name, tag))) tagProblems.push(`#${name}: tag "${tag}" is missing`);
|
|
10153
10163
|
if (have.botThreadsError) botProblems.push(`#${name}: could not read the bot's permissions (${shown$3(have.botThreadsError)})`);
|
|
10154
10164
|
else if (have.botThreads) {
|
|
10155
10165
|
if (!have.botThreads.post) botProblems.push(`#${name}: the bot cannot start posts or reply in it`);
|
|
@@ -10174,7 +10184,7 @@ const BINDINGS_ID = "relay-bindings";
|
|
|
10174
10184
|
const BINDINGS_TITLE = "relay Worker has its webhook and signing secret bound";
|
|
10175
10185
|
const WEBHOOK_ID = "relay-feed-webhook";
|
|
10176
10186
|
const WEBHOOK_TITLE = "error feed webhook exists and has a picture";
|
|
10177
|
-
const same$
|
|
10187
|
+
const same$3 = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
10178
10188
|
const shown$2 = (s) => sanitizeDetail(s);
|
|
10179
10189
|
/** One unsigned `POST` to the Worker, and what the answer says about it. Reads nothing from the response. */
|
|
10180
10190
|
async function answers(url, doFetch) {
|
|
@@ -10221,7 +10231,7 @@ async function relayChecks(input) {
|
|
|
10221
10231
|
else {
|
|
10222
10232
|
const bound = new Set(state.bindingNames.map((n) => n.toUpperCase()));
|
|
10223
10233
|
const wanted = [relayWebhookBinding(source), relaySecretBinding(source)];
|
|
10224
|
-
rows.push(resultRow(WORKER_ID, WORKER_TITLE, state.routes.some((r) => same$
|
|
10234
|
+
rows.push(resultRow(WORKER_ID, WORKER_TITLE, state.routes.some((r) => same$3(r, route)) ? [] : [`${shown$2(script)} has no route ${shown$2(route)}`], `${shown$2(script)} serves ${shown$2(route)}`), resultRow(BINDINGS_ID, BINDINGS_TITLE, wanted.filter((n) => !bound.has(n)).map((n) => `${n}: not bound`), `${wanted.length} of ${wanted.length} bound`));
|
|
10225
10235
|
}
|
|
10226
10236
|
} catch (err) {
|
|
10227
10237
|
const reason = missingTokenReason(err);
|
|
@@ -10236,13 +10246,13 @@ function webhookRow(input, source) {
|
|
|
10236
10246
|
const channel = input.layout.categories.flatMap((cat) => cat.channels ?? []).find((c) => c.feeds?.errors);
|
|
10237
10247
|
const feed = channel.feeds.errors;
|
|
10238
10248
|
const name = errorsFeedWebhook(feed, { providerName: source });
|
|
10239
|
-
const where = input.found.channels.find((c) => same$
|
|
10249
|
+
const where = input.found.channels.find((c) => same$3(c.name, channel.name));
|
|
10240
10250
|
const label = `#${shown$2(channel.name)}`;
|
|
10241
10251
|
const problems = [];
|
|
10242
10252
|
if (!where) problems.push(`${label}: no channel to hold the feed webhook`);
|
|
10243
10253
|
else if (where.webhooksError) problems.push(`${label}: could not list its webhooks (${shown$2(where.webhooksError)})`);
|
|
10244
|
-
else if (!where.webhooks.some((w) => same$
|
|
10245
|
-
else if (feedAvatarOf(input.layout, feed).length > 0 && !where.webhookAvatars?.some((w) => same$
|
|
10254
|
+
else if (!where.webhooks.some((w) => same$3(w, name))) problems.push(`${label}: no webhook named ${shown$2(name)}`);
|
|
10255
|
+
else if (feedAvatarOf(input.layout, feed).length > 0 && !where.webhookAvatars?.some((w) => same$3(w, name))) problems.push(`${label}: webhook ${shown$2(name)} has no picture`);
|
|
10246
10256
|
return resultRow(WEBHOOK_ID, WEBHOOK_TITLE, problems, `${label}: ${shown$2(name)}`);
|
|
10247
10257
|
}
|
|
10248
10258
|
// src/commands/sentry-relay-checks/sentry-relay-checks.ts
|
|
@@ -10309,7 +10319,7 @@ async function sentryRelayChecks(input) {
|
|
|
10309
10319
|
* It is the end-to-end check for `setup notifications`, and stays useful after
|
|
10310
10320
|
* as a drift check. The step numbers match the table in holocron#1098.
|
|
10311
10321
|
*/
|
|
10312
|
-
const same = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
10322
|
+
const same$2 = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
10313
10323
|
/** `everyone`, or the roles sorted and lower-cased, so order and case do not matter when comparing. */
|
|
10314
10324
|
const accessKey = (v) => v === "everyone" ? "everyone" : JSON.stringify([...new Set(v.map((r) => r.toLowerCase()))].sort());
|
|
10315
10325
|
/** The prompts of an onboarding in a form two of them can be compared in: the order of the channels and roles an answer gives, and case, do not matter. */
|
|
@@ -10448,10 +10458,10 @@ async function runDoctorNotifications(input) {
|
|
|
10448
10458
|
channel
|
|
10449
10459
|
})));
|
|
10450
10460
|
const pick = (name, category) => {
|
|
10451
|
-
const named = found.channels.filter((c) => same(c.name, name));
|
|
10461
|
+
const named = found.channels.filter((c) => same$2(c.name, name));
|
|
10452
10462
|
return {
|
|
10453
10463
|
named,
|
|
10454
|
-
match: named.find((c) => c.category !== void 0 && same(c.category, category))
|
|
10464
|
+
match: named.find((c) => c.category !== void 0 && same$2(c.category, category))
|
|
10455
10465
|
};
|
|
10456
10466
|
};
|
|
10457
10467
|
if (!found) {
|
|
@@ -10472,7 +10482,7 @@ async function runDoctorNotifications(input) {
|
|
|
10472
10482
|
} else {
|
|
10473
10483
|
const inspected = found;
|
|
10474
10484
|
const categories = layout.categories ?? [];
|
|
10475
|
-
add("categories", "categories exist", categories.filter((cat) => !inspected.categories.some((name) => same(name, cat.name))).map((cat) => `${shown(cat.name)}: missing`), categories.length === 0 ? "none declared" : `${categories.length} of ${categories.length} exist`);
|
|
10485
|
+
add("categories", "categories exist", categories.filter((cat) => !inspected.categories.some((name) => same$2(name, cat.name))).map((cat) => `${shown(cat.name)}: missing`), categories.length === 0 ? "none declared" : `${categories.length} of ${categories.length} exist`);
|
|
10476
10486
|
const channelProblems = [];
|
|
10477
10487
|
for (const { cat, channel } of declaredChannels) {
|
|
10478
10488
|
const { named, match } = pick(channel.name, cat);
|
|
@@ -10491,7 +10501,7 @@ async function runDoctorNotifications(input) {
|
|
|
10491
10501
|
else if (isForum) {
|
|
10492
10502
|
if (channel.defaultReaction && (match.defaultReaction ?? "") !== channel.defaultReaction) channelProblems.push(`#${shown(channel.name)}: default reaction is ${match.defaultReaction ? `"${shown(match.defaultReaction)}"` : "not set"} but the layout says "${shown(channel.defaultReaction)}"`);
|
|
10493
10503
|
for (const tag of channel.tags ?? []) {
|
|
10494
|
-
const have = match.tags?.find((t) => same(t.name, tag.name));
|
|
10504
|
+
const have = match.tags?.find((t) => same$2(t.name, tag.name));
|
|
10495
10505
|
if (!have) channelProblems.push(`#${shown(channel.name)}: tag "${shown(tag.name)}" is missing`);
|
|
10496
10506
|
else if ((have.emoji ?? "") !== (tag.emoji ?? "") || (have.moderated ?? false) !== (tag.moderated ?? false)) channelProblems.push(`#${shown(channel.name)}: tag "${shown(tag.name)}" differs from the layout (emoji or moderated)`);
|
|
10497
10507
|
}
|
|
@@ -10505,7 +10515,7 @@ async function runDoctorNotifications(input) {
|
|
|
10505
10515
|
const { match } = pick(channel.name, cat);
|
|
10506
10516
|
if (!match) webhookProblems.push(`#${shown(channel.name)}: no channel to hold the webhook`);
|
|
10507
10517
|
else if (match.webhooksError) webhookProblems.push(`#${shown(channel.name)}: could not list its webhooks (${shown(match.webhooksError)})`);
|
|
10508
|
-
else if (!match.webhooks.some((w) => same(w, name))) webhookProblems.push(`#${shown(channel.name)}: no webhook named ${shown(name)}`);
|
|
10518
|
+
else if (!match.webhooks.some((w) => same$2(w, name))) webhookProblems.push(`#${shown(channel.name)}: no webhook named ${shown(name)}`);
|
|
10509
10519
|
}
|
|
10510
10520
|
add("webhooks", "webhooks on their channels", webhookProblems, withWebhook.length === 0 ? "none declared" : `${withWebhook.length} of ${withWebhook.length} exist`);
|
|
10511
10521
|
const wantAvatar = declaredChannels.filter(({ channel }) => channel.webhook && webhookAvatarOf(layout, channel.webhook).length > 0);
|
|
@@ -10515,14 +10525,14 @@ async function runDoctorNotifications(input) {
|
|
|
10515
10525
|
const { match } = pick(channel.name, cat);
|
|
10516
10526
|
if (!match) avatarProblems.push(`#${shown(channel.name)}: no channel to hold the webhook`);
|
|
10517
10527
|
else if (match.webhooksError) avatarProblems.push(`#${shown(channel.name)}: could not list its webhooks (${shown(match.webhooksError)})`);
|
|
10518
|
-
else if (match.webhookAvatars && !match.webhookAvatars.some((w) => same(w, name))) avatarProblems.push(`#${shown(channel.name)}: webhook ${shown(name)} has no avatar`);
|
|
10528
|
+
else if (match.webhookAvatars && !match.webhookAvatars.some((w) => same$2(w, name))) avatarProblems.push(`#${shown(channel.name)}: webhook ${shown(name)} has no avatar`);
|
|
10519
10529
|
}
|
|
10520
10530
|
add("webhook-appearance", AVATAR_TITLE, avatarProblems, wantAvatar.length === 0 ? "none declared" : `${wantAvatar.length} of ${wantAvatar.length} set`);
|
|
10521
10531
|
const roles = layout.roles ?? [];
|
|
10522
10532
|
const roleProblems = [];
|
|
10523
10533
|
if (inspected.rolesError) roleProblems.push(`could not read the roles (${shown(inspected.rolesError)})`);
|
|
10524
10534
|
for (const role of inspected.rolesError ? [] : roles) {
|
|
10525
|
-
const named = inspected.roles.filter((r) => same(r.name, role.name));
|
|
10535
|
+
const named = inspected.roles.filter((r) => same$2(r.name, role.name));
|
|
10526
10536
|
const actual = named[0];
|
|
10527
10537
|
if (named.length > 1) roleProblems.push(`${shown(role.name)}: ${named.length} roles have this name; setup cannot tell which to manage`);
|
|
10528
10538
|
else if (!actual) roleProblems.push(`${shown(role.name)}: missing`);
|
|
@@ -10531,7 +10541,7 @@ async function runDoctorNotifications(input) {
|
|
|
10531
10541
|
add("roles", "roles exist and are mentionable", roleProblems, roles.length === 0 ? "none declared" : `${roles.length} of ${roles.length} as declared`);
|
|
10532
10542
|
const appearance = [];
|
|
10533
10543
|
if (!inspected.rolesError) for (const role of roles) {
|
|
10534
|
-
const actual = inspected.roles.find((r) => same(r.name, role.name));
|
|
10544
|
+
const actual = inspected.roles.find((r) => same$2(r.name, role.name));
|
|
10535
10545
|
if (!actual) {
|
|
10536
10546
|
appearance.push(`${shown(role.name)}: not checked, the role is missing`);
|
|
10537
10547
|
continue;
|
|
@@ -10585,9 +10595,9 @@ async function runDoctorNotifications(input) {
|
|
|
10585
10595
|
for (const cat of categories) {
|
|
10586
10596
|
if (cat.access) {
|
|
10587
10597
|
accessDeclared++;
|
|
10588
|
-
if (!inspected.categories.some((name) => same(name, cat.name))) accessProblems.push(`${shown(cat.name)}: not checked, the category is missing`);
|
|
10598
|
+
if (!inspected.categories.some((name) => same$2(name, cat.name))) accessProblems.push(`${shown(cat.name)}: not checked, the category is missing`);
|
|
10589
10599
|
else {
|
|
10590
|
-
const have = Object.entries(inspected.categoryAccess ?? {}).find(([n]) => same(n, cat.name))?.[1];
|
|
10600
|
+
const have = Object.entries(inspected.categoryAccess ?? {}).find(([n]) => same$2(n, cat.name))?.[1];
|
|
10591
10601
|
compare(shown(cat.name), cat.access, have);
|
|
10592
10602
|
}
|
|
10593
10603
|
}
|
|
@@ -10625,7 +10635,7 @@ async function runDoctorNotifications(input) {
|
|
|
10625
10635
|
const want = wantServer[field];
|
|
10626
10636
|
if (want === void 0) continue;
|
|
10627
10637
|
const actual = have[field];
|
|
10628
|
-
if (!((field === "systemChannel" || field === "rulesChannel" || field === "updatesChannel") && typeof want === "string" && typeof actual === "string" ? same(want, actual) : want === actual)) serverProblems.push(`${field} is ${shown(String(actual ?? "not set"))} but the layout says ${shown(String(want))}`);
|
|
10638
|
+
if (!((field === "systemChannel" || field === "rulesChannel" || field === "updatesChannel") && typeof want === "string" && typeof actual === "string" ? same$2(want, actual) : want === actual)) serverProblems.push(`${field} is ${shown(String(actual ?? "not set"))} but the layout says ${shown(String(want))}`);
|
|
10629
10639
|
}
|
|
10630
10640
|
}
|
|
10631
10641
|
}
|
|
@@ -10831,7 +10841,7 @@ async function runDoctorNotifications(input) {
|
|
|
10831
10841
|
})));
|
|
10832
10842
|
const testName = layout.testChannel;
|
|
10833
10843
|
const mode = input.deliver ? "all" : !input.builtOnly && testName !== void 0 ? "test" : "none";
|
|
10834
|
-
const targets = mode === "all" ? withHook : mode === "test" ? withHook.filter(({ channel }) => same(channel.name, testName)).slice(0, 1) : [];
|
|
10844
|
+
const targets = mode === "all" ? withHook : mode === "test" ? withHook.filter(({ channel }) => same$2(channel.name, testName)).slice(0, 1) : [];
|
|
10835
10845
|
let deliveryNote;
|
|
10836
10846
|
if (mode === "none") deliveryNote = !input.builtOnly && testName === void 0 ? "the delivery check needs a test channel: name one in the layout's `testChannel` (a channel with a webhook)" : "the delivery check posts test messages, so --built-only skips it; add --deliver to post to every channel";
|
|
10837
10847
|
else if (targets.length === 0) checks.push({
|
|
@@ -11275,7 +11285,7 @@ const info = (id, title, noun, extras) => ({
|
|
|
11275
11285
|
detail: `info: ${extras.length} ${noun} not in the template (never deleted)`,
|
|
11276
11286
|
problems: extras
|
|
11277
11287
|
});
|
|
11278
|
-
const row$
|
|
11288
|
+
const row$18 = (id, title, problems, ok) => ({
|
|
11279
11289
|
id,
|
|
11280
11290
|
title,
|
|
11281
11291
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -11311,19 +11321,19 @@ function viewProblems(want, found) {
|
|
|
11311
11321
|
function boardRows(boardName, template, state) {
|
|
11312
11322
|
const id = `project:${boardName}`;
|
|
11313
11323
|
const rows = [];
|
|
11314
|
-
rows.push(row$
|
|
11324
|
+
rows.push(row$18(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
|
|
11315
11325
|
const extraStatuses = state.statuses.filter((s) => !template.statuses.some((t) => t.name === s));
|
|
11316
11326
|
if (extraStatuses.length > 0) rows.push(info(`${id}:extra-statuses`, `${boardName}: extra statuses`, "status(es)", extraStatuses));
|
|
11317
|
-
for (const want of template.fields) rows.push(row$
|
|
11327
|
+
for (const want of template.fields) rows.push(row$18(`${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));
|
|
11318
11328
|
const extraFields = state.fields.filter((f) => !template.fields.some((t) => t.name === f.name));
|
|
11319
11329
|
if (extraFields.length > 0) rows.push(info(`${id}:extra-fields`, `${boardName}: extra fields`, "field(s)", extraFields.map((f) => f.name)));
|
|
11320
|
-
for (const want of template.views) rows.push(row$
|
|
11330
|
+
for (const want of template.views) rows.push(row$18(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
|
|
11321
11331
|
const extraViews = state.views.filter((v) => !template.views.some((t) => t.name === v.name));
|
|
11322
11332
|
if (extraViews.length > 0) rows.push(info(`${id}:extra-views`, `${boardName}: extra views`, "view(s)", extraViews.map((v) => v.name)));
|
|
11323
11333
|
for (const name of template.rules ?? []) {
|
|
11324
11334
|
const found = state.rules.find((r) => r.name === name);
|
|
11325
11335
|
const problems = !found ? [`missing rule ${name}`] : found.enabled ? [] : [`rule ${name} is off`];
|
|
11326
|
-
rows.push(row$
|
|
11336
|
+
rows.push(row$18(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
|
|
11327
11337
|
}
|
|
11328
11338
|
return rows;
|
|
11329
11339
|
}
|
|
@@ -11383,7 +11393,7 @@ function itemRows(boardName, items) {
|
|
|
11383
11393
|
* never fail the run. A template file that does not read is a failure naming the file. `--post [channel]` shares the
|
|
11384
11394
|
* failing rows through the `notifications` provider's bot, like `doctor notifications --post`.
|
|
11385
11395
|
*/
|
|
11386
|
-
const row$
|
|
11396
|
+
const row$17 = (id, title, status, detail, problems = []) => ({
|
|
11387
11397
|
id,
|
|
11388
11398
|
title,
|
|
11389
11399
|
status,
|
|
@@ -11437,14 +11447,14 @@ async function checkBoards(input, loader) {
|
|
|
11437
11447
|
loader,
|
|
11438
11448
|
...input.io ? { io: input.io } : {}
|
|
11439
11449
|
});
|
|
11440
|
-
if (!opened.ok) return [row$
|
|
11450
|
+
if (!opened.ok) return [row$17("project", "project", opened.kind, opened.reason, opened.problems)];
|
|
11441
11451
|
const { projects, owner, boards, templates, templateProblems } = opened.context;
|
|
11442
11452
|
const rows = templateProblems.map((problem) => {
|
|
11443
11453
|
/* v8 ignore next -- split always returns at least one element; the fallback only satisfies noUncheckedIndexedAccess */
|
|
11444
11454
|
const file = problem.split(": ")[0] ?? problem;
|
|
11445
|
-
return row$
|
|
11455
|
+
return row$17(`project:template:${file}`, `template file ${file}`, "fail", problem);
|
|
11446
11456
|
});
|
|
11447
|
-
if (boards.length === 0) return [...rows, row$
|
|
11457
|
+
if (boards.length === 0) return [...rows, row$17("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
|
|
11448
11458
|
for (const declared of boards) {
|
|
11449
11459
|
const template = templates[declared.template];
|
|
11450
11460
|
const title = `${declared.name}: board exists and is open`;
|
|
@@ -11452,18 +11462,18 @@ async function checkBoards(input, loader) {
|
|
|
11452
11462
|
const board = await projects.find(owner, declared.name);
|
|
11453
11463
|
if (!board) {
|
|
11454
11464
|
const closed = (await projects.list(owner)).some((b) => b.name === declared.name && b.closed);
|
|
11455
|
-
rows.push(row$
|
|
11465
|
+
rows.push(row$17(`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`"]));
|
|
11456
11466
|
continue;
|
|
11457
11467
|
}
|
|
11458
|
-
rows.push(row$
|
|
11468
|
+
rows.push(row$17(`project:${declared.name}`, title, "ok", board.url));
|
|
11459
11469
|
if (!template) {
|
|
11460
|
-
rows.push(row$
|
|
11470
|
+
rows.push(row$17(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
|
|
11461
11471
|
continue;
|
|
11462
11472
|
}
|
|
11463
11473
|
rows.push(...boardRows(declared.name, template, await projects.read(owner, board)));
|
|
11464
|
-
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$
|
|
11474
|
+
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$17(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
|
|
11465
11475
|
} catch (err) {
|
|
11466
|
-
rows.push(row$
|
|
11476
|
+
rows.push(row$17(`project:${declared.name}`, title, "fail", describeError(err)));
|
|
11467
11477
|
}
|
|
11468
11478
|
}
|
|
11469
11479
|
return rows;
|
|
@@ -12383,19 +12393,19 @@ async function runDoctorRepo(input) {
|
|
|
12383
12393
|
const rows = [];
|
|
12384
12394
|
if (!loader.has("source")) {
|
|
12385
12395
|
const why = whyMissing(loader, "source", "no `source` provider to read the repository with");
|
|
12386
|
-
for (const check of checks) rows.push(row$
|
|
12396
|
+
for (const check of checks) rows.push(row$16(check, { skip: why }));
|
|
12387
12397
|
} else {
|
|
12388
12398
|
const source = loader.get("source");
|
|
12389
12399
|
for (const check of checks) {
|
|
12390
12400
|
if (typeof source[check.needs] !== "function") {
|
|
12391
|
-
rows.push(row$
|
|
12401
|
+
rows.push(row$16(check, { skip: `provider does not implement ${check.needs}` }));
|
|
12392
12402
|
continue;
|
|
12393
12403
|
}
|
|
12394
12404
|
try {
|
|
12395
|
-
rows.push(row$
|
|
12405
|
+
rows.push(row$16(check, await check.run(source)));
|
|
12396
12406
|
} catch (err) {
|
|
12397
12407
|
const noToken = missingTokenReason(err);
|
|
12398
|
-
if (noToken !== void 0) rows.push(row$
|
|
12408
|
+
if (noToken !== void 0) rows.push(row$16(check, { skip: noToken }));
|
|
12399
12409
|
else rows.push({
|
|
12400
12410
|
id: check.id,
|
|
12401
12411
|
title: check.title,
|
|
@@ -12421,7 +12431,7 @@ async function runDoctorRepo(input) {
|
|
|
12421
12431
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
12422
12432
|
};
|
|
12423
12433
|
}
|
|
12424
|
-
function row$
|
|
12434
|
+
function row$16(check, result) {
|
|
12425
12435
|
const { id, title } = check;
|
|
12426
12436
|
if ("skip" in result) return {
|
|
12427
12437
|
id,
|
|
@@ -12944,7 +12954,7 @@ function providerGroup(providerName) {
|
|
|
12944
12954
|
}
|
|
12945
12955
|
// src/commands/doctor-secrets/credentials-rows.ts
|
|
12946
12956
|
/** A row for the provider as a whole, or for one of its variables when `name` is given. */
|
|
12947
|
-
function row$
|
|
12957
|
+
function row$15(provider, status, detail, name) {
|
|
12948
12958
|
return name === void 0 ? {
|
|
12949
12959
|
id: provider,
|
|
12950
12960
|
title: provider,
|
|
@@ -12969,10 +12979,10 @@ async function credentialsRows(input) {
|
|
|
12969
12979
|
const { loader } = input;
|
|
12970
12980
|
const { resolved } = input.loaded;
|
|
12971
12981
|
if (!resolved.providers.credentials) return {
|
|
12972
|
-
rows: input.asked ? [row$
|
|
12982
|
+
rows: input.asked ? [row$15("credentials", "skip", "no `credentials` provider is configured")] : [],
|
|
12973
12983
|
places: []
|
|
12974
12984
|
};
|
|
12975
|
-
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$
|
|
12985
|
+
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$15(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
|
|
12976
12986
|
const places = [];
|
|
12977
12987
|
if (!loader.has("credentials")) return {
|
|
12978
12988
|
rows,
|
|
@@ -12984,7 +12994,7 @@ async function credentialsRows(input) {
|
|
|
12984
12994
|
const tuple = tuples.find((t) => t.provider === impl.providerName);
|
|
12985
12995
|
const explicit = tuple && credentialsEnvironment(tuple, resolved);
|
|
12986
12996
|
if (!explicit && !derivesEnvironment(impl.providerName)) {
|
|
12987
|
-
rows.push(row$
|
|
12997
|
+
rows.push(row$15(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
|
|
12988
12998
|
continue;
|
|
12989
12999
|
}
|
|
12990
13000
|
try {
|
|
@@ -12996,7 +13006,7 @@ async function credentialsRows(input) {
|
|
|
12996
13006
|
rows.push(...checked.rows);
|
|
12997
13007
|
places.push(...checked.places);
|
|
12998
13008
|
} catch (err) {
|
|
12999
|
-
rows.push(row$
|
|
13009
|
+
rows.push(row$15(impl.providerName, "fail", errorMessage(err)));
|
|
13000
13010
|
}
|
|
13001
13011
|
}
|
|
13002
13012
|
return {
|
|
@@ -13012,17 +13022,17 @@ async function credentialsRows(input) {
|
|
|
13012
13022
|
async function checkProvider(impl, candidates, expected, synced) {
|
|
13013
13023
|
const provider = impl.providerName;
|
|
13014
13024
|
if (!impl.inspect) return {
|
|
13015
|
-
rows: [row$
|
|
13025
|
+
rows: [row$15(provider, "skip", "cannot list the variables without reading their values")],
|
|
13016
13026
|
places: []
|
|
13017
13027
|
};
|
|
13018
13028
|
if (expected.length === 0) return {
|
|
13019
|
-
rows: [row$
|
|
13029
|
+
rows: [row$15(provider, "skip", "no configured plugin lists the tokens it takes")],
|
|
13020
13030
|
places: []
|
|
13021
13031
|
};
|
|
13022
13032
|
const inspect = impl.inspect.bind(impl);
|
|
13023
13033
|
try {
|
|
13024
13034
|
const { found, missing } = await tryEnvironments(candidates, inspect);
|
|
13025
|
-
const rows = missing.map((name) => row$
|
|
13035
|
+
const rows = missing.map((name) => row$15(provider, "fail", `${provider} has no Environment named "${name}"`));
|
|
13026
13036
|
const group = providerGroup(provider);
|
|
13027
13037
|
const unreadPlaces = missing.map((name) => ({
|
|
13028
13038
|
column: {
|
|
@@ -13045,9 +13055,9 @@ async function checkProvider(impl, candidates, expected, synced) {
|
|
|
13045
13055
|
const have = (name) => found.some((f) => f.result.names.includes(name));
|
|
13046
13056
|
let present = 0;
|
|
13047
13057
|
for (const { name, optional } of expected) if (have(name)) present++;
|
|
13048
|
-
else if (optional) rows.push(row$
|
|
13049
|
-
else rows.push(row$
|
|
13050
|
-
if (present > 0) rows.push(row$
|
|
13058
|
+
else if (optional) rows.push(row$15(provider, "skip", `optional, not set in ${where}`, name));
|
|
13059
|
+
else rows.push(row$15(provider, "fail", `missing from ${where}`, name));
|
|
13060
|
+
if (present > 0) rows.push(row$15(provider, "ok", `${present} of ${expected.length} tokens present in ${where}`, "tokens"));
|
|
13051
13061
|
const names = new Set(expected.map((e) => e.name));
|
|
13052
13062
|
const places = [];
|
|
13053
13063
|
const missingRequired = expected.filter((e) => !e.optional && !have(e.name)).map((e) => e.name);
|
|
@@ -13086,7 +13096,7 @@ async function checkProvider(impl, candidates, expected, synced) {
|
|
|
13086
13096
|
};
|
|
13087
13097
|
} catch (err) {
|
|
13088
13098
|
return {
|
|
13089
|
-
rows: [row$
|
|
13099
|
+
rows: [row$15(provider, "fail", errorMessage(err))],
|
|
13090
13100
|
places: []
|
|
13091
13101
|
};
|
|
13092
13102
|
}
|
|
@@ -13960,7 +13970,7 @@ async function variableRows(loader, config, org) {
|
|
|
13960
13970
|
if (!loader.has("source")) {
|
|
13961
13971
|
const why = whyMissing(loader, "source", "no `source` provider to read them with");
|
|
13962
13972
|
for (const check of checks) {
|
|
13963
|
-
rows.push(row$
|
|
13973
|
+
rows.push(row$14(check, { skip: why }));
|
|
13964
13974
|
observations.push({
|
|
13965
13975
|
scope: check.scope,
|
|
13966
13976
|
unread: why
|
|
@@ -13970,7 +13980,7 @@ async function variableRows(loader, config, org) {
|
|
|
13970
13980
|
const source = loader.get("source");
|
|
13971
13981
|
for (const check of checks) try {
|
|
13972
13982
|
const result = await check.run(source);
|
|
13973
|
-
rows.push(row$
|
|
13983
|
+
rows.push(row$14(check, result));
|
|
13974
13984
|
observations.push("skip" in result ? {
|
|
13975
13985
|
scope: check.scope,
|
|
13976
13986
|
unread: result.skip
|
|
@@ -13981,7 +13991,7 @@ async function variableRows(loader, config, org) {
|
|
|
13981
13991
|
} catch (err) {
|
|
13982
13992
|
const noToken = missingTokenReason(err);
|
|
13983
13993
|
if (noToken !== void 0) {
|
|
13984
|
-
rows.push(row$
|
|
13994
|
+
rows.push(row$14(check, { skip: noToken }));
|
|
13985
13995
|
observations.push({
|
|
13986
13996
|
scope: check.scope,
|
|
13987
13997
|
unread: noToken
|
|
@@ -14007,7 +14017,7 @@ async function variableRows(loader, config, org) {
|
|
|
14007
14017
|
observations
|
|
14008
14018
|
};
|
|
14009
14019
|
}
|
|
14010
|
-
function row$
|
|
14020
|
+
function row$14(check, result) {
|
|
14011
14021
|
const { id, title } = check;
|
|
14012
14022
|
if ("skip" in result) return {
|
|
14013
14023
|
id,
|
|
@@ -14097,7 +14107,7 @@ function describeExpiry(expiresAt, now) {
|
|
|
14097
14107
|
*
|
|
14098
14108
|
* What a token may do is not checked: GitHub does not return a fine-grained token's permissions.
|
|
14099
14109
|
*/
|
|
14100
|
-
function row$
|
|
14110
|
+
function row$13(id, status, detail) {
|
|
14101
14111
|
return {
|
|
14102
14112
|
id: `verify:${id}`,
|
|
14103
14113
|
title: `verify ${id}`,
|
|
@@ -14125,12 +14135,12 @@ async function verifyRows(input) {
|
|
|
14125
14135
|
try {
|
|
14126
14136
|
module = await importer(pkg);
|
|
14127
14137
|
} catch (err) {
|
|
14128
|
-
rows.push(row$
|
|
14138
|
+
rows.push(row$13(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
|
|
14129
14139
|
continue;
|
|
14130
14140
|
}
|
|
14131
14141
|
for (const token of module.tokens ?? []) rows.push(await checkToken(token, module, env, readToken, now()));
|
|
14132
14142
|
}
|
|
14133
|
-
if (rows.length === 0) rows.push(row$
|
|
14143
|
+
if (rows.length === 0) rows.push(row$13("tokens", "skip", "no configured plugin lists the tokens it takes"));
|
|
14134
14144
|
return rows;
|
|
14135
14145
|
}
|
|
14136
14146
|
/**
|
|
@@ -14143,30 +14153,30 @@ async function loadCredentials(input) {
|
|
|
14143
14153
|
try {
|
|
14144
14154
|
await input.loader.load();
|
|
14145
14155
|
} catch (err) {
|
|
14146
|
-
return [row$
|
|
14156
|
+
return [row$13("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
|
|
14147
14157
|
}
|
|
14148
|
-
return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$
|
|
14158
|
+
return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$13(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
|
|
14149
14159
|
}
|
|
14150
14160
|
async function checkToken(token, module, env, readToken, now) {
|
|
14151
14161
|
const { keyringKey, envName, vendorEnvName } = token;
|
|
14152
14162
|
const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
|
|
14153
14163
|
const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
|
|
14154
14164
|
const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
|
|
14155
|
-
if (!value) return row$
|
|
14165
|
+
if (!value) return row$13(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
|
|
14156
14166
|
const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
|
|
14157
|
-
if (!verify) return row$
|
|
14167
|
+
if (!verify) return row$13(keyringKey, "skip", "set, but its plugin cannot verify it");
|
|
14158
14168
|
const from = fromEnv ?? stored?.source ?? "keyring";
|
|
14159
14169
|
try {
|
|
14160
14170
|
const verified = await verify(value);
|
|
14161
|
-
if (!verified.ok) return row$
|
|
14171
|
+
if (!verified.ok) return row$13(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
|
|
14162
14172
|
const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
|
|
14163
|
-
if (!expiry) return row$
|
|
14173
|
+
if (!expiry) return row$13(keyringKey, "ok", `${verified.subject} (${from})`);
|
|
14164
14174
|
return expiry.soon ? {
|
|
14165
|
-
...row$
|
|
14175
|
+
...row$13(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
|
|
14166
14176
|
problems: [`${expiry.text}: renew it`]
|
|
14167
|
-
} : row$
|
|
14177
|
+
} : row$13(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
|
|
14168
14178
|
} catch (err) {
|
|
14169
|
-
return row$
|
|
14179
|
+
return row$13(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
|
|
14170
14180
|
}
|
|
14171
14181
|
}
|
|
14172
14182
|
// src/commands/doctor-secrets/doctor-secrets.ts
|
|
@@ -14893,7 +14903,7 @@ function summariseProbeRows(id, title, rows) {
|
|
|
14893
14903
|
* provider with no `token` probe, no declared layer, or one that cannot be read is a skip with the reason.
|
|
14894
14904
|
*/
|
|
14895
14905
|
const PROBE = "token";
|
|
14896
|
-
const row$
|
|
14906
|
+
const row$12 = (id, title, status, detail, problems = []) => ({
|
|
14897
14907
|
id,
|
|
14898
14908
|
title,
|
|
14899
14909
|
status,
|
|
@@ -14918,12 +14928,12 @@ async function runDoctorTokens(input) {
|
|
|
14918
14928
|
try {
|
|
14919
14929
|
tokens = await providerTokens(provider);
|
|
14920
14930
|
} catch (err) {
|
|
14921
|
-
rows.push(row$
|
|
14931
|
+
rows.push(row$12(`tokens:${provider}`, provider, "skip", `could not read its tokens: ${describeError(err)}`));
|
|
14922
14932
|
continue;
|
|
14923
14933
|
}
|
|
14924
14934
|
const expectations = tokenExpectations(tokens);
|
|
14925
|
-
if (expectations.length === 0) rows.push(row$
|
|
14926
|
-
else if (!usableProbe(probes.get(provider))) rows.push(row$
|
|
14935
|
+
if (expectations.length === 0) rows.push(row$12(`tokens:${provider}`, provider, "skip", "info: declares no token layers, nothing to check"));
|
|
14936
|
+
else if (!usableProbe(probes.get(provider))) rows.push(row$12(`tokens:${provider}`, provider, "skip", `info: has no \`${PROBE}\` probe loaded, so its tokens are not checked`));
|
|
14927
14937
|
else declared.push({
|
|
14928
14938
|
provider,
|
|
14929
14939
|
tokens,
|
|
@@ -14985,14 +14995,14 @@ async function checkLayer(c) {
|
|
|
14985
14995
|
tokens
|
|
14986
14996
|
});
|
|
14987
14997
|
} catch (err) {
|
|
14988
|
-
if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$
|
|
14989
|
-
return c.wanted.map((e) => row$
|
|
14998
|
+
if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$12(id(e), title(e), "fail", "not held in this layer", [err.message]));
|
|
14999
|
+
return c.wanted.map((e) => row$12(id(e), title(e), "skip", `could not read the Environment: ${describeError(err)}`));
|
|
14990
15000
|
}
|
|
14991
15001
|
const rows = [];
|
|
14992
15002
|
for (const e of c.wanted) {
|
|
14993
15003
|
const token = held.held.find((h) => h.envName === e.envName);
|
|
14994
15004
|
if (!token) {
|
|
14995
|
-
rows.push(row$
|
|
15005
|
+
rows.push(row$12(id(e), title(e), "fail", `not held in ${held.environment}`, [`${e.envName} is declared for ${c.layer}`]));
|
|
14996
15006
|
continue;
|
|
14997
15007
|
}
|
|
14998
15008
|
rows.push(summariseProbeRows(id(e), title(e), await probeToken(c, e, token.token, held.plain)));
|
|
@@ -15065,7 +15075,7 @@ const doctorTokensCommand = {
|
|
|
15065
15075
|
}
|
|
15066
15076
|
};
|
|
15067
15077
|
// src/commands/doctor-wiki/wiki-rows.ts
|
|
15068
|
-
const row$
|
|
15078
|
+
const row$11 = (id, title, status, detail, problems = []) => ({
|
|
15069
15079
|
id,
|
|
15070
15080
|
title,
|
|
15071
15081
|
status,
|
|
@@ -15081,11 +15091,11 @@ const names = (paths) => paths.length > LISTED ? `${paths.slice(0, LISTED).join(
|
|
|
15081
15091
|
* skip, since a machine with no network says nothing about the site.
|
|
15082
15092
|
*/
|
|
15083
15093
|
function siteRow(id, title, probe, notFoundHint) {
|
|
15084
|
-
if (probe.status === void 0) return row$
|
|
15085
|
-
if (probe.status < 400) return row$
|
|
15086
|
-
if (probe.status === 401 || probe.status === 403) return row$
|
|
15094
|
+
if (probe.status === void 0) return row$11(id, title, "skip", `${probe.url}: ${probe.error ?? "no answer"}`);
|
|
15095
|
+
if (probe.status < 400) return row$11(id, title, "ok", `${probe.url} answers ${probe.status}`);
|
|
15096
|
+
if (probe.status === 401 || probe.status === 403) return row$11(id, title, "ok", `${probe.url} answers ${probe.status} (access is restricted)`);
|
|
15087
15097
|
const problem = probe.status === 404 ? `${probe.url} answers 404; ${notFoundHint}` : `${probe.url} answers ${probe.status}, expected a page`;
|
|
15088
|
-
return row$
|
|
15098
|
+
return row$11(id, title, "fail", `${probe.url} answers ${probe.status}`, [problem]);
|
|
15089
15099
|
}
|
|
15090
15100
|
/**
|
|
15091
15101
|
* The rows `holocron doctor wiki` prints for one {@link WikiInspection}: organization, docs instance, the site and its
|
|
@@ -15097,42 +15107,42 @@ function wikiRows(found, providerName) {
|
|
|
15097
15107
|
const { declared, found: foundOrg } = found.organization;
|
|
15098
15108
|
if (foundOrg === null) {
|
|
15099
15109
|
const problem = `fern/fern.config.json has no organization; \`holocron setup\` writes it`;
|
|
15100
|
-
rows.push(row$
|
|
15110
|
+
rows.push(row$11("wiki:organization", "organization is set", "fail", problem, [problem]));
|
|
15101
15111
|
} else if (foundOrg !== declared) {
|
|
15102
15112
|
const problem = `fern/fern.config.json names ${foundOrg}, the config declares ${declared}; run \`holocron setup\``;
|
|
15103
|
-
rows.push(row$
|
|
15104
|
-
} else rows.push(row$
|
|
15113
|
+
rows.push(row$11("wiki:organization", "organization is set", "fail", `${foundOrg}, declared ${declared}`, [problem]));
|
|
15114
|
+
} else rows.push(row$11("wiki:organization", "organization is set", "ok", `${declared} in fern/fern.config.json`));
|
|
15105
15115
|
const instance = found.instance;
|
|
15106
15116
|
if (instance === null) {
|
|
15107
15117
|
const problem = "fern/docs.yml does not exist; `holocron setup` writes it";
|
|
15108
|
-
rows.push(row$
|
|
15118
|
+
rows.push(row$11("wiki:instance", "docs site is declared", "fail", problem, [problem]));
|
|
15109
15119
|
} else {
|
|
15110
15120
|
const problems = [];
|
|
15111
15121
|
if (instance.foundUrl !== instance.expectedUrl) problems.push(`instance url is ${instance.foundUrl ?? "not set"}, expected ${instance.expectedUrl}`);
|
|
15112
15122
|
if (instance.expectedDomain !== void 0 && instance.foundDomain !== instance.expectedDomain) problems.push(`custom-domain is ${instance.foundDomain ?? "not set"}, expected ${instance.expectedDomain}`);
|
|
15113
|
-
rows.push(problems.length > 0 ? row$
|
|
15123
|
+
rows.push(problems.length > 0 ? row$11("wiki:instance", "docs site is declared", "fail", `${problems.length} problem(s)`, [...problems.map((p) => `fern/docs.yml: ${p}`)]) : row$11("wiki:instance", "docs site is declared", "ok", `${instance.expectedUrl} in fern/docs.yml`));
|
|
15114
15124
|
}
|
|
15115
15125
|
const [site, domain] = found.site;
|
|
15116
15126
|
if (site) rows.push(siteRow("wiki:site", "docs site answers", site, `the organization or its docs are not published; run the wiki workflow (\`fern generate --docs\`)`));
|
|
15117
15127
|
if (domain) rows.push(siteRow("wiki:domain", "custom domain answers", domain, `check the ${providerName} dashboard for the domain and \`holocron doctor dns\` for its record`));
|
|
15118
|
-
if (found.navigation === null) rows.push(row$
|
|
15128
|
+
if (found.navigation === null) rows.push(row$11("wiki:navigation", "navigation pages exist", "skip", "no fern/docs.yml to read"));
|
|
15119
15129
|
else if (found.navigation.missing.length > 0) {
|
|
15120
15130
|
const problems = found.navigation.missing.map((p) => `${p} is listed in fern/docs.yml but is not on disk`);
|
|
15121
|
-
rows.push(row$
|
|
15131
|
+
rows.push(row$11("wiki:navigation", "navigation pages exist", "fail", `${found.navigation.missing.length} missing`, problems));
|
|
15122
15132
|
} else {
|
|
15123
|
-
rows.push(row$
|
|
15124
|
-
if (found.navigation.unlisted.length > 0) rows.push(row$
|
|
15133
|
+
rows.push(row$11("wiki:navigation", "navigation pages exist", "ok", `${found.navigation.listed} listed pages exist`));
|
|
15134
|
+
if (found.navigation.unlisted.length > 0) rows.push(row$11("wiki:unlisted", "pages under docs/wiki are listed", "skip", `info: ${found.navigation.unlisted.length} not in the navigation (${names(found.navigation.unlisted)}); they are not published`));
|
|
15125
15135
|
}
|
|
15126
15136
|
const published = found.published;
|
|
15127
15137
|
const listed = found.navigation?.listed;
|
|
15128
|
-
if (!published) rows.push(row$
|
|
15138
|
+
if (!published) rows.push(row$11("wiki:published", "published pages", "skip", "the site's page index could not be asked"));
|
|
15129
15139
|
else if (published.pages === void 0) {
|
|
15130
15140
|
const why = published.status === void 0 ? published.error ?? "no answer" : `answered ${published.status}`;
|
|
15131
|
-
rows.push(row$
|
|
15141
|
+
rows.push(row$11("wiki:published", "published pages", "skip", `${published.url}: ${why}`));
|
|
15132
15142
|
} else if (listed !== void 0 && published.pages < listed) {
|
|
15133
15143
|
const problem = `${published.url} lists ${published.pages} page(s), the navigation lists ${listed}; the last publish is behind (run the wiki workflow)`;
|
|
15134
|
-
rows.push(row$
|
|
15135
|
-
} else rows.push(row$
|
|
15144
|
+
rows.push(row$11("wiki:published", "published pages", "fail", `${published.pages} of ${listed}`, [problem]));
|
|
15145
|
+
} else rows.push(row$11("wiki:published", "published pages", "ok", listed === void 0 ? `${published.pages} page(s) in ${published.url}` : `${published.pages} page(s) published for ${listed} listed`));
|
|
15136
15146
|
return rows;
|
|
15137
15147
|
}
|
|
15138
15148
|
// src/commands/doctor-wiki/doctor-wiki.ts
|
|
@@ -15186,6 +15196,295 @@ async function runDoctorWiki(input) {
|
|
|
15186
15196
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
15187
15197
|
};
|
|
15188
15198
|
}
|
|
15199
|
+
// src/commands/doctor-wiki/doctor-wiki.command.ts
|
|
15200
|
+
const doctorWikiCommand = {
|
|
15201
|
+
command: "wiki",
|
|
15202
|
+
describe: "Check the wiki's organization, docs site, domain and published pages (read-only)",
|
|
15203
|
+
handler: async (argv) => {
|
|
15204
|
+
const tokens = tokenContext(argv.token);
|
|
15205
|
+
if (!tokens) return;
|
|
15206
|
+
const loaded = await loadConfig(argv.cwd);
|
|
15207
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
15208
|
+
if ((await runDoctorWiki({
|
|
15209
|
+
loaded,
|
|
15210
|
+
context: {
|
|
15211
|
+
repoRoot: argv.cwd,
|
|
15212
|
+
...tokens,
|
|
15213
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
15214
|
+
}
|
|
15215
|
+
})).status === "fail") process.exitCode = 1;
|
|
15216
|
+
}
|
|
15217
|
+
};
|
|
15218
|
+
// src/commands/doctor-workers/read-failure.ts
|
|
15219
|
+
/**
|
|
15220
|
+
* The row for a read that threw: a skip when the token is missing or the provider refused it (401, 403: the token may
|
|
15221
|
+
* simply not reach this), a failure for anything else. The status is read off the error rather than with `instanceof`,
|
|
15222
|
+
* because the CLI and a plugin may each hold their own copy of the error class.
|
|
15223
|
+
*/
|
|
15224
|
+
function readFailureRow(id, title, err) {
|
|
15225
|
+
const noToken = missingTokenReason(err);
|
|
15226
|
+
if (noToken !== void 0) return {
|
|
15227
|
+
id,
|
|
15228
|
+
title,
|
|
15229
|
+
status: "skip",
|
|
15230
|
+
detail: noToken,
|
|
15231
|
+
problems: []
|
|
15232
|
+
};
|
|
15233
|
+
const status = err?.status;
|
|
15234
|
+
if (status === 401 || status === 403) return {
|
|
15235
|
+
id,
|
|
15236
|
+
title,
|
|
15237
|
+
status: "skip",
|
|
15238
|
+
detail: `not readable with this token (${status})`,
|
|
15239
|
+
problems: []
|
|
15240
|
+
};
|
|
15241
|
+
const detail = describeError(err);
|
|
15242
|
+
return {
|
|
15243
|
+
id,
|
|
15244
|
+
title,
|
|
15245
|
+
status: "fail",
|
|
15246
|
+
detail,
|
|
15247
|
+
problems: [detail]
|
|
15248
|
+
};
|
|
15249
|
+
}
|
|
15250
|
+
// src/commands/doctor-workers/check-project.ts
|
|
15251
|
+
const row$10 = (id, title, status, detail, problems = []) => ({
|
|
15252
|
+
id,
|
|
15253
|
+
title,
|
|
15254
|
+
status,
|
|
15255
|
+
detail,
|
|
15256
|
+
problems
|
|
15257
|
+
});
|
|
15258
|
+
const same$1 = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
15259
|
+
/**
|
|
15260
|
+
* The rows for one declared deployment project: it exists, its custom domain (when one is declared) is attached, and
|
|
15261
|
+
* the newest production deployment is healthy. A step the provider cannot do, or a token that cannot read it, is a
|
|
15262
|
+
* skip; a project that is not there fails and the steps that need it are skipped.
|
|
15263
|
+
*/
|
|
15264
|
+
async function checkProject(deploy, declared) {
|
|
15265
|
+
const project = declared.project;
|
|
15266
|
+
const ids = {
|
|
15267
|
+
exists: `deployment:${project}:exists`,
|
|
15268
|
+
domain: `deployment:${project}:domain`,
|
|
15269
|
+
deploy: `deployment:${project}:deployment`
|
|
15270
|
+
};
|
|
15271
|
+
const titles = {
|
|
15272
|
+
exists: `${project} project exists`,
|
|
15273
|
+
domain: `${project} has its custom domain`,
|
|
15274
|
+
deploy: `${project} latest deployment is healthy`
|
|
15275
|
+
};
|
|
15276
|
+
const rows = [];
|
|
15277
|
+
let exists = false;
|
|
15278
|
+
try {
|
|
15279
|
+
exists = (await deploy.listProjects()).some((p) => same$1(p.name, project) || p.id === project);
|
|
15280
|
+
rows.push(exists ? row$10(ids.exists, titles.exists, "ok", `${project} on ${deploy.providerName}`) : row$10(ids.exists, titles.exists, "fail", "not found", [`no project ${project} on ${deploy.providerName}; \`holocron setup\` makes it`]));
|
|
15281
|
+
} catch (err) {
|
|
15282
|
+
rows.push(readFailureRow(ids.exists, titles.exists, err));
|
|
15283
|
+
}
|
|
15284
|
+
const notChecked = (reason) => `not checked: ${reason}`;
|
|
15285
|
+
const gone = exists ? void 0 : "the project is not readable or not there";
|
|
15286
|
+
if (declared.hostname === void 0) {} else if (gone) rows.push(row$10(ids.domain, titles.domain, "skip", notChecked(gone)));
|
|
15287
|
+
else if (!deploy.listDomains) rows.push(row$10(ids.domain, titles.domain, "skip", `the \`${deploy.providerName}\` provider cannot list domains`));
|
|
15288
|
+
else try {
|
|
15289
|
+
const attached = await deploy.listDomains(project);
|
|
15290
|
+
rows.push(attached.some((d) => same$1(d, declared.hostname)) ? row$10(ids.domain, titles.domain, "ok", `${declared.hostname} attached`) : row$10(ids.domain, titles.domain, "fail", `${declared.hostname} not attached`, [`${declared.hostname} is not a domain of ${project}; \`holocron setup\` attaches it`]));
|
|
15291
|
+
} catch (err) {
|
|
15292
|
+
rows.push(readFailureRow(ids.domain, titles.domain, err));
|
|
15293
|
+
}
|
|
15294
|
+
if (gone) rows.push(row$10(ids.deploy, titles.deploy, "skip", notChecked(gone)));
|
|
15295
|
+
else if (!deploy.latestDeployment) rows.push(row$10(ids.deploy, titles.deploy, "skip", `the \`${deploy.providerName}\` provider cannot list deployments`));
|
|
15296
|
+
else try {
|
|
15297
|
+
const latest = await deploy.latestDeployment(project);
|
|
15298
|
+
if (!latest) rows.push(row$10(ids.deploy, titles.deploy, "skip", "no production deployment yet"));
|
|
15299
|
+
else if (latest.status === "ready") rows.push(row$10(ids.deploy, titles.deploy, "ok", latest.createdAt ? `ready, ${latest.createdAt}` : "ready"));
|
|
15300
|
+
else if (latest.status === "error") {
|
|
15301
|
+
const why = latest.errorMessage ? `: ${latest.errorMessage}` : "";
|
|
15302
|
+
rows.push(row$10(ids.deploy, titles.deploy, "fail", "the newest deployment errored", [`the newest production deployment of ${project} failed${why}`]));
|
|
15303
|
+
} else rows.push(row$10(ids.deploy, titles.deploy, "skip", `info: the newest deployment is ${latest.status}`));
|
|
15304
|
+
} catch (err) {
|
|
15305
|
+
rows.push(readFailureRow(ids.deploy, titles.deploy, err));
|
|
15306
|
+
}
|
|
15307
|
+
return rows;
|
|
15308
|
+
}
|
|
15309
|
+
// src/commands/doctor-workers/check-worker.ts
|
|
15310
|
+
const same = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
15311
|
+
const row$9 = (id, title, status, detail, problems = []) => ({
|
|
15312
|
+
id,
|
|
15313
|
+
title,
|
|
15314
|
+
status,
|
|
15315
|
+
detail,
|
|
15316
|
+
problems
|
|
15317
|
+
});
|
|
15318
|
+
/**
|
|
15319
|
+
* The rows for one declared Worker: its script is deployed and has the route for its host, it has the bindings it
|
|
15320
|
+
* needs (names only, a value is never read), and its newest deployment serves all traffic. A step the provider cannot
|
|
15321
|
+
* do is a skip, and a later step is skipped when the script is not there to read.
|
|
15322
|
+
*/
|
|
15323
|
+
async function checkWorker(workers, worker) {
|
|
15324
|
+
const name = worker.label;
|
|
15325
|
+
const ids = {
|
|
15326
|
+
deployed: `workers:${name}:deployed`,
|
|
15327
|
+
bindings: `workers:${name}:bindings`,
|
|
15328
|
+
deploy: `workers:${name}:deployment`
|
|
15329
|
+
};
|
|
15330
|
+
const titles = {
|
|
15331
|
+
deployed: `${name} Worker is deployed and routed`,
|
|
15332
|
+
bindings: `${name} Worker has its bindings`,
|
|
15333
|
+
deploy: `${name} Worker's latest deployment is healthy`
|
|
15334
|
+
};
|
|
15335
|
+
const skipAll = (reason) => [
|
|
15336
|
+
row$9(ids.deployed, titles.deployed, "skip", reason),
|
|
15337
|
+
row$9(ids.bindings, titles.bindings, "skip", reason),
|
|
15338
|
+
row$9(ids.deploy, titles.deploy, "skip", reason)
|
|
15339
|
+
];
|
|
15340
|
+
if (worker.script === void 0) return skipAll(`${workers.providerName} does not say how it names this Worker`);
|
|
15341
|
+
const script = worker.script;
|
|
15342
|
+
if (!workers.inspectScript) return skipAll(`the \`${workers.providerName}\` provider cannot read its Workers`);
|
|
15343
|
+
const rows = [];
|
|
15344
|
+
const route = `${worker.host}/*`;
|
|
15345
|
+
let exists = false;
|
|
15346
|
+
try {
|
|
15347
|
+
const state = await workers.inspectScript(script, worker.host);
|
|
15348
|
+
exists = state.exists;
|
|
15349
|
+
if (!state.exists) {
|
|
15350
|
+
const problem = `no Worker named ${script}; \`holocron setup\` deploys it`;
|
|
15351
|
+
rows.push(row$9(ids.deployed, titles.deployed, "fail", `${script} not deployed`, [problem]), row$9(ids.bindings, titles.bindings, "skip", `not checked: no Worker named ${script}`));
|
|
15352
|
+
} else {
|
|
15353
|
+
rows.push(state.routes.some((r) => same(r, route)) ? row$9(ids.deployed, titles.deployed, "ok", `${script} serves ${route}`) : row$9(ids.deployed, titles.deployed, "fail", `no route ${route}`, [`${script} has no route ${route}`]));
|
|
15354
|
+
if (worker.bindings.length === 0) rows.push(row$9(ids.bindings, titles.bindings, "ok", "none declared"));
|
|
15355
|
+
else {
|
|
15356
|
+
const bound = new Set(state.bindingNames.map((n) => n.toUpperCase()));
|
|
15357
|
+
const missing = worker.bindings.filter((n) => !bound.has(n.toUpperCase()));
|
|
15358
|
+
rows.push(missing.length === 0 ? row$9(ids.bindings, titles.bindings, "ok", `${worker.bindings.length} of ${worker.bindings.length} bound`) : row$9(ids.bindings, titles.bindings, "fail", `${missing.length} not bound`, missing.map((n) => `${n}: not bound`)));
|
|
15359
|
+
}
|
|
15360
|
+
}
|
|
15361
|
+
} catch (err) {
|
|
15362
|
+
const failure = readFailureRow(ids.deployed, titles.deployed, err);
|
|
15363
|
+
rows.push(failure, row$9(ids.bindings, titles.bindings, "skip", "not checked: could not read the Worker"));
|
|
15364
|
+
}
|
|
15365
|
+
if (!exists) rows.push(row$9(ids.deploy, titles.deploy, "skip", "not checked: the Worker is not readable or not there"));
|
|
15366
|
+
else if (!workers.latestDeployment) rows.push(row$9(ids.deploy, titles.deploy, "skip", `the \`${workers.providerName}\` provider cannot list deployments`));
|
|
15367
|
+
else try {
|
|
15368
|
+
const latest = await workers.latestDeployment(script);
|
|
15369
|
+
if (!latest) rows.push(row$9(ids.deploy, titles.deploy, "skip", `${script} has no recorded deployment`));
|
|
15370
|
+
else if (!latest.active) {
|
|
15371
|
+
const problem = `the newest deployment of ${script} does not serve all traffic`;
|
|
15372
|
+
rows.push(row$9(ids.deploy, titles.deploy, "fail", "not serving all traffic", [problem]));
|
|
15373
|
+
} else rows.push(row$9(ids.deploy, titles.deploy, "ok", latest.createdAt ? `deployed ${latest.createdAt}` : "serving all traffic"));
|
|
15374
|
+
} catch (err) {
|
|
15375
|
+
rows.push(readFailureRow(ids.deploy, titles.deploy, err));
|
|
15376
|
+
}
|
|
15377
|
+
return rows;
|
|
15378
|
+
}
|
|
15379
|
+
// src/commands/doctor-workers/declared-projects.ts
|
|
15380
|
+
/**
|
|
15381
|
+
* The deployment projects `holocron setup` makes: the preview project (and its domain) when the config carries a
|
|
15382
|
+
* preview configuration, otherwise one named like the repo, with the provider's own `domain` when it has one.
|
|
15383
|
+
*/
|
|
15384
|
+
function declaredProjects(config, deploy) {
|
|
15385
|
+
const preview = previewConfigOf(config);
|
|
15386
|
+
if (preview) return [{
|
|
15387
|
+
project: preview.project,
|
|
15388
|
+
...preview.domain ? { hostname: preview.domain } : {}
|
|
15389
|
+
}];
|
|
15390
|
+
return [{
|
|
15391
|
+
project: config.name,
|
|
15392
|
+
...deploy.domain ? { hostname: deploy.domain } : {}
|
|
15393
|
+
}];
|
|
15394
|
+
}
|
|
15395
|
+
// src/commands/doctor-workers/declared-workers.ts
|
|
15396
|
+
/**
|
|
15397
|
+
* The Workers the config makes `holocron setup` deploy: the relay Worker of each notifications layout that feeds an
|
|
15398
|
+
* error tracker (`relay.host`, its `script` or the default name, and the two bindings the relay reads for the tracker,
|
|
15399
|
+
* when one is configured), and the reverse proxy of a wiki that has a custom domain behind one. A proxy Worker whose
|
|
15400
|
+
* provider does not say how it names it has `script: undefined`, which the check reports as a skip.
|
|
15401
|
+
*/
|
|
15402
|
+
function declaredWorkers(input) {
|
|
15403
|
+
const declared = [];
|
|
15404
|
+
for (const layout of input.layouts) {
|
|
15405
|
+
const relay = layout.relay;
|
|
15406
|
+
if (!relay?.host || !wantsRelay(layout)) continue;
|
|
15407
|
+
declared.push({
|
|
15408
|
+
label: "relay",
|
|
15409
|
+
script: relay.script ?? "comlink",
|
|
15410
|
+
host: relay.host,
|
|
15411
|
+
bindings: input.errors ? [relayWebhookBinding(input.errors.providerName), relaySecretBinding(input.errors.providerName)] : []
|
|
15412
|
+
});
|
|
15413
|
+
}
|
|
15414
|
+
const proxied = input.wiki?.proxyConfig?.() ? input.wiki.dnsRecord?.() : null;
|
|
15415
|
+
if (proxied) {
|
|
15416
|
+
const host = proxied.record.name;
|
|
15417
|
+
declared.push({
|
|
15418
|
+
label: "wiki proxy",
|
|
15419
|
+
script: input.workers?.proxyScriptName?.(host),
|
|
15420
|
+
host,
|
|
15421
|
+
bindings: []
|
|
15422
|
+
});
|
|
15423
|
+
}
|
|
15424
|
+
return declared;
|
|
15425
|
+
}
|
|
15426
|
+
// src/commands/doctor-workers/doctor-workers.ts
|
|
15427
|
+
/**
|
|
15428
|
+
* `holocron doctor workers` — do the Workers and deployment projects the config declares exist, route and deploy?
|
|
15429
|
+
*
|
|
15430
|
+
* Read-only: it never deploys, routes or binds anything, and prints names, hostnames and times only, never a secret
|
|
15431
|
+
* value or a token. For each declared Worker (the relay Worker of a notifications layout, a wiki's reverse proxy):
|
|
15432
|
+
* the script is deployed with its route, has the bindings it needs (by name), and its newest deployment serves all
|
|
15433
|
+
* traffic. For each deployment project `setup` makes (the preview project, or one named like the repo): it exists, its
|
|
15434
|
+
* custom domain is attached, and the newest production deployment is ready. Only what the provider proves wrong
|
|
15435
|
+
* fails; a missing token, a 401 or 403, or a provider that cannot read it is a skip with the reason.
|
|
15436
|
+
*/
|
|
15437
|
+
const row$8 = (id, title, status, detail) => ({
|
|
15438
|
+
id,
|
|
15439
|
+
title,
|
|
15440
|
+
status,
|
|
15441
|
+
detail,
|
|
15442
|
+
problems: []
|
|
15443
|
+
});
|
|
15444
|
+
/** Why a capability is not there: the plugin failed to load, or none is configured. */
|
|
15445
|
+
function whyNone(loader, key, fallback) {
|
|
15446
|
+
const failure = loader.loadFailures().find((f) => f.key === key);
|
|
15447
|
+
return failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : fallback;
|
|
15448
|
+
}
|
|
15449
|
+
async function runDoctorWorkers(input) {
|
|
15450
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
15451
|
+
const logger = input.logger ?? getLogger();
|
|
15452
|
+
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
15453
|
+
await loader.load();
|
|
15454
|
+
assertPluginsResolvable(loader, "doctor workers");
|
|
15455
|
+
const rows = [];
|
|
15456
|
+
const workers = loader.has("workers") ? loader.get("workers") : void 0;
|
|
15457
|
+
const declared = declaredWorkers({
|
|
15458
|
+
layouts: (loader.has("notifications") ? loader.get("notifications") : []).flatMap((p) => p.layout ? [p.layout] : []),
|
|
15459
|
+
...loader.has("errors") ? { errors: loader.get("errors") } : {},
|
|
15460
|
+
...loader.has("wiki") ? { wiki: loader.get("wiki") } : {},
|
|
15461
|
+
...workers ? { workers } : {}
|
|
15462
|
+
});
|
|
15463
|
+
if (declared.length === 0) rows.push(row$8("workers", "declared Workers", "ok", "none declared"));
|
|
15464
|
+
else if (!workers) {
|
|
15465
|
+
const why = whyNone(loader, "workers", "no `workers` provider is configured in holocron.config.ts");
|
|
15466
|
+
for (const worker of declared) rows.push(row$8(`workers:${worker.label}`, `${worker.label} Worker`, "skip", why));
|
|
15467
|
+
} else for (const worker of declared) rows.push(...await checkWorker(workers, worker));
|
|
15468
|
+
if (!loader.has("deployment")) rows.push(row$8("deployment", "deployment project", "skip", whyNone(loader, "deployment", "no `deployment` provider is configured in holocron.config.ts")));
|
|
15469
|
+
else {
|
|
15470
|
+
const deploy = loader.get("deployment");
|
|
15471
|
+
for (const project of declaredProjects(input.loaded.resolved, deploy)) rows.push(...await checkProject(deploy, project));
|
|
15472
|
+
}
|
|
15473
|
+
printCheckRows(rows, print);
|
|
15474
|
+
const summary = summariseChecks(rows);
|
|
15475
|
+
printCheckSummary(summary, print);
|
|
15476
|
+
const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
|
|
15477
|
+
logger.info({
|
|
15478
|
+
...summary,
|
|
15479
|
+
status
|
|
15480
|
+
}, "doctor workers");
|
|
15481
|
+
return {
|
|
15482
|
+
status,
|
|
15483
|
+
rows,
|
|
15484
|
+
summary,
|
|
15485
|
+
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
15486
|
+
};
|
|
15487
|
+
}
|
|
15189
15488
|
// src/commands/deep-checks/deep-checks.ts
|
|
15190
15489
|
/**
|
|
15191
15490
|
* Every `doctor <capability>` deep check, in the order `doctor --all` runs them. Adding one is an entry here
|
|
@@ -15365,15 +15664,41 @@ const DEEP_CHECKS = [
|
|
|
15365
15664
|
{
|
|
15366
15665
|
name: "wiki",
|
|
15367
15666
|
capability: "wiki",
|
|
15667
|
+
command: doctorWikiCommand,
|
|
15668
|
+
async run(input) {
|
|
15669
|
+
const report = await runDoctorWiki(input);
|
|
15670
|
+
return {
|
|
15671
|
+
status: report.status,
|
|
15672
|
+
summary: report.summary,
|
|
15673
|
+
...report.reason ? { reason: report.reason } : {}
|
|
15674
|
+
};
|
|
15675
|
+
}
|
|
15676
|
+
},
|
|
15677
|
+
{
|
|
15678
|
+
name: "errors",
|
|
15679
|
+
capability: "errors",
|
|
15680
|
+
command: doctorErrorsCommand,
|
|
15681
|
+
async run(input) {
|
|
15682
|
+
const report = await runDoctorErrors(input);
|
|
15683
|
+
return {
|
|
15684
|
+
status: report.status,
|
|
15685
|
+
summary: report.summary,
|
|
15686
|
+
...report.reason ? { reason: report.reason } : {}
|
|
15687
|
+
};
|
|
15688
|
+
}
|
|
15689
|
+
},
|
|
15690
|
+
{
|
|
15691
|
+
name: "workers",
|
|
15692
|
+
capability: "workers",
|
|
15368
15693
|
command: {
|
|
15369
|
-
command: "
|
|
15370
|
-
describe: "Check the
|
|
15694
|
+
command: "workers",
|
|
15695
|
+
describe: "Check the declared Workers and deployment projects: they exist, route and deploy healthily (read-only)",
|
|
15371
15696
|
handler: async (argv) => {
|
|
15372
15697
|
const tokens = tokenContext(argv.token);
|
|
15373
15698
|
if (!tokens) return;
|
|
15374
15699
|
const loaded = await loadConfig(argv.cwd);
|
|
15375
15700
|
applyResolvedConfig(argv, loaded.resolved);
|
|
15376
|
-
if ((await
|
|
15701
|
+
if ((await runDoctorWorkers({
|
|
15377
15702
|
loaded,
|
|
15378
15703
|
context: {
|
|
15379
15704
|
repoRoot: argv.cwd,
|
|
@@ -15384,20 +15709,7 @@ const DEEP_CHECKS = [
|
|
|
15384
15709
|
}
|
|
15385
15710
|
},
|
|
15386
15711
|
async run(input) {
|
|
15387
|
-
const report = await
|
|
15388
|
-
return {
|
|
15389
|
-
status: report.status,
|
|
15390
|
-
summary: report.summary,
|
|
15391
|
-
...report.reason ? { reason: report.reason } : {}
|
|
15392
|
-
};
|
|
15393
|
-
}
|
|
15394
|
-
},
|
|
15395
|
-
{
|
|
15396
|
-
name: "errors",
|
|
15397
|
-
capability: "errors",
|
|
15398
|
-
command: doctorErrorsCommand,
|
|
15399
|
-
async run(input) {
|
|
15400
|
-
const report = await runDoctorErrors(input);
|
|
15712
|
+
const report = await runDoctorWorkers(input);
|
|
15401
15713
|
return {
|
|
15402
15714
|
status: report.status,
|
|
15403
15715
|
summary: report.summary,
|
|
@@ -23017,6 +23329,35 @@ const newCommand = {
|
|
|
23017
23329
|
builder: (y) => y.command(newRepoCommand).command(pluginCreateCommand).command(notificationsChannelAddCommand).command(githubAppCreateCommand).command(projectCreateCommand).command(secretSetCommand).command(notificationsCreateServerCommand).command(ideasPromoteCommand).command(issueCreateCommand).command(authSetCommand).command(tunnelUpCommand).command(newDomainCommand).command(groupMenu("new")),
|
|
23018
23330
|
handler: () => {}
|
|
23019
23331
|
};
|
|
23332
|
+
// src/commands/open-requests/parse-open-layers/parse-open-layers.ts
|
|
23333
|
+
/**
|
|
23334
|
+
* The layers `open requests` can fill, in the order they are listed. `ci` and `test` are left out on purpose: the request
|
|
23335
|
+
* tool is a person at a machine, and neither layer is one it signs requests for.
|
|
23336
|
+
*/
|
|
23337
|
+
const OPEN_LAYERS = [
|
|
23338
|
+
"local",
|
|
23339
|
+
"dev",
|
|
23340
|
+
"prod"
|
|
23341
|
+
];
|
|
23342
|
+
/**
|
|
23343
|
+
* Turns the `--environment` values into the layers to load. Each value may itself be a comma-separated list, so
|
|
23344
|
+
* `--environment dev,local` and `--environment dev --environment local` mean the same. Duplicates are collapsed, spaces
|
|
23345
|
+
* around a name are ignored, and the result is in {@link OPEN_LAYERS} order whatever order was typed. With no value the
|
|
23346
|
+
* result is `dev` alone.
|
|
23347
|
+
*
|
|
23348
|
+
* @param values - The raw `--environment` values, or `undefined` when the flag was not given.
|
|
23349
|
+
* @throws {ConfigError} For a name that is not one of {@link OPEN_LAYERS}, or an empty one; the message lists the allowed ones.
|
|
23350
|
+
*/
|
|
23351
|
+
function parseOpenLayers(values) {
|
|
23352
|
+
if (!values || values.length === 0) return ["dev"];
|
|
23353
|
+
const names = values.flatMap((value) => value.split(",").map((name) => name.trim()));
|
|
23354
|
+
const unknown = [...new Set(names.filter((name) => !OPEN_LAYERS.includes(name)))];
|
|
23355
|
+
if (unknown.length > 0) {
|
|
23356
|
+
const shown = unknown.map((name) => name === "" ? "(empty)" : JSON.stringify(name)).join(", ");
|
|
23357
|
+
throw new ConfigError$1(`--environment does not know ${shown}: use ${OPEN_LAYERS.join(", ")}, comma-separated or repeated`);
|
|
23358
|
+
}
|
|
23359
|
+
return OPEN_LAYERS.filter((layer) => names.includes(layer));
|
|
23360
|
+
}
|
|
23020
23361
|
// src/commands/open-requests/read-entry-values/read-entry-values.ts
|
|
23021
23362
|
/**
|
|
23022
23363
|
* The values of the named entries of one vault Environment, read in memory. Only an Environment this repo uses is read:
|
|
@@ -23191,7 +23532,7 @@ async function runOpenRequests(input) {
|
|
|
23191
23532
|
...input.deps
|
|
23192
23533
|
};
|
|
23193
23534
|
const dryRun = Boolean(input.context.dryRun);
|
|
23194
|
-
const
|
|
23535
|
+
const layers = parseOpenLayers(input.environments);
|
|
23195
23536
|
const { repoRoot } = input.context;
|
|
23196
23537
|
const rows = [];
|
|
23197
23538
|
const say = (next) => {
|
|
@@ -23239,10 +23580,13 @@ async function runOpenRequests(input) {
|
|
|
23239
23580
|
say(row$4(tool.providerName, "fail", describeError(err)));
|
|
23240
23581
|
return finish();
|
|
23241
23582
|
}
|
|
23242
|
-
const
|
|
23583
|
+
const loaded = plan.wants.filter((want) => layers.includes(want.layer));
|
|
23584
|
+
const notLoaded = plan.wants.filter((want) => !layers.includes(want.layer));
|
|
23585
|
+
const names = [...new Set(loaded.map((want) => want.name))].sort();
|
|
23243
23586
|
if (plan.unfilled.length > 0) say(row$4("unfilled", "skip", `${plan.unfilled.length} secret variable(s) refer to no entry, so nobody fills them`, plan.unfilled));
|
|
23587
|
+
say(row$4("layers", notLoaded.length > 0 ? "skip" : "ok", `loaded: ${layers.join(", ")}; not loaded: ${OPEN_LAYERS.filter((layer) => !layers.includes(layer)).join(", ") || "none"}`, notLoaded.map((want) => `${want.collection}: ${want.variable} is a ${want.layer} secret (${want.name}); start with --environment ${want.layer} to load it`)));
|
|
23244
23588
|
if (dryRun) {
|
|
23245
|
-
for (const want of
|
|
23589
|
+
for (const want of loaded) say(row$4(want.variable, "ok", `would fill ${want.collection}'s ${want.variable} from ${want.entry} of ${want.layer} as ${want.name}`));
|
|
23246
23590
|
if (names.length === 0) say(row$4("secrets", "ok", "nothing to fill: no variable refers to an entry"));
|
|
23247
23591
|
else say(row$4("secrets", "ok", `would write ${names.length} value(s) to ${SECRETS_FILE} and link it from ${plan.targets.length} collection(s)`));
|
|
23248
23592
|
say(row$4(plan.app, "ok", `would start ${plan.launch.command} in the foreground`));
|
|
@@ -23268,35 +23612,45 @@ async function runOpenRequests(input) {
|
|
|
23268
23612
|
if (!await (input.confirm ?? ((message) => confirm({
|
|
23269
23613
|
message,
|
|
23270
23614
|
default: false
|
|
23271
|
-
})))(names.length === 0 ? `Start ${plan.app} (nothing to fill)?` : `Read ${names.length} value(s) from ${
|
|
23615
|
+
})))(names.length === 0 ? `Start ${plan.app} (nothing to fill)?` : `Read ${names.length} value(s) from ${layers.join(", ")} and start ${plan.app} with them?`)) {
|
|
23272
23616
|
print(` ${style.skip("cancelled; nothing was read or written")}`);
|
|
23273
23617
|
return finish("cancelled");
|
|
23274
23618
|
}
|
|
23275
23619
|
}
|
|
23276
|
-
|
|
23620
|
+
const values = /* @__PURE__ */ new Map();
|
|
23277
23621
|
if (names.length > 0) {
|
|
23278
23622
|
const vault = loader.has("vault") ? loader.get("vault") : void 0;
|
|
23279
23623
|
if (!vault?.readEnvironmentEntries) {
|
|
23280
23624
|
say(row$4("vault", "fail", vault ? `${vault.providerName} cannot read an Environment's entries` : "needs a `vault` provider in holocron.config.ts (1password)"));
|
|
23281
23625
|
return finish();
|
|
23282
23626
|
}
|
|
23283
|
-
let
|
|
23284
|
-
|
|
23285
|
-
|
|
23286
|
-
|
|
23287
|
-
|
|
23288
|
-
|
|
23289
|
-
|
|
23290
|
-
|
|
23291
|
-
|
|
23292
|
-
|
|
23293
|
-
|
|
23294
|
-
|
|
23627
|
+
let failed = false;
|
|
23628
|
+
for (const layer of layers) {
|
|
23629
|
+
const wanted = loaded.filter((want) => want.layer === layer);
|
|
23630
|
+
if (wanted.length === 0) continue;
|
|
23631
|
+
let read;
|
|
23632
|
+
try {
|
|
23633
|
+
read = await readEntryValues({
|
|
23634
|
+
vault,
|
|
23635
|
+
environment: layer,
|
|
23636
|
+
configured: ownerEnvironments(input.loaded.resolved).names,
|
|
23637
|
+
repoRoot,
|
|
23638
|
+
names: [...new Set(wanted.map((want) => want.entry))].sort()
|
|
23639
|
+
});
|
|
23640
|
+
} catch (err) {
|
|
23641
|
+
say(row$4(`vault ${layer}`, "fail", describeError(err)));
|
|
23642
|
+
failed = true;
|
|
23643
|
+
continue;
|
|
23644
|
+
}
|
|
23645
|
+
for (const entry of read.missing) {
|
|
23646
|
+
say(row$4(`${layer} ${entry}`, "fail", `${read.environmentId} holds no value for ${entry}`));
|
|
23647
|
+
failed = true;
|
|
23648
|
+
}
|
|
23649
|
+
if (read.missing.length > 0) continue;
|
|
23650
|
+
for (const want of wanted) values.set(want.name, read.values.get(want.entry));
|
|
23651
|
+
say(row$4(`vault ${read.environmentId}`, "ok", `${wanted.length} value(s) read: ${[...new Set(wanted.map((want) => want.name))].join(", ")}`));
|
|
23295
23652
|
}
|
|
23296
|
-
|
|
23297
|
-
if (read.missing.length > 0) return finish();
|
|
23298
|
-
values = read.values;
|
|
23299
|
-
say(row$4(`vault ${read.environmentId}`, "ok", `${names.length} value(s) read: ${names.join(", ")}`));
|
|
23653
|
+
if (failed) return finish();
|
|
23300
23654
|
}
|
|
23301
23655
|
const secrets = resolve(repoRoot, SECRETS_FILE);
|
|
23302
23656
|
const lock = resolve(repoRoot, LOCK_FILE);
|
|
@@ -23380,7 +23734,8 @@ const openRequestsCommand = {
|
|
|
23380
23734
|
describe: "Open the request tool's workspace with its secrets filled in from the layer's vault Environment",
|
|
23381
23735
|
builder: (y) => y.option("environment", {
|
|
23382
23736
|
type: "string",
|
|
23383
|
-
|
|
23737
|
+
array: true,
|
|
23738
|
+
describe: "The layers to read the secrets from: `local`, `dev` or `prod`, repeated or comma-separated (default: `dev` alone; `prod` only when named)"
|
|
23384
23739
|
}).option("to", {
|
|
23385
23740
|
type: "string",
|
|
23386
23741
|
describe: "Open only for this tooling provider (needed when more than one can open its workspace)"
|
|
@@ -23401,7 +23756,7 @@ const openRequestsCommand = {
|
|
|
23401
23756
|
...tokens,
|
|
23402
23757
|
org: resolveOrg(argv, loaded.resolved)
|
|
23403
23758
|
},
|
|
23404
|
-
...argv.environment ? {
|
|
23759
|
+
...argv.environment ? { environments: argv.environment } : {},
|
|
23405
23760
|
...argv.to ? { to: argv.to } : {},
|
|
23406
23761
|
...argv.yes ? { yes: true } : {}
|
|
23407
23762
|
})).status === "fail") process.exitCode = 1;
|