@theholocron/cli 5.0.0-alpha.481 → 5.0.0-alpha.483
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 +691 -131
- package/dist/cli.mjs.map +1 -1
- package/dist/{index-BEvR4K8m.d.mts → index-UQEV2tGX.d.mts} +90 -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 +9 -9
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",
|
|
@@ -107,6 +109,7 @@ const COMMAND_CONTEXTS = {
|
|
|
107
109
|
"doctor project": "workspace",
|
|
108
110
|
"doctor logs": "workspace",
|
|
109
111
|
"doctor wiki": "workspace",
|
|
112
|
+
"doctor errors": "workspace",
|
|
110
113
|
"doctor github-app": "workspace",
|
|
111
114
|
"move issues": "workspace",
|
|
112
115
|
"apply properties": "workspace",
|
|
@@ -383,6 +386,14 @@ const doctorEnvironmentsEntry = {
|
|
|
383
386
|
skipOptions: ["all", "repo"],
|
|
384
387
|
supportsDryRun: false
|
|
385
388
|
};
|
|
389
|
+
// src/commands/doctor-errors/doctor-errors.entry.ts
|
|
390
|
+
const doctorErrorsEntry = {
|
|
391
|
+
name: "doctor errors",
|
|
392
|
+
description: "Check the error tracker's organization, declared projects, keys and alert rules (read-only)",
|
|
393
|
+
positionals: [],
|
|
394
|
+
skipOptions: ["all", "repo"],
|
|
395
|
+
supportsDryRun: false
|
|
396
|
+
};
|
|
386
397
|
// src/commands/doctor-github-app/doctor-github-app.entry.ts
|
|
387
398
|
const doctorGitHubAppEntry = {
|
|
388
399
|
name: "doctor github-app",
|
|
@@ -1001,6 +1012,18 @@ const npmBumpVersionsEntry = {
|
|
|
1001
1012
|
],
|
|
1002
1013
|
supportsDryRun: true
|
|
1003
1014
|
};
|
|
1015
|
+
// src/commands/open-requests/open-requests.entry.ts
|
|
1016
|
+
const openRequestsEntry = {
|
|
1017
|
+
name: "open requests",
|
|
1018
|
+
description: "Open the request tool's workspace with its secrets filled in from the layer's vault Environment",
|
|
1019
|
+
positionals: [],
|
|
1020
|
+
skipOptions: [
|
|
1021
|
+
"yes",
|
|
1022
|
+
"to",
|
|
1023
|
+
"environment"
|
|
1024
|
+
],
|
|
1025
|
+
supportsDryRun: true
|
|
1026
|
+
};
|
|
1004
1027
|
// src/commands/plugin-create/plugin-create.entry.ts
|
|
1005
1028
|
const pluginCreateEntry = {
|
|
1006
1029
|
name: "new plugin",
|
|
@@ -1334,6 +1357,7 @@ const registry = createCommandRegistry([
|
|
|
1334
1357
|
doctorGitHubAppEntry,
|
|
1335
1358
|
doctorLogsEntry,
|
|
1336
1359
|
doctorWikiEntry,
|
|
1360
|
+
doctorErrorsEntry,
|
|
1337
1361
|
projectMoveEntry,
|
|
1338
1362
|
repoPropertiesApplyEntry,
|
|
1339
1363
|
migrateIssueEntry,
|
|
@@ -1588,6 +1612,7 @@ const registry = createCommandRegistry([
|
|
|
1588
1612
|
authListEntry,
|
|
1589
1613
|
authExportEntry,
|
|
1590
1614
|
requestsExportEntry,
|
|
1615
|
+
openRequestsEntry,
|
|
1591
1616
|
{
|
|
1592
1617
|
name: "upload coverage",
|
|
1593
1618
|
description: "Upload the repo's coverage reports, one flag per group, through the coverage provider",
|
|
@@ -7420,7 +7445,7 @@ async function runDoctorDns(input) {
|
|
|
7420
7445
|
});
|
|
7421
7446
|
else if (!loader.has("dns")) {
|
|
7422
7447
|
const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
|
|
7423
|
-
for (const zone of zones) rows.push(row$
|
|
7448
|
+
for (const zone of zones) rows.push(row$20(zone, "skip", why));
|
|
7424
7449
|
for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
|
|
7425
7450
|
} else {
|
|
7426
7451
|
const dns = loader.get("dns");
|
|
@@ -7442,7 +7467,7 @@ async function runDoctorDns(input) {
|
|
|
7442
7467
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
7443
7468
|
};
|
|
7444
7469
|
}
|
|
7445
|
-
function row$
|
|
7470
|
+
function row$20(zone, status, detail, problems = []) {
|
|
7446
7471
|
return {
|
|
7447
7472
|
id: `dns-${zone}`,
|
|
7448
7473
|
title: `${zone} records exist`,
|
|
@@ -7471,7 +7496,7 @@ async function checkDomain(dns, deploy, project, hostname) {
|
|
|
7471
7496
|
return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
|
|
7472
7497
|
}
|
|
7473
7498
|
}
|
|
7474
|
-
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$
|
|
7499
|
+
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$20(zone, ...args)) {
|
|
7475
7500
|
try {
|
|
7476
7501
|
const have = await dns.listRecords(zone);
|
|
7477
7502
|
const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
|
|
@@ -7581,6 +7606,130 @@ const doctorEnvironmentsCommand = {
|
|
|
7581
7606
|
})).status === "fail") process.exitCode = 1;
|
|
7582
7607
|
}
|
|
7583
7608
|
};
|
|
7609
|
+
// src/commands/doctor-errors/declared-projects.ts
|
|
7610
|
+
/**
|
|
7611
|
+
* The error tracker projects the config declares: every project a notifications layout's `relay.errors.projects`
|
|
7612
|
+
* sends alerts from, in order, each once.
|
|
7613
|
+
*/
|
|
7614
|
+
function declaredProjects(layouts) {
|
|
7615
|
+
return [...new Set(layouts.flatMap((layout) => layout.relay?.errors?.projects ?? []))];
|
|
7616
|
+
}
|
|
7617
|
+
// src/commands/doctor-errors/errors-rows.ts
|
|
7618
|
+
const row$19 = (id, title, status, detail, problems = []) => ({
|
|
7619
|
+
id,
|
|
7620
|
+
title,
|
|
7621
|
+
status,
|
|
7622
|
+
detail,
|
|
7623
|
+
problems
|
|
7624
|
+
});
|
|
7625
|
+
/**
|
|
7626
|
+
* The rows `holocron doctor errors` prints for one {@link ErrorsInspection}: the organization, then for each declared
|
|
7627
|
+
* project that it exists, has a client key and is watched by an enabled alert rule. Pure. A project missing, a project
|
|
7628
|
+
* with no key and a project no enabled rule watches fail; alert rules the token could not read are a skip. The Comlink
|
|
7629
|
+
* relay's integration and rule have their own rows in `doctor notifications`.
|
|
7630
|
+
*/
|
|
7631
|
+
function errorsRows(found, providerName) {
|
|
7632
|
+
const orgSlug = found.org.slug;
|
|
7633
|
+
if (!found.org.exists) {
|
|
7634
|
+
const problem = `${providerName} has no organization named ${orgSlug}; check the \`org\` option of the \`errors\` provider`;
|
|
7635
|
+
const rows = [row$19("errors:org", "organization exists", "fail", `${orgSlug} not found`, [problem])];
|
|
7636
|
+
for (const project of found.projects) rows.push(row$19(`errors:project:${project.slug}`, `project ${project.slug} exists`, "skip", "not checked: no organization"));
|
|
7637
|
+
return rows;
|
|
7638
|
+
}
|
|
7639
|
+
const rows = [row$19("errors:org", "organization exists", "ok", `${orgSlug} (${found.org.name ?? orgSlug})`)];
|
|
7640
|
+
if (found.projects.length === 0) {
|
|
7641
|
+
rows.push(row$19("errors:projects", "declared projects", "skip", "none declared: no `relay.errors.projects` in a layout"));
|
|
7642
|
+
return rows;
|
|
7643
|
+
}
|
|
7644
|
+
for (const project of found.projects) {
|
|
7645
|
+
const slug = project.slug;
|
|
7646
|
+
if (!project.exists) {
|
|
7647
|
+
const problem = `no project ${slug} in ${found.org.slug}; create it in ${providerName}`;
|
|
7648
|
+
rows.push(row$19(`errors:project:${slug}`, `project ${slug} exists`, "fail", "not found", [problem]), row$19(`errors:dsn:${slug}`, `project ${slug} has a key`, "skip", "not checked: no project"), row$19(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "skip", "not checked: no project"));
|
|
7649
|
+
continue;
|
|
7650
|
+
}
|
|
7651
|
+
rows.push(row$19(`errors:project:${slug}`, `project ${slug} exists`, "ok", slug));
|
|
7652
|
+
rows.push(project.hasDsn ? row$19(`errors:dsn:${slug}`, `project ${slug} has a key`, "ok", "a client key (DSN) exists") : row$19(`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}`]));
|
|
7653
|
+
if (project.alertRules === void 0) rows.push(row$19(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "skip", found.alertsUnreadable ? `could not read the alert rules: ${found.alertsUnreadable}` : "not read"));
|
|
7654
|
+
else if (project.alertRules === 0) rows.push(row$19(`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`]));
|
|
7655
|
+
else rows.push(row$19(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "ok", `${project.alertRules} enabled rule(s)`));
|
|
7656
|
+
}
|
|
7657
|
+
return rows;
|
|
7658
|
+
}
|
|
7659
|
+
// src/commands/doctor-errors/doctor-errors.ts
|
|
7660
|
+
/**
|
|
7661
|
+
* `holocron doctor errors` — does the error tracker the config declares have the organization, projects, keys and
|
|
7662
|
+
* alert rules it relies on?
|
|
7663
|
+
*
|
|
7664
|
+
* Read-only: it never creates a project or a rule, and prints names and counts only, never a DSN, a key or a token.
|
|
7665
|
+
* The rows (`errorsRows()`): the organization; for each project a notifications layout's `relay.errors.projects`
|
|
7666
|
+
* declares, that it exists, has a client key and is watched by an enabled alert rule. The Comlink relay's own
|
|
7667
|
+
* integration and rule are `doctor notifications`' rows and are not repeated. A project the provider says is missing
|
|
7668
|
+
* fails; anything that cannot be read (no token, no `org`, a token without the alert scope) is a skip with the reason.
|
|
7669
|
+
*/
|
|
7670
|
+
const skip$1 = (detail) => ({
|
|
7671
|
+
id: "errors",
|
|
7672
|
+
title: "errors",
|
|
7673
|
+
status: "skip",
|
|
7674
|
+
detail,
|
|
7675
|
+
problems: []
|
|
7676
|
+
});
|
|
7677
|
+
async function runDoctorErrors(input) {
|
|
7678
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
7679
|
+
const logger = input.logger ?? getLogger();
|
|
7680
|
+
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
7681
|
+
await loader.load();
|
|
7682
|
+
assertPluginsResolvable(loader, "doctor errors");
|
|
7683
|
+
let rows;
|
|
7684
|
+
if (!loader.has("errors")) {
|
|
7685
|
+
const failure = loader.loadFailures().find((f) => f.key === "errors");
|
|
7686
|
+
rows = [skip$1(failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `errors` provider is configured in holocron.config.ts")];
|
|
7687
|
+
} else {
|
|
7688
|
+
const errors = loader.get("errors");
|
|
7689
|
+
if (!errors.inspect) rows = [skip$1(`${errors.providerName} cannot read its organization`)];
|
|
7690
|
+
else {
|
|
7691
|
+
const layouts = (loader.has("notifications") ? loader.get("notifications") : []).flatMap((p) => p.layout ? [p.layout] : []);
|
|
7692
|
+
try {
|
|
7693
|
+
rows = errorsRows(await errors.inspect({ projects: declaredProjects(layouts) }), errors.providerName);
|
|
7694
|
+
} catch (err) {
|
|
7695
|
+
rows = [skip$1(missingTokenReason(err) ?? `could not read ${errors.providerName}: ${describeError(err)}`)];
|
|
7696
|
+
}
|
|
7697
|
+
}
|
|
7698
|
+
}
|
|
7699
|
+
printCheckRows(rows, print);
|
|
7700
|
+
const summary = summariseChecks(rows);
|
|
7701
|
+
printCheckSummary(summary, print);
|
|
7702
|
+
const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
|
|
7703
|
+
logger.info({
|
|
7704
|
+
...summary,
|
|
7705
|
+
status
|
|
7706
|
+
}, "doctor errors");
|
|
7707
|
+
return {
|
|
7708
|
+
status,
|
|
7709
|
+
rows,
|
|
7710
|
+
summary,
|
|
7711
|
+
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
7712
|
+
};
|
|
7713
|
+
}
|
|
7714
|
+
// src/commands/doctor-errors/doctor-errors.command.ts
|
|
7715
|
+
const doctorErrorsCommand = {
|
|
7716
|
+
command: "errors",
|
|
7717
|
+
describe: "Check the error tracker's organization, declared projects, keys and alert rules (read-only)",
|
|
7718
|
+
handler: async (argv) => {
|
|
7719
|
+
const tokens = tokenContext(argv.token);
|
|
7720
|
+
if (!tokens) return;
|
|
7721
|
+
const loaded = await loadConfig(argv.cwd);
|
|
7722
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
7723
|
+
if ((await runDoctorErrors({
|
|
7724
|
+
loaded,
|
|
7725
|
+
context: {
|
|
7726
|
+
repoRoot: argv.cwd,
|
|
7727
|
+
...tokens,
|
|
7728
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
7729
|
+
}
|
|
7730
|
+
})).status === "fail") process.exitCode = 1;
|
|
7731
|
+
}
|
|
7732
|
+
};
|
|
7584
7733
|
// src/commands/doctor-github-app/permission-gaps.ts
|
|
7585
7734
|
const LEVELS$1 = [
|
|
7586
7735
|
"read",
|
|
@@ -7606,7 +7755,7 @@ function installationSettingsUrl(account, id) {
|
|
|
7606
7755
|
return `https://github.com/settings/installations/${id}`;
|
|
7607
7756
|
}
|
|
7608
7757
|
// src/commands/doctor-github-app/app-rows.ts
|
|
7609
|
-
const row$
|
|
7758
|
+
const row$18 = (name, what, problems, ok) => ({
|
|
7610
7759
|
id: `${name}:${what}`,
|
|
7611
7760
|
title: `${name}: ${what}`,
|
|
7612
7761
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -7633,9 +7782,9 @@ function appRows(name, manifest, app, installations) {
|
|
|
7633
7782
|
return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
|
|
7634
7783
|
});
|
|
7635
7784
|
return [
|
|
7636
|
-
row$
|
|
7637
|
-
row$
|
|
7638
|
-
row$
|
|
7785
|
+
row$18(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
|
|
7786
|
+
row$18(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
|
|
7787
|
+
row$18(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
|
|
7639
7788
|
];
|
|
7640
7789
|
}
|
|
7641
7790
|
// src/commands/doctor-github-app/parse-manifest.ts
|
|
@@ -7693,7 +7842,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
7693
7842
|
assertPluginsResolvable(loader, "doctor github-app");
|
|
7694
7843
|
}
|
|
7695
7844
|
const rows = [];
|
|
7696
|
-
if (instances.length === 0) rows.push(row$
|
|
7845
|
+
if (instances.length === 0) rows.push(row$17("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
|
|
7697
7846
|
for (const instance of instances) rows.push(...await checkInstance(instance, loader, input));
|
|
7698
7847
|
printCheckRows(rows, print);
|
|
7699
7848
|
const summary = summariseChecks(rows);
|
|
@@ -7710,7 +7859,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
7710
7859
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
7711
7860
|
};
|
|
7712
7861
|
}
|
|
7713
|
-
function row$
|
|
7862
|
+
function row$17(name, what, status, detail) {
|
|
7714
7863
|
return {
|
|
7715
7864
|
id: `${name}:${what}`,
|
|
7716
7865
|
title: `${name}: ${what}`,
|
|
@@ -7751,19 +7900,19 @@ async function checkInstance(instance, loader, input) {
|
|
|
7751
7900
|
try {
|
|
7752
7901
|
manifest = parseManifest(readManifest(instance.manifest));
|
|
7753
7902
|
} catch (err) {
|
|
7754
|
-
return [row$
|
|
7903
|
+
return [row$17(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
|
|
7755
7904
|
}
|
|
7756
7905
|
const read = await readCredentials(instance, loader);
|
|
7757
|
-
if ("reason" in read) return [row$
|
|
7906
|
+
if ("reason" in read) return [row$17(name, "reachable", "skip", read.reason)];
|
|
7758
7907
|
const api = input.api ?? defaultApi;
|
|
7759
7908
|
const secrets = [read.creds.privateKey];
|
|
7760
7909
|
try {
|
|
7761
7910
|
const app = await api.getApp(read.creds);
|
|
7762
7911
|
const installations = await api.listAppInstallations(read.creds);
|
|
7763
7912
|
const owner = app.owner ? `, owned by ${app.owner.login}` : "";
|
|
7764
|
-
return [row$
|
|
7913
|
+
return [row$17(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
|
|
7765
7914
|
} catch (err) {
|
|
7766
|
-
return [row$
|
|
7915
|
+
return [row$17(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
|
|
7767
7916
|
}
|
|
7768
7917
|
}
|
|
7769
7918
|
// src/commands/doctor-github-app/doctor-github-app.command.ts
|
|
@@ -7830,7 +7979,7 @@ function datasetTargets(config) {
|
|
|
7830
7979
|
* dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
|
|
7831
7980
|
* 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.
|
|
7832
7981
|
*/
|
|
7833
|
-
const row$
|
|
7982
|
+
const row$16 = (id, title, status, detail, problems = []) => ({
|
|
7834
7983
|
id,
|
|
7835
7984
|
title,
|
|
7836
7985
|
status,
|
|
@@ -7847,7 +7996,7 @@ async function runDoctorLogs(input) {
|
|
|
7847
7996
|
if (!loader.has("logs")) {
|
|
7848
7997
|
const failure = loader.loadFailures().find((f) => f.key === "logs");
|
|
7849
7998
|
const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
|
|
7850
|
-
rows.push(row$
|
|
7999
|
+
rows.push(row$16("logs", "logs", "skip", why));
|
|
7851
8000
|
} else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
|
|
7852
8001
|
printCheckRows(rows, print);
|
|
7853
8002
|
const summary = summariseChecks(rows);
|
|
@@ -7871,38 +8020,38 @@ async function checkLogs(logs, targets) {
|
|
|
7871
8020
|
for (const target of targets) {
|
|
7872
8021
|
const id = `logs:dataset:${target.id}`;
|
|
7873
8022
|
const title = `dataset for ${target.label}`;
|
|
7874
|
-
if (!target.name) rows.push(row$
|
|
7875
|
-
else if (!token.usable) rows.push(row$
|
|
7876
|
-
else if (!logs.readDataset) rows.push(row$
|
|
8023
|
+
if (!target.name) rows.push(row$16(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
|
|
8024
|
+
else if (!token.usable) rows.push(row$16(id, title, "skip", `${target.name}: not checked, the token is not usable`));
|
|
8025
|
+
else if (!logs.readDataset) rows.push(row$16(id, title, "skip", `${logs.providerName} cannot read a dataset`));
|
|
7877
8026
|
else rows.push(...await checkDataset(logs, target, target.name, id, title));
|
|
7878
8027
|
}
|
|
7879
8028
|
const org = resolveValue$1(["AXIOM_ORG"], void 0, { prefix: PREFIX$1 });
|
|
7880
|
-
rows.push(org ? row$
|
|
8029
|
+
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`));
|
|
7881
8030
|
return rows;
|
|
7882
8031
|
}
|
|
7883
8032
|
/** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
|
|
7884
8033
|
async function checkToken$1(logs, dataset) {
|
|
7885
8034
|
const title = "token is accepted";
|
|
7886
8035
|
if (!logs.checkToken) return {
|
|
7887
|
-
row: row$
|
|
8036
|
+
row: row$16("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
|
|
7888
8037
|
usable: true
|
|
7889
8038
|
};
|
|
7890
8039
|
try {
|
|
7891
8040
|
const result = await logs.checkToken(dataset);
|
|
7892
8041
|
if (result.ok) return {
|
|
7893
|
-
row: row$
|
|
8042
|
+
row: row$16("logs:token", title, "ok", `${logs.providerName} accepts the token`),
|
|
7894
8043
|
usable: true
|
|
7895
8044
|
};
|
|
7896
8045
|
const reason = result.reason ?? `${logs.providerName} refused the token`;
|
|
7897
8046
|
return {
|
|
7898
|
-
row: row$
|
|
8047
|
+
row: row$16("logs:token", title, "fail", reason, [reason]),
|
|
7899
8048
|
usable: false
|
|
7900
8049
|
};
|
|
7901
8050
|
} catch (err) {
|
|
7902
8051
|
const noToken = missingTokenReason(err);
|
|
7903
8052
|
const detail = noToken ?? `could not check the token: ${describeError(err)}`;
|
|
7904
8053
|
return {
|
|
7905
|
-
row: row$
|
|
8054
|
+
row: row$16("logs:token", title, "skip", detail),
|
|
7906
8055
|
usable: noToken === void 0
|
|
7907
8056
|
};
|
|
7908
8057
|
}
|
|
@@ -7912,17 +8061,17 @@ async function checkDataset(logs, target, name, id, title) {
|
|
|
7912
8061
|
const found = await logs.readDataset(name);
|
|
7913
8062
|
if (found.forbidden) {
|
|
7914
8063
|
const why = `${name}: not visible to this token (${logs.providerName} refused the read; it may also not exist)`;
|
|
7915
|
-
return [row$
|
|
8064
|
+
return [row$16(id, title, "skip", why)];
|
|
7916
8065
|
}
|
|
7917
8066
|
if (!found.exists) {
|
|
7918
8067
|
const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
|
|
7919
|
-
return [row$
|
|
8068
|
+
return [row$16(id, title, "fail", `${name} does not exist`, [problem])];
|
|
7920
8069
|
}
|
|
7921
8070
|
const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
|
|
7922
|
-
return [row$
|
|
8071
|
+
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)`)];
|
|
7923
8072
|
} catch (err) {
|
|
7924
8073
|
const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
|
|
7925
|
-
return [row$
|
|
8074
|
+
return [row$16(id, title, "skip", detail)];
|
|
7926
8075
|
}
|
|
7927
8076
|
}
|
|
7928
8077
|
// src/commands/doctor-logs/doctor-logs.command.ts
|
|
@@ -11126,7 +11275,7 @@ const info = (id, title, noun, extras) => ({
|
|
|
11126
11275
|
detail: `info: ${extras.length} ${noun} not in the template (never deleted)`,
|
|
11127
11276
|
problems: extras
|
|
11128
11277
|
});
|
|
11129
|
-
const row$
|
|
11278
|
+
const row$15 = (id, title, problems, ok) => ({
|
|
11130
11279
|
id,
|
|
11131
11280
|
title,
|
|
11132
11281
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -11162,19 +11311,19 @@ function viewProblems(want, found) {
|
|
|
11162
11311
|
function boardRows(boardName, template, state) {
|
|
11163
11312
|
const id = `project:${boardName}`;
|
|
11164
11313
|
const rows = [];
|
|
11165
|
-
rows.push(row$
|
|
11314
|
+
rows.push(row$15(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
|
|
11166
11315
|
const extraStatuses = state.statuses.filter((s) => !template.statuses.some((t) => t.name === s));
|
|
11167
11316
|
if (extraStatuses.length > 0) rows.push(info(`${id}:extra-statuses`, `${boardName}: extra statuses`, "status(es)", extraStatuses));
|
|
11168
|
-
for (const want of template.fields) rows.push(row$
|
|
11317
|
+
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));
|
|
11169
11318
|
const extraFields = state.fields.filter((f) => !template.fields.some((t) => t.name === f.name));
|
|
11170
11319
|
if (extraFields.length > 0) rows.push(info(`${id}:extra-fields`, `${boardName}: extra fields`, "field(s)", extraFields.map((f) => f.name)));
|
|
11171
|
-
for (const want of template.views) rows.push(row$
|
|
11320
|
+
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}` : ""}`));
|
|
11172
11321
|
const extraViews = state.views.filter((v) => !template.views.some((t) => t.name === v.name));
|
|
11173
11322
|
if (extraViews.length > 0) rows.push(info(`${id}:extra-views`, `${boardName}: extra views`, "view(s)", extraViews.map((v) => v.name)));
|
|
11174
11323
|
for (const name of template.rules ?? []) {
|
|
11175
11324
|
const found = state.rules.find((r) => r.name === name);
|
|
11176
11325
|
const problems = !found ? [`missing rule ${name}`] : found.enabled ? [] : [`rule ${name} is off`];
|
|
11177
|
-
rows.push(row$
|
|
11326
|
+
rows.push(row$15(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
|
|
11178
11327
|
}
|
|
11179
11328
|
return rows;
|
|
11180
11329
|
}
|
|
@@ -11234,7 +11383,7 @@ function itemRows(boardName, items) {
|
|
|
11234
11383
|
* never fail the run. A template file that does not read is a failure naming the file. `--post [channel]` shares the
|
|
11235
11384
|
* failing rows through the `notifications` provider's bot, like `doctor notifications --post`.
|
|
11236
11385
|
*/
|
|
11237
|
-
const row$
|
|
11386
|
+
const row$14 = (id, title, status, detail, problems = []) => ({
|
|
11238
11387
|
id,
|
|
11239
11388
|
title,
|
|
11240
11389
|
status,
|
|
@@ -11288,14 +11437,14 @@ async function checkBoards(input, loader) {
|
|
|
11288
11437
|
loader,
|
|
11289
11438
|
...input.io ? { io: input.io } : {}
|
|
11290
11439
|
});
|
|
11291
|
-
if (!opened.ok) return [row$
|
|
11440
|
+
if (!opened.ok) return [row$14("project", "project", opened.kind, opened.reason, opened.problems)];
|
|
11292
11441
|
const { projects, owner, boards, templates, templateProblems } = opened.context;
|
|
11293
11442
|
const rows = templateProblems.map((problem) => {
|
|
11294
11443
|
/* v8 ignore next -- split always returns at least one element; the fallback only satisfies noUncheckedIndexedAccess */
|
|
11295
11444
|
const file = problem.split(": ")[0] ?? problem;
|
|
11296
|
-
return row$
|
|
11445
|
+
return row$14(`project:template:${file}`, `template file ${file}`, "fail", problem);
|
|
11297
11446
|
});
|
|
11298
|
-
if (boards.length === 0) return [...rows, row$
|
|
11447
|
+
if (boards.length === 0) return [...rows, row$14("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
|
|
11299
11448
|
for (const declared of boards) {
|
|
11300
11449
|
const template = templates[declared.template];
|
|
11301
11450
|
const title = `${declared.name}: board exists and is open`;
|
|
@@ -11303,18 +11452,18 @@ async function checkBoards(input, loader) {
|
|
|
11303
11452
|
const board = await projects.find(owner, declared.name);
|
|
11304
11453
|
if (!board) {
|
|
11305
11454
|
const closed = (await projects.list(owner)).some((b) => b.name === declared.name && b.closed);
|
|
11306
|
-
rows.push(row$
|
|
11455
|
+
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`"]));
|
|
11307
11456
|
continue;
|
|
11308
11457
|
}
|
|
11309
|
-
rows.push(row$
|
|
11458
|
+
rows.push(row$14(`project:${declared.name}`, title, "ok", board.url));
|
|
11310
11459
|
if (!template) {
|
|
11311
|
-
rows.push(row$
|
|
11460
|
+
rows.push(row$14(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
|
|
11312
11461
|
continue;
|
|
11313
11462
|
}
|
|
11314
11463
|
rows.push(...boardRows(declared.name, template, await projects.read(owner, board)));
|
|
11315
|
-
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$
|
|
11464
|
+
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")]);
|
|
11316
11465
|
} catch (err) {
|
|
11317
|
-
rows.push(row$
|
|
11466
|
+
rows.push(row$14(`project:${declared.name}`, title, "fail", describeError(err)));
|
|
11318
11467
|
}
|
|
11319
11468
|
}
|
|
11320
11469
|
return rows;
|
|
@@ -11404,14 +11553,14 @@ function parseTagList(output) {
|
|
|
11404
11553
|
}];
|
|
11405
11554
|
});
|
|
11406
11555
|
}
|
|
11407
|
-
const defaultDeps = {
|
|
11556
|
+
const defaultDeps$1 = {
|
|
11408
11557
|
spawn: (command, args, options) => spawnSync(command, args, options),
|
|
11409
11558
|
fetch: (url) => fetch(url),
|
|
11410
11559
|
discover: discoverPublicPackages,
|
|
11411
11560
|
nowMs: () => Date.now()
|
|
11412
11561
|
};
|
|
11413
11562
|
/** `doctor releases`' inputs from the real git checkout under `repoRoot`, the npm registry and the workspace. */
|
|
11414
|
-
function realReleasesIo(repoRoot, deps = defaultDeps) {
|
|
11563
|
+
function realReleasesIo(repoRoot, deps = defaultDeps$1) {
|
|
11415
11564
|
return {
|
|
11416
11565
|
tags: () => {
|
|
11417
11566
|
const result = deps.spawn("git", [
|
|
@@ -12234,19 +12383,19 @@ async function runDoctorRepo(input) {
|
|
|
12234
12383
|
const rows = [];
|
|
12235
12384
|
if (!loader.has("source")) {
|
|
12236
12385
|
const why = whyMissing(loader, "source", "no `source` provider to read the repository with");
|
|
12237
|
-
for (const check of checks) rows.push(row$
|
|
12386
|
+
for (const check of checks) rows.push(row$13(check, { skip: why }));
|
|
12238
12387
|
} else {
|
|
12239
12388
|
const source = loader.get("source");
|
|
12240
12389
|
for (const check of checks) {
|
|
12241
12390
|
if (typeof source[check.needs] !== "function") {
|
|
12242
|
-
rows.push(row$
|
|
12391
|
+
rows.push(row$13(check, { skip: `provider does not implement ${check.needs}` }));
|
|
12243
12392
|
continue;
|
|
12244
12393
|
}
|
|
12245
12394
|
try {
|
|
12246
|
-
rows.push(row$
|
|
12395
|
+
rows.push(row$13(check, await check.run(source)));
|
|
12247
12396
|
} catch (err) {
|
|
12248
12397
|
const noToken = missingTokenReason(err);
|
|
12249
|
-
if (noToken !== void 0) rows.push(row$
|
|
12398
|
+
if (noToken !== void 0) rows.push(row$13(check, { skip: noToken }));
|
|
12250
12399
|
else rows.push({
|
|
12251
12400
|
id: check.id,
|
|
12252
12401
|
title: check.title,
|
|
@@ -12272,7 +12421,7 @@ async function runDoctorRepo(input) {
|
|
|
12272
12421
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
12273
12422
|
};
|
|
12274
12423
|
}
|
|
12275
|
-
function row$
|
|
12424
|
+
function row$13(check, result) {
|
|
12276
12425
|
const { id, title } = check;
|
|
12277
12426
|
if ("skip" in result) return {
|
|
12278
12427
|
id,
|
|
@@ -12795,7 +12944,7 @@ function providerGroup(providerName) {
|
|
|
12795
12944
|
}
|
|
12796
12945
|
// src/commands/doctor-secrets/credentials-rows.ts
|
|
12797
12946
|
/** A row for the provider as a whole, or for one of its variables when `name` is given. */
|
|
12798
|
-
function row$
|
|
12947
|
+
function row$12(provider, status, detail, name) {
|
|
12799
12948
|
return name === void 0 ? {
|
|
12800
12949
|
id: provider,
|
|
12801
12950
|
title: provider,
|
|
@@ -12820,10 +12969,10 @@ async function credentialsRows(input) {
|
|
|
12820
12969
|
const { loader } = input;
|
|
12821
12970
|
const { resolved } = input.loaded;
|
|
12822
12971
|
if (!resolved.providers.credentials) return {
|
|
12823
|
-
rows: input.asked ? [row$
|
|
12972
|
+
rows: input.asked ? [row$12("credentials", "skip", "no `credentials` provider is configured")] : [],
|
|
12824
12973
|
places: []
|
|
12825
12974
|
};
|
|
12826
|
-
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$
|
|
12975
|
+
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$12(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
|
|
12827
12976
|
const places = [];
|
|
12828
12977
|
if (!loader.has("credentials")) return {
|
|
12829
12978
|
rows,
|
|
@@ -12835,7 +12984,7 @@ async function credentialsRows(input) {
|
|
|
12835
12984
|
const tuple = tuples.find((t) => t.provider === impl.providerName);
|
|
12836
12985
|
const explicit = tuple && credentialsEnvironment(tuple, resolved);
|
|
12837
12986
|
if (!explicit && !derivesEnvironment(impl.providerName)) {
|
|
12838
|
-
rows.push(row$
|
|
12987
|
+
rows.push(row$12(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
|
|
12839
12988
|
continue;
|
|
12840
12989
|
}
|
|
12841
12990
|
try {
|
|
@@ -12847,7 +12996,7 @@ async function credentialsRows(input) {
|
|
|
12847
12996
|
rows.push(...checked.rows);
|
|
12848
12997
|
places.push(...checked.places);
|
|
12849
12998
|
} catch (err) {
|
|
12850
|
-
rows.push(row$
|
|
12999
|
+
rows.push(row$12(impl.providerName, "fail", errorMessage(err)));
|
|
12851
13000
|
}
|
|
12852
13001
|
}
|
|
12853
13002
|
return {
|
|
@@ -12863,17 +13012,17 @@ async function credentialsRows(input) {
|
|
|
12863
13012
|
async function checkProvider(impl, candidates, expected, synced) {
|
|
12864
13013
|
const provider = impl.providerName;
|
|
12865
13014
|
if (!impl.inspect) return {
|
|
12866
|
-
rows: [row$
|
|
13015
|
+
rows: [row$12(provider, "skip", "cannot list the variables without reading their values")],
|
|
12867
13016
|
places: []
|
|
12868
13017
|
};
|
|
12869
13018
|
if (expected.length === 0) return {
|
|
12870
|
-
rows: [row$
|
|
13019
|
+
rows: [row$12(provider, "skip", "no configured plugin lists the tokens it takes")],
|
|
12871
13020
|
places: []
|
|
12872
13021
|
};
|
|
12873
13022
|
const inspect = impl.inspect.bind(impl);
|
|
12874
13023
|
try {
|
|
12875
13024
|
const { found, missing } = await tryEnvironments(candidates, inspect);
|
|
12876
|
-
const rows = missing.map((name) => row$
|
|
13025
|
+
const rows = missing.map((name) => row$12(provider, "fail", `${provider} has no Environment named "${name}"`));
|
|
12877
13026
|
const group = providerGroup(provider);
|
|
12878
13027
|
const unreadPlaces = missing.map((name) => ({
|
|
12879
13028
|
column: {
|
|
@@ -12896,9 +13045,9 @@ async function checkProvider(impl, candidates, expected, synced) {
|
|
|
12896
13045
|
const have = (name) => found.some((f) => f.result.names.includes(name));
|
|
12897
13046
|
let present = 0;
|
|
12898
13047
|
for (const { name, optional } of expected) if (have(name)) present++;
|
|
12899
|
-
else if (optional) rows.push(row$
|
|
12900
|
-
else rows.push(row$
|
|
12901
|
-
if (present > 0) rows.push(row$
|
|
13048
|
+
else if (optional) rows.push(row$12(provider, "skip", `optional, not set in ${where}`, name));
|
|
13049
|
+
else rows.push(row$12(provider, "fail", `missing from ${where}`, name));
|
|
13050
|
+
if (present > 0) rows.push(row$12(provider, "ok", `${present} of ${expected.length} tokens present in ${where}`, "tokens"));
|
|
12902
13051
|
const names = new Set(expected.map((e) => e.name));
|
|
12903
13052
|
const places = [];
|
|
12904
13053
|
const missingRequired = expected.filter((e) => !e.optional && !have(e.name)).map((e) => e.name);
|
|
@@ -12937,7 +13086,7 @@ async function checkProvider(impl, candidates, expected, synced) {
|
|
|
12937
13086
|
};
|
|
12938
13087
|
} catch (err) {
|
|
12939
13088
|
return {
|
|
12940
|
-
rows: [row$
|
|
13089
|
+
rows: [row$12(provider, "fail", errorMessage(err))],
|
|
12941
13090
|
places: []
|
|
12942
13091
|
};
|
|
12943
13092
|
}
|
|
@@ -13811,7 +13960,7 @@ async function variableRows(loader, config, org) {
|
|
|
13811
13960
|
if (!loader.has("source")) {
|
|
13812
13961
|
const why = whyMissing(loader, "source", "no `source` provider to read them with");
|
|
13813
13962
|
for (const check of checks) {
|
|
13814
|
-
rows.push(row$
|
|
13963
|
+
rows.push(row$11(check, { skip: why }));
|
|
13815
13964
|
observations.push({
|
|
13816
13965
|
scope: check.scope,
|
|
13817
13966
|
unread: why
|
|
@@ -13821,7 +13970,7 @@ async function variableRows(loader, config, org) {
|
|
|
13821
13970
|
const source = loader.get("source");
|
|
13822
13971
|
for (const check of checks) try {
|
|
13823
13972
|
const result = await check.run(source);
|
|
13824
|
-
rows.push(row$
|
|
13973
|
+
rows.push(row$11(check, result));
|
|
13825
13974
|
observations.push("skip" in result ? {
|
|
13826
13975
|
scope: check.scope,
|
|
13827
13976
|
unread: result.skip
|
|
@@ -13832,7 +13981,7 @@ async function variableRows(loader, config, org) {
|
|
|
13832
13981
|
} catch (err) {
|
|
13833
13982
|
const noToken = missingTokenReason(err);
|
|
13834
13983
|
if (noToken !== void 0) {
|
|
13835
|
-
rows.push(row$
|
|
13984
|
+
rows.push(row$11(check, { skip: noToken }));
|
|
13836
13985
|
observations.push({
|
|
13837
13986
|
scope: check.scope,
|
|
13838
13987
|
unread: noToken
|
|
@@ -13858,7 +14007,7 @@ async function variableRows(loader, config, org) {
|
|
|
13858
14007
|
observations
|
|
13859
14008
|
};
|
|
13860
14009
|
}
|
|
13861
|
-
function row$
|
|
14010
|
+
function row$11(check, result) {
|
|
13862
14011
|
const { id, title } = check;
|
|
13863
14012
|
if ("skip" in result) return {
|
|
13864
14013
|
id,
|
|
@@ -13948,7 +14097,7 @@ function describeExpiry(expiresAt, now) {
|
|
|
13948
14097
|
*
|
|
13949
14098
|
* What a token may do is not checked: GitHub does not return a fine-grained token's permissions.
|
|
13950
14099
|
*/
|
|
13951
|
-
function row$
|
|
14100
|
+
function row$10(id, status, detail) {
|
|
13952
14101
|
return {
|
|
13953
14102
|
id: `verify:${id}`,
|
|
13954
14103
|
title: `verify ${id}`,
|
|
@@ -13976,12 +14125,12 @@ async function verifyRows(input) {
|
|
|
13976
14125
|
try {
|
|
13977
14126
|
module = await importer(pkg);
|
|
13978
14127
|
} catch (err) {
|
|
13979
|
-
rows.push(row$
|
|
14128
|
+
rows.push(row$10(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
|
|
13980
14129
|
continue;
|
|
13981
14130
|
}
|
|
13982
14131
|
for (const token of module.tokens ?? []) rows.push(await checkToken(token, module, env, readToken, now()));
|
|
13983
14132
|
}
|
|
13984
|
-
if (rows.length === 0) rows.push(row$
|
|
14133
|
+
if (rows.length === 0) rows.push(row$10("tokens", "skip", "no configured plugin lists the tokens it takes"));
|
|
13985
14134
|
return rows;
|
|
13986
14135
|
}
|
|
13987
14136
|
/**
|
|
@@ -13994,30 +14143,30 @@ async function loadCredentials(input) {
|
|
|
13994
14143
|
try {
|
|
13995
14144
|
await input.loader.load();
|
|
13996
14145
|
} catch (err) {
|
|
13997
|
-
return [row$
|
|
14146
|
+
return [row$10("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
|
|
13998
14147
|
}
|
|
13999
|
-
return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$
|
|
14148
|
+
return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$10(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
|
|
14000
14149
|
}
|
|
14001
14150
|
async function checkToken(token, module, env, readToken, now) {
|
|
14002
14151
|
const { keyringKey, envName, vendorEnvName } = token;
|
|
14003
14152
|
const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
|
|
14004
14153
|
const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
|
|
14005
14154
|
const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
|
|
14006
|
-
if (!value) return row$
|
|
14155
|
+
if (!value) return row$10(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
|
|
14007
14156
|
const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
|
|
14008
|
-
if (!verify) return row$
|
|
14157
|
+
if (!verify) return row$10(keyringKey, "skip", "set, but its plugin cannot verify it");
|
|
14009
14158
|
const from = fromEnv ?? stored?.source ?? "keyring";
|
|
14010
14159
|
try {
|
|
14011
14160
|
const verified = await verify(value);
|
|
14012
|
-
if (!verified.ok) return row$
|
|
14161
|
+
if (!verified.ok) return row$10(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
|
|
14013
14162
|
const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
|
|
14014
|
-
if (!expiry) return row$
|
|
14163
|
+
if (!expiry) return row$10(keyringKey, "ok", `${verified.subject} (${from})`);
|
|
14015
14164
|
return expiry.soon ? {
|
|
14016
|
-
...row$
|
|
14165
|
+
...row$10(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
|
|
14017
14166
|
problems: [`${expiry.text}: renew it`]
|
|
14018
|
-
} : row$
|
|
14167
|
+
} : row$10(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
|
|
14019
14168
|
} catch (err) {
|
|
14020
|
-
return row$
|
|
14169
|
+
return row$10(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
|
|
14021
14170
|
}
|
|
14022
14171
|
}
|
|
14023
14172
|
// src/commands/doctor-secrets/doctor-secrets.ts
|
|
@@ -14744,7 +14893,7 @@ function summariseProbeRows(id, title, rows) {
|
|
|
14744
14893
|
* provider with no `token` probe, no declared layer, or one that cannot be read is a skip with the reason.
|
|
14745
14894
|
*/
|
|
14746
14895
|
const PROBE = "token";
|
|
14747
|
-
const row$
|
|
14896
|
+
const row$9 = (id, title, status, detail, problems = []) => ({
|
|
14748
14897
|
id,
|
|
14749
14898
|
title,
|
|
14750
14899
|
status,
|
|
@@ -14769,12 +14918,12 @@ async function runDoctorTokens(input) {
|
|
|
14769
14918
|
try {
|
|
14770
14919
|
tokens = await providerTokens(provider);
|
|
14771
14920
|
} catch (err) {
|
|
14772
|
-
rows.push(row$
|
|
14921
|
+
rows.push(row$9(`tokens:${provider}`, provider, "skip", `could not read its tokens: ${describeError(err)}`));
|
|
14773
14922
|
continue;
|
|
14774
14923
|
}
|
|
14775
14924
|
const expectations = tokenExpectations(tokens);
|
|
14776
|
-
if (expectations.length === 0) rows.push(row$
|
|
14777
|
-
else if (!usableProbe(probes.get(provider))) rows.push(row$
|
|
14925
|
+
if (expectations.length === 0) rows.push(row$9(`tokens:${provider}`, provider, "skip", "info: declares no token layers, nothing to check"));
|
|
14926
|
+
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`));
|
|
14778
14927
|
else declared.push({
|
|
14779
14928
|
provider,
|
|
14780
14929
|
tokens,
|
|
@@ -14836,14 +14985,14 @@ async function checkLayer(c) {
|
|
|
14836
14985
|
tokens
|
|
14837
14986
|
});
|
|
14838
14987
|
} catch (err) {
|
|
14839
|
-
if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$
|
|
14840
|
-
return c.wanted.map((e) => row$
|
|
14988
|
+
if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$9(id(e), title(e), "fail", "not held in this layer", [err.message]));
|
|
14989
|
+
return c.wanted.map((e) => row$9(id(e), title(e), "skip", `could not read the Environment: ${describeError(err)}`));
|
|
14841
14990
|
}
|
|
14842
14991
|
const rows = [];
|
|
14843
14992
|
for (const e of c.wanted) {
|
|
14844
14993
|
const token = held.held.find((h) => h.envName === e.envName);
|
|
14845
14994
|
if (!token) {
|
|
14846
|
-
rows.push(row$
|
|
14995
|
+
rows.push(row$9(id(e), title(e), "fail", `not held in ${held.environment}`, [`${e.envName} is declared for ${c.layer}`]));
|
|
14847
14996
|
continue;
|
|
14848
14997
|
}
|
|
14849
14998
|
rows.push(summariseProbeRows(id(e), title(e), await probeToken(c, e, token.token, held.plain)));
|
|
@@ -14916,7 +15065,7 @@ const doctorTokensCommand = {
|
|
|
14916
15065
|
}
|
|
14917
15066
|
};
|
|
14918
15067
|
// src/commands/doctor-wiki/wiki-rows.ts
|
|
14919
|
-
const row$
|
|
15068
|
+
const row$8 = (id, title, status, detail, problems = []) => ({
|
|
14920
15069
|
id,
|
|
14921
15070
|
title,
|
|
14922
15071
|
status,
|
|
@@ -14932,11 +15081,11 @@ const names = (paths) => paths.length > LISTED ? `${paths.slice(0, LISTED).join(
|
|
|
14932
15081
|
* skip, since a machine with no network says nothing about the site.
|
|
14933
15082
|
*/
|
|
14934
15083
|
function siteRow(id, title, probe, notFoundHint) {
|
|
14935
|
-
if (probe.status === void 0) return row$
|
|
14936
|
-
if (probe.status < 400) return row$
|
|
14937
|
-
if (probe.status === 401 || probe.status === 403) return row$
|
|
15084
|
+
if (probe.status === void 0) return row$8(id, title, "skip", `${probe.url}: ${probe.error ?? "no answer"}`);
|
|
15085
|
+
if (probe.status < 400) return row$8(id, title, "ok", `${probe.url} answers ${probe.status}`);
|
|
15086
|
+
if (probe.status === 401 || probe.status === 403) return row$8(id, title, "ok", `${probe.url} answers ${probe.status} (access is restricted)`);
|
|
14938
15087
|
const problem = probe.status === 404 ? `${probe.url} answers 404; ${notFoundHint}` : `${probe.url} answers ${probe.status}, expected a page`;
|
|
14939
|
-
return row$
|
|
15088
|
+
return row$8(id, title, "fail", `${probe.url} answers ${probe.status}`, [problem]);
|
|
14940
15089
|
}
|
|
14941
15090
|
/**
|
|
14942
15091
|
* The rows `holocron doctor wiki` prints for one {@link WikiInspection}: organization, docs instance, the site and its
|
|
@@ -14948,42 +15097,42 @@ function wikiRows(found, providerName) {
|
|
|
14948
15097
|
const { declared, found: foundOrg } = found.organization;
|
|
14949
15098
|
if (foundOrg === null) {
|
|
14950
15099
|
const problem = `fern/fern.config.json has no organization; \`holocron setup\` writes it`;
|
|
14951
|
-
rows.push(row$
|
|
15100
|
+
rows.push(row$8("wiki:organization", "organization is set", "fail", problem, [problem]));
|
|
14952
15101
|
} else if (foundOrg !== declared) {
|
|
14953
15102
|
const problem = `fern/fern.config.json names ${foundOrg}, the config declares ${declared}; run \`holocron setup\``;
|
|
14954
|
-
rows.push(row$
|
|
14955
|
-
} else rows.push(row$
|
|
15103
|
+
rows.push(row$8("wiki:organization", "organization is set", "fail", `${foundOrg}, declared ${declared}`, [problem]));
|
|
15104
|
+
} else rows.push(row$8("wiki:organization", "organization is set", "ok", `${declared} in fern/fern.config.json`));
|
|
14956
15105
|
const instance = found.instance;
|
|
14957
15106
|
if (instance === null) {
|
|
14958
15107
|
const problem = "fern/docs.yml does not exist; `holocron setup` writes it";
|
|
14959
|
-
rows.push(row$
|
|
15108
|
+
rows.push(row$8("wiki:instance", "docs site is declared", "fail", problem, [problem]));
|
|
14960
15109
|
} else {
|
|
14961
15110
|
const problems = [];
|
|
14962
15111
|
if (instance.foundUrl !== instance.expectedUrl) problems.push(`instance url is ${instance.foundUrl ?? "not set"}, expected ${instance.expectedUrl}`);
|
|
14963
15112
|
if (instance.expectedDomain !== void 0 && instance.foundDomain !== instance.expectedDomain) problems.push(`custom-domain is ${instance.foundDomain ?? "not set"}, expected ${instance.expectedDomain}`);
|
|
14964
|
-
rows.push(problems.length > 0 ? row$
|
|
15113
|
+
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`));
|
|
14965
15114
|
}
|
|
14966
15115
|
const [site, domain] = found.site;
|
|
14967
15116
|
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\`)`));
|
|
14968
15117
|
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`));
|
|
14969
|
-
if (found.navigation === null) rows.push(row$
|
|
15118
|
+
if (found.navigation === null) rows.push(row$8("wiki:navigation", "navigation pages exist", "skip", "no fern/docs.yml to read"));
|
|
14970
15119
|
else if (found.navigation.missing.length > 0) {
|
|
14971
15120
|
const problems = found.navigation.missing.map((p) => `${p} is listed in fern/docs.yml but is not on disk`);
|
|
14972
|
-
rows.push(row$
|
|
15121
|
+
rows.push(row$8("wiki:navigation", "navigation pages exist", "fail", `${found.navigation.missing.length} missing`, problems));
|
|
14973
15122
|
} else {
|
|
14974
|
-
rows.push(row$
|
|
14975
|
-
if (found.navigation.unlisted.length > 0) rows.push(row$
|
|
15123
|
+
rows.push(row$8("wiki:navigation", "navigation pages exist", "ok", `${found.navigation.listed} listed pages exist`));
|
|
15124
|
+
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`));
|
|
14976
15125
|
}
|
|
14977
15126
|
const published = found.published;
|
|
14978
15127
|
const listed = found.navigation?.listed;
|
|
14979
|
-
if (!published) rows.push(row$
|
|
15128
|
+
if (!published) rows.push(row$8("wiki:published", "published pages", "skip", "the site's page index could not be asked"));
|
|
14980
15129
|
else if (published.pages === void 0) {
|
|
14981
15130
|
const why = published.status === void 0 ? published.error ?? "no answer" : `answered ${published.status}`;
|
|
14982
|
-
rows.push(row$
|
|
15131
|
+
rows.push(row$8("wiki:published", "published pages", "skip", `${published.url}: ${why}`));
|
|
14983
15132
|
} else if (listed !== void 0 && published.pages < listed) {
|
|
14984
15133
|
const problem = `${published.url} lists ${published.pages} page(s), the navigation lists ${listed}; the last publish is behind (run the wiki workflow)`;
|
|
14985
|
-
rows.push(row$
|
|
14986
|
-
} else rows.push(row$
|
|
15134
|
+
rows.push(row$8("wiki:published", "published pages", "fail", `${published.pages} of ${listed}`, [problem]));
|
|
15135
|
+
} 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`));
|
|
14987
15136
|
return rows;
|
|
14988
15137
|
}
|
|
14989
15138
|
// src/commands/doctor-wiki/doctor-wiki.ts
|
|
@@ -15242,6 +15391,19 @@ const DEEP_CHECKS = [
|
|
|
15242
15391
|
...report.reason ? { reason: report.reason } : {}
|
|
15243
15392
|
};
|
|
15244
15393
|
}
|
|
15394
|
+
},
|
|
15395
|
+
{
|
|
15396
|
+
name: "errors",
|
|
15397
|
+
capability: "errors",
|
|
15398
|
+
command: doctorErrorsCommand,
|
|
15399
|
+
async run(input) {
|
|
15400
|
+
const report = await runDoctorErrors(input);
|
|
15401
|
+
return {
|
|
15402
|
+
status: report.status,
|
|
15403
|
+
summary: report.summary,
|
|
15404
|
+
...report.reason ? { reason: report.reason } : {}
|
|
15405
|
+
};
|
|
15406
|
+
}
|
|
15245
15407
|
}
|
|
15246
15408
|
];
|
|
15247
15409
|
// src/commands/doctor-all/doctor-all.ts
|
|
@@ -15975,7 +16137,7 @@ function resolveExportDir(input) {
|
|
|
15975
16137
|
* listed under the provider's row and does not fail the run. It writes files, so it asks first unless `--dry-run` (the
|
|
15976
16138
|
* files are converted and listed, nothing is written) or `--yes` (without a terminal it refuses instead).
|
|
15977
16139
|
*/
|
|
15978
|
-
const row$
|
|
16140
|
+
const row$7 = (id, status, detail, problems = []) => ({
|
|
15979
16141
|
id,
|
|
15980
16142
|
title: id,
|
|
15981
16143
|
status,
|
|
@@ -16017,9 +16179,9 @@ async function runRequestsExport(input) {
|
|
|
16017
16179
|
print("");
|
|
16018
16180
|
const entry = input.loaded.resolved.providers.tooling;
|
|
16019
16181
|
const tuples = entry?.cardinality === "many" ? entry.tuples : [];
|
|
16020
|
-
if (tuples.length === 0) return finish([row$
|
|
16182
|
+
if (tuples.length === 0) return finish([row$7("tooling", "fail", "the config has no `tooling` provider to export for")]);
|
|
16021
16183
|
const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
|
|
16022
|
-
if (chosen.length === 0) return finish([row$
|
|
16184
|
+
if (chosen.length === 0) return finish([row$7(input.to, "fail", `not a \`tooling\` provider of this config (${tuples.map((t) => t.provider).join(", ")})`)]);
|
|
16023
16185
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
16024
16186
|
const loader = input.loader ?? new PluginLoader({
|
|
16025
16187
|
...input.loaded.resolved,
|
|
@@ -16039,17 +16201,17 @@ async function runRequestsExport(input) {
|
|
|
16039
16201
|
const tool = loaded.find((t) => t.providerName === id);
|
|
16040
16202
|
if (!tool) {
|
|
16041
16203
|
const failure = loader.loadFailures().find((f) => f.key === "tooling" && f.provider === id);
|
|
16042
|
-
rows.push(row$
|
|
16204
|
+
rows.push(row$7(id, "fail", `the provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`));
|
|
16043
16205
|
continue;
|
|
16044
16206
|
}
|
|
16045
16207
|
if (!tool.export) {
|
|
16046
|
-
rows.push(row$
|
|
16208
|
+
rows.push(row$7(id, "skip", "has no export: it reads the repo's files as they are"));
|
|
16047
16209
|
continue;
|
|
16048
16210
|
}
|
|
16049
16211
|
const collectionFiles = fileList$1(tuple.options.collectionFiles);
|
|
16050
16212
|
const envFiles = fileList$1(tuple.options.envFiles);
|
|
16051
16213
|
if (collectionFiles.length === 0) {
|
|
16052
|
-
rows.push(row$
|
|
16214
|
+
rows.push(row$7(id, "skip", "names no `collectionFiles`, so there is nothing to export"));
|
|
16053
16215
|
continue;
|
|
16054
16216
|
}
|
|
16055
16217
|
const groups = input.out === void 0 ? groupByFolder(collectionFiles) : [collectionFiles];
|
|
@@ -16063,7 +16225,7 @@ async function runRequestsExport(input) {
|
|
|
16063
16225
|
...input.out !== void 0 ? { out: input.out } : {}
|
|
16064
16226
|
});
|
|
16065
16227
|
if (!dir.ok) {
|
|
16066
|
-
rows.push(row$
|
|
16228
|
+
rows.push(row$7(label, "fail", dir.message));
|
|
16067
16229
|
continue;
|
|
16068
16230
|
}
|
|
16069
16231
|
targets.push({
|
|
@@ -16102,9 +16264,9 @@ async function runRequestsExport(input) {
|
|
|
16102
16264
|
const where = relative(repoRoot, outDir);
|
|
16103
16265
|
const files = result.files.length > 0 ? ` (${result.files.join(", ")})` : "";
|
|
16104
16266
|
paths.push(...result.files.map((file) => resolve(outDir, file)));
|
|
16105
|
-
rows.push(row$
|
|
16267
|
+
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}`)));
|
|
16106
16268
|
} catch (err) {
|
|
16107
|
-
rows.push(row$
|
|
16269
|
+
rows.push(row$7(label, "fail", describeError(err)));
|
|
16108
16270
|
}
|
|
16109
16271
|
const report = finish(rows.sort((a, b) => a.id.localeCompare(b.id)));
|
|
16110
16272
|
if (paths.length > 0) {
|
|
@@ -19878,7 +20040,7 @@ const githubAppCreateCommand = {
|
|
|
19878
20040
|
};
|
|
19879
20041
|
// src/commands/ideas-promote/build-spec/build-spec.ts
|
|
19880
20042
|
const FILED_FROM = /^Filed from idea:.*$/;
|
|
19881
|
-
const MARKER = /^<!-- holocron:idea [^>]*-->$/;
|
|
20043
|
+
const MARKER$1 = /^<!-- holocron:idea [^>]*-->$/;
|
|
19882
20044
|
/**
|
|
19883
20045
|
* A draft spec from an issue: frontmatter (`status: draft`, the `issue`, no `blocked-by`, and no `id`, which
|
|
19884
20046
|
* `sync specs` assigns), the title as the heading, and a `Problem` section holding the issue's text. The `Filed from
|
|
@@ -19890,7 +20052,7 @@ function buildSpec(input) {
|
|
|
19890
20052
|
let fromIdea = false;
|
|
19891
20053
|
const kept = lines.filter((line) => {
|
|
19892
20054
|
const trimmed = line.trim();
|
|
19893
|
-
if (FILED_FROM.test(trimmed) || MARKER.test(trimmed)) {
|
|
20055
|
+
if (FILED_FROM.test(trimmed) || MARKER$1.test(trimmed)) {
|
|
19894
20056
|
fromIdea = true;
|
|
19895
20057
|
return false;
|
|
19896
20058
|
}
|
|
@@ -19969,7 +20131,7 @@ function specName(title, name) {
|
|
|
19969
20131
|
*/
|
|
19970
20132
|
/** How many lines of the spec a dry run shows. */
|
|
19971
20133
|
const PREVIEW_LINES$1 = 12;
|
|
19972
|
-
const row$
|
|
20134
|
+
const row$6 = (id, status, detail) => ({
|
|
19973
20135
|
id,
|
|
19974
20136
|
title: id,
|
|
19975
20137
|
status,
|
|
@@ -19999,7 +20161,7 @@ async function runIdeasPromote(input) {
|
|
|
19999
20161
|
print(style.header(`Holocron new spec${dryRun ? " (dry-run)" : ""}`));
|
|
20000
20162
|
print("");
|
|
20001
20163
|
const entry = input.loaded.resolved.providers.issues;
|
|
20002
|
-
if (!entry) return finish([row$
|
|
20164
|
+
if (!entry) return finish([row$6(input.issue, "fail", "the config has no `issues` provider to read the issue with")]);
|
|
20003
20165
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
20004
20166
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
20005
20167
|
const loader = input.loader ?? new PluginLoader({
|
|
@@ -20014,18 +20176,18 @@ async function runIdeasPromote(input) {
|
|
|
20014
20176
|
assertPluginsResolvable(loader, "new spec");
|
|
20015
20177
|
if (!loader.has("issues")) {
|
|
20016
20178
|
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
20017
|
-
return finish([row$
|
|
20179
|
+
return finish([row$6(input.issue, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
20018
20180
|
}
|
|
20019
20181
|
let issue;
|
|
20020
20182
|
try {
|
|
20021
20183
|
issue = await loader.get("issues").get(input.issue);
|
|
20022
20184
|
} catch (err) {
|
|
20023
|
-
return finish([row$
|
|
20185
|
+
return finish([row$6(input.issue, "fail", `could not read the issue: ${describeError(err)}`)]);
|
|
20024
20186
|
}
|
|
20025
20187
|
const name = specName(issue.summary, input.name);
|
|
20026
|
-
if (!name) return finish([row$
|
|
20188
|
+
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`)]);
|
|
20027
20189
|
const relative = join(".notes", `${name}.spec.md`);
|
|
20028
|
-
if (io.exists(join(input.context.repoRoot, relative))) return finish([row$
|
|
20190
|
+
if (io.exists(join(input.context.repoRoot, relative))) return finish([row$6(relative, "fail", "the spec already exists; it is never overwritten")], relative);
|
|
20029
20191
|
const { org, name: repoName } = input.loaded.resolved;
|
|
20030
20192
|
const ref = githubRef(issue.url) ?? (issue.key.startsWith("#") ? `${org}/${repoName}${issue.key}` : issue.key);
|
|
20031
20193
|
const { content, fromIdea } = buildSpec({
|
|
@@ -20038,7 +20200,7 @@ async function runIdeasPromote(input) {
|
|
|
20038
20200
|
print(` ${relative}`);
|
|
20039
20201
|
for (const line of content.split("\n").slice(0, PREVIEW_LINES$1)) print(` ${style.skip(line)}`);
|
|
20040
20202
|
print("");
|
|
20041
|
-
return finish([row$
|
|
20203
|
+
return finish([row$6(relative, "skip", `would write the spec ${origin}`)], relative);
|
|
20042
20204
|
}
|
|
20043
20205
|
if (!input.yes) {
|
|
20044
20206
|
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`);
|
|
@@ -20057,9 +20219,9 @@ async function runIdeasPromote(input) {
|
|
|
20057
20219
|
try {
|
|
20058
20220
|
io.write(join(input.context.repoRoot, relative), content);
|
|
20059
20221
|
} catch (err) {
|
|
20060
|
-
return finish([row$
|
|
20222
|
+
return finish([row$6(relative, "fail", `could not write the spec: ${describeError(err)}`)], relative);
|
|
20061
20223
|
}
|
|
20062
|
-
return finish([row$
|
|
20224
|
+
return finish([row$6(relative, "ok", `wrote the spec ${origin}`)], relative);
|
|
20063
20225
|
}
|
|
20064
20226
|
// src/commands/ideas-promote/ideas-promote.command.ts
|
|
20065
20227
|
const ideasPromoteCommand = {
|
|
@@ -20113,7 +20275,7 @@ function readIssueBody(file, cwd, read = (p) => readFileSync(p, "utf8")) {
|
|
|
20113
20275
|
*/
|
|
20114
20276
|
/** How many lines of the body a dry run shows. */
|
|
20115
20277
|
const PREVIEW_LINES = 8;
|
|
20116
|
-
const row$
|
|
20278
|
+
const row$5 = (id, status, detail) => ({
|
|
20117
20279
|
id,
|
|
20118
20280
|
title: id,
|
|
20119
20281
|
status,
|
|
@@ -20137,9 +20299,9 @@ async function runIssueCreate(input) {
|
|
|
20137
20299
|
print(style.header(`Holocron new issue${dryRun ? " (dry-run)" : ""}`));
|
|
20138
20300
|
print("");
|
|
20139
20301
|
const title = input.title.trim();
|
|
20140
|
-
if (!title) return finish([row$
|
|
20302
|
+
if (!title) return finish([row$5("title", "fail", "the title is empty")]);
|
|
20141
20303
|
const entry = input.loaded.resolved.providers.issues;
|
|
20142
|
-
if (!entry) return finish([row$
|
|
20304
|
+
if (!entry) return finish([row$5(title, "fail", "the config has no `issues` provider to file the issue with")]);
|
|
20143
20305
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
20144
20306
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
20145
20307
|
const loader = input.loader ?? new PluginLoader({
|
|
@@ -20154,7 +20316,7 @@ async function runIssueCreate(input) {
|
|
|
20154
20316
|
assertPluginsResolvable(loader, "new issue");
|
|
20155
20317
|
if (!loader.has("issues")) {
|
|
20156
20318
|
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
20157
|
-
return finish([row$
|
|
20319
|
+
return finish([row$5(title, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
20158
20320
|
}
|
|
20159
20321
|
const labels = [...new Set((input.labels ?? []).map((l) => l.trim()).filter(Boolean))];
|
|
20160
20322
|
const body = input.body?.trim() ? input.body : void 0;
|
|
@@ -20170,7 +20332,7 @@ async function runIssueCreate(input) {
|
|
|
20170
20332
|
print(` ${title}`);
|
|
20171
20333
|
for (const line of (body ?? "").split("\n").slice(0, PREVIEW_LINES)) print(` ${style.skip(line)}`);
|
|
20172
20334
|
print("");
|
|
20173
|
-
return finish([row$
|
|
20335
|
+
return finish([row$5(title, "skip", `would file the issue${summary}`)]);
|
|
20174
20336
|
}
|
|
20175
20337
|
if (!input.yes) {
|
|
20176
20338
|
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");
|
|
@@ -20193,9 +20355,9 @@ async function runIssueCreate(input) {
|
|
|
20193
20355
|
...milestone ? { milestone } : {},
|
|
20194
20356
|
...assignees.length > 0 ? { assignees } : {}
|
|
20195
20357
|
});
|
|
20196
|
-
return finish([row$
|
|
20358
|
+
return finish([row$5(title, "ok", `filed ${key}`), ...(dropped ?? []).map((line) => row$5("not carried across", "skip", line))], key);
|
|
20197
20359
|
} catch (err) {
|
|
20198
|
-
return finish([row$
|
|
20360
|
+
return finish([row$5(title, "fail", `could not file the issue: ${describeError(err)}`)]);
|
|
20199
20361
|
}
|
|
20200
20362
|
}
|
|
20201
20363
|
// src/commands/issue-create/issue-create.command.ts
|
|
@@ -22855,6 +23017,403 @@ const newCommand = {
|
|
|
22855
23017
|
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")),
|
|
22856
23018
|
handler: () => {}
|
|
22857
23019
|
};
|
|
23020
|
+
// src/commands/open-requests/read-entry-values/read-entry-values.ts
|
|
23021
|
+
/**
|
|
23022
|
+
* The values of the named entries of one vault Environment, read in memory. Only an Environment this repo uses is read:
|
|
23023
|
+
* a layer word (`local`, `dev`, `ci`, `prod`) is this repo's `<org/repo> - <layer>`, and any other text must be a name
|
|
23024
|
+
* the config already names, as `probe --environment` requires. `local` reads the way the CLI does, `- local` over
|
|
23025
|
+
* `- dev`, and `- local` may be absent.
|
|
23026
|
+
*
|
|
23027
|
+
* This is the one place a concealed value is read on purpose (see `AGENTS.md`, "Concealed values"): only the names the
|
|
23028
|
+
* collection's references list are taken, every other entry is dropped before this returns, and a value is never
|
|
23029
|
+
* logged or put in an error. A name the Environment lacks, or holds blank, is in `missing`.
|
|
23030
|
+
*
|
|
23031
|
+
* @throws {Error} When the Environment is not one of this repo's or the vault cannot read entries.
|
|
23032
|
+
*/
|
|
23033
|
+
async function readEntryValues(input) {
|
|
23034
|
+
if (!isEnvironmentLayer(input.environment) && !input.configured.includes(input.environment)) {
|
|
23035
|
+
const known = [...ENVIRONMENT_LAYERS, ...input.configured];
|
|
23036
|
+
throw new Error(`${input.environment} is not an Environment this repo's config names; use one of: ${known.join(", ")}`);
|
|
23037
|
+
}
|
|
23038
|
+
const read = (id) => input.vault.readEnvironmentEntries(id);
|
|
23039
|
+
const at = {
|
|
23040
|
+
repoRoot: input.repoRoot,
|
|
23041
|
+
gitExec: input.gitExec
|
|
23042
|
+
};
|
|
23043
|
+
const environmentId = await resolveEnvironmentId(input.environment, at);
|
|
23044
|
+
let entries;
|
|
23045
|
+
if (input.environment === "local") {
|
|
23046
|
+
const dev = await read(await resolveEnvironmentId("dev", at));
|
|
23047
|
+
const local = await read(environmentId).catch(() => []);
|
|
23048
|
+
entries = [...dev, ...local];
|
|
23049
|
+
} else entries = await read(environmentId);
|
|
23050
|
+
const held = new Map(entries.map((entry) => [entry.name, entry.value]));
|
|
23051
|
+
const values = /* @__PURE__ */ new Map();
|
|
23052
|
+
const missing = [];
|
|
23053
|
+
for (const name of input.names) {
|
|
23054
|
+
const value = held.get(name);
|
|
23055
|
+
if (value) values.set(name, value);
|
|
23056
|
+
else missing.push(name);
|
|
23057
|
+
}
|
|
23058
|
+
return {
|
|
23059
|
+
environmentId,
|
|
23060
|
+
values,
|
|
23061
|
+
missing
|
|
23062
|
+
};
|
|
23063
|
+
}
|
|
23064
|
+
// src/commands/open-requests/run-open-requests/default-deps/default-deps.ts
|
|
23065
|
+
const run = promisify(execFile);
|
|
23066
|
+
/** What is at `path`, without following a symlink. */
|
|
23067
|
+
function inspect(path) {
|
|
23068
|
+
let stat;
|
|
23069
|
+
try {
|
|
23070
|
+
stat = lstatSync(path);
|
|
23071
|
+
} catch (err) {
|
|
23072
|
+
if (err.code === "ENOENT") return { kind: "none" };
|
|
23073
|
+
throw err;
|
|
23074
|
+
}
|
|
23075
|
+
if (stat.isSymbolicLink()) return {
|
|
23076
|
+
kind: "symlink",
|
|
23077
|
+
to: readlinkSync(path)
|
|
23078
|
+
};
|
|
23079
|
+
if (!stat.isFile()) return { kind: "other" };
|
|
23080
|
+
return {
|
|
23081
|
+
kind: "file",
|
|
23082
|
+
firstLine: readFileSync(path, "utf8").split("\n")[0]
|
|
23083
|
+
};
|
|
23084
|
+
}
|
|
23085
|
+
/** Whether a process with this id is running. */
|
|
23086
|
+
function alive(pid) {
|
|
23087
|
+
try {
|
|
23088
|
+
process.kill(pid, 0);
|
|
23089
|
+
return true;
|
|
23090
|
+
} catch (err) {
|
|
23091
|
+
return err.code === "EPERM";
|
|
23092
|
+
}
|
|
23093
|
+
}
|
|
23094
|
+
/** 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. */
|
|
23095
|
+
function takeLock(path, pid) {
|
|
23096
|
+
for (let attempt = 0; attempt < 2; attempt += 1) try {
|
|
23097
|
+
const fd = openSync(path, "wx", 384);
|
|
23098
|
+
writeSync(fd, String(pid));
|
|
23099
|
+
closeSync(fd);
|
|
23100
|
+
return true;
|
|
23101
|
+
} catch (err) {
|
|
23102
|
+
if (err.code !== "EEXIST") throw err;
|
|
23103
|
+
const holder = Number.parseInt(readFileSync(path, "utf8"), 10);
|
|
23104
|
+
if (Number.isInteger(holder) && alive(holder)) return false;
|
|
23105
|
+
rmSync(path, { force: true });
|
|
23106
|
+
}
|
|
23107
|
+
/* v8 ignore next -- only when another run takes the lock between the check and the retry */
|
|
23108
|
+
return false;
|
|
23109
|
+
}
|
|
23110
|
+
/** The real collaborators of `open requests`. */
|
|
23111
|
+
function defaultDeps() {
|
|
23112
|
+
return {
|
|
23113
|
+
isIgnored: isGitIgnored,
|
|
23114
|
+
makeDir: (dir) => void mkdirSync(dir, {
|
|
23115
|
+
recursive: true,
|
|
23116
|
+
mode: 448
|
|
23117
|
+
}),
|
|
23118
|
+
createPrivateFile: (path, text) => closeSync(createPrivateFile(path, text).fd),
|
|
23119
|
+
inspect,
|
|
23120
|
+
symlink: (to, link) => symlinkSync(to, link),
|
|
23121
|
+
remove: (path) => rmSync(path, { force: true }),
|
|
23122
|
+
takeLock,
|
|
23123
|
+
/* v8 ignore start -- the process list, the program and the signals are only real outside tests, which inject them */
|
|
23124
|
+
processes: async () => (await run("ps", ["-axo", "command"], { maxBuffer: 16777216 })).stdout,
|
|
23125
|
+
run: (launch) => new Promise((resolve, reject) => {
|
|
23126
|
+
const child = spawn(launch.command, launch.args, { stdio: "inherit" });
|
|
23127
|
+
const stop = () => child.kill("SIGTERM");
|
|
23128
|
+
process.once("SIGTERM", stop);
|
|
23129
|
+
child.once("error", (err) => {
|
|
23130
|
+
process.off("SIGTERM", stop);
|
|
23131
|
+
reject(err);
|
|
23132
|
+
});
|
|
23133
|
+
child.once("exit", (code) => {
|
|
23134
|
+
process.off("SIGTERM", stop);
|
|
23135
|
+
resolve(code ?? 0);
|
|
23136
|
+
});
|
|
23137
|
+
}),
|
|
23138
|
+
onTerminate: (handler) => {
|
|
23139
|
+
const events = [
|
|
23140
|
+
"SIGINT",
|
|
23141
|
+
"SIGTERM",
|
|
23142
|
+
"SIGHUP",
|
|
23143
|
+
"exit"
|
|
23144
|
+
];
|
|
23145
|
+
for (const event of events) process.once(event, handler);
|
|
23146
|
+
return () => {
|
|
23147
|
+
for (const event of events) process.off(event, handler);
|
|
23148
|
+
};
|
|
23149
|
+
},
|
|
23150
|
+
pid: process.pid,
|
|
23151
|
+
platform: process.platform
|
|
23152
|
+
};
|
|
23153
|
+
}
|
|
23154
|
+
// src/commands/open-requests/run-open-requests/run-open-requests.ts
|
|
23155
|
+
/**
|
|
23156
|
+
* `holocron open requests` — opens the request tool's workspace with its secrets filled in from the layer's vault
|
|
23157
|
+
* Environment, so nobody pastes a signing secret by hand.
|
|
23158
|
+
*
|
|
23159
|
+
* The `tooling` provider (Bruno's) says which values the workspace reads (`Tooling.open`: each secret variable is a
|
|
23160
|
+
* reference to a named entry, written by `sync requests`) and how to start the tool. This command takes exactly those
|
|
23161
|
+
* entries from the Environment, in memory, writes them to a private file in `.holocron/.private/` (mode 0600, git-ignored,
|
|
23162
|
+
* never printed), links the file to where the tool reads it (`<collection>/.env`) and runs the tool in the foreground.
|
|
23163
|
+
* The file, the links and the lock are removed when the tool quits, on an error, and on SIGINT, SIGTERM, SIGHUP and exit;
|
|
23164
|
+
* nothing can run on SIGKILL or a crash, so the file starts with a marker line and a later run removes its own leftover
|
|
23165
|
+
* and refuses anything without the marker. A tool that is already running is never touched: it would not see the values.
|
|
23166
|
+
* Names and paths are printed, never a value. `--dry-run` lists them and starts nothing.
|
|
23167
|
+
*/
|
|
23168
|
+
/** The first line of the file this command writes; a file that starts with it is this command's own leftover. */
|
|
23169
|
+
const MARKER = "# written by `holocron open requests` for one session and removed when it ends";
|
|
23170
|
+
/** The file the values go to, in the private directory. */
|
|
23171
|
+
const SECRETS_FILE = `${PRIVATE_DIR}/requests.env`;
|
|
23172
|
+
/** The lock a launch holds, in the private directory. */
|
|
23173
|
+
const LOCK_FILE = `${PRIVATE_DIR}/open-requests.lock`;
|
|
23174
|
+
const row$4 = (id, status, detail, problems = []) => ({
|
|
23175
|
+
id,
|
|
23176
|
+
title: id,
|
|
23177
|
+
status,
|
|
23178
|
+
detail,
|
|
23179
|
+
problems
|
|
23180
|
+
});
|
|
23181
|
+
/** Whether a link or file at `link` is something this command wrote: a link to the values file, or a marked file. */
|
|
23182
|
+
function isOurs(state, link, secrets) {
|
|
23183
|
+
if (state.kind === "symlink") return resolve(dirname(link), state.to) === secrets;
|
|
23184
|
+
return state.kind === "file" && state.firstLine === "# written by `holocron open requests` for one session and removed when it ends";
|
|
23185
|
+
}
|
|
23186
|
+
async function runOpenRequests(input) {
|
|
23187
|
+
/* v8 ignore next -- the console is only used outside tests, which inject `print` */
|
|
23188
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
23189
|
+
const deps = {
|
|
23190
|
+
...defaultDeps(),
|
|
23191
|
+
...input.deps
|
|
23192
|
+
};
|
|
23193
|
+
const dryRun = Boolean(input.context.dryRun);
|
|
23194
|
+
const environment = input.environment ?? "dev";
|
|
23195
|
+
const { repoRoot } = input.context;
|
|
23196
|
+
const rows = [];
|
|
23197
|
+
const say = (next) => {
|
|
23198
|
+
rows.push(next);
|
|
23199
|
+
printCheckRows([next], print);
|
|
23200
|
+
};
|
|
23201
|
+
const finish = (status) => {
|
|
23202
|
+
const summary = summariseChecks(rows);
|
|
23203
|
+
printCheckSummary(summary, print);
|
|
23204
|
+
return {
|
|
23205
|
+
status: status ?? (summary.fail > 0 ? "fail" : "ok"),
|
|
23206
|
+
rows
|
|
23207
|
+
};
|
|
23208
|
+
};
|
|
23209
|
+
print(style.header(`Holocron open requests${dryRun ? " (dry-run)" : ""}`));
|
|
23210
|
+
print("");
|
|
23211
|
+
const entry = input.loaded.resolved.providers.tooling;
|
|
23212
|
+
const tuples = entry?.cardinality === "many" ? entry.tuples : [];
|
|
23213
|
+
const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
|
|
23214
|
+
if (chosen.length === 0) {
|
|
23215
|
+
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(", ")})`));
|
|
23216
|
+
return finish();
|
|
23217
|
+
}
|
|
23218
|
+
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
23219
|
+
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
23220
|
+
/* v8 ignore stop */
|
|
23221
|
+
await loader.load();
|
|
23222
|
+
assertPluginsResolvable(loader, "open requests");
|
|
23223
|
+
const openable = (loader.has("tooling") ? loader.get("tooling") : []).filter((t) => chosen.some((tuple) => tuple.provider === t.providerName)).filter((t) => t.open !== void 0);
|
|
23224
|
+
if (openable.length !== 1) {
|
|
23225
|
+
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`));
|
|
23226
|
+
return finish();
|
|
23227
|
+
}
|
|
23228
|
+
const tool = openable[0];
|
|
23229
|
+
const tuple = chosen.find((t) => t.provider === tool.providerName);
|
|
23230
|
+
const list = (value) => Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
|
|
23231
|
+
let plan;
|
|
23232
|
+
try {
|
|
23233
|
+
plan = await tool.open({
|
|
23234
|
+
collectionFiles: list(tuple.options.collectionFiles),
|
|
23235
|
+
envFiles: list(tuple.options.envFiles),
|
|
23236
|
+
repoRoot
|
|
23237
|
+
});
|
|
23238
|
+
} catch (err) {
|
|
23239
|
+
say(row$4(tool.providerName, "fail", describeError(err)));
|
|
23240
|
+
return finish();
|
|
23241
|
+
}
|
|
23242
|
+
const names = [...new Set(plan.wants.map((w) => w.entry))].sort();
|
|
23243
|
+
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));
|
|
23244
|
+
if (dryRun) {
|
|
23245
|
+
for (const want of plan.wants) say(row$4(want.variable, "ok", `would fill ${want.collection}'s ${want.variable} from ${want.entry} of ${environment}`));
|
|
23246
|
+
if (names.length === 0) say(row$4("secrets", "ok", "nothing to fill: no variable refers to an entry"));
|
|
23247
|
+
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
|
+
say(row$4(plan.app, "ok", `would start ${plan.launch.command} in the foreground`));
|
|
23249
|
+
return finish();
|
|
23250
|
+
}
|
|
23251
|
+
if (deps.platform === "win32" && names.length > 0) {
|
|
23252
|
+
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"));
|
|
23253
|
+
return finish();
|
|
23254
|
+
}
|
|
23255
|
+
let running;
|
|
23256
|
+
try {
|
|
23257
|
+
running = await deps.processes();
|
|
23258
|
+
} catch (err) {
|
|
23259
|
+
say(row$4(plan.app, "fail", `could not tell whether ${plan.app} is running: ${describeError(err)}`));
|
|
23260
|
+
return finish();
|
|
23261
|
+
}
|
|
23262
|
+
if (running.split("\n").some((line) => line.includes(plan.running))) {
|
|
23263
|
+
say(row$4(plan.app, "fail", `${plan.app} is already running; quit it and run this again (it would not see the values)`));
|
|
23264
|
+
return finish();
|
|
23265
|
+
}
|
|
23266
|
+
if (!input.yes) {
|
|
23267
|
+
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`);
|
|
23268
|
+
if (!await (input.confirm ?? ((message) => confirm({
|
|
23269
|
+
message,
|
|
23270
|
+
default: false
|
|
23271
|
+
})))(names.length === 0 ? `Start ${plan.app} (nothing to fill)?` : `Read ${names.length} value(s) from ${environment} and start ${plan.app} with them?`)) {
|
|
23272
|
+
print(` ${style.skip("cancelled; nothing was read or written")}`);
|
|
23273
|
+
return finish("cancelled");
|
|
23274
|
+
}
|
|
23275
|
+
}
|
|
23276
|
+
let values = /* @__PURE__ */ new Map();
|
|
23277
|
+
if (names.length > 0) {
|
|
23278
|
+
const vault = loader.has("vault") ? loader.get("vault") : void 0;
|
|
23279
|
+
if (!vault?.readEnvironmentEntries) {
|
|
23280
|
+
say(row$4("vault", "fail", vault ? `${vault.providerName} cannot read an Environment's entries` : "needs a `vault` provider in holocron.config.ts (1password)"));
|
|
23281
|
+
return finish();
|
|
23282
|
+
}
|
|
23283
|
+
let read;
|
|
23284
|
+
try {
|
|
23285
|
+
read = await readEntryValues({
|
|
23286
|
+
vault,
|
|
23287
|
+
environment,
|
|
23288
|
+
configured: ownerEnvironments(input.loaded.resolved).names,
|
|
23289
|
+
repoRoot,
|
|
23290
|
+
names
|
|
23291
|
+
});
|
|
23292
|
+
} catch (err) {
|
|
23293
|
+
say(row$4(`vault ${environment}`, "fail", describeError(err)));
|
|
23294
|
+
return finish();
|
|
23295
|
+
}
|
|
23296
|
+
for (const name of read.missing) say(row$4(name, "fail", `${read.environmentId} holds no value for ${name}`));
|
|
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(", ")}`));
|
|
23300
|
+
}
|
|
23301
|
+
const secrets = resolve(repoRoot, SECRETS_FILE);
|
|
23302
|
+
const lock = resolve(repoRoot, LOCK_FILE);
|
|
23303
|
+
const created = [];
|
|
23304
|
+
let cleaned = false;
|
|
23305
|
+
const cleanup = () => {
|
|
23306
|
+
if (cleaned) return;
|
|
23307
|
+
cleaned = true;
|
|
23308
|
+
for (const link of plan.targets) {
|
|
23309
|
+
const state = deps.inspect(link);
|
|
23310
|
+
if (created.includes(link) && isOurs(state, link, secrets)) deps.remove(link);
|
|
23311
|
+
}
|
|
23312
|
+
if (created.includes(secrets)) deps.remove(secrets);
|
|
23313
|
+
deps.remove(lock);
|
|
23314
|
+
};
|
|
23315
|
+
deps.makeDir(dirname(secrets));
|
|
23316
|
+
if (!deps.takeLock(lock, deps.pid)) {
|
|
23317
|
+
say(row$4(plan.app, "fail", `another \`open requests\` is starting ${plan.app} (${LOCK_FILE} is held); try again when it has`));
|
|
23318
|
+
return finish();
|
|
23319
|
+
}
|
|
23320
|
+
const stop = deps.onTerminate(cleanup);
|
|
23321
|
+
try {
|
|
23322
|
+
if (names.length > 0) {
|
|
23323
|
+
const ignored = deps.isIgnored(secrets);
|
|
23324
|
+
if (ignored === "tracked" || ignored === "unknown") {
|
|
23325
|
+
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, "")]));
|
|
23326
|
+
return finish();
|
|
23327
|
+
}
|
|
23328
|
+
const stale = deps.inspect(secrets);
|
|
23329
|
+
if (stale.kind !== "none" && !(stale.kind === "file" && stale.firstLine === "# written by `holocron open requests` for one session and removed when it ends")) {
|
|
23330
|
+
say(row$4("values file", "fail", `${SECRETS_FILE} is not this command's (no marker line); move it away`));
|
|
23331
|
+
return finish();
|
|
23332
|
+
}
|
|
23333
|
+
for (const link of plan.targets) {
|
|
23334
|
+
const state = deps.inspect(link);
|
|
23335
|
+
if (state.kind !== "none" && !isOurs(state, link, secrets)) {
|
|
23336
|
+
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`));
|
|
23337
|
+
return finish();
|
|
23338
|
+
}
|
|
23339
|
+
}
|
|
23340
|
+
const lines = [MARKER];
|
|
23341
|
+
for (const [name, value] of values) {
|
|
23342
|
+
const line = dotenvLine(name, value);
|
|
23343
|
+
if (line === null) {
|
|
23344
|
+
say(row$4(name, "fail", `the value of ${name} cannot be written to a .env file as it is; it was not written`));
|
|
23345
|
+
return finish();
|
|
23346
|
+
}
|
|
23347
|
+
lines.push(line);
|
|
23348
|
+
}
|
|
23349
|
+
for (const link of plan.targets) deps.remove(link);
|
|
23350
|
+
deps.remove(secrets);
|
|
23351
|
+
deps.createPrivateFile(secrets, `${lines.join("\n")}\n`);
|
|
23352
|
+
created.push(secrets);
|
|
23353
|
+
for (const link of plan.targets) {
|
|
23354
|
+
deps.symlink(relative(dirname(link), secrets), link);
|
|
23355
|
+
created.push(link);
|
|
23356
|
+
}
|
|
23357
|
+
say(row$4("values file", "ok", `${SECRETS_FILE} (mode 0600, git-ignored) linked from ${plan.targets.map((t) => relative(repoRoot, t)).join(", ")}`));
|
|
23358
|
+
}
|
|
23359
|
+
print("");
|
|
23360
|
+
print(`starting ${plan.app}${names.length > 0 ? `; the values are removed when it quits (Ctrl-C ends it too)` : ""}`);
|
|
23361
|
+
let exitCode;
|
|
23362
|
+
try {
|
|
23363
|
+
exitCode = await deps.run(plan.launch);
|
|
23364
|
+
} catch (err) {
|
|
23365
|
+
say(row$4(plan.app, "fail", describeError(err)));
|
|
23366
|
+
return finish();
|
|
23367
|
+
}
|
|
23368
|
+
say(row$4(plan.app, exitCode === 0 ? "ok" : "fail", `ended with ${exitCode}`));
|
|
23369
|
+
return finish();
|
|
23370
|
+
} finally {
|
|
23371
|
+
stop();
|
|
23372
|
+
const wrote = created.includes(secrets);
|
|
23373
|
+
cleanup();
|
|
23374
|
+
if (wrote) print(style.dim(` removed ${SECRETS_FILE} and its links`));
|
|
23375
|
+
}
|
|
23376
|
+
}
|
|
23377
|
+
// src/commands/open-requests/open-requests.command.ts
|
|
23378
|
+
const openRequestsCommand = {
|
|
23379
|
+
command: "requests",
|
|
23380
|
+
describe: "Open the request tool's workspace with its secrets filled in from the layer's vault Environment",
|
|
23381
|
+
builder: (y) => y.option("environment", {
|
|
23382
|
+
type: "string",
|
|
23383
|
+
describe: "The layer (`local`, `dev`, `ci`, `prod`) or Environment to read the secrets from (default: `dev`)"
|
|
23384
|
+
}).option("to", {
|
|
23385
|
+
type: "string",
|
|
23386
|
+
describe: "Open only for this tooling provider (needed when more than one can open its workspace)"
|
|
23387
|
+
}).option("yes", {
|
|
23388
|
+
type: "boolean",
|
|
23389
|
+
describe: "Go ahead without asking (required without a terminal)"
|
|
23390
|
+
}),
|
|
23391
|
+
handler: async (argv) => {
|
|
23392
|
+
const tokens = tokenContext(argv.token);
|
|
23393
|
+
if (!tokens) return;
|
|
23394
|
+
const loaded = await loadConfig(argv.cwd);
|
|
23395
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
23396
|
+
if ((await runOpenRequests({
|
|
23397
|
+
loaded,
|
|
23398
|
+
context: {
|
|
23399
|
+
repoRoot: argv.cwd,
|
|
23400
|
+
dryRun: argv.dryRun,
|
|
23401
|
+
...tokens,
|
|
23402
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
23403
|
+
},
|
|
23404
|
+
...argv.environment ? { environment: argv.environment } : {},
|
|
23405
|
+
...argv.to ? { to: argv.to } : {},
|
|
23406
|
+
...argv.yes ? { yes: true } : {}
|
|
23407
|
+
})).status === "fail") process.exitCode = 1;
|
|
23408
|
+
}
|
|
23409
|
+
};
|
|
23410
|
+
// src/commands/open/open.command.ts
|
|
23411
|
+
const openCommand = {
|
|
23412
|
+
command: "open",
|
|
23413
|
+
describe: "Open a tool with what it needs filled in from the vault",
|
|
23414
|
+
builder: (y) => y.command(openRequestsCommand).command(groupMenu("open")),
|
|
23415
|
+
handler: () => {}
|
|
23416
|
+
};
|
|
22858
23417
|
// src/commands/probe/probe.args.ts
|
|
22859
23418
|
/**
|
|
22860
23419
|
* Shown in `holocron probe --help`: how a probe about a token (`cloudflare token`) picks the token it checks, so the
|
|
@@ -30890,6 +31449,7 @@ const COMMAND_MODULES = [
|
|
|
30890
31449
|
cleanupCommand,
|
|
30891
31450
|
applyCommand,
|
|
30892
31451
|
newCommand,
|
|
31452
|
+
openCommand,
|
|
30893
31453
|
listCommand,
|
|
30894
31454
|
removeCommand,
|
|
30895
31455
|
probeCommand,
|