@theholocron/cli 5.0.0-alpha.451 → 5.0.0-alpha.453
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 +15 -4
- package/dist/cli.mjs +841 -203
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-CAYb1d4M.mjs → config-system-BcdB9khh.mjs} +28 -3
- package/dist/{index-DMoGsKv2.d.mts → index-DVz1kZw5.d.mts} +155 -12
- package/dist/index.d.mts +10 -2
- package/dist/index.mjs +19 -2
- package/dist/plugin/capabilities.d.mts +2 -2
- package/dist/presets.d.mts +3 -3
- package/dist/presets.mjs +6 -6
- package/package.json +11 -11
package/dist/cli.mjs
CHANGED
|
@@ -13,10 +13,10 @@ import { hideBin } from "yargs/helpers";
|
|
|
13
13
|
import { DRY_RUN_NOOP_EXIT_CODE, createCommandRegistry, createMenu, numeric } from "@theholocron/kyber/menu";
|
|
14
14
|
import { Entry, findCredentials } from "@napi-rs/keyring";
|
|
15
15
|
import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver as createFeatureResolver$1, createKeyring, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue as resolveValue$1, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
|
|
16
|
-
import { DEFAULT_ORG, 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, createAlexignore, createAlexrc, createAstromech, createCommitMsg, createDco, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, frozenReusablePaths, generateThinCallerContent, hostedReusableWorkflows, isDeprecated, isTask, legacyCaller, legacyCallerFile, legacyGate, legacyWorkflowKey, localize, localizeActions, mergeScripts, readWorkspacePackages, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, workflowFile, workflowKey, workflowKeys, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
|
|
16
|
+
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, codecovFlagNames, createAlexignore, createAlexrc, createAstromech, createCommitMsg, createDco, 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, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, workflowFile, workflowKey, workflowKeys, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
|
|
17
17
|
import { loadTasksConfig } from "@theholocron/astromech/config";
|
|
18
18
|
import { ConfigError, ConfigError as ConfigError$1, createConfigSystem, lastWins, mergeByKey, shallowMerge, union } from "@theholocron/kyber/config";
|
|
19
|
-
import { LoaderError, assertPluginsResolvable as assertPluginsResolvable$1, createPluginSystem, isModuleNotFound, resolvePluginPackage as resolvePluginPackage$1 } from "@theholocron/kyber/plugins";
|
|
19
|
+
import { LoaderError, assertPluginsResolvable as assertPluginsResolvable$1, createPluginSystem, defaultImporter as defaultImporter$1, isModuleNotFound, isModuleNotFound as isModuleNotFound$1, resolvePluginPackage as resolvePluginPackage$1 } from "@theholocron/kyber/plugins";
|
|
20
20
|
import { readGitRemote, updateGitignore, upsertManagedBlock } from "@theholocron/git-utils";
|
|
21
21
|
import { bumpCatalogPins, discoverWorkspacePackages, parseCatalogs, readPackageJson, readPackageJsonSync, resolveWorkspaceGlobs } from "@theholocron/pkg-utils";
|
|
22
22
|
import { createCliLogger, createCliTelemetry } from "@theholocron/kyber/observability";
|
|
@@ -28,7 +28,7 @@ import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
|
28
28
|
import { promptForPositionals } from "@theholocron/kyber/prompts";
|
|
29
29
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
30
30
|
import { errorMessage } from "@theholocron/misc-utils";
|
|
31
|
-
import { copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
31
|
+
import { appendFileSync, copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
32
32
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
33
33
|
import { stringifyJson } from "@theholocron/json-utils";
|
|
34
34
|
import { findRootSync, isWorkspaceRoot, walkFilesSync } from "@theholocron/fs-utils";
|
|
@@ -1151,6 +1151,20 @@ const registry = createCommandRegistry([
|
|
|
1151
1151
|
],
|
|
1152
1152
|
supportsDryRun: true
|
|
1153
1153
|
},
|
|
1154
|
+
{
|
|
1155
|
+
name: "upload coverage",
|
|
1156
|
+
description: "Upload the repo's coverage reports, one flag per group, through the coverage provider",
|
|
1157
|
+
positionals: [],
|
|
1158
|
+
options: [{
|
|
1159
|
+
key: "uploads",
|
|
1160
|
+
flag: "--uploads",
|
|
1161
|
+
type: "input",
|
|
1162
|
+
required: true,
|
|
1163
|
+
message: "Uploads, a JSON list of {\"flag\", \"files\"}:"
|
|
1164
|
+
}],
|
|
1165
|
+
skipOptions: ["allow-empty"],
|
|
1166
|
+
supportsDryRun: true
|
|
1167
|
+
},
|
|
1154
1168
|
githubAppCreateEntry,
|
|
1155
1169
|
{
|
|
1156
1170
|
name: "new tunnel",
|
|
@@ -1433,6 +1447,29 @@ var MissingTokenError = class extends Error {
|
|
|
1433
1447
|
/** Lets a caller tell this error from any other by name, across package copies. */
|
|
1434
1448
|
name = "MissingTokenError";
|
|
1435
1449
|
};
|
|
1450
|
+
// src/config/split-agent/split-agent.ts
|
|
1451
|
+
const AGENT_OPTIONS = ["dcg"];
|
|
1452
|
+
/**
|
|
1453
|
+
* Reads `agent` in either form, a name (`"claude"`) or a name with options (`["claude", { dcg: true }]`), the form a
|
|
1454
|
+
* provider takes. The name keeps its place in the resolved config, so everything that installs skills reads it as before;
|
|
1455
|
+
* the options, when there are any, are kept beside it. A malformed value, an option that does not exist, a `dcg` that is
|
|
1456
|
+
* not a boolean, and `dcg: true` on an agent that has no `.claude/settings.json` are a `ConfigError` naming the problem.
|
|
1457
|
+
*/
|
|
1458
|
+
function splitAgent(raw) {
|
|
1459
|
+
if (raw === void 0) return {};
|
|
1460
|
+
if (typeof raw === "string") return { agent: raw };
|
|
1461
|
+
if (!Array.isArray(raw) || typeof raw[0] !== "string" || raw.length > 2) throw new ConfigError$1("`agent` must be a name, or a name with its options: \"claude\" or [\"claude\", { dcg: true }]");
|
|
1462
|
+
const [agent, options] = raw;
|
|
1463
|
+
if (options === void 0) return { agent };
|
|
1464
|
+
if (typeof options !== "object" || options === null || Array.isArray(options)) throw new ConfigError$1(`the options of the \`${agent}\` agent must be an object, like { dcg: true }`);
|
|
1465
|
+
for (const key of Object.keys(options)) if (!AGENT_OPTIONS.includes(key)) throw new ConfigError$1(`the \`${agent}\` agent has no option \`${key}\` (the options are: ${AGENT_OPTIONS.join(", ")})`);
|
|
1466
|
+
if (options.dcg !== void 0 && typeof options.dcg !== "boolean") throw new ConfigError$1(`the \`dcg\` option of the \`${agent}\` agent must be true or false`);
|
|
1467
|
+
if (options.dcg === true && agent !== "claude") throw new ConfigError$1(`\`dcg\` wires a hook into .claude/settings.json, so it is an option of "claude", not "${agent}"`);
|
|
1468
|
+
return {
|
|
1469
|
+
agent,
|
|
1470
|
+
agentOptions: options
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1436
1473
|
// src/credentials-environments/layer-environment/layer-environment.ts
|
|
1437
1474
|
/** The layer words, in the order the docs list them. */
|
|
1438
1475
|
const ENVIRONMENT_LAYERS = [
|
|
@@ -1772,6 +1809,7 @@ function resolveConfig(raw) {
|
|
|
1772
1809
|
if (credentialsEnvironment(tuple, raw) === void 0 && !derivesEnvironment(tuple.provider)) throw new ConfigError(`the \`${tuple.provider}\` credentials provider has no environment to read: give it an \`environment\` option or set \`credentials.environment\``);
|
|
1773
1810
|
}
|
|
1774
1811
|
const homepage = raw.homepage ?? (docs?.domain ? `https://${docs.domain}/` : void 0);
|
|
1812
|
+
const { agent, agentOptions } = splitAgent(raw.agent);
|
|
1775
1813
|
return {
|
|
1776
1814
|
name: raw.name,
|
|
1777
1815
|
description: raw.description,
|
|
@@ -1788,7 +1826,8 @@ function resolveConfig(raw) {
|
|
|
1788
1826
|
providers,
|
|
1789
1827
|
apps: raw.apps ?? [],
|
|
1790
1828
|
doctor: raw.doctor ?? {},
|
|
1791
|
-
agent
|
|
1829
|
+
agent,
|
|
1830
|
+
...agentOptions ? { agentOptions } : {},
|
|
1792
1831
|
skills: raw.skills,
|
|
1793
1832
|
docs,
|
|
1794
1833
|
env: raw.env,
|
|
@@ -1990,25 +2029,25 @@ function placeNotifications(raw, area) {
|
|
|
1990
2029
|
// src/config/load-config/place-org/place-org.ts
|
|
1991
2030
|
/** The options each provider key of `.holocron/org.*` may hold. Checked against `OrgConfig` by the type. */
|
|
1992
2031
|
const ORG_OPTIONS = {
|
|
1993
|
-
cloudflare: ["accountId"],
|
|
2032
|
+
cloudflare: ["accountId", "zone"],
|
|
1994
2033
|
vercel: ["teamId"],
|
|
1995
2034
|
checkly: ["accountId"],
|
|
1996
2035
|
sentry: ["org"]
|
|
1997
2036
|
};
|
|
1998
|
-
const isObject$
|
|
1999
|
-
const isTuple = (entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && isObject$
|
|
2037
|
+
const isObject$2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2038
|
+
const isTuple = (entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && isObject$2(entry[1]);
|
|
2000
2039
|
/**
|
|
2001
2040
|
* Check the shape of the area file: the top-level `domain` (a non-empty string), then a closed list of providers,
|
|
2002
2041
|
* each with a closed list of string options.
|
|
2003
2042
|
*/
|
|
2004
2043
|
function validate(area) {
|
|
2005
|
-
if (!isObject$
|
|
2044
|
+
if (!isObject$2(area.value)) throw new ConfigError$1(`${area.path} must export the org settings as an object`);
|
|
2006
2045
|
const { domain, ...rest } = area.value;
|
|
2007
2046
|
if (domain !== void 0 && (typeof domain !== "string" || domain === "")) throw new ConfigError$1(`${area.path}: "domain" must be a non-empty string`);
|
|
2008
2047
|
for (const [provider, options] of Object.entries(rest)) {
|
|
2009
2048
|
const allowed = ORG_OPTIONS[provider];
|
|
2010
2049
|
if (allowed === void 0) throw new ConfigError$1(`${area.path} has an unknown provider "${provider}". Known: ${Object.keys(ORG_OPTIONS).join(", ")}`);
|
|
2011
|
-
if (!isObject$
|
|
2050
|
+
if (!isObject$2(options)) throw new ConfigError$1(`${area.path}: "${provider}" must be an object of options`);
|
|
2012
2051
|
for (const [option, value] of Object.entries(options)) {
|
|
2013
2052
|
if (!allowed.includes(option)) throw new ConfigError$1(`${area.path}: "${provider}.${option}" is not an org option. Known: ${allowed.join(", ")}`);
|
|
2014
2053
|
if (typeof value !== "string" || value === "") throw new ConfigError$1(`${area.path}: "${provider}.${option}" must be a non-empty string`);
|
|
@@ -2327,6 +2366,7 @@ const COMMAND_CONTEXTS = {
|
|
|
2327
2366
|
"list tokens": "global",
|
|
2328
2367
|
"export tokens": "workspace",
|
|
2329
2368
|
"export requests": "workspace",
|
|
2369
|
+
"upload coverage": "workspace",
|
|
2330
2370
|
"new github-app": "global",
|
|
2331
2371
|
"check token": "global",
|
|
2332
2372
|
"publish bump-versions": "global",
|
|
@@ -2582,6 +2622,29 @@ function applyResolvedConfig(argv, resolved) {
|
|
|
2582
2622
|
function tokenContext(rawTokens) {
|
|
2583
2623
|
return tokenContext$1(rawTokens, reportError);
|
|
2584
2624
|
}
|
|
2625
|
+
// src/plugin/missing-plugin-hint/missing-plugin-hint.ts
|
|
2626
|
+
/**
|
|
2627
|
+
* The line that says how to get a plugin package that does not resolve: add it to the `holocron` catalog of
|
|
2628
|
+
* `pnpm-workspace.yaml` (beside `@theholocron/holocron-plugin-github`, same version) and to the repo's
|
|
2629
|
+
* `devDependencies` as `catalog:holocron`, then install.
|
|
2630
|
+
*/
|
|
2631
|
+
function missingPluginHint(packageName) {
|
|
2632
|
+
return `To add it: list \`${packageName}\` under \`catalogs.holocron\` in pnpm-workspace.yaml (the version of \`@theholocron/holocron-plugin-github\`), add \`"${packageName}": "catalog:holocron"\` to devDependencies, then run \`pnpm install\`.`;
|
|
2633
|
+
}
|
|
2634
|
+
/**
|
|
2635
|
+
* An importer that behaves as `base` and, when the package itself is not installed, appends {@link missingPluginHint}
|
|
2636
|
+
* to the error. The original text stays first, so the loader's check for a missing package still recognises it.
|
|
2637
|
+
*/
|
|
2638
|
+
function hintingImporter(base = defaultImporter$1) {
|
|
2639
|
+
return async (packageName) => {
|
|
2640
|
+
try {
|
|
2641
|
+
return await base(packageName);
|
|
2642
|
+
} catch (err) {
|
|
2643
|
+
if (err instanceof Error && isModuleNotFound$1(err) && err.message.includes(packageName)) err.message = `${err.message}\n${missingPluginHint(packageName)}`;
|
|
2644
|
+
throw err;
|
|
2645
|
+
}
|
|
2646
|
+
};
|
|
2647
|
+
}
|
|
2585
2648
|
// src/plugin/workspace/workspace.ts
|
|
2586
2649
|
/**
|
|
2587
2650
|
* The `workspace`-context guard.
|
|
@@ -2661,6 +2724,7 @@ const system = createPluginSystem({
|
|
|
2661
2724
|
const effectiveToken = context.cliTokens?.[tuple.provider] ?? context.cliToken;
|
|
2662
2725
|
return {
|
|
2663
2726
|
...config.repo?.name ? { repo: config.repo.name } : {},
|
|
2727
|
+
...config.repoValidation?.docsCoverage ? { docsCoverage: config.repoValidation.docsCoverage } : {},
|
|
2664
2728
|
...context,
|
|
2665
2729
|
...effectiveToken !== void 0 ? { cliToken: effectiveToken } : {},
|
|
2666
2730
|
cliTokens: void 0,
|
|
@@ -2702,6 +2766,20 @@ const system = createPluginSystem({
|
|
|
2702
2766
|
});
|
|
2703
2767
|
/** The Holocron plugin loader: `new PluginLoader(config, context, importer?, options?)`, then `load()`, `get(key)`. */
|
|
2704
2768
|
var PluginLoader = class extends system.PluginLoader {
|
|
2769
|
+
extraProviders;
|
|
2770
|
+
constructor(config, context, importer, options) {
|
|
2771
|
+
super(config, context, hintingImporter(importer), options);
|
|
2772
|
+
this.extraProviders = options?.extraProviders ?? [];
|
|
2773
|
+
}
|
|
2774
|
+
/**
|
|
2775
|
+
* Loads the configured providers, then each of `options.extraProviders` by name with no capability slot, so a plugin
|
|
2776
|
+
* a workspace app configures (`vercel`, for Sentinel) is found for its probes and tokens although this config does not
|
|
2777
|
+
* name it. A provider that fails to load is left out, as one that is not installed is: `probes()` does not list it.
|
|
2778
|
+
*/
|
|
2779
|
+
async load() {
|
|
2780
|
+
await super.load();
|
|
2781
|
+
for (const tuple of this.extraProviders) await this.loadProvider(tuple).catch(() => void 0);
|
|
2782
|
+
}
|
|
2705
2783
|
/** The probes each loaded provider offers, by provider name. Empty for a provider that offers none. */
|
|
2706
2784
|
probes() {
|
|
2707
2785
|
const found = /* @__PURE__ */ new Map();
|
|
@@ -6836,7 +6914,7 @@ async function runDoctorDns(input) {
|
|
|
6836
6914
|
});
|
|
6837
6915
|
else if (!loader.has("dns")) {
|
|
6838
6916
|
const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
|
|
6839
|
-
for (const zone of zones) rows.push(row$
|
|
6917
|
+
for (const zone of zones) rows.push(row$16(zone, "skip", why));
|
|
6840
6918
|
for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
|
|
6841
6919
|
} else {
|
|
6842
6920
|
const dns = loader.get("dns");
|
|
@@ -6858,7 +6936,7 @@ async function runDoctorDns(input) {
|
|
|
6858
6936
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
6859
6937
|
};
|
|
6860
6938
|
}
|
|
6861
|
-
function row$
|
|
6939
|
+
function row$16(zone, status, detail, problems = []) {
|
|
6862
6940
|
return {
|
|
6863
6941
|
id: `dns-${zone}`,
|
|
6864
6942
|
title: `${zone} records exist`,
|
|
@@ -6887,7 +6965,7 @@ async function checkDomain(dns, deploy, project, hostname) {
|
|
|
6887
6965
|
return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
|
|
6888
6966
|
}
|
|
6889
6967
|
}
|
|
6890
|
-
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$
|
|
6968
|
+
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$16(zone, ...args)) {
|
|
6891
6969
|
try {
|
|
6892
6970
|
const have = await dns.listRecords(zone);
|
|
6893
6971
|
const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
|
|
@@ -7022,7 +7100,7 @@ function installationSettingsUrl(account, id) {
|
|
|
7022
7100
|
return `https://github.com/settings/installations/${id}`;
|
|
7023
7101
|
}
|
|
7024
7102
|
// src/commands/doctor-github-app/app-rows.ts
|
|
7025
|
-
const row$
|
|
7103
|
+
const row$15 = (name, what, problems, ok) => ({
|
|
7026
7104
|
id: `${name}:${what}`,
|
|
7027
7105
|
title: `${name}: ${what}`,
|
|
7028
7106
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -7049,9 +7127,9 @@ function appRows(name, manifest, app, installations) {
|
|
|
7049
7127
|
return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
|
|
7050
7128
|
});
|
|
7051
7129
|
return [
|
|
7052
|
-
row$
|
|
7053
|
-
row$
|
|
7054
|
-
row$
|
|
7130
|
+
row$15(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
|
|
7131
|
+
row$15(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
|
|
7132
|
+
row$15(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
|
|
7055
7133
|
];
|
|
7056
7134
|
}
|
|
7057
7135
|
// src/commands/doctor-github-app/parse-manifest.ts
|
|
@@ -7109,7 +7187,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
7109
7187
|
assertPluginsResolvable(loader, "doctor github-app");
|
|
7110
7188
|
}
|
|
7111
7189
|
const rows = [];
|
|
7112
|
-
if (instances.length === 0) rows.push(row$
|
|
7190
|
+
if (instances.length === 0) rows.push(row$14("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
|
|
7113
7191
|
for (const instance of instances) rows.push(...await checkInstance(instance, loader, input));
|
|
7114
7192
|
printCheckRows(rows, print);
|
|
7115
7193
|
const summary = summariseChecks(rows);
|
|
@@ -7126,7 +7204,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
7126
7204
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
7127
7205
|
};
|
|
7128
7206
|
}
|
|
7129
|
-
function row$
|
|
7207
|
+
function row$14(name, what, status, detail) {
|
|
7130
7208
|
return {
|
|
7131
7209
|
id: `${name}:${what}`,
|
|
7132
7210
|
title: `${name}: ${what}`,
|
|
@@ -7167,19 +7245,19 @@ async function checkInstance(instance, loader, input) {
|
|
|
7167
7245
|
try {
|
|
7168
7246
|
manifest = parseManifest(readManifest(instance.manifest));
|
|
7169
7247
|
} catch (err) {
|
|
7170
|
-
return [row$
|
|
7248
|
+
return [row$14(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
|
|
7171
7249
|
}
|
|
7172
7250
|
const read = await readCredentials(instance, loader);
|
|
7173
|
-
if ("reason" in read) return [row$
|
|
7251
|
+
if ("reason" in read) return [row$14(name, "reachable", "skip", read.reason)];
|
|
7174
7252
|
const api = input.api ?? defaultApi;
|
|
7175
7253
|
const secrets = [read.creds.privateKey];
|
|
7176
7254
|
try {
|
|
7177
7255
|
const app = await api.getApp(read.creds);
|
|
7178
7256
|
const installations = await api.listAppInstallations(read.creds);
|
|
7179
7257
|
const owner = app.owner ? `, owned by ${app.owner.login}` : "";
|
|
7180
|
-
return [row$
|
|
7258
|
+
return [row$14(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
|
|
7181
7259
|
} catch (err) {
|
|
7182
|
-
return [row$
|
|
7260
|
+
return [row$14(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
|
|
7183
7261
|
}
|
|
7184
7262
|
}
|
|
7185
7263
|
// src/commands/doctor-github-app/doctor-github-app.command.ts
|
|
@@ -7246,7 +7324,7 @@ function datasetTargets(config) {
|
|
|
7246
7324
|
* dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
|
|
7247
7325
|
* a name, a token or a response that cannot be read is a skip with the reason.
|
|
7248
7326
|
*/
|
|
7249
|
-
const row$
|
|
7327
|
+
const row$13 = (id, title, status, detail, problems = []) => ({
|
|
7250
7328
|
id,
|
|
7251
7329
|
title,
|
|
7252
7330
|
status,
|
|
@@ -7263,7 +7341,7 @@ async function runDoctorLogs(input) {
|
|
|
7263
7341
|
if (!loader.has("logs")) {
|
|
7264
7342
|
const failure = loader.loadFailures().find((f) => f.key === "logs");
|
|
7265
7343
|
const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
|
|
7266
|
-
rows.push(row$
|
|
7344
|
+
rows.push(row$13("logs", "logs", "skip", why));
|
|
7267
7345
|
} else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
|
|
7268
7346
|
printCheckRows(rows, print);
|
|
7269
7347
|
const summary = summariseChecks(rows);
|
|
@@ -7287,38 +7365,38 @@ async function checkLogs(logs, targets) {
|
|
|
7287
7365
|
for (const target of targets) {
|
|
7288
7366
|
const id = `logs:dataset:${target.id}`;
|
|
7289
7367
|
const title = `dataset for ${target.label}`;
|
|
7290
|
-
if (!target.name) rows.push(row$
|
|
7291
|
-
else if (!token.usable) rows.push(row$
|
|
7292
|
-
else if (!logs.readDataset) rows.push(row$
|
|
7368
|
+
if (!target.name) rows.push(row$13(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
|
|
7369
|
+
else if (!token.usable) rows.push(row$13(id, title, "skip", `${target.name}: not checked, the token is not usable`));
|
|
7370
|
+
else if (!logs.readDataset) rows.push(row$13(id, title, "skip", `${logs.providerName} cannot read a dataset`));
|
|
7293
7371
|
else rows.push(...await checkDataset(logs, target, target.name, id, title));
|
|
7294
7372
|
}
|
|
7295
7373
|
const org = resolveValue$1(["AXIOM_ORG"], void 0, { prefix: PREFIX$1 });
|
|
7296
|
-
rows.push(org ? row$
|
|
7374
|
+
rows.push(org ? row$13("logs:org", "organization", "ok", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$13("logs:org", "organization", "skip", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links and check-dispatched need it`));
|
|
7297
7375
|
return rows;
|
|
7298
7376
|
}
|
|
7299
7377
|
/** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
|
|
7300
7378
|
async function checkToken$1(logs) {
|
|
7301
7379
|
const title = "token is accepted";
|
|
7302
7380
|
if (!logs.checkToken) return {
|
|
7303
|
-
row: row$
|
|
7381
|
+
row: row$13("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
|
|
7304
7382
|
usable: true
|
|
7305
7383
|
};
|
|
7306
7384
|
try {
|
|
7307
7385
|
const result = await logs.checkToken();
|
|
7308
7386
|
if (result.ok) return {
|
|
7309
|
-
row: row$
|
|
7387
|
+
row: row$13("logs:token", title, "ok", `${logs.providerName} accepts the token`),
|
|
7310
7388
|
usable: true
|
|
7311
7389
|
};
|
|
7312
7390
|
const reason = result.reason ?? `${logs.providerName} refused the token`;
|
|
7313
7391
|
return {
|
|
7314
|
-
row: row$
|
|
7392
|
+
row: row$13("logs:token", title, "fail", reason, [reason]),
|
|
7315
7393
|
usable: false
|
|
7316
7394
|
};
|
|
7317
7395
|
} catch (err) {
|
|
7318
7396
|
const noToken = missingTokenReason(err);
|
|
7319
7397
|
const detail = noToken ?? `could not check the token: ${describeError(err)}`;
|
|
7320
7398
|
return {
|
|
7321
|
-
row: row$
|
|
7399
|
+
row: row$13("logs:token", title, "skip", detail),
|
|
7322
7400
|
usable: noToken === void 0
|
|
7323
7401
|
};
|
|
7324
7402
|
}
|
|
@@ -7328,13 +7406,13 @@ async function checkDataset(logs, target, name, id, title) {
|
|
|
7328
7406
|
const found = await logs.readDataset(name);
|
|
7329
7407
|
if (!found.exists) {
|
|
7330
7408
|
const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
|
|
7331
|
-
return [row$
|
|
7409
|
+
return [row$13(id, title, "fail", `${name} does not exist`, [problem])];
|
|
7332
7410
|
}
|
|
7333
7411
|
const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
|
|
7334
|
-
return [row$
|
|
7412
|
+
return [row$13(id, title, "ok", `${name} exists`), row$13(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
|
|
7335
7413
|
} catch (err) {
|
|
7336
7414
|
const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
|
|
7337
|
-
return [row$
|
|
7415
|
+
return [row$13(id, title, "skip", detail)];
|
|
7338
7416
|
}
|
|
7339
7417
|
}
|
|
7340
7418
|
// src/commands/doctor-logs/doctor-logs.command.ts
|
|
@@ -10276,7 +10354,7 @@ const info = (id, title, noun, extras) => ({
|
|
|
10276
10354
|
detail: `info: ${extras.length} ${noun} not in the template (never deleted)`,
|
|
10277
10355
|
problems: extras
|
|
10278
10356
|
});
|
|
10279
|
-
const row$
|
|
10357
|
+
const row$12 = (id, title, problems, ok) => ({
|
|
10280
10358
|
id,
|
|
10281
10359
|
title,
|
|
10282
10360
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -10312,19 +10390,19 @@ function viewProblems(want, found) {
|
|
|
10312
10390
|
function boardRows(boardName, template, state) {
|
|
10313
10391
|
const id = `project:${boardName}`;
|
|
10314
10392
|
const rows = [];
|
|
10315
|
-
rows.push(row$
|
|
10393
|
+
rows.push(row$12(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
|
|
10316
10394
|
const extraStatuses = state.statuses.filter((s) => !template.statuses.some((t) => t.name === s));
|
|
10317
10395
|
if (extraStatuses.length > 0) rows.push(info(`${id}:extra-statuses`, `${boardName}: extra statuses`, "status(es)", extraStatuses));
|
|
10318
|
-
for (const want of template.fields) rows.push(row$
|
|
10396
|
+
for (const want of template.fields) rows.push(row$12(`${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));
|
|
10319
10397
|
const extraFields = state.fields.filter((f) => !template.fields.some((t) => t.name === f.name));
|
|
10320
10398
|
if (extraFields.length > 0) rows.push(info(`${id}:extra-fields`, `${boardName}: extra fields`, "field(s)", extraFields.map((f) => f.name)));
|
|
10321
|
-
for (const want of template.views) rows.push(row$
|
|
10399
|
+
for (const want of template.views) rows.push(row$12(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
|
|
10322
10400
|
const extraViews = state.views.filter((v) => !template.views.some((t) => t.name === v.name));
|
|
10323
10401
|
if (extraViews.length > 0) rows.push(info(`${id}:extra-views`, `${boardName}: extra views`, "view(s)", extraViews.map((v) => v.name)));
|
|
10324
10402
|
for (const name of template.rules ?? []) {
|
|
10325
10403
|
const found = state.rules.find((r) => r.name === name);
|
|
10326
10404
|
const problems = !found ? [`missing rule ${name}`] : found.enabled ? [] : [`rule ${name} is off`];
|
|
10327
|
-
rows.push(row$
|
|
10405
|
+
rows.push(row$12(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
|
|
10328
10406
|
}
|
|
10329
10407
|
return rows;
|
|
10330
10408
|
}
|
|
@@ -10384,7 +10462,7 @@ function itemRows(boardName, items) {
|
|
|
10384
10462
|
* never fail the run. A template file that does not read is a failure naming the file. `--post [channel]` shares the
|
|
10385
10463
|
* failing rows through the `notifications` provider's bot, like `doctor notifications --post`.
|
|
10386
10464
|
*/
|
|
10387
|
-
const row$
|
|
10465
|
+
const row$11 = (id, title, status, detail, problems = []) => ({
|
|
10388
10466
|
id,
|
|
10389
10467
|
title,
|
|
10390
10468
|
status,
|
|
@@ -10438,14 +10516,14 @@ async function checkBoards(input, loader) {
|
|
|
10438
10516
|
loader,
|
|
10439
10517
|
...input.io ? { io: input.io } : {}
|
|
10440
10518
|
});
|
|
10441
|
-
if (!opened.ok) return [row$
|
|
10519
|
+
if (!opened.ok) return [row$11("project", "project", opened.kind, opened.reason, opened.problems)];
|
|
10442
10520
|
const { projects, owner, boards, templates, templateProblems } = opened.context;
|
|
10443
10521
|
const rows = templateProblems.map((problem) => {
|
|
10444
10522
|
/* v8 ignore next -- split always returns at least one element; the fallback only satisfies noUncheckedIndexedAccess */
|
|
10445
10523
|
const file = problem.split(": ")[0] ?? problem;
|
|
10446
|
-
return row$
|
|
10524
|
+
return row$11(`project:template:${file}`, `template file ${file}`, "fail", problem);
|
|
10447
10525
|
});
|
|
10448
|
-
if (boards.length === 0) return [...rows, row$
|
|
10526
|
+
if (boards.length === 0) return [...rows, row$11("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
|
|
10449
10527
|
for (const declared of boards) {
|
|
10450
10528
|
const template = templates[declared.template];
|
|
10451
10529
|
const title = `${declared.name}: board exists and is open`;
|
|
@@ -10453,18 +10531,18 @@ async function checkBoards(input, loader) {
|
|
|
10453
10531
|
const board = await projects.find(owner, declared.name);
|
|
10454
10532
|
if (!board) {
|
|
10455
10533
|
const closed = (await projects.list(owner)).some((b) => b.name === declared.name && b.closed);
|
|
10456
|
-
rows.push(row$
|
|
10534
|
+
rows.push(row$11(`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`"]));
|
|
10457
10535
|
continue;
|
|
10458
10536
|
}
|
|
10459
|
-
rows.push(row$
|
|
10537
|
+
rows.push(row$11(`project:${declared.name}`, title, "ok", board.url));
|
|
10460
10538
|
if (!template) {
|
|
10461
|
-
rows.push(row$
|
|
10539
|
+
rows.push(row$11(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
|
|
10462
10540
|
continue;
|
|
10463
10541
|
}
|
|
10464
10542
|
rows.push(...boardRows(declared.name, template, await projects.read(owner, board)));
|
|
10465
|
-
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$
|
|
10543
|
+
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$11(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
|
|
10466
10544
|
} catch (err) {
|
|
10467
|
-
rows.push(row$
|
|
10545
|
+
rows.push(row$11(`project:${declared.name}`, title, "fail", describeError(err)));
|
|
10468
10546
|
}
|
|
10469
10547
|
}
|
|
10470
10548
|
return rows;
|
|
@@ -10494,6 +10572,39 @@ const doctorProjectCommand = {
|
|
|
10494
10572
|
})).status === "fail") process.exitCode = 1;
|
|
10495
10573
|
}
|
|
10496
10574
|
};
|
|
10575
|
+
// src/commands/coverage-expectations/coverage-expectations.ts
|
|
10576
|
+
/**
|
|
10577
|
+
* The flags and components `holocron sync` writes to `codecov.yml` for the workspace at `repoRoot`: the same
|
|
10578
|
+
* functions the generator uses, so a coverage provider's `checkRepo()` compares with exactly what is written. A flag per
|
|
10579
|
+
* package (none for `docs`), plus `documentation` when `docsCoverage` is `warn` or `required`; a component per package.
|
|
10580
|
+
* Both lists are sorted. Plugins call this instead of importing the task runner.
|
|
10581
|
+
*/
|
|
10582
|
+
function coverageExpectations(repoRoot, docsCoverage = "off") {
|
|
10583
|
+
const packages = readWorkspacePackages(repoRoot);
|
|
10584
|
+
const flags = codecovFlagNames(packages);
|
|
10585
|
+
if (docsCoverage !== "off") flags.push(DOCUMENTATION_FLAG);
|
|
10586
|
+
return {
|
|
10587
|
+
flags: [...new Set(flags)].sort(),
|
|
10588
|
+
components: packages.map((pkg) => pkg.slug).sort()
|
|
10589
|
+
};
|
|
10590
|
+
}
|
|
10591
|
+
// src/commands/coverage-status-contexts/coverage-status-contexts.ts
|
|
10592
|
+
/**
|
|
10593
|
+
* The commit statuses the repo's `coverage` provider posts (`Coverage.statusContexts()`), for the generators that decide
|
|
10594
|
+
* which statuses the `ci` aggregate and the ruleset wait on. The task runner imports no provider, so this is where the
|
|
10595
|
+
* contexts are read and handed in. `undefined` when no `coverage` provider is loaded or it does not implement the method,
|
|
10596
|
+
* which leaves the task runner's default in force. Names only: it reads the workspace's package names and the docs mode.
|
|
10597
|
+
*/
|
|
10598
|
+
function coverageStatusContexts(input) {
|
|
10599
|
+
if (!input.loader.has("coverage")) return void 0;
|
|
10600
|
+
const provider = input.loader.get("coverage");
|
|
10601
|
+
if (provider.statusContexts === void 0) return void 0;
|
|
10602
|
+
const documentation = input.docsCoverage ?? "off";
|
|
10603
|
+
return provider.statusContexts({
|
|
10604
|
+
components: coverageExpectations(input.repoRoot, documentation).components,
|
|
10605
|
+
documentation
|
|
10606
|
+
});
|
|
10607
|
+
}
|
|
10497
10608
|
// src/commands/repo-files/hosted-reusables.ts
|
|
10498
10609
|
/** The name of the private package that holds the reusable workflows and composite actions. */
|
|
10499
10610
|
const CI_PACKAGE = "@theholocron/ci";
|
|
@@ -10879,7 +10990,7 @@ const onOff = (value) => value ? "on" : "off";
|
|
|
10879
10990
|
* declares it (labels and security toggles are always written, so they are always checked). Variables, secrets and
|
|
10880
10991
|
* environments are separate checks. Pages, `CODEOWNERS` and the generated files are not compared here.
|
|
10881
10992
|
*/
|
|
10882
|
-
function repoChecks(config, repoRoot) {
|
|
10993
|
+
function repoChecks(config, repoRoot, statusContexts) {
|
|
10883
10994
|
const repo = config.repo;
|
|
10884
10995
|
const preset = repo?.protection && repo.protection !== "none" ? repo.protection : void 0;
|
|
10885
10996
|
const checks = [];
|
|
@@ -11044,7 +11155,7 @@ function repoChecks(config, repoRoot) {
|
|
|
11044
11155
|
checked: 1
|
|
11045
11156
|
};
|
|
11046
11157
|
const detail = await source.getRulesetDetail(found.id);
|
|
11047
|
-
const required = preset === "strict" ? strictChecks(config, repoRoot) : [];
|
|
11158
|
+
const required = preset === "strict" ? strictChecks(config, repoRoot, statusContexts) : [];
|
|
11048
11159
|
const rules = [
|
|
11049
11160
|
"deletion",
|
|
11050
11161
|
"non_fast_forward",
|
|
@@ -11108,13 +11219,14 @@ function declaredProperties(config) {
|
|
|
11108
11219
|
return out;
|
|
11109
11220
|
}
|
|
11110
11221
|
/** The status checks a `strict` ruleset requires, derived from the task manifest exactly as `setup` does. */
|
|
11111
|
-
function strictChecks(config, repoRoot) {
|
|
11222
|
+
function strictChecks(config, repoRoot, statusContexts) {
|
|
11112
11223
|
const tasksConfig = { tasks: config.tasks };
|
|
11113
11224
|
if (config.extraRequiredChecks) tasksConfig.extraRequiredChecks = config.extraRequiredChecks;
|
|
11114
11225
|
return createAstromech({
|
|
11115
11226
|
cwd: repoRoot,
|
|
11116
11227
|
config: tasksConfig,
|
|
11117
|
-
logger: getLogger()
|
|
11228
|
+
logger: getLogger(),
|
|
11229
|
+
...statusContexts ? { statusContexts } : {}
|
|
11118
11230
|
}).requiredChecks(hostsReusables(repoRoot));
|
|
11119
11231
|
}
|
|
11120
11232
|
// src/commands/doctor-repo/doctor-repo.ts
|
|
@@ -11134,23 +11246,27 @@ async function runDoctorRepo(input) {
|
|
|
11134
11246
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
11135
11247
|
await loader.load();
|
|
11136
11248
|
assertPluginsResolvable(loader, "doctor repo");
|
|
11137
|
-
const checks = repoChecks(input.loaded.resolved, input.context.repoRoot
|
|
11249
|
+
const checks = repoChecks(input.loaded.resolved, input.context.repoRoot, coverageStatusContexts({
|
|
11250
|
+
loader,
|
|
11251
|
+
repoRoot: input.context.repoRoot,
|
|
11252
|
+
docsCoverage: input.loaded.resolved.repoValidation?.docsCoverage
|
|
11253
|
+
}));
|
|
11138
11254
|
const rows = [];
|
|
11139
11255
|
if (!loader.has("source")) {
|
|
11140
11256
|
const why = whyMissing(loader, "source", "no `source` provider to read the repository with");
|
|
11141
|
-
for (const check of checks) rows.push(row$
|
|
11257
|
+
for (const check of checks) rows.push(row$10(check, { skip: why }));
|
|
11142
11258
|
} else {
|
|
11143
11259
|
const source = loader.get("source");
|
|
11144
11260
|
for (const check of checks) {
|
|
11145
11261
|
if (typeof source[check.needs] !== "function") {
|
|
11146
|
-
rows.push(row$
|
|
11262
|
+
rows.push(row$10(check, { skip: `provider does not implement ${check.needs}` }));
|
|
11147
11263
|
continue;
|
|
11148
11264
|
}
|
|
11149
11265
|
try {
|
|
11150
|
-
rows.push(row$
|
|
11266
|
+
rows.push(row$10(check, await check.run(source)));
|
|
11151
11267
|
} catch (err) {
|
|
11152
11268
|
const noToken = missingTokenReason(err);
|
|
11153
|
-
if (noToken !== void 0) rows.push(row$
|
|
11269
|
+
if (noToken !== void 0) rows.push(row$10(check, { skip: noToken }));
|
|
11154
11270
|
else rows.push({
|
|
11155
11271
|
id: check.id,
|
|
11156
11272
|
title: check.title,
|
|
@@ -11176,7 +11292,7 @@ async function runDoctorRepo(input) {
|
|
|
11176
11292
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
11177
11293
|
};
|
|
11178
11294
|
}
|
|
11179
|
-
function row$
|
|
11295
|
+
function row$10(check, result) {
|
|
11180
11296
|
const { id, title } = check;
|
|
11181
11297
|
if ("skip" in result) return {
|
|
11182
11298
|
id,
|
|
@@ -11699,7 +11815,7 @@ function providerGroup(providerName) {
|
|
|
11699
11815
|
}
|
|
11700
11816
|
// src/commands/doctor-secrets/credentials-rows.ts
|
|
11701
11817
|
/** A row for the provider as a whole, or for one of its variables when `name` is given. */
|
|
11702
|
-
function row$
|
|
11818
|
+
function row$9(provider, status, detail, name) {
|
|
11703
11819
|
return name === void 0 ? {
|
|
11704
11820
|
id: provider,
|
|
11705
11821
|
title: provider,
|
|
@@ -11724,10 +11840,10 @@ async function credentialsRows(input) {
|
|
|
11724
11840
|
const { loader } = input;
|
|
11725
11841
|
const { resolved } = input.loaded;
|
|
11726
11842
|
if (!resolved.providers.credentials) return {
|
|
11727
|
-
rows: input.asked ? [row$
|
|
11843
|
+
rows: input.asked ? [row$9("credentials", "skip", "no `credentials` provider is configured")] : [],
|
|
11728
11844
|
places: []
|
|
11729
11845
|
};
|
|
11730
|
-
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$
|
|
11846
|
+
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$9(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
|
|
11731
11847
|
const places = [];
|
|
11732
11848
|
if (!loader.has("credentials")) return {
|
|
11733
11849
|
rows,
|
|
@@ -11739,7 +11855,7 @@ async function credentialsRows(input) {
|
|
|
11739
11855
|
const tuple = tuples.find((t) => t.provider === impl.providerName);
|
|
11740
11856
|
const explicit = tuple && credentialsEnvironment(tuple, resolved);
|
|
11741
11857
|
if (!explicit && !derivesEnvironment(impl.providerName)) {
|
|
11742
|
-
rows.push(row$
|
|
11858
|
+
rows.push(row$9(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
|
|
11743
11859
|
continue;
|
|
11744
11860
|
}
|
|
11745
11861
|
try {
|
|
@@ -11751,7 +11867,7 @@ async function credentialsRows(input) {
|
|
|
11751
11867
|
rows.push(...checked.rows);
|
|
11752
11868
|
places.push(...checked.places);
|
|
11753
11869
|
} catch (err) {
|
|
11754
|
-
rows.push(row$
|
|
11870
|
+
rows.push(row$9(impl.providerName, "fail", errorMessage(err)));
|
|
11755
11871
|
}
|
|
11756
11872
|
}
|
|
11757
11873
|
return {
|
|
@@ -11767,17 +11883,17 @@ async function credentialsRows(input) {
|
|
|
11767
11883
|
async function checkProvider(impl, candidates, expected, synced) {
|
|
11768
11884
|
const provider = impl.providerName;
|
|
11769
11885
|
if (!impl.inspect) return {
|
|
11770
|
-
rows: [row$
|
|
11886
|
+
rows: [row$9(provider, "skip", "cannot list the variables without reading their values")],
|
|
11771
11887
|
places: []
|
|
11772
11888
|
};
|
|
11773
11889
|
if (expected.length === 0) return {
|
|
11774
|
-
rows: [row$
|
|
11890
|
+
rows: [row$9(provider, "skip", "no configured plugin lists the tokens it takes")],
|
|
11775
11891
|
places: []
|
|
11776
11892
|
};
|
|
11777
11893
|
const inspect = impl.inspect.bind(impl);
|
|
11778
11894
|
try {
|
|
11779
11895
|
const { found, missing } = await tryEnvironments(candidates, inspect);
|
|
11780
|
-
const rows = missing.map((name) => row$
|
|
11896
|
+
const rows = missing.map((name) => row$9(provider, "fail", `${provider} has no Environment named "${name}"`));
|
|
11781
11897
|
const group = providerGroup(provider);
|
|
11782
11898
|
const unreadPlaces = missing.map((name) => ({
|
|
11783
11899
|
column: {
|
|
@@ -11800,9 +11916,9 @@ async function checkProvider(impl, candidates, expected, synced) {
|
|
|
11800
11916
|
const have = (name) => found.some((f) => f.result.names.includes(name));
|
|
11801
11917
|
let present = 0;
|
|
11802
11918
|
for (const { name, optional } of expected) if (have(name)) present++;
|
|
11803
|
-
else if (optional) rows.push(row$
|
|
11804
|
-
else rows.push(row$
|
|
11805
|
-
if (present > 0) rows.push(row$
|
|
11919
|
+
else if (optional) rows.push(row$9(provider, "skip", `optional, not set in ${where}`, name));
|
|
11920
|
+
else rows.push(row$9(provider, "fail", `missing from ${where}`, name));
|
|
11921
|
+
if (present > 0) rows.push(row$9(provider, "ok", `${present} of ${expected.length} tokens present in ${where}`, "tokens"));
|
|
11806
11922
|
const names = new Set(expected.map((e) => e.name));
|
|
11807
11923
|
const places = [];
|
|
11808
11924
|
const missingRequired = expected.filter((e) => !e.optional && !have(e.name)).map((e) => e.name);
|
|
@@ -11841,7 +11957,7 @@ async function checkProvider(impl, candidates, expected, synced) {
|
|
|
11841
11957
|
};
|
|
11842
11958
|
} catch (err) {
|
|
11843
11959
|
return {
|
|
11844
|
-
rows: [row$
|
|
11960
|
+
rows: [row$9(provider, "fail", errorMessage(err))],
|
|
11845
11961
|
places: []
|
|
11846
11962
|
};
|
|
11847
11963
|
}
|
|
@@ -12715,7 +12831,7 @@ async function variableRows(loader, config, org) {
|
|
|
12715
12831
|
if (!loader.has("source")) {
|
|
12716
12832
|
const why = whyMissing(loader, "source", "no `source` provider to read them with");
|
|
12717
12833
|
for (const check of checks) {
|
|
12718
|
-
rows.push(row$
|
|
12834
|
+
rows.push(row$8(check, { skip: why }));
|
|
12719
12835
|
observations.push({
|
|
12720
12836
|
scope: check.scope,
|
|
12721
12837
|
unread: why
|
|
@@ -12725,7 +12841,7 @@ async function variableRows(loader, config, org) {
|
|
|
12725
12841
|
const source = loader.get("source");
|
|
12726
12842
|
for (const check of checks) try {
|
|
12727
12843
|
const result = await check.run(source);
|
|
12728
|
-
rows.push(row$
|
|
12844
|
+
rows.push(row$8(check, result));
|
|
12729
12845
|
observations.push("skip" in result ? {
|
|
12730
12846
|
scope: check.scope,
|
|
12731
12847
|
unread: result.skip
|
|
@@ -12736,7 +12852,7 @@ async function variableRows(loader, config, org) {
|
|
|
12736
12852
|
} catch (err) {
|
|
12737
12853
|
const noToken = missingTokenReason(err);
|
|
12738
12854
|
if (noToken !== void 0) {
|
|
12739
|
-
rows.push(row$
|
|
12855
|
+
rows.push(row$8(check, { skip: noToken }));
|
|
12740
12856
|
observations.push({
|
|
12741
12857
|
scope: check.scope,
|
|
12742
12858
|
unread: noToken
|
|
@@ -12762,7 +12878,7 @@ async function variableRows(loader, config, org) {
|
|
|
12762
12878
|
observations
|
|
12763
12879
|
};
|
|
12764
12880
|
}
|
|
12765
|
-
function row$
|
|
12881
|
+
function row$8(check, result) {
|
|
12766
12882
|
const { id, title } = check;
|
|
12767
12883
|
if ("skip" in result) return {
|
|
12768
12884
|
id,
|
|
@@ -12852,7 +12968,7 @@ function describeExpiry(expiresAt, now) {
|
|
|
12852
12968
|
*
|
|
12853
12969
|
* What a token may do is not checked: GitHub does not return a fine-grained token's permissions.
|
|
12854
12970
|
*/
|
|
12855
|
-
function row$
|
|
12971
|
+
function row$7(id, status, detail) {
|
|
12856
12972
|
return {
|
|
12857
12973
|
id: `verify:${id}`,
|
|
12858
12974
|
title: `verify ${id}`,
|
|
@@ -12880,12 +12996,12 @@ async function verifyRows(input) {
|
|
|
12880
12996
|
try {
|
|
12881
12997
|
module = await importer(pkg);
|
|
12882
12998
|
} catch (err) {
|
|
12883
|
-
rows.push(row$
|
|
12999
|
+
rows.push(row$7(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
|
|
12884
13000
|
continue;
|
|
12885
13001
|
}
|
|
12886
13002
|
for (const token of module.tokens ?? []) rows.push(await checkToken(token, module, env, readToken, now()));
|
|
12887
13003
|
}
|
|
12888
|
-
if (rows.length === 0) rows.push(row$
|
|
13004
|
+
if (rows.length === 0) rows.push(row$7("tokens", "skip", "no configured plugin lists the tokens it takes"));
|
|
12889
13005
|
return rows;
|
|
12890
13006
|
}
|
|
12891
13007
|
/**
|
|
@@ -12898,30 +13014,30 @@ async function loadCredentials(input) {
|
|
|
12898
13014
|
try {
|
|
12899
13015
|
await input.loader.load();
|
|
12900
13016
|
} catch (err) {
|
|
12901
|
-
return [row$
|
|
13017
|
+
return [row$7("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
|
|
12902
13018
|
}
|
|
12903
|
-
return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$
|
|
13019
|
+
return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$7(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
|
|
12904
13020
|
}
|
|
12905
13021
|
async function checkToken(token, module, env, readToken, now) {
|
|
12906
13022
|
const { keyringKey, envName, vendorEnvName } = token;
|
|
12907
13023
|
const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
|
|
12908
13024
|
const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
|
|
12909
13025
|
const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
|
|
12910
|
-
if (!value) return row$
|
|
13026
|
+
if (!value) return row$7(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
|
|
12911
13027
|
const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
|
|
12912
|
-
if (!verify) return row$
|
|
13028
|
+
if (!verify) return row$7(keyringKey, "skip", "set, but its plugin cannot verify it");
|
|
12913
13029
|
const from = fromEnv ?? stored?.source ?? "keyring";
|
|
12914
13030
|
try {
|
|
12915
13031
|
const verified = await verify(value);
|
|
12916
|
-
if (!verified.ok) return row$
|
|
13032
|
+
if (!verified.ok) return row$7(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
|
|
12917
13033
|
const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
|
|
12918
|
-
if (!expiry) return row$
|
|
13034
|
+
if (!expiry) return row$7(keyringKey, "ok", `${verified.subject} (${from})`);
|
|
12919
13035
|
return expiry.soon ? {
|
|
12920
|
-
...row$
|
|
13036
|
+
...row$7(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
|
|
12921
13037
|
problems: [`${expiry.text}: renew it`]
|
|
12922
|
-
} : row$
|
|
13038
|
+
} : row$7(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
|
|
12923
13039
|
} catch (err) {
|
|
12924
|
-
return row$
|
|
13040
|
+
return row$7(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
|
|
12925
13041
|
}
|
|
12926
13042
|
}
|
|
12927
13043
|
// src/commands/doctor-secrets/doctor-secrets.ts
|
|
@@ -13513,6 +13629,11 @@ async function runProbe(input) {
|
|
|
13513
13629
|
rows
|
|
13514
13630
|
};
|
|
13515
13631
|
}
|
|
13632
|
+
// src/commands/provider-tuples/provider-tuples.ts
|
|
13633
|
+
/** The providers a config names, in the order it names them: one tuple per capability entry, so a provider named twice appears twice. */
|
|
13634
|
+
function providerTuples(providers) {
|
|
13635
|
+
return Object.values(providers).flatMap((entry) => entry.cardinality === "single" ? [entry.tuple] : entry.tuples);
|
|
13636
|
+
}
|
|
13516
13637
|
// src/commands/token-rotation/token-rotation.ts
|
|
13517
13638
|
/** The rotation policy of a token that declares none: a token is due after 90 days, and an expiry is flagged 14 days ahead. */
|
|
13518
13639
|
const DEFAULT_TOKEN_ROTATION = {
|
|
@@ -13550,6 +13671,46 @@ function tokenExpectations(tokens, filter = {}) {
|
|
|
13550
13671
|
}
|
|
13551
13672
|
return found;
|
|
13552
13673
|
}
|
|
13674
|
+
// src/commands/workspace-providers/workspace-providers.ts
|
|
13675
|
+
/** The extensions a `holocron.config` can have. */
|
|
13676
|
+
const CONFIG_EXTENSIONS$1 = [
|
|
13677
|
+
"ts",
|
|
13678
|
+
"js",
|
|
13679
|
+
"mjs",
|
|
13680
|
+
"cjs",
|
|
13681
|
+
"json"
|
|
13682
|
+
];
|
|
13683
|
+
/**
|
|
13684
|
+
* The providers the configs of the workspace's packages name (`apps/sentinel` names `vercel` for its `deployment`) that
|
|
13685
|
+
* `config` does not: what `doctor tokens` and `probe` load by name next to the repo's own, so the token a package's
|
|
13686
|
+
* provider needs is checked from the root. Nothing is written and the root config needs no key for it. The first
|
|
13687
|
+
* package to name a provider supplies its options (its `teamId`, from the shared `org` area). A package whose config
|
|
13688
|
+
* cannot be read is left out: its own commands report it.
|
|
13689
|
+
*/
|
|
13690
|
+
async function workspaceProviders(repoRoot, config) {
|
|
13691
|
+
const known = new Set(providerTuples(config.providers).map((t) => t.provider));
|
|
13692
|
+
const found = [];
|
|
13693
|
+
let packages;
|
|
13694
|
+
try {
|
|
13695
|
+
packages = readWorkspacePackages(repoRoot);
|
|
13696
|
+
} catch {
|
|
13697
|
+
return found;
|
|
13698
|
+
}
|
|
13699
|
+
for (const pkg of packages) {
|
|
13700
|
+
const dir = join(repoRoot, pkg.path ?? `${pkg.dir}/${pkg.slug}`);
|
|
13701
|
+
if (!CONFIG_EXTENSIONS$1.some((ext) => existsSync(join(dir, `holocron.config.${ext}`)))) continue;
|
|
13702
|
+
try {
|
|
13703
|
+
for (const tuple of providerTuples((await loadConfig(dir)).resolved.providers)) {
|
|
13704
|
+
if (known.has(tuple.provider)) continue;
|
|
13705
|
+
known.add(tuple.provider);
|
|
13706
|
+
found.push(tuple);
|
|
13707
|
+
}
|
|
13708
|
+
} catch {
|
|
13709
|
+
continue;
|
|
13710
|
+
}
|
|
13711
|
+
}
|
|
13712
|
+
return found;
|
|
13713
|
+
}
|
|
13553
13714
|
// src/commands/doctor-tokens/summarise-probe-rows.ts
|
|
13554
13715
|
/**
|
|
13555
13716
|
* Folds what one token probe reported into the one row the doctor shows for that token in that layer. A failing probe row
|
|
@@ -13603,7 +13764,7 @@ function summariseProbeRows(id, title, rows) {
|
|
|
13603
13764
|
* provider with no `token` probe, no declared layer, or one that cannot be read is a skip with the reason.
|
|
13604
13765
|
*/
|
|
13605
13766
|
const PROBE = "token";
|
|
13606
|
-
const row$
|
|
13767
|
+
const row$6 = (id, title, status, detail, problems = []) => ({
|
|
13607
13768
|
id,
|
|
13608
13769
|
title,
|
|
13609
13770
|
status,
|
|
@@ -13613,7 +13774,8 @@ const row$5 = (id, title, status, detail, problems = []) => ({
|
|
|
13613
13774
|
async function runDoctorTokens(input) {
|
|
13614
13775
|
const print = input.print ?? ((line) => console.log(line));
|
|
13615
13776
|
const logger = input.logger ?? getLogger();
|
|
13616
|
-
const
|
|
13777
|
+
const extras = input.workspaceProviders ?? await workspaceProviders(input.context.repoRoot, input.loaded.resolved);
|
|
13778
|
+
const makeLoader = input.makeLoader ?? ((context) => new PluginLoader(input.loaded.resolved, context, void 0, { extraProviders: extras }));
|
|
13617
13779
|
const loader = input.loader ?? makeLoader(input.context);
|
|
13618
13780
|
await loader.load();
|
|
13619
13781
|
assertPluginsResolvable(loader, "doctor tokens");
|
|
@@ -13622,17 +13784,17 @@ async function runDoctorTokens(input) {
|
|
|
13622
13784
|
const declared = [];
|
|
13623
13785
|
/* v8 ignore next -- the real importer reads installed plugin packages, which tests replace with `providerTokens` */
|
|
13624
13786
|
const providerTokens = input.providerTokens ?? defaultProviderTokens(input.loaded);
|
|
13625
|
-
for (const provider of providersOf(input.loaded.resolved.providers)) {
|
|
13787
|
+
for (const provider of providersOf(input.loaded.resolved.providers, extras)) {
|
|
13626
13788
|
let tokens;
|
|
13627
13789
|
try {
|
|
13628
13790
|
tokens = await providerTokens(provider);
|
|
13629
13791
|
} catch (err) {
|
|
13630
|
-
rows.push(row$
|
|
13792
|
+
rows.push(row$6(`tokens:${provider}`, provider, "skip", `could not read its tokens: ${describeError(err)}`));
|
|
13631
13793
|
continue;
|
|
13632
13794
|
}
|
|
13633
13795
|
const expectations = tokenExpectations(tokens);
|
|
13634
|
-
if (expectations.length === 0) rows.push(row$
|
|
13635
|
-
else if (!usableProbe(probes.get(provider))) rows.push(row$
|
|
13796
|
+
if (expectations.length === 0) rows.push(row$6(`tokens:${provider}`, provider, "skip", "info: declares no token layers, nothing to check"));
|
|
13797
|
+
else if (!usableProbe(probes.get(provider))) rows.push(row$6(`tokens:${provider}`, provider, "skip", `info: has no \`${PROBE}\` probe loaded, so its tokens are not checked`));
|
|
13636
13798
|
else declared.push({
|
|
13637
13799
|
provider,
|
|
13638
13800
|
tokens,
|
|
@@ -13670,10 +13832,9 @@ async function runDoctorTokens(input) {
|
|
|
13670
13832
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") || "no plugin declares a token layer" } : {}
|
|
13671
13833
|
};
|
|
13672
13834
|
}
|
|
13673
|
-
/** The provider names the config lists, once each. */
|
|
13674
|
-
function providersOf(providers) {
|
|
13675
|
-
|
|
13676
|
-
return [...new Set(names)];
|
|
13835
|
+
/** The provider names the config lists, then the workspace's extra ones, once each. */
|
|
13836
|
+
function providersOf(providers, extras) {
|
|
13837
|
+
return [...new Set([...providerTuples(providers), ...extras].map((t) => t.provider))];
|
|
13677
13838
|
}
|
|
13678
13839
|
const usableProbe = (probes) => probes?.[PROBE]?.acceptsToken === true;
|
|
13679
13840
|
const rowId = (layer, provider, envName) => `tokens:${layer}:${provider}:${envName}`;
|
|
@@ -13695,14 +13856,14 @@ async function checkLayer(c) {
|
|
|
13695
13856
|
tokens
|
|
13696
13857
|
});
|
|
13697
13858
|
} catch (err) {
|
|
13698
|
-
if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$
|
|
13699
|
-
return c.wanted.map((e) => row$
|
|
13859
|
+
if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$6(id(e), title(e), "fail", "not held in this layer", [err.message]));
|
|
13860
|
+
return c.wanted.map((e) => row$6(id(e), title(e), "skip", `could not read the Environment: ${describeError(err)}`));
|
|
13700
13861
|
}
|
|
13701
13862
|
const rows = [];
|
|
13702
13863
|
for (const e of c.wanted) {
|
|
13703
13864
|
const token = held.held.find((h) => h.envName === e.envName);
|
|
13704
13865
|
if (!token) {
|
|
13705
|
-
rows.push(row$
|
|
13866
|
+
rows.push(row$6(id(e), title(e), "fail", `not held in ${held.environment}`, [`${e.envName} is declared for ${c.layer}`]));
|
|
13706
13867
|
continue;
|
|
13707
13868
|
}
|
|
13708
13869
|
rows.push(summariseProbeRows(id(e), title(e), await probeToken(c, e, token.token, held.plain)));
|
|
@@ -14628,7 +14789,7 @@ const within = (path, folder) => {
|
|
|
14628
14789
|
};
|
|
14629
14790
|
/**
|
|
14630
14791
|
* The folder one provider's export is written to: `<out>/<provider>`, where `out` is `--out`, else `.export` beside the
|
|
14631
|
-
* first
|
|
14792
|
+
* first of `files` (`requests/.export/postman`, git-ignored; the caller passes one folder's files at a time). The folder is refused when it is, or contains, a
|
|
14632
14793
|
* source file's folder: an export never writes where the source files are, so it cannot overwrite the one source.
|
|
14633
14794
|
* A folder below the source folder is fine.
|
|
14634
14795
|
*/
|
|
@@ -14658,13 +14819,16 @@ function resolveExportDir(input) {
|
|
|
14658
14819
|
*
|
|
14659
14820
|
* The repo's `collectionFiles` / `envFiles` stay the one source. For each `tooling` provider the config names (or only
|
|
14660
14821
|
* `--to`), the command reads those two options from the provider's entry and calls the optional `Tooling.export` with
|
|
14661
|
-
* them and an output folder, `<out>/<provider>`; by default `.export` beside the
|
|
14662
|
-
* git-ignored (`resolveExportDir()` refuses a folder that is, or holds, the folder of a source file).
|
|
14822
|
+
* them and an output folder, `<out>/<provider>`; by default `.export` beside the collection files, which is
|
|
14823
|
+
* git-ignored (`resolveExportDir()` refuses a folder that is, or holds, the folder of a source file). Collection files in
|
|
14824
|
+
* different folders are exported in separate calls, each into the `.export` beside its own folder (one app's files never
|
|
14825
|
+
* land in another app's folder), and each call gets the environment files beside its collections (all of them when none
|
|
14826
|
+
* sits there); `--out` puts everything in one call under the one folder, with every environment file. A provider with
|
|
14663
14827
|
* no `export`, or an entry with no `collectionFiles`, is a skipped row. What the conversion could not carry across is
|
|
14664
14828
|
* listed under the provider's row and does not fail the run. It writes files, so it asks first unless `--dry-run` (the
|
|
14665
14829
|
* files are converted and listed, nothing is written) or `--yes` (without a terminal it refuses instead).
|
|
14666
14830
|
*/
|
|
14667
|
-
const row$
|
|
14831
|
+
const row$5 = (id, status, detail, problems = []) => ({
|
|
14668
14832
|
id,
|
|
14669
14833
|
title: id,
|
|
14670
14834
|
status,
|
|
@@ -14673,6 +14837,21 @@ const row$4 = (id, status, detail, problems = []) => ({
|
|
|
14673
14837
|
});
|
|
14674
14838
|
/** A provider option that is a list of file names; anything else reads as none. */
|
|
14675
14839
|
const fileList = (value) => Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
|
|
14840
|
+
/** The collection files grouped by the folder they sit in, in the order the folders first appear. */
|
|
14841
|
+
function groupByFolder(files) {
|
|
14842
|
+
const groups = /* @__PURE__ */ new Map();
|
|
14843
|
+
for (const file of files) groups.set(dirname(file), [...groups.get(dirname(file)) ?? [], file]);
|
|
14844
|
+
return [...groups.values()];
|
|
14845
|
+
}
|
|
14846
|
+
/**
|
|
14847
|
+
* The environment files that sit in the same folder as a group of collection files, so an app's collection carries
|
|
14848
|
+
* its own environments. When none sits there, all of them: an environment kept elsewhere is shared by every collection.
|
|
14849
|
+
*/
|
|
14850
|
+
function envFilesBeside(group, envFiles) {
|
|
14851
|
+
const folder = dirname(group[0]);
|
|
14852
|
+
const beside = envFiles.filter((file) => dirname(file) === folder);
|
|
14853
|
+
return beside.length > 0 ? beside : envFiles;
|
|
14854
|
+
}
|
|
14676
14855
|
async function runRequestsExport(input) {
|
|
14677
14856
|
/* v8 ignore next -- the console is only used outside tests, which inject `print` */
|
|
14678
14857
|
const print = input.print ?? ((line) => console.log(line));
|
|
@@ -14691,9 +14870,9 @@ async function runRequestsExport(input) {
|
|
|
14691
14870
|
print("");
|
|
14692
14871
|
const entry = input.loaded.resolved.providers.tooling;
|
|
14693
14872
|
const tuples = entry?.cardinality === "many" ? entry.tuples : [];
|
|
14694
|
-
if (tuples.length === 0) return finish([row$
|
|
14873
|
+
if (tuples.length === 0) return finish([row$5("tooling", "fail", "the config has no `tooling` provider to export for")]);
|
|
14695
14874
|
const chosen = input.to === void 0 ? tuples : tuples.filter((t) => t.provider === input.to);
|
|
14696
|
-
if (chosen.length === 0) return finish([row$
|
|
14875
|
+
if (chosen.length === 0) return finish([row$5(input.to, "fail", `not a \`tooling\` provider of this config (${tuples.map((t) => t.provider).join(", ")})`)]);
|
|
14697
14876
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
14698
14877
|
const loader = input.loader ?? new PluginLoader({
|
|
14699
14878
|
...input.loaded.resolved,
|
|
@@ -14713,36 +14892,42 @@ async function runRequestsExport(input) {
|
|
|
14713
14892
|
const tool = loaded.find((t) => t.providerName === id);
|
|
14714
14893
|
if (!tool) {
|
|
14715
14894
|
const failure = loader.loadFailures().find((f) => f.key === "tooling" && f.provider === id);
|
|
14716
|
-
rows.push(row$
|
|
14895
|
+
rows.push(row$5(id, "fail", `the provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`));
|
|
14717
14896
|
continue;
|
|
14718
14897
|
}
|
|
14719
14898
|
if (!tool.export) {
|
|
14720
|
-
rows.push(row$
|
|
14899
|
+
rows.push(row$5(id, "skip", "has no export: it reads the repo's files as they are"));
|
|
14721
14900
|
continue;
|
|
14722
14901
|
}
|
|
14723
14902
|
const collectionFiles = fileList(tuple.options.collectionFiles);
|
|
14724
14903
|
const envFiles = fileList(tuple.options.envFiles);
|
|
14725
14904
|
if (collectionFiles.length === 0) {
|
|
14726
|
-
rows.push(row$
|
|
14905
|
+
rows.push(row$5(id, "skip", "names no `collectionFiles`, so there is nothing to export"));
|
|
14727
14906
|
continue;
|
|
14728
14907
|
}
|
|
14729
|
-
const
|
|
14730
|
-
|
|
14731
|
-
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
|
|
14737
|
-
|
|
14908
|
+
const groups = input.out === void 0 ? groupByFolder(collectionFiles) : [collectionFiles];
|
|
14909
|
+
for (const group of groups) {
|
|
14910
|
+
const label = groups.length > 1 ? `${id}: ${dirname(group[0])}` : id;
|
|
14911
|
+
const envs = input.out === void 0 ? envFilesBeside(group, envFiles) : envFiles;
|
|
14912
|
+
const dir = resolveExportDir({
|
|
14913
|
+
repoRoot,
|
|
14914
|
+
provider: id,
|
|
14915
|
+
files: [...group, ...envs],
|
|
14916
|
+
...input.out !== void 0 ? { out: input.out } : {}
|
|
14917
|
+
});
|
|
14918
|
+
if (!dir.ok) {
|
|
14919
|
+
rows.push(row$5(label, "fail", dir.message));
|
|
14920
|
+
continue;
|
|
14921
|
+
}
|
|
14922
|
+
targets.push({
|
|
14923
|
+
provider: id,
|
|
14924
|
+
label,
|
|
14925
|
+
collectionFiles: group,
|
|
14926
|
+
envFiles: envs,
|
|
14927
|
+
outDir: dir.dir,
|
|
14928
|
+
tool
|
|
14929
|
+
});
|
|
14738
14930
|
}
|
|
14739
|
-
targets.push({
|
|
14740
|
-
provider: id,
|
|
14741
|
-
collectionFiles,
|
|
14742
|
-
envFiles,
|
|
14743
|
-
outDir: dir.dir,
|
|
14744
|
-
tool
|
|
14745
|
-
});
|
|
14746
14931
|
}
|
|
14747
14932
|
if (targets.length === 0) return finish(rows);
|
|
14748
14933
|
if (!dryRun && !input.yes) {
|
|
@@ -14750,7 +14935,7 @@ async function runRequestsExport(input) {
|
|
|
14750
14935
|
if (!await (input.confirm ?? ((message) => confirm({
|
|
14751
14936
|
message,
|
|
14752
14937
|
default: false
|
|
14753
|
-
})))(`Write the exports for ${targets.map((t) => t.provider).join(", ")}?`)) {
|
|
14938
|
+
})))(`Write the exports for ${[...new Set(targets.map((t) => t.provider))].join(", ")}?`)) {
|
|
14754
14939
|
print(` ${style.skip("cancelled; nothing was written")}`);
|
|
14755
14940
|
return {
|
|
14756
14941
|
status: "cancelled",
|
|
@@ -14759,7 +14944,7 @@ async function runRequestsExport(input) {
|
|
|
14759
14944
|
}
|
|
14760
14945
|
}
|
|
14761
14946
|
const paths = [];
|
|
14762
|
-
for (const { tool,
|
|
14947
|
+
for (const { tool, label, collectionFiles, envFiles, outDir } of targets) try {
|
|
14763
14948
|
const result = await tool.export({
|
|
14764
14949
|
collectionFiles,
|
|
14765
14950
|
envFiles,
|
|
@@ -14770,9 +14955,9 @@ async function runRequestsExport(input) {
|
|
|
14770
14955
|
const where = relative(repoRoot, outDir);
|
|
14771
14956
|
const files = result.files.length > 0 ? ` (${result.files.join(", ")})` : "";
|
|
14772
14957
|
paths.push(...result.files.map((file) => resolve(outDir, file)));
|
|
14773
|
-
rows.push(row$
|
|
14958
|
+
rows.push(row$5(label, "ok", `${dryRun ? "would write" : "wrote"} ${result.files.length} file(s) to ${where}${files}`, result.issues.map((issue) => `issue in ${issue.file}: ${issue.message}`)));
|
|
14774
14959
|
} catch (err) {
|
|
14775
|
-
rows.push(row$
|
|
14960
|
+
rows.push(row$5(label, "fail", describeError(err)));
|
|
14776
14961
|
}
|
|
14777
14962
|
const report = finish(rows.sort((a, b) => a.id.localeCompare(b.id)));
|
|
14778
14963
|
if (paths.length > 0) {
|
|
@@ -14835,6 +15020,41 @@ const skillsUpdateArgs = (y) => y.positional("name", {
|
|
|
14835
15020
|
type: "string",
|
|
14836
15021
|
describe: "Skill name to update (omit to update all installed skills)"
|
|
14837
15022
|
});
|
|
15023
|
+
// src/commands/coverage-config-files/coverage-config-files.ts
|
|
15024
|
+
/** The text of a file in the repository, or `null` when it is not there or cannot be read. */
|
|
15025
|
+
function readExisting(repoRoot, path) {
|
|
15026
|
+
try {
|
|
15027
|
+
return readFileSync(join(repoRoot, path), "utf8");
|
|
15028
|
+
} catch {
|
|
15029
|
+
return null;
|
|
15030
|
+
}
|
|
15031
|
+
}
|
|
15032
|
+
/**
|
|
15033
|
+
* The config files the repo's `coverage` provider writes (`Coverage.configFiles()`, `codecov.yml` for Codecov), as a
|
|
15034
|
+
* function that makes them, so a failure in the provider is the caller's to report as a failed step and not a crash
|
|
15035
|
+
* before anything is written. The task runner imports no provider, so this is where the workspace is read and handed in:
|
|
15036
|
+
* the packages as components and flags, the docs mode and a reader for the file already there (to merge into it).
|
|
15037
|
+
* `undefined` when no `coverage` provider is loaded or it does not implement the method: `generateRepoFiles()` then
|
|
15038
|
+
* writes no coverage config, which is what a run with no provider does. Names and file text only.
|
|
15039
|
+
*/
|
|
15040
|
+
function coverageConfigFiles(input) {
|
|
15041
|
+
if (!input.loader.has("coverage")) return void 0;
|
|
15042
|
+
const provider = input.loader.get("coverage");
|
|
15043
|
+
if (provider.configFiles === void 0) return void 0;
|
|
15044
|
+
const documentation = input.docsCoverage ?? "off";
|
|
15045
|
+
return () => {
|
|
15046
|
+
const packages = readWorkspacePackages(input.repoRoot);
|
|
15047
|
+
return provider.configFiles({
|
|
15048
|
+
components: packages.map((pkg) => ({
|
|
15049
|
+
id: pkg.slug,
|
|
15050
|
+
path: packageLocation(pkg)
|
|
15051
|
+
})),
|
|
15052
|
+
flags: codecovFlagNames(packages),
|
|
15053
|
+
documentation,
|
|
15054
|
+
existing: (path) => readExisting(input.repoRoot, path)
|
|
15055
|
+
});
|
|
15056
|
+
};
|
|
15057
|
+
}
|
|
14838
15058
|
// ../../.holocron/org.md
|
|
14839
15059
|
var org_default = "<!-- editorconfig-checker-disable-file -->\n\n# theholocron — agent operating contract\n\nOrg-level agent conventions for all `theholocron` repositories. The canonical\ncopy is `.holocron/org.md` in `theholocron/holocron`. `holocron sync` writes\nit into each repo's `AGENTS.md` between generated markers, so no repo needs a\nsibling checkout to read it; holocron itself imports it with `@.holocron/org.md`.\nEdit it in holocron, then run `holocron sync`.\n\n## Repo map\n\nEach concern lives in exactly one repo:\n\n| Concern | Repo |\n| ----------------------------------------------------------------- | ----------------------------------------- |\n| Shareable tool config (ESLint, Prettier, TSConfig, Vitest, …) | `theholocron/holocron` (`configs/`) |\n| HTTP clients and API wrappers | `theholocron/holocron` (`clients/`) |\n| Infrastructure automation, CI orchestration, repo lifecycle | `theholocron/holocron` |\n| Org-level CI workflows, composite actions, community health files | `theholocron/.github` |\n| Internal member docs and private org config | `theholocron/.github-private` (this repo) |\n| Shared agent skills registry | `theholocron/holocron` (`skills/`) |\n\nIf you find yourself copy-pasting a tool config across repos, it belongs in\nthe `configs/` folder of `theholocron/holocron`. If you find yourself writing a new\nautomation command, it belongs in `holocron` too. Generic helpers (`utils/`) and\nobservability (`observability/`) live in that monorepo as well.\n\n### `holocron.config` format\n\n- Repos **with** a `package.json` → `holocron.config.ts` with `defineConfig`\n from `@theholocron/cli`. The CLI must be resolvable at runtime for the TS\n format to work.\n- Repos **without** a `package.json` (e.g. `.github`, `.github-private`) →\n `holocron.config.json`.\n\n## Workflow\n\n- **Always open a PR — never push directly to the default branch.** Even for\n small fixes: create a branch, push it, open a PR. This lets CI run, keeps\n history reviewable, and respects branch protection. The only exception is\n bootstrapping a brand-new repo before protection is set up.\n- **Conventional Commits.** `feat:` / `fix:` / `chore:` / `docs:` / `ci:` /\n `test:` / `refactor:` / `perf:` — semantic-release uses these for versioning\n and changelogs. Repos without a release step use the subset relevant to them.\n- **Always `git commit -s`** (DCO). The `Signed-off-by:` trailer is required\n on every commit. `-s` generates it automatically from `git config user.name`\n and `user.email`.\n- **Always rebase, never merge `main`.** Use `git rebase origin/main` to keep a\n branch current. `git merge main` creates an unsigned merge commit and drags bot\n commits into the PR history — both trigger DCO check failures.\n- **No Claude attribution** in commits, PRs, issues, or docs. No\n `Co-Authored-By` trailer. The author is the user.\n- **One PR = one focused change.** Squash-merge; the PR title becomes the\n squashed commit subject that semantic-release reads.\n- **File issues for non-trivial work** and reference them in commits/PRs\n (`Closes #N` / `Refs #N`). Skip for typo fixes.\n- **Spec process: Issue before spec.** Before writing a spec file, file an issue\n first, in the tracker the config's `issues` provider names (GitHub when the\n config sets no `issues` provider). The issue is the durable tracking artifact.\n The spec's frontmatter `issue:` field must reference it. Order: Issue → Spec →\n PR → Review → merge.\n- **Reference the issue in that tracker's syntax** in commits and the PR: `Closes #N`\n / `Refs #N` for GitHub, the issue key (`Closes ENG-42` / `Refs ENG-42`) for Linear.\n\n## Before starting any coding task\n\n1. Verify you are on a feature branch, not `main`. If on `main`, create a branch\n first. Never commit directly to `main`. If on an existing feature branch, run\n `git fetch origin && git rebase origin/main` to ensure it has the latest from\n `main` — never start work on a stale branch.\n2. Any PR that adds new behavior must include tests and documentation in the same\n PR. Do not open docs-only or test-only follow-up PRs — tests and docs ship with\n the feature. This applies to new packages, capabilities, commands, APIs, and\n any observable behavior change.\n3. If adding a new client or plugin package, update the docs-theme registry in\n the same PR or a cleanly scoped immediate follow-up.\n4. One PR per logical change. Do not bundle unrelated fixes with a feature.\n\n## After completing any coding task\n\n1. Confirm you are still on the intended feature branch.\n2. Confirm all checklist items in any invoked skill are complete.\n3. Confirm CI is green before requesting review.\n\n## CI workflows\n\nAll reusable workflow implementations and composite actions **live as source in\n`theholocron/holocron` — `packages/astromech/src/templates/reusable/`** and are\ngenerated + pushed to `theholocron/.github` by `holocron sync github`.\n**`theholocron/.github` and `.github-private` are pure sync targets** — never\nhand-edit their `.github/workflows/*`, `.github/actions/*` or\n`workflow-templates/*`; edit the source in `holocron` and merge.\n\nEvery other repo (`configs`, `clients`, `holocron`, `.github-private`) gets\n**thin callers** — lightweight `.github/workflows/` files that delegate to\n`.github` via `uses: theholocron/.github/.github/workflows/<name>.yml@main` and\n`secrets: inherit`. Thin callers are generated from the manifest by\n`astromech.thinCallers()` (`holocron sync` / `holocron setup`).\n\n### Sync\n\nThe `sync-workflow-templates` workflow in `theholocron/holocron` keeps thin\ncallers up to date. It runs automatically on push to `main` when\n`packages/cli/src/templates/**` or `packages/astromech/src/templates/**` change.\nChanges to other parts of the sync machinery (e.g. `sync-github.ts`) require a\nmanual dispatch:\n\n```sh\ngh workflow run sync-workflow-templates.yml --repo theholocron/holocron --ref main\n```\n\n### Per-repo task list\n\nEach secondary repo controls which tasks (and their CI workflows) it\nreceives — and can supply per-task `with:` overrides — via the `tasks`\narray in its `holocron.config.ts` (or `holocron.config.json`).\n`@theholocron/astromech` reads it as the single source for `holocron run`\n/ `holocron run ci` / the generated workflow thin callers:\n\n```typescript\ntasks: [\"lint\", { name: \"release\", with: { \"run-build\": false } }];\n```\n\nOnly add a task if the corresponding capability exists in the repo:\n\n| Task | Requires |\n| ------------- | ------------------------------------------------- |\n| `test` | vitest suite with `--coverage` |\n| `typecheck` | TypeScript (`pnpm typecheck` script) |\n| `audit` | a bundle build step (`pnpm build` script) |\n| `sync-github` | `packages/cli/src/templates/**` — `holocron` only |\n\n### Release workflow — npm prefix and registry-url\n\n**Never run `npm config set prefix <path>` in a release workflow.** It writes\n`prefix=<path>` to `~/.npmrc`, which pnpm reads for npm configuration. With a\nnon-default prefix set, pnpm cannot locate the registry auth it needs to perform\nthe GitHub OIDC token exchange and fails with `ENEEDAUTH` — even when Trusted\nPublishers are correctly configured on npmjs.com.\n\nNode.js from `hostedtoolcache` already provides a user-writable npm prefix on\nPATH. Run `npm install -g <pkg>` directly.\n\n**Never cache `~/.npm-global` or any npm global directory in release workflows.**\nA stale cache restores old auth config that poisons the OIDC exchange.\n\n**Never set `registry-url` in the shared `setup-node` composite action.** It\ncauses `actions/setup-node` to write `//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}`\nto a temp `.npmrc` and set `NPM_CONFIG_USERCONFIG` pointing at it. pnpm then\nreads that file, fails env-var substitution when the token is empty, and loses\nauth entirely.\n\nThe reference implementation is `theholocron/holocron`'s own release workflow —\nno prefix step, no cache, no `registry-url`.\n\n### Discarding a bad sync PR\n\n**Delete the branch, don't only close the PR.** A closed-but-existing branch\nblocks future PR creation — GitHub returns 422 \"A pull request already exists\"\nand the sync silently skips opening a new one.\n\n```sh\ngh pr close <n> --repo <owner>/<repo> --delete-branch\n```\n\n## Code standards\n\n### Package manager\n\n**pnpm only.** Never use `npm` or `yarn`. Run workspace-wide tasks through\nTurbo (`pnpm test`, `pnpm build`, etc.); run single-package tasks with\n`pnpm --filter <name> <script>`.\n\n### TypeScript\n\n**No `any`.** Use `unknown` for values of genuinely unknown shape and narrow\nwith type guards. Use generics instead of `any` in function signatures.\n`as never` and `as unknown as T` are acceptable for internal casts where the\ntype system can't follow; `any` is not.\n\n### Node.js version\n\n`engines.node` must be set in every `package.json`. To update the Node.js\nversion across a repo run `holocron upgrade node <to>` from any repo that has\nthe CLI installed — it patches `engines.node`, `@types/node`, `.nvmrc`,\n`.node-version`, and `.github/workflows/*.yml` automatically.\n\n### `.alexrc.json`\n\n**Generated by `holocron setup` — do not edit manually.** The canonical\nallow-list lives in `ALEX_CONFIG` in\n`theholocron/holocron · packages/cli/src/inclusive-language/config.ts`. To\nallow a new term across all repos: edit that constant, open a PR in\n`holocron`, merge, then re-run `holocron setup` in each consuming repo.\n\n### Running `holocron setup`\n\nInstall `@theholocron/cli` and `@theholocron/holocron-plugin-github` under\n`catalogs.holocron` in `pnpm-workspace.yaml`:\n\n```yaml\ncatalogs:\n holocron:\n \"@theholocron/cli\": <version>\n \"@theholocron/holocron-plugin-github\": <version>\n```\n\nThen run:\n\n```sh\nGITHUB_TOKEN=$(gh auth token) \\\nHOLOCRON_ORG_TOKEN=$(security find-generic-password -s \"com.theholocron.cli\" -a \"github.org\" -w) \\\npnpm exec holocron setup --token $(security find-generic-password -s \"com.theholocron.cli\" -a \"github.admin\" -w)\n```\n\nAll tokens are stored in the macOS keychain under service `com.theholocron.cli`. See `docs/tokens.md` in the `holocron` repo for the full token matrix and required scopes.\n\nBump both catalog entries together when upgrading — they publish in lockstep.\n\n### README structure\n\nEvery repo README follows this layout. Use `holocron sync readme` to regenerate the Installation + Usage block automatically.\n\n```markdown\n# Package Name\n\n<!-- holocron:description -->\n\nOne-line description (synced from holocron.config.ts description field).\n<!-- /holocron:description -->\n\n<!-- holocron:installation -->\n\n## Installation\n\n...generated from package.json bin / exports...\n\n## Usage\n\n...generated from package.json bin / exports...\n<!-- /holocron:installation -->\n\n## What's Included ← template repos only; omit for libraries\n\n...feature table...\n\n## Development\n\npnpm scripts table or code block\n\n## Releases\n\nAutomated via semantic-release. Link to CHANGELOG.md.\n\n## Documentation\n\nLink to docs site.\n```\n\n**Rules:**\n\n- Never write \"Getting Started\" — use separate \"Installation\" and \"Usage\" headings.\n- The `<!-- holocron:description -->` and `<!-- holocron:installation -->` marker blocks must stay in sync with the config/package; run `holocron sync readme` after changing `description` in `holocron.config.ts` or `bin` in `package.json`.\n- The \"What's Included\" section belongs only in template repos (cli-template, node-template, react-template, etc.) where it describes what the template ships. Library and app repos omit it.\n\n---\n\n## This repo (`.github-private`)\n\n> **Local path:** `~/Code/theholocron/github-private/`\n> **GitHub repo:** `theholocron/.github-private`\n\nInternal member documentation and private org-level configuration for the\n`theholocron` org. Content here is only visible to org members.\n\nConventional Commit types used here: `docs:` for content changes, `ci:` for\nworkflow changes, `chore:` for maintenance.\n\nNo test suite (documentation repo). `pnpm lint` runs `yamllint` on workflow\nfiles. Branch protection on `main` requires DCO and passing CI checks.\n";
|
|
14840
15060
|
// src/commands/repo-files/generate-agent-files.ts
|
|
@@ -14890,6 +15110,83 @@ async function agentsFile(root) {
|
|
|
14890
15110
|
for (const name of ["AGENTS.md", "CLAUDE.md"]) if ((await lstat(join(root, name)).catch(() => null))?.isFile()) return name;
|
|
14891
15111
|
return null;
|
|
14892
15112
|
}
|
|
15113
|
+
const isObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15114
|
+
/** Whether a hook entry already runs `dcg`, with or without arguments (`dcg`, `dcg --strict`, a path ending in `/dcg`). */
|
|
15115
|
+
function runsDcg(hook) {
|
|
15116
|
+
if (!isObject$1(hook) || typeof hook.command !== "string") return false;
|
|
15117
|
+
const program = hook.command.trim().split(/\s+/)[0];
|
|
15118
|
+
return program === "dcg" || program.endsWith(`/dcg`);
|
|
15119
|
+
}
|
|
15120
|
+
/**
|
|
15121
|
+
* `settings` with the `dcg` `PreToolUse` hook for Bash calls wired in, and everything else in it (permissions, other
|
|
15122
|
+
* hooks, other matchers) exactly as it was. Already wired, whatever the matcher entry looks like around it, is left
|
|
15123
|
+
* alone, so a second run changes nothing. Throws on a file whose shape cannot hold the hook (`hooks` or `PreToolUse`
|
|
15124
|
+
* that is not an object or a list), so a hand-edited file is never silently replaced.
|
|
15125
|
+
*/
|
|
15126
|
+
function withDcgHook(settings) {
|
|
15127
|
+
if (!isObject$1(settings)) throw new Error("the settings file is not a JSON object");
|
|
15128
|
+
const hooks = settings.hooks ?? {};
|
|
15129
|
+
if (!isObject$1(hooks)) throw new Error("`hooks` in the settings file is not an object");
|
|
15130
|
+
const preToolUse = hooks.PreToolUse ?? [];
|
|
15131
|
+
if (!Array.isArray(preToolUse)) throw new Error("`hooks.PreToolUse` in the settings file is not a list");
|
|
15132
|
+
if (preToolUse.some((entry) => isObject$1(entry) && entry.matcher === "Bash" && Array.isArray(entry.hooks) && entry.hooks.some(runsDcg))) return settings;
|
|
15133
|
+
return {
|
|
15134
|
+
...settings,
|
|
15135
|
+
hooks: {
|
|
15136
|
+
...hooks,
|
|
15137
|
+
PreToolUse: [...preToolUse, {
|
|
15138
|
+
matcher: "Bash",
|
|
15139
|
+
hooks: [{
|
|
15140
|
+
type: "command",
|
|
15141
|
+
command: "dcg"
|
|
15142
|
+
}]
|
|
15143
|
+
}]
|
|
15144
|
+
}
|
|
15145
|
+
};
|
|
15146
|
+
}
|
|
15147
|
+
// src/commands/repo-files/generate-claude-files.ts
|
|
15148
|
+
const CLAUDE_SETTINGS_FILE = ".claude/settings.json";
|
|
15149
|
+
/**
|
|
15150
|
+
* `.claude/settings.json` with the `dcg` `PreToolUse` hook, for a repo whose config opts in with `agent: ["claude", { dcg: true }]`. The file
|
|
15151
|
+
* already on disk is merged, so a repo's own `permissions` and hooks are kept; the same bytes come out of `setup` and
|
|
15152
|
+
* `sync`, and `probe generated check` fails when the hook is missing. A repo that does not opt in gets nothing (no
|
|
15153
|
+
* step, no file), so the repos that never used it are unchanged. A file that is not valid JSON, or has a shape that
|
|
15154
|
+
* cannot hold the hook, is a failed step naming the file; it is never overwritten.
|
|
15155
|
+
*/
|
|
15156
|
+
async function generateClaudeFiles(input) {
|
|
15157
|
+
if (input.loaded.resolved.agentOptions?.dcg !== true) return [];
|
|
15158
|
+
const step = `write ${CLAUDE_SETTINGS_FILE}`;
|
|
15159
|
+
const text = await readFile(join(input.repoRoot, CLAUDE_SETTINGS_FILE), "utf8").catch(() => void 0);
|
|
15160
|
+
let existing = {};
|
|
15161
|
+
if (text !== void 0) try {
|
|
15162
|
+
existing = JSON.parse(text);
|
|
15163
|
+
} catch {
|
|
15164
|
+
return [{
|
|
15165
|
+
kind: "error",
|
|
15166
|
+
step,
|
|
15167
|
+
syncStep: step,
|
|
15168
|
+
message: `${CLAUDE_SETTINGS_FILE} is not valid JSON`
|
|
15169
|
+
}];
|
|
15170
|
+
}
|
|
15171
|
+
try {
|
|
15172
|
+
const content = formatJson(withDcgHook(existing));
|
|
15173
|
+
return [{
|
|
15174
|
+
kind: "file",
|
|
15175
|
+
path: CLAUDE_SETTINGS_FILE,
|
|
15176
|
+
content,
|
|
15177
|
+
step,
|
|
15178
|
+
syncStep: step,
|
|
15179
|
+
note: "dcg PreToolUse hook"
|
|
15180
|
+
}];
|
|
15181
|
+
} catch (err) {
|
|
15182
|
+
return [{
|
|
15183
|
+
kind: "error",
|
|
15184
|
+
step,
|
|
15185
|
+
syncStep: step,
|
|
15186
|
+
message: `${CLAUDE_SETTINGS_FILE}: ${errorMessage(err)}`
|
|
15187
|
+
}];
|
|
15188
|
+
}
|
|
15189
|
+
}
|
|
14893
15190
|
// src/commands/setup/own-catalog-packages/own-catalog-packages.ts
|
|
14894
15191
|
/**
|
|
14895
15192
|
* The packages of this workspace that a pnpm catalog also lists: the minimum versions a plugin accepts
|
|
@@ -14936,12 +15233,41 @@ function file(path, content, note) {
|
|
|
14936
15233
|
...note === void 0 ? {} : { note }
|
|
14937
15234
|
};
|
|
14938
15235
|
}
|
|
15236
|
+
/** The step `setup` and `sync` report when the coverage provider's files are not written, whichever file that is. */
|
|
15237
|
+
const COVERAGE_STEP = "write coverage config";
|
|
15238
|
+
/**
|
|
15239
|
+
* The files the `coverage` provider writes (`codecov.yml`), from `input.coverageConfigFiles`. Without one (no provider
|
|
15240
|
+
* is loaded, or it writes none) the step is skipped and no file is written or changed. A file that is not there yet is
|
|
15241
|
+
* only written when a `test:unit` task is configured: a repo with no test workflow has nothing to report coverage for.
|
|
15242
|
+
* A provider that throws is a failed step.
|
|
15243
|
+
*/
|
|
15244
|
+
function coverageConfigEntries(input, taskNames) {
|
|
15245
|
+
const skip = (step, message) => ({
|
|
15246
|
+
kind: "skip",
|
|
15247
|
+
step,
|
|
15248
|
+
syncStep: step,
|
|
15249
|
+
message
|
|
15250
|
+
});
|
|
15251
|
+
if (input.coverageConfigFiles === void 0) return [skip(COVERAGE_STEP, "no coverage provider configured")];
|
|
15252
|
+
let files;
|
|
15253
|
+
try {
|
|
15254
|
+
files = input.coverageConfigFiles();
|
|
15255
|
+
} catch (error) {
|
|
15256
|
+
return [{
|
|
15257
|
+
kind: "error",
|
|
15258
|
+
step: COVERAGE_STEP,
|
|
15259
|
+
syncStep: COVERAGE_STEP,
|
|
15260
|
+
message: errorMessage(error)
|
|
15261
|
+
}];
|
|
15262
|
+
}
|
|
15263
|
+
const hasTests = taskNames.some((name) => isTask(name, "test:unit"));
|
|
15264
|
+
return Object.entries(files).map(([path, content]) => !hasTests && !existsSync(join(input.repoRoot, path)) ? skip(`write ${path}`, "no test workflow configured") : file(path, content));
|
|
15265
|
+
}
|
|
14939
15266
|
/**
|
|
14940
15267
|
* The config files that are not workflows: the labeler, Dependabot and DCO configs, the lint and editor configs, the
|
|
14941
|
-
* git hooks and `codecov.yml
|
|
14942
|
-
* disk, so the file is read here.
|
|
15268
|
+
* git hooks and the coverage provider's config (`codecov.yml`), in the order `setup` writes them.
|
|
14943
15269
|
*/
|
|
14944
|
-
|
|
15270
|
+
function generateConfigFiles(input) {
|
|
14945
15271
|
const config = input.loaded.resolved;
|
|
14946
15272
|
const taskNames = (config.tasks ?? []).map((e) => typeof e === "string" ? e : e.name);
|
|
14947
15273
|
const entries = [];
|
|
@@ -14958,28 +15284,7 @@ async function generateConfigFiles(input) {
|
|
|
14958
15284
|
syncStep: `write ${hook}`,
|
|
14959
15285
|
message: "git hooks disabled"
|
|
14960
15286
|
});
|
|
14961
|
-
|
|
14962
|
-
if (!taskNames.some((name) => isTask(name, "test:unit")) && existing == null) entries.push({
|
|
14963
|
-
kind: "skip",
|
|
14964
|
-
step: "write codecov.yml",
|
|
14965
|
-
syncStep: "write codecov.yml",
|
|
14966
|
-
message: "no test workflow configured"
|
|
14967
|
-
});
|
|
14968
|
-
else try {
|
|
14969
|
-
const content = createAstromech({
|
|
14970
|
-
cwd: input.repoRoot,
|
|
14971
|
-
logger: input.logger ?? getLogger()
|
|
14972
|
-
}).codecovConfig(existing, { docsCoverage: config.repoValidation?.docsCoverage ?? "off" });
|
|
14973
|
-
const packageCount = readWorkspacePackages(input.repoRoot).length;
|
|
14974
|
-
entries.push(file("codecov.yml", content, packageCount > 0 ? `${packageCount} components` : "no components"));
|
|
14975
|
-
} catch (error) {
|
|
14976
|
-
entries.push({
|
|
14977
|
-
kind: "error",
|
|
14978
|
-
step: "write codecov.yml",
|
|
14979
|
-
syncStep: "write codecov.yml",
|
|
14980
|
-
message: errorMessage(error)
|
|
14981
|
-
});
|
|
14982
|
-
}
|
|
15287
|
+
entries.push(...coverageConfigEntries(input, taskNames));
|
|
14983
15288
|
return entries;
|
|
14984
15289
|
}
|
|
14985
15290
|
// src/commands/repo-files/generate-private-dir-files.ts
|
|
@@ -15233,6 +15538,7 @@ function generateWorkflowFiles(input) {
|
|
|
15233
15538
|
org: config.org,
|
|
15234
15539
|
domain: config.domain
|
|
15235
15540
|
},
|
|
15541
|
+
...input.statusContexts ? { statusContexts: input.statusContexts } : {},
|
|
15236
15542
|
logger: input.logger ?? getLogger()
|
|
15237
15543
|
});
|
|
15238
15544
|
const files = astromech.thinCallers();
|
|
@@ -15314,7 +15620,7 @@ function generateWorkflowFiles(input) {
|
|
|
15314
15620
|
// src/commands/repo-files/generate-repo-files.ts
|
|
15315
15621
|
/**
|
|
15316
15622
|
* Every file `holocron setup` writes to disk from the config alone, in the order it writes them: the thin-caller
|
|
15317
|
-
* workflows, the config files, the agent instructions block, the private directory (`.holocron/.private/.gitkeep` and its `.gitignore` block), then
|
|
15623
|
+
* workflows, the config files, the agent instructions block, `.claude/settings.json` (only when `agent: ["claude", { dcg: true }]` opts in), the private directory (`.holocron/.private/.gitkeep` and its `.gitignore` block), then
|
|
15318
15624
|
* `turbo.json` and its follow-up edits. No provider and no network, so a job without
|
|
15319
15625
|
* a token can produce them, and `sync` takes the files it shares from here too. What setup reads from a provider
|
|
15320
15626
|
* (CODEOWNERS, which needs the org, the installed skills, the agent prompts) is not here.
|
|
@@ -15322,8 +15628,9 @@ function generateWorkflowFiles(input) {
|
|
|
15322
15628
|
async function generateRepoFiles(input) {
|
|
15323
15629
|
return [
|
|
15324
15630
|
...generateWorkflowFiles(input),
|
|
15325
|
-
...
|
|
15631
|
+
...generateConfigFiles(input),
|
|
15326
15632
|
...await generateAgentFiles(input),
|
|
15633
|
+
...await generateClaudeFiles(input),
|
|
15327
15634
|
...await generatePrivateDirFiles(input),
|
|
15328
15635
|
...await generateTurboFiles(input)
|
|
15329
15636
|
];
|
|
@@ -16059,6 +16366,16 @@ async function runSetup(input) {
|
|
|
16059
16366
|
const steps = [];
|
|
16060
16367
|
const repo = config.repo;
|
|
16061
16368
|
const effectivePreset = repo?.protection;
|
|
16369
|
+
const statusContexts = coverageStatusContexts({
|
|
16370
|
+
loader,
|
|
16371
|
+
repoRoot: input.context.repoRoot,
|
|
16372
|
+
docsCoverage: config.repoValidation?.docsCoverage
|
|
16373
|
+
});
|
|
16374
|
+
const coverageFiles = coverageConfigFiles({
|
|
16375
|
+
loader,
|
|
16376
|
+
repoRoot: input.context.repoRoot,
|
|
16377
|
+
docsCoverage: config.repoValidation?.docsCoverage
|
|
16378
|
+
});
|
|
16062
16379
|
const setupPkgRelPath = resolvePkgRelPath(findRootSync(input.context.repoRoot, ".git", {
|
|
16063
16380
|
fallback: "start",
|
|
16064
16381
|
realpath: true
|
|
@@ -16104,7 +16421,8 @@ async function runSetup(input) {
|
|
|
16104
16421
|
const requiredChecks = effectivePreset === "strict" ? createAstromech({
|
|
16105
16422
|
cwd: input.context.repoRoot,
|
|
16106
16423
|
config: tasksConfig,
|
|
16107
|
-
logger
|
|
16424
|
+
logger,
|
|
16425
|
+
...statusContexts ? { statusContexts } : {}
|
|
16108
16426
|
}).requiredChecks(hostsReusables(input.context.repoRoot)) : [];
|
|
16109
16427
|
steps.push(await upsertBranchProtection(source, dryRun, requiredChecks));
|
|
16110
16428
|
print(formatStep(steps[steps.length - 1]));
|
|
@@ -16117,6 +16435,8 @@ async function runSetup(input) {
|
|
|
16117
16435
|
loaded: input.loaded,
|
|
16118
16436
|
repoRoot: input.context.repoRoot,
|
|
16119
16437
|
hooks: input.hooks,
|
|
16438
|
+
...statusContexts ? { statusContexts } : {},
|
|
16439
|
+
...coverageFiles ? { coverageConfigFiles: coverageFiles } : {},
|
|
16120
16440
|
logger
|
|
16121
16441
|
})) {
|
|
16122
16442
|
if (entry.kind === "skip") steps.push({
|
|
@@ -18138,7 +18458,7 @@ function specName(title, name) {
|
|
|
18138
18458
|
*/
|
|
18139
18459
|
/** How many lines of the spec a dry run shows. */
|
|
18140
18460
|
const PREVIEW_LINES$1 = 12;
|
|
18141
|
-
const row$
|
|
18461
|
+
const row$4 = (id, status, detail) => ({
|
|
18142
18462
|
id,
|
|
18143
18463
|
title: id,
|
|
18144
18464
|
status,
|
|
@@ -18168,7 +18488,7 @@ async function runIdeasPromote(input) {
|
|
|
18168
18488
|
print(style.header(`Holocron new spec${dryRun ? " (dry-run)" : ""}`));
|
|
18169
18489
|
print("");
|
|
18170
18490
|
const entry = input.loaded.resolved.providers.issues;
|
|
18171
|
-
if (!entry) return finish([row$
|
|
18491
|
+
if (!entry) return finish([row$4(input.issue, "fail", "the config has no `issues` provider to read the issue with")]);
|
|
18172
18492
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
18173
18493
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
18174
18494
|
const loader = input.loader ?? new PluginLoader({
|
|
@@ -18183,18 +18503,18 @@ async function runIdeasPromote(input) {
|
|
|
18183
18503
|
assertPluginsResolvable(loader, "new spec");
|
|
18184
18504
|
if (!loader.has("issues")) {
|
|
18185
18505
|
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
18186
|
-
return finish([row$
|
|
18506
|
+
return finish([row$4(input.issue, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
18187
18507
|
}
|
|
18188
18508
|
let issue;
|
|
18189
18509
|
try {
|
|
18190
18510
|
issue = await loader.get("issues").get(input.issue);
|
|
18191
18511
|
} catch (err) {
|
|
18192
|
-
return finish([row$
|
|
18512
|
+
return finish([row$4(input.issue, "fail", `could not read the issue: ${describeError(err)}`)]);
|
|
18193
18513
|
}
|
|
18194
18514
|
const name = specName(issue.summary, input.name);
|
|
18195
|
-
if (!name) return finish([row$
|
|
18515
|
+
if (!name) return finish([row$4(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`)]);
|
|
18196
18516
|
const relative = join(".notes", `${name}.spec.md`);
|
|
18197
|
-
if (io.exists(join(input.context.repoRoot, relative))) return finish([row$
|
|
18517
|
+
if (io.exists(join(input.context.repoRoot, relative))) return finish([row$4(relative, "fail", "the spec already exists; it is never overwritten")], relative);
|
|
18198
18518
|
const { org, name: repoName } = input.loaded.resolved;
|
|
18199
18519
|
const ref = githubRef(issue.url) ?? (issue.key.startsWith("#") ? `${org}/${repoName}${issue.key}` : issue.key);
|
|
18200
18520
|
const { content, fromIdea } = buildSpec({
|
|
@@ -18207,7 +18527,7 @@ async function runIdeasPromote(input) {
|
|
|
18207
18527
|
print(` ${relative}`);
|
|
18208
18528
|
for (const line of content.split("\n").slice(0, PREVIEW_LINES$1)) print(` ${style.skip(line)}`);
|
|
18209
18529
|
print("");
|
|
18210
|
-
return finish([row$
|
|
18530
|
+
return finish([row$4(relative, "skip", `would write the spec ${origin}`)], relative);
|
|
18211
18531
|
}
|
|
18212
18532
|
if (!input.yes) {
|
|
18213
18533
|
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`);
|
|
@@ -18226,9 +18546,9 @@ async function runIdeasPromote(input) {
|
|
|
18226
18546
|
try {
|
|
18227
18547
|
io.write(join(input.context.repoRoot, relative), content);
|
|
18228
18548
|
} catch (err) {
|
|
18229
|
-
return finish([row$
|
|
18549
|
+
return finish([row$4(relative, "fail", `could not write the spec: ${describeError(err)}`)], relative);
|
|
18230
18550
|
}
|
|
18231
|
-
return finish([row$
|
|
18551
|
+
return finish([row$4(relative, "ok", `wrote the spec ${origin}`)], relative);
|
|
18232
18552
|
}
|
|
18233
18553
|
// src/commands/ideas-promote/ideas-promote.command.ts
|
|
18234
18554
|
const ideasPromoteCommand = {
|
|
@@ -18274,7 +18594,7 @@ const ideasPromoteCommand = {
|
|
|
18274
18594
|
*/
|
|
18275
18595
|
/** How many lines of the body a dry run shows. */
|
|
18276
18596
|
const PREVIEW_LINES = 8;
|
|
18277
|
-
const row$
|
|
18597
|
+
const row$3 = (id, status, detail) => ({
|
|
18278
18598
|
id,
|
|
18279
18599
|
title: id,
|
|
18280
18600
|
status,
|
|
@@ -18298,9 +18618,9 @@ async function runIssueCreate(input) {
|
|
|
18298
18618
|
print(style.header(`Holocron new issue${dryRun ? " (dry-run)" : ""}`));
|
|
18299
18619
|
print("");
|
|
18300
18620
|
const title = input.title.trim();
|
|
18301
|
-
if (!title) return finish([row$
|
|
18621
|
+
if (!title) return finish([row$3("title", "fail", "the title is empty")]);
|
|
18302
18622
|
const entry = input.loaded.resolved.providers.issues;
|
|
18303
|
-
if (!entry) return finish([row$
|
|
18623
|
+
if (!entry) return finish([row$3(title, "fail", "the config has no `issues` provider to file the issue with")]);
|
|
18304
18624
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
18305
18625
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
18306
18626
|
const loader = input.loader ?? new PluginLoader({
|
|
@@ -18315,7 +18635,7 @@ async function runIssueCreate(input) {
|
|
|
18315
18635
|
assertPluginsResolvable(loader, "new issue");
|
|
18316
18636
|
if (!loader.has("issues")) {
|
|
18317
18637
|
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
18318
|
-
return finish([row$
|
|
18638
|
+
return finish([row$3(title, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
18319
18639
|
}
|
|
18320
18640
|
const labels = [...new Set((input.labels ?? []).map((l) => l.trim()).filter(Boolean))];
|
|
18321
18641
|
const body = input.body?.trim() ? input.body : void 0;
|
|
@@ -18326,7 +18646,7 @@ async function runIssueCreate(input) {
|
|
|
18326
18646
|
print(` ${title}`);
|
|
18327
18647
|
for (const line of (body ?? "").split("\n").slice(0, PREVIEW_LINES)) print(` ${style.skip(line)}`);
|
|
18328
18648
|
print("");
|
|
18329
|
-
return finish([row$
|
|
18649
|
+
return finish([row$3(title, "skip", `would file the issue${summary}`)]);
|
|
18330
18650
|
}
|
|
18331
18651
|
if (!input.yes) {
|
|
18332
18652
|
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");
|
|
@@ -18348,9 +18668,9 @@ async function runIssueCreate(input) {
|
|
|
18348
18668
|
...labels.length > 0 ? { labels } : {},
|
|
18349
18669
|
...milestone ? { milestone } : {}
|
|
18350
18670
|
});
|
|
18351
|
-
return finish([row$
|
|
18671
|
+
return finish([row$3(title, "ok", `filed ${key}`)], key);
|
|
18352
18672
|
} catch (err) {
|
|
18353
|
-
return finish([row$
|
|
18673
|
+
return finish([row$3(title, "fail", `could not file the issue: ${describeError(err)}`)]);
|
|
18354
18674
|
}
|
|
18355
18675
|
}
|
|
18356
18676
|
// src/commands/issue-create/issue-create.command.ts
|
|
@@ -22458,14 +22778,16 @@ async function generate(input) {
|
|
|
22458
22778
|
* are named by the package in the message. CI runs it, so a change to a generator or to the config that was not followed by a run of `setup`
|
|
22459
22779
|
* or `sync` cannot merge.
|
|
22460
22780
|
*/
|
|
22461
|
-
function generatedProbes(loaded, repoRoot) {
|
|
22781
|
+
function generatedProbes(loaded, repoRoot, statusContexts, coverageFiles) {
|
|
22462
22782
|
return { check: {
|
|
22463
22783
|
summary: "Fail for each generated file that differs from the committed copy (CI runs this).",
|
|
22464
22784
|
writes: false,
|
|
22465
22785
|
async run(ctx) {
|
|
22466
22786
|
const input = {
|
|
22467
22787
|
loaded,
|
|
22468
|
-
repoRoot
|
|
22788
|
+
repoRoot,
|
|
22789
|
+
...statusContexts ? { statusContexts } : {},
|
|
22790
|
+
...coverageFiles ? { coverageConfigFiles: coverageFiles } : {}
|
|
22469
22791
|
};
|
|
22470
22792
|
const first = await generate(input);
|
|
22471
22793
|
const second = await generate(input);
|
|
@@ -22974,8 +23296,10 @@ function tasksProbes(io, names = legacyReplacements()) {
|
|
|
22974
23296
|
*/
|
|
22975
23297
|
async function runProbeCommand(input) {
|
|
22976
23298
|
const print = input.print ?? ((line) => console.log(line));
|
|
22977
|
-
|
|
22978
|
-
|
|
23299
|
+
let extras = [];
|
|
23300
|
+
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
23301
|
+
const makeLoader = input.makeLoader ?? ((context) => new PluginLoader(input.loaded.resolved, context, void 0, { extraProviders: extras }));
|
|
23302
|
+
/* v8 ignore stop */
|
|
22979
23303
|
const loader = input.loader ?? makeLoader(input.context);
|
|
22980
23304
|
await loader.load();
|
|
22981
23305
|
const groups = new Map(loader.probes());
|
|
@@ -22987,10 +23311,26 @@ async function runProbeCommand(input) {
|
|
|
22987
23311
|
groups.set(COMLINK_PROVIDER, comlink);
|
|
22988
23312
|
groups.set(DOCS_PROVIDER, docsCoverageProbes(input.context.repoRoot, input.typedoc, void 0, input.loaded.resolved.repoValidation?.docsCoverage ?? "off"));
|
|
22989
23313
|
groups.set(DEPS_PROVIDER, depsProbes(input.context.repoRoot, print));
|
|
22990
|
-
groups.set(GENERATED_PROVIDER, generatedProbes(input.loaded, input.context.repoRoot
|
|
23314
|
+
groups.set(GENERATED_PROVIDER, generatedProbes(input.loaded, input.context.repoRoot, coverageStatusContexts({
|
|
23315
|
+
loader,
|
|
23316
|
+
repoRoot: input.context.repoRoot,
|
|
23317
|
+
docsCoverage: input.loaded.resolved.repoValidation?.docsCoverage
|
|
23318
|
+
}), coverageConfigFiles({
|
|
23319
|
+
loader,
|
|
23320
|
+
repoRoot: input.context.repoRoot,
|
|
23321
|
+
docsCoverage: input.loaded.resolved.repoValidation?.docsCoverage
|
|
23322
|
+
})));
|
|
22991
23323
|
groups.set("ci", ciProbes(input.context.org));
|
|
22992
23324
|
groups.set(SPECS_PROVIDER, specsProbes(realSpecsIo(input.context.repoRoot)));
|
|
22993
23325
|
groups.set(TASKS_PROVIDER, tasksProbes(realTasksIo(input.context.repoRoot)));
|
|
23326
|
+
if (!input.provider || !groups.has(input.provider)) {
|
|
23327
|
+
extras = input.workspaceProviders ?? await workspaceProviders(input.context.repoRoot, input.loaded.resolved);
|
|
23328
|
+
if (extras.length > 0) {
|
|
23329
|
+
const extended = makeLoader(input.context);
|
|
23330
|
+
await extended.load();
|
|
23331
|
+
for (const [provider, found] of extended.probes()) if (!groups.has(provider)) groups.set(provider, found);
|
|
23332
|
+
}
|
|
23333
|
+
}
|
|
22994
23334
|
if (!input.provider) {
|
|
22995
23335
|
if (input.pick) await input.pick(groups);
|
|
22996
23336
|
else for (const line of listProbes(groups)) print(line);
|
|
@@ -25163,7 +25503,7 @@ async function convergeCreatedIssue(issues, marker, created) {
|
|
|
25163
25503
|
*/
|
|
25164
25504
|
/** The state that files a note when the config names none. */
|
|
25165
25505
|
const DEFAULT_FILING_STATE = "in-progress";
|
|
25166
|
-
const row$
|
|
25506
|
+
const row$2 = (id, status, detail) => ({
|
|
25167
25507
|
id,
|
|
25168
25508
|
title: id,
|
|
25169
25509
|
status,
|
|
@@ -25195,7 +25535,7 @@ async function runIdeasSync(input) {
|
|
|
25195
25535
|
print(style.header(`Holocron sync ideas${dryRun ? " (dry-run)" : ""}`));
|
|
25196
25536
|
print("");
|
|
25197
25537
|
const entry = resolveIdeasProvider(input.loaded.resolved, input.env);
|
|
25198
|
-
if (!entry) return finish([row$
|
|
25538
|
+
if (!entry) return finish([row$2("ideas", "fail", "no `ideas` provider: set `providers.ideas` (`[\"obsidian\", { dir }]`) in holocron.config or HOLOCRON_IDEAS_DIR")]);
|
|
25199
25539
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
25200
25540
|
const reader = input.ideasLoader ?? new PluginLoader({
|
|
25201
25541
|
...input.loaded.resolved,
|
|
@@ -25206,25 +25546,25 @@ async function runIdeasSync(input) {
|
|
|
25206
25546
|
assertPluginsResolvable(reader, "sync ideas");
|
|
25207
25547
|
if (!reader.has("ideas")) {
|
|
25208
25548
|
const failure = reader.loadFailures().find((f) => f.key === "ideas");
|
|
25209
|
-
return finish([row$
|
|
25549
|
+
return finish([row$2("ideas", "fail", `the \`ideas\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
25210
25550
|
}
|
|
25211
25551
|
const ideas = reader.get("ideas");
|
|
25212
25552
|
let records;
|
|
25213
25553
|
try {
|
|
25214
25554
|
records = await ideas.list();
|
|
25215
25555
|
} catch (err) {
|
|
25216
|
-
return finish([row$
|
|
25556
|
+
return finish([row$2("ideas", "fail", describeError(err))]);
|
|
25217
25557
|
}
|
|
25218
25558
|
const fileState = input.loaded.resolved.ideas?.states?.file ?? DEFAULT_FILING_STATE;
|
|
25219
25559
|
const rows = [];
|
|
25220
25560
|
const ready = [];
|
|
25221
|
-
for (const idea of records) if (idea.error !== void 0) rows.push(row$
|
|
25561
|
+
for (const idea of records) if (idea.error !== void 0) rows.push(row$2(idea.key, "fail", idea.error));
|
|
25222
25562
|
else if (idea.status !== fileState || idea.issue !== void 0) notReady++;
|
|
25223
|
-
else if (idea.attachments.length > 0) rows.push(row$
|
|
25563
|
+
else if (idea.attachments.length > 0) rows.push(row$2(idea.key, "skip", `has embedded files an issue cannot carry (${idea.attachments.join(", ")}); not filed`));
|
|
25224
25564
|
else ready.push(idea);
|
|
25225
25565
|
if (ready.length === 0) return finish(rows);
|
|
25226
25566
|
if (dryRun) {
|
|
25227
|
-
for (const idea of ready) rows.push(row$
|
|
25567
|
+
for (const idea of ready) rows.push(row$2(idea.key, "skip", `would file "${idea.title}"`));
|
|
25228
25568
|
return finish(rows.sort((a, b) => a.id.localeCompare(b.id)));
|
|
25229
25569
|
}
|
|
25230
25570
|
if (!input.yes) {
|
|
@@ -25248,7 +25588,7 @@ async function runIdeasSync(input) {
|
|
|
25248
25588
|
for (const idea of ready) {
|
|
25249
25589
|
const path = idea.key;
|
|
25250
25590
|
if (!issues) {
|
|
25251
|
-
rows.push(row$
|
|
25591
|
+
rows.push(row$2(path, "fail", "the config has no `issues` provider to file it with"));
|
|
25252
25592
|
continue;
|
|
25253
25593
|
}
|
|
25254
25594
|
let existing;
|
|
@@ -25258,7 +25598,7 @@ async function runIdeasSync(input) {
|
|
|
25258
25598
|
limit: 100
|
|
25259
25599
|
})).filter((issue) => issue.body?.includes(marker(path))));
|
|
25260
25600
|
} catch (err) {
|
|
25261
|
-
rows.push(row$
|
|
25601
|
+
rows.push(row$2(path, "fail", `could not check for an existing issue, so none was created: ${describeError(err)}`));
|
|
25262
25602
|
continue;
|
|
25263
25603
|
}
|
|
25264
25604
|
let key;
|
|
@@ -25273,7 +25613,7 @@ async function runIdeasSync(input) {
|
|
|
25273
25613
|
body: issueBody(idea)
|
|
25274
25614
|
}));
|
|
25275
25615
|
} catch (err) {
|
|
25276
|
-
rows.push(row$
|
|
25616
|
+
rows.push(row$2(path, "fail", `could not create the issue: ${describeError(err)}`));
|
|
25277
25617
|
continue;
|
|
25278
25618
|
}
|
|
25279
25619
|
({key, detail, warning} = await convergeCreatedIssue(issues, marker(path), created));
|
|
@@ -25281,12 +25621,12 @@ async function runIdeasSync(input) {
|
|
|
25281
25621
|
try {
|
|
25282
25622
|
await ideas.markFiled(path, key);
|
|
25283
25623
|
rows.push({
|
|
25284
|
-
...row$
|
|
25624
|
+
...row$2(path, "ok", detail),
|
|
25285
25625
|
problems: warning ? ["a duplicate issue for this idea may be open: close the extra one by hand"] : []
|
|
25286
25626
|
});
|
|
25287
25627
|
} catch (err) {
|
|
25288
25628
|
rows.push({
|
|
25289
|
-
...row$
|
|
25629
|
+
...row$2(path, "fail", `issue ${key} was created but \`issue:\` was not written: ${describeError(err)}`),
|
|
25290
25630
|
problems: [`add \`issue: ${key}\` to the note by hand`]
|
|
25291
25631
|
});
|
|
25292
25632
|
}
|
|
@@ -26726,6 +27066,95 @@ function parseSince(value, now = Date.now()) {
|
|
|
26726
27066
|
if (Number.isNaN(at)) throw new ConfigError(`sync issues: --since "${value}" is not a date or a span like 30m, 12h, 7d or 2w`);
|
|
26727
27067
|
return new Date(at).toISOString();
|
|
26728
27068
|
}
|
|
27069
|
+
// src/commands/sync-issues/assignees-location/assignees-location.ts
|
|
27070
|
+
/** Where the assignees file is: the org's private config repo, as the Discord links file is. */
|
|
27071
|
+
function assigneesLocation(org) {
|
|
27072
|
+
if (!org) throw new Error("no org to find the assignees file under — set `org` in holocron.config.ts or pass --org");
|
|
27073
|
+
return {
|
|
27074
|
+
repo: `${org}/.github-private`,
|
|
27075
|
+
path: "issues/assignees.json"
|
|
27076
|
+
};
|
|
27077
|
+
}
|
|
27078
|
+
// src/commands/sync-issues/parse-assignees/parse-assignees.ts
|
|
27079
|
+
/**
|
|
27080
|
+
* Reads the assignees file's text. Throws with a plain reason on anything that is not that file, so a damaged one is
|
|
27081
|
+
* never treated as empty. A login or an email may appear once (compared without regard to case), because a repeat
|
|
27082
|
+
* would make the sync pick one of two people at random.
|
|
27083
|
+
*/
|
|
27084
|
+
function parseAssignees(text) {
|
|
27085
|
+
let raw;
|
|
27086
|
+
try {
|
|
27087
|
+
raw = JSON.parse(text);
|
|
27088
|
+
} catch {
|
|
27089
|
+
throw new Error("the assignees file is not valid JSON");
|
|
27090
|
+
}
|
|
27091
|
+
const file = raw;
|
|
27092
|
+
if (file.version !== 1) throw new Error(`the assignees file has version ${JSON.stringify(file.version)}; expected 1`);
|
|
27093
|
+
if (!Array.isArray(file.links)) throw new Error("the assignees file has no `links` list");
|
|
27094
|
+
const links = file.links.map((entry, i) => {
|
|
27095
|
+
const e = entry;
|
|
27096
|
+
if (typeof e.login !== "string" || e.login.trim() === "") throw new Error(`links[${i}]: \`login\` must be a string`);
|
|
27097
|
+
if (typeof e.email !== "string" || !e.email.includes("@")) throw new Error(`links[${i}]: \`email\` must be an email address`);
|
|
27098
|
+
return {
|
|
27099
|
+
login: e.login.trim(),
|
|
27100
|
+
email: e.email.trim()
|
|
27101
|
+
};
|
|
27102
|
+
});
|
|
27103
|
+
for (const key of ["login", "email"]) {
|
|
27104
|
+
const seen = /* @__PURE__ */ new Set();
|
|
27105
|
+
for (const [i, link] of links.entries()) {
|
|
27106
|
+
const value = link[key].toLowerCase();
|
|
27107
|
+
if (seen.has(value)) throw new Error(`links[${i}]: \`${key}\` ${link[key]} appears more than once`);
|
|
27108
|
+
seen.add(value);
|
|
27109
|
+
}
|
|
27110
|
+
}
|
|
27111
|
+
return {
|
|
27112
|
+
version: 1,
|
|
27113
|
+
links
|
|
27114
|
+
};
|
|
27115
|
+
}
|
|
27116
|
+
// src/commands/sync-issues/read-assignees/read-assignees.ts
|
|
27117
|
+
/**
|
|
27118
|
+
* Reads the assignees file through the `source` provider. A file that does not exist, or a source that cannot read
|
|
27119
|
+
* files, is an empty map; a damaged file throws with its location.
|
|
27120
|
+
*/
|
|
27121
|
+
async function readAssignees(source, org) {
|
|
27122
|
+
if (!source?.readFile) return [];
|
|
27123
|
+
const { repo, path } = assigneesLocation(org);
|
|
27124
|
+
const file = await source.readFile(path, repo);
|
|
27125
|
+
if (!file) return [];
|
|
27126
|
+
try {
|
|
27127
|
+
return parseAssignees(file.content).links;
|
|
27128
|
+
} catch (err) {
|
|
27129
|
+
throw new Error(`${repo}/${path}: ${errorMessage(err)}`, { cause: err });
|
|
27130
|
+
}
|
|
27131
|
+
}
|
|
27132
|
+
// src/commands/sync-issues/apply-assignees/apply-assignees.ts
|
|
27133
|
+
/**
|
|
27134
|
+
* Fills in the other tracker's name for each record's assignee from the assignees file: the GitHub `login` when the
|
|
27135
|
+
* assignee has an email (a Linear source), the `emailAddress` when the assignee's id is a login (a GitHub source). A
|
|
27136
|
+
* record with no assignee, or one the file does not name, is returned as it was, so the target reports it as not mapped.
|
|
27137
|
+
*/
|
|
27138
|
+
function applyAssignees(records, links) {
|
|
27139
|
+
if (links.length === 0) return records;
|
|
27140
|
+
const byEmail = new Map(links.map((l) => [l.email.toLowerCase(), l]));
|
|
27141
|
+
const byLogin = new Map(links.map((l) => [l.login.toLowerCase(), l]));
|
|
27142
|
+
return records.map((record) => {
|
|
27143
|
+
const who = record.assignee;
|
|
27144
|
+
if (!who) return record;
|
|
27145
|
+
const link = (who.emailAddress ? byEmail.get(who.emailAddress.toLowerCase()) : void 0) ?? byLogin.get(who.id.toLowerCase());
|
|
27146
|
+
if (!link) return record;
|
|
27147
|
+
const assignee = {
|
|
27148
|
+
...who,
|
|
27149
|
+
login: link.login,
|
|
27150
|
+
...who.emailAddress ? {} : { emailAddress: link.email }
|
|
27151
|
+
};
|
|
27152
|
+
return {
|
|
27153
|
+
...record,
|
|
27154
|
+
assignee
|
|
27155
|
+
};
|
|
27156
|
+
});
|
|
27157
|
+
}
|
|
26729
27158
|
// src/commands/sync-issues/run-sync-issues/run-sync-issues.ts
|
|
26730
27159
|
/**
|
|
26731
27160
|
* `holocron sync issues` — one direction of the issue sync between two trackers.
|
|
@@ -26791,8 +27220,13 @@ async function runSyncIssues(input) {
|
|
|
26791
27220
|
if (limited) row("skip", limited);
|
|
26792
27221
|
if (records.length === 0) return stop("skip", "nothing to sync");
|
|
26793
27222
|
const guarded = records.filter((r) => r.migratedFrom !== void 0);
|
|
26794
|
-
|
|
27223
|
+
let toSync = records.filter((r) => r.migratedFrom === void 0);
|
|
26795
27224
|
for (const r of guarded) row("skip", `${r.key} is a copy of ${r.migratedFrom}; not synced back`);
|
|
27225
|
+
if (input.readAssignees && toSync.some((r) => r.assignee)) try {
|
|
27226
|
+
toSync = applyAssignees(toSync, await input.readAssignees());
|
|
27227
|
+
} catch (err) {
|
|
27228
|
+
return stop("fail", `assignees: ${describeError(err)}`);
|
|
27229
|
+
}
|
|
26796
27230
|
const dryRun = Boolean(input.context.dryRun);
|
|
26797
27231
|
let results = [];
|
|
26798
27232
|
if (toSync.length > 0) {
|
|
@@ -26869,13 +27303,19 @@ const syncIssuesCommand = {
|
|
|
26869
27303
|
const loaded = await loadConfig(argv.cwd);
|
|
26870
27304
|
applyResolvedConfig(argv, loaded.resolved);
|
|
26871
27305
|
const org = resolveOrg(argv, loaded.resolved);
|
|
27306
|
+
const context = {
|
|
27307
|
+
repoRoot: argv.cwd,
|
|
27308
|
+
dryRun: argv.dryRun,
|
|
27309
|
+
...tokens,
|
|
27310
|
+
org
|
|
27311
|
+
};
|
|
26872
27312
|
if ((await runSyncIssues({
|
|
26873
27313
|
loaded,
|
|
26874
|
-
context
|
|
26875
|
-
|
|
26876
|
-
|
|
26877
|
-
|
|
26878
|
-
org
|
|
27314
|
+
context,
|
|
27315
|
+
readAssignees: async () => {
|
|
27316
|
+
const loader = new PluginLoader(loaded.resolved, context);
|
|
27317
|
+
await loader.load();
|
|
27318
|
+
return readAssignees(loader.has("source") ? loader.get("source") : void 0, org);
|
|
26879
27319
|
},
|
|
26880
27320
|
from: argv.from,
|
|
26881
27321
|
to: argv.to,
|
|
@@ -27181,7 +27621,7 @@ const syncReadmeCommand = {
|
|
|
27181
27621
|
* is one row; a provider that throws is a failing row and the others still run. `--dry-run` names what would be synced
|
|
27182
27622
|
* and calls no provider. It asks nothing first: like `setup`, it makes the tool match what the repo declares.
|
|
27183
27623
|
*/
|
|
27184
|
-
const row = (id, status, detail) => ({
|
|
27624
|
+
const row$1 = (id, status, detail) => ({
|
|
27185
27625
|
id,
|
|
27186
27626
|
title: id,
|
|
27187
27627
|
status,
|
|
@@ -27204,7 +27644,7 @@ async function runSyncTooling(input) {
|
|
|
27204
27644
|
print(style.header(`Holocron sync tooling${dryRun ? " (dry-run)" : ""}`));
|
|
27205
27645
|
print("");
|
|
27206
27646
|
const { tooling, credentials } = input.loaded.resolved.providers;
|
|
27207
|
-
if (!tooling) return finish([row("tooling", "fail", "no `tooling` provider: set `providers.tooling` (for example `postman`) in holocron.config")]);
|
|
27647
|
+
if (!tooling) return finish([row$1("tooling", "fail", "no `tooling` provider: set `providers.tooling` (for example `postman`) in holocron.config")]);
|
|
27208
27648
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
27209
27649
|
const loader = input.loader ?? new PluginLoader({
|
|
27210
27650
|
...input.loaded.resolved,
|
|
@@ -27218,19 +27658,19 @@ async function runSyncTooling(input) {
|
|
|
27218
27658
|
assertPluginsResolvable(loader, "sync tooling");
|
|
27219
27659
|
if (!loader.has("tooling")) {
|
|
27220
27660
|
const failure = loader.loadFailures().find((f) => f.key === "tooling");
|
|
27221
|
-
return finish([row("tooling", "fail", `the \`tooling\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
27661
|
+
return finish([row$1("tooling", "fail", `the \`tooling\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
27222
27662
|
}
|
|
27223
27663
|
const rows = [];
|
|
27224
27664
|
for (const tool of loader.get("tooling")) {
|
|
27225
27665
|
if (dryRun) {
|
|
27226
|
-
rows.push(row(tool.providerName, "skip", "would sync"));
|
|
27666
|
+
rows.push(row$1(tool.providerName, "skip", "would sync"));
|
|
27227
27667
|
continue;
|
|
27228
27668
|
}
|
|
27229
27669
|
try {
|
|
27230
27670
|
await tool.sync();
|
|
27231
|
-
rows.push(row(tool.providerName, "ok", "synced"));
|
|
27671
|
+
rows.push(row$1(tool.providerName, "ok", "synced"));
|
|
27232
27672
|
} catch (err) {
|
|
27233
|
-
rows.push(row(tool.providerName, "fail", describeError(err)));
|
|
27673
|
+
rows.push(row$1(tool.providerName, "fail", describeError(err)));
|
|
27234
27674
|
}
|
|
27235
27675
|
}
|
|
27236
27676
|
return finish(rows);
|
|
@@ -27510,6 +27950,7 @@ const SYNC_STEPS = [
|
|
|
27510
27950
|
"turbo",
|
|
27511
27951
|
"agents",
|
|
27512
27952
|
"private",
|
|
27953
|
+
"claude",
|
|
27513
27954
|
"wiki"
|
|
27514
27955
|
];
|
|
27515
27956
|
const LOCAL_STEPS = /* @__PURE__ */ new Set([
|
|
@@ -27522,6 +27963,7 @@ const LOCAL_STEPS = /* @__PURE__ */ new Set([
|
|
|
27522
27963
|
"turbo",
|
|
27523
27964
|
"agents",
|
|
27524
27965
|
"private",
|
|
27966
|
+
"claude",
|
|
27525
27967
|
"wiki"
|
|
27526
27968
|
]);
|
|
27527
27969
|
async function runSync(input) {
|
|
@@ -27702,6 +28144,7 @@ async function runSync(input) {
|
|
|
27702
28144
|
"turbo",
|
|
27703
28145
|
"agents",
|
|
27704
28146
|
"private",
|
|
28147
|
+
"claude",
|
|
27705
28148
|
"wiki"
|
|
27706
28149
|
]) {
|
|
27707
28150
|
if (requestedSteps !== void 0 && !requestedSteps.includes(stepName)) continue;
|
|
@@ -27787,9 +28230,15 @@ async function runSync(input) {
|
|
|
27787
28230
|
print(formatSyncStep(steps[steps.length - 1]));
|
|
27788
28231
|
}
|
|
27789
28232
|
if (stepName === "workflows") {
|
|
28233
|
+
const statusContexts = coverageStatusContexts({
|
|
28234
|
+
loader,
|
|
28235
|
+
repoRoot: input.context.repoRoot,
|
|
28236
|
+
docsCoverage: config.repoValidation?.docsCoverage
|
|
28237
|
+
});
|
|
27790
28238
|
const entries = generateWorkflowFiles({
|
|
27791
28239
|
loaded: input.loaded,
|
|
27792
28240
|
repoRoot: input.context.repoRoot,
|
|
28241
|
+
...statusContexts ? { statusContexts } : {},
|
|
27793
28242
|
logger
|
|
27794
28243
|
});
|
|
27795
28244
|
if ((config.tasks ?? []).length === 0) {
|
|
@@ -27926,6 +28375,37 @@ async function runSync(input) {
|
|
|
27926
28375
|
print(formatSyncStep(steps[steps.length - 1]));
|
|
27927
28376
|
}
|
|
27928
28377
|
}
|
|
28378
|
+
if (stepName === "claude") {
|
|
28379
|
+
if (resolvedRepoRoot !== gitRoot) {
|
|
28380
|
+
if (input.loaded.resolved.agentOptions?.dcg === true) {
|
|
28381
|
+
steps.push({
|
|
28382
|
+
capability: "local",
|
|
28383
|
+
step: "sync claude settings",
|
|
28384
|
+
status: "skip",
|
|
28385
|
+
message: "--cwd is a monorepo subpackage, not the git root — run from the root"
|
|
28386
|
+
});
|
|
28387
|
+
print(formatSyncStep(steps[steps.length - 1]));
|
|
28388
|
+
}
|
|
28389
|
+
continue;
|
|
28390
|
+
}
|
|
28391
|
+
for (const entry of await generateClaudeFiles({
|
|
28392
|
+
loaded: input.loaded,
|
|
28393
|
+
repoRoot: input.context.repoRoot,
|
|
28394
|
+
logger
|
|
28395
|
+
})) {
|
|
28396
|
+
if (entry.kind === "error") steps.push({
|
|
28397
|
+
capability: "local",
|
|
28398
|
+
step: entry.syncStep,
|
|
28399
|
+
status: "fail",
|
|
28400
|
+
message: entry.message
|
|
28401
|
+
});
|
|
28402
|
+
else steps.push(await runSyncStep("local", entry.syncStep, dryRun, async () => {
|
|
28403
|
+
await mkdir(dirname(join(gitRoot, entry.path)), { recursive: true });
|
|
28404
|
+
await writeFile(join(gitRoot, entry.path), entry.content, "utf8");
|
|
28405
|
+
}));
|
|
28406
|
+
print(formatSyncStep(steps[steps.length - 1]));
|
|
28407
|
+
}
|
|
28408
|
+
}
|
|
27929
28409
|
if (stepName === "wiki") {
|
|
27930
28410
|
const result = await runSyncWiki({
|
|
27931
28411
|
loaded: input.loaded,
|
|
@@ -28368,6 +28848,164 @@ const upgradeCommand = {
|
|
|
28368
28848
|
builder: (y) => y.command(upgradeNodeCommand).command(upgradeDepsCommand).command(groupMenu("upgrade")),
|
|
28369
28849
|
handler: () => {}
|
|
28370
28850
|
};
|
|
28851
|
+
// src/commands/upload-coverage/parse-uploads/parse-uploads.ts
|
|
28852
|
+
const MESSAGE = "uploads must be a JSON list of {\"flag\", \"files\"} with both set.";
|
|
28853
|
+
/**
|
|
28854
|
+
* Reads `--uploads`: a JSON list of `{ "flag": "utils", "files": "utils/*\/coverage/lcov.info" }`, where `files` is a
|
|
28855
|
+
* glob relative to the repo root or a list of them (the action's own input takes the single glob). Anything else is a
|
|
28856
|
+
* message, never a throw, so the run can report it as a row.
|
|
28857
|
+
*/
|
|
28858
|
+
function parseUploads(text) {
|
|
28859
|
+
let value;
|
|
28860
|
+
try {
|
|
28861
|
+
value = JSON.parse(text);
|
|
28862
|
+
} catch {
|
|
28863
|
+
return {
|
|
28864
|
+
ok: false,
|
|
28865
|
+
message: `${MESSAGE} It is not JSON.`
|
|
28866
|
+
};
|
|
28867
|
+
}
|
|
28868
|
+
if (!Array.isArray(value)) return {
|
|
28869
|
+
ok: false,
|
|
28870
|
+
message: MESSAGE
|
|
28871
|
+
};
|
|
28872
|
+
const uploads = [];
|
|
28873
|
+
for (const entry of value) {
|
|
28874
|
+
const item = typeof entry === "object" && entry !== null ? entry : {};
|
|
28875
|
+
const files = typeof item.files === "string" ? [item.files] : item.files;
|
|
28876
|
+
if (typeof item.flag !== "string" || item.flag === "" || !Array.isArray(files) || files.length === 0 || !files.every((file) => typeof file === "string" && file !== "")) return {
|
|
28877
|
+
ok: false,
|
|
28878
|
+
message: MESSAGE
|
|
28879
|
+
};
|
|
28880
|
+
uploads.push({
|
|
28881
|
+
flag: item.flag,
|
|
28882
|
+
files
|
|
28883
|
+
});
|
|
28884
|
+
}
|
|
28885
|
+
return {
|
|
28886
|
+
ok: true,
|
|
28887
|
+
uploads
|
|
28888
|
+
};
|
|
28889
|
+
}
|
|
28890
|
+
// src/commands/upload-coverage/run-upload-coverage/run-upload-coverage.ts
|
|
28891
|
+
/**
|
|
28892
|
+
* `holocron upload coverage` — uploads the repo's coverage reports through the `coverage` provider.
|
|
28893
|
+
*
|
|
28894
|
+
* `--uploads` is a JSON list of `{ flag, files }` (a glob relative to the repo root, or a list of them). The provider's
|
|
28895
|
+
* optional `Coverage.upload` does the work (for Codecov: the job's OIDC token, the Codecov CLI, the `SF:` rewrite, the
|
|
28896
|
+
* retries) and answers with names and counts; this command prints one row per flag and fails when a flag failed or,
|
|
28897
|
+
* without `--allow-empty`, when no group had a report. It never prints a token. `--dry-run` lists the groups and
|
|
28898
|
+
* uploads nothing (and loads no provider).
|
|
28899
|
+
*/
|
|
28900
|
+
const row = (id, status, detail, problems = []) => ({
|
|
28901
|
+
id,
|
|
28902
|
+
title: id,
|
|
28903
|
+
status,
|
|
28904
|
+
detail,
|
|
28905
|
+
problems
|
|
28906
|
+
});
|
|
28907
|
+
async function runUploadCoverage(input) {
|
|
28908
|
+
/* v8 ignore next -- the console is only used outside tests, which inject `print` */
|
|
28909
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
28910
|
+
const dryRun = Boolean(input.context.dryRun);
|
|
28911
|
+
const finish = (rows, uploaded = 0) => {
|
|
28912
|
+
printCheckRows(rows, print);
|
|
28913
|
+
const summary = summariseChecks(rows);
|
|
28914
|
+
printCheckSummary(summary, print);
|
|
28915
|
+
return {
|
|
28916
|
+
status: summary.fail > 0 ? "fail" : "ok",
|
|
28917
|
+
rows,
|
|
28918
|
+
uploaded
|
|
28919
|
+
};
|
|
28920
|
+
};
|
|
28921
|
+
print(style.header(`Holocron upload coverage${dryRun ? " (dry-run)" : ""}`));
|
|
28922
|
+
print("");
|
|
28923
|
+
const parsed = parseUploads(input.uploads);
|
|
28924
|
+
if (!parsed.ok) return finish([row("uploads", "fail", parsed.message)]);
|
|
28925
|
+
if (dryRun) return finish(parsed.uploads.map((group) => row(group.flag, "skip", `would upload files matching ${group.files.join(", ")}`)));
|
|
28926
|
+
const entry = input.loaded.resolved.providers.coverage;
|
|
28927
|
+
if (!entry) return finish([row("coverage", "fail", "no `coverage` provider: set `providers.coverage` (`\"codecov\"`) in holocron.config")]);
|
|
28928
|
+
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
28929
|
+
const loader = input.loader ?? new PluginLoader({
|
|
28930
|
+
...input.loaded.resolved,
|
|
28931
|
+
providers: { coverage: entry }
|
|
28932
|
+
}, input.context);
|
|
28933
|
+
/* v8 ignore stop */
|
|
28934
|
+
await loader.load();
|
|
28935
|
+
assertPluginsResolvable(loader, "upload coverage");
|
|
28936
|
+
if (!loader.has("coverage")) {
|
|
28937
|
+
const failure = loader.loadFailures().find((f) => f.key === "coverage");
|
|
28938
|
+
return finish([row("coverage", "fail", `the \`coverage\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
28939
|
+
}
|
|
28940
|
+
const provider = loader.get("coverage");
|
|
28941
|
+
if (!provider.upload) return finish([row("coverage", "fail", `the \`${provider.providerName}\` provider cannot upload coverage`)]);
|
|
28942
|
+
try {
|
|
28943
|
+
const result = await provider.upload({
|
|
28944
|
+
uploads: parsed.uploads,
|
|
28945
|
+
repoRoot: input.context.repoRoot,
|
|
28946
|
+
...input.allowEmpty ? { allowEmpty: true } : {}
|
|
28947
|
+
});
|
|
28948
|
+
const rows = result.flags.map((flag) => {
|
|
28949
|
+
if (flag.outcome === "uploaded") return row(flag.flag, "ok", `uploaded ${flag.files} file(s)`, flag.notes);
|
|
28950
|
+
if (flag.outcome === "skipped") return row(flag.flag, "skip", flag.notes.at(-1) ?? "skipped", flag.notes.slice(0, -1));
|
|
28951
|
+
return row(flag.flag, "fail", "the upload failed", flag.notes);
|
|
28952
|
+
});
|
|
28953
|
+
if (result.problem !== void 0 && !result.flags.some((flag) => flag.outcome === "failed")) rows.push(row("upload", "fail", result.problem));
|
|
28954
|
+
return finish(rows, result.uploaded);
|
|
28955
|
+
} catch (err) {
|
|
28956
|
+
return finish([row("upload", "fail", describeError(err))]);
|
|
28957
|
+
}
|
|
28958
|
+
}
|
|
28959
|
+
// src/commands/upload-coverage/write-step-output/write-step-output.ts
|
|
28960
|
+
/**
|
|
28961
|
+
* Appends `name=value` to the file GitHub Actions names in `GITHUB_OUTPUT`, so a later step reads it as
|
|
28962
|
+
* `steps.<id>.outputs.<name>`. Does nothing outside Actions (the variable is unset). Returns whether a line was written.
|
|
28963
|
+
*/
|
|
28964
|
+
function writeStepOutput(name, value, env = createEnvLookup(), append = appendFileSync) {
|
|
28965
|
+
const file = env.get("GITHUB_OUTPUT");
|
|
28966
|
+
if (file === void 0) return false;
|
|
28967
|
+
append(file, `${name}=${value}\n`);
|
|
28968
|
+
return true;
|
|
28969
|
+
}
|
|
28970
|
+
// src/commands/upload-coverage/upload-coverage.command.ts
|
|
28971
|
+
const uploadCoverageCommand = {
|
|
28972
|
+
command: "coverage",
|
|
28973
|
+
describe: "Upload the repo's coverage reports, one flag per group, through the coverage provider",
|
|
28974
|
+
builder: (y) => y.option("uploads", {
|
|
28975
|
+
type: "string",
|
|
28976
|
+
demandOption: true,
|
|
28977
|
+
describe: "JSON list of {\"flag\": \"utils\", \"files\": \"utils/*/coverage/lcov.info\"} (a glob from the repo root)"
|
|
28978
|
+
}).option("allow-empty", {
|
|
28979
|
+
type: "boolean",
|
|
28980
|
+
describe: "Let a run with no coverage file in any group finish quietly (an affected run that selected nothing)"
|
|
28981
|
+
}),
|
|
28982
|
+
handler: async (argv) => {
|
|
28983
|
+
const tokens = tokenContext(argv.token);
|
|
28984
|
+
if (!tokens) return;
|
|
28985
|
+
const loaded = await loadConfig(argv.cwd);
|
|
28986
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
28987
|
+
const report = await runUploadCoverage({
|
|
28988
|
+
loaded,
|
|
28989
|
+
context: {
|
|
28990
|
+
repoRoot: argv.cwd,
|
|
28991
|
+
dryRun: argv.dryRun,
|
|
28992
|
+
...tokens,
|
|
28993
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
28994
|
+
},
|
|
28995
|
+
uploads: argv.uploads,
|
|
28996
|
+
...argv.allowEmpty ? { allowEmpty: true } : {}
|
|
28997
|
+
});
|
|
28998
|
+
writeStepOutput("uploaded", report.uploaded);
|
|
28999
|
+
if (report.status === "fail") process.exitCode = 1;
|
|
29000
|
+
}
|
|
29001
|
+
};
|
|
29002
|
+
// src/commands/upload/upload.command.ts
|
|
29003
|
+
const uploadCommand = {
|
|
29004
|
+
command: "upload",
|
|
29005
|
+
describe: "Upload what a run produced (coverage reports) to the service that keeps it",
|
|
29006
|
+
builder: (y) => y.command(uploadCoverageCommand).command(groupMenu("upload")),
|
|
29007
|
+
handler: () => {}
|
|
29008
|
+
};
|
|
28371
29009
|
// src/cli/own-package-json.ts
|
|
28372
29010
|
/**
|
|
28373
29011
|
* The `name` and `version` of the package that `moduleUrl` belongs to, from the nearest `package.json` above it.
|
|
@@ -28444,7 +29082,7 @@ try {
|
|
|
28444
29082
|
org: argv.org
|
|
28445
29083
|
});
|
|
28446
29084
|
finishCommand = startCommand(name);
|
|
28447
|
-
}).command(cloneCommand).command(doctorCommand).command(installCommand).command(updateCommand).command(runCommand).command(showCommand).command(checkCommand).command(exportCommand).command(menuCommand(CLI_VERSION)).command(setupCommand).command(upgradeCommand).command(cleanupCommand).command(applyCommand).command(newCommand).command(listCommand).command(removeCommand).command(probeCommand).command(providerCommand).command(linkCommand).command(closeCommand).command(moveCommand).command(migrateCommand).command(devCommand).command(syncCommand).command(publishCommand).command(deployCommand).command(resolveCommand).command(reconcileCommand).strict().help().epilogue(`Execution contexts:
|
|
29085
|
+
}).command(cloneCommand).command(doctorCommand).command(installCommand).command(updateCommand).command(runCommand).command(showCommand).command(checkCommand).command(exportCommand).command(uploadCommand).command(menuCommand(CLI_VERSION)).command(setupCommand).command(upgradeCommand).command(cleanupCommand).command(applyCommand).command(newCommand).command(listCommand).command(removeCommand).command(probeCommand).command(providerCommand).command(linkCommand).command(closeCommand).command(moveCommand).command(migrateCommand).command(devCommand).command(syncCommand).command(publishCommand).command(deployCommand).command(resolveCommand).command(reconcileCommand).strict().help().epilogue(`Execution contexts:
|
|
28448
29086
|
global works from a bare 'npm i -g': ${commandsInContext("global").join(", ")}\n repo-aware needs ./holocron.config in cwd: ${commandsInContext("repo-aware").join(", ")}\n workspace also needs the plugin packages: ${commandsInContext("workspace").join(", ")}\n https://docs.theholocron.dev/holocron/execution-contexts`).fail((msg, err) => {
|
|
28449
29087
|
if (err instanceof Error && USER_FACING_ERRORS.has(err.name)) {
|
|
28450
29088
|
captureException(err);
|