@theholocron/cli 5.0.0-alpha.520 → 5.0.0-alpha.521
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 +3 -1
- package/dist/cli.mjs +1040 -405
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-D_ZIb8Dw.mjs → config-system-S97oWF6b.mjs} +6 -0
- package/dist/{index-DFp_iLFu.d.mts → index-D4i2IB5D.d.mts} +72 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/plugin/capabilities.d.mts +2 -2
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/package.json +12 -12
package/dist/cli.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { appendFileSync, closeSync, copyFileSync, existsSync, fstatSync, lstatSy
|
|
|
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
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
|
-
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";
|
|
17
|
+
import { AGGREGATE_CHECK_NAME, AGGREGATE_SHADOW_CHECK_NAME, 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, aggregatePoster, 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, postAggregate, 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";
|
|
20
20
|
import { resolveAxiomFromEnv } from "@theholocron/observability/logger";
|
|
@@ -35,7 +35,7 @@ import { ADR_DIR, ADR_STATUSES, CLOSED_STATUSES, SPEC_DIRS, SPEC_STATUSES, WITHD
|
|
|
35
35
|
import { stringifyJson } from "@theholocron/json-utils";
|
|
36
36
|
import { findRootSync, isWorkspaceRoot, walkFilesSync } from "@theholocron/fs-utils";
|
|
37
37
|
import { appManifestPage, buildAppManifest, convertAppManifest, serveAppManifest, serveHandler, superviseProcesses } from "@theholocron/dagobah";
|
|
38
|
-
import { createGitHubClient, getApp, listAppInstallations } from "@theholocron/github-client";
|
|
38
|
+
import { createGitHubClient, getApp, listAppDeliveries, listAppInstallations, redeliverAppDelivery } from "@theholocron/github-client";
|
|
39
39
|
import { createServer } from "node:http";
|
|
40
40
|
import { promisify } from "node:util";
|
|
41
41
|
import { loadConfigPath } from "@theholocron/datapad";
|
|
@@ -103,7 +103,9 @@ const COMMAND_CONTEXTS = {
|
|
|
103
103
|
"sync roles": "workspace",
|
|
104
104
|
"cleanup posts": "workspace",
|
|
105
105
|
"sync specs": "workspace",
|
|
106
|
+
"reconcile ci": "workspace",
|
|
106
107
|
"reconcile project": "workspace",
|
|
108
|
+
"redeliver webhooks": "workspace",
|
|
107
109
|
"doctor all": "workspace",
|
|
108
110
|
"doctor notifications": "workspace",
|
|
109
111
|
"doctor environments": "workspace",
|
|
@@ -426,7 +428,17 @@ const doctorCiEntry = {
|
|
|
426
428
|
name: "doctor ci",
|
|
427
429
|
description: "Check the repo against the flat task vocabulary: aliases, caller names, the ci aggregate, home (read-only)",
|
|
428
430
|
positionals: [],
|
|
429
|
-
|
|
431
|
+
options: [{
|
|
432
|
+
key: "shadow",
|
|
433
|
+
flag: "--shadow",
|
|
434
|
+
type: "confirm",
|
|
435
|
+
message: "Also compare Sentinel's shadow aggregate with the Actions one?"
|
|
436
|
+
}],
|
|
437
|
+
skipOptions: [
|
|
438
|
+
"all",
|
|
439
|
+
"repo",
|
|
440
|
+
"limit"
|
|
441
|
+
],
|
|
430
442
|
supportsDryRun: false
|
|
431
443
|
};
|
|
432
444
|
// src/commands/doctor-dns/doctor-dns.entry.ts
|
|
@@ -1595,6 +1607,38 @@ const publishEntry = {
|
|
|
1595
1607
|
}
|
|
1596
1608
|
]
|
|
1597
1609
|
};
|
|
1610
|
+
// src/commands/reconcile-ci/reconcile-ci.entry.ts
|
|
1611
|
+
const reconcileCiEntry = {
|
|
1612
|
+
name: "reconcile ci",
|
|
1613
|
+
description: "Make the ci / Required checks check say what the checks on each open pull request call for (the manual path and the sweep)",
|
|
1614
|
+
positionals: [{
|
|
1615
|
+
key: "pullRequest",
|
|
1616
|
+
message: "Pull request number (empty for every open one):",
|
|
1617
|
+
type: "input"
|
|
1618
|
+
}],
|
|
1619
|
+
options: [{
|
|
1620
|
+
key: "shadow",
|
|
1621
|
+
flag: "--shadow",
|
|
1622
|
+
type: "confirm",
|
|
1623
|
+
message: "Repair Sentinel's shadow check instead of the real one?"
|
|
1624
|
+
}],
|
|
1625
|
+
skipOptions: ["max-age"],
|
|
1626
|
+
supportsDryRun: true
|
|
1627
|
+
};
|
|
1628
|
+
// src/commands/redeliver-webhooks/redeliver-webhooks.entry.ts
|
|
1629
|
+
const redeliverWebhooksEntry = {
|
|
1630
|
+
name: "redeliver webhooks",
|
|
1631
|
+
description: "Ask GitHub to deliver again the webhooks each registered App's endpoint did not accept (the recovery step after a Sentinel outage)",
|
|
1632
|
+
positionals: [],
|
|
1633
|
+
options: [{
|
|
1634
|
+
key: "since",
|
|
1635
|
+
flag: "--since",
|
|
1636
|
+
type: "input",
|
|
1637
|
+
message: "How far back (30m, 12h, 7d; default 1d):"
|
|
1638
|
+
}],
|
|
1639
|
+
skipOptions: ["app", "yes"],
|
|
1640
|
+
supportsDryRun: true
|
|
1641
|
+
};
|
|
1598
1642
|
// src/commands/repo-cleanup-branches/repo-cleanup-branches.entry.ts
|
|
1599
1643
|
const repoCleanupBranchesEntry = {
|
|
1600
1644
|
name: "cleanup branches",
|
|
@@ -2247,7 +2291,9 @@ const registry = createCommandRegistry([
|
|
|
2247
2291
|
projectCloseEntry,
|
|
2248
2292
|
projectSetupEntry,
|
|
2249
2293
|
projectStatusEntry,
|
|
2250
|
-
projectReconcileEntry
|
|
2294
|
+
projectReconcileEntry,
|
|
2295
|
+
reconcileCiEntry,
|
|
2296
|
+
redeliverWebhooksEntry
|
|
2251
2297
|
], "interactive-menu");
|
|
2252
2298
|
/** Every Holocron command, in menu order: what {@link launchMenu} lists and what a leaf handler's prompt reads. */
|
|
2253
2299
|
const COMMAND_REGISTRY = registry.entries;
|
|
@@ -3082,6 +3128,8 @@ const DOCS_COVERAGE_MODES = [
|
|
|
3082
3128
|
"warn",
|
|
3083
3129
|
"required"
|
|
3084
3130
|
];
|
|
3131
|
+
/** The values `ci.aggregate` accepts. */
|
|
3132
|
+
const CI_AGGREGATE_POSTERS = ["actions", "sentinel"];
|
|
3085
3133
|
/**
|
|
3086
3134
|
* The environment a `credentials` provider reads: its own `environment` option when it has one, else the shared
|
|
3087
3135
|
* `credentials.environment`, else `undefined`. The option lets each of several providers name its own (a 1Password
|
|
@@ -3108,6 +3156,8 @@ function resolveConfig(raw) {
|
|
|
3108
3156
|
}
|
|
3109
3157
|
const docsCoverage = raw.repoValidation?.docsCoverage;
|
|
3110
3158
|
if (docsCoverage !== void 0 && !DOCS_COVERAGE_MODES.includes(docsCoverage)) throw new ConfigError(`\`repoValidation.docsCoverage\` must be one of ${DOCS_COVERAGE_MODES.map((m) => `"${m}"`).join(", ")}, got ${JSON.stringify(docsCoverage)}`);
|
|
3159
|
+
const aggregate = raw.ci?.aggregate;
|
|
3160
|
+
if (aggregate !== void 0 && !CI_AGGREGATE_POSTERS.includes(aggregate)) throw new ConfigError(`\`ci.aggregate\` must be one of ${CI_AGGREGATE_POSTERS.map((m) => `"${m}"`).join(", ")}, got ${JSON.stringify(aggregate)}`);
|
|
3111
3161
|
if (raw.credentials !== void 0) {
|
|
3112
3162
|
const environment = raw.credentials.environment;
|
|
3113
3163
|
if (typeof environment !== "string" || environment.trim() === "") throw new ConfigError("`credentials.environment` must be the name of an environment, got an empty value");
|
|
@@ -3142,6 +3192,7 @@ function resolveConfig(raw) {
|
|
|
3142
3192
|
syncScripts: raw.syncScripts,
|
|
3143
3193
|
holocronScript: raw.holocronScript,
|
|
3144
3194
|
extraRequiredChecks: raw.extraRequiredChecks,
|
|
3195
|
+
ci: raw.ci,
|
|
3145
3196
|
hooks: raw.hooks,
|
|
3146
3197
|
providers,
|
|
3147
3198
|
apps: raw.apps ?? [],
|
|
@@ -3284,6 +3335,7 @@ async function deriveDefaults$1(found) {
|
|
|
3284
3335
|
if (manifest.syncScripts !== void 0) result.syncScripts = manifest.syncScripts;
|
|
3285
3336
|
if (manifest.holocronScript !== void 0) result.holocronScript = manifest.holocronScript;
|
|
3286
3337
|
if (manifest.hooks !== void 0) result.hooks = manifest.hooks;
|
|
3338
|
+
if (manifest.ci !== void 0) result.ci = manifest.ci;
|
|
3287
3339
|
if (manifest.extraRequiredChecks) result.extraRequiredChecks = [...result.extraRequiredChecks ?? [], ...manifest.extraRequiredChecks];
|
|
3288
3340
|
return result;
|
|
3289
3341
|
}
|
|
@@ -3996,7 +4048,7 @@ function planIssueTypes(declared, existing, update) {
|
|
|
3996
4048
|
}
|
|
3997
4049
|
const WRITE_PERMISSION = "creating or changing issue Types needs an organization admin and the organization permission Issue types: write (HOLOCRON_ORG_TOKEN)";
|
|
3998
4050
|
const READ_PERMISSION = "reading the organization's issue Types needs the organization permission Issue types: read (HOLOCRON_ORG_TOKEN)";
|
|
3999
|
-
const row$
|
|
4051
|
+
const row$35 = (id, title, status, detail, problems = []) => ({
|
|
4000
4052
|
id: `issue-types:${id}`,
|
|
4001
4053
|
title,
|
|
4002
4054
|
status,
|
|
@@ -4016,7 +4068,7 @@ async function ensureIssueTypes(input) {
|
|
|
4016
4068
|
const refused = input.caller === "setup" ? "skip" : "fail";
|
|
4017
4069
|
const stop = (status, detail, problems = []) => ({
|
|
4018
4070
|
status,
|
|
4019
|
-
rows: [row$
|
|
4071
|
+
rows: [row$35("types", "issue types", status, detail, problems)],
|
|
4020
4072
|
created,
|
|
4021
4073
|
updated
|
|
4022
4074
|
});
|
|
@@ -4056,7 +4108,7 @@ async function ensureIssueTypes(input) {
|
|
|
4056
4108
|
default: false
|
|
4057
4109
|
})))(`Change the organization's issue Types?\n${todo.map((a) => ` ${describeAction(a).detail} ${a.declared.name}`).join("\n")}`)) return {
|
|
4058
4110
|
status: "cancelled",
|
|
4059
|
-
rows: [row$
|
|
4111
|
+
rows: [row$35("types", "issue types", "skip", "cancelled; nothing was changed")],
|
|
4060
4112
|
created,
|
|
4061
4113
|
updated
|
|
4062
4114
|
};
|
|
@@ -4071,34 +4123,34 @@ async function ensureIssueTypes(input) {
|
|
|
4071
4123
|
continue;
|
|
4072
4124
|
}
|
|
4073
4125
|
if (limited) {
|
|
4074
|
-
rows.push(row$
|
|
4126
|
+
rows.push(row$35(name, name, "skip", "left: stopped at a rate limit"));
|
|
4075
4127
|
continue;
|
|
4076
4128
|
}
|
|
4077
4129
|
if (refusedOnce) {
|
|
4078
|
-
rows.push(row$
|
|
4130
|
+
rows.push(row$35(name, name, refused, "not written: the token was refused"));
|
|
4079
4131
|
continue;
|
|
4080
4132
|
}
|
|
4081
4133
|
try {
|
|
4082
4134
|
if (action.kind === "create") {
|
|
4083
4135
|
await issues.createType(toDeclaration(action.declared));
|
|
4084
4136
|
created.push(name);
|
|
4085
|
-
rows.push(row$
|
|
4137
|
+
rows.push(row$35(name, name, "ok", "created"));
|
|
4086
4138
|
} else {
|
|
4087
4139
|
const patch = Object.fromEntries(action.changes.map((c) => [c.field, c.to]));
|
|
4088
4140
|
await issues.updateType?.(action.existing.id, patch);
|
|
4089
4141
|
updated.push(name);
|
|
4090
|
-
rows.push(row$
|
|
4142
|
+
rows.push(row$35(name, name, "ok", `updated ${action.changes.map((c) => c.field).join(", ")}`));
|
|
4091
4143
|
}
|
|
4092
4144
|
} catch (err) {
|
|
4093
4145
|
const kind = classifyTypeError(err);
|
|
4094
4146
|
if (kind === "rate-limit") {
|
|
4095
4147
|
limited = true;
|
|
4096
|
-
rows.push(row$
|
|
4148
|
+
rows.push(row$35(name, name, "fail", "rate limited: stopped; run it again to finish"));
|
|
4097
4149
|
} else if (kind === "refused") {
|
|
4098
4150
|
refusedOnce = true;
|
|
4099
|
-
rows.push(row$
|
|
4100
|
-
} else if (kind === "conflict" && action.kind === "create" && await nowExists(issues, name)) rows.push(row$
|
|
4101
|
-
else rows.push(row$
|
|
4151
|
+
rows.push(row$35(name, name, refused, WRITE_PERMISSION));
|
|
4152
|
+
} else if (kind === "conflict" && action.kind === "create" && await nowExists(issues, name)) rows.push(row$35(name, name, "ok", "exists (made in the meantime)"));
|
|
4153
|
+
else rows.push(row$35(name, name, "fail", describeError(err)));
|
|
4102
4154
|
}
|
|
4103
4155
|
}
|
|
4104
4156
|
return {
|
|
@@ -4119,12 +4171,12 @@ async function nowExists(issues, name) {
|
|
|
4119
4171
|
/** The row of an action that is not carried out (a dry run, or the list shown before asking), or that needs none. */
|
|
4120
4172
|
function describeAction(action) {
|
|
4121
4173
|
const name = action.declared.name;
|
|
4122
|
-
if (action.kind === "create") return row$
|
|
4174
|
+
if (action.kind === "create") return row$35(name, name, "skip", "would create");
|
|
4123
4175
|
if (action.kind === "update") {
|
|
4124
4176
|
const fields = action.changes.map((c) => c.field).join(", ");
|
|
4125
|
-
return row$
|
|
4177
|
+
return row$35(name, name, "skip", `would update ${fields}`, action.changes.map((c) => `${c.field}: was ${JSON.stringify(c.was)}, to ${JSON.stringify(c.to)}`));
|
|
4126
4178
|
}
|
|
4127
|
-
return row$
|
|
4179
|
+
return row$35(name, name, "ok", action.existing.enabled ? "exists" : "exists (turned off in the organization)");
|
|
4128
4180
|
}
|
|
4129
4181
|
// src/commands/notifications-channel-add/private-host.ts
|
|
4130
4182
|
/**
|
|
@@ -6711,7 +6763,7 @@ async function openBoardContext(input) {
|
|
|
6711
6763
|
};
|
|
6712
6764
|
}
|
|
6713
6765
|
// src/commands/issue-fields/add-issue-to-board/add-issue-to-board.ts
|
|
6714
|
-
const row$
|
|
6766
|
+
const row$34 = (board, status, detail) => ({
|
|
6715
6767
|
id: `board ${board}`,
|
|
6716
6768
|
title: `board ${board}`,
|
|
6717
6769
|
status,
|
|
@@ -6733,27 +6785,27 @@ async function addIssueToBoard(input) {
|
|
|
6733
6785
|
loader: input.loader,
|
|
6734
6786
|
...input.io ? { io: input.io } : {}
|
|
6735
6787
|
});
|
|
6736
|
-
if (!opened.ok) return row$
|
|
6788
|
+
if (!opened.ok) return row$34(board, opened.kind === "skip" ? "skip" : "fail", [opened.reason, ...opened.problems].join("; "));
|
|
6737
6789
|
const { projects, owner, boards, templates } = opened.context;
|
|
6738
|
-
if (!projects.addItems) return row$
|
|
6790
|
+
if (!projects.addItems) return row$34(board, "skip", `the \`${projects.providerName}\` provider cannot add items to a board`);
|
|
6739
6791
|
const declared = boards.find((b) => b.name.toLowerCase() === board.toLowerCase());
|
|
6740
6792
|
if (!declared) {
|
|
6741
6793
|
const names = boards.map((b) => b.name).join(", ");
|
|
6742
|
-
return row$
|
|
6794
|
+
return row$34(board, "fail", `no board named "${board}" is declared in providers.projects${names ? ` (declared: ${names})` : ""}`);
|
|
6743
6795
|
}
|
|
6744
6796
|
const template = templates[declared.template];
|
|
6745
|
-
if (!template) return row$
|
|
6797
|
+
if (!template) return row$34(board, "fail", `the template "${declared.template}" of "${declared.name}" is not available`);
|
|
6746
6798
|
const found = await projects.find(owner, declared.name);
|
|
6747
|
-
if (!found) return row$
|
|
6748
|
-
if (input.dryRun) return row$
|
|
6799
|
+
if (!found) return row$34(board, "fail", `the board "${declared.name}" does not exist yet; \`holocron setup project\` makes it`);
|
|
6800
|
+
if (input.dryRun) return row$34(board, "skip", `would add ${key} to "${declared.name}"`);
|
|
6749
6801
|
const [added] = await projects.addItems(owner, found, [{
|
|
6750
6802
|
key,
|
|
6751
6803
|
...input.priority ? { priority: input.priority } : {}
|
|
6752
6804
|
}], template);
|
|
6753
6805
|
const dropped = added?.dropped ?? [];
|
|
6754
|
-
return row$
|
|
6806
|
+
return row$34(board, dropped.length > 0 ? "skip" : "ok", `${added?.added ? "added" : "already on"} "${declared.name}"${dropped.length > 0 ? `; not set: ${dropped.join(", ")}` : ""}`);
|
|
6755
6807
|
} catch (err) {
|
|
6756
|
-
return row$
|
|
6808
|
+
return row$34(board, "fail", `could not add ${key} to the board: ${describeError(err)}`);
|
|
6757
6809
|
}
|
|
6758
6810
|
}
|
|
6759
6811
|
// src/commands/issue-fields/describe-issue-fields/describe-issue-fields.ts
|
|
@@ -6860,7 +6912,7 @@ function prepareIssueFields(input, areas) {
|
|
|
6860
6912
|
* asks first unless `--dry-run` or `--yes` (without a terminal it refuses instead). `update work` is another command,
|
|
6861
6913
|
* which spans the pull request and the board.
|
|
6862
6914
|
*/
|
|
6863
|
-
const row$
|
|
6915
|
+
const row$33 = (id, status, detail) => ({
|
|
6864
6916
|
id,
|
|
6865
6917
|
title: id,
|
|
6866
6918
|
status,
|
|
@@ -6886,7 +6938,7 @@ async function runIssueUpdate(input) {
|
|
|
6886
6938
|
print(style.header(`Holocron update issue${dryRun ? " (dry-run)" : ""}`));
|
|
6887
6939
|
print("");
|
|
6888
6940
|
const key = input.key.trim();
|
|
6889
|
-
if (!key) return finish([row$
|
|
6941
|
+
if (!key) return finish([row$33("key", "fail", "the issue key is empty")]);
|
|
6890
6942
|
const prepared = prepareIssueFields(input, input.loaded.resolved.repo?.labels?.areas);
|
|
6891
6943
|
const problems = prepared.ok ? [] : [...prepared.problems];
|
|
6892
6944
|
const clear = [...new Set(input.clear ?? [])];
|
|
@@ -6913,7 +6965,7 @@ async function runIssueUpdate(input) {
|
|
|
6913
6965
|
for (const label of addLabels) if (removeLabels.some((r) => r.toLowerCase() === label.toLowerCase())) problems.push(`the label "${label}" is both added and removed`);
|
|
6914
6966
|
const blockers = prepared.ok ? prepared.fields.blockedBy ?? [] : [];
|
|
6915
6967
|
for (const k of unblock) if (blockers.includes(k)) problems.push(`${k} is both added and removed as a blocker`);
|
|
6916
|
-
if (problems.length > 0 || !prepared.ok) return finish(problems.map((p) => row$
|
|
6968
|
+
if (problems.length > 0 || !prepared.ok) return finish(problems.map((p) => row$33(key, "fail", p)));
|
|
6917
6969
|
const patch = {
|
|
6918
6970
|
...prepared.fields,
|
|
6919
6971
|
...title ? { title } : {},
|
|
@@ -6939,10 +6991,10 @@ async function runIssueUpdate(input) {
|
|
|
6939
6991
|
...unblock.length > 0 ? [`unblock: ${unblock.join(", ")}`] : [],
|
|
6940
6992
|
...clear.length > 0 ? [`clear: ${clear.join(", ")}`] : []
|
|
6941
6993
|
];
|
|
6942
|
-
if (details.length === 0) return finish([row$
|
|
6994
|
+
if (details.length === 0) return finish([row$33(key, "fail", "nothing to change; name a field to set, or `--clear` one")]);
|
|
6943
6995
|
const summary = ` (${details.join("; ")})`;
|
|
6944
6996
|
const entry = input.loaded.resolved.providers.issues;
|
|
6945
|
-
if (!entry) return finish([row$
|
|
6997
|
+
if (!entry) return finish([row$33(key, "fail", "the config has no `issues` provider to update the issue with")]);
|
|
6946
6998
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
6947
6999
|
const projects = prepared.project ? input.loaded.resolved.providers.projects : void 0;
|
|
6948
7000
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
@@ -6959,10 +7011,10 @@ async function runIssueUpdate(input) {
|
|
|
6959
7011
|
assertPluginsResolvable(loader, "update issue");
|
|
6960
7012
|
if (!loader.has("issues")) {
|
|
6961
7013
|
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
6962
|
-
return finish([row$
|
|
7014
|
+
return finish([row$33(key, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
6963
7015
|
}
|
|
6964
7016
|
const issues = loader.get("issues");
|
|
6965
|
-
if (!issues.update) return finish([row$
|
|
7017
|
+
if (!issues.update) return finish([row$33(key, "fail", `the \`${issues.providerName}\` provider does not support \`update issue\``)]);
|
|
6966
7018
|
if (dryRun) {
|
|
6967
7019
|
const board = prepared.project ? await addIssueToBoard({
|
|
6968
7020
|
loaded: input.loaded,
|
|
@@ -6972,7 +7024,7 @@ async function runIssueUpdate(input) {
|
|
|
6972
7024
|
key,
|
|
6973
7025
|
dryRun: true
|
|
6974
7026
|
}) : void 0;
|
|
6975
|
-
return finish([row$
|
|
7027
|
+
return finish([row$33(key, "skip", `would update the issue${summary}`), ...board ? [board] : []]);
|
|
6976
7028
|
}
|
|
6977
7029
|
if (!input.yes) {
|
|
6978
7030
|
if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError("`update issue` changes an issue; pass --yes to run it without asking, or --dry-run to preview");
|
|
@@ -6998,12 +7050,12 @@ async function runIssueUpdate(input) {
|
|
|
6998
7050
|
...prepared.fields.priority ? { priority: prepared.fields.priority } : {}
|
|
6999
7051
|
}) : void 0;
|
|
7000
7052
|
return finish([
|
|
7001
|
-
row$
|
|
7002
|
-
...(result.dropped ?? []).map((line) => row$
|
|
7053
|
+
row$33(result.key, "ok", result.changed.length > 0 ? `updated: ${result.changed.join("; ")}` : "already as asked; nothing changed"),
|
|
7054
|
+
...(result.dropped ?? []).map((line) => row$33("not carried across", "skip", line)),
|
|
7003
7055
|
...board ? [board] : []
|
|
7004
7056
|
], result.changed);
|
|
7005
7057
|
} catch (err) {
|
|
7006
|
-
return finish([row$
|
|
7058
|
+
return finish([row$33(key, "fail", `could not update the issue: ${describeError(err)}`)]);
|
|
7007
7059
|
}
|
|
7008
7060
|
}
|
|
7009
7061
|
// src/commands/start-work/find-worktree/find-worktree.ts
|
|
@@ -7043,7 +7095,7 @@ function unpushedCommits(git, cwd, branch) {
|
|
|
7043
7095
|
], cwd)) || 0;
|
|
7044
7096
|
}
|
|
7045
7097
|
// src/commands/close-work/clean-up-work/clean-up-work.ts
|
|
7046
|
-
const row$
|
|
7098
|
+
const row$32 = (id, status, detail) => ({
|
|
7047
7099
|
id,
|
|
7048
7100
|
title: id,
|
|
7049
7101
|
status,
|
|
@@ -7072,51 +7124,51 @@ function cleanUpWork(input) {
|
|
|
7072
7124
|
let keepBranch;
|
|
7073
7125
|
try {
|
|
7074
7126
|
const path = findWorktree(git, repoRoot, branch);
|
|
7075
|
-
if (!path) rows.push(row$
|
|
7127
|
+
if (!path) rows.push(row$32("worktree", "skip", `none holds ${branch}`));
|
|
7076
7128
|
else if (input.keepWorktree) {
|
|
7077
|
-
rows.push(row$
|
|
7129
|
+
rows.push(row$32("worktree", "skip", `kept at ${path} (--keep-worktree)`));
|
|
7078
7130
|
keepBranch = "its worktree is kept";
|
|
7079
7131
|
} else if (resolve(path) === mainWorktree(input)) {
|
|
7080
|
-
rows.push(row$
|
|
7132
|
+
rows.push(row$32("worktree", "skip", `${branch} is checked out in the main checkout; switch it to another branch first`));
|
|
7081
7133
|
keepBranch = "it is checked out in the main checkout";
|
|
7082
7134
|
} else if (resolve(repoRoot) === resolve(path) || resolve(repoRoot).startsWith(resolve(path) + sep)) {
|
|
7083
|
-
rows.push(row$
|
|
7135
|
+
rows.push(row$32("worktree", "skip", `${path} is where this command is running; run it from another checkout`));
|
|
7084
7136
|
keepBranch = "its worktree is where this command is running";
|
|
7085
7137
|
} else if (git(["status", "--porcelain"], path)) {
|
|
7086
|
-
rows.push(row$
|
|
7138
|
+
rows.push(row$32("worktree", "fail", `${path} has uncommitted changes; commit or discard them, nothing was removed`));
|
|
7087
7139
|
keepBranch = "its worktree has uncommitted changes";
|
|
7088
|
-
} else if (dryRun) rows.push(row$
|
|
7140
|
+
} else if (dryRun) rows.push(row$32("worktree", "skip", `would remove ${path}`));
|
|
7089
7141
|
else {
|
|
7090
7142
|
git([
|
|
7091
7143
|
"worktree",
|
|
7092
7144
|
"remove",
|
|
7093
7145
|
path
|
|
7094
7146
|
], repoRoot);
|
|
7095
|
-
rows.push(row$
|
|
7147
|
+
rows.push(row$32("worktree", "ok", `removed ${path}`));
|
|
7096
7148
|
}
|
|
7097
7149
|
} catch (err) {
|
|
7098
|
-
rows.push(row$
|
|
7150
|
+
rows.push(row$32("worktree", "fail", `could not remove the worktree: ${describeError(err)}`));
|
|
7099
7151
|
keepBranch = "its worktree could not be removed";
|
|
7100
7152
|
}
|
|
7101
7153
|
try {
|
|
7102
7154
|
const unpushed = unpushedCommits(git, repoRoot, branch);
|
|
7103
|
-
if (unpushed === void 0) rows.push(row$
|
|
7104
|
-
else if (keepBranch) rows.push(row$
|
|
7155
|
+
if (unpushed === void 0) rows.push(row$32("local branch", "skip", `${branch} is not in this checkout`));
|
|
7156
|
+
else if (keepBranch) rows.push(row$32("local branch", "skip", `${branch} stays: ${keepBranch}`));
|
|
7105
7157
|
else {
|
|
7106
7158
|
const tip = git(["rev-parse", `refs/heads/${branch}`], repoRoot);
|
|
7107
|
-
if (!(input.mode === "abandoned" || unpushed === 0 || input.headSha && tip === input.headSha)) rows.push(row$
|
|
7108
|
-
else if (dryRun) rows.push(row$
|
|
7159
|
+
if (!(input.mode === "abandoned" || unpushed === 0 || input.headSha && tip === input.headSha)) rows.push(row$32("local branch", "fail", `${branch} holds commits the pull request does not (tip ${tip.slice(0, 7)}); not deleted`));
|
|
7160
|
+
else if (dryRun) rows.push(row$32("local branch", "skip", `would delete ${branch}`));
|
|
7109
7161
|
else {
|
|
7110
7162
|
git([
|
|
7111
7163
|
"branch",
|
|
7112
7164
|
"-D",
|
|
7113
7165
|
branch
|
|
7114
7166
|
], repoRoot);
|
|
7115
|
-
rows.push(row$
|
|
7167
|
+
rows.push(row$32("local branch", "ok", `deleted ${branch}`));
|
|
7116
7168
|
}
|
|
7117
7169
|
}
|
|
7118
7170
|
} catch (err) {
|
|
7119
|
-
rows.push(row$
|
|
7171
|
+
rows.push(row$32("local branch", "fail", `could not delete ${branch}: ${describeError(err)}`));
|
|
7120
7172
|
}
|
|
7121
7173
|
try {
|
|
7122
7174
|
const remote = git([
|
|
@@ -7125,9 +7177,9 @@ function cleanUpWork(input) {
|
|
|
7125
7177
|
"origin",
|
|
7126
7178
|
`refs/heads/${branch}`
|
|
7127
7179
|
], repoRoot);
|
|
7128
|
-
rows.push(remote ? row$
|
|
7180
|
+
rows.push(remote ? row$32("remote branch", "skip", `${branch} is still on origin; GitHub deletes it on merge (the repo setting), or run: git push origin --delete ${branch}`) : row$32("remote branch", "ok", `${branch} is gone from origin`));
|
|
7129
7181
|
} catch (err) {
|
|
7130
|
-
rows.push(row$
|
|
7182
|
+
rows.push(row$32("remote branch", "skip", `could not ask origin: ${describeError(err)}`));
|
|
7131
7183
|
}
|
|
7132
7184
|
return rows;
|
|
7133
7185
|
}
|
|
@@ -7171,7 +7223,7 @@ function findWorkBranches(git, cwd, issue) {
|
|
|
7171
7223
|
});
|
|
7172
7224
|
}
|
|
7173
7225
|
// src/commands/close-work/abandon-work/abandon-work.ts
|
|
7174
|
-
const row$
|
|
7226
|
+
const row$31 = (id, status, detail) => ({
|
|
7175
7227
|
id,
|
|
7176
7228
|
title: id,
|
|
7177
7229
|
status,
|
|
@@ -7196,9 +7248,9 @@ async function abandonWork(a) {
|
|
|
7196
7248
|
try {
|
|
7197
7249
|
found = findWorkBranches(git, repoRoot, key);
|
|
7198
7250
|
} catch (err) {
|
|
7199
|
-
return { rows: [row$
|
|
7251
|
+
return { rows: [row$31("local branch", "fail", `could not list the branches: ${describeError(err)}`)] };
|
|
7200
7252
|
}
|
|
7201
|
-
if (found.length > 1) return { rows: [row$
|
|
7253
|
+
if (found.length > 1) return { rows: [row$31("local branch", "fail", `${found.length} branches are named for ${key} (${found.join(", ")}); --pr names the pull request whose branch to remove`)] };
|
|
7202
7254
|
branch = found[0];
|
|
7203
7255
|
}
|
|
7204
7256
|
if (branch) {
|
|
@@ -7206,9 +7258,9 @@ async function abandonWork(a) {
|
|
|
7206
7258
|
try {
|
|
7207
7259
|
unpushed = unpushedCommits(git, repoRoot, branch);
|
|
7208
7260
|
} catch (err) {
|
|
7209
|
-
return { rows: [row$
|
|
7261
|
+
return { rows: [row$31("unpushed commits", "fail", `could not read ${branch}: ${describeError(err)}`)] };
|
|
7210
7262
|
}
|
|
7211
|
-
if (unpushed !== void 0 && unpushed > 0) return { rows: [row$
|
|
7263
|
+
if (unpushed !== void 0 && unpushed > 0) return { rows: [row$31("unpushed commits", "fail", `${branch} holds ${unpushed} commit${unpushed === 1 ? "" : "s"} no remote branch has; push ${unpushed === 1 ? "it" : "them"} or delete the branch by hand. Nothing was changed`)] };
|
|
7212
7264
|
}
|
|
7213
7265
|
if (!dryRun && !input.yes) {
|
|
7214
7266
|
const what = [
|
|
@@ -7222,31 +7274,31 @@ async function abandonWork(a) {
|
|
|
7222
7274
|
};
|
|
7223
7275
|
}
|
|
7224
7276
|
let specFiles = [];
|
|
7225
|
-
if (!pr) rows.push(row$
|
|
7277
|
+
if (!pr) rows.push(row$31("pull request", "skip", `no open pull request for ${key}`));
|
|
7226
7278
|
else {
|
|
7227
7279
|
try {
|
|
7228
7280
|
specFiles = source.listPullRequestFiles ? findSpecFiles(await source.listPullRequestFiles(pr.number)) : [];
|
|
7229
7281
|
} catch (err) {
|
|
7230
|
-
rows.push(row$
|
|
7282
|
+
rows.push(row$31("spec", "fail", `could not read the pull request's files: ${describeError(err)}`));
|
|
7231
7283
|
}
|
|
7232
|
-
if (pr.state !== "open") rows.push(row$
|
|
7233
|
-
else if (!source.updatePullRequest) rows.push(row$
|
|
7234
|
-
else if (dryRun) rows.push(row$
|
|
7284
|
+
if (pr.state !== "open") rows.push(row$31("pull request", "skip", `#${pr.number} is already closed`));
|
|
7285
|
+
else if (!source.updatePullRequest) rows.push(row$31("pull request", "fail", `the \`${source.providerName}\` provider cannot close a pull request`));
|
|
7286
|
+
else if (dryRun) rows.push(row$31("pull request", "skip", `would close #${pr.number}`));
|
|
7235
7287
|
else try {
|
|
7236
7288
|
await source.updatePullRequest(pr.number, { state: "closed" });
|
|
7237
|
-
rows.push(row$
|
|
7289
|
+
rows.push(row$31("pull request", "ok", `closed #${pr.number}`));
|
|
7238
7290
|
} catch (err) {
|
|
7239
|
-
rows.push(row$
|
|
7291
|
+
rows.push(row$31("pull request", "fail", `could not close #${pr.number}: ${describeError(err)}`));
|
|
7240
7292
|
}
|
|
7241
7293
|
}
|
|
7242
7294
|
if (pr && !rows.some((r) => r.id === "spec")) {
|
|
7243
|
-
if (specFiles.length === 0) rows.push(row$
|
|
7244
|
-
else if (!input.withdrawSpecs) rows.push(row$
|
|
7295
|
+
if (specFiles.length === 0) rows.push(row$31("spec", "skip", "the pull request holds no spec or ADR, so no post to withdraw"));
|
|
7296
|
+
else if (!input.withdrawSpecs) rows.push(row$31("spec", "fail", "no way to withdraw the post was given"));
|
|
7245
7297
|
else try {
|
|
7246
7298
|
const result = await input.withdrawSpecs(specFiles);
|
|
7247
|
-
rows.push(row$
|
|
7299
|
+
rows.push(row$31("spec", result.ok ? "ok" : "fail", `${specFiles.join(", ")}: ${result.detail}`));
|
|
7248
7300
|
} catch (err) {
|
|
7249
|
-
rows.push(row$
|
|
7301
|
+
rows.push(row$31("spec", "fail", `could not withdraw the post: ${describeError(err)}`));
|
|
7250
7302
|
}
|
|
7251
7303
|
}
|
|
7252
7304
|
if (branch) rows.push(...cleanUpWork({
|
|
@@ -7257,9 +7309,9 @@ async function abandonWork(a) {
|
|
|
7257
7309
|
mode: "abandoned",
|
|
7258
7310
|
...input.keepWorktree ? { keepWorktree: true } : {}
|
|
7259
7311
|
}));
|
|
7260
|
-
else rows.push(row$
|
|
7261
|
-
if (dryRun) rows.push(row$
|
|
7262
|
-
else if (input.yes) rows.push(row$
|
|
7312
|
+
else rows.push(row$31("local branch", "skip", `no local branch is named for ${key}`));
|
|
7313
|
+
if (dryRun) rows.push(row$31("issue", "skip", `would ask whether to close ${key} as not planned`));
|
|
7314
|
+
else if (input.yes) rows.push(row$31("issue", "skip", `${key} left open: --yes does not close an issue; run \`holocron update issue ${key} --state closed --state-reason not_planned\` to close it as not planned`));
|
|
7263
7315
|
else if (await a.ask(`Close ${key} as not planned?`)) {
|
|
7264
7316
|
const close = await (input.updateIssue ?? runIssueUpdate)({
|
|
7265
7317
|
key,
|
|
@@ -7276,7 +7328,7 @@ async function abandonWork(a) {
|
|
|
7276
7328
|
id: `issue: ${r.id}`,
|
|
7277
7329
|
title: `issue: ${r.title}`
|
|
7278
7330
|
});
|
|
7279
|
-
} else rows.push(row$
|
|
7331
|
+
} else rows.push(row$31("issue", "skip", `${key} left open`));
|
|
7280
7332
|
return { rows };
|
|
7281
7333
|
}
|
|
7282
7334
|
// src/commands/update-work/find-work-pull-request/find-work-pull-request.ts
|
|
@@ -7755,7 +7807,7 @@ function workTitle(input) {
|
|
|
7755
7807
|
const MAX_TITLE = 100;
|
|
7756
7808
|
const DEFAULT_BASE = "alpha";
|
|
7757
7809
|
const WORKTREES = ".claude/worktrees";
|
|
7758
|
-
const row$
|
|
7810
|
+
const row$30 = (id, status, detail) => ({
|
|
7759
7811
|
id,
|
|
7760
7812
|
title: id,
|
|
7761
7813
|
status,
|
|
@@ -7791,7 +7843,7 @@ async function runStartWork(input) {
|
|
|
7791
7843
|
};
|
|
7792
7844
|
};
|
|
7793
7845
|
const fail = (id, detail) => {
|
|
7794
|
-
rows.push(row$
|
|
7846
|
+
rows.push(row$30(id, "fail", detail));
|
|
7795
7847
|
return finish();
|
|
7796
7848
|
};
|
|
7797
7849
|
print(style.header(`Holocron start work${dryRun ? " (dry-run)" : ""}`));
|
|
@@ -7847,7 +7899,7 @@ async function runStartWork(input) {
|
|
|
7847
7899
|
} catch (err) {
|
|
7848
7900
|
return fail(key, `could not read the issue: ${describeError(err)}`);
|
|
7849
7901
|
}
|
|
7850
|
-
rows.push(row$
|
|
7902
|
+
rows.push(row$30(key, "ok", `${issue.summary} (${issue.status})`));
|
|
7851
7903
|
const named = workTitle({
|
|
7852
7904
|
issueTitle: issue.summary,
|
|
7853
7905
|
...input.kind ? {
|
|
@@ -7890,14 +7942,14 @@ async function runStartWork(input) {
|
|
|
7890
7942
|
...source ? [`draft pull request "${title}" (${link.keyword} ${key})`] : ["no pull request"]
|
|
7891
7943
|
].join("; ");
|
|
7892
7944
|
if (dryRun) {
|
|
7893
|
-
rows.push(row$
|
|
7894
|
-
rows.push(row$
|
|
7895
|
-
rows.push(row$
|
|
7896
|
-
if (useWorktree) rows.push(row$
|
|
7897
|
-
rows.push(row$
|
|
7898
|
-
rows.push(row$
|
|
7899
|
-
if (source) rows.push(row$
|
|
7900
|
-
rows.push(row$
|
|
7945
|
+
rows.push(row$30("title", "skip", `${title} (${named.reason}${releaseNote})`));
|
|
7946
|
+
rows.push(row$30("start date", "skip", `would set the start date${input.effort ? ` and Effort ${input.effort}` : ""}${branchExists ? " (not again: the branch exists)" : ""}`));
|
|
7947
|
+
rows.push(row$30("branch", "skip", `would ${branchExists ? "reuse" : "make"} ${branch} from origin/${base}`));
|
|
7948
|
+
if (useWorktree) rows.push(row$30("worktree", "skip", `would use ${wtPath}`));
|
|
7949
|
+
rows.push(row$30("first commit", "skip", `would commit${spec ? ` ${spec.rel}` : " empty"} as "${commitSubject}"`));
|
|
7950
|
+
rows.push(row$30("push", "skip", `would push ${branch} to origin`));
|
|
7951
|
+
if (source) rows.push(row$30("pull request", "skip", `would open a draft pull request against ${base}, ${link.keyword} ${key}`));
|
|
7952
|
+
rows.push(row$30("board status", "skip", "the open pull request moves the issue to In Progress"));
|
|
7901
7953
|
return finish();
|
|
7902
7954
|
}
|
|
7903
7955
|
if (!input.yes) {
|
|
@@ -7913,18 +7965,18 @@ async function runStartWork(input) {
|
|
|
7913
7965
|
};
|
|
7914
7966
|
}
|
|
7915
7967
|
}
|
|
7916
|
-
rows.push(row$
|
|
7917
|
-
if (branchExists) rows.push(row$
|
|
7918
|
-
else if (!issues.update) rows.push(row$
|
|
7968
|
+
rows.push(row$30("title", "ok", `${title} (${named.reason}${releaseNote})`));
|
|
7969
|
+
if (branchExists) rows.push(row$30("start date", "skip", "the branch exists, so the work started before; the start date is left as it is"));
|
|
7970
|
+
else if (!issues.update) rows.push(row$30("start date", "skip", `the \`${issues.providerName}\` provider cannot update an issue`));
|
|
7919
7971
|
else try {
|
|
7920
7972
|
const result = await issues.update(key, {
|
|
7921
7973
|
startDate: io.today(),
|
|
7922
7974
|
...input.effort ? { effort: input.effort } : {}
|
|
7923
7975
|
});
|
|
7924
|
-
rows.push(row$
|
|
7925
|
-
for (const line of result.dropped ?? []) rows.push(row$
|
|
7976
|
+
rows.push(row$30("start date", "ok", result.changed.length > 0 ? result.changed.join(", ") : "already as asked"));
|
|
7977
|
+
for (const line of result.dropped ?? []) rows.push(row$30("not carried across", "skip", line));
|
|
7926
7978
|
} catch (err) {
|
|
7927
|
-
rows.push(row$
|
|
7979
|
+
rows.push(row$30("start date", "fail", `could not update the issue: ${describeError(err)}`));
|
|
7928
7980
|
}
|
|
7929
7981
|
let dir = root;
|
|
7930
7982
|
try {
|
|
@@ -7953,7 +8005,7 @@ async function runStartWork(input) {
|
|
|
7953
8005
|
"--abbrev-ref",
|
|
7954
8006
|
"HEAD"
|
|
7955
8007
|
], root) !== branch && dir === root) io.git(["switch", branch], root);
|
|
7956
|
-
rows.push(row$
|
|
8008
|
+
rows.push(row$30("branch", "ok", `${branch} already exists; reused`));
|
|
7957
8009
|
} else if (useWorktree) {
|
|
7958
8010
|
io.git([
|
|
7959
8011
|
"worktree",
|
|
@@ -7965,7 +8017,7 @@ async function runStartWork(input) {
|
|
|
7965
8017
|
start
|
|
7966
8018
|
], root);
|
|
7967
8019
|
dir = wtPath;
|
|
7968
|
-
rows.push(row$
|
|
8020
|
+
rows.push(row$30("branch", "ok", `made ${branch} from ${start}`));
|
|
7969
8021
|
} else {
|
|
7970
8022
|
io.git([
|
|
7971
8023
|
"switch",
|
|
@@ -7974,19 +8026,19 @@ async function runStartWork(input) {
|
|
|
7974
8026
|
branch,
|
|
7975
8027
|
start
|
|
7976
8028
|
], root);
|
|
7977
|
-
rows.push(row$
|
|
8029
|
+
rows.push(row$30("branch", "ok", `made ${branch} from ${start} and switched to it`));
|
|
7978
8030
|
}
|
|
7979
8031
|
report = {
|
|
7980
8032
|
...report,
|
|
7981
8033
|
directory: dir
|
|
7982
8034
|
};
|
|
7983
|
-
if (useWorktree) rows.push(row$
|
|
8035
|
+
if (useWorktree) rows.push(row$30("worktree", "ok", dir));
|
|
7984
8036
|
const ahead = Number(git([
|
|
7985
8037
|
"rev-list",
|
|
7986
8038
|
"--count",
|
|
7987
8039
|
`${start}..${branch}`
|
|
7988
8040
|
]) || "0");
|
|
7989
|
-
if (ahead > 0) rows.push(row$
|
|
8041
|
+
if (ahead > 0) rows.push(row$30("first commit", "skip", `${branch} already has ${ahead} commit${ahead === 1 ? "" : "s"}`));
|
|
7990
8042
|
else {
|
|
7991
8043
|
const trailer = `Refs ${workReference(key)}`;
|
|
7992
8044
|
if (spec) {
|
|
@@ -7997,7 +8049,7 @@ async function runStartWork(input) {
|
|
|
7997
8049
|
spec.rel
|
|
7998
8050
|
], dir);
|
|
7999
8051
|
const status = /^status:\s*(\S+)/m.exec(io.read(spec.abs))?.[1];
|
|
8000
|
-
if (status && status !== "draft") rows.push(row$
|
|
8052
|
+
if (status && status !== "draft") rows.push(row$30("spec", "skip", `the spec's status is ${status}, not draft`));
|
|
8001
8053
|
}
|
|
8002
8054
|
io.git([
|
|
8003
8055
|
"commit",
|
|
@@ -8008,7 +8060,7 @@ async function runStartWork(input) {
|
|
|
8008
8060
|
"-m",
|
|
8009
8061
|
trailer
|
|
8010
8062
|
], dir);
|
|
8011
|
-
rows.push(row$
|
|
8063
|
+
rows.push(row$30("first commit", "ok", `${io.git([
|
|
8012
8064
|
"rev-parse",
|
|
8013
8065
|
"--short",
|
|
8014
8066
|
"HEAD"
|
|
@@ -8020,9 +8072,9 @@ async function runStartWork(input) {
|
|
|
8020
8072
|
"origin",
|
|
8021
8073
|
branch
|
|
8022
8074
|
], dir);
|
|
8023
|
-
rows.push(row$
|
|
8075
|
+
rows.push(row$30("push", "ok", `${branch} is on origin`));
|
|
8024
8076
|
} catch (err) {
|
|
8025
|
-
rows.push(row$
|
|
8077
|
+
rows.push(row$30("git", "fail", `${describeError(err)}; nothing was deleted, run the command again to carry on`));
|
|
8026
8078
|
return finish();
|
|
8027
8079
|
}
|
|
8028
8080
|
if (source) try {
|
|
@@ -8038,7 +8090,7 @@ async function runStartWork(input) {
|
|
|
8038
8090
|
...input.templatesIo ? { templatesIo: input.templatesIo } : {}
|
|
8039
8091
|
});
|
|
8040
8092
|
issueBoards = read.boards;
|
|
8041
|
-
if (read.problem) rows.push(row$
|
|
8093
|
+
if (read.problem) rows.push(row$30("boards", "skip", `the pull request is not put on the issue's boards: ${read.problem}`));
|
|
8042
8094
|
}
|
|
8043
8095
|
const projects = [.../* @__PURE__ */ new Set([...issueBoards, ...input.project ? [input.project] : []])];
|
|
8044
8096
|
const mirrored = {
|
|
@@ -8070,12 +8122,12 @@ async function runStartWork(input) {
|
|
|
8070
8122
|
created: result.created
|
|
8071
8123
|
}
|
|
8072
8124
|
};
|
|
8073
|
-
rows.push(row$
|
|
8074
|
-
for (const line of result.dropped) rows.push(row$
|
|
8125
|
+
rows.push(row$30("pull request", "ok", `${result.created ? "opened" : "already open:"} #${pr.number}${result.draft ? " (draft)" : ""} ${pr.url}`));
|
|
8126
|
+
for (const line of result.dropped) rows.push(row$30("not carried across", "skip", line));
|
|
8075
8127
|
} catch (err) {
|
|
8076
|
-
rows.push(row$
|
|
8128
|
+
rows.push(row$30("pull request", "fail", `could not open the pull request: ${describeError(err)}; run the command again to open it`));
|
|
8077
8129
|
}
|
|
8078
|
-
rows.push(row$
|
|
8130
|
+
rows.push(row$30("board status", "skip", "not set: the open pull request moves the issue to In Progress; `update work --status` sets it by hand while the automation is down"));
|
|
8079
8131
|
return finish();
|
|
8080
8132
|
}
|
|
8081
8133
|
// src/commands/update-work/guard-work-status/guard-work-status.ts
|
|
@@ -8123,7 +8175,7 @@ function guardWorkStatus(status, force) {
|
|
|
8123
8175
|
* terminal it refuses). `--dry-run` runs the reads and writes nothing. A run with nothing to change still syncs the
|
|
8124
8176
|
* area labels.
|
|
8125
8177
|
*/
|
|
8126
|
-
const row$
|
|
8178
|
+
const row$29 = (id, status, detail) => ({
|
|
8127
8179
|
id,
|
|
8128
8180
|
title: id,
|
|
8129
8181
|
status,
|
|
@@ -8157,7 +8209,7 @@ async function runUpdateWork(input) {
|
|
|
8157
8209
|
};
|
|
8158
8210
|
};
|
|
8159
8211
|
const fail = (id, detail) => {
|
|
8160
|
-
rows.push(row$
|
|
8212
|
+
rows.push(row$29(id, "fail", detail));
|
|
8161
8213
|
return finish();
|
|
8162
8214
|
};
|
|
8163
8215
|
print(style.header(`Holocron update work${dryRun ? " (dry-run)" : ""}`));
|
|
@@ -8246,7 +8298,7 @@ async function runUpdateWork(input) {
|
|
|
8246
8298
|
title: `start: ${r.title}`
|
|
8247
8299
|
});
|
|
8248
8300
|
if (started.status === "fail") {
|
|
8249
|
-
rows.push(row$
|
|
8301
|
+
rows.push(row$29("update work", "skip", "start work failed, so nothing after it was run"));
|
|
8250
8302
|
return finish();
|
|
8251
8303
|
}
|
|
8252
8304
|
}
|
|
@@ -8258,10 +8310,10 @@ async function runUpdateWork(input) {
|
|
|
8258
8310
|
} else if (source.listPullRequests) {
|
|
8259
8311
|
const found = findWorkPullRequests(await source.listPullRequests("open"), key);
|
|
8260
8312
|
pr = found[0];
|
|
8261
|
-
if (found.length > 1) rows.push(row$
|
|
8313
|
+
if (found.length > 1) rows.push(row$29("pull request", "skip", `${found.length} open pull requests match ${key}; using #${pr?.number} (--pr names another)`));
|
|
8262
8314
|
}
|
|
8263
8315
|
} catch (err) {
|
|
8264
|
-
rows.push(row$
|
|
8316
|
+
rows.push(row$29("pull request", "fail", `could not find the pull request: ${describeError(err)}`));
|
|
8265
8317
|
return finish();
|
|
8266
8318
|
}
|
|
8267
8319
|
if (pr) {
|
|
@@ -8272,24 +8324,24 @@ async function runUpdateWork(input) {
|
|
|
8272
8324
|
url: pr.url
|
|
8273
8325
|
}
|
|
8274
8326
|
};
|
|
8275
|
-
rows.push(row$
|
|
8327
|
+
rows.push(row$29("pull request", "ok", `#${pr.number} ${pr.title}`));
|
|
8276
8328
|
} else {
|
|
8277
8329
|
const detail = `no open pull request for ${key} (its branch is <type>/<issue>-<slug>; --pr names one, --start makes one)`;
|
|
8278
|
-
rows.push(row$
|
|
8330
|
+
rows.push(row$29("pull request", title ? "fail" : "skip", title ? `${detail}; --title needs one` : detail));
|
|
8279
8331
|
}
|
|
8280
8332
|
let derived = [];
|
|
8281
|
-
if (!pr) rows.push(row$
|
|
8282
|
-
else if (!areas || Object.keys(areas).length === 0) rows.push(row$
|
|
8283
|
-
else if (!source.listPullRequestFiles) rows.push(row$
|
|
8333
|
+
if (!pr) rows.push(row$29("area labels", "skip", "no pull request to read the changed folders of"));
|
|
8334
|
+
else if (!areas || Object.keys(areas).length === 0) rows.push(row$29("area labels", "skip", "the repo declares no `repo.labels.areas`"));
|
|
8335
|
+
else if (!source.listPullRequestFiles) rows.push(row$29("area labels", "skip", `the \`${source.providerName}\` provider cannot list a pull request's files`));
|
|
8284
8336
|
else try {
|
|
8285
8337
|
derived = areaLabelsForFiles(await source.listPullRequestFiles(pr.number), areas);
|
|
8286
8338
|
report = {
|
|
8287
8339
|
...report,
|
|
8288
8340
|
areaLabels: derived
|
|
8289
8341
|
};
|
|
8290
|
-
rows.push(row$
|
|
8342
|
+
rows.push(row$29("area labels", derived.length > 0 ? "ok" : "skip", derived.length > 0 ? derived.join(", ") : "the changed folders are in no area"));
|
|
8291
8343
|
} catch (err) {
|
|
8292
|
-
rows.push(row$
|
|
8344
|
+
rows.push(row$29("area labels", "fail", `could not read the changed files: ${describeError(err)}`));
|
|
8293
8345
|
}
|
|
8294
8346
|
let missingOnIssue = derived;
|
|
8295
8347
|
if (derived.length > 0 && issues.export) try {
|
|
@@ -8326,7 +8378,7 @@ async function runUpdateWork(input) {
|
|
|
8326
8378
|
id: `issue: ${r.id}`,
|
|
8327
8379
|
title: `issue: ${r.title}`
|
|
8328
8380
|
});
|
|
8329
|
-
} else rows.push(row$
|
|
8381
|
+
} else rows.push(row$29("issue", "skip", "no issue field to change"));
|
|
8330
8382
|
if (pr) {
|
|
8331
8383
|
const prLabels = unique([...addLabels, ...derived]);
|
|
8332
8384
|
const patch = {
|
|
@@ -8345,15 +8397,15 @@ async function runUpdateWork(input) {
|
|
|
8345
8397
|
...milestone ? [`milestone ${milestone}`] : [],
|
|
8346
8398
|
...input.project ? [`board ${input.project}`] : []
|
|
8347
8399
|
];
|
|
8348
|
-
if (parts.length === 0) rows.push(row$
|
|
8349
|
-
else if (!source.updatePullRequest) rows.push(row$
|
|
8350
|
-
else if (dryRun) rows.push(row$
|
|
8400
|
+
if (parts.length === 0) rows.push(row$29(`pull request #${pr.number}`, "skip", "no field to change"));
|
|
8401
|
+
else if (!source.updatePullRequest) rows.push(row$29(`pull request #${pr.number}`, "fail", `the \`${source.providerName}\` provider cannot update a pull request`));
|
|
8402
|
+
else if (dryRun) rows.push(row$29(`pull request #${pr.number}`, "skip", `would update ${parts.join("; ")}`));
|
|
8351
8403
|
else try {
|
|
8352
8404
|
const result = await source.updatePullRequest(pr.number, patch);
|
|
8353
|
-
rows.push(row$
|
|
8354
|
-
for (const line of result.dropped) rows.push(row$
|
|
8405
|
+
rows.push(row$29(`pull request #${pr.number}`, "ok", `updated ${parts.join("; ")}`));
|
|
8406
|
+
for (const line of result.dropped) rows.push(row$29("not carried across", "skip", line));
|
|
8355
8407
|
} catch (err) {
|
|
8356
|
-
rows.push(row$
|
|
8408
|
+
rows.push(row$29(`pull request #${pr.number}`, "fail", `could not update the pull request: ${describeError(err)}`));
|
|
8357
8409
|
}
|
|
8358
8410
|
}
|
|
8359
8411
|
if (status) {
|
|
@@ -8369,11 +8421,11 @@ async function runUpdateWork(input) {
|
|
|
8369
8421
|
...input.board ? { board: input.board } : {}
|
|
8370
8422
|
});
|
|
8371
8423
|
const change = set.key && set.to ? `${set.key} ${set.from ?? "no status"} → ${set.to}` : `${key} → ${status}`;
|
|
8372
|
-
rows.push(set.status === "ok" ? row$
|
|
8424
|
+
rows.push(set.status === "ok" ? row$29("board status", dryRun ? "skip" : "ok", dryRun ? `would set ${change}` : change) : row$29("board status", "fail", sub.lines.map((l) => l.trim()).filter(Boolean).join("; ") || "could not set the status"));
|
|
8373
8425
|
} catch (err) {
|
|
8374
|
-
rows.push(row$
|
|
8426
|
+
rows.push(row$29("board status", "fail", describeError(err)));
|
|
8375
8427
|
}
|
|
8376
|
-
rows.push(row$
|
|
8428
|
+
rows.push(row$29("board status is temporary", "skip", guard?.ok && guard.forced ? "forced: the automation owns this status and overwrites it once it runs again (#2388)" : "the board's rules overwrite a hand-set status once the pull request moves it (#2388)"));
|
|
8377
8429
|
}
|
|
8378
8430
|
return finish();
|
|
8379
8431
|
}
|
|
@@ -8392,7 +8444,7 @@ function findClosedWorkPullRequests(prs, issue) {
|
|
|
8392
8444
|
return [...matching.filter((pr) => pr.merged), ...matching.filter((pr) => !pr.merged)];
|
|
8393
8445
|
}
|
|
8394
8446
|
// src/commands/close-work/release-closed-blockers/release-closed-blockers.ts
|
|
8395
|
-
const row$
|
|
8447
|
+
const row$28 = (id, status, detail) => ({
|
|
8396
8448
|
id,
|
|
8397
8449
|
title: id,
|
|
8398
8450
|
status,
|
|
@@ -8406,16 +8458,16 @@ const row$26 = (id, status, detail) => ({
|
|
|
8406
8458
|
*/
|
|
8407
8459
|
async function releaseClosedBlockers(input) {
|
|
8408
8460
|
const { issues, key } = input;
|
|
8409
|
-
if (!issues.export) return [row$
|
|
8461
|
+
if (!issues.export) return [row$28("relations", "skip", `the \`${issues.providerName}\` provider cannot read blockers`)];
|
|
8410
8462
|
try {
|
|
8411
8463
|
const blockers = (await issues.export({ keys: [key] }))[0]?.blockedBy ?? [];
|
|
8412
|
-
if (blockers.length === 0) return [row$
|
|
8464
|
+
if (blockers.length === 0) return [row$28("relations", "skip", `${key} has no blockers`)];
|
|
8413
8465
|
const closed = (await issues.export({ keys: blockers })).filter((r) => r.closed).map((r) => r.key);
|
|
8414
|
-
if (closed.length === 0) return [row$
|
|
8466
|
+
if (closed.length === 0) return [row$28("relations", "skip", `${blockers.length} blocker${blockers.length === 1 ? "" : "s"} still open: ${blockers.join(", ")}`)];
|
|
8415
8467
|
const done = await input.unblock(closed);
|
|
8416
|
-
return [row$
|
|
8468
|
+
return [row$28("relations", done.status === "fail" ? "fail" : "ok", `closed ${closed.length === 1 ? "blocker" : "blockers"} ${closed.join(", ")} taken off ${key}`), ...done.rows.filter((r) => r.status === "fail")];
|
|
8417
8469
|
} catch (err) {
|
|
8418
|
-
return [row$
|
|
8470
|
+
return [row$28("relations", "fail", `could not update the blockers: ${describeError(err)}`)];
|
|
8419
8471
|
}
|
|
8420
8472
|
}
|
|
8421
8473
|
// src/commands/close-work/wait-for-checks/wait-for-checks.ts
|
|
@@ -8952,8 +9004,8 @@ async function withdrawSpecs(loaded, context, files) {
|
|
|
8952
9004
|
const DEFAULT_TIMEOUT_MINUTES = 30;
|
|
8953
9005
|
const DEFAULT_INTERVAL_MS = 3e4;
|
|
8954
9006
|
/** How many failing checks a row names. */
|
|
8955
|
-
const MAX_NAMED = 8;
|
|
8956
|
-
const row$
|
|
9007
|
+
const MAX_NAMED$1 = 8;
|
|
9008
|
+
const row$27 = (id, status, detail) => ({
|
|
8957
9009
|
id,
|
|
8958
9010
|
title: id,
|
|
8959
9011
|
status,
|
|
@@ -8978,7 +9030,7 @@ async function runCloseWork(input) {
|
|
|
8978
9030
|
};
|
|
8979
9031
|
};
|
|
8980
9032
|
const fail = (id, detail) => {
|
|
8981
|
-
rows.push(row$
|
|
9033
|
+
rows.push(row$27(id, "fail", detail));
|
|
8982
9034
|
return finish();
|
|
8983
9035
|
};
|
|
8984
9036
|
print(style.header(`Holocron close work${input.abandon ? " --abandon" : ""}${dryRun ? " (dry-run)" : ""}`));
|
|
@@ -9026,7 +9078,7 @@ async function runCloseWork(input) {
|
|
|
9026
9078
|
if (!source.listPullRequests) throw new Error(`the \`${source.providerName}\` provider cannot list pull requests`);
|
|
9027
9079
|
const open = findWorkPullRequests(await source.listPullRequests("open"), key);
|
|
9028
9080
|
pr = open[0];
|
|
9029
|
-
if (open.length > 1) rows.push(row$
|
|
9081
|
+
if (open.length > 1) rows.push(row$27("pull request", "skip", `${open.length} open pull requests match ${key}; using #${pr?.number} (--pr names another)`));
|
|
9030
9082
|
if (!pr && !input.abandon) pr = findClosedWorkPullRequests(await source.listPullRequests("closed"), key)[0];
|
|
9031
9083
|
}
|
|
9032
9084
|
} catch (err) {
|
|
@@ -9064,10 +9116,10 @@ async function runCloseWork(input) {
|
|
|
9064
9116
|
const repoRoot = input.context.repoRoot;
|
|
9065
9117
|
if (pr.state === "closed") {
|
|
9066
9118
|
if (!pr.merged) {
|
|
9067
|
-
rows.push(row$
|
|
9119
|
+
rows.push(row$27("pull request", "skip", `#${pr.number} was closed without merging; \`close work ${key} --abandon\` tidies its branch and spec`));
|
|
9068
9120
|
return finish();
|
|
9069
9121
|
}
|
|
9070
|
-
rows.push(row$
|
|
9122
|
+
rows.push(row$27("pull request", "ok", `#${pr.number} merged: ${pr.title}`));
|
|
9071
9123
|
if (!dryRun && !input.yes && !await ask(`Remove the worktree and local branch of ${pr.branch}?`)) {
|
|
9072
9124
|
print(` ${style.skip("cancelled; nothing was changed")}`);
|
|
9073
9125
|
return {
|
|
@@ -9086,7 +9138,7 @@ async function runCloseWork(input) {
|
|
|
9086
9138
|
}));
|
|
9087
9139
|
return finish();
|
|
9088
9140
|
}
|
|
9089
|
-
rows.push(row$
|
|
9141
|
+
rows.push(row$27("pull request", "ok", `#${pr.number} ${pr.title}`));
|
|
9090
9142
|
if (!source.getPullRequestChecks) return fail("ci / Required checks", `the \`${source.providerName}\` provider cannot read a pull request's checks`);
|
|
9091
9143
|
const readChecks = source.getPullRequestChecks.bind(source);
|
|
9092
9144
|
const number = pr.number;
|
|
@@ -9107,12 +9159,12 @@ async function runCloseWork(input) {
|
|
|
9107
9159
|
}
|
|
9108
9160
|
const { checks } = result;
|
|
9109
9161
|
if (checks.state !== "success") {
|
|
9110
|
-
const failing = checks.failing.slice(0, MAX_NAMED).map((c) => c.url ? `${c.name} (${c.url})` : c.name);
|
|
9162
|
+
const failing = checks.failing.slice(0, MAX_NAMED$1).map((c) => c.url ? `${c.name} (${c.url})` : c.name);
|
|
9111
9163
|
const more = checks.failing.length - failing.length;
|
|
9112
9164
|
const named = failing.length > 0 ? `: ${failing.join(", ")}${more > 0 ? `, and ${more} more` : ""}` : "";
|
|
9113
9165
|
return fail("ci / Required checks", `${checks.state === "failure" ? `is red${named}` : result.timedOut ? `is still ${checks.state} after ${minutes} minute${minutes === 1 ? "" : "s"}` : `is ${checks.state === "none" ? "not posted yet" : "still running"}; --wait polls until it is green`}. #${number} was not marked ready; run \`close work ${key}\` again once it is green`);
|
|
9114
9166
|
}
|
|
9115
|
-
rows.push(row$
|
|
9167
|
+
rows.push(row$27("ci / Required checks", "ok", `green${checks.sha ? ` on ${checks.sha.slice(0, 7)}` : ""}`));
|
|
9116
9168
|
if (!dryRun && !input.yes) {
|
|
9117
9169
|
if (!await ask(`${key} is green. ${`Mark #${number} ready, update the area labels and take closed blockers off ${key}`}?`)) {
|
|
9118
9170
|
print(` ${style.skip("cancelled; nothing was changed")}`);
|
|
@@ -9122,13 +9174,13 @@ async function runCloseWork(input) {
|
|
|
9122
9174
|
};
|
|
9123
9175
|
}
|
|
9124
9176
|
}
|
|
9125
|
-
if (!source.markReady) rows.push(row$
|
|
9126
|
-
else if (dryRun) rows.push(row$
|
|
9177
|
+
if (!source.markReady) rows.push(row$27("ready", "fail", `the \`${source.providerName}\` provider cannot mark a pull request ready`));
|
|
9178
|
+
else if (dryRun) rows.push(row$27("ready", "skip", `would mark #${number} ready if it is a draft`));
|
|
9127
9179
|
else try {
|
|
9128
9180
|
const changed = await source.markReady(number);
|
|
9129
|
-
rows.push(row$
|
|
9181
|
+
rows.push(row$27("ready", "ok", changed ? `#${number} is ready for review; the board moves to In Review by itself. The maintainer merges, \`close work ${key}\` again after that clears the checkout` : `#${number} was already ready; the maintainer merges`));
|
|
9130
9182
|
} catch (err) {
|
|
9131
|
-
rows.push(row$
|
|
9183
|
+
rows.push(row$27("ready", "fail", `could not mark #${number} ready: ${describeError(err)}`));
|
|
9132
9184
|
}
|
|
9133
9185
|
try {
|
|
9134
9186
|
const updated = await (input.updateWork ?? runUpdateWork)({
|
|
@@ -9146,7 +9198,7 @@ async function runCloseWork(input) {
|
|
|
9146
9198
|
title: `labels: ${r.title}`
|
|
9147
9199
|
});
|
|
9148
9200
|
} catch (err) {
|
|
9149
|
-
rows.push(row$
|
|
9201
|
+
rows.push(row$27("labels", "fail", `could not update the area labels: ${describeError(err)}`));
|
|
9150
9202
|
}
|
|
9151
9203
|
rows.push(...await releaseClosedBlockers({
|
|
9152
9204
|
issues,
|
|
@@ -10669,9 +10721,19 @@ const byId = (ids) => new Map(ids.map((id) => [id, id]));
|
|
|
10669
10721
|
* stale. A skip when the repo has no aggregate caller, which only the repo that hosts the reusables writes today. The
|
|
10670
10722
|
* ruleset that requires the aggregate is `doctor repo`'s to compare, not this row's.
|
|
10671
10723
|
*/
|
|
10672
|
-
function aggregateRow(callers, derived) {
|
|
10724
|
+
function aggregateRow(callers, derived, poster = "actions") {
|
|
10673
10725
|
const id = "aggregate";
|
|
10674
10726
|
const title = "ci aggregate lists the configured tasks";
|
|
10727
|
+
if (poster === "sentinel") {
|
|
10728
|
+
const left = callers.find((caller) => caller.file === "ci.ci.yml" || caller.file === "ci.yml");
|
|
10729
|
+
return left === void 0 ? {
|
|
10730
|
+
id,
|
|
10731
|
+
title,
|
|
10732
|
+
status: "ok",
|
|
10733
|
+
detail: `Sentinel posts the aggregate (ci.aggregate); its expected list derives from the config (${derived.length} ids)`,
|
|
10734
|
+
problems: []
|
|
10735
|
+
} : problemRow(id, title, [`${left.file} is still there, but ci.aggregate says Sentinel posts the check: two posters`], "");
|
|
10736
|
+
}
|
|
10675
10737
|
const aggregate = callers.find((caller) => (caller.file === "ci.ci.yml" || caller.file === "ci.yml") && caller.expected !== void 0);
|
|
10676
10738
|
if (aggregate === void 0) return {
|
|
10677
10739
|
id,
|
|
@@ -10866,6 +10928,129 @@ function realCiIo(repoRoot) {
|
|
|
10866
10928
|
} };
|
|
10867
10929
|
/* v8 ignore stop */
|
|
10868
10930
|
}
|
|
10931
|
+
// src/commands/doctor-ci/shadow-verdict.ts
|
|
10932
|
+
/**
|
|
10933
|
+
* The verdict of the newest run named `name` among a commit's check runs: still running is `pending`, a completed
|
|
10934
|
+
* `success` is `success` and any other completed result is `failure`. The newest is the one with the latest start and,
|
|
10935
|
+
* on a tie, the higher id, the rule the aggregate itself follows. `undefined` when nothing posted under the name.
|
|
10936
|
+
*/
|
|
10937
|
+
function shadowVerdict(runs, name) {
|
|
10938
|
+
const newest = runs.filter((run) => run.name === name).sort((a, b) => (b.startedAt ?? "").localeCompare(a.startedAt ?? "") || Number(b.id) - Number(a.id))[0];
|
|
10939
|
+
if (newest === void 0) return void 0;
|
|
10940
|
+
if (newest.status !== "completed") return "pending";
|
|
10941
|
+
return newest.conclusion === "success" ? "success" : "failure";
|
|
10942
|
+
}
|
|
10943
|
+
// src/commands/doctor-ci/read-shadow-samples.ts
|
|
10944
|
+
/** The name Sentinel's shadow posts under; the same string as Sentinel's `SENTINEL_CI_AGGREGATE_SHADOW_NAME`. */
|
|
10945
|
+
const SHADOW_CHECK_NAME = `${AGGREGATE_CHECK_NAME} (sentinel)`;
|
|
10946
|
+
/**
|
|
10947
|
+
* The two aggregate verdicts of the newest pull requests, newest first: the open ones and the merged ones (a pull
|
|
10948
|
+
* request closed without merging has no verdict worth comparing), at most `limit` of them. Each is read from the check
|
|
10949
|
+
* runs of the pull request's head commit through the `source` provider.
|
|
10950
|
+
*/
|
|
10951
|
+
async function readShadowSamples(source, limit = 40) {
|
|
10952
|
+
const [open, closed] = await Promise.all([source.listPullRequests("open"), source.listPullRequests("closed")]);
|
|
10953
|
+
const newest = [...open, ...closed.filter((pr) => pr.merged)].filter((pr) => pr.headSha !== void 0).sort((a, b) => b.number - a.number).slice(0, limit);
|
|
10954
|
+
const samples = [];
|
|
10955
|
+
for (const pr of newest) {
|
|
10956
|
+
const runs = await source.listCheckRuns(pr.headSha);
|
|
10957
|
+
const actions = shadowVerdict(runs, AGGREGATE_CHECK_NAME);
|
|
10958
|
+
const sentinel = shadowVerdict(runs, SHADOW_CHECK_NAME);
|
|
10959
|
+
samples.push({
|
|
10960
|
+
number: pr.number,
|
|
10961
|
+
...actions === void 0 ? {} : { actions },
|
|
10962
|
+
...sentinel === void 0 ? {} : { sentinel }
|
|
10963
|
+
});
|
|
10964
|
+
}
|
|
10965
|
+
return samples;
|
|
10966
|
+
}
|
|
10967
|
+
// src/commands/doctor-ci/shadow-row.ts
|
|
10968
|
+
const ID$7 = "shadow";
|
|
10969
|
+
const TITLE$7 = "Sentinel's ci shadow agrees with the Actions aggregate";
|
|
10970
|
+
/**
|
|
10971
|
+
* The `shadow` row (SPEC-0099, phase 4): do `ci / Required checks (sentinel)` and `ci / Required checks` say the same on
|
|
10972
|
+
* the same commit? `samples` are the newest pull requests first. A pull request is **decided** when both posted and
|
|
10973
|
+
* neither is still `pending`; one the shadow never posted on (it predates it) and one still running are left out, since
|
|
10974
|
+
* neither says the two disagree. Any decided pull request where they differ fails the row and is named. With none, the
|
|
10975
|
+
* row is a skip. Otherwise it counts the newest pull requests in a row that agree and passes at
|
|
10976
|
+
* {@link SHADOW_AGREEMENT_TARGET}, and is a skip (not a failure) below it: the shadow is still being watched. The spec
|
|
10977
|
+
* also asks that the agreeing set include a re-run of one leaf, a cancelled first batch, a late status, a skipped leaf and
|
|
10978
|
+
* a missing id; that is read by a person, not here.
|
|
10979
|
+
*/
|
|
10980
|
+
function shadowRow$1(samples, target = 20) {
|
|
10981
|
+
const decided = samples.filter((sample) => sample.actions !== void 0 && sample.sentinel !== void 0 && sample.actions !== "pending" && sample.sentinel !== "pending");
|
|
10982
|
+
if (decided.length === 0) return {
|
|
10983
|
+
id: ID$7,
|
|
10984
|
+
title: TITLE$7,
|
|
10985
|
+
status: "skip",
|
|
10986
|
+
detail: "no pull request has a finished verdict from both the Actions aggregate and the shadow yet",
|
|
10987
|
+
problems: []
|
|
10988
|
+
};
|
|
10989
|
+
const disagreements = decided.filter((sample) => sample.actions !== sample.sentinel);
|
|
10990
|
+
if (disagreements.length > 0) return {
|
|
10991
|
+
id: ID$7,
|
|
10992
|
+
title: TITLE$7,
|
|
10993
|
+
status: "fail",
|
|
10994
|
+
detail: `${disagreements.length} of ${decided.length} decided pull requests disagree`,
|
|
10995
|
+
problems: disagreements.map((s) => `#${s.number}: Actions said ${s.actions}, the shadow said ${s.sentinel}`)
|
|
10996
|
+
};
|
|
10997
|
+
const consecutive = decided.length;
|
|
10998
|
+
return consecutive >= target ? {
|
|
10999
|
+
id: ID$7,
|
|
11000
|
+
title: TITLE$7,
|
|
11001
|
+
status: "ok",
|
|
11002
|
+
detail: `${consecutive} consecutive pull requests agree (target ${target})`,
|
|
11003
|
+
problems: []
|
|
11004
|
+
} : {
|
|
11005
|
+
id: ID$7,
|
|
11006
|
+
title: TITLE$7,
|
|
11007
|
+
status: "skip",
|
|
11008
|
+
detail: `${consecutive} of ${target} consecutive pull requests agree so far`,
|
|
11009
|
+
problems: []
|
|
11010
|
+
};
|
|
11011
|
+
}
|
|
11012
|
+
// src/commands/doctor-ci/shadow-rows.ts
|
|
11013
|
+
const fail$1 = (detail) => ({
|
|
11014
|
+
id: "shadow",
|
|
11015
|
+
title: "Sentinel's ci shadow agrees with the Actions aggregate",
|
|
11016
|
+
status: "fail",
|
|
11017
|
+
detail,
|
|
11018
|
+
problems: []
|
|
11019
|
+
});
|
|
11020
|
+
/**
|
|
11021
|
+
* The `shadow` row for `doctor ci --shadow`: loads only the `source` provider, reads the newest pull requests' two
|
|
11022
|
+
* aggregate verdicts and compares them with {@link shadowRow}. A missing provider, a provider that cannot list check runs
|
|
11023
|
+
* or a read that throws is a failing row with the reason, never a throw.
|
|
11024
|
+
*/
|
|
11025
|
+
async function shadowRows(input) {
|
|
11026
|
+
const providers = input.loaded.resolved.providers;
|
|
11027
|
+
if (!providers.source) return [fail$1("the config has no `source` provider to read the check runs with")];
|
|
11028
|
+
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
11029
|
+
const loader = input.loader ?? new PluginLoader({
|
|
11030
|
+
...input.loaded.resolved,
|
|
11031
|
+
providers: {
|
|
11032
|
+
source: providers.source,
|
|
11033
|
+
...providers.credentials ? { credentials: providers.credentials } : {}
|
|
11034
|
+
}
|
|
11035
|
+
}, input.context);
|
|
11036
|
+
/* v8 ignore stop */
|
|
11037
|
+
try {
|
|
11038
|
+
await loader.load();
|
|
11039
|
+
assertPluginsResolvable(loader, "doctor ci");
|
|
11040
|
+
if (!loader.has("source")) {
|
|
11041
|
+
const failure = loader.loadFailures().find((f) => f.key === "source");
|
|
11042
|
+
return [fail$1(`the \`source\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)];
|
|
11043
|
+
}
|
|
11044
|
+
const source = loader.get("source");
|
|
11045
|
+
if (!source.listPullRequests || !source.listCheckRuns) return [fail$1(`the \`${source.providerName}\` provider cannot list pull requests and check runs`)];
|
|
11046
|
+
return [shadowRow$1(await readShadowSamples({
|
|
11047
|
+
listPullRequests: source.listPullRequests.bind(source),
|
|
11048
|
+
listCheckRuns: source.listCheckRuns.bind(source)
|
|
11049
|
+
}, input.shadowLimit))];
|
|
11050
|
+
} catch (error) {
|
|
11051
|
+
return [fail$1(describeError(error))];
|
|
11052
|
+
}
|
|
11053
|
+
}
|
|
10869
11054
|
// src/commands/doctor-ci/tasks-row.ts
|
|
10870
11055
|
/**
|
|
10871
11056
|
* The `tasks` row: a `tasks:` entry in the config that uses a deprecated alias (an old dotted name, `validate`,
|
|
@@ -10897,11 +11082,13 @@ async function runDoctorCi(input) {
|
|
|
10897
11082
|
const callers = io.workflows().flatMap(({ file, text }) => parseCaller(file, text) ?? []);
|
|
10898
11083
|
const tasksConfig = { tasks };
|
|
10899
11084
|
if (config.extraRequiredChecks) tasksConfig.extraRequiredChecks = config.extraRequiredChecks;
|
|
11085
|
+
if (config.ci) tasksConfig.ci = config.ci;
|
|
10900
11086
|
const rows = [
|
|
10901
11087
|
tasksRow(tasks.map((entry) => typeof entry === "string" ? entry : entry.name)),
|
|
10902
11088
|
callersRow(callers),
|
|
10903
|
-
aggregateRow(callers, aggregateChecks(tasksConfig).expected),
|
|
10904
|
-
homeRow(callers, input.legacyGate ?? legacyGate())
|
|
11089
|
+
aggregateRow(callers, aggregateChecks(tasksConfig).expected, aggregatePoster(tasksConfig)),
|
|
11090
|
+
homeRow(callers, input.legacyGate ?? legacyGate()),
|
|
11091
|
+
...input.shadow ? await shadowRows(input) : []
|
|
10905
11092
|
];
|
|
10906
11093
|
printCheckRows(rows, print);
|
|
10907
11094
|
const summary = summariseChecks(rows);
|
|
@@ -10921,12 +11108,27 @@ async function runDoctorCi(input) {
|
|
|
10921
11108
|
const doctorCiCommand = {
|
|
10922
11109
|
command: "ci",
|
|
10923
11110
|
describe: "Check the repo against the flat task vocabulary: aliases, caller names, the ci aggregate, home (read-only)",
|
|
11111
|
+
builder: (y) => y.option("shadow", {
|
|
11112
|
+
type: "boolean",
|
|
11113
|
+
describe: "Also compare Sentinel's shadow aggregate (ci / Required checks (sentinel)) with the Actions one on the newest pull requests (reads through `source`)"
|
|
11114
|
+
}).option("limit", {
|
|
11115
|
+
type: "number",
|
|
11116
|
+
describe: "With --shadow: how many of the newest pull requests to read (default 40)"
|
|
11117
|
+
}),
|
|
10924
11118
|
handler: async (argv) => {
|
|
11119
|
+
const tokens = argv.shadow ? tokenContext(argv.token) : {};
|
|
11120
|
+
if (!tokens) return;
|
|
10925
11121
|
const loaded = await loadConfig(argv.cwd);
|
|
10926
11122
|
applyResolvedConfig(argv, loaded.resolved);
|
|
10927
11123
|
if ((await runDoctorCi({
|
|
10928
11124
|
loaded,
|
|
10929
|
-
context: {
|
|
11125
|
+
context: {
|
|
11126
|
+
repoRoot: argv.cwd,
|
|
11127
|
+
...tokens,
|
|
11128
|
+
...argv.shadow ? { org: resolveOrg(argv, loaded.resolved) } : {}
|
|
11129
|
+
},
|
|
11130
|
+
...argv.shadow ? { shadow: true } : {},
|
|
11131
|
+
...argv.limit !== void 0 ? { shadowLimit: Number(argv.limit) } : {}
|
|
10930
11132
|
})).status === "fail") process.exitCode = 1;
|
|
10931
11133
|
}
|
|
10932
11134
|
};
|
|
@@ -11314,7 +11516,7 @@ async function runDoctorDns(input) {
|
|
|
11314
11516
|
});
|
|
11315
11517
|
else if (!loader.has("dns")) {
|
|
11316
11518
|
const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
|
|
11317
|
-
for (const zone of zones) rows.push(row$
|
|
11519
|
+
for (const zone of zones) rows.push(row$26(zone, "skip", why));
|
|
11318
11520
|
for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
|
|
11319
11521
|
} else {
|
|
11320
11522
|
const dns = loader.get("dns");
|
|
@@ -11336,7 +11538,7 @@ async function runDoctorDns(input) {
|
|
|
11336
11538
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
11337
11539
|
};
|
|
11338
11540
|
}
|
|
11339
|
-
function row$
|
|
11541
|
+
function row$26(zone, status, detail, problems = []) {
|
|
11340
11542
|
return {
|
|
11341
11543
|
id: `dns-${zone}`,
|
|
11342
11544
|
title: `${zone} records exist`,
|
|
@@ -11365,7 +11567,7 @@ async function checkDomain(dns, deploy, project, hostname) {
|
|
|
11365
11567
|
return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
|
|
11366
11568
|
}
|
|
11367
11569
|
}
|
|
11368
|
-
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$
|
|
11570
|
+
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$26(zone, ...args)) {
|
|
11369
11571
|
try {
|
|
11370
11572
|
const have = await dns.listRecords(zone);
|
|
11371
11573
|
const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
|
|
@@ -11484,7 +11686,7 @@ function declaredProjects$1(layouts) {
|
|
|
11484
11686
|
return [...new Set(layouts.flatMap((layout) => layout.relay?.errors?.projects ?? []))];
|
|
11485
11687
|
}
|
|
11486
11688
|
// src/commands/doctor-errors/errors-rows.ts
|
|
11487
|
-
const row$
|
|
11689
|
+
const row$25 = (id, title, status, detail, problems = []) => ({
|
|
11488
11690
|
id,
|
|
11489
11691
|
title,
|
|
11490
11692
|
status,
|
|
@@ -11501,27 +11703,27 @@ function errorsRows(found, providerName) {
|
|
|
11501
11703
|
const orgSlug = found.org.slug;
|
|
11502
11704
|
if (!found.org.exists) {
|
|
11503
11705
|
const problem = `${providerName} has no organization named ${orgSlug}; check the \`org\` option of the \`errors\` provider`;
|
|
11504
|
-
const rows = [row$
|
|
11505
|
-
for (const project of found.projects) rows.push(row$
|
|
11706
|
+
const rows = [row$25("errors:org", "organization exists", "fail", `${orgSlug} not found`, [problem])];
|
|
11707
|
+
for (const project of found.projects) rows.push(row$25(`errors:project:${project.slug}`, `project ${project.slug} exists`, "skip", "not checked: no organization"));
|
|
11506
11708
|
return rows;
|
|
11507
11709
|
}
|
|
11508
|
-
const rows = [row$
|
|
11710
|
+
const rows = [row$25("errors:org", "organization exists", "ok", `${orgSlug} (${found.org.name ?? orgSlug})`)];
|
|
11509
11711
|
if (found.projects.length === 0) {
|
|
11510
|
-
rows.push(row$
|
|
11712
|
+
rows.push(row$25("errors:projects", "declared projects", "skip", "none declared: no `relay.errors.projects` in a layout"));
|
|
11511
11713
|
return rows;
|
|
11512
11714
|
}
|
|
11513
11715
|
for (const project of found.projects) {
|
|
11514
11716
|
const slug = project.slug;
|
|
11515
11717
|
if (!project.exists) {
|
|
11516
11718
|
const problem = `no project ${slug} in ${found.org.slug}; create it in ${providerName}`;
|
|
11517
|
-
rows.push(row$
|
|
11719
|
+
rows.push(row$25(`errors:project:${slug}`, `project ${slug} exists`, "fail", "not found", [problem]), row$25(`errors:dsn:${slug}`, `project ${slug} has a key`, "skip", "not checked: no project"), row$25(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "skip", "not checked: no project"));
|
|
11518
11720
|
continue;
|
|
11519
11721
|
}
|
|
11520
|
-
rows.push(row$
|
|
11521
|
-
rows.push(project.hasDsn ? row$
|
|
11522
|
-
if (project.alertRules === void 0) rows.push(row$
|
|
11523
|
-
else if (project.alertRules === 0) rows.push(row$
|
|
11524
|
-
else rows.push(row$
|
|
11722
|
+
rows.push(row$25(`errors:project:${slug}`, `project ${slug} exists`, "ok", slug));
|
|
11723
|
+
rows.push(project.hasDsn ? row$25(`errors:dsn:${slug}`, `project ${slug} has a key`, "ok", "a client key (DSN) exists") : row$25(`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}`]));
|
|
11724
|
+
if (project.alertRules === void 0) rows.push(row$25(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "skip", found.alertsUnreadable ? `could not read the alert rules: ${found.alertsUnreadable}` : "not read"));
|
|
11725
|
+
else if (project.alertRules === 0) rows.push(row$25(`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`]));
|
|
11726
|
+
else rows.push(row$25(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "ok", `${project.alertRules} enabled rule(s)`));
|
|
11525
11727
|
}
|
|
11526
11728
|
return rows;
|
|
11527
11729
|
}
|
|
@@ -11624,7 +11826,7 @@ function installationSettingsUrl(account, id) {
|
|
|
11624
11826
|
return `https://github.com/settings/installations/${id}`;
|
|
11625
11827
|
}
|
|
11626
11828
|
// src/commands/doctor-github-app/app-rows.ts
|
|
11627
|
-
const row$
|
|
11829
|
+
const row$24 = (name, what, problems, ok) => ({
|
|
11628
11830
|
id: `${name}:${what}`,
|
|
11629
11831
|
title: `${name}: ${what}`,
|
|
11630
11832
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -11651,11 +11853,116 @@ function appRows(name, manifest, app, installations) {
|
|
|
11651
11853
|
return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
|
|
11652
11854
|
});
|
|
11653
11855
|
return [
|
|
11654
|
-
row$
|
|
11655
|
-
row$
|
|
11656
|
-
row$
|
|
11856
|
+
row$24(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
|
|
11857
|
+
row$24(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
|
|
11858
|
+
row$24(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
|
|
11657
11859
|
];
|
|
11658
11860
|
}
|
|
11861
|
+
// src/commands/webhook-deliveries/failed-deliveries.ts
|
|
11862
|
+
/** Whether a delivery reached the App's endpoint and was answered with a success (2xx). */
|
|
11863
|
+
const succeeded = (delivery) => delivery.statusCode >= 200 && delivery.statusCode < 300;
|
|
11864
|
+
/**
|
|
11865
|
+
* The deliveries that still need delivering again, oldest first (SPEC-0099, recovery 2). A delivery and its
|
|
11866
|
+
* redeliveries share one GUID, so each GUID is judged by its **latest** attempt: a first attempt that failed and was
|
|
11867
|
+
* redelivered successfully is done, and one whose latest redelivery failed too is returned once, as that attempt, never
|
|
11868
|
+
* once per attempt. A delivery that got no answer at all (`statusCode` `0`) has failed.
|
|
11869
|
+
*/
|
|
11870
|
+
function failedDeliveries(deliveries) {
|
|
11871
|
+
const latest = /* @__PURE__ */ new Map();
|
|
11872
|
+
for (const delivery of deliveries) {
|
|
11873
|
+
const seen = latest.get(delivery.guid);
|
|
11874
|
+
if (seen === void 0 || delivery.deliveredAt > seen.deliveredAt) latest.set(delivery.guid, delivery);
|
|
11875
|
+
}
|
|
11876
|
+
return [...latest.values()].filter((delivery) => !succeeded(delivery)).sort((a, b) => a.deliveredAt.localeCompare(b.deliveredAt) || a.id - b.id);
|
|
11877
|
+
}
|
|
11878
|
+
// src/commands/doctor-github-app/read-app-credentials.ts
|
|
11879
|
+
/** The names the App's credentials are kept under, Sentinel's own first and the bare ones an older Environment has (#1864). */
|
|
11880
|
+
const APP_ID = ["SENTINEL_GITHUB_APP_ID", "GITHUB_APP_ID"];
|
|
11881
|
+
const PRIVATE_KEY = ["SENTINEL_GITHUB_APP_PRIVATE_KEY", "GITHUB_APP_PRIVATE_KEY"];
|
|
11882
|
+
/** The first of `names` the environment holds a value for. */
|
|
11883
|
+
function held(values, names) {
|
|
11884
|
+
return names.map((name) => values[name]).find((value) => value?.trim());
|
|
11885
|
+
}
|
|
11886
|
+
/** An error's message with the secrets it was handed taken out, so nothing read from the vault is ever printed. */
|
|
11887
|
+
function scrubbed$1(err, secrets) {
|
|
11888
|
+
return secrets.filter(Boolean).reduce((text, secret) => text.split(secret).join("[redacted]"), errorMessage(err));
|
|
11889
|
+
}
|
|
11890
|
+
/**
|
|
11891
|
+
* The App's id and key from its vault environment, read in memory and never printed or written, or the reason they cannot
|
|
11892
|
+
* be had (no `vault` provider, an environment that cannot be read, a name it does not hold). Shared by `doctor github-app`
|
|
11893
|
+
* and `redeliver webhooks`, which both call the App's own endpoints with its JWT.
|
|
11894
|
+
*/
|
|
11895
|
+
async function readAppCredentials(instance, loader) {
|
|
11896
|
+
const vault = loader.has("vault") ? loader.get("vault") : void 0;
|
|
11897
|
+
if (!vault?.readEnvironment) return { reason: vault ? `${vault.providerName} cannot read an environment's variables` : "needs a `vault` provider in holocron.config.ts (1password)" };
|
|
11898
|
+
const environment = resolvedEnvironment(instance);
|
|
11899
|
+
let values;
|
|
11900
|
+
try {
|
|
11901
|
+
values = await vault.readEnvironment(environment);
|
|
11902
|
+
} catch (err) {
|
|
11903
|
+
return { reason: `cannot read the "${environment}" environment: ${errorMessage(err)}` };
|
|
11904
|
+
}
|
|
11905
|
+
const appId = held(values, APP_ID);
|
|
11906
|
+
const key = held(values, PRIVATE_KEY);
|
|
11907
|
+
const missing = [appId ? void 0 : APP_ID, key ? void 0 : PRIVATE_KEY].filter((names) => names !== void 0);
|
|
11908
|
+
if (missing.length > 0) return { reason: `"${environment}" does not hold ${missing.map(([preferred, older]) => `${preferred} (or ${older})`).join(" or ")}` };
|
|
11909
|
+
const privateKey = key.includes("\n") ? key : key.replace(/\\n/g, "\n");
|
|
11910
|
+
return { creds: {
|
|
11911
|
+
appId: appId.trim(),
|
|
11912
|
+
privateKey
|
|
11913
|
+
} };
|
|
11914
|
+
}
|
|
11915
|
+
// src/commands/doctor-github-app/delivery-row.ts
|
|
11916
|
+
const DAY_MS$1 = 864e5;
|
|
11917
|
+
/** The most failed deliveries a row names; the rest are counted. */
|
|
11918
|
+
const MAX_NAMED = 10;
|
|
11919
|
+
/**
|
|
11920
|
+
* The `deliveries` row of one App instance (SPEC-0099, signal 3): how many webhook deliveries in the last day failed and
|
|
11921
|
+
* have not been delivered again successfully. A failing row names the oldest ones and ends with the command that repairs
|
|
11922
|
+
* them. A delivery log that cannot be read (an API without the call, a refusal) is a skip with the reason, never a failure
|
|
11923
|
+
* of the check.
|
|
11924
|
+
*/
|
|
11925
|
+
async function deliveryRow(name, creds, api, now, secrets) {
|
|
11926
|
+
const id = `${name}:deliveries`;
|
|
11927
|
+
const title = `${name}: deliveries`;
|
|
11928
|
+
if (!api.listAppDeliveries) return {
|
|
11929
|
+
id,
|
|
11930
|
+
title,
|
|
11931
|
+
status: "skip",
|
|
11932
|
+
detail: "the delivery log is not read here",
|
|
11933
|
+
problems: []
|
|
11934
|
+
};
|
|
11935
|
+
let failed;
|
|
11936
|
+
try {
|
|
11937
|
+
failed = failedDeliveries(await api.listAppDeliveries(creds, { since: (/* @__PURE__ */ new Date(now - DAY_MS$1)).toISOString() }));
|
|
11938
|
+
} catch (err) {
|
|
11939
|
+
return {
|
|
11940
|
+
id,
|
|
11941
|
+
title,
|
|
11942
|
+
status: "skip",
|
|
11943
|
+
detail: `cannot read the delivery log: ${scrubbed$1(err, secrets)}`,
|
|
11944
|
+
problems: []
|
|
11945
|
+
};
|
|
11946
|
+
}
|
|
11947
|
+
if (failed.length === 0) return {
|
|
11948
|
+
id,
|
|
11949
|
+
title,
|
|
11950
|
+
status: "ok",
|
|
11951
|
+
detail: "no failed webhook deliveries in the last day",
|
|
11952
|
+
problems: []
|
|
11953
|
+
};
|
|
11954
|
+
const named = failed.slice(0, MAX_NAMED).map((d) => {
|
|
11955
|
+
return `${d.action === null ? d.event : `${d.event}.${d.action}`}, ${d.status || `status ${d.statusCode}`}, ${d.deliveredAt}`;
|
|
11956
|
+
});
|
|
11957
|
+
const more = failed.length > MAX_NAMED ? [`and ${failed.length - MAX_NAMED} more`] : [];
|
|
11958
|
+
return {
|
|
11959
|
+
id,
|
|
11960
|
+
title,
|
|
11961
|
+
status: "fail",
|
|
11962
|
+
detail: `${failed.length} failed webhook deliver${failed.length === 1 ? "y" : "ies"} in the last day; repair with \`holocron redeliver webhooks --app ${name}\``,
|
|
11963
|
+
problems: [...named, ...more]
|
|
11964
|
+
};
|
|
11965
|
+
}
|
|
11659
11966
|
// src/commands/doctor-github-app/parse-manifest.ts
|
|
11660
11967
|
const LEVELS = [
|
|
11661
11968
|
"read",
|
|
@@ -11686,20 +11993,15 @@ function parseManifest(text) {
|
|
|
11686
11993
|
* memory (never printed, never written), signs the App's own JWT and calls `GET /app` and `GET /app/installations`.
|
|
11687
11994
|
* Rows per instance: reachable; events (every manifest event is subscribed); permissions (each manifest permission is
|
|
11688
11995
|
* granted at least at its level, `read < write < admin`); installations (none lags the App, which is a pending
|
|
11689
|
-
* update an owner has not accepted)
|
|
11996
|
+
* update an owner has not accepted); deliveries (no webhook delivery of the last day failed and stayed failed, SPEC-0099;
|
|
11997
|
+
* a log that cannot be read is a skip). Extras on the App are named in a row's detail as `info`, never a failure. A row
|
|
11690
11998
|
* that fails ends with the settings page that fixes it. An instance whose credentials cannot be read is a skip with
|
|
11691
11999
|
* the reason; an unreadable manifest, a rejected JWT or a gap is a failure.
|
|
11692
12000
|
*/
|
|
11693
|
-
|
|
11694
|
-
const APP_ID = ["SENTINEL_GITHUB_APP_ID", "GITHUB_APP_ID"];
|
|
11695
|
-
const PRIVATE_KEY = ["SENTINEL_GITHUB_APP_PRIVATE_KEY", "GITHUB_APP_PRIVATE_KEY"];
|
|
11696
|
-
/** The first of `names` the environment holds a value for. */
|
|
11697
|
-
function held(values, names) {
|
|
11698
|
-
return names.map((name) => values[name]).find((value) => value?.trim());
|
|
11699
|
-
}
|
|
11700
|
-
const defaultApi = {
|
|
12001
|
+
const defaultApi$1 = {
|
|
11701
12002
|
getApp,
|
|
11702
|
-
listAppInstallations
|
|
12003
|
+
listAppInstallations,
|
|
12004
|
+
listAppDeliveries
|
|
11703
12005
|
};
|
|
11704
12006
|
async function runDoctorGitHubApp(input) {
|
|
11705
12007
|
const print = input.print ?? ((line) => console.log(line));
|
|
@@ -11711,7 +12013,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
11711
12013
|
assertPluginsResolvable(loader, "doctor github-app");
|
|
11712
12014
|
}
|
|
11713
12015
|
const rows = [];
|
|
11714
|
-
if (instances.length === 0) rows.push(row$
|
|
12016
|
+
if (instances.length === 0) rows.push(row$23("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
|
|
11715
12017
|
for (const instance of instances) rows.push(...await checkInstance(instance, loader, input));
|
|
11716
12018
|
printCheckRows(rows, print);
|
|
11717
12019
|
const summary = summariseChecks(rows);
|
|
@@ -11728,7 +12030,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
11728
12030
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
11729
12031
|
};
|
|
11730
12032
|
}
|
|
11731
|
-
function row$
|
|
12033
|
+
function row$23(name, what, status, detail) {
|
|
11732
12034
|
return {
|
|
11733
12035
|
id: `${name}:${what}`,
|
|
11734
12036
|
title: `${name}: ${what}`,
|
|
@@ -11737,31 +12039,6 @@ function row$21(name, what, status, detail) {
|
|
|
11737
12039
|
problems: []
|
|
11738
12040
|
};
|
|
11739
12041
|
}
|
|
11740
|
-
/** An error's message with the secrets it was handed taken out, so nothing read from the vault is ever printed. */
|
|
11741
|
-
function scrubbed$1(err, secrets) {
|
|
11742
|
-
return secrets.filter(Boolean).reduce((text, secret) => text.split(secret).join("[redacted]"), errorMessage(err));
|
|
11743
|
-
}
|
|
11744
|
-
/** The App's id and key from its vault environment, or the reason they cannot be had. */
|
|
11745
|
-
async function readCredentials(instance, loader) {
|
|
11746
|
-
const vault = loader.has("vault") ? loader.get("vault") : void 0;
|
|
11747
|
-
if (!vault?.readEnvironment) return { reason: vault ? `${vault.providerName} cannot read an environment's variables` : "needs a `vault` provider in holocron.config.ts (1password)" };
|
|
11748
|
-
const environment = resolvedEnvironment(instance);
|
|
11749
|
-
let values;
|
|
11750
|
-
try {
|
|
11751
|
-
values = await vault.readEnvironment(environment);
|
|
11752
|
-
} catch (err) {
|
|
11753
|
-
return { reason: `cannot read the "${environment}" environment: ${errorMessage(err)}` };
|
|
11754
|
-
}
|
|
11755
|
-
const appId = held(values, APP_ID);
|
|
11756
|
-
const key = held(values, PRIVATE_KEY);
|
|
11757
|
-
const missing = [appId ? void 0 : APP_ID, key ? void 0 : PRIVATE_KEY].filter((names) => names !== void 0);
|
|
11758
|
-
if (missing.length > 0) return { reason: `"${environment}" does not hold ${missing.map(([preferred, older]) => `${preferred} (or ${older})`).join(" or ")}` };
|
|
11759
|
-
const privateKey = key.includes("\n") ? key : key.replace(/\\n/g, "\n");
|
|
11760
|
-
return { creds: {
|
|
11761
|
-
appId: appId.trim(),
|
|
11762
|
-
privateKey
|
|
11763
|
-
} };
|
|
11764
|
-
}
|
|
11765
12042
|
async function checkInstance(instance, loader, input) {
|
|
11766
12043
|
const { name } = instance;
|
|
11767
12044
|
const readManifest = input.readManifest ?? ((path) => readFileSync(join(input.context.repoRoot, path), "utf8"));
|
|
@@ -11769,19 +12046,23 @@ async function checkInstance(instance, loader, input) {
|
|
|
11769
12046
|
try {
|
|
11770
12047
|
manifest = parseManifest(readManifest(instance.manifest));
|
|
11771
12048
|
} catch (err) {
|
|
11772
|
-
return [row$
|
|
12049
|
+
return [row$23(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
|
|
11773
12050
|
}
|
|
11774
|
-
const read = await
|
|
11775
|
-
if ("reason" in read) return [row$
|
|
11776
|
-
const api = input.api ?? defaultApi;
|
|
12051
|
+
const read = await readAppCredentials(instance, loader);
|
|
12052
|
+
if ("reason" in read) return [row$23(name, "reachable", "skip", read.reason)];
|
|
12053
|
+
const api = input.api ?? defaultApi$1;
|
|
11777
12054
|
const secrets = [read.creds.privateKey];
|
|
11778
12055
|
try {
|
|
11779
12056
|
const app = await api.getApp(read.creds);
|
|
11780
12057
|
const installations = await api.listAppInstallations(read.creds);
|
|
11781
12058
|
const owner = app.owner ? `, owned by ${app.owner.login}` : "";
|
|
11782
|
-
return [
|
|
12059
|
+
return [
|
|
12060
|
+
row$23(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`),
|
|
12061
|
+
...appRows(name, manifest, app, installations),
|
|
12062
|
+
await deliveryRow(name, read.creds, api, (input.now ?? Date.now)(), secrets)
|
|
12063
|
+
];
|
|
11783
12064
|
} catch (err) {
|
|
11784
|
-
return [row$
|
|
12065
|
+
return [row$23(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
|
|
11785
12066
|
}
|
|
11786
12067
|
}
|
|
11787
12068
|
// src/commands/doctor-github-app/doctor-github-app.command.ts
|
|
@@ -11848,7 +12129,7 @@ function datasetTargets(config) {
|
|
|
11848
12129
|
* dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
|
|
11849
12130
|
* 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.
|
|
11850
12131
|
*/
|
|
11851
|
-
const row$
|
|
12132
|
+
const row$22 = (id, title, status, detail, problems = []) => ({
|
|
11852
12133
|
id,
|
|
11853
12134
|
title,
|
|
11854
12135
|
status,
|
|
@@ -11865,7 +12146,7 @@ async function runDoctorLogs(input) {
|
|
|
11865
12146
|
if (!loader.has("logs")) {
|
|
11866
12147
|
const failure = loader.loadFailures().find((f) => f.key === "logs");
|
|
11867
12148
|
const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
|
|
11868
|
-
rows.push(row$
|
|
12149
|
+
rows.push(row$22("logs", "logs", "skip", why));
|
|
11869
12150
|
} else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
|
|
11870
12151
|
printCheckRows(rows, print);
|
|
11871
12152
|
const summary = summariseChecks(rows);
|
|
@@ -11889,38 +12170,38 @@ async function checkLogs(logs, targets) {
|
|
|
11889
12170
|
for (const target of targets) {
|
|
11890
12171
|
const id = `logs:dataset:${target.id}`;
|
|
11891
12172
|
const title = `dataset for ${target.label}`;
|
|
11892
|
-
if (!target.name) rows.push(row$
|
|
11893
|
-
else if (!token.usable) rows.push(row$
|
|
11894
|
-
else if (!logs.readDataset) rows.push(row$
|
|
12173
|
+
if (!target.name) rows.push(row$22(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
|
|
12174
|
+
else if (!token.usable) rows.push(row$22(id, title, "skip", `${target.name}: not checked, the token is not usable`));
|
|
12175
|
+
else if (!logs.readDataset) rows.push(row$22(id, title, "skip", `${logs.providerName} cannot read a dataset`));
|
|
11895
12176
|
else rows.push(...await checkDataset(logs, target, target.name, id, title));
|
|
11896
12177
|
}
|
|
11897
12178
|
const org = resolveValue$1(["AXIOM_ORG"], void 0, { prefix: PREFIX$1 });
|
|
11898
|
-
rows.push(org ? row$
|
|
12179
|
+
rows.push(org ? row$22("logs:org", "organization", "ok", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$22("logs:org", "organization", "skip", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links need it`));
|
|
11899
12180
|
return rows;
|
|
11900
12181
|
}
|
|
11901
12182
|
/** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
|
|
11902
12183
|
async function checkToken$1(logs, dataset) {
|
|
11903
12184
|
const title = "token is accepted";
|
|
11904
12185
|
if (!logs.checkToken) return {
|
|
11905
|
-
row: row$
|
|
12186
|
+
row: row$22("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
|
|
11906
12187
|
usable: true
|
|
11907
12188
|
};
|
|
11908
12189
|
try {
|
|
11909
12190
|
const result = await logs.checkToken(dataset);
|
|
11910
12191
|
if (result.ok) return {
|
|
11911
|
-
row: row$
|
|
12192
|
+
row: row$22("logs:token", title, "ok", `${logs.providerName} accepts the token`),
|
|
11912
12193
|
usable: true
|
|
11913
12194
|
};
|
|
11914
12195
|
const reason = result.reason ?? `${logs.providerName} refused the token`;
|
|
11915
12196
|
return {
|
|
11916
|
-
row: row$
|
|
12197
|
+
row: row$22("logs:token", title, "fail", reason, [reason]),
|
|
11917
12198
|
usable: false
|
|
11918
12199
|
};
|
|
11919
12200
|
} catch (err) {
|
|
11920
12201
|
const noToken = missingTokenReason(err);
|
|
11921
12202
|
const detail = noToken ?? `could not check the token: ${describeError(err)}`;
|
|
11922
12203
|
return {
|
|
11923
|
-
row: row$
|
|
12204
|
+
row: row$22("logs:token", title, "skip", detail),
|
|
11924
12205
|
usable: noToken === void 0
|
|
11925
12206
|
};
|
|
11926
12207
|
}
|
|
@@ -11930,17 +12211,17 @@ async function checkDataset(logs, target, name, id, title) {
|
|
|
11930
12211
|
const found = await logs.readDataset(name);
|
|
11931
12212
|
if (found.forbidden) {
|
|
11932
12213
|
const why = `${name}: not visible to this token (${logs.providerName} refused the read; it may also not exist)`;
|
|
11933
|
-
return [row$
|
|
12214
|
+
return [row$22(id, title, "skip", why)];
|
|
11934
12215
|
}
|
|
11935
12216
|
if (!found.exists) {
|
|
11936
12217
|
const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
|
|
11937
|
-
return [row$
|
|
12218
|
+
return [row$22(id, title, "fail", `${name} does not exist`, [problem])];
|
|
11938
12219
|
}
|
|
11939
12220
|
const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
|
|
11940
|
-
return [row$
|
|
12221
|
+
return [row$22(id, title, "ok", `${name} exists`), row$22(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
|
|
11941
12222
|
} catch (err) {
|
|
11942
12223
|
const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
|
|
11943
|
-
return [row$
|
|
12224
|
+
return [row$22(id, title, "skip", detail)];
|
|
11944
12225
|
}
|
|
11945
12226
|
}
|
|
11946
12227
|
// src/commands/doctor-logs/doctor-logs.command.ts
|
|
@@ -15523,7 +15804,7 @@ const info = (id, title, noun, extras) => ({
|
|
|
15523
15804
|
detail: `info: ${extras.length} ${noun} not in the template (never deleted)`,
|
|
15524
15805
|
problems: extras
|
|
15525
15806
|
});
|
|
15526
|
-
const row$
|
|
15807
|
+
const row$21 = (id, title, problems, ok) => ({
|
|
15527
15808
|
id,
|
|
15528
15809
|
title,
|
|
15529
15810
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -15559,19 +15840,19 @@ function viewProblems(want, found) {
|
|
|
15559
15840
|
function boardRows(boardName, template, state) {
|
|
15560
15841
|
const id = `project:${boardName}`;
|
|
15561
15842
|
const rows = [];
|
|
15562
|
-
rows.push(row$
|
|
15843
|
+
rows.push(row$21(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
|
|
15563
15844
|
const extraStatuses = state.statuses.filter((s) => !template.statuses.some((t) => t.name === s));
|
|
15564
15845
|
if (extraStatuses.length > 0) rows.push(info(`${id}:extra-statuses`, `${boardName}: extra statuses`, "status(es)", extraStatuses));
|
|
15565
|
-
for (const want of template.fields) rows.push(row$
|
|
15846
|
+
for (const want of template.fields) rows.push(row$21(`${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));
|
|
15566
15847
|
const extraFields = state.fields.filter((f) => !template.fields.some((t) => t.name === f.name));
|
|
15567
15848
|
if (extraFields.length > 0) rows.push(info(`${id}:extra-fields`, `${boardName}: extra fields`, "field(s)", extraFields.map((f) => f.name)));
|
|
15568
|
-
for (const want of template.views) rows.push(row$
|
|
15849
|
+
for (const want of template.views) rows.push(row$21(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
|
|
15569
15850
|
const extraViews = state.views.filter((v) => !template.views.some((t) => t.name === v.name));
|
|
15570
15851
|
if (extraViews.length > 0) rows.push(info(`${id}:extra-views`, `${boardName}: extra views`, "view(s)", extraViews.map((v) => v.name)));
|
|
15571
15852
|
for (const name of template.rules ?? []) {
|
|
15572
15853
|
const found = state.rules.find((r) => r.name === name);
|
|
15573
15854
|
const problems = !found ? [`missing rule ${name}`] : found.enabled ? [] : [`rule ${name} is off`];
|
|
15574
|
-
rows.push(row$
|
|
15855
|
+
rows.push(row$21(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
|
|
15575
15856
|
}
|
|
15576
15857
|
return rows;
|
|
15577
15858
|
}
|
|
@@ -15631,7 +15912,7 @@ function itemRows(boardName, items) {
|
|
|
15631
15912
|
* never fail the run. A template file that does not read is a failure naming the file. `--post [channel]` shares the
|
|
15632
15913
|
* failing rows through the `notifications` provider's bot, like `doctor notifications --post`.
|
|
15633
15914
|
*/
|
|
15634
|
-
const row$
|
|
15915
|
+
const row$20 = (id, title, status, detail, problems = []) => ({
|
|
15635
15916
|
id,
|
|
15636
15917
|
title,
|
|
15637
15918
|
status,
|
|
@@ -15685,14 +15966,14 @@ async function checkBoards(input, loader) {
|
|
|
15685
15966
|
loader,
|
|
15686
15967
|
...input.io ? { io: input.io } : {}
|
|
15687
15968
|
});
|
|
15688
|
-
if (!opened.ok) return [row$
|
|
15969
|
+
if (!opened.ok) return [row$20("project", "project", opened.kind, opened.reason, opened.problems)];
|
|
15689
15970
|
const { projects, owner, boards, templates, templateProblems } = opened.context;
|
|
15690
15971
|
const rows = templateProblems.map((problem) => {
|
|
15691
15972
|
/* v8 ignore next -- split always returns at least one element; the fallback only satisfies noUncheckedIndexedAccess */
|
|
15692
15973
|
const file = problem.split(": ")[0] ?? problem;
|
|
15693
|
-
return row$
|
|
15974
|
+
return row$20(`project:template:${file}`, `template file ${file}`, "fail", problem);
|
|
15694
15975
|
});
|
|
15695
|
-
if (boards.length === 0) return [...rows, row$
|
|
15976
|
+
if (boards.length === 0) return [...rows, row$20("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
|
|
15696
15977
|
for (const declared of boards) {
|
|
15697
15978
|
const template = templates[declared.template];
|
|
15698
15979
|
const title = `${declared.name}: board exists and is open`;
|
|
@@ -15700,18 +15981,18 @@ async function checkBoards(input, loader) {
|
|
|
15700
15981
|
const board = await projects.find(owner, declared.name);
|
|
15701
15982
|
if (!board) {
|
|
15702
15983
|
const closed = (await projects.list(owner)).some((b) => b.name === declared.name && b.closed);
|
|
15703
|
-
rows.push(row$
|
|
15984
|
+
rows.push(row$20(`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`"]));
|
|
15704
15985
|
continue;
|
|
15705
15986
|
}
|
|
15706
|
-
rows.push(row$
|
|
15987
|
+
rows.push(row$20(`project:${declared.name}`, title, "ok", board.url));
|
|
15707
15988
|
if (!template) {
|
|
15708
|
-
rows.push(row$
|
|
15989
|
+
rows.push(row$20(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
|
|
15709
15990
|
continue;
|
|
15710
15991
|
}
|
|
15711
15992
|
rows.push(...boardRows(declared.name, template, await projects.read(owner, board)));
|
|
15712
|
-
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$
|
|
15993
|
+
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$20(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
|
|
15713
15994
|
} catch (err) {
|
|
15714
|
-
rows.push(row$
|
|
15995
|
+
rows.push(row$20(`project:${declared.name}`, title, "fail", describeError(err)));
|
|
15715
15996
|
}
|
|
15716
15997
|
}
|
|
15717
15998
|
return rows;
|
|
@@ -16732,19 +17013,19 @@ async function runDoctorRepo(input) {
|
|
|
16732
17013
|
const rows = [];
|
|
16733
17014
|
if (!loader.has("source")) {
|
|
16734
17015
|
const why = whyMissing(loader, "source", "no `source` provider to read the repository with");
|
|
16735
|
-
for (const check of checks) rows.push(row$
|
|
17016
|
+
for (const check of checks) rows.push(row$19(check, { skip: why }));
|
|
16736
17017
|
} else {
|
|
16737
17018
|
const source = loader.get("source");
|
|
16738
17019
|
for (const check of checks) {
|
|
16739
17020
|
if (typeof source[check.needs] !== "function") {
|
|
16740
|
-
rows.push(row$
|
|
17021
|
+
rows.push(row$19(check, { skip: `provider does not implement ${check.needs}` }));
|
|
16741
17022
|
continue;
|
|
16742
17023
|
}
|
|
16743
17024
|
try {
|
|
16744
|
-
rows.push(row$
|
|
17025
|
+
rows.push(row$19(check, await check.run(source)));
|
|
16745
17026
|
} catch (err) {
|
|
16746
17027
|
const noToken = missingTokenReason(err);
|
|
16747
|
-
if (noToken !== void 0) rows.push(row$
|
|
17028
|
+
if (noToken !== void 0) rows.push(row$19(check, { skip: noToken }));
|
|
16748
17029
|
else rows.push({
|
|
16749
17030
|
id: check.id,
|
|
16750
17031
|
title: check.title,
|
|
@@ -16771,7 +17052,7 @@ async function runDoctorRepo(input) {
|
|
|
16771
17052
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
16772
17053
|
};
|
|
16773
17054
|
}
|
|
16774
|
-
function row$
|
|
17055
|
+
function row$19(check, result) {
|
|
16775
17056
|
const { id, title } = check;
|
|
16776
17057
|
if ("skip" in result) return {
|
|
16777
17058
|
id,
|
|
@@ -17295,7 +17576,7 @@ function providerGroup(providerName) {
|
|
|
17295
17576
|
}
|
|
17296
17577
|
// src/commands/doctor-secrets/credentials-rows.ts
|
|
17297
17578
|
/** A row for the provider as a whole, or for one of its variables when `name` is given. */
|
|
17298
|
-
function row$
|
|
17579
|
+
function row$18(provider, status, detail, name) {
|
|
17299
17580
|
return name === void 0 ? {
|
|
17300
17581
|
id: provider,
|
|
17301
17582
|
title: provider,
|
|
@@ -17320,10 +17601,10 @@ async function credentialsRows(input) {
|
|
|
17320
17601
|
const { loader } = input;
|
|
17321
17602
|
const { resolved } = input.loaded;
|
|
17322
17603
|
if (!resolved.providers.credentials) return {
|
|
17323
|
-
rows: input.asked ? [row$
|
|
17604
|
+
rows: input.asked ? [row$18("credentials", "skip", "no `credentials` provider is configured")] : [],
|
|
17324
17605
|
places: []
|
|
17325
17606
|
};
|
|
17326
|
-
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$
|
|
17607
|
+
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$18(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
|
|
17327
17608
|
const places = [];
|
|
17328
17609
|
if (!loader.has("credentials")) return {
|
|
17329
17610
|
rows,
|
|
@@ -17335,7 +17616,7 @@ async function credentialsRows(input) {
|
|
|
17335
17616
|
const tuple = tuples.find((t) => t.provider === impl.providerName);
|
|
17336
17617
|
const explicit = tuple && credentialsEnvironment(tuple, resolved);
|
|
17337
17618
|
if (!explicit && !derivesEnvironment(impl.providerName)) {
|
|
17338
|
-
rows.push(row$
|
|
17619
|
+
rows.push(row$18(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
|
|
17339
17620
|
continue;
|
|
17340
17621
|
}
|
|
17341
17622
|
try {
|
|
@@ -17347,7 +17628,7 @@ async function credentialsRows(input) {
|
|
|
17347
17628
|
rows.push(...checked.rows);
|
|
17348
17629
|
places.push(...checked.places);
|
|
17349
17630
|
} catch (err) {
|
|
17350
|
-
rows.push(row$
|
|
17631
|
+
rows.push(row$18(impl.providerName, "fail", errorMessage(err)));
|
|
17351
17632
|
}
|
|
17352
17633
|
}
|
|
17353
17634
|
return {
|
|
@@ -17363,17 +17644,17 @@ async function credentialsRows(input) {
|
|
|
17363
17644
|
async function checkProvider(impl, candidates, expected, synced) {
|
|
17364
17645
|
const provider = impl.providerName;
|
|
17365
17646
|
if (!impl.inspect) return {
|
|
17366
|
-
rows: [row$
|
|
17647
|
+
rows: [row$18(provider, "skip", "cannot list the variables without reading their values")],
|
|
17367
17648
|
places: []
|
|
17368
17649
|
};
|
|
17369
17650
|
if (expected.length === 0) return {
|
|
17370
|
-
rows: [row$
|
|
17651
|
+
rows: [row$18(provider, "skip", "no configured plugin lists the tokens it takes")],
|
|
17371
17652
|
places: []
|
|
17372
17653
|
};
|
|
17373
17654
|
const inspect = impl.inspect.bind(impl);
|
|
17374
17655
|
try {
|
|
17375
17656
|
const { found, missing } = await tryEnvironments(candidates, inspect);
|
|
17376
|
-
const rows = missing.map((name) => row$
|
|
17657
|
+
const rows = missing.map((name) => row$18(provider, "fail", `${provider} has no Environment named "${name}"`));
|
|
17377
17658
|
const group = providerGroup(provider);
|
|
17378
17659
|
const unreadPlaces = missing.map((name) => ({
|
|
17379
17660
|
column: {
|
|
@@ -17396,9 +17677,9 @@ async function checkProvider(impl, candidates, expected, synced) {
|
|
|
17396
17677
|
const have = (name) => found.some((f) => f.result.names.includes(name));
|
|
17397
17678
|
let present = 0;
|
|
17398
17679
|
for (const { name, optional } of expected) if (have(name)) present++;
|
|
17399
|
-
else if (optional) rows.push(row$
|
|
17400
|
-
else rows.push(row$
|
|
17401
|
-
if (present > 0) rows.push(row$
|
|
17680
|
+
else if (optional) rows.push(row$18(provider, "skip", `optional, not set in ${where}`, name));
|
|
17681
|
+
else rows.push(row$18(provider, "fail", `missing from ${where}`, name));
|
|
17682
|
+
if (present > 0) rows.push(row$18(provider, "ok", `${present} of ${expected.length} tokens present in ${where}`, "tokens"));
|
|
17402
17683
|
const names = new Set(expected.map((e) => e.name));
|
|
17403
17684
|
const places = [];
|
|
17404
17685
|
const missingRequired = expected.filter((e) => !e.optional && !have(e.name)).map((e) => e.name);
|
|
@@ -17437,7 +17718,7 @@ async function checkProvider(impl, candidates, expected, synced) {
|
|
|
17437
17718
|
};
|
|
17438
17719
|
} catch (err) {
|
|
17439
17720
|
return {
|
|
17440
|
-
rows: [row$
|
|
17721
|
+
rows: [row$18(provider, "fail", errorMessage(err))],
|
|
17441
17722
|
places: []
|
|
17442
17723
|
};
|
|
17443
17724
|
}
|
|
@@ -18311,7 +18592,7 @@ async function variableRows(loader, config, org) {
|
|
|
18311
18592
|
if (!loader.has("source")) {
|
|
18312
18593
|
const why = whyMissing(loader, "source", "no `source` provider to read them with");
|
|
18313
18594
|
for (const check of checks) {
|
|
18314
|
-
rows.push(row$
|
|
18595
|
+
rows.push(row$17(check, { skip: why }));
|
|
18315
18596
|
observations.push({
|
|
18316
18597
|
scope: check.scope,
|
|
18317
18598
|
unread: why
|
|
@@ -18321,7 +18602,7 @@ async function variableRows(loader, config, org) {
|
|
|
18321
18602
|
const source = loader.get("source");
|
|
18322
18603
|
for (const check of checks) try {
|
|
18323
18604
|
const result = await check.run(source);
|
|
18324
|
-
rows.push(row$
|
|
18605
|
+
rows.push(row$17(check, result));
|
|
18325
18606
|
observations.push("skip" in result ? {
|
|
18326
18607
|
scope: check.scope,
|
|
18327
18608
|
unread: result.skip
|
|
@@ -18332,7 +18613,7 @@ async function variableRows(loader, config, org) {
|
|
|
18332
18613
|
} catch (err) {
|
|
18333
18614
|
const noToken = missingTokenReason(err);
|
|
18334
18615
|
if (noToken !== void 0) {
|
|
18335
|
-
rows.push(row$
|
|
18616
|
+
rows.push(row$17(check, { skip: noToken }));
|
|
18336
18617
|
observations.push({
|
|
18337
18618
|
scope: check.scope,
|
|
18338
18619
|
unread: noToken
|
|
@@ -18358,7 +18639,7 @@ async function variableRows(loader, config, org) {
|
|
|
18358
18639
|
observations
|
|
18359
18640
|
};
|
|
18360
18641
|
}
|
|
18361
|
-
function row$
|
|
18642
|
+
function row$17(check, result) {
|
|
18362
18643
|
const { id, title } = check;
|
|
18363
18644
|
if ("skip" in result) return {
|
|
18364
18645
|
id,
|
|
@@ -18448,7 +18729,7 @@ function describeExpiry(expiresAt, now) {
|
|
|
18448
18729
|
*
|
|
18449
18730
|
* What a token may do is not checked: GitHub does not return a fine-grained token's permissions.
|
|
18450
18731
|
*/
|
|
18451
|
-
function row$
|
|
18732
|
+
function row$16(id, status, detail) {
|
|
18452
18733
|
return {
|
|
18453
18734
|
id: `verify:${id}`,
|
|
18454
18735
|
title: `verify ${id}`,
|
|
@@ -18476,12 +18757,12 @@ async function verifyRows(input) {
|
|
|
18476
18757
|
try {
|
|
18477
18758
|
module = await importer(pkg);
|
|
18478
18759
|
} catch (err) {
|
|
18479
|
-
rows.push(row$
|
|
18760
|
+
rows.push(row$16(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
|
|
18480
18761
|
continue;
|
|
18481
18762
|
}
|
|
18482
18763
|
for (const token of module.tokens ?? []) rows.push(await checkToken(token, module, env, readToken, now()));
|
|
18483
18764
|
}
|
|
18484
|
-
if (rows.length === 0) rows.push(row$
|
|
18765
|
+
if (rows.length === 0) rows.push(row$16("tokens", "skip", "no configured plugin lists the tokens it takes"));
|
|
18485
18766
|
return rows;
|
|
18486
18767
|
}
|
|
18487
18768
|
/**
|
|
@@ -18494,30 +18775,30 @@ async function loadCredentials(input) {
|
|
|
18494
18775
|
try {
|
|
18495
18776
|
await input.loader.load();
|
|
18496
18777
|
} catch (err) {
|
|
18497
|
-
return [row$
|
|
18778
|
+
return [row$16("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
|
|
18498
18779
|
}
|
|
18499
|
-
return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$
|
|
18780
|
+
return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$16(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
|
|
18500
18781
|
}
|
|
18501
18782
|
async function checkToken(token, module, env, readToken, now) {
|
|
18502
18783
|
const { keyringKey, envName, vendorEnvName } = token;
|
|
18503
18784
|
const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
|
|
18504
18785
|
const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
|
|
18505
18786
|
const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
|
|
18506
|
-
if (!value) return row$
|
|
18787
|
+
if (!value) return row$16(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
|
|
18507
18788
|
const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
|
|
18508
|
-
if (!verify) return row$
|
|
18789
|
+
if (!verify) return row$16(keyringKey, "skip", "set, but its plugin cannot verify it");
|
|
18509
18790
|
const from = fromEnv ?? stored?.source ?? "keyring";
|
|
18510
18791
|
try {
|
|
18511
18792
|
const verified = await verify(value);
|
|
18512
|
-
if (!verified.ok) return row$
|
|
18793
|
+
if (!verified.ok) return row$16(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
|
|
18513
18794
|
const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
|
|
18514
|
-
if (!expiry) return row$
|
|
18795
|
+
if (!expiry) return row$16(keyringKey, "ok", `${verified.subject} (${from})`);
|
|
18515
18796
|
return expiry.soon ? {
|
|
18516
|
-
...row$
|
|
18797
|
+
...row$16(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
|
|
18517
18798
|
problems: [`${expiry.text}: renew it`]
|
|
18518
|
-
} : row$
|
|
18799
|
+
} : row$16(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
|
|
18519
18800
|
} catch (err) {
|
|
18520
|
-
return row$
|
|
18801
|
+
return row$16(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
|
|
18521
18802
|
}
|
|
18522
18803
|
}
|
|
18523
18804
|
// src/commands/doctor-secrets/doctor-secrets.ts
|
|
@@ -19199,7 +19480,7 @@ function summariseProbeRows(id, title, rows) {
|
|
|
19199
19480
|
* provider with no `token` probe, no declared layer, or one that cannot be read is a skip with the reason.
|
|
19200
19481
|
*/
|
|
19201
19482
|
const PROBE = "token";
|
|
19202
|
-
const row$
|
|
19483
|
+
const row$15 = (id, title, status, detail, problems = []) => ({
|
|
19203
19484
|
id,
|
|
19204
19485
|
title,
|
|
19205
19486
|
status,
|
|
@@ -19224,12 +19505,12 @@ async function runDoctorTokens(input) {
|
|
|
19224
19505
|
try {
|
|
19225
19506
|
tokens = await providerTokens(provider);
|
|
19226
19507
|
} catch (err) {
|
|
19227
|
-
rows.push(row$
|
|
19508
|
+
rows.push(row$15(`tokens:${provider}`, provider, "skip", `could not read its tokens: ${describeError(err)}`));
|
|
19228
19509
|
continue;
|
|
19229
19510
|
}
|
|
19230
19511
|
const expectations = tokenExpectations(tokens);
|
|
19231
|
-
if (expectations.length === 0) rows.push(row$
|
|
19232
|
-
else if (!usableProbe(probes.get(provider))) rows.push(row$
|
|
19512
|
+
if (expectations.length === 0) rows.push(row$15(`tokens:${provider}`, provider, "skip", "info: declares no token layers, nothing to check"));
|
|
19513
|
+
else if (!usableProbe(probes.get(provider))) rows.push(row$15(`tokens:${provider}`, provider, "skip", `info: has no \`${PROBE}\` probe loaded, so its tokens are not checked`));
|
|
19233
19514
|
else declared.push({
|
|
19234
19515
|
provider,
|
|
19235
19516
|
tokens,
|
|
@@ -19291,14 +19572,14 @@ async function checkLayer(c) {
|
|
|
19291
19572
|
tokens
|
|
19292
19573
|
});
|
|
19293
19574
|
} catch (err) {
|
|
19294
|
-
if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$
|
|
19295
|
-
return c.wanted.map((e) => row$
|
|
19575
|
+
if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$15(id(e), title(e), "fail", "not held in this layer", [err.message]));
|
|
19576
|
+
return c.wanted.map((e) => row$15(id(e), title(e), "skip", `could not read the Environment: ${describeError(err)}`));
|
|
19296
19577
|
}
|
|
19297
19578
|
const rows = [];
|
|
19298
19579
|
for (const e of c.wanted) {
|
|
19299
19580
|
const token = held.held.find((h) => h.envName === e.envName);
|
|
19300
19581
|
if (!token) {
|
|
19301
|
-
rows.push(row$
|
|
19582
|
+
rows.push(row$15(id(e), title(e), "fail", `not held in ${held.environment}`, [`${e.envName} is declared for ${c.layer}`]));
|
|
19302
19583
|
continue;
|
|
19303
19584
|
}
|
|
19304
19585
|
rows.push(summariseProbeRows(id(e), title(e), await probeToken(c, e, token.token, held.plain)));
|
|
@@ -19371,7 +19652,7 @@ const doctorTokensCommand = {
|
|
|
19371
19652
|
}
|
|
19372
19653
|
};
|
|
19373
19654
|
// src/commands/doctor-wiki/wiki-rows.ts
|
|
19374
|
-
const row$
|
|
19655
|
+
const row$14 = (id, title, status, detail, problems = []) => ({
|
|
19375
19656
|
id,
|
|
19376
19657
|
title,
|
|
19377
19658
|
status,
|
|
@@ -19387,11 +19668,11 @@ const names = (paths) => paths.length > LISTED ? `${paths.slice(0, LISTED).join(
|
|
|
19387
19668
|
* skip, since a machine with no network says nothing about the site.
|
|
19388
19669
|
*/
|
|
19389
19670
|
function siteRow(id, title, probe, notFoundHint) {
|
|
19390
|
-
if (probe.status === void 0) return row$
|
|
19391
|
-
if (probe.status < 400) return row$
|
|
19392
|
-
if (probe.status === 401 || probe.status === 403) return row$
|
|
19671
|
+
if (probe.status === void 0) return row$14(id, title, "skip", `${probe.url}: ${probe.error ?? "no answer"}`);
|
|
19672
|
+
if (probe.status < 400) return row$14(id, title, "ok", `${probe.url} answers ${probe.status}`);
|
|
19673
|
+
if (probe.status === 401 || probe.status === 403) return row$14(id, title, "ok", `${probe.url} answers ${probe.status} (access is restricted)`);
|
|
19393
19674
|
const problem = probe.status === 404 ? `${probe.url} answers 404; ${notFoundHint}` : `${probe.url} answers ${probe.status}, expected a page`;
|
|
19394
|
-
return row$
|
|
19675
|
+
return row$14(id, title, "fail", `${probe.url} answers ${probe.status}`, [problem]);
|
|
19395
19676
|
}
|
|
19396
19677
|
/**
|
|
19397
19678
|
* The rows `holocron doctor wiki` prints for one {@link WikiInspection}: organization, docs instance, the site and its
|
|
@@ -19403,42 +19684,42 @@ function wikiRows(found, providerName) {
|
|
|
19403
19684
|
const { declared, found: foundOrg } = found.organization;
|
|
19404
19685
|
if (foundOrg === null) {
|
|
19405
19686
|
const problem = `fern/fern.config.json has no organization; \`holocron setup\` writes it`;
|
|
19406
|
-
rows.push(row$
|
|
19687
|
+
rows.push(row$14("wiki:organization", "organization is set", "fail", problem, [problem]));
|
|
19407
19688
|
} else if (foundOrg !== declared) {
|
|
19408
19689
|
const problem = `fern/fern.config.json names ${foundOrg}, the config declares ${declared}; run \`holocron setup\``;
|
|
19409
|
-
rows.push(row$
|
|
19410
|
-
} else rows.push(row$
|
|
19690
|
+
rows.push(row$14("wiki:organization", "organization is set", "fail", `${foundOrg}, declared ${declared}`, [problem]));
|
|
19691
|
+
} else rows.push(row$14("wiki:organization", "organization is set", "ok", `${declared} in fern/fern.config.json`));
|
|
19411
19692
|
const instance = found.instance;
|
|
19412
19693
|
if (instance === null) {
|
|
19413
19694
|
const problem = "fern/docs.yml does not exist; `holocron setup` writes it";
|
|
19414
|
-
rows.push(row$
|
|
19695
|
+
rows.push(row$14("wiki:instance", "docs site is declared", "fail", problem, [problem]));
|
|
19415
19696
|
} else {
|
|
19416
19697
|
const problems = [];
|
|
19417
19698
|
if (instance.foundUrl !== instance.expectedUrl) problems.push(`instance url is ${instance.foundUrl ?? "not set"}, expected ${instance.expectedUrl}`);
|
|
19418
19699
|
if (instance.expectedDomain !== void 0 && instance.foundDomain !== instance.expectedDomain) problems.push(`custom-domain is ${instance.foundDomain ?? "not set"}, expected ${instance.expectedDomain}`);
|
|
19419
|
-
rows.push(problems.length > 0 ? row$
|
|
19700
|
+
rows.push(problems.length > 0 ? row$14("wiki:instance", "docs site is declared", "fail", `${problems.length} problem(s)`, [...problems.map((p) => `fern/docs.yml: ${p}`)]) : row$14("wiki:instance", "docs site is declared", "ok", `${instance.expectedUrl} in fern/docs.yml`));
|
|
19420
19701
|
}
|
|
19421
19702
|
const [site, domain] = found.site;
|
|
19422
19703
|
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\`)`));
|
|
19423
19704
|
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`));
|
|
19424
|
-
if (found.navigation === null) rows.push(row$
|
|
19705
|
+
if (found.navigation === null) rows.push(row$14("wiki:navigation", "navigation pages exist", "skip", "no fern/docs.yml to read"));
|
|
19425
19706
|
else if (found.navigation.missing.length > 0) {
|
|
19426
19707
|
const problems = found.navigation.missing.map((p) => `${p} is listed in fern/docs.yml but is not on disk`);
|
|
19427
|
-
rows.push(row$
|
|
19708
|
+
rows.push(row$14("wiki:navigation", "navigation pages exist", "fail", `${found.navigation.missing.length} missing`, problems));
|
|
19428
19709
|
} else {
|
|
19429
|
-
rows.push(row$
|
|
19430
|
-
if (found.navigation.unlisted.length > 0) rows.push(row$
|
|
19710
|
+
rows.push(row$14("wiki:navigation", "navigation pages exist", "ok", `${found.navigation.listed} listed pages exist`));
|
|
19711
|
+
if (found.navigation.unlisted.length > 0) rows.push(row$14("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`));
|
|
19431
19712
|
}
|
|
19432
19713
|
const published = found.published;
|
|
19433
19714
|
const listed = found.navigation?.listed;
|
|
19434
|
-
if (!published) rows.push(row$
|
|
19715
|
+
if (!published) rows.push(row$14("wiki:published", "published pages", "skip", "the site's page index could not be asked"));
|
|
19435
19716
|
else if (published.pages === void 0) {
|
|
19436
19717
|
const why = published.status === void 0 ? published.error ?? "no answer" : `answered ${published.status}`;
|
|
19437
|
-
rows.push(row$
|
|
19718
|
+
rows.push(row$14("wiki:published", "published pages", "skip", `${published.url}: ${why}`));
|
|
19438
19719
|
} else if (listed !== void 0 && published.pages < listed) {
|
|
19439
19720
|
const problem = `${published.url} lists ${published.pages} page(s), the navigation lists ${listed}; the last publish is behind (run the wiki workflow)`;
|
|
19440
|
-
rows.push(row$
|
|
19441
|
-
} else rows.push(row$
|
|
19721
|
+
rows.push(row$14("wiki:published", "published pages", "fail", `${published.pages} of ${listed}`, [problem]));
|
|
19722
|
+
} else rows.push(row$14("wiki:published", "published pages", "ok", listed === void 0 ? `${published.pages} page(s) in ${published.url}` : `${published.pages} page(s) published for ${listed} listed`));
|
|
19442
19723
|
return rows;
|
|
19443
19724
|
}
|
|
19444
19725
|
// src/commands/doctor-wiki/doctor-wiki.ts
|
|
@@ -19544,7 +19825,7 @@ function readFailureRow(id, title, err) {
|
|
|
19544
19825
|
};
|
|
19545
19826
|
}
|
|
19546
19827
|
// src/commands/doctor-workers/check-project.ts
|
|
19547
|
-
const row$
|
|
19828
|
+
const row$13 = (id, title, status, detail, problems = []) => ({
|
|
19548
19829
|
id,
|
|
19549
19830
|
title,
|
|
19550
19831
|
status,
|
|
@@ -19573,30 +19854,30 @@ async function checkProject(deploy, declared) {
|
|
|
19573
19854
|
let exists = false;
|
|
19574
19855
|
try {
|
|
19575
19856
|
exists = (await deploy.listProjects()).some((p) => same$1(p.name, project) || p.id === project);
|
|
19576
|
-
rows.push(exists ? row$
|
|
19857
|
+
rows.push(exists ? row$13(ids.exists, titles.exists, "ok", `${project} on ${deploy.providerName}`) : row$13(ids.exists, titles.exists, "fail", "not found", [`no project ${project} on ${deploy.providerName}; \`holocron setup\` makes it`]));
|
|
19577
19858
|
} catch (err) {
|
|
19578
19859
|
rows.push(readFailureRow(ids.exists, titles.exists, err));
|
|
19579
19860
|
}
|
|
19580
19861
|
const notChecked = (reason) => `not checked: ${reason}`;
|
|
19581
19862
|
const gone = exists ? void 0 : "the project is not readable or not there";
|
|
19582
|
-
if (declared.hostname === void 0) {} else if (gone) rows.push(row$
|
|
19583
|
-
else if (!deploy.listDomains) rows.push(row$
|
|
19863
|
+
if (declared.hostname === void 0) {} else if (gone) rows.push(row$13(ids.domain, titles.domain, "skip", notChecked(gone)));
|
|
19864
|
+
else if (!deploy.listDomains) rows.push(row$13(ids.domain, titles.domain, "skip", `the \`${deploy.providerName}\` provider cannot list domains`));
|
|
19584
19865
|
else try {
|
|
19585
19866
|
const attached = await deploy.listDomains(project);
|
|
19586
|
-
rows.push(attached.some((d) => same$1(d, declared.hostname)) ? row$
|
|
19867
|
+
rows.push(attached.some((d) => same$1(d, declared.hostname)) ? row$13(ids.domain, titles.domain, "ok", `${declared.hostname} attached`) : row$13(ids.domain, titles.domain, "fail", `${declared.hostname} not attached`, [`${declared.hostname} is not a domain of ${project}; \`holocron setup\` attaches it`]));
|
|
19587
19868
|
} catch (err) {
|
|
19588
19869
|
rows.push(readFailureRow(ids.domain, titles.domain, err));
|
|
19589
19870
|
}
|
|
19590
|
-
if (gone) rows.push(row$
|
|
19591
|
-
else if (!deploy.latestDeployment) rows.push(row$
|
|
19871
|
+
if (gone) rows.push(row$13(ids.deploy, titles.deploy, "skip", notChecked(gone)));
|
|
19872
|
+
else if (!deploy.latestDeployment) rows.push(row$13(ids.deploy, titles.deploy, "skip", `the \`${deploy.providerName}\` provider cannot list deployments`));
|
|
19592
19873
|
else try {
|
|
19593
19874
|
const latest = await deploy.latestDeployment(project);
|
|
19594
|
-
if (!latest) rows.push(row$
|
|
19595
|
-
else if (latest.status === "ready") rows.push(row$
|
|
19875
|
+
if (!latest) rows.push(row$13(ids.deploy, titles.deploy, "skip", "no production deployment yet"));
|
|
19876
|
+
else if (latest.status === "ready") rows.push(row$13(ids.deploy, titles.deploy, "ok", latest.createdAt ? `ready, ${latest.createdAt}` : "ready"));
|
|
19596
19877
|
else if (latest.status === "error") {
|
|
19597
19878
|
const why = latest.errorMessage ? `: ${latest.errorMessage}` : "";
|
|
19598
|
-
rows.push(row$
|
|
19599
|
-
} else rows.push(row$
|
|
19879
|
+
rows.push(row$13(ids.deploy, titles.deploy, "fail", "the newest deployment errored", [`the newest production deployment of ${project} failed${why}`]));
|
|
19880
|
+
} else rows.push(row$13(ids.deploy, titles.deploy, "skip", `info: the newest deployment is ${latest.status}`));
|
|
19600
19881
|
} catch (err) {
|
|
19601
19882
|
rows.push(readFailureRow(ids.deploy, titles.deploy, err));
|
|
19602
19883
|
}
|
|
@@ -19604,7 +19885,7 @@ async function checkProject(deploy, declared) {
|
|
|
19604
19885
|
}
|
|
19605
19886
|
// src/commands/doctor-workers/check-worker.ts
|
|
19606
19887
|
const same = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
19607
|
-
const row$
|
|
19888
|
+
const row$12 = (id, title, status, detail, problems = []) => ({
|
|
19608
19889
|
id,
|
|
19609
19890
|
title,
|
|
19610
19891
|
status,
|
|
@@ -19629,9 +19910,9 @@ async function checkWorker(workers, worker) {
|
|
|
19629
19910
|
deploy: `${name} Worker's latest deployment is healthy`
|
|
19630
19911
|
};
|
|
19631
19912
|
const skipAll = (reason) => [
|
|
19632
|
-
row$
|
|
19633
|
-
row$
|
|
19634
|
-
row$
|
|
19913
|
+
row$12(ids.deployed, titles.deployed, "skip", reason),
|
|
19914
|
+
row$12(ids.bindings, titles.bindings, "skip", reason),
|
|
19915
|
+
row$12(ids.deploy, titles.deploy, "skip", reason)
|
|
19635
19916
|
];
|
|
19636
19917
|
if (worker.script === void 0) return skipAll(`${workers.providerName} does not say how it names this Worker`);
|
|
19637
19918
|
const script = worker.script;
|
|
@@ -19644,29 +19925,29 @@ async function checkWorker(workers, worker) {
|
|
|
19644
19925
|
exists = state.exists;
|
|
19645
19926
|
if (!state.exists) {
|
|
19646
19927
|
const problem = `no Worker named ${script}; \`holocron setup\` deploys it`;
|
|
19647
|
-
rows.push(row$
|
|
19928
|
+
rows.push(row$12(ids.deployed, titles.deployed, "fail", `${script} not deployed`, [problem]), row$12(ids.bindings, titles.bindings, "skip", `not checked: no Worker named ${script}`));
|
|
19648
19929
|
} else {
|
|
19649
|
-
rows.push(state.routes.some((r) => same(r, route)) ? row$
|
|
19650
|
-
if (worker.bindings.length === 0) rows.push(row$
|
|
19930
|
+
rows.push(state.routes.some((r) => same(r, route)) ? row$12(ids.deployed, titles.deployed, "ok", `${script} serves ${route}`) : row$12(ids.deployed, titles.deployed, "fail", `no route ${route}`, [`${script} has no route ${route}`]));
|
|
19931
|
+
if (worker.bindings.length === 0) rows.push(row$12(ids.bindings, titles.bindings, "ok", "none declared"));
|
|
19651
19932
|
else {
|
|
19652
19933
|
const bound = new Set(state.bindingNames.map((n) => n.toUpperCase()));
|
|
19653
19934
|
const missing = worker.bindings.filter((n) => !bound.has(n.toUpperCase()));
|
|
19654
|
-
rows.push(missing.length === 0 ? row$
|
|
19935
|
+
rows.push(missing.length === 0 ? row$12(ids.bindings, titles.bindings, "ok", `${worker.bindings.length} of ${worker.bindings.length} bound`) : row$12(ids.bindings, titles.bindings, "fail", `${missing.length} not bound`, missing.map((n) => `${n}: not bound`)));
|
|
19655
19936
|
}
|
|
19656
19937
|
}
|
|
19657
19938
|
} catch (err) {
|
|
19658
19939
|
const failure = readFailureRow(ids.deployed, titles.deployed, err);
|
|
19659
|
-
rows.push(failure, row$
|
|
19940
|
+
rows.push(failure, row$12(ids.bindings, titles.bindings, "skip", "not checked: could not read the Worker"));
|
|
19660
19941
|
}
|
|
19661
|
-
if (!exists) rows.push(row$
|
|
19662
|
-
else if (!workers.latestDeployment) rows.push(row$
|
|
19942
|
+
if (!exists) rows.push(row$12(ids.deploy, titles.deploy, "skip", "not checked: the Worker is not readable or not there"));
|
|
19943
|
+
else if (!workers.latestDeployment) rows.push(row$12(ids.deploy, titles.deploy, "skip", `the \`${workers.providerName}\` provider cannot list deployments`));
|
|
19663
19944
|
else try {
|
|
19664
19945
|
const latest = await workers.latestDeployment(script);
|
|
19665
|
-
if (!latest) rows.push(row$
|
|
19946
|
+
if (!latest) rows.push(row$12(ids.deploy, titles.deploy, "skip", `${script} has no recorded deployment`));
|
|
19666
19947
|
else if (!latest.active) {
|
|
19667
19948
|
const problem = `the newest deployment of ${script} does not serve all traffic`;
|
|
19668
|
-
rows.push(row$
|
|
19669
|
-
} else rows.push(row$
|
|
19949
|
+
rows.push(row$12(ids.deploy, titles.deploy, "fail", "not serving all traffic", [problem]));
|
|
19950
|
+
} else rows.push(row$12(ids.deploy, titles.deploy, "ok", latest.createdAt ? `deployed ${latest.createdAt}` : "serving all traffic"));
|
|
19670
19951
|
} catch (err) {
|
|
19671
19952
|
rows.push(readFailureRow(ids.deploy, titles.deploy, err));
|
|
19672
19953
|
}
|
|
@@ -19730,7 +20011,7 @@ function declaredWorkers(input) {
|
|
|
19730
20011
|
* custom domain is attached, and the newest production deployment is ready. Only what the provider proves wrong
|
|
19731
20012
|
* fails; a missing token, a 401 or 403, or a provider that cannot read it is a skip with the reason.
|
|
19732
20013
|
*/
|
|
19733
|
-
const row$
|
|
20014
|
+
const row$11 = (id, title, status, detail) => ({
|
|
19734
20015
|
id,
|
|
19735
20016
|
title,
|
|
19736
20017
|
status,
|
|
@@ -19756,12 +20037,12 @@ async function runDoctorWorkers(input) {
|
|
|
19756
20037
|
...loader.has("wiki") ? { wiki: loader.get("wiki") } : {},
|
|
19757
20038
|
...workers ? { workers } : {}
|
|
19758
20039
|
});
|
|
19759
|
-
if (declared.length === 0) rows.push(row$
|
|
20040
|
+
if (declared.length === 0) rows.push(row$11("workers", "declared Workers", "ok", "none declared"));
|
|
19760
20041
|
else if (!workers) {
|
|
19761
20042
|
const why = whyNone(loader, "workers", "no `workers` provider is configured in holocron.config.ts");
|
|
19762
|
-
for (const worker of declared) rows.push(row$
|
|
20043
|
+
for (const worker of declared) rows.push(row$11(`workers:${worker.label}`, `${worker.label} Worker`, "skip", why));
|
|
19763
20044
|
} else for (const worker of declared) rows.push(...await checkWorker(workers, worker));
|
|
19764
|
-
if (!loader.has("deployment")) rows.push(row$
|
|
20045
|
+
if (!loader.has("deployment")) rows.push(row$11("deployment", "deployment project", "skip", whyNone(loader, "deployment", "no `deployment` provider is configured in holocron.config.ts")));
|
|
19765
20046
|
else {
|
|
19766
20047
|
const deploy = loader.get("deployment");
|
|
19767
20048
|
for (const project of declaredProjects(input.loaded.resolved, deploy)) rows.push(...await checkProject(deploy, project));
|
|
@@ -20745,7 +21026,7 @@ function resolveExportDir(input) {
|
|
|
20745
21026
|
* listed under the provider's row and does not fail the run. It writes files, so it asks first unless `--dry-run` (the
|
|
20746
21027
|
* files are converted and listed, nothing is written) or `--yes` (without a terminal it refuses instead).
|
|
20747
21028
|
*/
|
|
20748
|
-
const row$
|
|
21029
|
+
const row$10 = (id, status, detail, problems = []) => ({
|
|
20749
21030
|
id,
|
|
20750
21031
|
title: id,
|
|
20751
21032
|
status,
|
|
@@ -20787,9 +21068,9 @@ async function runRequestsExport(input) {
|
|
|
20787
21068
|
print("");
|
|
20788
21069
|
const entry = input.loaded.resolved.providers.tooling;
|
|
20789
21070
|
const tuples = entry?.cardinality === "many" ? entry.tuples : [];
|
|
20790
|
-
if (tuples.length === 0) return finish([row$
|
|
21071
|
+
if (tuples.length === 0) return finish([row$10("tooling", "fail", "the config has no `tooling` provider to export for")]);
|
|
20791
21072
|
const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
|
|
20792
|
-
if (chosen.length === 0) return finish([row$
|
|
21073
|
+
if (chosen.length === 0) return finish([row$10(input.to, "fail", `not a \`tooling\` provider of this config (${tuples.map((t) => t.provider).join(", ")})`)]);
|
|
20793
21074
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
20794
21075
|
const loader = input.loader ?? new PluginLoader({
|
|
20795
21076
|
...input.loaded.resolved,
|
|
@@ -20809,17 +21090,17 @@ async function runRequestsExport(input) {
|
|
|
20809
21090
|
const tool = loaded.find((t) => t.providerName === id);
|
|
20810
21091
|
if (!tool) {
|
|
20811
21092
|
const failure = loader.loadFailures().find((f) => f.key === "tooling" && f.provider === id);
|
|
20812
|
-
rows.push(row$
|
|
21093
|
+
rows.push(row$10(id, "fail", `the provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`));
|
|
20813
21094
|
continue;
|
|
20814
21095
|
}
|
|
20815
21096
|
if (!tool.export) {
|
|
20816
|
-
rows.push(row$
|
|
21097
|
+
rows.push(row$10(id, "skip", "has no export: it reads the repo's files as they are"));
|
|
20817
21098
|
continue;
|
|
20818
21099
|
}
|
|
20819
21100
|
const collectionFiles = fileList$1(tuple.options.collectionFiles);
|
|
20820
21101
|
const envFiles = fileList$1(tuple.options.envFiles);
|
|
20821
21102
|
if (collectionFiles.length === 0) {
|
|
20822
|
-
rows.push(row$
|
|
21103
|
+
rows.push(row$10(id, "skip", "names no `collectionFiles`, so there is nothing to export"));
|
|
20823
21104
|
continue;
|
|
20824
21105
|
}
|
|
20825
21106
|
const groups = input.out === void 0 ? groupByFolder(collectionFiles) : [collectionFiles];
|
|
@@ -20833,7 +21114,7 @@ async function runRequestsExport(input) {
|
|
|
20833
21114
|
...input.out !== void 0 ? { out: input.out } : {}
|
|
20834
21115
|
});
|
|
20835
21116
|
if (!dir.ok) {
|
|
20836
|
-
rows.push(row$
|
|
21117
|
+
rows.push(row$10(label, "fail", dir.message));
|
|
20837
21118
|
continue;
|
|
20838
21119
|
}
|
|
20839
21120
|
targets.push({
|
|
@@ -20872,9 +21153,9 @@ async function runRequestsExport(input) {
|
|
|
20872
21153
|
const where = relative(repoRoot, outDir);
|
|
20873
21154
|
const files = result.files.length > 0 ? ` (${result.files.join(", ")})` : "";
|
|
20874
21155
|
paths.push(...result.files.map((file) => resolve(outDir, file)));
|
|
20875
|
-
rows.push(row$
|
|
21156
|
+
rows.push(row$10(label, "ok", `${dryRun ? "would write" : "wrote"} ${result.files.length} file(s) to ${where}${files}`, result.issues.map((issue) => `issue in ${issue.file}: ${issue.message}`)));
|
|
20876
21157
|
} catch (err) {
|
|
20877
|
-
rows.push(row$
|
|
21158
|
+
rows.push(row$10(label, "fail", describeError(err)));
|
|
20878
21159
|
}
|
|
20879
21160
|
const report = finish(rows.sort((a, b) => a.id.localeCompare(b.id)));
|
|
20880
21161
|
if (paths.length > 0) {
|
|
@@ -21740,7 +22021,8 @@ function generateWorkflowFiles(input) {
|
|
|
21740
22021
|
cwd: input.repoRoot,
|
|
21741
22022
|
config: {
|
|
21742
22023
|
tasks,
|
|
21743
|
-
extraRequiredChecks: config.extraRequiredChecks
|
|
22024
|
+
extraRequiredChecks: config.extraRequiredChecks,
|
|
22025
|
+
...config.ci === void 0 ? {} : { ci: config.ci }
|
|
21744
22026
|
},
|
|
21745
22027
|
orgContext: {
|
|
21746
22028
|
org: config.org,
|
|
@@ -21809,6 +22091,7 @@ function generateWorkflowFiles(input) {
|
|
|
21809
22091
|
});
|
|
21810
22092
|
}
|
|
21811
22093
|
for (const [id, content] of hostedReusableWorkflows()) {
|
|
22094
|
+
if (id === "ci" && astromech.aggregatePoster() === "sentinel") continue;
|
|
21812
22095
|
const filename = workflowFile(id);
|
|
21813
22096
|
entries.push({
|
|
21814
22097
|
kind: "file",
|
|
@@ -25058,7 +25341,7 @@ function specName(title, name) {
|
|
|
25058
25341
|
*/
|
|
25059
25342
|
/** How many lines of the spec a dry run shows. */
|
|
25060
25343
|
const PREVIEW_LINES$1 = 12;
|
|
25061
|
-
const row$
|
|
25344
|
+
const row$9 = (id, status, detail) => ({
|
|
25062
25345
|
id,
|
|
25063
25346
|
title: id,
|
|
25064
25347
|
status,
|
|
@@ -25088,7 +25371,7 @@ async function runIdeasPromote(input) {
|
|
|
25088
25371
|
print(style.header(`Holocron new spec${dryRun ? " (dry-run)" : ""}`));
|
|
25089
25372
|
print("");
|
|
25090
25373
|
const entry = input.loaded.resolved.providers.issues;
|
|
25091
|
-
if (!entry) return finish([row$
|
|
25374
|
+
if (!entry) return finish([row$9(input.issue, "fail", "the config has no `issues` provider to read the issue with")]);
|
|
25092
25375
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
25093
25376
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
25094
25377
|
const loader = input.loader ?? new PluginLoader({
|
|
@@ -25103,18 +25386,18 @@ async function runIdeasPromote(input) {
|
|
|
25103
25386
|
assertPluginsResolvable(loader, "new spec");
|
|
25104
25387
|
if (!loader.has("issues")) {
|
|
25105
25388
|
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
25106
|
-
return finish([row$
|
|
25389
|
+
return finish([row$9(input.issue, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
25107
25390
|
}
|
|
25108
25391
|
let issue;
|
|
25109
25392
|
try {
|
|
25110
25393
|
issue = await loader.get("issues").get(input.issue);
|
|
25111
25394
|
} catch (err) {
|
|
25112
|
-
return finish([row$
|
|
25395
|
+
return finish([row$9(input.issue, "fail", `could not read the issue: ${describeError(err)}`)]);
|
|
25113
25396
|
}
|
|
25114
25397
|
const name = specName(issue.summary, input.name);
|
|
25115
|
-
if (!name) return finish([row$
|
|
25398
|
+
if (!name) return finish([row$9(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`)]);
|
|
25116
25399
|
const relative = join(".notes", `${name}.spec.md`);
|
|
25117
|
-
if (io.exists(join(input.context.repoRoot, relative))) return finish([row$
|
|
25400
|
+
if (io.exists(join(input.context.repoRoot, relative))) return finish([row$9(relative, "fail", "the spec already exists; it is never overwritten")], relative);
|
|
25118
25401
|
const { org, name: repoName } = input.loaded.resolved;
|
|
25119
25402
|
const ref = githubRef(issue.url) ?? (issue.key.startsWith("#") ? `${org}/${repoName}${issue.key}` : issue.key);
|
|
25120
25403
|
const { content, fromIdea } = buildSpec({
|
|
@@ -25127,7 +25410,7 @@ async function runIdeasPromote(input) {
|
|
|
25127
25410
|
print(` ${relative}`);
|
|
25128
25411
|
for (const line of content.split("\n").slice(0, PREVIEW_LINES$1)) print(` ${style.skip(line)}`);
|
|
25129
25412
|
print("");
|
|
25130
|
-
return finish([row$
|
|
25413
|
+
return finish([row$9(relative, "skip", `would write the spec ${origin}`)], relative);
|
|
25131
25414
|
}
|
|
25132
25415
|
if (!input.yes) {
|
|
25133
25416
|
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`);
|
|
@@ -25146,9 +25429,9 @@ async function runIdeasPromote(input) {
|
|
|
25146
25429
|
try {
|
|
25147
25430
|
io.write(join(input.context.repoRoot, relative), content);
|
|
25148
25431
|
} catch (err) {
|
|
25149
|
-
return finish([row$
|
|
25432
|
+
return finish([row$9(relative, "fail", `could not write the spec: ${describeError(err)}`)], relative);
|
|
25150
25433
|
}
|
|
25151
|
-
return finish([row$
|
|
25434
|
+
return finish([row$9(relative, "ok", `wrote the spec ${origin}`)], relative);
|
|
25152
25435
|
}
|
|
25153
25436
|
// src/commands/ideas-promote/ideas-promote.command.ts
|
|
25154
25437
|
const ideasPromoteCommand = {
|
|
@@ -25224,7 +25507,7 @@ function readIssueBody(file, cwd, read = (p) => readFileSync(p, "utf8")) {
|
|
|
25224
25507
|
*/
|
|
25225
25508
|
/** How many lines of the body a dry run shows. */
|
|
25226
25509
|
const PREVIEW_LINES = 8;
|
|
25227
|
-
const row$
|
|
25510
|
+
const row$8 = (id, status, detail) => ({
|
|
25228
25511
|
id,
|
|
25229
25512
|
title: id,
|
|
25230
25513
|
status,
|
|
@@ -25248,11 +25531,11 @@ async function runIssueCreate(input) {
|
|
|
25248
25531
|
print(style.header(`Holocron new issue${dryRun ? " (dry-run)" : ""}`));
|
|
25249
25532
|
print("");
|
|
25250
25533
|
const title = input.title.trim();
|
|
25251
|
-
if (!title) return finish([row$
|
|
25534
|
+
if (!title) return finish([row$8("title", "fail", "the title is empty")]);
|
|
25252
25535
|
const prepared = prepareIssueFields(input, input.loaded.resolved.repo?.labels?.areas);
|
|
25253
|
-
if (!prepared.ok) return finish(prepared.problems.map((p) => row$
|
|
25536
|
+
if (!prepared.ok) return finish(prepared.problems.map((p) => row$8(title, "fail", p)));
|
|
25254
25537
|
const entry = input.loaded.resolved.providers.issues;
|
|
25255
|
-
if (!entry) return finish([row$
|
|
25538
|
+
if (!entry) return finish([row$8(title, "fail", "the config has no `issues` provider to file the issue with")]);
|
|
25256
25539
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
25257
25540
|
const projects = prepared.project ? input.loaded.resolved.providers.projects : void 0;
|
|
25258
25541
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
@@ -25269,7 +25552,7 @@ async function runIssueCreate(input) {
|
|
|
25269
25552
|
assertPluginsResolvable(loader, "new issue");
|
|
25270
25553
|
if (!loader.has("issues")) {
|
|
25271
25554
|
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
25272
|
-
return finish([row$
|
|
25555
|
+
return finish([row$8(title, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
25273
25556
|
}
|
|
25274
25557
|
const labels = [.../* @__PURE__ */ new Set([...(input.labels ?? []).map((l) => l.trim()).filter(Boolean), ...prepared.areaLabels])];
|
|
25275
25558
|
const body = input.body?.trim() ? input.body : void 0;
|
|
@@ -25286,7 +25569,7 @@ async function runIssueCreate(input) {
|
|
|
25286
25569
|
print(` ${title}`);
|
|
25287
25570
|
for (const line of body ? body.split("\n").slice(0, PREVIEW_LINES) : []) print(` ${style.skip(line)}`);
|
|
25288
25571
|
print("");
|
|
25289
|
-
return finish([row$
|
|
25572
|
+
return finish([row$8(title, "skip", `would file the issue${summary}`)]);
|
|
25290
25573
|
}
|
|
25291
25574
|
if (!input.yes) {
|
|
25292
25575
|
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");
|
|
@@ -25319,12 +25602,12 @@ async function runIssueCreate(input) {
|
|
|
25319
25602
|
...prepared.fields.priority ? { priority: prepared.fields.priority } : {}
|
|
25320
25603
|
}) : void 0;
|
|
25321
25604
|
return finish([
|
|
25322
|
-
row$
|
|
25323
|
-
...(dropped ?? []).map((line) => row$
|
|
25605
|
+
row$8(title, "ok", `filed ${key}`),
|
|
25606
|
+
...(dropped ?? []).map((line) => row$8("not carried across", "skip", line)),
|
|
25324
25607
|
...board ? [board] : []
|
|
25325
25608
|
], key);
|
|
25326
25609
|
} catch (err) {
|
|
25327
|
-
return finish([row$
|
|
25610
|
+
return finish([row$8(title, "fail", `could not file the issue: ${describeError(err)}`)]);
|
|
25328
25611
|
}
|
|
25329
25612
|
}
|
|
25330
25613
|
// src/commands/issue-create/issue-create.command.ts
|
|
@@ -25620,7 +25903,7 @@ function readGitConfig(cwd, key, run = runGit) {
|
|
|
25620
25903
|
* identity; Effort is asked on a terminal when it was not given (the CLI never chooses it). The issue's key is printed
|
|
25621
25904
|
* by the first row, before anything else is done, so a failed spec leaves the issue as the anchor to resume from.
|
|
25622
25905
|
*/
|
|
25623
|
-
const row$
|
|
25906
|
+
const row$7 = (id, status, detail) => ({
|
|
25624
25907
|
id,
|
|
25625
25908
|
title: id,
|
|
25626
25909
|
status,
|
|
@@ -25639,7 +25922,7 @@ async function runNewWork(input) {
|
|
|
25639
25922
|
const name = specName(input.title, input.specName);
|
|
25640
25923
|
if (!name) {
|
|
25641
25924
|
const detail = input.specName === void 0 ? "no spec name can be made from the title; pass --spec <name>" : `"${input.specName}" is not a spec name: use lower-case words joined by hyphens, such as tech-my-topic`;
|
|
25642
|
-
const rows = [row$
|
|
25925
|
+
const rows = [row$7("spec", "fail", detail)];
|
|
25643
25926
|
printCheckRows(rows, print);
|
|
25644
25927
|
return {
|
|
25645
25928
|
status: "fail",
|
|
@@ -25648,7 +25931,7 @@ async function runNewWork(input) {
|
|
|
25648
25931
|
}
|
|
25649
25932
|
specPath = join(".notes", `${name}.spec.md`);
|
|
25650
25933
|
if (io.exists(join(root, specPath))) {
|
|
25651
|
-
const rows = [row$
|
|
25934
|
+
const rows = [row$7(specPath, "fail", "the spec already exists; it is never overwritten")];
|
|
25652
25935
|
printCheckRows(rows, print);
|
|
25653
25936
|
return {
|
|
25654
25937
|
status: "fail",
|
|
@@ -25658,7 +25941,7 @@ async function runNewWork(input) {
|
|
|
25658
25941
|
}
|
|
25659
25942
|
}
|
|
25660
25943
|
const assignees = input.assignees && input.assignees.length > 0 ? input.assignees : [gitAssignee(input.gitConfig ?? ((key) => readGitConfig(root, key)))].filter((a) => Boolean(a));
|
|
25661
|
-
if (!input.assignees?.length && assignees.length === 0) extra.push(row$
|
|
25944
|
+
if (!input.assignees?.length && assignees.length === 0) extra.push(row$7("assignee", "skip", "git config has no GitHub login (`github.user`); pass --assignee to assign the issue"));
|
|
25662
25945
|
let effort = input.effort;
|
|
25663
25946
|
const interactive = input.interactive ?? Boolean(process.stdin.isTTY);
|
|
25664
25947
|
if (!effort && !input.yes && !dryRun && interactive) effort = await (input.askEffort ?? promptEffort)();
|
|
@@ -28403,7 +28686,7 @@ const MARKER = "# written by `holocron open requests` for one session and remove
|
|
|
28403
28686
|
const SECRETS_FILE = `${PRIVATE_DIR}/requests.env`;
|
|
28404
28687
|
/** The lock a launch holds, in the private directory. */
|
|
28405
28688
|
const LOCK_FILE = `${PRIVATE_DIR}/open-requests.lock`;
|
|
28406
|
-
const row$
|
|
28689
|
+
const row$6 = (id, status, detail, problems = []) => ({
|
|
28407
28690
|
id,
|
|
28408
28691
|
title: id,
|
|
28409
28692
|
status,
|
|
@@ -28444,7 +28727,7 @@ async function runOpenRequests(input) {
|
|
|
28444
28727
|
const tuples = entry?.cardinality === "many" ? entry.tuples : [];
|
|
28445
28728
|
const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
|
|
28446
28729
|
if (chosen.length === 0) {
|
|
28447
|
-
say(row$
|
|
28730
|
+
say(row$6(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(", ")})`));
|
|
28448
28731
|
return finish();
|
|
28449
28732
|
}
|
|
28450
28733
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
@@ -28454,7 +28737,7 @@ async function runOpenRequests(input) {
|
|
|
28454
28737
|
assertPluginsResolvable(loader, "open requests");
|
|
28455
28738
|
const openable = (loader.has("tooling") ? loader.get("tooling") : []).filter((t) => chosen.some((tuple) => tuple.provider === t.providerName)).filter((t) => t.open !== void 0);
|
|
28456
28739
|
if (openable.length !== 1) {
|
|
28457
|
-
say(row$
|
|
28740
|
+
say(row$6("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`));
|
|
28458
28741
|
return finish();
|
|
28459
28742
|
}
|
|
28460
28743
|
const tool = openable[0];
|
|
@@ -28468,34 +28751,34 @@ async function runOpenRequests(input) {
|
|
|
28468
28751
|
repoRoot
|
|
28469
28752
|
});
|
|
28470
28753
|
} catch (err) {
|
|
28471
|
-
say(row$
|
|
28754
|
+
say(row$6(tool.providerName, "fail", describeError(err)));
|
|
28472
28755
|
return finish();
|
|
28473
28756
|
}
|
|
28474
28757
|
const loaded = plan.wants.filter((want) => layers.includes(want.layer));
|
|
28475
28758
|
const notLoaded = plan.wants.filter((want) => !layers.includes(want.layer));
|
|
28476
28759
|
const names = [...new Set(loaded.map((want) => want.name))].sort();
|
|
28477
|
-
if (plan.unfilled.length > 0) say(row$
|
|
28478
|
-
say(row$
|
|
28760
|
+
if (plan.unfilled.length > 0) say(row$6("unfilled", "skip", `${plan.unfilled.length} secret variable(s) refer to no entry, so nobody fills them`, plan.unfilled));
|
|
28761
|
+
say(row$6("layers", notLoaded.length > 0 ? "skip" : "ok", `loaded: ${layers.join(", ")}; not loaded: ${OPEN_LAYERS.filter((layer) => !layers.includes(layer)).join(", ") || "none"}`, notLoaded.map((want) => `${want.collection}: ${want.variable} is a ${want.layer} secret (${want.name}); start with --environment ${want.layer} to load it`)));
|
|
28479
28762
|
if (dryRun) {
|
|
28480
|
-
for (const want of loaded) say(row$
|
|
28481
|
-
if (names.length === 0) say(row$
|
|
28482
|
-
else say(row$
|
|
28483
|
-
say(row$
|
|
28763
|
+
for (const want of loaded) say(row$6(want.variable, "ok", `would fill ${want.collection}'s ${want.variable} from ${want.entry} of ${want.layer} as ${want.name}`));
|
|
28764
|
+
if (names.length === 0) say(row$6("secrets", "ok", "nothing to fill: no variable refers to an entry"));
|
|
28765
|
+
else say(row$6("secrets", "ok", `would write ${names.length} value(s) to ${SECRETS_FILE} and link it from ${plan.targets.length} collection(s)`));
|
|
28766
|
+
say(row$6(plan.app, "ok", `would start ${plan.launch.command} in the foreground`));
|
|
28484
28767
|
return finish();
|
|
28485
28768
|
}
|
|
28486
28769
|
if (deps.platform === "win32" && names.length > 0) {
|
|
28487
|
-
say(row$
|
|
28770
|
+
say(row$6(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"));
|
|
28488
28771
|
return finish();
|
|
28489
28772
|
}
|
|
28490
28773
|
let running;
|
|
28491
28774
|
try {
|
|
28492
28775
|
running = await deps.processes();
|
|
28493
28776
|
} catch (err) {
|
|
28494
|
-
say(row$
|
|
28777
|
+
say(row$6(plan.app, "fail", `could not tell whether ${plan.app} is running: ${describeError(err)}`));
|
|
28495
28778
|
return finish();
|
|
28496
28779
|
}
|
|
28497
28780
|
if (running.split("\n").some((line) => line.includes(plan.running))) {
|
|
28498
|
-
say(row$
|
|
28781
|
+
say(row$6(plan.app, "fail", `${plan.app} is already running; quit it and run this again (it would not see the values)`));
|
|
28499
28782
|
return finish();
|
|
28500
28783
|
}
|
|
28501
28784
|
if (!input.yes) {
|
|
@@ -28512,7 +28795,7 @@ async function runOpenRequests(input) {
|
|
|
28512
28795
|
if (names.length > 0) {
|
|
28513
28796
|
const vault = loader.has("vault") ? loader.get("vault") : void 0;
|
|
28514
28797
|
if (!vault?.readEnvironmentEntries) {
|
|
28515
|
-
say(row$
|
|
28798
|
+
say(row$6("vault", "fail", vault ? `${vault.providerName} cannot read an Environment's entries` : "needs a `vault` provider in holocron.config.ts (1password)"));
|
|
28516
28799
|
return finish();
|
|
28517
28800
|
}
|
|
28518
28801
|
let failed = false;
|
|
@@ -28529,17 +28812,17 @@ async function runOpenRequests(input) {
|
|
|
28529
28812
|
names: [...new Set(wanted.map((want) => want.entry))].sort()
|
|
28530
28813
|
});
|
|
28531
28814
|
} catch (err) {
|
|
28532
|
-
say(row$
|
|
28815
|
+
say(row$6(`vault ${layer}`, "fail", describeError(err)));
|
|
28533
28816
|
failed = true;
|
|
28534
28817
|
continue;
|
|
28535
28818
|
}
|
|
28536
28819
|
for (const entry of read.missing) {
|
|
28537
|
-
say(row$
|
|
28820
|
+
say(row$6(`${layer} ${entry}`, "fail", `${read.environmentId} holds no value for ${entry}`));
|
|
28538
28821
|
failed = true;
|
|
28539
28822
|
}
|
|
28540
28823
|
if (read.missing.length > 0) continue;
|
|
28541
28824
|
for (const want of wanted) values.set(want.name, read.values.get(want.entry));
|
|
28542
|
-
say(row$
|
|
28825
|
+
say(row$6(`vault ${read.environmentId}`, "ok", `${wanted.length} value(s) read: ${[...new Set(wanted.map((want) => want.name))].join(", ")}`));
|
|
28543
28826
|
}
|
|
28544
28827
|
if (failed) return finish();
|
|
28545
28828
|
}
|
|
@@ -28559,7 +28842,7 @@ async function runOpenRequests(input) {
|
|
|
28559
28842
|
};
|
|
28560
28843
|
deps.makeDir(dirname(secrets));
|
|
28561
28844
|
if (!deps.takeLock(lock, deps.pid)) {
|
|
28562
|
-
say(row$
|
|
28845
|
+
say(row$6(plan.app, "fail", `another \`open requests\` is starting ${plan.app} (${LOCK_FILE} is held); try again when it has`));
|
|
28563
28846
|
return finish();
|
|
28564
28847
|
}
|
|
28565
28848
|
const stop = deps.onTerminate(cleanup);
|
|
@@ -28567,18 +28850,18 @@ async function runOpenRequests(input) {
|
|
|
28567
28850
|
if (names.length > 0) {
|
|
28568
28851
|
const ignored = deps.isIgnored(secrets);
|
|
28569
28852
|
if (ignored === "tracked" || ignored === "unknown") {
|
|
28570
|
-
say(row$
|
|
28853
|
+
say(row$6("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, "")]));
|
|
28571
28854
|
return finish();
|
|
28572
28855
|
}
|
|
28573
28856
|
const stale = deps.inspect(secrets);
|
|
28574
28857
|
if (stale.kind !== "none" && !(stale.kind === "file" && stale.firstLine === "# written by `holocron open requests` for one session and removed when it ends")) {
|
|
28575
|
-
say(row$
|
|
28858
|
+
say(row$6("values file", "fail", `${SECRETS_FILE} is not this command's (no marker line); move it away`));
|
|
28576
28859
|
return finish();
|
|
28577
28860
|
}
|
|
28578
28861
|
for (const link of plan.targets) {
|
|
28579
28862
|
const state = deps.inspect(link);
|
|
28580
28863
|
if (state.kind !== "none" && !isOurs(state, link, secrets)) {
|
|
28581
|
-
say(row$
|
|
28864
|
+
say(row$6("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`));
|
|
28582
28865
|
return finish();
|
|
28583
28866
|
}
|
|
28584
28867
|
}
|
|
@@ -28586,7 +28869,7 @@ async function runOpenRequests(input) {
|
|
|
28586
28869
|
for (const [name, value] of values) {
|
|
28587
28870
|
const line = dotenvLine(name, value);
|
|
28588
28871
|
if (line === null) {
|
|
28589
|
-
say(row$
|
|
28872
|
+
say(row$6(name, "fail", `the value of ${name} cannot be written to a .env file as it is; it was not written`));
|
|
28590
28873
|
return finish();
|
|
28591
28874
|
}
|
|
28592
28875
|
lines.push(line);
|
|
@@ -28599,7 +28882,7 @@ async function runOpenRequests(input) {
|
|
|
28599
28882
|
deps.symlink(relative(dirname(link), secrets), link);
|
|
28600
28883
|
created.push(link);
|
|
28601
28884
|
}
|
|
28602
|
-
say(row$
|
|
28885
|
+
say(row$6("values file", "ok", `${SECRETS_FILE} (mode 0600, git-ignored) linked from ${plan.targets.map((t) => relative(repoRoot, t)).join(", ")}`));
|
|
28603
28886
|
}
|
|
28604
28887
|
print("");
|
|
28605
28888
|
print(`starting ${plan.app}${names.length > 0 ? `; the values are removed when it quits (Ctrl-C ends it too)` : ""}`);
|
|
@@ -28607,10 +28890,10 @@ async function runOpenRequests(input) {
|
|
|
28607
28890
|
try {
|
|
28608
28891
|
exitCode = await deps.run(plan.launch);
|
|
28609
28892
|
} catch (err) {
|
|
28610
|
-
say(row$
|
|
28893
|
+
say(row$6(plan.app, "fail", describeError(err)));
|
|
28611
28894
|
return finish();
|
|
28612
28895
|
}
|
|
28613
|
-
say(row$
|
|
28896
|
+
say(row$6(plan.app, exitCode === 0 ? "ok" : "fail", `ended with ${exitCode}`));
|
|
28614
28897
|
return finish();
|
|
28615
28898
|
} finally {
|
|
28616
28899
|
stop();
|
|
@@ -32490,11 +32773,380 @@ const projectReconcileCommand = {
|
|
|
32490
32773
|
})).status === "fail") process.exitCode = 1;
|
|
32491
32774
|
}
|
|
32492
32775
|
};
|
|
32776
|
+
// src/commands/reconcile-ci/run-reconcile-ci/run-reconcile-ci.ts
|
|
32777
|
+
/**
|
|
32778
|
+
* `holocron reconcile ci [pull-request]` — make the `ci / Required checks` check say what the state calls for.
|
|
32779
|
+
*
|
|
32780
|
+
* It is the manual tool and the scheduled sweep of spec `process-sentinel-posts-ci` (SPEC-0099): for each open pull
|
|
32781
|
+
* request (or the one named) it reads the check runs and commit statuses of the head commit through the `source`
|
|
32782
|
+
* provider and calls astromech's `postAggregate()`, the one function Sentinel's webhook handler uses too. A pull request
|
|
32783
|
+
* whose check already says the verdict is left alone, so a healthy run writes nothing; one with no check, or one that
|
|
32784
|
+
* disagrees, is posted. A pull request that was missing or wrong and had waited longer than `--max-age` is a failing
|
|
32785
|
+
* row, because that is what a missed delivery looks like; one younger than that is still in flight and only reported.
|
|
32786
|
+
*
|
|
32787
|
+
* It posts the real `ci / Required checks` only where the checkout's `ci.aggregate` is `sentinel`: while it is
|
|
32788
|
+
* `actions` the Actions job is the poster and a second writer would be a second poster, so the command does nothing
|
|
32789
|
+
* unless `--shadow` asks it to repair Sentinel's shadow check. A run on a commit where another app (the Actions
|
|
32790
|
+
* job) already posts the check leaves it alone.
|
|
32791
|
+
*
|
|
32792
|
+
* `expected` comes from the config of the checkout it runs in. The sweep runs from the default branch, which is the
|
|
32793
|
+
* base of the pull requests it repairs, so a pull request cannot shrink its own gate. `--dry-run` reads and prints what
|
|
32794
|
+
* it would do and posts nothing.
|
|
32795
|
+
*/
|
|
32796
|
+
const DEFAULT_MAX_AGE_MINUTES = 10;
|
|
32797
|
+
const row$5 = (id, status, detail) => ({
|
|
32798
|
+
id,
|
|
32799
|
+
title: id,
|
|
32800
|
+
status,
|
|
32801
|
+
detail,
|
|
32802
|
+
problems: []
|
|
32803
|
+
});
|
|
32804
|
+
/** The `source` methods the sweep needs, all of them optional on the capability. */
|
|
32805
|
+
function missingMethods(source) {
|
|
32806
|
+
return [
|
|
32807
|
+
"listCheckRuns",
|
|
32808
|
+
"listCommitStatuses",
|
|
32809
|
+
"createCheckRun",
|
|
32810
|
+
"updateCheckRun"
|
|
32811
|
+
].filter((name) => typeof source[name] !== "function");
|
|
32812
|
+
}
|
|
32813
|
+
/** Runs `holocron reconcile ci`; see the file's comment. */
|
|
32814
|
+
async function runReconcileCi(input) {
|
|
32815
|
+
/* v8 ignore next -- the console is only used outside tests, which inject `print` */
|
|
32816
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
32817
|
+
const logger = input.logger ?? getLogger();
|
|
32818
|
+
const now = input.now ?? Date.now;
|
|
32819
|
+
const dryRun = Boolean(input.context.dryRun);
|
|
32820
|
+
const rows = [];
|
|
32821
|
+
const finish = () => {
|
|
32822
|
+
printCheckRows(rows, print);
|
|
32823
|
+
const summary = summariseChecks(rows);
|
|
32824
|
+
printCheckSummary(summary, print);
|
|
32825
|
+
const status = summary.fail > 0 ? "fail" : "ok";
|
|
32826
|
+
logger.info({
|
|
32827
|
+
...summary,
|
|
32828
|
+
status
|
|
32829
|
+
}, "reconcile ci");
|
|
32830
|
+
return {
|
|
32831
|
+
status,
|
|
32832
|
+
rows
|
|
32833
|
+
};
|
|
32834
|
+
};
|
|
32835
|
+
const fail = (id, detail) => {
|
|
32836
|
+
rows.push(row$5(id, "fail", detail));
|
|
32837
|
+
return finish();
|
|
32838
|
+
};
|
|
32839
|
+
print(style.header(`Holocron reconcile ci${dryRun ? " (dry-run)" : ""}`));
|
|
32840
|
+
print("");
|
|
32841
|
+
if (input.maxAgeMinutes !== void 0 && !(input.maxAgeMinutes > 0)) return fail("max-age", "--max-age is a number of minutes above zero");
|
|
32842
|
+
if (!input.shadow && aggregatePoster({ ci: input.loaded.resolved.ci }) === "actions") {
|
|
32843
|
+
rows.push(row$5("ci.aggregate", "skip", `ci.aggregate is actions here, so the Actions job posts ${AGGREGATE_CHECK_NAME} and nothing is posted; --shadow repairs Sentinel's shadow check`));
|
|
32844
|
+
return finish();
|
|
32845
|
+
}
|
|
32846
|
+
const providers = input.loaded.resolved.providers;
|
|
32847
|
+
if (!providers.source) return fail("source", "the config has no `source` provider to read and post the checks with");
|
|
32848
|
+
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
32849
|
+
const loader = input.loader ?? new PluginLoader({
|
|
32850
|
+
...input.loaded.resolved,
|
|
32851
|
+
providers: {
|
|
32852
|
+
source: providers.source,
|
|
32853
|
+
...providers.credentials ? { credentials: providers.credentials } : {}
|
|
32854
|
+
}
|
|
32855
|
+
}, input.context);
|
|
32856
|
+
/* v8 ignore stop */
|
|
32857
|
+
await loader.load();
|
|
32858
|
+
assertPluginsResolvable(loader, "reconcile ci");
|
|
32859
|
+
if (!loader.has("source")) {
|
|
32860
|
+
const failure = loader.loadFailures().find((f) => f.key === "source");
|
|
32861
|
+
return fail("source", `the \`source\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`);
|
|
32862
|
+
}
|
|
32863
|
+
const source = loader.get("source");
|
|
32864
|
+
const lacking = missingMethods(source);
|
|
32865
|
+
if (lacking.length > 0) return fail("source", `the \`${source.providerName}\` provider cannot ${lacking.join(", ")}`);
|
|
32866
|
+
const config = input.loaded.resolved;
|
|
32867
|
+
const tasksConfig = { tasks: config.tasks ?? [] };
|
|
32868
|
+
if (config.extraRequiredChecks) tasksConfig.extraRequiredChecks = config.extraRequiredChecks;
|
|
32869
|
+
const { expected, statuses } = aggregateChecks(tasksConfig);
|
|
32870
|
+
let pullRequests;
|
|
32871
|
+
try {
|
|
32872
|
+
if (input.pullRequest !== void 0) {
|
|
32873
|
+
if (!source.getPullRequest) return fail("pull requests", `the \`${source.providerName}\` provider cannot read a pull request`);
|
|
32874
|
+
pullRequests = [await source.getPullRequest(input.pullRequest)];
|
|
32875
|
+
} else {
|
|
32876
|
+
if (!source.listPullRequests) return fail("pull requests", `the \`${source.providerName}\` provider cannot list pull requests`);
|
|
32877
|
+
pullRequests = await source.listPullRequests("open");
|
|
32878
|
+
}
|
|
32879
|
+
} catch (error) {
|
|
32880
|
+
return fail("pull requests", describeError(error));
|
|
32881
|
+
}
|
|
32882
|
+
if (pullRequests.length === 0) {
|
|
32883
|
+
rows.push(row$5("pull requests", "skip", "no open pull requests"));
|
|
32884
|
+
return finish();
|
|
32885
|
+
}
|
|
32886
|
+
const api = {
|
|
32887
|
+
listCheckRuns: (sha) => source.listCheckRuns(sha),
|
|
32888
|
+
listCommitStatuses: (sha) => source.listCommitStatuses(sha),
|
|
32889
|
+
createCheckRun: (sha, name, write) => source.createCheckRun(sha, name, write),
|
|
32890
|
+
updateCheckRun: (id, write) => source.updateCheckRun(id, write)
|
|
32891
|
+
};
|
|
32892
|
+
const graceMs = (input.maxAgeMinutes ?? DEFAULT_MAX_AGE_MINUTES) * 6e4;
|
|
32893
|
+
for (const pr of pullRequests) {
|
|
32894
|
+
const id = `#${pr.number}`;
|
|
32895
|
+
if (pr.headSha === void 0) {
|
|
32896
|
+
rows.push(row$5(id, "skip", "the provider gave no head commit"));
|
|
32897
|
+
continue;
|
|
32898
|
+
}
|
|
32899
|
+
try {
|
|
32900
|
+
const out = await postAggregate({
|
|
32901
|
+
api,
|
|
32902
|
+
sha: pr.headSha,
|
|
32903
|
+
expected,
|
|
32904
|
+
statuses,
|
|
32905
|
+
now: now(),
|
|
32906
|
+
graceMs,
|
|
32907
|
+
dryRun,
|
|
32908
|
+
name: input.shadow ? AGGREGATE_SHADOW_CHECK_NAME : AGGREGATE_CHECK_NAME
|
|
32909
|
+
});
|
|
32910
|
+
const verdict = out.result.conclusion;
|
|
32911
|
+
if (out.action === "foreign") rows.push(row$5(id, "skip", "another app (the Actions job) already posts this check on the commit; left alone"));
|
|
32912
|
+
else if (out.action === "unchanged") rows.push(row$5(id, "ok", `up to date (${verdict})`));
|
|
32913
|
+
else if (out.stale) {
|
|
32914
|
+
const what = dryRun ? "would repair" : "repaired";
|
|
32915
|
+
rows.push(row$5(id, "fail", `${what}: the check was missing or wrong (now ${verdict}); a delivery was missed`));
|
|
32916
|
+
} else {
|
|
32917
|
+
const what = dryRun ? "would post" : "posted";
|
|
32918
|
+
rows.push(row$5(id, "ok", `${what} ${verdict} (still in flight)`));
|
|
32919
|
+
}
|
|
32920
|
+
} catch (error) {
|
|
32921
|
+
rows.push(row$5(id, "fail", describeError(error)));
|
|
32922
|
+
}
|
|
32923
|
+
}
|
|
32924
|
+
return finish();
|
|
32925
|
+
}
|
|
32926
|
+
// src/commands/reconcile-ci/reconcile-ci.command.ts
|
|
32927
|
+
const reconcileCiCommand = {
|
|
32928
|
+
command: "ci [pull-request]",
|
|
32929
|
+
describe: "Make the ci / Required checks check say what the checks on each open pull request call for (the manual path and the sweep)",
|
|
32930
|
+
builder: (y) => y.positional("pull-request", {
|
|
32931
|
+
type: "number",
|
|
32932
|
+
describe: "Reconcile only this pull request (default: every open one)"
|
|
32933
|
+
}).option("shadow", {
|
|
32934
|
+
type: "boolean",
|
|
32935
|
+
describe: "Repair Sentinel's shadow check (ci / Required checks (sentinel)) instead of the real one; the only way to post while ci.aggregate is actions"
|
|
32936
|
+
}).option("max-age", {
|
|
32937
|
+
type: "number",
|
|
32938
|
+
describe: "Minutes a missing or unfinished aggregate may wait before it counts as a missed delivery and fails the run (default 10)"
|
|
32939
|
+
}),
|
|
32940
|
+
handler: async (argv) => {
|
|
32941
|
+
const tokens = tokenContext(argv.token);
|
|
32942
|
+
if (!tokens) return;
|
|
32943
|
+
const loaded = await loadConfig(argv.cwd);
|
|
32944
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
32945
|
+
if ((await runReconcileCi({
|
|
32946
|
+
loaded,
|
|
32947
|
+
context: {
|
|
32948
|
+
repoRoot: argv.cwd,
|
|
32949
|
+
dryRun: argv.dryRun,
|
|
32950
|
+
...tokens,
|
|
32951
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
32952
|
+
},
|
|
32953
|
+
...argv["pull-request"] !== void 0 ? { pullRequest: Number(argv["pull-request"]) } : {},
|
|
32954
|
+
...argv["max-age"] !== void 0 ? { maxAgeMinutes: Number(argv["max-age"]) } : {},
|
|
32955
|
+
...argv.shadow ? { shadow: true } : {}
|
|
32956
|
+
})).status === "fail") process.exitCode = 1;
|
|
32957
|
+
}
|
|
32958
|
+
};
|
|
32493
32959
|
// src/commands/reconcile/reconcile.command.ts
|
|
32494
32960
|
const reconcileCommand = {
|
|
32495
32961
|
command: "reconcile",
|
|
32496
|
-
describe: "Set project board item statuses where a rule says so",
|
|
32497
|
-
builder: (y) => y.command(projectReconcileCommand).command(groupMenu("reconcile")),
|
|
32962
|
+
describe: "Set project board item statuses where a rule says so, or bring the ci check up to date",
|
|
32963
|
+
builder: (y) => y.command(projectReconcileCommand).command(reconcileCiCommand).command(groupMenu("reconcile")),
|
|
32964
|
+
handler: () => {}
|
|
32965
|
+
};
|
|
32966
|
+
// src/commands/sync-issues/parse-since/parse-since.ts
|
|
32967
|
+
const UNITS = {
|
|
32968
|
+
m: 6e4,
|
|
32969
|
+
h: 36e5,
|
|
32970
|
+
d: 864e5,
|
|
32971
|
+
w: 6048e5
|
|
32972
|
+
};
|
|
32973
|
+
/**
|
|
32974
|
+
* Turns the `--since` value into an ISO timestamp: a date or date and time (`2026-03-01`, `2026-03-01T09:00:00Z`) or a
|
|
32975
|
+
* span back from `now` (`30m`, `12h`, `7d`, `2w`). Anything else is a `ConfigError`, so a typo never reads as "all".
|
|
32976
|
+
*/
|
|
32977
|
+
function parseSince(value, now = Date.now()) {
|
|
32978
|
+
const span = /^(\d+)([mhdw])$/.exec(value.trim());
|
|
32979
|
+
if (span) return new Date(now - Number(span[1]) * UNITS[span[2]]).toISOString();
|
|
32980
|
+
const at = Date.parse(value);
|
|
32981
|
+
if (Number.isNaN(at)) throw new ConfigError(`sync issues: --since "${value}" is not a date or a span like 30m, 12h, 7d or 2w`);
|
|
32982
|
+
return new Date(at).toISOString();
|
|
32983
|
+
}
|
|
32984
|
+
// src/commands/redeliver-webhooks/run-redeliver-webhooks/run-redeliver-webhooks.ts
|
|
32985
|
+
/**
|
|
32986
|
+
* `holocron redeliver webhooks [--since <time>] [--app <name>] [--dry-run] [--yes]` — the recovery step after a Sentinel
|
|
32987
|
+
* outage (spec `process-sentinel-posts-ci`, SPEC-0099, recovery 2).
|
|
32988
|
+
*
|
|
32989
|
+
* For each registered GitHub App instance it reads the App's webhook delivery log with the App's own JWT, keeps the
|
|
32990
|
+
* deliveries whose latest attempt did not succeed (`failedDeliveries()`), and asks GitHub to deliver each one again, oldest
|
|
32991
|
+
* first and once. It repairs every Sentinel handler (the `#prs` feed, board status, role sync, the checks, the `ci`
|
|
32992
|
+
* aggregate), not only the aggregate, and replaying is safe because each handler recomputes from the API. It never
|
|
32993
|
+
* reaches a delivery that was never attempted, and GitHub keeps the log only for a limited time.
|
|
32994
|
+
*
|
|
32995
|
+
* The App's id and key are read in memory from its vault environment, as `doctor github-app` reads them, and never
|
|
32996
|
+
* printed. It asks once before redelivering unless `--yes`; without a terminal that is a `NonInteractiveError`, except on
|
|
32997
|
+
* `--dry-run`, which lists what it would redeliver and calls nothing that writes.
|
|
32998
|
+
*/
|
|
32999
|
+
const DEFAULT_SINCE = "1d";
|
|
33000
|
+
const defaultApi = {
|
|
33001
|
+
listAppDeliveries,
|
|
33002
|
+
redeliverAppDelivery
|
|
33003
|
+
};
|
|
33004
|
+
const row$4 = (id, status, detail) => ({
|
|
33005
|
+
id,
|
|
33006
|
+
title: id,
|
|
33007
|
+
status,
|
|
33008
|
+
detail,
|
|
33009
|
+
problems: []
|
|
33010
|
+
});
|
|
33011
|
+
/** Runs `holocron redeliver webhooks`; see the file's comment. */
|
|
33012
|
+
async function runRedeliverWebhooks(input) {
|
|
33013
|
+
/* v8 ignore next -- the console is only used outside tests, which inject `print` */
|
|
33014
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
33015
|
+
const logger = input.logger ?? getLogger();
|
|
33016
|
+
/* v8 ignore next -- the real GitHub calls are only used outside tests, which inject `api` */
|
|
33017
|
+
const api = input.api ?? defaultApi;
|
|
33018
|
+
const dryRun = Boolean(input.context.dryRun);
|
|
33019
|
+
const rows = [];
|
|
33020
|
+
const finish = () => {
|
|
33021
|
+
printCheckRows(rows, print);
|
|
33022
|
+
const summary = summariseChecks(rows);
|
|
33023
|
+
printCheckSummary(summary, print);
|
|
33024
|
+
const status = summary.fail > 0 ? "fail" : "ok";
|
|
33025
|
+
logger.info({
|
|
33026
|
+
...summary,
|
|
33027
|
+
status
|
|
33028
|
+
}, "redeliver webhooks");
|
|
33029
|
+
return {
|
|
33030
|
+
status,
|
|
33031
|
+
rows
|
|
33032
|
+
};
|
|
33033
|
+
};
|
|
33034
|
+
const fail = (id, detail) => {
|
|
33035
|
+
rows.push(row$4(id, "fail", detail));
|
|
33036
|
+
return finish();
|
|
33037
|
+
};
|
|
33038
|
+
print(style.header(`Holocron redeliver webhooks${dryRun ? " (dry-run)" : ""}`));
|
|
33039
|
+
print("");
|
|
33040
|
+
let since;
|
|
33041
|
+
try {
|
|
33042
|
+
since = parseSince(input.since ?? DEFAULT_SINCE, (input.now ?? Date.now)());
|
|
33043
|
+
} catch (error) {
|
|
33044
|
+
return fail("since", describeError(error).replace(/^sync issues: /, ""));
|
|
33045
|
+
}
|
|
33046
|
+
const all = input.loaded.resolved.githubApps ?? [];
|
|
33047
|
+
if (all.length === 0) {
|
|
33048
|
+
rows.push(row$4("github-app", "skip", "no `githubApps` are declared in holocron.config.ts"));
|
|
33049
|
+
return finish();
|
|
33050
|
+
}
|
|
33051
|
+
const instances = input.app === void 0 ? all : all.filter((instance) => instance.name === input.app);
|
|
33052
|
+
if (instances.length === 0) return fail("app", `no \`githubApps\` entry is named "${input.app}" (${all.map((i) => i.name).join(", ")})`);
|
|
33053
|
+
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
33054
|
+
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
33055
|
+
/* v8 ignore stop */
|
|
33056
|
+
await loader.load();
|
|
33057
|
+
assertPluginsResolvable(loader, "redeliver webhooks");
|
|
33058
|
+
const pending = [];
|
|
33059
|
+
for (const instance of instances) {
|
|
33060
|
+
const read = await readAppCredentials(instance, loader);
|
|
33061
|
+
if ("reason" in read) {
|
|
33062
|
+
rows.push(row$4(`${instance.name}`, "skip", read.reason));
|
|
33063
|
+
continue;
|
|
33064
|
+
}
|
|
33065
|
+
try {
|
|
33066
|
+
const failed = failedDeliveries(await api.listAppDeliveries(read.creds, { since }));
|
|
33067
|
+
if (failed.length === 0) rows.push(row$4(instance.name, "ok", `no failed deliveries since ${since}`));
|
|
33068
|
+
for (const delivery of failed) pending.push({
|
|
33069
|
+
app: instance.name,
|
|
33070
|
+
creds: read.creds,
|
|
33071
|
+
delivery
|
|
33072
|
+
});
|
|
33073
|
+
} catch (error) {
|
|
33074
|
+
rows.push(row$4(instance.name, "fail", `cannot read the delivery log: ${scrubbed$1(error, [read.creds.privateKey])}`));
|
|
33075
|
+
}
|
|
33076
|
+
}
|
|
33077
|
+
if (pending.length === 0) return finish();
|
|
33078
|
+
const label = ({ app, delivery }) => {
|
|
33079
|
+
const what = delivery.action === null ? delivery.event : `${delivery.event}.${delivery.action}`;
|
|
33080
|
+
return {
|
|
33081
|
+
id: `${app}:${delivery.id}`,
|
|
33082
|
+
text: `${what} of ${delivery.deliveredAt} (${delivery.status || `status ${delivery.statusCode}`})`
|
|
33083
|
+
};
|
|
33084
|
+
};
|
|
33085
|
+
if (dryRun) {
|
|
33086
|
+
for (const item of pending) rows.push(row$4(label(item).id, "skip", `would redeliver ${label(item).text}`));
|
|
33087
|
+
return finish();
|
|
33088
|
+
}
|
|
33089
|
+
/* v8 ignore next -- the terminal is only asked outside tests, which inject `interactive` */
|
|
33090
|
+
const interactive = input.interactive ?? Boolean(process.stdin.isTTY);
|
|
33091
|
+
if (!input.yes && !interactive) throw new NonInteractiveError("`redeliver webhooks` asks GitHub to deliver webhooks again; pass --yes to run it without asking, or --dry-run to preview");
|
|
33092
|
+
/* v8 ignore next -- inquirer only runs outside tests, which inject `confirm` */
|
|
33093
|
+
const ask = input.confirm ?? ((message) => confirm({
|
|
33094
|
+
message,
|
|
33095
|
+
default: false
|
|
33096
|
+
}));
|
|
33097
|
+
if (!input.yes && !await ask(`Redeliver ${pending.length} failed webhook deliver${pending.length === 1 ? "y" : "ies"}?`)) {
|
|
33098
|
+
rows.push(row$4("redeliver", "skip", "not confirmed; nothing was redelivered"));
|
|
33099
|
+
return finish();
|
|
33100
|
+
}
|
|
33101
|
+
for (const item of pending) {
|
|
33102
|
+
const { id, text } = label(item);
|
|
33103
|
+
try {
|
|
33104
|
+
await api.redeliverAppDelivery(item.creds, item.delivery.id);
|
|
33105
|
+
rows.push(row$4(id, "ok", `redelivered ${text}`));
|
|
33106
|
+
} catch (error) {
|
|
33107
|
+
rows.push(row$4(id, "fail", scrubbed$1(error, [item.creds.privateKey])));
|
|
33108
|
+
}
|
|
33109
|
+
}
|
|
33110
|
+
return finish();
|
|
33111
|
+
}
|
|
33112
|
+
// src/commands/redeliver-webhooks/redeliver-webhooks.command.ts
|
|
33113
|
+
const redeliverWebhooksCommand = {
|
|
33114
|
+
command: "webhooks",
|
|
33115
|
+
describe: "Ask GitHub to deliver again the webhooks each registered App's endpoint did not accept (the recovery step after a Sentinel outage)",
|
|
33116
|
+
builder: (y) => y.option("since", {
|
|
33117
|
+
type: "string",
|
|
33118
|
+
describe: "How far back to look: a span (30m, 12h, 7d, 2w) or a date (default 1d)"
|
|
33119
|
+
}).option("app", {
|
|
33120
|
+
type: "string",
|
|
33121
|
+
describe: "Only this githubApps instance, by name"
|
|
33122
|
+
}).option("yes", {
|
|
33123
|
+
type: "boolean",
|
|
33124
|
+
describe: "Redeliver without asking (required without a terminal)"
|
|
33125
|
+
}),
|
|
33126
|
+
handler: async (argv) => {
|
|
33127
|
+
const tokens = tokenContext(argv.token);
|
|
33128
|
+
if (!tokens) return;
|
|
33129
|
+
const loaded = await loadConfig(argv.cwd);
|
|
33130
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
33131
|
+
if ((await runRedeliverWebhooks({
|
|
33132
|
+
loaded,
|
|
33133
|
+
context: {
|
|
33134
|
+
repoRoot: argv.cwd,
|
|
33135
|
+
dryRun: argv.dryRun,
|
|
33136
|
+
...tokens,
|
|
33137
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
33138
|
+
},
|
|
33139
|
+
...argv.since !== void 0 ? { since: String(argv.since) } : {},
|
|
33140
|
+
...argv.app !== void 0 ? { app: String(argv.app) } : {},
|
|
33141
|
+
...argv.yes ? { yes: true } : {}
|
|
33142
|
+
})).status === "fail") process.exitCode = 1;
|
|
33143
|
+
}
|
|
33144
|
+
};
|
|
33145
|
+
// src/commands/redeliver/redeliver.command.ts
|
|
33146
|
+
const redeliverCommand = {
|
|
33147
|
+
command: "redeliver",
|
|
33148
|
+
describe: "Deliver again what a GitHub App's endpoint did not accept",
|
|
33149
|
+
builder: (y) => y.command(redeliverWebhooksCommand).command(groupMenu("redeliver")),
|
|
32498
33150
|
handler: () => {}
|
|
32499
33151
|
};
|
|
32500
33152
|
// src/commands/auth/auth-unset.args.ts
|
|
@@ -34165,24 +34817,6 @@ const syncGithubCommand = {
|
|
|
34165
34817
|
})).status === "fail") process.exitCode = 1;
|
|
34166
34818
|
}
|
|
34167
34819
|
};
|
|
34168
|
-
// src/commands/sync-issues/parse-since/parse-since.ts
|
|
34169
|
-
const UNITS = {
|
|
34170
|
-
m: 6e4,
|
|
34171
|
-
h: 36e5,
|
|
34172
|
-
d: 864e5,
|
|
34173
|
-
w: 6048e5
|
|
34174
|
-
};
|
|
34175
|
-
/**
|
|
34176
|
-
* Turns the `--since` value into an ISO timestamp: a date or date and time (`2026-03-01`, `2026-03-01T09:00:00Z`) or a
|
|
34177
|
-
* span back from `now` (`30m`, `12h`, `7d`, `2w`). Anything else is a `ConfigError`, so a typo never reads as "all".
|
|
34178
|
-
*/
|
|
34179
|
-
function parseSince(value, now = Date.now()) {
|
|
34180
|
-
const span = /^(\d+)([mhdw])$/.exec(value.trim());
|
|
34181
|
-
if (span) return new Date(now - Number(span[1]) * UNITS[span[2]]).toISOString();
|
|
34182
|
-
const at = Date.parse(value);
|
|
34183
|
-
if (Number.isNaN(at)) throw new ConfigError(`sync issues: --since "${value}" is not a date or a span like 30m, 12h, 7d or 2w`);
|
|
34184
|
-
return new Date(at).toISOString();
|
|
34185
|
-
}
|
|
34186
34820
|
// src/commands/sync-issues/assignees-location/assignees-location.ts
|
|
34187
34821
|
/** Where the assignees file is: the org's private config repo, as the Discord links file is. */
|
|
34188
34822
|
function assigneesLocation(org) {
|
|
@@ -36618,6 +37252,7 @@ const COMMAND_MODULES = [
|
|
|
36618
37252
|
deployCommand,
|
|
36619
37253
|
resolveCommand,
|
|
36620
37254
|
reconcileCommand,
|
|
37255
|
+
redeliverCommand,
|
|
36621
37256
|
projectCommand
|
|
36622
37257
|
];
|
|
36623
37258
|
// src/cli/own-package-json.ts
|