@theholocron/cli 5.0.0-alpha.424 → 5.0.0-alpha.426
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/cli.mjs +394 -108
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +14 -0
- package/package.json +11 -11
package/dist/cli.mjs
CHANGED
|
@@ -21,7 +21,7 @@ import { readGitRemote, updateGitignore, upsertManagedBlock } from "@theholocron
|
|
|
21
21
|
import { bumpCatalogPins, discoverWorkspacePackages, parseCatalogs, readPackageJson, readPackageJsonSync, resolveWorkspaceGlobs } from "@theholocron/pkg-utils";
|
|
22
22
|
import { createCliLogger, createCliTelemetry } from "@theholocron/kyber/observability";
|
|
23
23
|
import { resolveAxiomFromEnv } from "@theholocron/observability/logger";
|
|
24
|
-
import { Separator, checkbox, confirm, input, select } from "@inquirer/prompts";
|
|
24
|
+
import { Separator, checkbox, confirm, input, password, select } from "@inquirer/prompts";
|
|
25
25
|
import { runCheckAgainstUrl } from "@theholocron/kyber/checks";
|
|
26
26
|
import { access, copyFile, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
27
27
|
import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
@@ -375,6 +375,28 @@ const ideasSyncEntry = {
|
|
|
375
375
|
skipOptions: ["yes"],
|
|
376
376
|
supportsDryRun: true
|
|
377
377
|
};
|
|
378
|
+
// src/commands/issue-create/issue-create.entry.ts
|
|
379
|
+
const issueCreateEntry = {
|
|
380
|
+
name: "new issue",
|
|
381
|
+
description: "File an issue in the repo's tracker",
|
|
382
|
+
positionals: [{
|
|
383
|
+
key: "title",
|
|
384
|
+
message: "Title:",
|
|
385
|
+
type: "input"
|
|
386
|
+
}],
|
|
387
|
+
options: [{
|
|
388
|
+
key: "body",
|
|
389
|
+
flag: "--body",
|
|
390
|
+
type: "input",
|
|
391
|
+
message: "Text:"
|
|
392
|
+
}],
|
|
393
|
+
skipOptions: [
|
|
394
|
+
"label",
|
|
395
|
+
"milestone",
|
|
396
|
+
"yes"
|
|
397
|
+
],
|
|
398
|
+
supportsDryRun: true
|
|
399
|
+
};
|
|
378
400
|
// src/commands/migrate/migrate-issue/migrate-issue.entry.ts
|
|
379
401
|
const migrateIssueEntry = {
|
|
380
402
|
name: "migrate issue",
|
|
@@ -1058,6 +1080,7 @@ const registry = createCommandRegistry([
|
|
|
1058
1080
|
},
|
|
1059
1081
|
ideasSyncEntry,
|
|
1060
1082
|
ideasPromoteEntry,
|
|
1083
|
+
issueCreateEntry,
|
|
1061
1084
|
{
|
|
1062
1085
|
name: "sync readme",
|
|
1063
1086
|
description: "Sync the Installation + Usage block in README.md from package.json",
|
|
@@ -2352,7 +2375,8 @@ const COMMAND_CONTEXTS = {
|
|
|
2352
2375
|
"sync github": "workspace",
|
|
2353
2376
|
"sync issues": "workspace",
|
|
2354
2377
|
"sync ideas": "workspace",
|
|
2355
|
-
"new spec": "workspace"
|
|
2378
|
+
"new spec": "workspace",
|
|
2379
|
+
"new issue": "workspace"
|
|
2356
2380
|
};
|
|
2357
2381
|
/**
|
|
2358
2382
|
* The context for a command name from `argv._`. Falls back to the leading
|
|
@@ -6591,12 +6615,12 @@ async function runDoctorTokens(input) {
|
|
|
6591
6615
|
try {
|
|
6592
6616
|
module = await importer(pkg);
|
|
6593
6617
|
} catch (err) {
|
|
6594
|
-
rows.push(row$
|
|
6618
|
+
rows.push(row$12(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
|
|
6595
6619
|
continue;
|
|
6596
6620
|
}
|
|
6597
6621
|
for (const token of module.tokens ?? []) rows.push(await checkToken$1(token, module, env, readToken, now()));
|
|
6598
6622
|
}
|
|
6599
|
-
if (rows.length === 0) rows.push(row$
|
|
6623
|
+
if (rows.length === 0) rows.push(row$12("tokens", "skip", "no configured plugin lists the tokens it takes"));
|
|
6600
6624
|
printCheckRows(rows, print);
|
|
6601
6625
|
const summary = summariseChecks(rows);
|
|
6602
6626
|
printCheckSummary(summary, print);
|
|
@@ -6628,11 +6652,11 @@ async function loadCredentials(input) {
|
|
|
6628
6652
|
try {
|
|
6629
6653
|
await loader.load();
|
|
6630
6654
|
} catch (err) {
|
|
6631
|
-
return [row$
|
|
6655
|
+
return [row$12("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
|
|
6632
6656
|
}
|
|
6633
|
-
return loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$
|
|
6657
|
+
return loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$12(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
|
|
6634
6658
|
}
|
|
6635
|
-
function row$
|
|
6659
|
+
function row$12(id, status, detail) {
|
|
6636
6660
|
return {
|
|
6637
6661
|
id,
|
|
6638
6662
|
title: id,
|
|
@@ -6646,21 +6670,21 @@ async function checkToken$1(token, module, env, readToken, now) {
|
|
|
6646
6670
|
const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
|
|
6647
6671
|
const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
|
|
6648
6672
|
const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
|
|
6649
|
-
if (!value) return row$
|
|
6673
|
+
if (!value) return row$12(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
|
|
6650
6674
|
const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
|
|
6651
|
-
if (!verify) return row$
|
|
6675
|
+
if (!verify) return row$12(keyringKey, "skip", "set, but its plugin cannot verify it");
|
|
6652
6676
|
const from = fromEnv ?? stored?.source ?? "keyring";
|
|
6653
6677
|
try {
|
|
6654
6678
|
const verified = await verify(value);
|
|
6655
|
-
if (!verified.ok) return row$
|
|
6679
|
+
if (!verified.ok) return row$12(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
|
|
6656
6680
|
const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
|
|
6657
|
-
if (!expiry) return row$
|
|
6681
|
+
if (!expiry) return row$12(keyringKey, "ok", `${verified.subject} (${from})`);
|
|
6658
6682
|
return expiry.soon ? {
|
|
6659
|
-
...row$
|
|
6683
|
+
...row$12(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
|
|
6660
6684
|
problems: [`${expiry.text}: renew it`]
|
|
6661
|
-
} : row$
|
|
6685
|
+
} : row$12(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
|
|
6662
6686
|
} catch (err) {
|
|
6663
|
-
return row$
|
|
6687
|
+
return row$12(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
|
|
6664
6688
|
}
|
|
6665
6689
|
}
|
|
6666
6690
|
// src/commands/doctor-tokens/doctor-tokens.command.ts
|
|
@@ -6719,7 +6743,7 @@ async function runDoctorCredentials(input) {
|
|
|
6719
6743
|
};
|
|
6720
6744
|
}
|
|
6721
6745
|
/** A row for the provider as a whole, or for one of its variables when `name` is given. */
|
|
6722
|
-
function row$
|
|
6746
|
+
function row$11(provider, status, detail, name) {
|
|
6723
6747
|
return name === void 0 ? {
|
|
6724
6748
|
id: provider,
|
|
6725
6749
|
title: provider,
|
|
@@ -6736,8 +6760,8 @@ function row$10(provider, status, detail, name) {
|
|
|
6736
6760
|
}
|
|
6737
6761
|
async function checkCredentials(input, loader) {
|
|
6738
6762
|
const { resolved } = input.loaded;
|
|
6739
|
-
if (!resolved.providers.credentials) return [row$
|
|
6740
|
-
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$
|
|
6763
|
+
if (!resolved.providers.credentials) return [row$11("credentials", "skip", "no `credentials` provider is configured")];
|
|
6764
|
+
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$11(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
|
|
6741
6765
|
if (!loader.has("credentials")) return rows;
|
|
6742
6766
|
const expected = await expectedTokens(input);
|
|
6743
6767
|
const { tuples } = resolved.providers.credentials;
|
|
@@ -6745,7 +6769,7 @@ async function checkCredentials(input, loader) {
|
|
|
6745
6769
|
const tuple = tuples.find((t) => t.provider === impl.providerName);
|
|
6746
6770
|
const explicit = tuple && credentialsEnvironment(tuple, resolved);
|
|
6747
6771
|
if (!explicit && !derivesEnvironment(impl.providerName)) {
|
|
6748
|
-
rows.push(row$
|
|
6772
|
+
rows.push(row$11(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
|
|
6749
6773
|
continue;
|
|
6750
6774
|
}
|
|
6751
6775
|
try {
|
|
@@ -6756,7 +6780,7 @@ async function checkCredentials(input, loader) {
|
|
|
6756
6780
|
});
|
|
6757
6781
|
rows.push(...await checkProvider(impl, candidates, expected));
|
|
6758
6782
|
} catch (err) {
|
|
6759
|
-
rows.push(row$
|
|
6783
|
+
rows.push(row$11(impl.providerName, "fail", errorMessage(err)));
|
|
6760
6784
|
}
|
|
6761
6785
|
}
|
|
6762
6786
|
return rows;
|
|
@@ -6768,25 +6792,25 @@ async function checkCredentials(input, loader) {
|
|
|
6768
6792
|
*/
|
|
6769
6793
|
async function checkProvider(impl, candidates, expected) {
|
|
6770
6794
|
const provider = impl.providerName;
|
|
6771
|
-
if (!impl.inspect) return [row$
|
|
6772
|
-
if (expected.length === 0) return [row$
|
|
6773
|
-
if (candidates.length === 0) return [row$
|
|
6795
|
+
if (!impl.inspect) return [row$11(provider, "skip", "cannot list the variables without reading their values")];
|
|
6796
|
+
if (expected.length === 0) return [row$11(provider, "skip", "no configured plugin lists the tokens it takes")];
|
|
6797
|
+
if (candidates.length === 0) return [row$11(provider, "skip", "the `test` layer reads no Environment")];
|
|
6774
6798
|
const inspect = impl.inspect.bind(impl);
|
|
6775
6799
|
try {
|
|
6776
6800
|
const { found, missing } = await tryEnvironments(candidates, inspect);
|
|
6777
|
-
const rows = missing.map((name) => row$
|
|
6801
|
+
const rows = missing.map((name) => row$11(provider, "fail", `${provider} has no Environment named "${name}"`));
|
|
6778
6802
|
const labels = found.map(({ name, result }) => result.environment === name ? `"${name}"` : `"${result.environment}" (the config writes "${name}")`);
|
|
6779
6803
|
const where = labels.join(", ");
|
|
6780
6804
|
if (found.length === 0) return rows;
|
|
6781
6805
|
for (const { name, optional } of expected) {
|
|
6782
6806
|
const at = found.findIndex((f) => f.result.names.includes(name));
|
|
6783
|
-
if (at >= 0) rows.push(row$
|
|
6784
|
-
else if (optional) rows.push(row$
|
|
6785
|
-
else rows.push(row$
|
|
6807
|
+
if (at >= 0) rows.push(row$11(provider, "ok", `present in ${labels[at]}`, name));
|
|
6808
|
+
else if (optional) rows.push(row$11(provider, "skip", `optional, not set in ${where}`, name));
|
|
6809
|
+
else rows.push(row$11(provider, "fail", `missing from ${where}`, name));
|
|
6786
6810
|
}
|
|
6787
6811
|
return rows;
|
|
6788
6812
|
} catch (err) {
|
|
6789
|
-
return [row$
|
|
6813
|
+
return [row$11(provider, "fail", errorMessage(err))];
|
|
6790
6814
|
}
|
|
6791
6815
|
}
|
|
6792
6816
|
/**
|
|
@@ -7076,7 +7100,7 @@ async function runDoctorDns(input) {
|
|
|
7076
7100
|
});
|
|
7077
7101
|
else if (!loader.has("dns")) {
|
|
7078
7102
|
const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
|
|
7079
|
-
for (const zone of zones) rows.push(row$
|
|
7103
|
+
for (const zone of zones) rows.push(row$10(zone, "skip", why));
|
|
7080
7104
|
for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
|
|
7081
7105
|
} else {
|
|
7082
7106
|
const dns = loader.get("dns");
|
|
@@ -7098,7 +7122,7 @@ async function runDoctorDns(input) {
|
|
|
7098
7122
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
7099
7123
|
};
|
|
7100
7124
|
}
|
|
7101
|
-
function row$
|
|
7125
|
+
function row$10(zone, status, detail, problems = []) {
|
|
7102
7126
|
return {
|
|
7103
7127
|
id: `dns-${zone}`,
|
|
7104
7128
|
title: `${zone} records exist`,
|
|
@@ -7127,7 +7151,7 @@ async function checkDomain(dns, deploy, project, hostname) {
|
|
|
7127
7151
|
return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
|
|
7128
7152
|
}
|
|
7129
7153
|
}
|
|
7130
|
-
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$
|
|
7154
|
+
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$10(zone, ...args)) {
|
|
7131
7155
|
try {
|
|
7132
7156
|
const have = await dns.listRecords(zone);
|
|
7133
7157
|
const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
|
|
@@ -7262,7 +7286,7 @@ function installationSettingsUrl(account, id) {
|
|
|
7262
7286
|
return `https://github.com/settings/installations/${id}`;
|
|
7263
7287
|
}
|
|
7264
7288
|
// src/commands/doctor-github-app/app-rows.ts
|
|
7265
|
-
const row$
|
|
7289
|
+
const row$9 = (name, what, problems, ok) => ({
|
|
7266
7290
|
id: `${name}:${what}`,
|
|
7267
7291
|
title: `${name}: ${what}`,
|
|
7268
7292
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -7289,9 +7313,9 @@ function appRows(name, manifest, app, installations) {
|
|
|
7289
7313
|
return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
|
|
7290
7314
|
});
|
|
7291
7315
|
return [
|
|
7292
|
-
row$
|
|
7293
|
-
row$
|
|
7294
|
-
row$
|
|
7316
|
+
row$9(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
|
|
7317
|
+
row$9(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
|
|
7318
|
+
row$9(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
|
|
7295
7319
|
];
|
|
7296
7320
|
}
|
|
7297
7321
|
// src/commands/doctor-github-app/parse-manifest.ts
|
|
@@ -7349,7 +7373,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
7349
7373
|
assertPluginsResolvable$1(loader, "doctor github-app");
|
|
7350
7374
|
}
|
|
7351
7375
|
const rows = [];
|
|
7352
|
-
if (instances.length === 0) rows.push(row$
|
|
7376
|
+
if (instances.length === 0) rows.push(row$8("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
|
|
7353
7377
|
for (const instance of instances) rows.push(...await checkInstance(instance, loader, input));
|
|
7354
7378
|
printCheckRows(rows, print);
|
|
7355
7379
|
const summary = summariseChecks(rows);
|
|
@@ -7366,7 +7390,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
7366
7390
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
7367
7391
|
};
|
|
7368
7392
|
}
|
|
7369
|
-
function row$
|
|
7393
|
+
function row$8(name, what, status, detail) {
|
|
7370
7394
|
return {
|
|
7371
7395
|
id: `${name}:${what}`,
|
|
7372
7396
|
title: `${name}: ${what}`,
|
|
@@ -7407,19 +7431,19 @@ async function checkInstance(instance, loader, input) {
|
|
|
7407
7431
|
try {
|
|
7408
7432
|
manifest = parseManifest(readManifest(instance.manifest));
|
|
7409
7433
|
} catch (err) {
|
|
7410
|
-
return [row$
|
|
7434
|
+
return [row$8(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
|
|
7411
7435
|
}
|
|
7412
7436
|
const read = await readCredentials(instance, loader);
|
|
7413
|
-
if ("reason" in read) return [row$
|
|
7437
|
+
if ("reason" in read) return [row$8(name, "reachable", "skip", read.reason)];
|
|
7414
7438
|
const api = input.api ?? defaultApi;
|
|
7415
7439
|
const secrets = [read.creds.privateKey];
|
|
7416
7440
|
try {
|
|
7417
7441
|
const app = await api.getApp(read.creds);
|
|
7418
7442
|
const installations = await api.listAppInstallations(read.creds);
|
|
7419
7443
|
const owner = app.owner ? `, owned by ${app.owner.login}` : "";
|
|
7420
|
-
return [row$
|
|
7444
|
+
return [row$8(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
|
|
7421
7445
|
} catch (err) {
|
|
7422
|
-
return [row$
|
|
7446
|
+
return [row$8(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
|
|
7423
7447
|
}
|
|
7424
7448
|
}
|
|
7425
7449
|
// src/commands/doctor-github-app/doctor-github-app.command.ts
|
|
@@ -7486,7 +7510,7 @@ function datasetTargets(config) {
|
|
|
7486
7510
|
* dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
|
|
7487
7511
|
* a name, a token or a response that cannot be read is a skip with the reason.
|
|
7488
7512
|
*/
|
|
7489
|
-
const row$
|
|
7513
|
+
const row$7 = (id, title, status, detail, problems = []) => ({
|
|
7490
7514
|
id,
|
|
7491
7515
|
title,
|
|
7492
7516
|
status,
|
|
@@ -7503,7 +7527,7 @@ async function runDoctorLogs(input) {
|
|
|
7503
7527
|
if (!loader.has("logs")) {
|
|
7504
7528
|
const failure = loader.loadFailures().find((f) => f.key === "logs");
|
|
7505
7529
|
const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
|
|
7506
|
-
rows.push(row$
|
|
7530
|
+
rows.push(row$7("logs", "logs", "skip", why));
|
|
7507
7531
|
} else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
|
|
7508
7532
|
printCheckRows(rows, print);
|
|
7509
7533
|
const summary = summariseChecks(rows);
|
|
@@ -7527,38 +7551,38 @@ async function checkLogs(logs, targets) {
|
|
|
7527
7551
|
for (const target of targets) {
|
|
7528
7552
|
const id = `logs:dataset:${target.id}`;
|
|
7529
7553
|
const title = `dataset for ${target.label}`;
|
|
7530
|
-
if (!target.name) rows.push(row$
|
|
7531
|
-
else if (!token.usable) rows.push(row$
|
|
7532
|
-
else if (!logs.readDataset) rows.push(row$
|
|
7554
|
+
if (!target.name) rows.push(row$7(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
|
|
7555
|
+
else if (!token.usable) rows.push(row$7(id, title, "skip", `${target.name}: not checked, the token is not usable`));
|
|
7556
|
+
else if (!logs.readDataset) rows.push(row$7(id, title, "skip", `${logs.providerName} cannot read a dataset`));
|
|
7533
7557
|
else rows.push(...await checkDataset(logs, target, target.name, id, title));
|
|
7534
7558
|
}
|
|
7535
7559
|
const org = resolveValue$2(["AXIOM_ORG"], void 0, { prefix: PREFIX });
|
|
7536
|
-
rows.push(org ? row$
|
|
7560
|
+
rows.push(org ? row$7("logs:org", "organization", "ok", `${PREFIX}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$7("logs:org", "organization", "skip", `${PREFIX}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links and check-dispatched need it`));
|
|
7537
7561
|
return rows;
|
|
7538
7562
|
}
|
|
7539
7563
|
/** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
|
|
7540
7564
|
async function checkToken(logs) {
|
|
7541
7565
|
const title = "token is accepted";
|
|
7542
7566
|
if (!logs.checkToken) return {
|
|
7543
|
-
row: row$
|
|
7567
|
+
row: row$7("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
|
|
7544
7568
|
usable: true
|
|
7545
7569
|
};
|
|
7546
7570
|
try {
|
|
7547
7571
|
const result = await logs.checkToken();
|
|
7548
7572
|
if (result.ok) return {
|
|
7549
|
-
row: row$
|
|
7573
|
+
row: row$7("logs:token", title, "ok", `${logs.providerName} accepts the token`),
|
|
7550
7574
|
usable: true
|
|
7551
7575
|
};
|
|
7552
7576
|
const reason = result.reason ?? `${logs.providerName} refused the token`;
|
|
7553
7577
|
return {
|
|
7554
|
-
row: row$
|
|
7578
|
+
row: row$7("logs:token", title, "fail", reason, [reason]),
|
|
7555
7579
|
usable: false
|
|
7556
7580
|
};
|
|
7557
7581
|
} catch (err) {
|
|
7558
7582
|
const noToken = missingTokenReason(err);
|
|
7559
7583
|
const detail = noToken ?? `could not check the token: ${describeError(err)}`;
|
|
7560
7584
|
return {
|
|
7561
|
-
row: row$
|
|
7585
|
+
row: row$7("logs:token", title, "skip", detail),
|
|
7562
7586
|
usable: noToken === void 0
|
|
7563
7587
|
};
|
|
7564
7588
|
}
|
|
@@ -7568,13 +7592,13 @@ async function checkDataset(logs, target, name, id, title) {
|
|
|
7568
7592
|
const found = await logs.readDataset(name);
|
|
7569
7593
|
if (!found.exists) {
|
|
7570
7594
|
const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
|
|
7571
|
-
return [row$
|
|
7595
|
+
return [row$7(id, title, "fail", `${name} does not exist`, [problem])];
|
|
7572
7596
|
}
|
|
7573
7597
|
const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
|
|
7574
|
-
return [row$
|
|
7598
|
+
return [row$7(id, title, "ok", `${name} exists`), row$7(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
|
|
7575
7599
|
} catch (err) {
|
|
7576
7600
|
const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
|
|
7577
|
-
return [row$
|
|
7601
|
+
return [row$7(id, title, "skip", detail)];
|
|
7578
7602
|
}
|
|
7579
7603
|
}
|
|
7580
7604
|
// src/commands/doctor-logs/doctor-logs.command.ts
|
|
@@ -10516,7 +10540,7 @@ const info = (id, title, noun, extras) => ({
|
|
|
10516
10540
|
detail: `info: ${extras.length} ${noun} not in the template (never deleted)`,
|
|
10517
10541
|
problems: extras
|
|
10518
10542
|
});
|
|
10519
|
-
const row$
|
|
10543
|
+
const row$6 = (id, title, problems, ok) => ({
|
|
10520
10544
|
id,
|
|
10521
10545
|
title,
|
|
10522
10546
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -10552,19 +10576,19 @@ function viewProblems(want, found) {
|
|
|
10552
10576
|
function boardRows(boardName, template, state) {
|
|
10553
10577
|
const id = `project:${boardName}`;
|
|
10554
10578
|
const rows = [];
|
|
10555
|
-
rows.push(row$
|
|
10579
|
+
rows.push(row$6(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
|
|
10556
10580
|
const extraStatuses = state.statuses.filter((s) => !template.statuses.some((t) => t.name === s));
|
|
10557
10581
|
if (extraStatuses.length > 0) rows.push(info(`${id}:extra-statuses`, `${boardName}: extra statuses`, "status(es)", extraStatuses));
|
|
10558
|
-
for (const want of template.fields) rows.push(row$
|
|
10582
|
+
for (const want of template.fields) rows.push(row$6(`${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));
|
|
10559
10583
|
const extraFields = state.fields.filter((f) => !template.fields.some((t) => t.name === f.name));
|
|
10560
10584
|
if (extraFields.length > 0) rows.push(info(`${id}:extra-fields`, `${boardName}: extra fields`, "field(s)", extraFields.map((f) => f.name)));
|
|
10561
|
-
for (const want of template.views) rows.push(row$
|
|
10585
|
+
for (const want of template.views) rows.push(row$6(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
|
|
10562
10586
|
const extraViews = state.views.filter((v) => !template.views.some((t) => t.name === v.name));
|
|
10563
10587
|
if (extraViews.length > 0) rows.push(info(`${id}:extra-views`, `${boardName}: extra views`, "view(s)", extraViews.map((v) => v.name)));
|
|
10564
10588
|
for (const name of template.rules ?? []) {
|
|
10565
10589
|
const found = state.rules.find((r) => r.name === name);
|
|
10566
10590
|
const problems = !found ? [`missing rule ${name}`] : found.enabled ? [] : [`rule ${name} is off`];
|
|
10567
|
-
rows.push(row$
|
|
10591
|
+
rows.push(row$6(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
|
|
10568
10592
|
}
|
|
10569
10593
|
return rows;
|
|
10570
10594
|
}
|
|
@@ -10624,7 +10648,7 @@ function itemRows(boardName, items) {
|
|
|
10624
10648
|
* never fail the run. A template file that does not read is a failure naming the file. `--post [channel]` shares the
|
|
10625
10649
|
* failing rows through the `notifications` provider's bot, like `doctor notifications --post`.
|
|
10626
10650
|
*/
|
|
10627
|
-
const row$
|
|
10651
|
+
const row$5 = (id, title, status, detail, problems = []) => ({
|
|
10628
10652
|
id,
|
|
10629
10653
|
title,
|
|
10630
10654
|
status,
|
|
@@ -10678,14 +10702,14 @@ async function checkBoards(input, loader) {
|
|
|
10678
10702
|
loader,
|
|
10679
10703
|
...input.io ? { io: input.io } : {}
|
|
10680
10704
|
});
|
|
10681
|
-
if (!opened.ok) return [row$
|
|
10705
|
+
if (!opened.ok) return [row$5("project", "project", opened.kind, opened.reason, opened.problems)];
|
|
10682
10706
|
const { projects, owner, boards, templates, templateProblems } = opened.context;
|
|
10683
10707
|
const rows = templateProblems.map((problem) => {
|
|
10684
10708
|
/* v8 ignore next -- split always returns at least one element; the fallback only satisfies noUncheckedIndexedAccess */
|
|
10685
10709
|
const file = problem.split(": ")[0] ?? problem;
|
|
10686
|
-
return row$
|
|
10710
|
+
return row$5(`project:template:${file}`, `template file ${file}`, "fail", problem);
|
|
10687
10711
|
});
|
|
10688
|
-
if (boards.length === 0) return [...rows, row$
|
|
10712
|
+
if (boards.length === 0) return [...rows, row$5("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
|
|
10689
10713
|
for (const declared of boards) {
|
|
10690
10714
|
const template = templates[declared.template];
|
|
10691
10715
|
const title = `${declared.name}: board exists and is open`;
|
|
@@ -10693,18 +10717,18 @@ async function checkBoards(input, loader) {
|
|
|
10693
10717
|
const board = await projects.find(owner, declared.name);
|
|
10694
10718
|
if (!board) {
|
|
10695
10719
|
const closed = (await projects.list(owner)).some((b) => b.name === declared.name && b.closed);
|
|
10696
|
-
rows.push(row$
|
|
10720
|
+
rows.push(row$5(`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`"]));
|
|
10697
10721
|
continue;
|
|
10698
10722
|
}
|
|
10699
|
-
rows.push(row$
|
|
10723
|
+
rows.push(row$5(`project:${declared.name}`, title, "ok", board.url));
|
|
10700
10724
|
if (!template) {
|
|
10701
|
-
rows.push(row$
|
|
10725
|
+
rows.push(row$5(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
|
|
10702
10726
|
continue;
|
|
10703
10727
|
}
|
|
10704
10728
|
rows.push(...boardRows(declared.name, template, await projects.read(owner, board)));
|
|
10705
|
-
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$
|
|
10729
|
+
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$5(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
|
|
10706
10730
|
} catch (err) {
|
|
10707
|
-
rows.push(row$
|
|
10731
|
+
rows.push(row$5(`project:${declared.name}`, title, "fail", describeError(err)));
|
|
10708
10732
|
}
|
|
10709
10733
|
}
|
|
10710
10734
|
return rows;
|
|
@@ -11378,19 +11402,19 @@ async function runDoctorRepo(input) {
|
|
|
11378
11402
|
const rows = [];
|
|
11379
11403
|
if (!loader.has("source")) {
|
|
11380
11404
|
const why = whyMissing(loader, "source", "no `source` provider to read the repository with");
|
|
11381
|
-
for (const check of checks) rows.push(row$
|
|
11405
|
+
for (const check of checks) rows.push(row$4(check, { skip: why }));
|
|
11382
11406
|
} else {
|
|
11383
11407
|
const source = loader.get("source");
|
|
11384
11408
|
for (const check of checks) {
|
|
11385
11409
|
if (typeof source[check.needs] !== "function") {
|
|
11386
|
-
rows.push(row$
|
|
11410
|
+
rows.push(row$4(check, { skip: `provider does not implement ${check.needs}` }));
|
|
11387
11411
|
continue;
|
|
11388
11412
|
}
|
|
11389
11413
|
try {
|
|
11390
|
-
rows.push(row$
|
|
11414
|
+
rows.push(row$4(check, await check.run(source)));
|
|
11391
11415
|
} catch (err) {
|
|
11392
11416
|
const noToken = missingTokenReason(err);
|
|
11393
|
-
if (noToken !== void 0) rows.push(row$
|
|
11417
|
+
if (noToken !== void 0) rows.push(row$4(check, { skip: noToken }));
|
|
11394
11418
|
else rows.push({
|
|
11395
11419
|
id: check.id,
|
|
11396
11420
|
title: check.title,
|
|
@@ -11416,7 +11440,7 @@ async function runDoctorRepo(input) {
|
|
|
11416
11440
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
11417
11441
|
};
|
|
11418
11442
|
}
|
|
11419
|
-
function row$
|
|
11443
|
+
function row$4(check, result) {
|
|
11420
11444
|
const { id, title } = check;
|
|
11421
11445
|
if ("skip" in result) return {
|
|
11422
11446
|
id,
|
|
@@ -12708,14 +12732,14 @@ async function runDoctorVariables(input) {
|
|
|
12708
12732
|
});
|
|
12709
12733
|
else if (!loader.has("source")) {
|
|
12710
12734
|
const why = whyMissing(loader, "source", "no `source` provider to read them with");
|
|
12711
|
-
for (const check of checks) rows.push(row$
|
|
12735
|
+
for (const check of checks) rows.push(row$3(check, { skip: why }));
|
|
12712
12736
|
} else {
|
|
12713
12737
|
const source = loader.get("source");
|
|
12714
12738
|
for (const check of checks) try {
|
|
12715
|
-
rows.push(row$
|
|
12739
|
+
rows.push(row$3(check, await check.run(source)));
|
|
12716
12740
|
} catch (err) {
|
|
12717
12741
|
const noToken = missingTokenReason(err);
|
|
12718
|
-
if (noToken !== void 0) rows.push(row$
|
|
12742
|
+
if (noToken !== void 0) rows.push(row$3(check, { skip: noToken }));
|
|
12719
12743
|
else rows.push({
|
|
12720
12744
|
id: check.id,
|
|
12721
12745
|
title: check.title,
|
|
@@ -12740,7 +12764,7 @@ async function runDoctorVariables(input) {
|
|
|
12740
12764
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
12741
12765
|
};
|
|
12742
12766
|
}
|
|
12743
|
-
function row$
|
|
12767
|
+
function row$3(check, result) {
|
|
12744
12768
|
const { id, title } = check;
|
|
12745
12769
|
if ("skip" in result) return {
|
|
12746
12770
|
id,
|
|
@@ -17032,8 +17056,8 @@ function specName(title, name) {
|
|
|
17032
17056
|
* `--yes` (without a terminal it refuses instead).
|
|
17033
17057
|
*/
|
|
17034
17058
|
/** How many lines of the spec a dry run shows. */
|
|
17035
|
-
const PREVIEW_LINES = 12;
|
|
17036
|
-
const row$
|
|
17059
|
+
const PREVIEW_LINES$1 = 12;
|
|
17060
|
+
const row$2 = (id, status, detail) => ({
|
|
17037
17061
|
id,
|
|
17038
17062
|
title: id,
|
|
17039
17063
|
status,
|
|
@@ -17063,7 +17087,7 @@ async function runIdeasPromote(input) {
|
|
|
17063
17087
|
print(style.header(`Holocron new spec${dryRun ? " (dry-run)" : ""}`));
|
|
17064
17088
|
print("");
|
|
17065
17089
|
const entry = input.loaded.resolved.providers.issues;
|
|
17066
|
-
if (!entry) return finish([row$
|
|
17090
|
+
if (!entry) return finish([row$2(input.issue, "fail", "the config has no `issues` provider to read the issue with")]);
|
|
17067
17091
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
17068
17092
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
17069
17093
|
const loader = input.loader ?? new PluginLoader({
|
|
@@ -17078,18 +17102,18 @@ async function runIdeasPromote(input) {
|
|
|
17078
17102
|
assertPluginsResolvable$1(loader, "new spec");
|
|
17079
17103
|
if (!loader.has("issues")) {
|
|
17080
17104
|
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
17081
|
-
return finish([row$
|
|
17105
|
+
return finish([row$2(input.issue, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
17082
17106
|
}
|
|
17083
17107
|
let issue;
|
|
17084
17108
|
try {
|
|
17085
17109
|
issue = await loader.get("issues").get(input.issue);
|
|
17086
17110
|
} catch (err) {
|
|
17087
|
-
return finish([row$
|
|
17111
|
+
return finish([row$2(input.issue, "fail", `could not read the issue: ${describeError(err)}`)]);
|
|
17088
17112
|
}
|
|
17089
17113
|
const name = specName(issue.summary, input.name);
|
|
17090
|
-
if (!name) return finish([row$
|
|
17114
|
+
if (!name) return finish([row$2(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`)]);
|
|
17091
17115
|
const relative = join(".notes", `${name}.spec.md`);
|
|
17092
|
-
if (io.exists(join(input.context.repoRoot, relative))) return finish([row$
|
|
17116
|
+
if (io.exists(join(input.context.repoRoot, relative))) return finish([row$2(relative, "fail", "the spec already exists; it is never overwritten")], relative);
|
|
17093
17117
|
const { org, name: repoName } = input.loaded.resolved;
|
|
17094
17118
|
const ref = githubRef(issue.url) ?? (issue.key.startsWith("#") ? `${org}/${repoName}${issue.key}` : issue.key);
|
|
17095
17119
|
const { content, fromIdea } = buildSpec({
|
|
@@ -17100,9 +17124,9 @@ async function runIdeasPromote(input) {
|
|
|
17100
17124
|
const origin = fromIdea ? `from ${issue.key}, which carries the idea marker` : `from ${issue.key}, which has no \`Filed from idea:\` marker (its text is used as it is)`;
|
|
17101
17125
|
if (dryRun) {
|
|
17102
17126
|
print(` ${relative}`);
|
|
17103
|
-
for (const line of content.split("\n").slice(0, PREVIEW_LINES)) print(` ${style.skip(line)}`);
|
|
17127
|
+
for (const line of content.split("\n").slice(0, PREVIEW_LINES$1)) print(` ${style.skip(line)}`);
|
|
17104
17128
|
print("");
|
|
17105
|
-
return finish([row$
|
|
17129
|
+
return finish([row$2(relative, "skip", `would write the spec ${origin}`)], relative);
|
|
17106
17130
|
}
|
|
17107
17131
|
if (!input.yes) {
|
|
17108
17132
|
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`);
|
|
@@ -17121,9 +17145,9 @@ async function runIdeasPromote(input) {
|
|
|
17121
17145
|
try {
|
|
17122
17146
|
io.write(join(input.context.repoRoot, relative), content);
|
|
17123
17147
|
} catch (err) {
|
|
17124
|
-
return finish([row$
|
|
17148
|
+
return finish([row$2(relative, "fail", `could not write the spec: ${describeError(err)}`)], relative);
|
|
17125
17149
|
}
|
|
17126
|
-
return finish([row$
|
|
17150
|
+
return finish([row$2(relative, "ok", `wrote the spec ${origin}`)], relative);
|
|
17127
17151
|
}
|
|
17128
17152
|
// src/commands/ideas-promote/ideas-promote.command.ts
|
|
17129
17153
|
const ideasPromoteCommand = {
|
|
@@ -17159,6 +17183,138 @@ const ideasPromoteCommand = {
|
|
|
17159
17183
|
})).status === "fail") process.exitCode = 1;
|
|
17160
17184
|
}
|
|
17161
17185
|
};
|
|
17186
|
+
// src/commands/issue-create/run-issue-create/run-issue-create.ts
|
|
17187
|
+
/**
|
|
17188
|
+
* `holocron new issue` — files an issue through the repo's `issues` provider.
|
|
17189
|
+
*
|
|
17190
|
+
* The provider's `create` makes the issue (GitHub or Linear, whatever the config names), so the command knows nothing
|
|
17191
|
+
* of a tracker. It writes to a tracker, so it asks first unless `--dry-run` or `--yes` (without a terminal it refuses
|
|
17192
|
+
* instead). It does not look for a duplicate: filing the same title twice makes two issues.
|
|
17193
|
+
*/
|
|
17194
|
+
/** How many lines of the body a dry run shows. */
|
|
17195
|
+
const PREVIEW_LINES = 8;
|
|
17196
|
+
const row$1 = (id, status, detail) => ({
|
|
17197
|
+
id,
|
|
17198
|
+
title: id,
|
|
17199
|
+
status,
|
|
17200
|
+
detail,
|
|
17201
|
+
problems: []
|
|
17202
|
+
});
|
|
17203
|
+
async function runIssueCreate(input) {
|
|
17204
|
+
/* v8 ignore next -- the console is only used outside tests, which inject `print` */
|
|
17205
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
17206
|
+
const dryRun = Boolean(input.context.dryRun);
|
|
17207
|
+
const finish = (rows, key) => {
|
|
17208
|
+
printCheckRows(rows, print);
|
|
17209
|
+
const summary = summariseChecks(rows);
|
|
17210
|
+
printCheckSummary(summary, print);
|
|
17211
|
+
return {
|
|
17212
|
+
status: summary.fail > 0 ? "fail" : "ok",
|
|
17213
|
+
rows,
|
|
17214
|
+
...key ? { key } : {}
|
|
17215
|
+
};
|
|
17216
|
+
};
|
|
17217
|
+
print(style.header(`Holocron new issue${dryRun ? " (dry-run)" : ""}`));
|
|
17218
|
+
print("");
|
|
17219
|
+
const title = input.title.trim();
|
|
17220
|
+
if (!title) return finish([row$1("title", "fail", "the title is empty")]);
|
|
17221
|
+
const entry = input.loaded.resolved.providers.issues;
|
|
17222
|
+
if (!entry) return finish([row$1(title, "fail", "the config has no `issues` provider to file the issue with")]);
|
|
17223
|
+
const credentials = input.loaded.resolved.providers.credentials;
|
|
17224
|
+
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
17225
|
+
const loader = input.loader ?? new PluginLoader({
|
|
17226
|
+
...input.loaded.resolved,
|
|
17227
|
+
providers: {
|
|
17228
|
+
issues: entry,
|
|
17229
|
+
...credentials ? { credentials } : {}
|
|
17230
|
+
}
|
|
17231
|
+
}, input.context);
|
|
17232
|
+
/* v8 ignore stop */
|
|
17233
|
+
await loader.load();
|
|
17234
|
+
assertPluginsResolvable$1(loader, "new issue");
|
|
17235
|
+
if (!loader.has("issues")) {
|
|
17236
|
+
const failure = loader.loadFailures().find((f) => f.key === "issues");
|
|
17237
|
+
return finish([row$1(title, "fail", `the \`issues\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
17238
|
+
}
|
|
17239
|
+
const labels = [...new Set((input.labels ?? []).map((l) => l.trim()).filter(Boolean))];
|
|
17240
|
+
const body = input.body?.trim() ? input.body : void 0;
|
|
17241
|
+
const milestone = input.milestone?.trim() ? input.milestone.trim() : void 0;
|
|
17242
|
+
const details = [labels.length > 0 ? `labels: ${labels.join(", ")}` : void 0, milestone ? `milestone: ${milestone}` : void 0].filter(Boolean);
|
|
17243
|
+
const summary = details.length > 0 ? ` (${details.join("; ")})` : "";
|
|
17244
|
+
if (dryRun) {
|
|
17245
|
+
print(` ${title}`);
|
|
17246
|
+
for (const line of (body ?? "").split("\n").slice(0, PREVIEW_LINES)) print(` ${style.skip(line)}`);
|
|
17247
|
+
print("");
|
|
17248
|
+
return finish([row$1(title, "skip", `would file the issue${summary}`)]);
|
|
17249
|
+
}
|
|
17250
|
+
if (!input.yes) {
|
|
17251
|
+
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");
|
|
17252
|
+
if (!await (input.confirm ?? ((message) => confirm({
|
|
17253
|
+
message,
|
|
17254
|
+
default: false
|
|
17255
|
+
})))(`File "${title}"${summary}?`)) {
|
|
17256
|
+
print(` ${style.skip("cancelled; nothing was filed")}`);
|
|
17257
|
+
return {
|
|
17258
|
+
status: "cancelled",
|
|
17259
|
+
rows: []
|
|
17260
|
+
};
|
|
17261
|
+
}
|
|
17262
|
+
}
|
|
17263
|
+
try {
|
|
17264
|
+
const { key } = await loader.get("issues").create({
|
|
17265
|
+
summary: title,
|
|
17266
|
+
...body ? { body } : {},
|
|
17267
|
+
...labels.length > 0 ? { labels } : {},
|
|
17268
|
+
...milestone ? { milestone } : {}
|
|
17269
|
+
});
|
|
17270
|
+
return finish([row$1(title, "ok", `filed ${key}`)], key);
|
|
17271
|
+
} catch (err) {
|
|
17272
|
+
return finish([row$1(title, "fail", `could not file the issue: ${describeError(err)}`)]);
|
|
17273
|
+
}
|
|
17274
|
+
}
|
|
17275
|
+
// src/commands/issue-create/issue-create.command.ts
|
|
17276
|
+
const issueCreateCommand = {
|
|
17277
|
+
command: "issue <title>",
|
|
17278
|
+
describe: "File an issue in the repo's tracker",
|
|
17279
|
+
builder: (y) => y.positional("title", {
|
|
17280
|
+
type: "string",
|
|
17281
|
+
demandOption: true,
|
|
17282
|
+
describe: "The issue's title"
|
|
17283
|
+
}).option("body", {
|
|
17284
|
+
type: "string",
|
|
17285
|
+
describe: "The issue's text"
|
|
17286
|
+
}).option("label", {
|
|
17287
|
+
type: "string",
|
|
17288
|
+
array: true,
|
|
17289
|
+
describe: "A label to put on it (repeatable)"
|
|
17290
|
+
}).option("milestone", {
|
|
17291
|
+
type: "string",
|
|
17292
|
+
describe: "The milestone: its number or its exact title"
|
|
17293
|
+
}).option("yes", {
|
|
17294
|
+
type: "boolean",
|
|
17295
|
+
describe: "File without asking (required without a terminal)"
|
|
17296
|
+
}),
|
|
17297
|
+
handler: async (argv) => {
|
|
17298
|
+
const tokens = tokenContext$1(argv.token);
|
|
17299
|
+
if (!tokens) return;
|
|
17300
|
+
const loaded = await loadConfig(argv.cwd);
|
|
17301
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
17302
|
+
if ((await runIssueCreate({
|
|
17303
|
+
title: String(argv.title),
|
|
17304
|
+
loaded,
|
|
17305
|
+
context: {
|
|
17306
|
+
repoRoot: argv.cwd,
|
|
17307
|
+
dryRun: argv.dryRun,
|
|
17308
|
+
...tokens,
|
|
17309
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
17310
|
+
},
|
|
17311
|
+
...argv.body ? { body: argv.body } : {},
|
|
17312
|
+
...argv.label ? { labels: argv.label.map(String) } : {},
|
|
17313
|
+
...argv.milestone ? { milestone: String(argv.milestone) } : {},
|
|
17314
|
+
...argv.yes ? { yes: true } : {}
|
|
17315
|
+
})).status === "fail") process.exitCode = 1;
|
|
17316
|
+
}
|
|
17317
|
+
};
|
|
17162
17318
|
// src/commands/notifications-channel-add/notifications-channel-add.args.ts
|
|
17163
17319
|
const notificationsChannelAddArgs = (y) => y.positional("name", {
|
|
17164
17320
|
type: "string",
|
|
@@ -19588,8 +19744,8 @@ const newRepoCommand = {
|
|
|
19588
19744
|
// src/commands/new/new.command.ts
|
|
19589
19745
|
const newCommand = {
|
|
19590
19746
|
command: "new",
|
|
19591
|
-
describe: "Create a repo, plugin, channel, server, secret, token, tunnel, GitHub App, project or
|
|
19592
|
-
builder: (y) => y.command(newRepoCommand).command(pluginCreateCommand).command(notificationsChannelAddCommand).command(githubAppCreateCommand).command(projectCreateCommand).command(secretSetCommand).command(notificationsCreateServerCommand).command(ideasPromoteCommand).command(authSetCommand).command(tunnelUpCommand).command(groupMenu$1("new")),
|
|
19747
|
+
describe: "Create a repo, plugin, channel, server, secret, token, tunnel, GitHub App, project, spec or issue",
|
|
19748
|
+
builder: (y) => y.command(newRepoCommand).command(pluginCreateCommand).command(notificationsChannelAddCommand).command(githubAppCreateCommand).command(projectCreateCommand).command(secretSetCommand).command(notificationsCreateServerCommand).command(ideasPromoteCommand).command(issueCreateCommand).command(authSetCommand).command(tunnelUpCommand).command(groupMenu$1("new")),
|
|
19593
19749
|
handler: () => {}
|
|
19594
19750
|
};
|
|
19595
19751
|
// src/commands/probe/probe.args.ts
|
|
@@ -19620,6 +19776,9 @@ const probeArgs = (y) => y.positional("provider", {
|
|
|
19620
19776
|
}).option("copy", {
|
|
19621
19777
|
type: "boolean",
|
|
19622
19778
|
describe: "`1password export-environment`: put the variables on the clipboard instead of a file"
|
|
19779
|
+
}).option("environment", {
|
|
19780
|
+
type: "string",
|
|
19781
|
+
describe: "A probe about a token (`cloudflare token`): check the provider's token held in this vault Environment (a layer such as `ci` or `dev`, or a name)"
|
|
19623
19782
|
}).option("yes", {
|
|
19624
19783
|
type: "boolean",
|
|
19625
19784
|
default: false,
|
|
@@ -21098,6 +21257,107 @@ function listProbes(groups) {
|
|
|
21098
21257
|
}
|
|
21099
21258
|
return lines;
|
|
21100
21259
|
}
|
|
21260
|
+
// src/commands/probe/probe-token/choose-token.ts
|
|
21261
|
+
/**
|
|
21262
|
+
* Asks which token a probe that accepts one should check: the configured one, one from an Environment, or one typed in
|
|
21263
|
+
* (hidden as it is typed). Only called on a terminal when neither `--token` nor `--environment` was given.
|
|
21264
|
+
*/
|
|
21265
|
+
async function chooseToken(provider) {
|
|
21266
|
+
const how = await select({
|
|
21267
|
+
message: `Which ${provider} token should it check?`,
|
|
21268
|
+
choices: [
|
|
21269
|
+
{
|
|
21270
|
+
name: "The one this repo is configured to use",
|
|
21271
|
+
value: "configured"
|
|
21272
|
+
},
|
|
21273
|
+
{
|
|
21274
|
+
name: "One from a vault Environment (a layer such as ci or dev, or a name)",
|
|
21275
|
+
value: "environment"
|
|
21276
|
+
},
|
|
21277
|
+
{
|
|
21278
|
+
name: "Type or paste a token",
|
|
21279
|
+
value: "paste"
|
|
21280
|
+
}
|
|
21281
|
+
]
|
|
21282
|
+
});
|
|
21283
|
+
if (how === "environment") return { environment: (await input({
|
|
21284
|
+
message: "Environment (layer or name):",
|
|
21285
|
+
default: "ci"
|
|
21286
|
+
})).trim() };
|
|
21287
|
+
if (how === "paste") return { token: (await password({
|
|
21288
|
+
message: `${provider} token:`,
|
|
21289
|
+
mask: "*"
|
|
21290
|
+
})).trim() };
|
|
21291
|
+
}
|
|
21292
|
+
// src/commands/probe/probe-token/default-provider-tokens.ts
|
|
21293
|
+
/**
|
|
21294
|
+
* Reads the tokens a provider's plugin lists (its module-level `tokens`), resolving the plugin package from the
|
|
21295
|
+
* directory of the config that was loaded so a `--cwd` run finds the plugins installed there.
|
|
21296
|
+
*/
|
|
21297
|
+
function defaultProviderTokens(loaded, importer = createDefaultImporter(dirname(loaded.filepath))) {
|
|
21298
|
+
return async (provider) => (await importer(resolvePluginPackage$1(provider))).tokens ?? [];
|
|
21299
|
+
}
|
|
21300
|
+
// src/commands/secrets-sync/resolve-environment-id/resolve-environment-id.ts
|
|
21301
|
+
/**
|
|
21302
|
+
* The vault Environment `holocron sync secrets <environmentId>` reads. A layer word (`local`, `dev`, `ci`, `prod`) is the
|
|
21303
|
+
* Environment of that layer of this repository, `<org/repo> - <layer>`; any other text is a literal Environment name.
|
|
21304
|
+
* A literal name wins only when it is not exactly a layer word, so an Environment that is itself called `prod` cannot be
|
|
21305
|
+
* addressed by that name (spec `tech-environment-layers`, #2069).
|
|
21306
|
+
*
|
|
21307
|
+
* @param id - The positional the user gave.
|
|
21308
|
+
* @param input - Where the repository is (its `origin` remote is read there), and optionally how to read it.
|
|
21309
|
+
* @throws {ConfigError} For a layer word when the remote cannot be read (the message names the `environment` option).
|
|
21310
|
+
*/
|
|
21311
|
+
async function resolveEnvironmentId(id, input) {
|
|
21312
|
+
if (!isEnvironmentLayer(id)) return id;
|
|
21313
|
+
return layerEnvironment(await repoSlug(input.repoRoot, input.gitExec), id);
|
|
21314
|
+
}
|
|
21315
|
+
// src/commands/probe/probe-token/environment-token.ts
|
|
21316
|
+
/**
|
|
21317
|
+
* The provider's API token as held in one vault Environment, read in memory. Only an Environment this repo uses is
|
|
21318
|
+
* read: a layer word (`local`, `dev`, `ci`, `prod`) is this repo's `<org/repo> - <layer>`, and any other text must be a
|
|
21319
|
+
* name the config already names (`configured`), so a probe cannot be pointed at an Environment the repo has nothing to
|
|
21320
|
+
* do with. `local` reads the way the CLI does, `- local` over `- dev`, and `- local` may be absent.
|
|
21321
|
+
*
|
|
21322
|
+
* The variables looked for are the ones the provider's plugin lists (`HOLOCRON_CLOUDFLARE_TOKEN`, then the vendor's own
|
|
21323
|
+
* `CLOUDFLARE_API_TOKEN`); the first that holds a value wins.
|
|
21324
|
+
*
|
|
21325
|
+
* @throws {Error} When the name is not one of this repo's, no vault that reads an Environment is configured, or the
|
|
21326
|
+
* Environment holds none of the variables.
|
|
21327
|
+
*/
|
|
21328
|
+
async function environmentToken(input) {
|
|
21329
|
+
if (!isEnvironmentLayer(input.environment) && !input.configured.includes(input.environment)) {
|
|
21330
|
+
const known = [...ENVIRONMENT_LAYERS, ...input.configured];
|
|
21331
|
+
throw new Error(`${input.environment} is not an Environment this repo's config names; use one of: ${known.join(", ")}`);
|
|
21332
|
+
}
|
|
21333
|
+
const read = input.vault?.readEnvironment?.bind(input.vault);
|
|
21334
|
+
if (!read) throw new Error("--environment needs a vault provider that can read an Environment (1Password); none is configured");
|
|
21335
|
+
const at = {
|
|
21336
|
+
repoRoot: input.repoRoot,
|
|
21337
|
+
gitExec: input.gitExec
|
|
21338
|
+
};
|
|
21339
|
+
const environment = await resolveEnvironmentId(input.environment, at);
|
|
21340
|
+
let values;
|
|
21341
|
+
if (input.environment === "local") {
|
|
21342
|
+
const dev = await read(await resolveEnvironmentId("dev", at));
|
|
21343
|
+
const local = await read(environment).catch(() => ({}));
|
|
21344
|
+
values = {
|
|
21345
|
+
...dev,
|
|
21346
|
+
...local
|
|
21347
|
+
};
|
|
21348
|
+
} else values = await read(environment);
|
|
21349
|
+
const names = input.tokens.flatMap((t) => [t.envName, ...t.vendorEnvName ? [t.vendorEnvName] : []]);
|
|
21350
|
+
if (names.length === 0) throw new Error(`the ${input.provider} plugin lists no token to look for`);
|
|
21351
|
+
for (const variable of names) {
|
|
21352
|
+
const token = values[variable];
|
|
21353
|
+
if (token) return {
|
|
21354
|
+
token,
|
|
21355
|
+
environment,
|
|
21356
|
+
variable
|
|
21357
|
+
};
|
|
21358
|
+
}
|
|
21359
|
+
throw new Error(`${environment} holds none of ${names.join(", ")}`);
|
|
21360
|
+
}
|
|
21101
21361
|
// src/commands/probe/references/clone-org.ts
|
|
21102
21362
|
const SKIP_DIRS = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
21103
21363
|
const MAX_FILE_BYTES = 5242880;
|
|
@@ -21687,7 +21947,8 @@ function tasksProbes(io, names = legacyReplacements()) {
|
|
|
21687
21947
|
async function runProbeCommand(input) {
|
|
21688
21948
|
const print = input.print ?? ((line) => console.log(line));
|
|
21689
21949
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
21690
|
-
const
|
|
21950
|
+
const makeLoader = input.makeLoader ?? ((context) => new PluginLoader(input.loaded.resolved, context));
|
|
21951
|
+
const loader = input.loader ?? makeLoader(input.context);
|
|
21691
21952
|
await loader.load();
|
|
21692
21953
|
const groups = new Map(loader.probes());
|
|
21693
21954
|
const comlink = comlinkProbes({
|
|
@@ -21716,17 +21977,55 @@ async function runProbeCommand(input) {
|
|
|
21716
21977
|
for (const line of listProbes(/* @__PURE__ */ new Map([[input.provider, probes]]))) print(line);
|
|
21717
21978
|
return { status: "listed" };
|
|
21718
21979
|
}
|
|
21719
|
-
|
|
21980
|
+
let probe = probes[input.probe];
|
|
21720
21981
|
if (!probe) {
|
|
21721
21982
|
print(statusRow("fail", [`\`${input.provider}\` has no probe \`${input.probe}\``, `try: ${Object.keys(probes).sort().join(", ")}`]));
|
|
21722
21983
|
return { status: "fail" };
|
|
21723
21984
|
}
|
|
21724
|
-
|
|
21985
|
+
let context = input.context;
|
|
21986
|
+
let layer;
|
|
21987
|
+
if (probe.acceptsToken) {
|
|
21988
|
+
const given = context.cliTokens?.[input.provider] ?? context.cliToken;
|
|
21989
|
+
const chosen = input.environment ? { environment: input.environment } : given === void 0 ? await input.chooseToken?.(input.provider) : void 0;
|
|
21990
|
+
let override;
|
|
21991
|
+
try {
|
|
21992
|
+
if (chosen?.environment) {
|
|
21993
|
+
const found = await environmentToken({
|
|
21994
|
+
provider: input.provider,
|
|
21995
|
+
environment: chosen.environment,
|
|
21996
|
+
repoRoot: context.repoRoot,
|
|
21997
|
+
configured: ownerEnvironments(input.loaded.resolved).names,
|
|
21998
|
+
vault: loader.has("vault") ? loader.get("vault") : void 0,
|
|
21999
|
+
/* v8 ignore next -- the real importer reads installed plugin packages, which tests replace with `providerTokens` */
|
|
22000
|
+
tokens: await (input.providerTokens ?? defaultProviderTokens(input.loaded))(input.provider)
|
|
22001
|
+
});
|
|
22002
|
+
override = found.token;
|
|
22003
|
+
if (isEnvironmentLayer(chosen.environment)) layer = chosen.environment;
|
|
22004
|
+
print(statusRow("skip", ["token", `read ${found.variable} from ${found.environment}`]));
|
|
22005
|
+
} else if (chosen?.token) override = chosen.token;
|
|
22006
|
+
} catch (err) {
|
|
22007
|
+
print(statusRow("fail", [`\`${input.provider} ${input.probe}\``, commandFailureMessage(err)]));
|
|
22008
|
+
return { status: "fail" };
|
|
22009
|
+
}
|
|
22010
|
+
if (override !== void 0) {
|
|
22011
|
+
context = {
|
|
22012
|
+
...context,
|
|
22013
|
+
cliTokens: {
|
|
22014
|
+
...context.cliTokens,
|
|
22015
|
+
[input.provider]: override
|
|
22016
|
+
}
|
|
22017
|
+
};
|
|
22018
|
+
const reloaded = makeLoader(context);
|
|
22019
|
+
await reloaded.load();
|
|
22020
|
+
probe = reloaded.probes().get(input.provider)?.[input.probe] ?? probe;
|
|
22021
|
+
}
|
|
22022
|
+
}
|
|
22023
|
+
const tokens = [context.cliToken, ...Object.values(context.cliTokens ?? {})].filter((t) => typeof t === "string");
|
|
21725
22024
|
return { status: (await runProbe({
|
|
21726
22025
|
name: `${input.provider} ${input.probe}`,
|
|
21727
22026
|
provider: input.provider,
|
|
21728
22027
|
probeName: input.probe,
|
|
21729
|
-
args: input.args ?? [],
|
|
22028
|
+
args: [...input.args ?? [], ...layer ? ["--layer", layer] : []],
|
|
21730
22029
|
...input.lcov ? { lcov: input.lcov } : {},
|
|
21731
22030
|
probe,
|
|
21732
22031
|
dryRun: input.dryRun ?? false,
|
|
@@ -21769,6 +22068,8 @@ const probeCommand = {
|
|
|
21769
22068
|
...argv.lcov ? { lcov: argv.lcov } : {},
|
|
21770
22069
|
dryRun: argv.dryRun,
|
|
21771
22070
|
yes: argv.yes,
|
|
22071
|
+
...argv.environment ? { environment: argv.environment } : {},
|
|
22072
|
+
...process.stdin.isTTY ? { chooseToken } : {},
|
|
21772
22073
|
...process.stdin.isTTY ? { pick: (groups) => launchMenu(buildProbeMenuEntries(groups), argv, {
|
|
21773
22074
|
pickMessage: "probe — choose a provider:",
|
|
21774
22075
|
nonInteractiveMessage: "Run `holocron probe` to list the probes.",
|
|
@@ -23950,21 +24251,6 @@ const notificationsSyncRolesCommand = {
|
|
|
23950
24251
|
})).status === "fail") process.exitCode = 1;
|
|
23951
24252
|
}
|
|
23952
24253
|
};
|
|
23953
|
-
// src/commands/secrets-sync/resolve-environment-id/resolve-environment-id.ts
|
|
23954
|
-
/**
|
|
23955
|
-
* The vault Environment `holocron sync secrets <environmentId>` reads. A layer word (`local`, `dev`, `ci`, `prod`) is the
|
|
23956
|
-
* Environment of that layer of this repository, `<org/repo> - <layer>`; any other text is a literal Environment name.
|
|
23957
|
-
* A literal name wins only when it is not exactly a layer word, so an Environment that is itself called `prod` cannot be
|
|
23958
|
-
* addressed by that name (spec `tech-environment-layers`, #2069).
|
|
23959
|
-
*
|
|
23960
|
-
* @param id - The positional the user gave.
|
|
23961
|
-
* @param input - Where the repository is (its `origin` remote is read there), and optionally how to read it.
|
|
23962
|
-
* @throws {ConfigError} For a layer word when the remote cannot be read (the message names the `environment` option).
|
|
23963
|
-
*/
|
|
23964
|
-
async function resolveEnvironmentId(id, input) {
|
|
23965
|
-
if (!isEnvironmentLayer(id)) return id;
|
|
23966
|
-
return layerEnvironment(await repoSlug(input.repoRoot, input.gitExec), id);
|
|
23967
|
-
}
|
|
23968
24254
|
// src/commands/secrets-sync/secret-routes.ts
|
|
23969
24255
|
/**
|
|
23970
24256
|
* The routes into `secrets` that `repo.secrets.sync` declares for one vault environment: every entry naming it gives
|