@theholocron/cli 5.0.0-alpha.480 → 5.0.0-alpha.482
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 +5 -2
- package/dist/cli.mjs +716 -139
- package/dist/cli.mjs.map +1 -1
- package/dist/{index-Dqs99QEg.d.mts → index-Crowwrda.d.mts} +113 -1
- 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 +7 -7
package/dist/cli.mjs
CHANGED
|
@@ -10,10 +10,10 @@ import { NonInteractiveError, commandFailureMessage, createProgress, createRetry
|
|
|
10
10
|
import { LOG_LEVELS } from "@theholocron/observability/core";
|
|
11
11
|
import yargs from "yargs";
|
|
12
12
|
import { hideBin } from "yargs/helpers";
|
|
13
|
-
import { appendFileSync, copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { appendFileSync, closeSync, copyFileSync, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
14
14
|
import { DRY_RUN_NOOP_EXIT_CODE, createCommandRegistry, createMenu, numeric } from "@theholocron/kyber/menu";
|
|
15
15
|
import { Entry, findCredentials } from "@napi-rs/keyring";
|
|
16
|
-
import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver as createFeatureResolver$1, createKeyring, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue as resolveValue$1, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
|
|
16
|
+
import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver as createFeatureResolver$1, createKeyring, createPrivateFile, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue as resolveValue$1, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
|
|
17
17
|
import { DEFAULT_ORG, DOCUMENTATION_FLAG, DOT_GITHUB_REPO, HOLOCRON_REPO, KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, PRERELEASE_CHANNEL, RELEASE_BRANCHES, RESERVED_SCRIPT_NAMES, SUITES, TASKS, aggregateChecks, checkPackageScripts, checkReleaseLines, codecovFlagNames, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, formatJson, frozenReusablePaths, generateThinCallerContent, hostedReusableWorkflows, isDeprecated, isTask, legacyCaller, legacyCallerFile, legacyGate, legacyWorkflowKey, localize, localizeActions, mergeScripts, packageLocation, readWorkspacePackages, recordDeploys, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, wedgeFix, workflowFile, workflowKey, workflowKeys, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
|
|
18
18
|
import { loadTasksConfig, releaseGroups } from "@theholocron/astromech/config";
|
|
19
19
|
import { createCliLogger, createCliTelemetry } from "@theholocron/kyber/observability";
|
|
@@ -29,12 +29,13 @@ import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
|
29
29
|
import { promptForPositionals } from "@theholocron/kyber/prompts";
|
|
30
30
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
31
31
|
import { errorMessage } from "@theholocron/misc-utils";
|
|
32
|
-
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
32
|
+
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
33
33
|
import { stringifyJson } from "@theholocron/json-utils";
|
|
34
34
|
import { findRootSync, isWorkspaceRoot, walkFilesSync } from "@theholocron/fs-utils";
|
|
35
35
|
import { appManifestPage, buildAppManifest, convertAppManifest, serveAppManifest, serveHandler, superviseProcesses } from "@theholocron/dagobah";
|
|
36
36
|
import { createGitHubClient, getApp, listAppInstallations } from "@theholocron/github-client";
|
|
37
37
|
import { createServer } from "node:http";
|
|
38
|
+
import { promisify } from "node:util";
|
|
38
39
|
import { ADR_DIR, ADR_STATUSES, CLOSED_STATUSES, SPEC_DIRS, SPEC_STATUSES, WITHDRAWN_STATE, assignSpecIds, checkSpecs, classifySpecPath, discussionBody, discussionIdLine, discussionPrLine, discussionTitle, evaluateDocsPresence, isAddedDocComment, isFeat, packageOf, parseFrontmatter, parseSkipDocs, reconcileSpecStatus, specSummary, specTitle, updateFrontmatter } from "@theholocron/astromech/repo-validation";
|
|
39
40
|
import { loadConfigPath } from "@theholocron/datapad";
|
|
40
41
|
import { moveMajorTag } from "@theholocron/kyber/git";
|
|
@@ -63,6 +64,7 @@ const COMMAND_CONTEXTS = {
|
|
|
63
64
|
"list tokens": "global",
|
|
64
65
|
"export tokens": "workspace",
|
|
65
66
|
"export requests": "workspace",
|
|
67
|
+
"open requests": "workspace",
|
|
66
68
|
"upload coverage": "workspace",
|
|
67
69
|
"new github-app": "global",
|
|
68
70
|
"check token": "global",
|
|
@@ -106,6 +108,7 @@ const COMMAND_CONTEXTS = {
|
|
|
106
108
|
"doctor environments": "workspace",
|
|
107
109
|
"doctor project": "workspace",
|
|
108
110
|
"doctor logs": "workspace",
|
|
111
|
+
"doctor wiki": "workspace",
|
|
109
112
|
"doctor github-app": "workspace",
|
|
110
113
|
"move issues": "workspace",
|
|
111
114
|
"apply properties": "workspace",
|
|
@@ -521,6 +524,14 @@ const doctorTokensEntry = {
|
|
|
521
524
|
skipOptions: ["all", "repo"],
|
|
522
525
|
supportsDryRun: false
|
|
523
526
|
};
|
|
527
|
+
// src/commands/doctor-wiki/doctor-wiki.entry.ts
|
|
528
|
+
const doctorWikiEntry = {
|
|
529
|
+
name: "doctor wiki",
|
|
530
|
+
description: "Check the wiki's organization, docs site, domain and published pages (read-only)",
|
|
531
|
+
positionals: [],
|
|
532
|
+
skipOptions: ["all", "repo"],
|
|
533
|
+
supportsDryRun: false
|
|
534
|
+
};
|
|
524
535
|
// src/commands/github-app-create/github-app-create.entry.ts
|
|
525
536
|
const githubAppCreateEntry = {
|
|
526
537
|
name: "new github-app",
|
|
@@ -992,6 +1003,18 @@ const npmBumpVersionsEntry = {
|
|
|
992
1003
|
],
|
|
993
1004
|
supportsDryRun: true
|
|
994
1005
|
};
|
|
1006
|
+
// src/commands/open-requests/open-requests.entry.ts
|
|
1007
|
+
const openRequestsEntry = {
|
|
1008
|
+
name: "open requests",
|
|
1009
|
+
description: "Open the request tool's workspace with its secrets filled in from the layer's vault Environment",
|
|
1010
|
+
positionals: [],
|
|
1011
|
+
skipOptions: [
|
|
1012
|
+
"yes",
|
|
1013
|
+
"to",
|
|
1014
|
+
"environment"
|
|
1015
|
+
],
|
|
1016
|
+
supportsDryRun: true
|
|
1017
|
+
};
|
|
995
1018
|
// src/commands/plugin-create/plugin-create.entry.ts
|
|
996
1019
|
const pluginCreateEntry = {
|
|
997
1020
|
name: "new plugin",
|
|
@@ -1324,6 +1347,7 @@ const registry = createCommandRegistry([
|
|
|
1324
1347
|
doctorProjectEntry,
|
|
1325
1348
|
doctorGitHubAppEntry,
|
|
1326
1349
|
doctorLogsEntry,
|
|
1350
|
+
doctorWikiEntry,
|
|
1327
1351
|
projectMoveEntry,
|
|
1328
1352
|
repoPropertiesApplyEntry,
|
|
1329
1353
|
migrateIssueEntry,
|
|
@@ -1578,6 +1602,7 @@ const registry = createCommandRegistry([
|
|
|
1578
1602
|
authListEntry,
|
|
1579
1603
|
authExportEntry,
|
|
1580
1604
|
requestsExportEntry,
|
|
1605
|
+
openRequestsEntry,
|
|
1581
1606
|
{
|
|
1582
1607
|
name: "upload coverage",
|
|
1583
1608
|
description: "Upload the repo's coverage reports, one flag per group, through the coverage provider",
|
|
@@ -2451,7 +2476,7 @@ function mergeSync(a, b) {
|
|
|
2451
2476
|
} : rest);
|
|
2452
2477
|
}
|
|
2453
2478
|
// src/config/compose/merge-repo/merge-repo.ts
|
|
2454
|
-
const names$
|
|
2479
|
+
const names$2 = union();
|
|
2455
2480
|
const properties = shallowMerge();
|
|
2456
2481
|
const teamsByKey = mergeByKey((t) => typeof t === "string" ? t : t.slug);
|
|
2457
2482
|
/**
|
|
@@ -2481,16 +2506,16 @@ function mergeRepo(prev, next) {
|
|
|
2481
2506
|
};
|
|
2482
2507
|
if (secrets) {
|
|
2483
2508
|
const environments = { ...repo.secrets?.environments };
|
|
2484
|
-
for (const [env, list] of Object.entries(secrets.environments ?? {})) environments[env] = names$
|
|
2509
|
+
for (const [env, list] of Object.entries(secrets.environments ?? {})) environments[env] = names$2.merge(environments[env] ?? [], list);
|
|
2485
2510
|
repo.secrets = {
|
|
2486
|
-
...repo.secrets?.repo || secrets.repo ? { repo: names$
|
|
2487
|
-
...repo.secrets?.org || secrets.org ? { org: names$
|
|
2511
|
+
...repo.secrets?.repo || secrets.repo ? { repo: names$2.merge(repo.secrets?.repo ?? [], secrets.repo ?? []) } : {},
|
|
2512
|
+
...repo.secrets?.org || secrets.org ? { org: names$2.merge(repo.secrets?.org ?? [], secrets.org ?? []) } : {},
|
|
2488
2513
|
...Object.keys(environments).length > 0 ? { environments } : {},
|
|
2489
2514
|
...repo.secrets?.sync || secrets.sync ? { sync: mergeSync(repo.secrets?.sync, secrets.sync) } : {},
|
|
2490
2515
|
...repo.secrets?.deploy || secrets.deploy ? { deploy: [...repo.secrets?.deploy ?? [], ...secrets.deploy ?? []] } : {}
|
|
2491
2516
|
};
|
|
2492
2517
|
}
|
|
2493
|
-
if (topics) repo.topics = names$
|
|
2518
|
+
if (topics) repo.topics = names$2.merge(repo.topics ?? [], topics);
|
|
2494
2519
|
if (teams) repo.teams = teamsByKey.merge(repo.teams ?? [], teams);
|
|
2495
2520
|
return repo;
|
|
2496
2521
|
}
|
|
@@ -3437,10 +3462,10 @@ function pickProvider(providers, wanted, can, verb) {
|
|
|
3437
3462
|
if (capable.length === 0) throw new Error(`no \`notifications\` provider can ${verb.infinitive} — add one that implements it (for example discord) to holocron.config.ts`);
|
|
3438
3463
|
if (wanted) {
|
|
3439
3464
|
const match = capable.find((p) => p.providerName === wanted);
|
|
3440
|
-
if (!match) throw new Error(`no ${verb.gerund} \`notifications\` provider named \`${wanted}\` (have: ${names(capable)})`);
|
|
3465
|
+
if (!match) throw new Error(`no ${verb.gerund} \`notifications\` provider named \`${wanted}\` (have: ${names$1(capable)})`);
|
|
3441
3466
|
return match;
|
|
3442
3467
|
}
|
|
3443
|
-
if (capable.length > 1) throw new Error(`several \`notifications\` providers can ${verb.infinitive} (${names(capable)}) — pass --provider <name>`);
|
|
3468
|
+
if (capable.length > 1) throw new Error(`several \`notifications\` providers can ${verb.infinitive} (${names$1(capable)}) — pass --provider <name>`);
|
|
3444
3469
|
return capable[0];
|
|
3445
3470
|
}
|
|
3446
3471
|
/** Pick the provider that can provision. Any ensure* method counts: a role-only layout needs no channel support. */
|
|
@@ -3450,7 +3475,7 @@ function pickProvisioner(providers, wanted) {
|
|
|
3450
3475
|
gerund: "provisioning"
|
|
3451
3476
|
});
|
|
3452
3477
|
}
|
|
3453
|
-
const names = (ps) => ps.map((p) => p.providerName).join(", ");
|
|
3478
|
+
const names$1 = (ps) => ps.map((p) => p.providerName).join(", ");
|
|
3454
3479
|
/**
|
|
3455
3480
|
* The first reason the layout's secret names cannot work, or undefined. Two things
|
|
3456
3481
|
* cannot share one secret: the second write would overwrite the first and callers
|
|
@@ -7410,7 +7435,7 @@ async function runDoctorDns(input) {
|
|
|
7410
7435
|
});
|
|
7411
7436
|
else if (!loader.has("dns")) {
|
|
7412
7437
|
const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
|
|
7413
|
-
for (const zone of zones) rows.push(row$
|
|
7438
|
+
for (const zone of zones) rows.push(row$19(zone, "skip", why));
|
|
7414
7439
|
for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
|
|
7415
7440
|
} else {
|
|
7416
7441
|
const dns = loader.get("dns");
|
|
@@ -7432,7 +7457,7 @@ async function runDoctorDns(input) {
|
|
|
7432
7457
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
7433
7458
|
};
|
|
7434
7459
|
}
|
|
7435
|
-
function row$
|
|
7460
|
+
function row$19(zone, status, detail, problems = []) {
|
|
7436
7461
|
return {
|
|
7437
7462
|
id: `dns-${zone}`,
|
|
7438
7463
|
title: `${zone} records exist`,
|
|
@@ -7461,7 +7486,7 @@ async function checkDomain(dns, deploy, project, hostname) {
|
|
|
7461
7486
|
return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
|
|
7462
7487
|
}
|
|
7463
7488
|
}
|
|
7464
|
-
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$
|
|
7489
|
+
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$19(zone, ...args)) {
|
|
7465
7490
|
try {
|
|
7466
7491
|
const have = await dns.listRecords(zone);
|
|
7467
7492
|
const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
|
|
@@ -7596,7 +7621,7 @@ function installationSettingsUrl(account, id) {
|
|
|
7596
7621
|
return `https://github.com/settings/installations/${id}`;
|
|
7597
7622
|
}
|
|
7598
7623
|
// src/commands/doctor-github-app/app-rows.ts
|
|
7599
|
-
const row$
|
|
7624
|
+
const row$18 = (name, what, problems, ok) => ({
|
|
7600
7625
|
id: `${name}:${what}`,
|
|
7601
7626
|
title: `${name}: ${what}`,
|
|
7602
7627
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -7623,9 +7648,9 @@ function appRows(name, manifest, app, installations) {
|
|
|
7623
7648
|
return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
|
|
7624
7649
|
});
|
|
7625
7650
|
return [
|
|
7626
|
-
row$
|
|
7627
|
-
row$
|
|
7628
|
-
row$
|
|
7651
|
+
row$18(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
|
|
7652
|
+
row$18(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
|
|
7653
|
+
row$18(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
|
|
7629
7654
|
];
|
|
7630
7655
|
}
|
|
7631
7656
|
// src/commands/doctor-github-app/parse-manifest.ts
|
|
@@ -7683,7 +7708,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
7683
7708
|
assertPluginsResolvable(loader, "doctor github-app");
|
|
7684
7709
|
}
|
|
7685
7710
|
const rows = [];
|
|
7686
|
-
if (instances.length === 0) rows.push(row$
|
|
7711
|
+
if (instances.length === 0) rows.push(row$17("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
|
|
7687
7712
|
for (const instance of instances) rows.push(...await checkInstance(instance, loader, input));
|
|
7688
7713
|
printCheckRows(rows, print);
|
|
7689
7714
|
const summary = summariseChecks(rows);
|
|
@@ -7700,7 +7725,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
7700
7725
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
7701
7726
|
};
|
|
7702
7727
|
}
|
|
7703
|
-
function row$
|
|
7728
|
+
function row$17(name, what, status, detail) {
|
|
7704
7729
|
return {
|
|
7705
7730
|
id: `${name}:${what}`,
|
|
7706
7731
|
title: `${name}: ${what}`,
|
|
@@ -7741,19 +7766,19 @@ async function checkInstance(instance, loader, input) {
|
|
|
7741
7766
|
try {
|
|
7742
7767
|
manifest = parseManifest(readManifest(instance.manifest));
|
|
7743
7768
|
} catch (err) {
|
|
7744
|
-
return [row$
|
|
7769
|
+
return [row$17(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
|
|
7745
7770
|
}
|
|
7746
7771
|
const read = await readCredentials(instance, loader);
|
|
7747
|
-
if ("reason" in read) return [row$
|
|
7772
|
+
if ("reason" in read) return [row$17(name, "reachable", "skip", read.reason)];
|
|
7748
7773
|
const api = input.api ?? defaultApi;
|
|
7749
7774
|
const secrets = [read.creds.privateKey];
|
|
7750
7775
|
try {
|
|
7751
7776
|
const app = await api.getApp(read.creds);
|
|
7752
7777
|
const installations = await api.listAppInstallations(read.creds);
|
|
7753
7778
|
const owner = app.owner ? `, owned by ${app.owner.login}` : "";
|
|
7754
|
-
return [row$
|
|
7779
|
+
return [row$17(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
|
|
7755
7780
|
} catch (err) {
|
|
7756
|
-
return [row$
|
|
7781
|
+
return [row$17(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
|
|
7757
7782
|
}
|
|
7758
7783
|
}
|
|
7759
7784
|
// src/commands/doctor-github-app/doctor-github-app.command.ts
|
|
@@ -7820,7 +7845,7 @@ function datasetTargets(config) {
|
|
|
7820
7845
|
* dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
|
|
7821
7846
|
* 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.
|
|
7822
7847
|
*/
|
|
7823
|
-
const row$
|
|
7848
|
+
const row$16 = (id, title, status, detail, problems = []) => ({
|
|
7824
7849
|
id,
|
|
7825
7850
|
title,
|
|
7826
7851
|
status,
|
|
@@ -7837,7 +7862,7 @@ async function runDoctorLogs(input) {
|
|
|
7837
7862
|
if (!loader.has("logs")) {
|
|
7838
7863
|
const failure = loader.loadFailures().find((f) => f.key === "logs");
|
|
7839
7864
|
const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
|
|
7840
|
-
rows.push(row$
|
|
7865
|
+
rows.push(row$16("logs", "logs", "skip", why));
|
|
7841
7866
|
} else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
|
|
7842
7867
|
printCheckRows(rows, print);
|
|
7843
7868
|
const summary = summariseChecks(rows);
|
|
@@ -7861,38 +7886,38 @@ async function checkLogs(logs, targets) {
|
|
|
7861
7886
|
for (const target of targets) {
|
|
7862
7887
|
const id = `logs:dataset:${target.id}`;
|
|
7863
7888
|
const title = `dataset for ${target.label}`;
|
|
7864
|
-
if (!target.name) rows.push(row$
|
|
7865
|
-
else if (!token.usable) rows.push(row$
|
|
7866
|
-
else if (!logs.readDataset) rows.push(row$
|
|
7889
|
+
if (!target.name) rows.push(row$16(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
|
|
7890
|
+
else if (!token.usable) rows.push(row$16(id, title, "skip", `${target.name}: not checked, the token is not usable`));
|
|
7891
|
+
else if (!logs.readDataset) rows.push(row$16(id, title, "skip", `${logs.providerName} cannot read a dataset`));
|
|
7867
7892
|
else rows.push(...await checkDataset(logs, target, target.name, id, title));
|
|
7868
7893
|
}
|
|
7869
7894
|
const org = resolveValue$1(["AXIOM_ORG"], void 0, { prefix: PREFIX$1 });
|
|
7870
|
-
rows.push(org ? row$
|
|
7895
|
+
rows.push(org ? row$16("logs:org", "organization", "ok", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$16("logs:org", "organization", "skip", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links need it`));
|
|
7871
7896
|
return rows;
|
|
7872
7897
|
}
|
|
7873
7898
|
/** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
|
|
7874
7899
|
async function checkToken$1(logs, dataset) {
|
|
7875
7900
|
const title = "token is accepted";
|
|
7876
7901
|
if (!logs.checkToken) return {
|
|
7877
|
-
row: row$
|
|
7902
|
+
row: row$16("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
|
|
7878
7903
|
usable: true
|
|
7879
7904
|
};
|
|
7880
7905
|
try {
|
|
7881
7906
|
const result = await logs.checkToken(dataset);
|
|
7882
7907
|
if (result.ok) return {
|
|
7883
|
-
row: row$
|
|
7908
|
+
row: row$16("logs:token", title, "ok", `${logs.providerName} accepts the token`),
|
|
7884
7909
|
usable: true
|
|
7885
7910
|
};
|
|
7886
7911
|
const reason = result.reason ?? `${logs.providerName} refused the token`;
|
|
7887
7912
|
return {
|
|
7888
|
-
row: row$
|
|
7913
|
+
row: row$16("logs:token", title, "fail", reason, [reason]),
|
|
7889
7914
|
usable: false
|
|
7890
7915
|
};
|
|
7891
7916
|
} catch (err) {
|
|
7892
7917
|
const noToken = missingTokenReason(err);
|
|
7893
7918
|
const detail = noToken ?? `could not check the token: ${describeError(err)}`;
|
|
7894
7919
|
return {
|
|
7895
|
-
row: row$
|
|
7920
|
+
row: row$16("logs:token", title, "skip", detail),
|
|
7896
7921
|
usable: noToken === void 0
|
|
7897
7922
|
};
|
|
7898
7923
|
}
|
|
@@ -7902,17 +7927,17 @@ async function checkDataset(logs, target, name, id, title) {
|
|
|
7902
7927
|
const found = await logs.readDataset(name);
|
|
7903
7928
|
if (found.forbidden) {
|
|
7904
7929
|
const why = `${name}: not visible to this token (${logs.providerName} refused the read; it may also not exist)`;
|
|
7905
|
-
return [row$
|
|
7930
|
+
return [row$16(id, title, "skip", why)];
|
|
7906
7931
|
}
|
|
7907
7932
|
if (!found.exists) {
|
|
7908
7933
|
const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
|
|
7909
|
-
return [row$
|
|
7934
|
+
return [row$16(id, title, "fail", `${name} does not exist`, [problem])];
|
|
7910
7935
|
}
|
|
7911
7936
|
const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
|
|
7912
|
-
return [row$
|
|
7937
|
+
return [row$16(id, title, "ok", `${name} exists`), row$16(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
|
|
7913
7938
|
} catch (err) {
|
|
7914
7939
|
const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
|
|
7915
|
-
return [row$
|
|
7940
|
+
return [row$16(id, title, "skip", detail)];
|
|
7916
7941
|
}
|
|
7917
7942
|
}
|
|
7918
7943
|
// src/commands/doctor-logs/doctor-logs.command.ts
|
|
@@ -11116,7 +11141,7 @@ const info = (id, title, noun, extras) => ({
|
|
|
11116
11141
|
detail: `info: ${extras.length} ${noun} not in the template (never deleted)`,
|
|
11117
11142
|
problems: extras
|
|
11118
11143
|
});
|
|
11119
|
-
const row$
|
|
11144
|
+
const row$15 = (id, title, problems, ok) => ({
|
|
11120
11145
|
id,
|
|
11121
11146
|
title,
|
|
11122
11147
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -11152,19 +11177,19 @@ function viewProblems(want, found) {
|
|
|
11152
11177
|
function boardRows(boardName, template, state) {
|
|
11153
11178
|
const id = `project:${boardName}`;
|
|
11154
11179
|
const rows = [];
|
|
11155
|
-
rows.push(row$
|
|
11180
|
+
rows.push(row$15(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
|
|
11156
11181
|
const extraStatuses = state.statuses.filter((s) => !template.statuses.some((t) => t.name === s));
|
|
11157
11182
|
if (extraStatuses.length > 0) rows.push(info(`${id}:extra-statuses`, `${boardName}: extra statuses`, "status(es)", extraStatuses));
|
|
11158
|
-
for (const want of template.fields) rows.push(row$
|
|
11183
|
+
for (const want of template.fields) rows.push(row$15(`${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));
|
|
11159
11184
|
const extraFields = state.fields.filter((f) => !template.fields.some((t) => t.name === f.name));
|
|
11160
11185
|
if (extraFields.length > 0) rows.push(info(`${id}:extra-fields`, `${boardName}: extra fields`, "field(s)", extraFields.map((f) => f.name)));
|
|
11161
|
-
for (const want of template.views) rows.push(row$
|
|
11186
|
+
for (const want of template.views) rows.push(row$15(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
|
|
11162
11187
|
const extraViews = state.views.filter((v) => !template.views.some((t) => t.name === v.name));
|
|
11163
11188
|
if (extraViews.length > 0) rows.push(info(`${id}:extra-views`, `${boardName}: extra views`, "view(s)", extraViews.map((v) => v.name)));
|
|
11164
11189
|
for (const name of template.rules ?? []) {
|
|
11165
11190
|
const found = state.rules.find((r) => r.name === name);
|
|
11166
11191
|
const problems = !found ? [`missing rule ${name}`] : found.enabled ? [] : [`rule ${name} is off`];
|
|
11167
|
-
rows.push(row$
|
|
11192
|
+
rows.push(row$15(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
|
|
11168
11193
|
}
|
|
11169
11194
|
return rows;
|
|
11170
11195
|
}
|
|
@@ -11224,7 +11249,7 @@ function itemRows(boardName, items) {
|
|
|
11224
11249
|
* never fail the run. A template file that does not read is a failure naming the file. `--post [channel]` shares the
|
|
11225
11250
|
* failing rows through the `notifications` provider's bot, like `doctor notifications --post`.
|
|
11226
11251
|
*/
|
|
11227
|
-
const row$
|
|
11252
|
+
const row$14 = (id, title, status, detail, problems = []) => ({
|
|
11228
11253
|
id,
|
|
11229
11254
|
title,
|
|
11230
11255
|
status,
|
|
@@ -11278,14 +11303,14 @@ async function checkBoards(input, loader) {
|
|
|
11278
11303
|
loader,
|
|
11279
11304
|
...input.io ? { io: input.io } : {}
|
|
11280
11305
|
});
|
|
11281
|
-
if (!opened.ok) return [row$
|
|
11306
|
+
if (!opened.ok) return [row$14("project", "project", opened.kind, opened.reason, opened.problems)];
|
|
11282
11307
|
const { projects, owner, boards, templates, templateProblems } = opened.context;
|
|
11283
11308
|
const rows = templateProblems.map((problem) => {
|
|
11284
11309
|
/* v8 ignore next -- split always returns at least one element; the fallback only satisfies noUncheckedIndexedAccess */
|
|
11285
11310
|
const file = problem.split(": ")[0] ?? problem;
|
|
11286
|
-
return row$
|
|
11311
|
+
return row$14(`project:template:${file}`, `template file ${file}`, "fail", problem);
|
|
11287
11312
|
});
|
|
11288
|
-
if (boards.length === 0) return [...rows, row$
|
|
11313
|
+
if (boards.length === 0) return [...rows, row$14("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
|
|
11289
11314
|
for (const declared of boards) {
|
|
11290
11315
|
const template = templates[declared.template];
|
|
11291
11316
|
const title = `${declared.name}: board exists and is open`;
|
|
@@ -11293,18 +11318,18 @@ async function checkBoards(input, loader) {
|
|
|
11293
11318
|
const board = await projects.find(owner, declared.name);
|
|
11294
11319
|
if (!board) {
|
|
11295
11320
|
const closed = (await projects.list(owner)).some((b) => b.name === declared.name && b.closed);
|
|
11296
|
-
rows.push(row$
|
|
11321
|
+
rows.push(row$14(`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`"]));
|
|
11297
11322
|
continue;
|
|
11298
11323
|
}
|
|
11299
|
-
rows.push(row$
|
|
11324
|
+
rows.push(row$14(`project:${declared.name}`, title, "ok", board.url));
|
|
11300
11325
|
if (!template) {
|
|
11301
|
-
rows.push(row$
|
|
11326
|
+
rows.push(row$14(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
|
|
11302
11327
|
continue;
|
|
11303
11328
|
}
|
|
11304
11329
|
rows.push(...boardRows(declared.name, template, await projects.read(owner, board)));
|
|
11305
|
-
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$
|
|
11330
|
+
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$14(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
|
|
11306
11331
|
} catch (err) {
|
|
11307
|
-
rows.push(row$
|
|
11332
|
+
rows.push(row$14(`project:${declared.name}`, title, "fail", describeError(err)));
|
|
11308
11333
|
}
|
|
11309
11334
|
}
|
|
11310
11335
|
return rows;
|
|
@@ -11394,14 +11419,14 @@ function parseTagList(output) {
|
|
|
11394
11419
|
}];
|
|
11395
11420
|
});
|
|
11396
11421
|
}
|
|
11397
|
-
const defaultDeps = {
|
|
11422
|
+
const defaultDeps$1 = {
|
|
11398
11423
|
spawn: (command, args, options) => spawnSync(command, args, options),
|
|
11399
11424
|
fetch: (url) => fetch(url),
|
|
11400
11425
|
discover: discoverPublicPackages,
|
|
11401
11426
|
nowMs: () => Date.now()
|
|
11402
11427
|
};
|
|
11403
11428
|
/** `doctor releases`' inputs from the real git checkout under `repoRoot`, the npm registry and the workspace. */
|
|
11404
|
-
function realReleasesIo(repoRoot, deps = defaultDeps) {
|
|
11429
|
+
function realReleasesIo(repoRoot, deps = defaultDeps$1) {
|
|
11405
11430
|
return {
|
|
11406
11431
|
tags: () => {
|
|
11407
11432
|
const result = deps.spawn("git", [
|
|
@@ -12224,19 +12249,19 @@ async function runDoctorRepo(input) {
|
|
|
12224
12249
|
const rows = [];
|
|
12225
12250
|
if (!loader.has("source")) {
|
|
12226
12251
|
const why = whyMissing(loader, "source", "no `source` provider to read the repository with");
|
|
12227
|
-
for (const check of checks) rows.push(row$
|
|
12252
|
+
for (const check of checks) rows.push(row$13(check, { skip: why }));
|
|
12228
12253
|
} else {
|
|
12229
12254
|
const source = loader.get("source");
|
|
12230
12255
|
for (const check of checks) {
|
|
12231
12256
|
if (typeof source[check.needs] !== "function") {
|
|
12232
|
-
rows.push(row$
|
|
12257
|
+
rows.push(row$13(check, { skip: `provider does not implement ${check.needs}` }));
|
|
12233
12258
|
continue;
|
|
12234
12259
|
}
|
|
12235
12260
|
try {
|
|
12236
|
-
rows.push(row$
|
|
12261
|
+
rows.push(row$13(check, await check.run(source)));
|
|
12237
12262
|
} catch (err) {
|
|
12238
12263
|
const noToken = missingTokenReason(err);
|
|
12239
|
-
if (noToken !== void 0) rows.push(row$
|
|
12264
|
+
if (noToken !== void 0) rows.push(row$13(check, { skip: noToken }));
|
|
12240
12265
|
else rows.push({
|
|
12241
12266
|
id: check.id,
|
|
12242
12267
|
title: check.title,
|
|
@@ -12262,7 +12287,7 @@ async function runDoctorRepo(input) {
|
|
|
12262
12287
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
12263
12288
|
};
|
|
12264
12289
|
}
|
|
12265
|
-
function row$
|
|
12290
|
+
function row$13(check, result) {
|
|
12266
12291
|
const { id, title } = check;
|
|
12267
12292
|
if ("skip" in result) return {
|
|
12268
12293
|
id,
|
|
@@ -12785,7 +12810,7 @@ function providerGroup(providerName) {
|
|
|
12785
12810
|
}
|
|
12786
12811
|
// src/commands/doctor-secrets/credentials-rows.ts
|
|
12787
12812
|
/** A row for the provider as a whole, or for one of its variables when `name` is given. */
|
|
12788
|
-
function row$
|
|
12813
|
+
function row$12(provider, status, detail, name) {
|
|
12789
12814
|
return name === void 0 ? {
|
|
12790
12815
|
id: provider,
|
|
12791
12816
|
title: provider,
|
|
@@ -12810,10 +12835,10 @@ async function credentialsRows(input) {
|
|
|
12810
12835
|
const { loader } = input;
|
|
12811
12836
|
const { resolved } = input.loaded;
|
|
12812
12837
|
if (!resolved.providers.credentials) return {
|
|
12813
|
-
rows: input.asked ? [row$
|
|
12838
|
+
rows: input.asked ? [row$12("credentials", "skip", "no `credentials` provider is configured")] : [],
|
|
12814
12839
|
places: []
|
|
12815
12840
|
};
|
|
12816
|
-
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$
|
|
12841
|
+
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$12(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
|
|
12817
12842
|
const places = [];
|
|
12818
12843
|
if (!loader.has("credentials")) return {
|
|
12819
12844
|
rows,
|
|
@@ -12825,7 +12850,7 @@ async function credentialsRows(input) {
|
|
|
12825
12850
|
const tuple = tuples.find((t) => t.provider === impl.providerName);
|
|
12826
12851
|
const explicit = tuple && credentialsEnvironment(tuple, resolved);
|
|
12827
12852
|
if (!explicit && !derivesEnvironment(impl.providerName)) {
|
|
12828
|
-
rows.push(row$
|
|
12853
|
+
rows.push(row$12(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
|
|
12829
12854
|
continue;
|
|
12830
12855
|
}
|
|
12831
12856
|
try {
|
|
@@ -12837,7 +12862,7 @@ async function credentialsRows(input) {
|
|
|
12837
12862
|
rows.push(...checked.rows);
|
|
12838
12863
|
places.push(...checked.places);
|
|
12839
12864
|
} catch (err) {
|
|
12840
|
-
rows.push(row$
|
|
12865
|
+
rows.push(row$12(impl.providerName, "fail", errorMessage(err)));
|
|
12841
12866
|
}
|
|
12842
12867
|
}
|
|
12843
12868
|
return {
|
|
@@ -12853,17 +12878,17 @@ async function credentialsRows(input) {
|
|
|
12853
12878
|
async function checkProvider(impl, candidates, expected, synced) {
|
|
12854
12879
|
const provider = impl.providerName;
|
|
12855
12880
|
if (!impl.inspect) return {
|
|
12856
|
-
rows: [row$
|
|
12881
|
+
rows: [row$12(provider, "skip", "cannot list the variables without reading their values")],
|
|
12857
12882
|
places: []
|
|
12858
12883
|
};
|
|
12859
12884
|
if (expected.length === 0) return {
|
|
12860
|
-
rows: [row$
|
|
12885
|
+
rows: [row$12(provider, "skip", "no configured plugin lists the tokens it takes")],
|
|
12861
12886
|
places: []
|
|
12862
12887
|
};
|
|
12863
12888
|
const inspect = impl.inspect.bind(impl);
|
|
12864
12889
|
try {
|
|
12865
12890
|
const { found, missing } = await tryEnvironments(candidates, inspect);
|
|
12866
|
-
const rows = missing.map((name) => row$
|
|
12891
|
+
const rows = missing.map((name) => row$12(provider, "fail", `${provider} has no Environment named "${name}"`));
|
|
12867
12892
|
const group = providerGroup(provider);
|
|
12868
12893
|
const unreadPlaces = missing.map((name) => ({
|
|
12869
12894
|
column: {
|
|
@@ -12886,9 +12911,9 @@ async function checkProvider(impl, candidates, expected, synced) {
|
|
|
12886
12911
|
const have = (name) => found.some((f) => f.result.names.includes(name));
|
|
12887
12912
|
let present = 0;
|
|
12888
12913
|
for (const { name, optional } of expected) if (have(name)) present++;
|
|
12889
|
-
else if (optional) rows.push(row$
|
|
12890
|
-
else rows.push(row$
|
|
12891
|
-
if (present > 0) rows.push(row$
|
|
12914
|
+
else if (optional) rows.push(row$12(provider, "skip", `optional, not set in ${where}`, name));
|
|
12915
|
+
else rows.push(row$12(provider, "fail", `missing from ${where}`, name));
|
|
12916
|
+
if (present > 0) rows.push(row$12(provider, "ok", `${present} of ${expected.length} tokens present in ${where}`, "tokens"));
|
|
12892
12917
|
const names = new Set(expected.map((e) => e.name));
|
|
12893
12918
|
const places = [];
|
|
12894
12919
|
const missingRequired = expected.filter((e) => !e.optional && !have(e.name)).map((e) => e.name);
|
|
@@ -12927,7 +12952,7 @@ async function checkProvider(impl, candidates, expected, synced) {
|
|
|
12927
12952
|
};
|
|
12928
12953
|
} catch (err) {
|
|
12929
12954
|
return {
|
|
12930
|
-
rows: [row$
|
|
12955
|
+
rows: [row$12(provider, "fail", errorMessage(err))],
|
|
12931
12956
|
places: []
|
|
12932
12957
|
};
|
|
12933
12958
|
}
|
|
@@ -13801,7 +13826,7 @@ async function variableRows(loader, config, org) {
|
|
|
13801
13826
|
if (!loader.has("source")) {
|
|
13802
13827
|
const why = whyMissing(loader, "source", "no `source` provider to read them with");
|
|
13803
13828
|
for (const check of checks) {
|
|
13804
|
-
rows.push(row$
|
|
13829
|
+
rows.push(row$11(check, { skip: why }));
|
|
13805
13830
|
observations.push({
|
|
13806
13831
|
scope: check.scope,
|
|
13807
13832
|
unread: why
|
|
@@ -13811,7 +13836,7 @@ async function variableRows(loader, config, org) {
|
|
|
13811
13836
|
const source = loader.get("source");
|
|
13812
13837
|
for (const check of checks) try {
|
|
13813
13838
|
const result = await check.run(source);
|
|
13814
|
-
rows.push(row$
|
|
13839
|
+
rows.push(row$11(check, result));
|
|
13815
13840
|
observations.push("skip" in result ? {
|
|
13816
13841
|
scope: check.scope,
|
|
13817
13842
|
unread: result.skip
|
|
@@ -13822,7 +13847,7 @@ async function variableRows(loader, config, org) {
|
|
|
13822
13847
|
} catch (err) {
|
|
13823
13848
|
const noToken = missingTokenReason(err);
|
|
13824
13849
|
if (noToken !== void 0) {
|
|
13825
|
-
rows.push(row$
|
|
13850
|
+
rows.push(row$11(check, { skip: noToken }));
|
|
13826
13851
|
observations.push({
|
|
13827
13852
|
scope: check.scope,
|
|
13828
13853
|
unread: noToken
|
|
@@ -13848,7 +13873,7 @@ async function variableRows(loader, config, org) {
|
|
|
13848
13873
|
observations
|
|
13849
13874
|
};
|
|
13850
13875
|
}
|
|
13851
|
-
function row$
|
|
13876
|
+
function row$11(check, result) {
|
|
13852
13877
|
const { id, title } = check;
|
|
13853
13878
|
if ("skip" in result) return {
|
|
13854
13879
|
id,
|
|
@@ -13938,7 +13963,7 @@ function describeExpiry(expiresAt, now) {
|
|
|
13938
13963
|
*
|
|
13939
13964
|
* What a token may do is not checked: GitHub does not return a fine-grained token's permissions.
|
|
13940
13965
|
*/
|
|
13941
|
-
function row$
|
|
13966
|
+
function row$10(id, status, detail) {
|
|
13942
13967
|
return {
|
|
13943
13968
|
id: `verify:${id}`,
|
|
13944
13969
|
title: `verify ${id}`,
|
|
@@ -13966,12 +13991,12 @@ async function verifyRows(input) {
|
|
|
13966
13991
|
try {
|
|
13967
13992
|
module = await importer(pkg);
|
|
13968
13993
|
} catch (err) {
|
|
13969
|
-
rows.push(row$
|
|
13994
|
+
rows.push(row$10(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
|
|
13970
13995
|
continue;
|
|
13971
13996
|
}
|
|
13972
13997
|
for (const token of module.tokens ?? []) rows.push(await checkToken(token, module, env, readToken, now()));
|
|
13973
13998
|
}
|
|
13974
|
-
if (rows.length === 0) rows.push(row$
|
|
13999
|
+
if (rows.length === 0) rows.push(row$10("tokens", "skip", "no configured plugin lists the tokens it takes"));
|
|
13975
14000
|
return rows;
|
|
13976
14001
|
}
|
|
13977
14002
|
/**
|
|
@@ -13984,30 +14009,30 @@ async function loadCredentials(input) {
|
|
|
13984
14009
|
try {
|
|
13985
14010
|
await input.loader.load();
|
|
13986
14011
|
} catch (err) {
|
|
13987
|
-
return [row$
|
|
14012
|
+
return [row$10("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
|
|
13988
14013
|
}
|
|
13989
|
-
return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$
|
|
14014
|
+
return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$10(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
|
|
13990
14015
|
}
|
|
13991
14016
|
async function checkToken(token, module, env, readToken, now) {
|
|
13992
14017
|
const { keyringKey, envName, vendorEnvName } = token;
|
|
13993
14018
|
const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
|
|
13994
14019
|
const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
|
|
13995
14020
|
const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
|
|
13996
|
-
if (!value) return row$
|
|
14021
|
+
if (!value) return row$10(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
|
|
13997
14022
|
const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
|
|
13998
|
-
if (!verify) return row$
|
|
14023
|
+
if (!verify) return row$10(keyringKey, "skip", "set, but its plugin cannot verify it");
|
|
13999
14024
|
const from = fromEnv ?? stored?.source ?? "keyring";
|
|
14000
14025
|
try {
|
|
14001
14026
|
const verified = await verify(value);
|
|
14002
|
-
if (!verified.ok) return row$
|
|
14027
|
+
if (!verified.ok) return row$10(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
|
|
14003
14028
|
const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
|
|
14004
|
-
if (!expiry) return row$
|
|
14029
|
+
if (!expiry) return row$10(keyringKey, "ok", `${verified.subject} (${from})`);
|
|
14005
14030
|
return expiry.soon ? {
|
|
14006
|
-
...row$
|
|
14031
|
+
...row$10(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
|
|
14007
14032
|
problems: [`${expiry.text}: renew it`]
|
|
14008
|
-
} : row$
|
|
14033
|
+
} : row$10(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
|
|
14009
14034
|
} catch (err) {
|
|
14010
|
-
return row$
|
|
14035
|
+
return row$10(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
|
|
14011
14036
|
}
|
|
14012
14037
|
}
|
|
14013
14038
|
// src/commands/doctor-secrets/doctor-secrets.ts
|
|
@@ -14734,7 +14759,7 @@ function summariseProbeRows(id, title, rows) {
|
|
|
14734
14759
|
* provider with no `token` probe, no declared layer, or one that cannot be read is a skip with the reason.
|
|
14735
14760
|
*/
|
|
14736
14761
|
const PROBE = "token";
|
|
14737
|
-
const row$
|
|
14762
|
+
const row$9 = (id, title, status, detail, problems = []) => ({
|
|
14738
14763
|
id,
|
|
14739
14764
|
title,
|
|
14740
14765
|
status,
|
|
@@ -14759,12 +14784,12 @@ async function runDoctorTokens(input) {
|
|
|
14759
14784
|
try {
|
|
14760
14785
|
tokens = await providerTokens(provider);
|
|
14761
14786
|
} catch (err) {
|
|
14762
|
-
rows.push(row$
|
|
14787
|
+
rows.push(row$9(`tokens:${provider}`, provider, "skip", `could not read its tokens: ${describeError(err)}`));
|
|
14763
14788
|
continue;
|
|
14764
14789
|
}
|
|
14765
14790
|
const expectations = tokenExpectations(tokens);
|
|
14766
|
-
if (expectations.length === 0) rows.push(row$
|
|
14767
|
-
else if (!usableProbe(probes.get(provider))) rows.push(row$
|
|
14791
|
+
if (expectations.length === 0) rows.push(row$9(`tokens:${provider}`, provider, "skip", "info: declares no token layers, nothing to check"));
|
|
14792
|
+
else if (!usableProbe(probes.get(provider))) rows.push(row$9(`tokens:${provider}`, provider, "skip", `info: has no \`${PROBE}\` probe loaded, so its tokens are not checked`));
|
|
14768
14793
|
else declared.push({
|
|
14769
14794
|
provider,
|
|
14770
14795
|
tokens,
|
|
@@ -14826,14 +14851,14 @@ async function checkLayer(c) {
|
|
|
14826
14851
|
tokens
|
|
14827
14852
|
});
|
|
14828
14853
|
} catch (err) {
|
|
14829
|
-
if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$
|
|
14830
|
-
return c.wanted.map((e) => row$
|
|
14854
|
+
if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$9(id(e), title(e), "fail", "not held in this layer", [err.message]));
|
|
14855
|
+
return c.wanted.map((e) => row$9(id(e), title(e), "skip", `could not read the Environment: ${describeError(err)}`));
|
|
14831
14856
|
}
|
|
14832
14857
|
const rows = [];
|
|
14833
14858
|
for (const e of c.wanted) {
|
|
14834
14859
|
const token = held.held.find((h) => h.envName === e.envName);
|
|
14835
14860
|
if (!token) {
|
|
14836
|
-
rows.push(row$
|
|
14861
|
+
rows.push(row$9(id(e), title(e), "fail", `not held in ${held.environment}`, [`${e.envName} is declared for ${c.layer}`]));
|
|
14837
14862
|
continue;
|
|
14838
14863
|
}
|
|
14839
14864
|
rows.push(summariseProbeRows(id(e), title(e), await probeToken(c, e, token.token, held.plain)));
|
|
@@ -14886,6 +14911,147 @@ async function runWith(c, e, token, context) {
|
|
|
14886
14911
|
})).rows;
|
|
14887
14912
|
}
|
|
14888
14913
|
}
|
|
14914
|
+
// src/commands/doctor-tokens/doctor-tokens.command.ts
|
|
14915
|
+
const doctorTokensCommand = {
|
|
14916
|
+
command: "tokens",
|
|
14917
|
+
describe: "Check every token the plugins declare for a layer has the permissions it should, no more, and is not due for rotation (read-only, goes online)",
|
|
14918
|
+
handler: async (argv) => {
|
|
14919
|
+
const tokens = tokenContext(argv.token);
|
|
14920
|
+
if (!tokens) return;
|
|
14921
|
+
const loaded = await loadConfig(argv.cwd);
|
|
14922
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
14923
|
+
if ((await runDoctorTokens({
|
|
14924
|
+
loaded,
|
|
14925
|
+
context: {
|
|
14926
|
+
repoRoot: argv.cwd,
|
|
14927
|
+
...tokens,
|
|
14928
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
14929
|
+
}
|
|
14930
|
+
})).status === "fail") process.exitCode = 1;
|
|
14931
|
+
}
|
|
14932
|
+
};
|
|
14933
|
+
// src/commands/doctor-wiki/wiki-rows.ts
|
|
14934
|
+
const row$8 = (id, title, status, detail, problems = []) => ({
|
|
14935
|
+
id,
|
|
14936
|
+
title,
|
|
14937
|
+
status,
|
|
14938
|
+
detail,
|
|
14939
|
+
problems
|
|
14940
|
+
});
|
|
14941
|
+
/** How many names a row lists before it says how many more there are. */
|
|
14942
|
+
const LISTED = 5;
|
|
14943
|
+
const names = (paths) => paths.length > LISTED ? `${paths.slice(0, LISTED).join(", ")} and ${paths.length - LISTED} more` : paths.join(", ");
|
|
14944
|
+
/**
|
|
14945
|
+
* One address: an answer below 400 passes, a 401 or 403 passes too (the site is there and restricts who reads it:
|
|
14946
|
+
* password protection is set in the provider's dashboard), a 404 or any other status fails, and no answer at all is a
|
|
14947
|
+
* skip, since a machine with no network says nothing about the site.
|
|
14948
|
+
*/
|
|
14949
|
+
function siteRow(id, title, probe, notFoundHint) {
|
|
14950
|
+
if (probe.status === void 0) return row$8(id, title, "skip", `${probe.url}: ${probe.error ?? "no answer"}`);
|
|
14951
|
+
if (probe.status < 400) return row$8(id, title, "ok", `${probe.url} answers ${probe.status}`);
|
|
14952
|
+
if (probe.status === 401 || probe.status === 403) return row$8(id, title, "ok", `${probe.url} answers ${probe.status} (access is restricted)`);
|
|
14953
|
+
const problem = probe.status === 404 ? `${probe.url} answers 404; ${notFoundHint}` : `${probe.url} answers ${probe.status}, expected a page`;
|
|
14954
|
+
return row$8(id, title, "fail", `${probe.url} answers ${probe.status}`, [problem]);
|
|
14955
|
+
}
|
|
14956
|
+
/**
|
|
14957
|
+
* The rows `holocron doctor wiki` prints for one {@link WikiInspection}: organization, docs instance, the site and its
|
|
14958
|
+
* custom domain, the navigation against the sources, pages the navigation leaves out (information only) and the
|
|
14959
|
+
* published page index. Pure; a thing that could not be read is a skip with the reason, never a failure.
|
|
14960
|
+
*/
|
|
14961
|
+
function wikiRows(found, providerName) {
|
|
14962
|
+
const rows = [];
|
|
14963
|
+
const { declared, found: foundOrg } = found.organization;
|
|
14964
|
+
if (foundOrg === null) {
|
|
14965
|
+
const problem = `fern/fern.config.json has no organization; \`holocron setup\` writes it`;
|
|
14966
|
+
rows.push(row$8("wiki:organization", "organization is set", "fail", problem, [problem]));
|
|
14967
|
+
} else if (foundOrg !== declared) {
|
|
14968
|
+
const problem = `fern/fern.config.json names ${foundOrg}, the config declares ${declared}; run \`holocron setup\``;
|
|
14969
|
+
rows.push(row$8("wiki:organization", "organization is set", "fail", `${foundOrg}, declared ${declared}`, [problem]));
|
|
14970
|
+
} else rows.push(row$8("wiki:organization", "organization is set", "ok", `${declared} in fern/fern.config.json`));
|
|
14971
|
+
const instance = found.instance;
|
|
14972
|
+
if (instance === null) {
|
|
14973
|
+
const problem = "fern/docs.yml does not exist; `holocron setup` writes it";
|
|
14974
|
+
rows.push(row$8("wiki:instance", "docs site is declared", "fail", problem, [problem]));
|
|
14975
|
+
} else {
|
|
14976
|
+
const problems = [];
|
|
14977
|
+
if (instance.foundUrl !== instance.expectedUrl) problems.push(`instance url is ${instance.foundUrl ?? "not set"}, expected ${instance.expectedUrl}`);
|
|
14978
|
+
if (instance.expectedDomain !== void 0 && instance.foundDomain !== instance.expectedDomain) problems.push(`custom-domain is ${instance.foundDomain ?? "not set"}, expected ${instance.expectedDomain}`);
|
|
14979
|
+
rows.push(problems.length > 0 ? row$8("wiki:instance", "docs site is declared", "fail", `${problems.length} problem(s)`, [...problems.map((p) => `fern/docs.yml: ${p}`)]) : row$8("wiki:instance", "docs site is declared", "ok", `${instance.expectedUrl} in fern/docs.yml`));
|
|
14980
|
+
}
|
|
14981
|
+
const [site, domain] = found.site;
|
|
14982
|
+
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\`)`));
|
|
14983
|
+
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`));
|
|
14984
|
+
if (found.navigation === null) rows.push(row$8("wiki:navigation", "navigation pages exist", "skip", "no fern/docs.yml to read"));
|
|
14985
|
+
else if (found.navigation.missing.length > 0) {
|
|
14986
|
+
const problems = found.navigation.missing.map((p) => `${p} is listed in fern/docs.yml but is not on disk`);
|
|
14987
|
+
rows.push(row$8("wiki:navigation", "navigation pages exist", "fail", `${found.navigation.missing.length} missing`, problems));
|
|
14988
|
+
} else {
|
|
14989
|
+
rows.push(row$8("wiki:navigation", "navigation pages exist", "ok", `${found.navigation.listed} listed pages exist`));
|
|
14990
|
+
if (found.navigation.unlisted.length > 0) rows.push(row$8("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`));
|
|
14991
|
+
}
|
|
14992
|
+
const published = found.published;
|
|
14993
|
+
const listed = found.navigation?.listed;
|
|
14994
|
+
if (!published) rows.push(row$8("wiki:published", "published pages", "skip", "the site's page index could not be asked"));
|
|
14995
|
+
else if (published.pages === void 0) {
|
|
14996
|
+
const why = published.status === void 0 ? published.error ?? "no answer" : `answered ${published.status}`;
|
|
14997
|
+
rows.push(row$8("wiki:published", "published pages", "skip", `${published.url}: ${why}`));
|
|
14998
|
+
} else if (listed !== void 0 && published.pages < listed) {
|
|
14999
|
+
const problem = `${published.url} lists ${published.pages} page(s), the navigation lists ${listed}; the last publish is behind (run the wiki workflow)`;
|
|
15000
|
+
rows.push(row$8("wiki:published", "published pages", "fail", `${published.pages} of ${listed}`, [problem]));
|
|
15001
|
+
} else rows.push(row$8("wiki:published", "published pages", "ok", listed === void 0 ? `${published.pages} page(s) in ${published.url}` : `${published.pages} page(s) published for ${listed} listed`));
|
|
15002
|
+
return rows;
|
|
15003
|
+
}
|
|
15004
|
+
// src/commands/doctor-wiki/doctor-wiki.ts
|
|
15005
|
+
/**
|
|
15006
|
+
* `holocron doctor wiki` — does the wiki the config declares exist, and is it what the sources say?
|
|
15007
|
+
*
|
|
15008
|
+
* Read-only: it never provisions, publishes or writes, sends no token, and prints names, addresses and counts only. The
|
|
15009
|
+
* rows (`wikiRows()`): the provider's organization and docs instance against the config, the site and its custom
|
|
15010
|
+
* domain answering, the navigation's pages existing on disk, the pages the navigation leaves out (an `info` row) and
|
|
15011
|
+
* the published page index against the navigation. Only a mismatch the files or the site prove fails; a site that
|
|
15012
|
+
* cannot be reached, an index that is not served, or a provider that cannot read its wiki is a skip with the reason.
|
|
15013
|
+
*/
|
|
15014
|
+
const skip = (detail) => ({
|
|
15015
|
+
id: "wiki",
|
|
15016
|
+
title: "wiki",
|
|
15017
|
+
status: "skip",
|
|
15018
|
+
detail,
|
|
15019
|
+
problems: []
|
|
15020
|
+
});
|
|
15021
|
+
async function runDoctorWiki(input) {
|
|
15022
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
15023
|
+
const logger = input.logger ?? getLogger();
|
|
15024
|
+
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
15025
|
+
await loader.load();
|
|
15026
|
+
assertPluginsResolvable(loader, "doctor wiki");
|
|
15027
|
+
let rows;
|
|
15028
|
+
if (!loader.has("wiki")) {
|
|
15029
|
+
const failure = loader.loadFailures().find((f) => f.key === "wiki");
|
|
15030
|
+
rows = [skip(failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `wiki` provider is configured in holocron.config.ts")];
|
|
15031
|
+
} else {
|
|
15032
|
+
const wiki = loader.get("wiki");
|
|
15033
|
+
if (!wiki.inspect) rows = [skip(`${wiki.providerName} cannot read its wiki`)];
|
|
15034
|
+
else try {
|
|
15035
|
+
rows = wikiRows(await wiki.inspect(), wiki.providerName);
|
|
15036
|
+
} catch (err) {
|
|
15037
|
+
rows = [skip(missingTokenReason(err) ?? `could not read the wiki: ${describeError(err)}`)];
|
|
15038
|
+
}
|
|
15039
|
+
}
|
|
15040
|
+
printCheckRows(rows, print);
|
|
15041
|
+
const summary = summariseChecks(rows);
|
|
15042
|
+
printCheckSummary(summary, print);
|
|
15043
|
+
const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
|
|
15044
|
+
logger.info({
|
|
15045
|
+
...summary,
|
|
15046
|
+
status
|
|
15047
|
+
}, "doctor wiki");
|
|
15048
|
+
return {
|
|
15049
|
+
status,
|
|
15050
|
+
rows,
|
|
15051
|
+
summary,
|
|
15052
|
+
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
15053
|
+
};
|
|
15054
|
+
}
|
|
14889
15055
|
// src/commands/deep-checks/deep-checks.ts
|
|
14890
15056
|
/**
|
|
14891
15057
|
* Every `doctor <capability>` deep check, in the order `doctor --all` runs them. Adding one is an entry here
|
|
@@ -14988,24 +15154,7 @@ const DEEP_CHECKS = [
|
|
|
14988
15154
|
{
|
|
14989
15155
|
name: "tokens",
|
|
14990
15156
|
capability: "vault",
|
|
14991
|
-
command:
|
|
14992
|
-
command: "tokens",
|
|
14993
|
-
describe: "Check every token the plugins declare for a layer has the permissions it should, no more, and is not due for rotation (read-only, goes online)",
|
|
14994
|
-
handler: async (argv) => {
|
|
14995
|
-
const tokens = tokenContext(argv.token);
|
|
14996
|
-
if (!tokens) return;
|
|
14997
|
-
const loaded = await loadConfig(argv.cwd);
|
|
14998
|
-
applyResolvedConfig(argv, loaded.resolved);
|
|
14999
|
-
if ((await runDoctorTokens({
|
|
15000
|
-
loaded,
|
|
15001
|
-
context: {
|
|
15002
|
-
repoRoot: argv.cwd,
|
|
15003
|
-
...tokens,
|
|
15004
|
-
org: resolveOrg(argv, loaded.resolved)
|
|
15005
|
-
}
|
|
15006
|
-
})).status === "fail") process.exitCode = 1;
|
|
15007
|
-
}
|
|
15008
|
-
},
|
|
15157
|
+
command: doctorTokensCommand,
|
|
15009
15158
|
async run(input) {
|
|
15010
15159
|
const report = await runDoctorTokens(input);
|
|
15011
15160
|
return {
|
|
@@ -15078,6 +15227,36 @@ const DEEP_CHECKS = [
|
|
|
15078
15227
|
...report.reason ? { reason: report.reason } : {}
|
|
15079
15228
|
};
|
|
15080
15229
|
}
|
|
15230
|
+
},
|
|
15231
|
+
{
|
|
15232
|
+
name: "wiki",
|
|
15233
|
+
capability: "wiki",
|
|
15234
|
+
command: {
|
|
15235
|
+
command: "wiki",
|
|
15236
|
+
describe: "Check the wiki's organization, docs site, domain and published pages (read-only)",
|
|
15237
|
+
handler: async (argv) => {
|
|
15238
|
+
const tokens = tokenContext(argv.token);
|
|
15239
|
+
if (!tokens) return;
|
|
15240
|
+
const loaded = await loadConfig(argv.cwd);
|
|
15241
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
15242
|
+
if ((await runDoctorWiki({
|
|
15243
|
+
loaded,
|
|
15244
|
+
context: {
|
|
15245
|
+
repoRoot: argv.cwd,
|
|
15246
|
+
...tokens,
|
|
15247
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
15248
|
+
}
|
|
15249
|
+
})).status === "fail") process.exitCode = 1;
|
|
15250
|
+
}
|
|
15251
|
+
},
|
|
15252
|
+
async run(input) {
|
|
15253
|
+
const report = await runDoctorWiki(input);
|
|
15254
|
+
return {
|
|
15255
|
+
status: report.status,
|
|
15256
|
+
summary: report.summary,
|
|
15257
|
+
...report.reason ? { reason: report.reason } : {}
|
|
15258
|
+
};
|
|
15259
|
+
}
|
|
15081
15260
|
}
|
|
15082
15261
|
];
|
|
15083
15262
|
// src/commands/doctor-all/doctor-all.ts
|
|
@@ -15811,7 +15990,7 @@ function resolveExportDir(input) {
|
|
|
15811
15990
|
* listed under the provider's row and does not fail the run. It writes files, so it asks first unless `--dry-run` (the
|
|
15812
15991
|
* files are converted and listed, nothing is written) or `--yes` (without a terminal it refuses instead).
|
|
15813
15992
|
*/
|
|
15814
|
-
const row$
|
|
15993
|
+
const row$7 = (id, status, detail, problems = []) => ({
|
|
15815
15994
|
id,
|
|
15816
15995
|
title: id,
|
|
15817
15996
|
status,
|
|
@@ -15853,9 +16032,9 @@ async function runRequestsExport(input) {
|
|
|
15853
16032
|
print("");
|
|
15854
16033
|
const entry = input.loaded.resolved.providers.tooling;
|
|
15855
16034
|
const tuples = entry?.cardinality === "many" ? entry.tuples : [];
|
|
15856
|
-
if (tuples.length === 0) return finish([row$
|
|
16035
|
+
if (tuples.length === 0) return finish([row$7("tooling", "fail", "the config has no `tooling` provider to export for")]);
|
|
15857
16036
|
const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
|
|
15858
|
-
if (chosen.length === 0) return finish([row$
|
|
16037
|
+
if (chosen.length === 0) return finish([row$7(input.to, "fail", `not a \`tooling\` provider of this config (${tuples.map((t) => t.provider).join(", ")})`)]);
|
|
15859
16038
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
15860
16039
|
const loader = input.loader ?? new PluginLoader({
|
|
15861
16040
|
...input.loaded.resolved,
|
|
@@ -15875,17 +16054,17 @@ async function runRequestsExport(input) {
|
|
|
15875
16054
|
const tool = loaded.find((t) => t.providerName === id);
|
|
15876
16055
|
if (!tool) {
|
|
15877
16056
|
const failure = loader.loadFailures().find((f) => f.key === "tooling" && f.provider === id);
|
|
15878
|
-
rows.push(row$
|
|
16057
|
+
rows.push(row$7(id, "fail", `the provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`));
|
|
15879
16058
|
continue;
|
|
15880
16059
|
}
|
|
15881
16060
|
if (!tool.export) {
|
|
15882
|
-
rows.push(row$
|
|
16061
|
+
rows.push(row$7(id, "skip", "has no export: it reads the repo's files as they are"));
|
|
15883
16062
|
continue;
|
|
15884
16063
|
}
|
|
15885
16064
|
const collectionFiles = fileList$1(tuple.options.collectionFiles);
|
|
15886
16065
|
const envFiles = fileList$1(tuple.options.envFiles);
|
|
15887
16066
|
if (collectionFiles.length === 0) {
|
|
15888
|
-
rows.push(row$
|
|
16067
|
+
rows.push(row$7(id, "skip", "names no `collectionFiles`, so there is nothing to export"));
|
|
15889
16068
|
continue;
|
|
15890
16069
|
}
|
|
15891
16070
|
const groups = input.out === void 0 ? groupByFolder(collectionFiles) : [collectionFiles];
|
|
@@ -15899,7 +16078,7 @@ async function runRequestsExport(input) {
|
|
|
15899
16078
|
...input.out !== void 0 ? { out: input.out } : {}
|
|
15900
16079
|
});
|
|
15901
16080
|
if (!dir.ok) {
|
|
15902
|
-
rows.push(row$
|
|
16081
|
+
rows.push(row$7(label, "fail", dir.message));
|
|
15903
16082
|
continue;
|
|
15904
16083
|
}
|
|
15905
16084
|
targets.push({
|
|
@@ -15938,9 +16117,9 @@ async function runRequestsExport(input) {
|
|
|
15938
16117
|
const where = relative(repoRoot, outDir);
|
|
15939
16118
|
const files = result.files.length > 0 ? ` (${result.files.join(", ")})` : "";
|
|
15940
16119
|
paths.push(...result.files.map((file) => resolve(outDir, file)));
|
|
15941
|
-
rows.push(row$
|
|
16120
|
+
rows.push(row$7(label, "ok", `${dryRun ? "would write" : "wrote"} ${result.files.length} file(s) to ${where}${files}`, result.issues.map((issue) => `issue in ${issue.file}: ${issue.message}`)));
|
|
15942
16121
|
} catch (err) {
|
|
15943
|
-
rows.push(row$
|
|
16122
|
+
rows.push(row$7(label, "fail", describeError(err)));
|
|
15944
16123
|
}
|
|
15945
16124
|
const report = finish(rows.sort((a, b) => a.id.localeCompare(b.id)));
|
|
15946
16125
|
if (paths.length > 0) {
|
|
@@ -19714,7 +19893,7 @@ const githubAppCreateCommand = {
|
|
|
19714
19893
|
};
|
|
19715
19894
|
// src/commands/ideas-promote/build-spec/build-spec.ts
|
|
19716
19895
|
const FILED_FROM = /^Filed from idea:.*$/;
|
|
19717
|
-
const MARKER = /^<!-- holocron:idea [^>]*-->$/;
|
|
19896
|
+
const MARKER$1 = /^<!-- holocron:idea [^>]*-->$/;
|
|
19718
19897
|
/**
|
|
19719
19898
|
* A draft spec from an issue: frontmatter (`status: draft`, the `issue`, no `blocked-by`, and no `id`, which
|
|
19720
19899
|
* `sync specs` assigns), the title as the heading, and a `Problem` section holding the issue's text. The `Filed from
|
|
@@ -19726,7 +19905,7 @@ function buildSpec(input) {
|
|
|
19726
19905
|
let fromIdea = false;
|
|
19727
19906
|
const kept = lines.filter((line) => {
|
|
19728
19907
|
const trimmed = line.trim();
|
|
19729
|
-
if (FILED_FROM.test(trimmed) || MARKER.test(trimmed)) {
|
|
19908
|
+
if (FILED_FROM.test(trimmed) || MARKER$1.test(trimmed)) {
|
|
19730
19909
|
fromIdea = true;
|
|
19731
19910
|
return false;
|
|
19732
19911
|
}
|
|
@@ -19805,7 +19984,7 @@ function specName(title, name) {
|
|
|
19805
19984
|
*/
|
|
19806
19985
|
/** How many lines of the spec a dry run shows. */
|
|
19807
19986
|
const PREVIEW_LINES$1 = 12;
|
|
19808
|
-
const row$
|
|
19987
|
+
const row$6 = (id, status, detail) => ({
|
|
19809
19988
|
id,
|
|
19810
19989
|
title: id,
|
|
19811
19990
|
status,
|
|
@@ -19835,7 +20014,7 @@ async function runIdeasPromote(input) {
|
|
|
19835
20014
|
print(style.header(`Holocron new spec${dryRun ? " (dry-run)" : ""}`));
|
|
19836
20015
|
print("");
|
|
19837
20016
|
const entry = input.loaded.resolved.providers.issues;
|
|
19838
|
-
if (!entry) return finish([row$
|
|
20017
|
+
if (!entry) return finish([row$6(input.issue, "fail", "the config has no `issues` provider to read the issue with")]);
|
|
19839
20018
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
19840
20019
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
19841
20020
|
const loader = input.loader ?? new PluginLoader({
|
|
@@ -19850,18 +20029,18 @@ async function runIdeasPromote(input) {
|
|
|
19850
20029
|
assertPluginsResolvable(loader, "new spec");
|
|
19851
20030
|
if (!loader.has("issues")) {
|
|
19852
20031
|
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
19853
|
-
return finish([row$
|
|
20032
|
+
return finish([row$6(input.issue, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
19854
20033
|
}
|
|
19855
20034
|
let issue;
|
|
19856
20035
|
try {
|
|
19857
20036
|
issue = await loader.get("issues").get(input.issue);
|
|
19858
20037
|
} catch (err) {
|
|
19859
|
-
return finish([row$
|
|
20038
|
+
return finish([row$6(input.issue, "fail", `could not read the issue: ${describeError(err)}`)]);
|
|
19860
20039
|
}
|
|
19861
20040
|
const name = specName(issue.summary, input.name);
|
|
19862
|
-
if (!name) return finish([row$
|
|
20041
|
+
if (!name) return finish([row$6(issue.key, "fail", input.name === void 0 ? "no spec name can be made from the title; pass --name" : `"${input.name}" is not a spec name: use lower-case words joined by hyphens, such as tech-my-topic`)]);
|
|
19863
20042
|
const relative = join(".notes", `${name}.spec.md`);
|
|
19864
|
-
if (io.exists(join(input.context.repoRoot, relative))) return finish([row$
|
|
20043
|
+
if (io.exists(join(input.context.repoRoot, relative))) return finish([row$6(relative, "fail", "the spec already exists; it is never overwritten")], relative);
|
|
19865
20044
|
const { org, name: repoName } = input.loaded.resolved;
|
|
19866
20045
|
const ref = githubRef(issue.url) ?? (issue.key.startsWith("#") ? `${org}/${repoName}${issue.key}` : issue.key);
|
|
19867
20046
|
const { content, fromIdea } = buildSpec({
|
|
@@ -19874,7 +20053,7 @@ async function runIdeasPromote(input) {
|
|
|
19874
20053
|
print(` ${relative}`);
|
|
19875
20054
|
for (const line of content.split("\n").slice(0, PREVIEW_LINES$1)) print(` ${style.skip(line)}`);
|
|
19876
20055
|
print("");
|
|
19877
|
-
return finish([row$
|
|
20056
|
+
return finish([row$6(relative, "skip", `would write the spec ${origin}`)], relative);
|
|
19878
20057
|
}
|
|
19879
20058
|
if (!input.yes) {
|
|
19880
20059
|
if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`\`new spec\` writes ${relative}; pass --yes to run it without asking, or --dry-run to preview`);
|
|
@@ -19893,9 +20072,9 @@ async function runIdeasPromote(input) {
|
|
|
19893
20072
|
try {
|
|
19894
20073
|
io.write(join(input.context.repoRoot, relative), content);
|
|
19895
20074
|
} catch (err) {
|
|
19896
|
-
return finish([row$
|
|
20075
|
+
return finish([row$6(relative, "fail", `could not write the spec: ${describeError(err)}`)], relative);
|
|
19897
20076
|
}
|
|
19898
|
-
return finish([row$
|
|
20077
|
+
return finish([row$6(relative, "ok", `wrote the spec ${origin}`)], relative);
|
|
19899
20078
|
}
|
|
19900
20079
|
// src/commands/ideas-promote/ideas-promote.command.ts
|
|
19901
20080
|
const ideasPromoteCommand = {
|
|
@@ -19949,7 +20128,7 @@ function readIssueBody(file, cwd, read = (p) => readFileSync(p, "utf8")) {
|
|
|
19949
20128
|
*/
|
|
19950
20129
|
/** How many lines of the body a dry run shows. */
|
|
19951
20130
|
const PREVIEW_LINES = 8;
|
|
19952
|
-
const row$
|
|
20131
|
+
const row$5 = (id, status, detail) => ({
|
|
19953
20132
|
id,
|
|
19954
20133
|
title: id,
|
|
19955
20134
|
status,
|
|
@@ -19973,9 +20152,9 @@ async function runIssueCreate(input) {
|
|
|
19973
20152
|
print(style.header(`Holocron new issue${dryRun ? " (dry-run)" : ""}`));
|
|
19974
20153
|
print("");
|
|
19975
20154
|
const title = input.title.trim();
|
|
19976
|
-
if (!title) return finish([row$
|
|
20155
|
+
if (!title) return finish([row$5("title", "fail", "the title is empty")]);
|
|
19977
20156
|
const entry = input.loaded.resolved.providers.issues;
|
|
19978
|
-
if (!entry) return finish([row$
|
|
20157
|
+
if (!entry) return finish([row$5(title, "fail", "the config has no `issues` provider to file the issue with")]);
|
|
19979
20158
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
19980
20159
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
19981
20160
|
const loader = input.loader ?? new PluginLoader({
|
|
@@ -19990,7 +20169,7 @@ async function runIssueCreate(input) {
|
|
|
19990
20169
|
assertPluginsResolvable(loader, "new issue");
|
|
19991
20170
|
if (!loader.has("issues")) {
|
|
19992
20171
|
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
19993
|
-
return finish([row$
|
|
20172
|
+
return finish([row$5(title, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
19994
20173
|
}
|
|
19995
20174
|
const labels = [...new Set((input.labels ?? []).map((l) => l.trim()).filter(Boolean))];
|
|
19996
20175
|
const body = input.body?.trim() ? input.body : void 0;
|
|
@@ -20006,7 +20185,7 @@ async function runIssueCreate(input) {
|
|
|
20006
20185
|
print(` ${title}`);
|
|
20007
20186
|
for (const line of (body ?? "").split("\n").slice(0, PREVIEW_LINES)) print(` ${style.skip(line)}`);
|
|
20008
20187
|
print("");
|
|
20009
|
-
return finish([row$
|
|
20188
|
+
return finish([row$5(title, "skip", `would file the issue${summary}`)]);
|
|
20010
20189
|
}
|
|
20011
20190
|
if (!input.yes) {
|
|
20012
20191
|
if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError("`new issue` files an issue; pass --yes to run it without asking, or --dry-run to preview");
|
|
@@ -20029,9 +20208,9 @@ async function runIssueCreate(input) {
|
|
|
20029
20208
|
...milestone ? { milestone } : {},
|
|
20030
20209
|
...assignees.length > 0 ? { assignees } : {}
|
|
20031
20210
|
});
|
|
20032
|
-
return finish([row$
|
|
20211
|
+
return finish([row$5(title, "ok", `filed ${key}`), ...(dropped ?? []).map((line) => row$5("not carried across", "skip", line))], key);
|
|
20033
20212
|
} catch (err) {
|
|
20034
|
-
return finish([row$
|
|
20213
|
+
return finish([row$5(title, "fail", `could not file the issue: ${describeError(err)}`)]);
|
|
20035
20214
|
}
|
|
20036
20215
|
}
|
|
20037
20216
|
// src/commands/issue-create/issue-create.command.ts
|
|
@@ -22691,6 +22870,403 @@ const newCommand = {
|
|
|
22691
22870
|
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")),
|
|
22692
22871
|
handler: () => {}
|
|
22693
22872
|
};
|
|
22873
|
+
// src/commands/open-requests/read-entry-values/read-entry-values.ts
|
|
22874
|
+
/**
|
|
22875
|
+
* The values of the named entries of one vault Environment, read in memory. Only an Environment this repo uses is read:
|
|
22876
|
+
* a layer word (`local`, `dev`, `ci`, `prod`) is this repo's `<org/repo> - <layer>`, and any other text must be a name
|
|
22877
|
+
* the config already names, as `probe --environment` requires. `local` reads the way the CLI does, `- local` over
|
|
22878
|
+
* `- dev`, and `- local` may be absent.
|
|
22879
|
+
*
|
|
22880
|
+
* This is the one place a concealed value is read on purpose (see `AGENTS.md`, "Concealed values"): only the names the
|
|
22881
|
+
* collection's references list are taken, every other entry is dropped before this returns, and a value is never
|
|
22882
|
+
* logged or put in an error. A name the Environment lacks, or holds blank, is in `missing`.
|
|
22883
|
+
*
|
|
22884
|
+
* @throws {Error} When the Environment is not one of this repo's or the vault cannot read entries.
|
|
22885
|
+
*/
|
|
22886
|
+
async function readEntryValues(input) {
|
|
22887
|
+
if (!isEnvironmentLayer(input.environment) && !input.configured.includes(input.environment)) {
|
|
22888
|
+
const known = [...ENVIRONMENT_LAYERS, ...input.configured];
|
|
22889
|
+
throw new Error(`${input.environment} is not an Environment this repo's config names; use one of: ${known.join(", ")}`);
|
|
22890
|
+
}
|
|
22891
|
+
const read = (id) => input.vault.readEnvironmentEntries(id);
|
|
22892
|
+
const at = {
|
|
22893
|
+
repoRoot: input.repoRoot,
|
|
22894
|
+
gitExec: input.gitExec
|
|
22895
|
+
};
|
|
22896
|
+
const environmentId = await resolveEnvironmentId(input.environment, at);
|
|
22897
|
+
let entries;
|
|
22898
|
+
if (input.environment === "local") {
|
|
22899
|
+
const dev = await read(await resolveEnvironmentId("dev", at));
|
|
22900
|
+
const local = await read(environmentId).catch(() => []);
|
|
22901
|
+
entries = [...dev, ...local];
|
|
22902
|
+
} else entries = await read(environmentId);
|
|
22903
|
+
const held = new Map(entries.map((entry) => [entry.name, entry.value]));
|
|
22904
|
+
const values = /* @__PURE__ */ new Map();
|
|
22905
|
+
const missing = [];
|
|
22906
|
+
for (const name of input.names) {
|
|
22907
|
+
const value = held.get(name);
|
|
22908
|
+
if (value) values.set(name, value);
|
|
22909
|
+
else missing.push(name);
|
|
22910
|
+
}
|
|
22911
|
+
return {
|
|
22912
|
+
environmentId,
|
|
22913
|
+
values,
|
|
22914
|
+
missing
|
|
22915
|
+
};
|
|
22916
|
+
}
|
|
22917
|
+
// src/commands/open-requests/run-open-requests/default-deps/default-deps.ts
|
|
22918
|
+
const run = promisify(execFile);
|
|
22919
|
+
/** What is at `path`, without following a symlink. */
|
|
22920
|
+
function inspect(path) {
|
|
22921
|
+
let stat;
|
|
22922
|
+
try {
|
|
22923
|
+
stat = lstatSync(path);
|
|
22924
|
+
} catch (err) {
|
|
22925
|
+
if (err.code === "ENOENT") return { kind: "none" };
|
|
22926
|
+
throw err;
|
|
22927
|
+
}
|
|
22928
|
+
if (stat.isSymbolicLink()) return {
|
|
22929
|
+
kind: "symlink",
|
|
22930
|
+
to: readlinkSync(path)
|
|
22931
|
+
};
|
|
22932
|
+
if (!stat.isFile()) return { kind: "other" };
|
|
22933
|
+
return {
|
|
22934
|
+
kind: "file",
|
|
22935
|
+
firstLine: readFileSync(path, "utf8").split("\n")[0]
|
|
22936
|
+
};
|
|
22937
|
+
}
|
|
22938
|
+
/** Whether a process with this id is running. */
|
|
22939
|
+
function alive(pid) {
|
|
22940
|
+
try {
|
|
22941
|
+
process.kill(pid, 0);
|
|
22942
|
+
return true;
|
|
22943
|
+
} catch (err) {
|
|
22944
|
+
return err.code === "EPERM";
|
|
22945
|
+
}
|
|
22946
|
+
}
|
|
22947
|
+
/** Makes the lock file holding `pid`, or says it is held by a process that still runs; a lock of a dead one is replaced. */
|
|
22948
|
+
function takeLock(path, pid) {
|
|
22949
|
+
for (let attempt = 0; attempt < 2; attempt += 1) try {
|
|
22950
|
+
const fd = openSync(path, "wx", 384);
|
|
22951
|
+
writeSync(fd, String(pid));
|
|
22952
|
+
closeSync(fd);
|
|
22953
|
+
return true;
|
|
22954
|
+
} catch (err) {
|
|
22955
|
+
if (err.code !== "EEXIST") throw err;
|
|
22956
|
+
const holder = Number.parseInt(readFileSync(path, "utf8"), 10);
|
|
22957
|
+
if (Number.isInteger(holder) && alive(holder)) return false;
|
|
22958
|
+
rmSync(path, { force: true });
|
|
22959
|
+
}
|
|
22960
|
+
/* v8 ignore next -- only when another run takes the lock between the check and the retry */
|
|
22961
|
+
return false;
|
|
22962
|
+
}
|
|
22963
|
+
/** The real collaborators of `open requests`. */
|
|
22964
|
+
function defaultDeps() {
|
|
22965
|
+
return {
|
|
22966
|
+
isIgnored: isGitIgnored,
|
|
22967
|
+
makeDir: (dir) => void mkdirSync(dir, {
|
|
22968
|
+
recursive: true,
|
|
22969
|
+
mode: 448
|
|
22970
|
+
}),
|
|
22971
|
+
createPrivateFile: (path, text) => closeSync(createPrivateFile(path, text).fd),
|
|
22972
|
+
inspect,
|
|
22973
|
+
symlink: (to, link) => symlinkSync(to, link),
|
|
22974
|
+
remove: (path) => rmSync(path, { force: true }),
|
|
22975
|
+
takeLock,
|
|
22976
|
+
/* v8 ignore start -- the process list, the program and the signals are only real outside tests, which inject them */
|
|
22977
|
+
processes: async () => (await run("ps", ["-axo", "command"], { maxBuffer: 16777216 })).stdout,
|
|
22978
|
+
run: (launch) => new Promise((resolve, reject) => {
|
|
22979
|
+
const child = spawn(launch.command, launch.args, { stdio: "inherit" });
|
|
22980
|
+
const stop = () => child.kill("SIGTERM");
|
|
22981
|
+
process.once("SIGTERM", stop);
|
|
22982
|
+
child.once("error", (err) => {
|
|
22983
|
+
process.off("SIGTERM", stop);
|
|
22984
|
+
reject(err);
|
|
22985
|
+
});
|
|
22986
|
+
child.once("exit", (code) => {
|
|
22987
|
+
process.off("SIGTERM", stop);
|
|
22988
|
+
resolve(code ?? 0);
|
|
22989
|
+
});
|
|
22990
|
+
}),
|
|
22991
|
+
onTerminate: (handler) => {
|
|
22992
|
+
const events = [
|
|
22993
|
+
"SIGINT",
|
|
22994
|
+
"SIGTERM",
|
|
22995
|
+
"SIGHUP",
|
|
22996
|
+
"exit"
|
|
22997
|
+
];
|
|
22998
|
+
for (const event of events) process.once(event, handler);
|
|
22999
|
+
return () => {
|
|
23000
|
+
for (const event of events) process.off(event, handler);
|
|
23001
|
+
};
|
|
23002
|
+
},
|
|
23003
|
+
pid: process.pid,
|
|
23004
|
+
platform: process.platform
|
|
23005
|
+
};
|
|
23006
|
+
}
|
|
23007
|
+
// src/commands/open-requests/run-open-requests/run-open-requests.ts
|
|
23008
|
+
/**
|
|
23009
|
+
* `holocron open requests` — opens the request tool's workspace with its secrets filled in from the layer's vault
|
|
23010
|
+
* Environment, so nobody pastes a signing secret by hand.
|
|
23011
|
+
*
|
|
23012
|
+
* The `tooling` provider (Bruno's) says which values the workspace reads (`Tooling.open`: each secret variable is a
|
|
23013
|
+
* reference to a named entry, written by `sync requests`) and how to start the tool. This command takes exactly those
|
|
23014
|
+
* entries from the Environment, in memory, writes them to a private file in `.holocron/.private/` (mode 0600, git-ignored,
|
|
23015
|
+
* never printed), links the file to where the tool reads it (`<collection>/.env`) and runs the tool in the foreground.
|
|
23016
|
+
* The file, the links and the lock are removed when the tool quits, on an error, and on SIGINT, SIGTERM, SIGHUP and exit;
|
|
23017
|
+
* nothing can run on SIGKILL or a crash, so the file starts with a marker line and a later run removes its own leftover
|
|
23018
|
+
* and refuses anything without the marker. A tool that is already running is never touched: it would not see the values.
|
|
23019
|
+
* Names and paths are printed, never a value. `--dry-run` lists them and starts nothing.
|
|
23020
|
+
*/
|
|
23021
|
+
/** The first line of the file this command writes; a file that starts with it is this command's own leftover. */
|
|
23022
|
+
const MARKER = "# written by `holocron open requests` for one session and removed when it ends";
|
|
23023
|
+
/** The file the values go to, in the private directory. */
|
|
23024
|
+
const SECRETS_FILE = `${PRIVATE_DIR}/requests.env`;
|
|
23025
|
+
/** The lock a launch holds, in the private directory. */
|
|
23026
|
+
const LOCK_FILE = `${PRIVATE_DIR}/open-requests.lock`;
|
|
23027
|
+
const row$4 = (id, status, detail, problems = []) => ({
|
|
23028
|
+
id,
|
|
23029
|
+
title: id,
|
|
23030
|
+
status,
|
|
23031
|
+
detail,
|
|
23032
|
+
problems
|
|
23033
|
+
});
|
|
23034
|
+
/** Whether a link or file at `link` is something this command wrote: a link to the values file, or a marked file. */
|
|
23035
|
+
function isOurs(state, link, secrets) {
|
|
23036
|
+
if (state.kind === "symlink") return resolve(dirname(link), state.to) === secrets;
|
|
23037
|
+
return state.kind === "file" && state.firstLine === "# written by `holocron open requests` for one session and removed when it ends";
|
|
23038
|
+
}
|
|
23039
|
+
async function runOpenRequests(input) {
|
|
23040
|
+
/* v8 ignore next -- the console is only used outside tests, which inject `print` */
|
|
23041
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
23042
|
+
const deps = {
|
|
23043
|
+
...defaultDeps(),
|
|
23044
|
+
...input.deps
|
|
23045
|
+
};
|
|
23046
|
+
const dryRun = Boolean(input.context.dryRun);
|
|
23047
|
+
const environment = input.environment ?? "dev";
|
|
23048
|
+
const { repoRoot } = input.context;
|
|
23049
|
+
const rows = [];
|
|
23050
|
+
const say = (next) => {
|
|
23051
|
+
rows.push(next);
|
|
23052
|
+
printCheckRows([next], print);
|
|
23053
|
+
};
|
|
23054
|
+
const finish = (status) => {
|
|
23055
|
+
const summary = summariseChecks(rows);
|
|
23056
|
+
printCheckSummary(summary, print);
|
|
23057
|
+
return {
|
|
23058
|
+
status: status ?? (summary.fail > 0 ? "fail" : "ok"),
|
|
23059
|
+
rows
|
|
23060
|
+
};
|
|
23061
|
+
};
|
|
23062
|
+
print(style.header(`Holocron open requests${dryRun ? " (dry-run)" : ""}`));
|
|
23063
|
+
print("");
|
|
23064
|
+
const entry = input.loaded.resolved.providers.tooling;
|
|
23065
|
+
const tuples = entry?.cardinality === "many" ? entry.tuples : [];
|
|
23066
|
+
const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
|
|
23067
|
+
if (chosen.length === 0) {
|
|
23068
|
+
say(row$4(input.to ?? "tooling", "fail", input.to === void 0 ? "the config has no `tooling` provider to open" : `not a \`tooling\` provider of this config (${tuples.map((t) => t.provider).join(", ")})`));
|
|
23069
|
+
return finish();
|
|
23070
|
+
}
|
|
23071
|
+
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
23072
|
+
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
23073
|
+
/* v8 ignore stop */
|
|
23074
|
+
await loader.load();
|
|
23075
|
+
assertPluginsResolvable(loader, "open requests");
|
|
23076
|
+
const openable = (loader.has("tooling") ? loader.get("tooling") : []).filter((t) => chosen.some((tuple) => tuple.provider === t.providerName)).filter((t) => t.open !== void 0);
|
|
23077
|
+
if (openable.length !== 1) {
|
|
23078
|
+
say(row$4("tooling", "fail", openable.length === 0 ? "no `tooling` provider can open its workspace" : `more than one \`tooling\` provider can open its workspace (${openable.map((t) => t.providerName).join(", ")}); name one with --to`));
|
|
23079
|
+
return finish();
|
|
23080
|
+
}
|
|
23081
|
+
const tool = openable[0];
|
|
23082
|
+
const tuple = chosen.find((t) => t.provider === tool.providerName);
|
|
23083
|
+
const list = (value) => Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
|
|
23084
|
+
let plan;
|
|
23085
|
+
try {
|
|
23086
|
+
plan = await tool.open({
|
|
23087
|
+
collectionFiles: list(tuple.options.collectionFiles),
|
|
23088
|
+
envFiles: list(tuple.options.envFiles),
|
|
23089
|
+
repoRoot
|
|
23090
|
+
});
|
|
23091
|
+
} catch (err) {
|
|
23092
|
+
say(row$4(tool.providerName, "fail", describeError(err)));
|
|
23093
|
+
return finish();
|
|
23094
|
+
}
|
|
23095
|
+
const names = [...new Set(plan.wants.map((w) => w.entry))].sort();
|
|
23096
|
+
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));
|
|
23097
|
+
if (dryRun) {
|
|
23098
|
+
for (const want of plan.wants) say(row$4(want.variable, "ok", `would fill ${want.collection}'s ${want.variable} from ${want.entry} of ${environment}`));
|
|
23099
|
+
if (names.length === 0) say(row$4("secrets", "ok", "nothing to fill: no variable refers to an entry"));
|
|
23100
|
+
else say(row$4("secrets", "ok", `would write ${names.length} value(s) to ${SECRETS_FILE} and link it from ${plan.targets.length} collection(s)`));
|
|
23101
|
+
say(row$4(plan.app, "ok", `would start ${plan.launch.command} in the foreground`));
|
|
23102
|
+
return finish();
|
|
23103
|
+
}
|
|
23104
|
+
if (deps.platform === "win32" && names.length > 0) {
|
|
23105
|
+
say(row$4(plan.app, "fail", "cannot make the values file private on Windows: its mode bits are not enforced, and a link needs rights it may lack"));
|
|
23106
|
+
return finish();
|
|
23107
|
+
}
|
|
23108
|
+
let running;
|
|
23109
|
+
try {
|
|
23110
|
+
running = await deps.processes();
|
|
23111
|
+
} catch (err) {
|
|
23112
|
+
say(row$4(plan.app, "fail", `could not tell whether ${plan.app} is running: ${describeError(err)}`));
|
|
23113
|
+
return finish();
|
|
23114
|
+
}
|
|
23115
|
+
if (running.split("\n").some((line) => line.includes(plan.running))) {
|
|
23116
|
+
say(row$4(plan.app, "fail", `${plan.app} is already running; quit it and run this again (it would not see the values)`));
|
|
23117
|
+
return finish();
|
|
23118
|
+
}
|
|
23119
|
+
if (!input.yes) {
|
|
23120
|
+
if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`\`open requests\` writes ${names.length} secret value(s) to a private file and starts ${plan.app}; pass --yes to run it without asking, or --dry-run to preview`);
|
|
23121
|
+
if (!await (input.confirm ?? ((message) => confirm({
|
|
23122
|
+
message,
|
|
23123
|
+
default: false
|
|
23124
|
+
})))(names.length === 0 ? `Start ${plan.app} (nothing to fill)?` : `Read ${names.length} value(s) from ${environment} and start ${plan.app} with them?`)) {
|
|
23125
|
+
print(` ${style.skip("cancelled; nothing was read or written")}`);
|
|
23126
|
+
return finish("cancelled");
|
|
23127
|
+
}
|
|
23128
|
+
}
|
|
23129
|
+
let values = /* @__PURE__ */ new Map();
|
|
23130
|
+
if (names.length > 0) {
|
|
23131
|
+
const vault = loader.has("vault") ? loader.get("vault") : void 0;
|
|
23132
|
+
if (!vault?.readEnvironmentEntries) {
|
|
23133
|
+
say(row$4("vault", "fail", vault ? `${vault.providerName} cannot read an Environment's entries` : "needs a `vault` provider in holocron.config.ts (1password)"));
|
|
23134
|
+
return finish();
|
|
23135
|
+
}
|
|
23136
|
+
let read;
|
|
23137
|
+
try {
|
|
23138
|
+
read = await readEntryValues({
|
|
23139
|
+
vault,
|
|
23140
|
+
environment,
|
|
23141
|
+
configured: ownerEnvironments(input.loaded.resolved).names,
|
|
23142
|
+
repoRoot,
|
|
23143
|
+
names
|
|
23144
|
+
});
|
|
23145
|
+
} catch (err) {
|
|
23146
|
+
say(row$4(`vault ${environment}`, "fail", describeError(err)));
|
|
23147
|
+
return finish();
|
|
23148
|
+
}
|
|
23149
|
+
for (const name of read.missing) say(row$4(name, "fail", `${read.environmentId} holds no value for ${name}`));
|
|
23150
|
+
if (read.missing.length > 0) return finish();
|
|
23151
|
+
values = read.values;
|
|
23152
|
+
say(row$4(`vault ${read.environmentId}`, "ok", `${names.length} value(s) read: ${names.join(", ")}`));
|
|
23153
|
+
}
|
|
23154
|
+
const secrets = resolve(repoRoot, SECRETS_FILE);
|
|
23155
|
+
const lock = resolve(repoRoot, LOCK_FILE);
|
|
23156
|
+
const created = [];
|
|
23157
|
+
let cleaned = false;
|
|
23158
|
+
const cleanup = () => {
|
|
23159
|
+
if (cleaned) return;
|
|
23160
|
+
cleaned = true;
|
|
23161
|
+
for (const link of plan.targets) {
|
|
23162
|
+
const state = deps.inspect(link);
|
|
23163
|
+
if (created.includes(link) && isOurs(state, link, secrets)) deps.remove(link);
|
|
23164
|
+
}
|
|
23165
|
+
if (created.includes(secrets)) deps.remove(secrets);
|
|
23166
|
+
deps.remove(lock);
|
|
23167
|
+
};
|
|
23168
|
+
deps.makeDir(dirname(secrets));
|
|
23169
|
+
if (!deps.takeLock(lock, deps.pid)) {
|
|
23170
|
+
say(row$4(plan.app, "fail", `another \`open requests\` is starting ${plan.app} (${LOCK_FILE} is held); try again when it has`));
|
|
23171
|
+
return finish();
|
|
23172
|
+
}
|
|
23173
|
+
const stop = deps.onTerminate(cleanup);
|
|
23174
|
+
try {
|
|
23175
|
+
if (names.length > 0) {
|
|
23176
|
+
const ignored = deps.isIgnored(secrets);
|
|
23177
|
+
if (ignored === "tracked" || ignored === "unknown") {
|
|
23178
|
+
say(row$4("values file", "fail", `refusing to write ${SECRETS_FILE}: git ${ignored === "tracked" ? "does not ignore it, so it could be committed" : "could not say whether it ignores it"}`, [ignoreAdvice(true, "")]));
|
|
23179
|
+
return finish();
|
|
23180
|
+
}
|
|
23181
|
+
const stale = deps.inspect(secrets);
|
|
23182
|
+
if (stale.kind !== "none" && !(stale.kind === "file" && stale.firstLine === "# written by `holocron open requests` for one session and removed when it ends")) {
|
|
23183
|
+
say(row$4("values file", "fail", `${SECRETS_FILE} is not this command's (no marker line); move it away`));
|
|
23184
|
+
return finish();
|
|
23185
|
+
}
|
|
23186
|
+
for (const link of plan.targets) {
|
|
23187
|
+
const state = deps.inspect(link);
|
|
23188
|
+
if (state.kind !== "none" && !isOurs(state, link, secrets)) {
|
|
23189
|
+
say(row$4("link", "fail", `${relative(repoRoot, link)} exists and is not this command's (it is not a link to ${SECRETS_FILE}, and has no marker line); move it away`));
|
|
23190
|
+
return finish();
|
|
23191
|
+
}
|
|
23192
|
+
}
|
|
23193
|
+
const lines = [MARKER];
|
|
23194
|
+
for (const [name, value] of values) {
|
|
23195
|
+
const line = dotenvLine(name, value);
|
|
23196
|
+
if (line === null) {
|
|
23197
|
+
say(row$4(name, "fail", `the value of ${name} cannot be written to a .env file as it is; it was not written`));
|
|
23198
|
+
return finish();
|
|
23199
|
+
}
|
|
23200
|
+
lines.push(line);
|
|
23201
|
+
}
|
|
23202
|
+
for (const link of plan.targets) deps.remove(link);
|
|
23203
|
+
deps.remove(secrets);
|
|
23204
|
+
deps.createPrivateFile(secrets, `${lines.join("\n")}\n`);
|
|
23205
|
+
created.push(secrets);
|
|
23206
|
+
for (const link of plan.targets) {
|
|
23207
|
+
deps.symlink(relative(dirname(link), secrets), link);
|
|
23208
|
+
created.push(link);
|
|
23209
|
+
}
|
|
23210
|
+
say(row$4("values file", "ok", `${SECRETS_FILE} (mode 0600, git-ignored) linked from ${plan.targets.map((t) => relative(repoRoot, t)).join(", ")}`));
|
|
23211
|
+
}
|
|
23212
|
+
print("");
|
|
23213
|
+
print(`starting ${plan.app}${names.length > 0 ? `; the values are removed when it quits (Ctrl-C ends it too)` : ""}`);
|
|
23214
|
+
let exitCode;
|
|
23215
|
+
try {
|
|
23216
|
+
exitCode = await deps.run(plan.launch);
|
|
23217
|
+
} catch (err) {
|
|
23218
|
+
say(row$4(plan.app, "fail", describeError(err)));
|
|
23219
|
+
return finish();
|
|
23220
|
+
}
|
|
23221
|
+
say(row$4(plan.app, exitCode === 0 ? "ok" : "fail", `ended with ${exitCode}`));
|
|
23222
|
+
return finish();
|
|
23223
|
+
} finally {
|
|
23224
|
+
stop();
|
|
23225
|
+
const wrote = created.includes(secrets);
|
|
23226
|
+
cleanup();
|
|
23227
|
+
if (wrote) print(style.dim(` removed ${SECRETS_FILE} and its links`));
|
|
23228
|
+
}
|
|
23229
|
+
}
|
|
23230
|
+
// src/commands/open-requests/open-requests.command.ts
|
|
23231
|
+
const openRequestsCommand = {
|
|
23232
|
+
command: "requests",
|
|
23233
|
+
describe: "Open the request tool's workspace with its secrets filled in from the layer's vault Environment",
|
|
23234
|
+
builder: (y) => y.option("environment", {
|
|
23235
|
+
type: "string",
|
|
23236
|
+
describe: "The layer (`local`, `dev`, `ci`, `prod`) or Environment to read the secrets from (default: `dev`)"
|
|
23237
|
+
}).option("to", {
|
|
23238
|
+
type: "string",
|
|
23239
|
+
describe: "Open only for this tooling provider (needed when more than one can open its workspace)"
|
|
23240
|
+
}).option("yes", {
|
|
23241
|
+
type: "boolean",
|
|
23242
|
+
describe: "Go ahead without asking (required without a terminal)"
|
|
23243
|
+
}),
|
|
23244
|
+
handler: async (argv) => {
|
|
23245
|
+
const tokens = tokenContext(argv.token);
|
|
23246
|
+
if (!tokens) return;
|
|
23247
|
+
const loaded = await loadConfig(argv.cwd);
|
|
23248
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
23249
|
+
if ((await runOpenRequests({
|
|
23250
|
+
loaded,
|
|
23251
|
+
context: {
|
|
23252
|
+
repoRoot: argv.cwd,
|
|
23253
|
+
dryRun: argv.dryRun,
|
|
23254
|
+
...tokens,
|
|
23255
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
23256
|
+
},
|
|
23257
|
+
...argv.environment ? { environment: argv.environment } : {},
|
|
23258
|
+
...argv.to ? { to: argv.to } : {},
|
|
23259
|
+
...argv.yes ? { yes: true } : {}
|
|
23260
|
+
})).status === "fail") process.exitCode = 1;
|
|
23261
|
+
}
|
|
23262
|
+
};
|
|
23263
|
+
// src/commands/open/open.command.ts
|
|
23264
|
+
const openCommand = {
|
|
23265
|
+
command: "open",
|
|
23266
|
+
describe: "Open a tool with what it needs filled in from the vault",
|
|
23267
|
+
builder: (y) => y.command(openRequestsCommand).command(groupMenu("open")),
|
|
23268
|
+
handler: () => {}
|
|
23269
|
+
};
|
|
22694
23270
|
// src/commands/probe/probe.args.ts
|
|
22695
23271
|
/**
|
|
22696
23272
|
* Shown in `holocron probe --help`: how a probe about a token (`cloudflare token`) picks the token it checks, so the
|
|
@@ -30726,6 +31302,7 @@ const COMMAND_MODULES = [
|
|
|
30726
31302
|
cleanupCommand,
|
|
30727
31303
|
applyCommand,
|
|
30728
31304
|
newCommand,
|
|
31305
|
+
openCommand,
|
|
30729
31306
|
listCommand,
|
|
30730
31307
|
removeCommand,
|
|
30731
31308
|
probeCommand,
|