@theholocron/cli 5.0.0-alpha.393 → 5.0.0-alpha.395
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 +11 -3
- package/dist/cli.mjs +512 -141
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-BVYtgrmR.mjs → config-system-BzAs0RR1.mjs} +13 -0
- package/dist/{config-system-u0AcPQ77.d.mts → config-system-CLi7Ceta.d.mts} +24 -2
- package/dist/{index-nzzQsd0r.d.mts → index-DbptTVsV.d.mts} +5 -0
- package/dist/index.d.mts +55 -55
- package/dist/index.mjs +15 -15
- package/dist/plugin/capabilities.d.mts +1 -1
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/package.json +13 -12
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
3
|
import { homedir, tmpdir } from "node:os";
|
|
5
4
|
import path, { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
6
5
|
import { PREFIX, createEnvLookup, firstEnv, holocronEnv } from "@theholocron/env-utils/lookup";
|
|
@@ -22,7 +21,9 @@ import { resolveAxiomFromEnv } from "@theholocron/observability/logger";
|
|
|
22
21
|
import { Entry, findCredentials } from "@napi-rs/keyring";
|
|
23
22
|
import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver, createKeyring, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
|
|
24
23
|
import { errorMessage } from "@theholocron/misc-utils";
|
|
25
|
-
import {
|
|
24
|
+
import { runCheckAgainstUrl } from "@theholocron/kyber/checks";
|
|
25
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
26
|
+
import { copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
26
27
|
import { DRY_RUN_NOOP_EXIT_CODE, createCommandRegistry, createMenu, numeric } from "@theholocron/kyber/menu";
|
|
27
28
|
import { promptForPositionals } from "@theholocron/kyber/prompts";
|
|
28
29
|
import { Separator, checkbox, confirm, input, select } from "@inquirer/prompts";
|
|
@@ -34,9 +35,8 @@ import { access, copyFile, lstat, mkdir, open, readFile, readdir, realpath, rena
|
|
|
34
35
|
import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
35
36
|
import { createGitHubClient, getApp, listAppInstallations } from "@theholocron/github-client";
|
|
36
37
|
import { createServer } from "node:http";
|
|
37
|
-
import { runCheckAgainstUrl } from "@theholocron/kyber/checks";
|
|
38
|
-
import { moveMajorTag } from "@theholocron/kyber/git";
|
|
39
38
|
import { ADR_DIR, ADR_STATUSES, CLOSED_STATUSES, SPEC_DIRS, SPEC_STATUSES, WITHDRAWN_STATE, assignSpecIds, checkSpecs, classifySpecPath, discussionBody, discussionIdLine, discussionPrLine, discussionTitle, evaluateDocsPresence, isAddedDocComment, isFeat, packageOf, parseFrontmatter, parseSkipDocs, reconcileSpecStatus, specSummary, specTitle, updateFrontmatter } from "@theholocron/astromech/repo-validation";
|
|
39
|
+
import { moveMajorTag } from "@theholocron/kyber/git";
|
|
40
40
|
import { loadConfigPath } from "@theholocron/datapad";
|
|
41
41
|
import { fetchLatestFromNpm, runUpgradeNode } from "@theholocron/astromech/upgrade";
|
|
42
42
|
import { lintCommitMsgFile } from "@theholocron/astromech/lint";
|
|
@@ -221,6 +221,17 @@ function validateGitHubApps(apps) {
|
|
|
221
221
|
}
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
|
+
/** Throws a {@link ConfigError} naming the first thing wrong with the `ideas` block. */
|
|
225
|
+
function validateIdeas(ideas) {
|
|
226
|
+
const nonEmpty = (value) => typeof value === "string" && value.trim() !== "";
|
|
227
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
228
|
+
if (!isObject(ideas)) throw new ConfigError$1("`ideas` must be an object: { dir, states? }");
|
|
229
|
+
if (!nonEmpty(ideas.dir)) throw new ConfigError$1("`ideas.dir` must be the path of the notes folder, got an empty value");
|
|
230
|
+
if (ideas.states !== void 0) {
|
|
231
|
+
if (!isObject(ideas.states)) throw new ConfigError$1("`ideas.states` must be an object: { file? }");
|
|
232
|
+
if (ideas.states.file !== void 0 && !nonEmpty(ideas.states.file)) throw new ConfigError$1("`ideas.states.file` must be a state name, got an empty value");
|
|
233
|
+
}
|
|
234
|
+
}
|
|
224
235
|
/** Throws a {@link ConfigError} naming the first thing wrong with the `dev` block. */
|
|
225
236
|
function validateDev(dev) {
|
|
226
237
|
const nonEmpty = (value) => typeof value === "string" && value.trim() !== "";
|
|
@@ -277,6 +288,7 @@ function resolveConfig(raw) {
|
|
|
277
288
|
}
|
|
278
289
|
if (raw.dev !== void 0) validateDev(raw.dev);
|
|
279
290
|
if (raw.githubApps !== void 0) validateGitHubApps(raw.githubApps);
|
|
291
|
+
if (raw.ideas !== void 0) validateIdeas(raw.ideas);
|
|
280
292
|
validateVariablesSync(raw.repo?.variables);
|
|
281
293
|
const credentialsEntry = providers.credentials;
|
|
282
294
|
if (credentialsEntry?.cardinality === "many") for (const tuple of credentialsEntry.tuples) {
|
|
@@ -308,6 +320,7 @@ function resolveConfig(raw) {
|
|
|
308
320
|
credentials: raw.credentials,
|
|
309
321
|
dev: raw.dev,
|
|
310
322
|
githubApps: raw.githubApps,
|
|
323
|
+
ideas: raw.ideas,
|
|
311
324
|
log: raw.log,
|
|
312
325
|
telemetry: raw.telemetry,
|
|
313
326
|
eslint: raw.eslint
|
|
@@ -660,7 +673,7 @@ system$1.defineConfig;
|
|
|
660
673
|
*/
|
|
661
674
|
const loadConfig = system$1.loadConfig;
|
|
662
675
|
system$1.compose;
|
|
663
|
-
// src/auth.ts
|
|
676
|
+
// src/auth/auth.ts
|
|
664
677
|
/**
|
|
665
678
|
* The CLI's credentials: the OS keyring every plugin's bootstrap token lives in, and the two token resolvers built on
|
|
666
679
|
* it. Both are public, so a plugin's `src/auth.ts` is a one-line call.
|
|
@@ -783,7 +796,8 @@ const COMMAND_CONTEXTS = {
|
|
|
783
796
|
"repo sync": "workspace",
|
|
784
797
|
"repo cleanup branches": "workspace",
|
|
785
798
|
"sync github": "workspace",
|
|
786
|
-
"sync issues": "workspace"
|
|
799
|
+
"sync issues": "workspace",
|
|
800
|
+
"ideas sync": "workspace"
|
|
787
801
|
};
|
|
788
802
|
/**
|
|
789
803
|
* The context for a command name from `argv._`. Falls back to the leading
|
|
@@ -1121,41 +1135,6 @@ function actionsOf(plugin) {
|
|
|
1121
1135
|
...plugin.doctor ? { doctor: plugin.doctor } : {}
|
|
1122
1136
|
};
|
|
1123
1137
|
}
|
|
1124
|
-
// src/plugin/verify-vercel-project/verify-vercel-project.ts
|
|
1125
|
-
/**
|
|
1126
|
-
* `true` only when Vercel's API confirms `url` resolves to a deployment
|
|
1127
|
-
* whose `projectId` matches `expectedProjectId` exactly. `false` for any
|
|
1128
|
-
* other outcome — a non-matching project, a non-2xx response, a
|
|
1129
|
-
* malformed body, or a transport failure — never throws, since every one
|
|
1130
|
-
* of those outcomes means the same thing to a caller: don't attach the
|
|
1131
|
-
* credential.
|
|
1132
|
-
*/
|
|
1133
|
-
async function verifyVercelDeploymentProject(url, expectedProjectId, token, opts = {}) {
|
|
1134
|
-
const doFetch = opts.fetch ?? fetch;
|
|
1135
|
-
const baseUrl = opts.baseUrl ?? "https://api.vercel.com";
|
|
1136
|
-
let host;
|
|
1137
|
-
try {
|
|
1138
|
-
host = new URL(url).host;
|
|
1139
|
-
} catch {
|
|
1140
|
-
return false;
|
|
1141
|
-
}
|
|
1142
|
-
const params = new URLSearchParams({ url: host });
|
|
1143
|
-
if (opts.teamId) params.set("teamId", opts.teamId);
|
|
1144
|
-
let response;
|
|
1145
|
-
try {
|
|
1146
|
-
response = await doFetch(`${baseUrl}/v13/deployments/get?${params}`, { headers: { Authorization: `Bearer ${token}` } });
|
|
1147
|
-
} catch {
|
|
1148
|
-
return false;
|
|
1149
|
-
}
|
|
1150
|
-
if (!response.ok) return false;
|
|
1151
|
-
let body;
|
|
1152
|
-
try {
|
|
1153
|
-
body = await response.json();
|
|
1154
|
-
} catch {
|
|
1155
|
-
return false;
|
|
1156
|
-
}
|
|
1157
|
-
return (typeof body === "object" && body !== null && "projectId" in body ? body.projectId : void 0) === expectedProjectId;
|
|
1158
|
-
}
|
|
1159
1138
|
// src/commands/auth/auth.ts
|
|
1160
1139
|
/**
|
|
1161
1140
|
* `holocron auth <subcommand>` — manage bootstrap credentials in the
|
|
@@ -1517,12 +1496,12 @@ async function runDoctorTokens(input) {
|
|
|
1517
1496
|
try {
|
|
1518
1497
|
module = await importer(pkg);
|
|
1519
1498
|
} catch (err) {
|
|
1520
|
-
rows.push(row$
|
|
1499
|
+
rows.push(row$10(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
|
|
1521
1500
|
continue;
|
|
1522
1501
|
}
|
|
1523
1502
|
for (const token of module.tokens ?? []) rows.push(await checkToken$1(token, module, env, readToken, now()));
|
|
1524
1503
|
}
|
|
1525
|
-
if (rows.length === 0) rows.push(row$
|
|
1504
|
+
if (rows.length === 0) rows.push(row$10("tokens", "skip", "no configured plugin lists the tokens it takes"));
|
|
1526
1505
|
printCheckRows(rows, print);
|
|
1527
1506
|
const summary = summariseChecks(rows);
|
|
1528
1507
|
printCheckSummary(summary, print);
|
|
@@ -1554,11 +1533,11 @@ async function loadCredentials(input) {
|
|
|
1554
1533
|
try {
|
|
1555
1534
|
await loader.load();
|
|
1556
1535
|
} catch (err) {
|
|
1557
|
-
return [row$
|
|
1536
|
+
return [row$10("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
|
|
1558
1537
|
}
|
|
1559
|
-
return loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$
|
|
1538
|
+
return loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$10(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
|
|
1560
1539
|
}
|
|
1561
|
-
function row$
|
|
1540
|
+
function row$10(id, status, detail) {
|
|
1562
1541
|
return {
|
|
1563
1542
|
id,
|
|
1564
1543
|
title: id,
|
|
@@ -1572,21 +1551,21 @@ async function checkToken$1(token, module, env, readToken, now) {
|
|
|
1572
1551
|
const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
|
|
1573
1552
|
const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
|
|
1574
1553
|
const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
|
|
1575
|
-
if (!value) return row$
|
|
1554
|
+
if (!value) return row$10(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron auth set ${keyringKey}\`)`);
|
|
1576
1555
|
const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
|
|
1577
|
-
if (!verify) return row$
|
|
1556
|
+
if (!verify) return row$10(keyringKey, "skip", "set, but its plugin cannot verify it");
|
|
1578
1557
|
const from = fromEnv ?? stored?.source ?? "keyring";
|
|
1579
1558
|
try {
|
|
1580
1559
|
const verified = await verify(value);
|
|
1581
|
-
if (!verified.ok) return row$
|
|
1560
|
+
if (!verified.ok) return row$10(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
|
|
1582
1561
|
const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
|
|
1583
|
-
if (!expiry) return row$
|
|
1562
|
+
if (!expiry) return row$10(keyringKey, "ok", `${verified.subject} (${from})`);
|
|
1584
1563
|
return expiry.soon ? {
|
|
1585
|
-
...row$
|
|
1564
|
+
...row$10(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
|
|
1586
1565
|
problems: [`${expiry.text}: renew it`]
|
|
1587
|
-
} : row$
|
|
1566
|
+
} : row$10(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
|
|
1588
1567
|
} catch (err) {
|
|
1589
|
-
return row$
|
|
1568
|
+
return row$10(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
|
|
1590
1569
|
}
|
|
1591
1570
|
}
|
|
1592
1571
|
// src/commands/doctor-tokens/doctor-tokens.command.ts
|
|
@@ -2168,6 +2147,14 @@ const githubAppCreateEntry = {
|
|
|
2168
2147
|
],
|
|
2169
2148
|
supportsDryRun: false
|
|
2170
2149
|
};
|
|
2150
|
+
// src/commands/ideas-sync/ideas-sync.entry.ts
|
|
2151
|
+
const ideasSyncEntry = {
|
|
2152
|
+
name: "ideas sync",
|
|
2153
|
+
description: "File the idea notes that are ready as issues and record the issue in each note",
|
|
2154
|
+
positionals: [],
|
|
2155
|
+
skipOptions: ["yes"],
|
|
2156
|
+
supportsDryRun: true
|
|
2157
|
+
};
|
|
2171
2158
|
// src/commands/migrate/migrate-issue/migrate-issue.entry.ts
|
|
2172
2159
|
const migrateIssueEntry = {
|
|
2173
2160
|
name: "migrate issue",
|
|
@@ -2838,6 +2825,7 @@ const registry = createCommandRegistry([
|
|
|
2838
2825
|
skipOptions: ["yes"],
|
|
2839
2826
|
supportsDryRun: true
|
|
2840
2827
|
},
|
|
2828
|
+
ideasSyncEntry,
|
|
2841
2829
|
{
|
|
2842
2830
|
name: "repo sync readme",
|
|
2843
2831
|
description: "Sync the Installation + Usage block in README.md from package.json",
|
|
@@ -3622,6 +3610,45 @@ const deployStageArgs = (y) => y.option("package-dir", {
|
|
|
3622
3610
|
type: "string",
|
|
3623
3611
|
describe: "Where to write the payload. Default: `.vercel-deploy` inside the package."
|
|
3624
3612
|
});
|
|
3613
|
+
// src/commands/deploy-stage/alpha-release/alpha-release.ts
|
|
3614
|
+
/**
|
|
3615
|
+
* The release npm's `alpha` dist-tag points at for `name`, with the peer ranges it declares
|
|
3616
|
+
* (`npm view <name>@alpha version peerDependencies --json`).
|
|
3617
|
+
*
|
|
3618
|
+
* @returns `undefined` when the package or its `alpha` tag does not exist (npm's E404).
|
|
3619
|
+
* @throws when npm cannot be run or the registry cannot be reached: staging then would pin whatever is
|
|
3620
|
+
* installed, which is the stale version this lookup exists to replace.
|
|
3621
|
+
*/
|
|
3622
|
+
function alphaRelease(name) {
|
|
3623
|
+
const result = spawnSync("npm", [
|
|
3624
|
+
"view",
|
|
3625
|
+
`${name}@alpha`,
|
|
3626
|
+
"version",
|
|
3627
|
+
"peerDependencies",
|
|
3628
|
+
"--json"
|
|
3629
|
+
], {
|
|
3630
|
+
encoding: "utf8",
|
|
3631
|
+
stdio: [
|
|
3632
|
+
"ignore",
|
|
3633
|
+
"pipe",
|
|
3634
|
+
"pipe"
|
|
3635
|
+
]
|
|
3636
|
+
});
|
|
3637
|
+
if (result.error) throw new Error(`cannot run npm to look up ${name}@alpha: ${result.error.message}`);
|
|
3638
|
+
if (result.status !== 0) {
|
|
3639
|
+
if (/E404|code E404/.test(`${result.stdout}${result.stderr}`)) return void 0;
|
|
3640
|
+
const reason = (result.stderr || result.stdout).split("\n").find((line) => line.trim()) ?? `exit ${result.status}`;
|
|
3641
|
+
throw new Error(`cannot look up ${name}@alpha on npm (is the registry reachable?): ${reason.trim()}`);
|
|
3642
|
+
}
|
|
3643
|
+
const parsed = JSON.parse(result.stdout);
|
|
3644
|
+
const view = typeof parsed === "string" ? { version: parsed } : parsed;
|
|
3645
|
+
if (typeof view.version !== "string") return void 0;
|
|
3646
|
+
const peers = view.peerDependencies;
|
|
3647
|
+
return {
|
|
3648
|
+
version: view.version,
|
|
3649
|
+
...peers && typeof peers === "object" ? { peerDependencies: peers } : {}
|
|
3650
|
+
};
|
|
3651
|
+
}
|
|
3625
3652
|
// src/commands/deploy-stage/installed-peers.ts
|
|
3626
3653
|
/**
|
|
3627
3654
|
* The `package.json` of `peer` as the package at `manifestPath` would resolve it: the closest `node_modules`
|
|
@@ -3661,6 +3688,40 @@ function installedPeers(packageDir, dependency) {
|
|
|
3661
3688
|
collectPeers(realpathSync(manifestPath), peers);
|
|
3662
3689
|
return peers;
|
|
3663
3690
|
}
|
|
3691
|
+
// src/commands/deploy-stage/pin-alpha-releases/pin-alpha-releases.ts
|
|
3692
|
+
const OWN_SCOPE = "@theholocron/";
|
|
3693
|
+
const ALPHA_VERSION = /-alpha\./;
|
|
3694
|
+
const EXACT_VERSION = /^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/;
|
|
3695
|
+
/**
|
|
3696
|
+
* Moves every `@theholocron/*` dependency installed at an `alpha` prerelease to the version npm's `alpha` tag points
|
|
3697
|
+
* at. A workspace package's `package.json` keeps the version it had when it was last committed, and a release only
|
|
3698
|
+
* writes the new one into the published copy, so the installed version of a plugin can be hundreds of releases behind
|
|
3699
|
+
* what npm serves, with a peer on a CLI it was never published with. A version that is not an `alpha` prerelease, a
|
|
3700
|
+
* package outside the scope and a package npm has no `alpha` tag for stay as they are.
|
|
3701
|
+
*
|
|
3702
|
+
* `mismatches` lists each exact peer a pinned release declares (`@theholocron/cli` is one) that differs from the
|
|
3703
|
+
* version staged for it, so a release cut between two lookups shows up instead of failing at runtime.
|
|
3704
|
+
*/
|
|
3705
|
+
function pinAlphaReleases(dependencies, lookup) {
|
|
3706
|
+
const pinned = {};
|
|
3707
|
+
const changes = [];
|
|
3708
|
+
const peerRanges = [];
|
|
3709
|
+
for (const [name, version] of Object.entries(dependencies)) {
|
|
3710
|
+
const release = name.startsWith(OWN_SCOPE) && ALPHA_VERSION.test(version) ? lookup(name) : void 0;
|
|
3711
|
+
pinned[name] = release?.version ?? version;
|
|
3712
|
+
if (release && release.version !== version) changes.push(`${name} ${version} → ${release.version}`);
|
|
3713
|
+
if (release?.peerDependencies) peerRanges.push([
|
|
3714
|
+
name,
|
|
3715
|
+
release.version,
|
|
3716
|
+
release.peerDependencies
|
|
3717
|
+
]);
|
|
3718
|
+
}
|
|
3719
|
+
return {
|
|
3720
|
+
dependencies: pinned,
|
|
3721
|
+
changes,
|
|
3722
|
+
mismatches: peerRanges.flatMap(([name, version, peers]) => Object.entries(peers).filter(([peer, range]) => peer in pinned && EXACT_VERSION.test(range) && pinned[peer] !== range).map(([peer, range]) => `${name}@${version} peers ${peer}@${range}, but ${peer}@${pinned[peer]} is staged`))
|
|
3723
|
+
};
|
|
3724
|
+
}
|
|
3664
3725
|
// src/commands/deploy-stage/undeclared-externals.ts
|
|
3665
3726
|
/** `"@scope/pkg/sub"` → `"@scope/pkg"`, `"pkg/sub"` → `"pkg"`. */
|
|
3666
3727
|
function packageName(specifier) {
|
|
@@ -3755,8 +3816,10 @@ function vercelEngines(engines) {
|
|
|
3755
3816
|
* here. They stay in `dependencies` because a repo's own `holocron.config.ts`
|
|
3756
3817
|
* imports `@theholocron/cli` / `astromech/config` at runtime (only
|
|
3757
3818
|
* `defineConfig`, an identity function, so a version skew there is harmless).
|
|
3758
|
-
* Pinned versions still have to exist on npm
|
|
3759
|
-
*
|
|
3819
|
+
* Pinned versions still have to exist on npm. A workspace package's `package.json` is not updated when it is
|
|
3820
|
+
* released (the plugins sit at 5.0.0-alpha.132 on disk and 5.0.0-alpha.393 on npm, and each peers on exactly one CLI
|
|
3821
|
+
* version), so an `@theholocron/*` dependency installed at an `alpha` prerelease is pinned to npm's `alpha` tag
|
|
3822
|
+
* instead (`pinAlphaReleases()`); the lookup fails when npm cannot be reached, rather than staging the stale version.
|
|
3760
3823
|
*/
|
|
3761
3824
|
function installedVersion(packageDir, name) {
|
|
3762
3825
|
const pkgPath = join(packageDir, "node_modules", name, "package.json");
|
|
@@ -3789,10 +3852,12 @@ function stageDeploy(input) {
|
|
|
3789
3852
|
].join("\n"));
|
|
3790
3853
|
const direct = Object.fromEntries(Object.keys(pkg.dependencies ?? {}).map((name) => [name, resolveVersion(packageDir, name)]));
|
|
3791
3854
|
const peers = Object.fromEntries(Object.keys(direct).flatMap((name) => Object.entries(resolvePeers(packageDir, name))).filter(([name]) => !(name in direct)));
|
|
3792
|
-
const dependencies = Object.fromEntries(Object.entries({
|
|
3855
|
+
const { dependencies, changes, mismatches } = pinAlphaReleases(Object.fromEntries(Object.entries({
|
|
3793
3856
|
...direct,
|
|
3794
3857
|
...peers
|
|
3795
|
-
}).sort(([a], [b]) => a.localeCompare(b)));
|
|
3858
|
+
}).sort(([a], [b]) => a.localeCompare(b))), input.alphaRelease ?? alphaRelease);
|
|
3859
|
+
for (const change of changes) print(` pinned to npm's alpha tag: ${change}`);
|
|
3860
|
+
for (const mismatch of mismatches) print(` warning: ${mismatch}`);
|
|
3796
3861
|
rmSync(outDir, {
|
|
3797
3862
|
recursive: true,
|
|
3798
3863
|
force: true
|
|
@@ -4776,7 +4841,7 @@ function parseList(text) {
|
|
|
4776
4841
|
}
|
|
4777
4842
|
// src/commands/doctor-ci/unquote.ts
|
|
4778
4843
|
/** The text of a YAML scalar without its surrounding quotes. */
|
|
4779
|
-
function unquote$
|
|
4844
|
+
function unquote$2(value) {
|
|
4780
4845
|
return value.trim().replace(/^(["'])(.*)\1$/, "$2");
|
|
4781
4846
|
}
|
|
4782
4847
|
// src/commands/doctor-ci/parse-caller.ts
|
|
@@ -4808,7 +4873,7 @@ function parseCaller(file, text) {
|
|
|
4808
4873
|
continue;
|
|
4809
4874
|
}
|
|
4810
4875
|
const name = /^ {4}name:\s*(.+?)\s*$/.exec(line);
|
|
4811
|
-
if (name && current) current.name = unquote$
|
|
4876
|
+
if (name && current) current.name = unquote$2(name[1]);
|
|
4812
4877
|
const uses = /^ {4}uses:\s*(\S+)/.exec(line);
|
|
4813
4878
|
if (uses && current) current.uses = uses[1];
|
|
4814
4879
|
}
|
|
@@ -4819,8 +4884,8 @@ function parseCaller(file, text) {
|
|
|
4819
4884
|
return {
|
|
4820
4885
|
file,
|
|
4821
4886
|
jobs,
|
|
4822
|
-
...workflowName === void 0 ? {} : { name: unquote$
|
|
4823
|
-
...expected === void 0 ? {} : { expected: parseList(unquote$
|
|
4887
|
+
...workflowName === void 0 ? {} : { name: unquote$2(workflowName) },
|
|
4888
|
+
...expected === void 0 ? {} : { expected: parseList(unquote$2(expected)) }
|
|
4824
4889
|
};
|
|
4825
4890
|
}
|
|
4826
4891
|
// src/commands/doctor-ci/real-ci-io.ts
|
|
@@ -4941,7 +5006,7 @@ async function runDoctorCredentials(input) {
|
|
|
4941
5006
|
};
|
|
4942
5007
|
}
|
|
4943
5008
|
/** A row for the provider as a whole, or for one of its variables when `name` is given. */
|
|
4944
|
-
function row$
|
|
5009
|
+
function row$9(provider, status, detail, name) {
|
|
4945
5010
|
return name === void 0 ? {
|
|
4946
5011
|
id: provider,
|
|
4947
5012
|
title: provider,
|
|
@@ -4958,32 +5023,32 @@ function row$8(provider, status, detail, name) {
|
|
|
4958
5023
|
}
|
|
4959
5024
|
async function checkCredentials(input, loader) {
|
|
4960
5025
|
const { resolved } = input.loaded;
|
|
4961
|
-
if (!resolved.providers.credentials) return [row$
|
|
4962
|
-
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$
|
|
5026
|
+
if (!resolved.providers.credentials) return [row$9("credentials", "skip", "no `credentials` provider is configured")];
|
|
5027
|
+
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$9(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
|
|
4963
5028
|
if (!loader.has("credentials")) return rows;
|
|
4964
5029
|
const expected = await expectedTokens(input);
|
|
4965
5030
|
const { tuples } = resolved.providers.credentials;
|
|
4966
5031
|
for (const impl of loader.get("credentials")) {
|
|
4967
5032
|
const tuple = tuples.find((t) => t.provider === impl.providerName);
|
|
4968
5033
|
const environment = tuple && credentialsEnvironment(tuple, resolved);
|
|
4969
|
-
rows.push(...environment ? await checkProvider(impl, environment, expected) : [row$
|
|
5034
|
+
rows.push(...environment ? await checkProvider(impl, environment, expected) : [row$9(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set")]);
|
|
4970
5035
|
}
|
|
4971
5036
|
return rows;
|
|
4972
5037
|
}
|
|
4973
5038
|
async function checkProvider(impl, environment, expected) {
|
|
4974
5039
|
const provider = impl.providerName;
|
|
4975
|
-
if (!impl.inspect) return [row$
|
|
4976
|
-
if (expected.length === 0) return [row$
|
|
5040
|
+
if (!impl.inspect) return [row$9(provider, "skip", "cannot list the variables without reading their values")];
|
|
5041
|
+
if (expected.length === 0) return [row$9(provider, "skip", "no configured plugin lists the tokens it takes")];
|
|
4977
5042
|
try {
|
|
4978
5043
|
const found = await impl.inspect(environment);
|
|
4979
5044
|
const held = new Set(found.names);
|
|
4980
5045
|
const where = found.environment === environment ? `"${found.environment}"` : `"${found.environment}" (the config writes "${environment}")`;
|
|
4981
5046
|
return expected.map(({ name, optional }) => {
|
|
4982
|
-
if (held.has(name)) return row$
|
|
4983
|
-
return optional ? row$
|
|
5047
|
+
if (held.has(name)) return row$9(provider, "ok", `present in ${where}`, name);
|
|
5048
|
+
return optional ? row$9(provider, "skip", `optional, not set in ${where}`, name) : row$9(provider, "fail", `missing from ${where}`, name);
|
|
4984
5049
|
});
|
|
4985
5050
|
} catch (err) {
|
|
4986
|
-
return [row$
|
|
5051
|
+
return [row$9(provider, "fail", errorMessage(err))];
|
|
4987
5052
|
}
|
|
4988
5053
|
}
|
|
4989
5054
|
/**
|
|
@@ -5814,7 +5879,7 @@ async function runDoctorDns(input) {
|
|
|
5814
5879
|
});
|
|
5815
5880
|
else if (!loader.has("dns")) {
|
|
5816
5881
|
const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
|
|
5817
|
-
for (const zone of zones) rows.push(row$
|
|
5882
|
+
for (const zone of zones) rows.push(row$8(zone, "skip", why));
|
|
5818
5883
|
for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
|
|
5819
5884
|
} else {
|
|
5820
5885
|
const dns = loader.get("dns");
|
|
@@ -5836,7 +5901,7 @@ async function runDoctorDns(input) {
|
|
|
5836
5901
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
5837
5902
|
};
|
|
5838
5903
|
}
|
|
5839
|
-
function row$
|
|
5904
|
+
function row$8(zone, status, detail, problems = []) {
|
|
5840
5905
|
return {
|
|
5841
5906
|
id: `dns-${zone}`,
|
|
5842
5907
|
title: `${zone} records exist`,
|
|
@@ -5865,7 +5930,7 @@ async function checkDomain(dns, deploy, project, hostname) {
|
|
|
5865
5930
|
return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
|
|
5866
5931
|
}
|
|
5867
5932
|
}
|
|
5868
|
-
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$
|
|
5933
|
+
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$8(zone, ...args)) {
|
|
5869
5934
|
try {
|
|
5870
5935
|
const have = await dns.listRecords(zone);
|
|
5871
5936
|
const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
|
|
@@ -6000,7 +6065,7 @@ function installationSettingsUrl(account, id) {
|
|
|
6000
6065
|
return `https://github.com/settings/installations/${id}`;
|
|
6001
6066
|
}
|
|
6002
6067
|
// src/commands/doctor-github-app/app-rows.ts
|
|
6003
|
-
const row$
|
|
6068
|
+
const row$7 = (name, what, problems, ok) => ({
|
|
6004
6069
|
id: `${name}:${what}`,
|
|
6005
6070
|
title: `${name}: ${what}`,
|
|
6006
6071
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -6027,9 +6092,9 @@ function appRows(name, manifest, app, installations) {
|
|
|
6027
6092
|
return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
|
|
6028
6093
|
});
|
|
6029
6094
|
return [
|
|
6030
|
-
row$
|
|
6031
|
-
row$
|
|
6032
|
-
row$
|
|
6095
|
+
row$7(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
|
|
6096
|
+
row$7(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
|
|
6097
|
+
row$7(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
|
|
6033
6098
|
];
|
|
6034
6099
|
}
|
|
6035
6100
|
// src/commands/doctor-github-app/parse-manifest.ts
|
|
@@ -6087,7 +6152,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
6087
6152
|
assertPluginsResolvable$1(loader, "doctor github-app");
|
|
6088
6153
|
}
|
|
6089
6154
|
const rows = [];
|
|
6090
|
-
if (instances.length === 0) rows.push(row$
|
|
6155
|
+
if (instances.length === 0) rows.push(row$6("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
|
|
6091
6156
|
for (const instance of instances) rows.push(...await checkInstance(instance, loader, input));
|
|
6092
6157
|
printCheckRows(rows, print);
|
|
6093
6158
|
const summary = summariseChecks(rows);
|
|
@@ -6104,7 +6169,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
6104
6169
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
6105
6170
|
};
|
|
6106
6171
|
}
|
|
6107
|
-
function row$
|
|
6172
|
+
function row$6(name, what, status, detail) {
|
|
6108
6173
|
return {
|
|
6109
6174
|
id: `${name}:${what}`,
|
|
6110
6175
|
title: `${name}: ${what}`,
|
|
@@ -6147,19 +6212,19 @@ async function checkInstance(instance, loader, input) {
|
|
|
6147
6212
|
try {
|
|
6148
6213
|
manifest = parseManifest(readManifest(instance.manifest));
|
|
6149
6214
|
} catch (err) {
|
|
6150
|
-
return [row$
|
|
6215
|
+
return [row$6(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
|
|
6151
6216
|
}
|
|
6152
6217
|
const read = await readCredentials(instance, loader);
|
|
6153
|
-
if ("reason" in read) return [row$
|
|
6218
|
+
if ("reason" in read) return [row$6(name, "reachable", "skip", read.reason)];
|
|
6154
6219
|
const api = input.api ?? defaultApi;
|
|
6155
6220
|
const secrets = [read.creds.privateKey];
|
|
6156
6221
|
try {
|
|
6157
6222
|
const app = await api.getApp(read.creds);
|
|
6158
6223
|
const installations = await api.listAppInstallations(read.creds);
|
|
6159
6224
|
const owner = app.owner ? `, owned by ${app.owner.login}` : "";
|
|
6160
|
-
return [row$
|
|
6225
|
+
return [row$6(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
|
|
6161
6226
|
} catch (err) {
|
|
6162
|
-
return [row$
|
|
6227
|
+
return [row$6(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed(err, secrets)}`)];
|
|
6163
6228
|
}
|
|
6164
6229
|
}
|
|
6165
6230
|
// src/commands/doctor-github-app/doctor-github-app.command.ts
|
|
@@ -6226,7 +6291,7 @@ function datasetTargets(config) {
|
|
|
6226
6291
|
* dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
|
|
6227
6292
|
* a name, a token or a response that cannot be read is a skip with the reason.
|
|
6228
6293
|
*/
|
|
6229
|
-
const row$
|
|
6294
|
+
const row$5 = (id, title, status, detail, problems = []) => ({
|
|
6230
6295
|
id,
|
|
6231
6296
|
title,
|
|
6232
6297
|
status,
|
|
@@ -6243,7 +6308,7 @@ async function runDoctorLogs(input) {
|
|
|
6243
6308
|
if (!loader.has("logs")) {
|
|
6244
6309
|
const failure = loader.loadFailures().find((f) => f.key === "logs");
|
|
6245
6310
|
const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
|
|
6246
|
-
rows.push(row$
|
|
6311
|
+
rows.push(row$5("logs", "logs", "skip", why));
|
|
6247
6312
|
} else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
|
|
6248
6313
|
printCheckRows(rows, print);
|
|
6249
6314
|
const summary = summariseChecks(rows);
|
|
@@ -6267,38 +6332,38 @@ async function checkLogs(logs, targets) {
|
|
|
6267
6332
|
for (const target of targets) {
|
|
6268
6333
|
const id = `logs:dataset:${target.id}`;
|
|
6269
6334
|
const title = `dataset for ${target.label}`;
|
|
6270
|
-
if (!target.name) rows.push(row$
|
|
6271
|
-
else if (!token.usable) rows.push(row$
|
|
6272
|
-
else if (!logs.readDataset) rows.push(row$
|
|
6335
|
+
if (!target.name) rows.push(row$5(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
|
|
6336
|
+
else if (!token.usable) rows.push(row$5(id, title, "skip", `${target.name}: not checked, the token is not usable`));
|
|
6337
|
+
else if (!logs.readDataset) rows.push(row$5(id, title, "skip", `${logs.providerName} cannot read a dataset`));
|
|
6273
6338
|
else rows.push(...await checkDataset(logs, target, target.name, id, title));
|
|
6274
6339
|
}
|
|
6275
6340
|
const org = resolveValue$2(["AXIOM_ORG"], void 0, { prefix: PREFIX });
|
|
6276
|
-
rows.push(org ? row$
|
|
6341
|
+
rows.push(org ? row$5("logs:org", "organization", "ok", `${PREFIX}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$5("logs:org", "organization", "skip", `${PREFIX}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links and check-dispatched need it`));
|
|
6277
6342
|
return rows;
|
|
6278
6343
|
}
|
|
6279
6344
|
/** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
|
|
6280
6345
|
async function checkToken(logs) {
|
|
6281
6346
|
const title = "token is accepted";
|
|
6282
6347
|
if (!logs.checkToken) return {
|
|
6283
|
-
row: row$
|
|
6348
|
+
row: row$5("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
|
|
6284
6349
|
usable: true
|
|
6285
6350
|
};
|
|
6286
6351
|
try {
|
|
6287
6352
|
const result = await logs.checkToken();
|
|
6288
6353
|
if (result.ok) return {
|
|
6289
|
-
row: row$
|
|
6354
|
+
row: row$5("logs:token", title, "ok", `${logs.providerName} accepts the token`),
|
|
6290
6355
|
usable: true
|
|
6291
6356
|
};
|
|
6292
6357
|
const reason = result.reason ?? `${logs.providerName} refused the token`;
|
|
6293
6358
|
return {
|
|
6294
|
-
row: row$
|
|
6359
|
+
row: row$5("logs:token", title, "fail", reason, [reason]),
|
|
6295
6360
|
usable: false
|
|
6296
6361
|
};
|
|
6297
6362
|
} catch (err) {
|
|
6298
6363
|
const noToken = missingTokenReason(err);
|
|
6299
6364
|
const detail = noToken ?? `could not check the token: ${describeError(err)}`;
|
|
6300
6365
|
return {
|
|
6301
|
-
row: row$
|
|
6366
|
+
row: row$5("logs:token", title, "skip", detail),
|
|
6302
6367
|
usable: noToken === void 0
|
|
6303
6368
|
};
|
|
6304
6369
|
}
|
|
@@ -6308,13 +6373,13 @@ async function checkDataset(logs, target, name, id, title) {
|
|
|
6308
6373
|
const found = await logs.readDataset(name);
|
|
6309
6374
|
if (!found.exists) {
|
|
6310
6375
|
const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
|
|
6311
|
-
return [row$
|
|
6376
|
+
return [row$5(id, title, "fail", `${name} does not exist`, [problem])];
|
|
6312
6377
|
}
|
|
6313
6378
|
const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
|
|
6314
|
-
return [row$
|
|
6379
|
+
return [row$5(id, title, "ok", `${name} exists`), row$5(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
|
|
6315
6380
|
} catch (err) {
|
|
6316
6381
|
const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
|
|
6317
|
-
return [row$
|
|
6382
|
+
return [row$5(id, title, "skip", detail)];
|
|
6318
6383
|
}
|
|
6319
6384
|
}
|
|
6320
6385
|
// src/commands/doctor-logs/doctor-logs.command.ts
|
|
@@ -7968,7 +8033,7 @@ const GROUP_NAMES = /* @__PURE__ */ new Set([
|
|
|
7968
8033
|
/** What a task id looks like: lowercase letters and digits, with a hyphen or a colon inside. */
|
|
7969
8034
|
const ID = /^[a-z][a-z0-9:-]*$/;
|
|
7970
8035
|
/** The unquoted text of a YAML list entry's value. */
|
|
7971
|
-
const unquote = (value) => value.trim().replace(/^(["'])(.*)\1$/, "$2");
|
|
8036
|
+
const unquote$1 = (value) => value.trim().replace(/^(["'])(.*)\1$/, "$2");
|
|
7972
8037
|
/**
|
|
7973
8038
|
* Problems with the workflow names a workflow lists under `workflow_run: workflows:`, as human-readable lines: one for
|
|
7974
8039
|
* each name that is an old group name (`Verification`), an old dotted task name or a lowercase name that is no task id.
|
|
@@ -7977,7 +8042,7 @@ const unquote = (value) => value.trim().replace(/^(["'])(.*)\1$/, "$2");
|
|
|
7977
8042
|
* alone: this reads the text, not the repo's workflows.
|
|
7978
8043
|
*/
|
|
7979
8044
|
function workflowNameProblems(text) {
|
|
7980
|
-
return [...(/^ {2}workflow_run:\n {4}workflows:\n((?: {6}- [^\n]+\n)+)/m.exec(text)?.[1] ?? "").matchAll(/^ {6}- ([^\n#]+)/gm)].map((m) => unquote(m[1])).flatMap((name) => {
|
|
8045
|
+
return [...(/^ {2}workflow_run:\n {4}workflows:\n((?: {6}- [^\n]+\n)+)/m.exec(text)?.[1] ?? "").matchAll(/^ {6}- ([^\n#]+)/gm)].map((m) => unquote$1(m[1])).flatMap((name) => {
|
|
7981
8046
|
if (GROUP_NAMES.has(name)) return [`${name}: an old group name; a caller's workflow is named for its task id`];
|
|
7982
8047
|
if (!ID.test(name)) return [];
|
|
7983
8048
|
if (name in LEGACY_NAMES) return [`${name}: an old task name; a caller's workflow is named for its task id`];
|
|
@@ -9303,7 +9368,7 @@ const info = (id, title, noun, extras) => ({
|
|
|
9303
9368
|
detail: `info: ${extras.length} ${noun} not in the template (never deleted)`,
|
|
9304
9369
|
problems: extras
|
|
9305
9370
|
});
|
|
9306
|
-
const row$
|
|
9371
|
+
const row$4 = (id, title, problems, ok) => ({
|
|
9307
9372
|
id,
|
|
9308
9373
|
title,
|
|
9309
9374
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -9339,19 +9404,19 @@ function viewProblems(want, found) {
|
|
|
9339
9404
|
function boardRows(boardName, template, state) {
|
|
9340
9405
|
const id = `project:${boardName}`;
|
|
9341
9406
|
const rows = [];
|
|
9342
|
-
rows.push(row$
|
|
9407
|
+
rows.push(row$4(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
|
|
9343
9408
|
const extraStatuses = state.statuses.filter((s) => !template.statuses.some((t) => t.name === s));
|
|
9344
9409
|
if (extraStatuses.length > 0) rows.push(info(`${id}:extra-statuses`, `${boardName}: extra statuses`, "status(es)", extraStatuses));
|
|
9345
|
-
for (const want of template.fields) rows.push(row$
|
|
9410
|
+
for (const want of template.fields) rows.push(row$4(`${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));
|
|
9346
9411
|
const extraFields = state.fields.filter((f) => !template.fields.some((t) => t.name === f.name));
|
|
9347
9412
|
if (extraFields.length > 0) rows.push(info(`${id}:extra-fields`, `${boardName}: extra fields`, "field(s)", extraFields.map((f) => f.name)));
|
|
9348
|
-
for (const want of template.views) rows.push(row$
|
|
9413
|
+
for (const want of template.views) rows.push(row$4(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
|
|
9349
9414
|
const extraViews = state.views.filter((v) => !template.views.some((t) => t.name === v.name));
|
|
9350
9415
|
if (extraViews.length > 0) rows.push(info(`${id}:extra-views`, `${boardName}: extra views`, "view(s)", extraViews.map((v) => v.name)));
|
|
9351
9416
|
for (const name of template.rules ?? []) {
|
|
9352
9417
|
const found = state.rules.find((r) => r.name === name);
|
|
9353
9418
|
const problems = !found ? [`missing rule ${name}`] : found.enabled ? [] : [`rule ${name} is off`];
|
|
9354
|
-
rows.push(row$
|
|
9419
|
+
rows.push(row$4(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
|
|
9355
9420
|
}
|
|
9356
9421
|
return rows;
|
|
9357
9422
|
}
|
|
@@ -9411,7 +9476,7 @@ function itemRows(boardName, items) {
|
|
|
9411
9476
|
* never fail the run. A template file that does not read is a failure naming the file. `--post [channel]` shares the
|
|
9412
9477
|
* failing rows through the `notifications` provider's bot, like `doctor notifications --post`.
|
|
9413
9478
|
*/
|
|
9414
|
-
const row$
|
|
9479
|
+
const row$3 = (id, title, status, detail, problems = []) => ({
|
|
9415
9480
|
id,
|
|
9416
9481
|
title,
|
|
9417
9482
|
status,
|
|
@@ -9465,14 +9530,14 @@ async function checkBoards(input, loader) {
|
|
|
9465
9530
|
loader,
|
|
9466
9531
|
...input.io ? { io: input.io } : {}
|
|
9467
9532
|
});
|
|
9468
|
-
if (!opened.ok) return [row$
|
|
9533
|
+
if (!opened.ok) return [row$3("project", "project", opened.kind, opened.reason, opened.problems)];
|
|
9469
9534
|
const { projects, owner, boards, templates, templateProblems } = opened.context;
|
|
9470
9535
|
const rows = templateProblems.map((problem) => {
|
|
9471
9536
|
/* v8 ignore next -- split always returns at least one element; the fallback only satisfies noUncheckedIndexedAccess */
|
|
9472
9537
|
const file = problem.split(": ")[0] ?? problem;
|
|
9473
|
-
return row$
|
|
9538
|
+
return row$3(`project:template:${file}`, `template file ${file}`, "fail", problem);
|
|
9474
9539
|
});
|
|
9475
|
-
if (boards.length === 0) return [...rows, row$
|
|
9540
|
+
if (boards.length === 0) return [...rows, row$3("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
|
|
9476
9541
|
for (const declared of boards) {
|
|
9477
9542
|
const template = templates[declared.template];
|
|
9478
9543
|
const title = `${declared.name}: board exists and is open`;
|
|
@@ -9480,18 +9545,18 @@ async function checkBoards(input, loader) {
|
|
|
9480
9545
|
const board = await projects.find(owner, declared.name);
|
|
9481
9546
|
if (!board) {
|
|
9482
9547
|
const closed = (await projects.list(owner)).some((b) => b.name === declared.name && b.closed);
|
|
9483
|
-
rows.push(row$
|
|
9548
|
+
rows.push(row$3(`project:${declared.name}`, title, "fail", closed ? "the board is closed" : "no open board has this name", [closed ? "reopen it, or run `holocron project setup` to make a new one" : "run `holocron project setup`"]));
|
|
9484
9549
|
continue;
|
|
9485
9550
|
}
|
|
9486
|
-
rows.push(row$
|
|
9551
|
+
rows.push(row$3(`project:${declared.name}`, title, "ok", board.url));
|
|
9487
9552
|
if (!template) {
|
|
9488
|
-
rows.push(row$
|
|
9553
|
+
rows.push(row$3(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
|
|
9489
9554
|
continue;
|
|
9490
9555
|
}
|
|
9491
9556
|
rows.push(...boardRows(declared.name, template, await projects.read(owner, board)));
|
|
9492
|
-
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$
|
|
9557
|
+
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$3(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
|
|
9493
9558
|
} catch (err) {
|
|
9494
|
-
rows.push(row$
|
|
9559
|
+
rows.push(row$3(`project:${declared.name}`, title, "fail", describeError(err)));
|
|
9495
9560
|
}
|
|
9496
9561
|
}
|
|
9497
9562
|
return rows;
|
|
@@ -10166,19 +10231,19 @@ async function runDoctorRepo(input) {
|
|
|
10166
10231
|
const rows = [];
|
|
10167
10232
|
if (!loader.has("source")) {
|
|
10168
10233
|
const why = whyMissing(loader, "source", "no `source` provider to read the repository with");
|
|
10169
|
-
for (const check of checks) rows.push(row$
|
|
10234
|
+
for (const check of checks) rows.push(row$2(check, { skip: why }));
|
|
10170
10235
|
} else {
|
|
10171
10236
|
const source = loader.get("source");
|
|
10172
10237
|
for (const check of checks) {
|
|
10173
10238
|
if (typeof source[check.needs] !== "function") {
|
|
10174
|
-
rows.push(row$
|
|
10239
|
+
rows.push(row$2(check, { skip: `provider does not implement ${check.needs}` }));
|
|
10175
10240
|
continue;
|
|
10176
10241
|
}
|
|
10177
10242
|
try {
|
|
10178
|
-
rows.push(row$
|
|
10243
|
+
rows.push(row$2(check, await check.run(source)));
|
|
10179
10244
|
} catch (err) {
|
|
10180
10245
|
const noToken = missingTokenReason(err);
|
|
10181
|
-
if (noToken !== void 0) rows.push(row$
|
|
10246
|
+
if (noToken !== void 0) rows.push(row$2(check, { skip: noToken }));
|
|
10182
10247
|
else rows.push({
|
|
10183
10248
|
id: check.id,
|
|
10184
10249
|
title: check.title,
|
|
@@ -10204,7 +10269,7 @@ async function runDoctorRepo(input) {
|
|
|
10204
10269
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
10205
10270
|
};
|
|
10206
10271
|
}
|
|
10207
|
-
function row$
|
|
10272
|
+
function row$2(check, result) {
|
|
10208
10273
|
const { id, title } = check;
|
|
10209
10274
|
if ("skip" in result) return {
|
|
10210
10275
|
id,
|
|
@@ -10612,14 +10677,14 @@ async function runDoctorVariables(input) {
|
|
|
10612
10677
|
});
|
|
10613
10678
|
else if (!loader.has("source")) {
|
|
10614
10679
|
const why = whyMissing(loader, "source", "no `source` provider to read them with");
|
|
10615
|
-
for (const check of checks) rows.push(row(check, { skip: why }));
|
|
10680
|
+
for (const check of checks) rows.push(row$1(check, { skip: why }));
|
|
10616
10681
|
} else {
|
|
10617
10682
|
const source = loader.get("source");
|
|
10618
10683
|
for (const check of checks) try {
|
|
10619
|
-
rows.push(row(check, await check.run(source)));
|
|
10684
|
+
rows.push(row$1(check, await check.run(source)));
|
|
10620
10685
|
} catch (err) {
|
|
10621
10686
|
const noToken = missingTokenReason(err);
|
|
10622
|
-
if (noToken !== void 0) rows.push(row(check, { skip: noToken }));
|
|
10687
|
+
if (noToken !== void 0) rows.push(row$1(check, { skip: noToken }));
|
|
10623
10688
|
else rows.push({
|
|
10624
10689
|
id: check.id,
|
|
10625
10690
|
title: check.title,
|
|
@@ -10644,7 +10709,7 @@ async function runDoctorVariables(input) {
|
|
|
10644
10709
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
10645
10710
|
};
|
|
10646
10711
|
}
|
|
10647
|
-
function row(check, result) {
|
|
10712
|
+
function row$1(check, result) {
|
|
10648
10713
|
const { id, title } = check;
|
|
10649
10714
|
if ("skip" in result) return {
|
|
10650
10715
|
id,
|
|
@@ -11407,6 +11472,280 @@ const githubAppCommand = {
|
|
|
11407
11472
|
builder: (y) => y.command(githubAppCreateCommand).command(groupMenu$1("github-app")),
|
|
11408
11473
|
handler: () => {}
|
|
11409
11474
|
};
|
|
11475
|
+
// src/commands/ideas-sync/list-notes/list-notes.ts
|
|
11476
|
+
/**
|
|
11477
|
+
* Every Markdown note under `dir`, as paths relative to it with `/` separators, sorted. A folder whose name starts
|
|
11478
|
+
* with `_` or `.` (`.obsidian`, `.trash`, `_archive`) is not entered. `undefined` when `dir` itself cannot be read.
|
|
11479
|
+
*/
|
|
11480
|
+
function listNotes(io, dir) {
|
|
11481
|
+
const top = io.readDir(dir);
|
|
11482
|
+
if (!top) return void 0;
|
|
11483
|
+
const found = [];
|
|
11484
|
+
const walk = (relative, entries) => {
|
|
11485
|
+
for (const entry of entries ?? []) {
|
|
11486
|
+
const path = relative === "" ? entry.name : `${relative}/${entry.name}`;
|
|
11487
|
+
if (entry.directory) {
|
|
11488
|
+
if (!/^[_.]/.test(entry.name)) walk(path, io.readDir(join(dir, path)));
|
|
11489
|
+
} else if (entry.name.toLowerCase().endsWith(".md") && !entry.name.startsWith(".")) found.push(path);
|
|
11490
|
+
}
|
|
11491
|
+
};
|
|
11492
|
+
walk("", top);
|
|
11493
|
+
return found.sort();
|
|
11494
|
+
}
|
|
11495
|
+
// src/commands/ideas-sync/parse-note/parse-note.ts
|
|
11496
|
+
const FRONTMATTER = /^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/;
|
|
11497
|
+
const FENCE = /^(```|~~~)[\s\S]*?^\1/gm;
|
|
11498
|
+
const WEB_ADDRESS = /^[a-z][a-z0-9+.-]*:/i;
|
|
11499
|
+
const unquote = (value) => value.replace(/^(["'])(.*)\1$/, "$2").trim();
|
|
11500
|
+
/**
|
|
11501
|
+
* Reads one note: its `status:` and `issue:` properties, its title, its text without the frontmatter and the files it
|
|
11502
|
+
* embeds. The title is the first `#` heading, else `fileName` without `.md`. An embed is `![[x]]` (any) or ``
|
|
11503
|
+
* where `x` is not an address with a scheme; embeds inside a code fence are text and do not count.
|
|
11504
|
+
*/
|
|
11505
|
+
function parseNote(text, fileName) {
|
|
11506
|
+
const fields = parseFrontmatter(text.replace(/\r\n/g, "\n"));
|
|
11507
|
+
const body = text.replace(FRONTMATTER, "");
|
|
11508
|
+
const prose = body.replace(/\r/g, "").replace(FENCE, "");
|
|
11509
|
+
const heading = /^#[ \t]+(.+?)[ \t]*$/m.exec(prose);
|
|
11510
|
+
const wiki = [...prose.matchAll(/!\[\[[^\]]+\]\]/g)].map((m) => m[0]);
|
|
11511
|
+
const links = [...prose.matchAll(/!\[[^\]]*\]\(([^)\s]+)[^)]*\)/g)].filter((m) => !WEB_ADDRESS.test(m[1])).map((m) => m[0]);
|
|
11512
|
+
return {
|
|
11513
|
+
status: unquote(fields?.get("status")?.value ?? ""),
|
|
11514
|
+
issue: unquote(fields?.get("issue")?.value ?? ""),
|
|
11515
|
+
title: heading?.[1] ?? fileName.replace(/\.md$/i, ""),
|
|
11516
|
+
body,
|
|
11517
|
+
attachments: [...wiki, ...links]
|
|
11518
|
+
};
|
|
11519
|
+
}
|
|
11520
|
+
// src/commands/ideas-sync/real-ideas-io/real-ideas-io.ts
|
|
11521
|
+
/** The `ideas sync` inputs from the real filesystem. */
|
|
11522
|
+
function realIdeasIo() {
|
|
11523
|
+
/* v8 ignore start -- reads the real filesystem; the command is tested with an injected io */
|
|
11524
|
+
return {
|
|
11525
|
+
readDir: (path) => {
|
|
11526
|
+
try {
|
|
11527
|
+
return readdirSync(path, { withFileTypes: true }).map((e) => ({
|
|
11528
|
+
name: e.name,
|
|
11529
|
+
directory: e.isDirectory()
|
|
11530
|
+
}));
|
|
11531
|
+
} catch {
|
|
11532
|
+
return;
|
|
11533
|
+
}
|
|
11534
|
+
},
|
|
11535
|
+
read: (path) => {
|
|
11536
|
+
try {
|
|
11537
|
+
return readFileSync(path, "utf8");
|
|
11538
|
+
} catch {
|
|
11539
|
+
return;
|
|
11540
|
+
}
|
|
11541
|
+
},
|
|
11542
|
+
write: (path, text) => writeFileSync(path, text, "utf8"),
|
|
11543
|
+
home: () => homedir()
|
|
11544
|
+
};
|
|
11545
|
+
/* v8 ignore stop */
|
|
11546
|
+
}
|
|
11547
|
+
// src/commands/ideas-sync/resolve-ideas-dir/resolve-ideas-dir.ts
|
|
11548
|
+
/**
|
|
11549
|
+
* The folder of idea notes: `HOLOCRON_IDEAS_DIR` (then `IDEAS_DIR`) when set, else `ideas.dir` of the config.
|
|
11550
|
+
* A leading `~` is the home folder. `undefined` when neither names one.
|
|
11551
|
+
*/
|
|
11552
|
+
function resolveIdeasDir(ideas, home, source) {
|
|
11553
|
+
const dir = holocronEnv(source).get("IDEAS_DIR") ?? ideas?.dir;
|
|
11554
|
+
if (dir === void 0) return void 0;
|
|
11555
|
+
if (dir === "~") return home;
|
|
11556
|
+
return dir.startsWith("~/") ? join(home, dir.slice(2)) : dir;
|
|
11557
|
+
}
|
|
11558
|
+
// src/commands/ideas-sync/write-issue-key/write-issue-key.ts
|
|
11559
|
+
const BLOCK = /^---(\r?\n)([\s\S]*?)(\r?\n)---/;
|
|
11560
|
+
/**
|
|
11561
|
+
* The note's text with `issue: <key>` in its frontmatter: a blank `issue:` line is filled in, else a line is added at
|
|
11562
|
+
* the end of the block. Everything else, including line endings and the body, is left byte for byte. A note with no
|
|
11563
|
+
* frontmatter is returned unchanged (such a note has no `status:`, so it is never filed).
|
|
11564
|
+
*/
|
|
11565
|
+
function writeIssueKey(text, key) {
|
|
11566
|
+
const match = BLOCK.exec(text);
|
|
11567
|
+
if (!match) return text;
|
|
11568
|
+
const [whole, open, inner, close] = match;
|
|
11569
|
+
const lines = inner.split(/\r?\n/);
|
|
11570
|
+
const separators = inner.match(/\r?\n/g) ?? [];
|
|
11571
|
+
const at = lines.findIndex((line) => /^issue:/.test(line));
|
|
11572
|
+
const next = at === -1 ? [...lines, `issue: ${key}`] : lines.map((line, i) => i === at ? `issue: ${key}` : line);
|
|
11573
|
+
let rebuilt = next[0];
|
|
11574
|
+
next.slice(1).forEach((line, i) => {
|
|
11575
|
+
rebuilt += (separators[i] ?? close) + line;
|
|
11576
|
+
});
|
|
11577
|
+
return `---${open}${rebuilt}${close}---${text.slice(whole.length)}`;
|
|
11578
|
+
}
|
|
11579
|
+
// src/commands/ideas-sync/run-ideas-sync/run-ideas-sync.ts
|
|
11580
|
+
/**
|
|
11581
|
+
* `holocron ideas sync` — files the idea notes that are ready.
|
|
11582
|
+
*
|
|
11583
|
+
* It reads every Markdown note in `ideas.dir` (not in a folder whose name starts with `_` or `.`). A note whose
|
|
11584
|
+
* `status:` is the filing state (default `in-progress`) and that has no `issue:` becomes an issue through the repo's
|
|
11585
|
+
* `issues` provider, and its `issue:` property is then written in the tracker's own syntax, which is what makes the
|
|
11586
|
+
* step run once. A note with embedded files is reported and skipped, since an issue body cannot carry them. Only
|
|
11587
|
+
* notes to be filed, and notes that need the person's attention, get a row; the rest are counted. The issue body ends
|
|
11588
|
+
* with a hidden `<!-- holocron:idea <path> -->` line, and an issue that carries it is reused instead of making a second
|
|
11589
|
+
* one (found with `Issues.search`, the recent issues only). It never deletes anything, and a note it cannot file is a
|
|
11590
|
+
* failing row (the run goes on). It writes, so it asks first unless `--dry-run` or `--yes` (without a terminal it refuses instead).
|
|
11591
|
+
*/
|
|
11592
|
+
/** The state that files a note when the config names none. */
|
|
11593
|
+
const DEFAULT_FILING_STATE = "in-progress";
|
|
11594
|
+
const row = (id, status, detail) => ({
|
|
11595
|
+
id,
|
|
11596
|
+
title: id,
|
|
11597
|
+
status,
|
|
11598
|
+
detail,
|
|
11599
|
+
problems: []
|
|
11600
|
+
});
|
|
11601
|
+
/**
|
|
11602
|
+
* The hidden line that ties an issue to its note. A later run looks for it before it creates an issue, so a note whose
|
|
11603
|
+
* `issue:` could not be written is not filed twice.
|
|
11604
|
+
*/
|
|
11605
|
+
const marker = (path) => `<!-- holocron:idea ${path} -->`;
|
|
11606
|
+
/** The issue's body: the note's text, the line that traces the issue to its idea, and the hidden marker. */
|
|
11607
|
+
const issueBody = (note, path) => `${note.body.trim()}\n\nFiled from idea: ${note.title}\n${marker(path)}`;
|
|
11608
|
+
/** How many recent issues are searched for the marker (the narrowest existing method, `Issues.search`). */
|
|
11609
|
+
const SEARCH_LIMIT = 100;
|
|
11610
|
+
async function runIdeasSync(input) {
|
|
11611
|
+
/* v8 ignore next -- the console is only used outside tests, which inject `print` */
|
|
11612
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
11613
|
+
/* v8 ignore next -- the real disk is only used outside tests, which inject `io` */
|
|
11614
|
+
const io = input.io ?? realIdeasIo();
|
|
11615
|
+
const dryRun = Boolean(input.context.dryRun);
|
|
11616
|
+
let notReady = 0;
|
|
11617
|
+
const finish = (rows, status) => {
|
|
11618
|
+
printCheckRows(rows, print);
|
|
11619
|
+
const summary = summariseChecks(rows);
|
|
11620
|
+
printCheckSummary(summary, print);
|
|
11621
|
+
if (notReady > 0) print(` ${notReady} note(s) not ready (another status, or already filed), shown in no row`);
|
|
11622
|
+
return {
|
|
11623
|
+
status: status ?? (summary.fail > 0 ? "fail" : "ok"),
|
|
11624
|
+
rows
|
|
11625
|
+
};
|
|
11626
|
+
};
|
|
11627
|
+
print(style.header(`Holocron ideas sync${dryRun ? " (dry-run)" : ""}`));
|
|
11628
|
+
print("");
|
|
11629
|
+
const ideas = input.loaded.resolved.ideas;
|
|
11630
|
+
const dir = resolveIdeasDir(ideas, io.home(), input.env);
|
|
11631
|
+
if (!dir) return finish([row("ideas", "fail", "no notes folder: set `ideas.dir` in holocron.config or HOLOCRON_IDEAS_DIR")]);
|
|
11632
|
+
const paths = listNotes(io, dir);
|
|
11633
|
+
if (!paths) return finish([row(dir, "fail", "the notes folder does not exist or cannot be read")]);
|
|
11634
|
+
const fileState = ideas?.states?.file ?? DEFAULT_FILING_STATE;
|
|
11635
|
+
const rows = [];
|
|
11636
|
+
const ready = [];
|
|
11637
|
+
for (const path of paths) {
|
|
11638
|
+
const text = io.read(join(dir, path));
|
|
11639
|
+
if (text === void 0) {
|
|
11640
|
+
rows.push(row(path, "fail", "cannot be read"));
|
|
11641
|
+
continue;
|
|
11642
|
+
}
|
|
11643
|
+
const note = parseNote(text, path.slice(path.lastIndexOf("/") + 1));
|
|
11644
|
+
if (note.status !== fileState || note.issue !== "") notReady++;
|
|
11645
|
+
else if (note.attachments.length > 0) rows.push(row(path, "skip", `has embedded files an issue cannot carry (${note.attachments.join(", ")}); not filed`));
|
|
11646
|
+
else ready.push({
|
|
11647
|
+
path,
|
|
11648
|
+
note
|
|
11649
|
+
});
|
|
11650
|
+
}
|
|
11651
|
+
if (ready.length === 0) return finish(rows);
|
|
11652
|
+
if (dryRun) {
|
|
11653
|
+
for (const { path, note } of ready) rows.push(row(path, "skip", `would file "${note.title}"`));
|
|
11654
|
+
return finish(rows.sort((a, b) => a.id.localeCompare(b.id)));
|
|
11655
|
+
}
|
|
11656
|
+
if (!input.yes) {
|
|
11657
|
+
if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`\`ideas sync\` creates ${ready.length} issue(s) and edits the notes; pass --yes to run it without asking, or --dry-run to preview`);
|
|
11658
|
+
if (!await (input.confirm ?? ((message) => confirm({
|
|
11659
|
+
message,
|
|
11660
|
+
default: false
|
|
11661
|
+
})))(`File ${ready.length} idea(s) as issues and record the issue in each note?`)) {
|
|
11662
|
+
print(` ${style.skip("cancelled; nothing was changed")}`);
|
|
11663
|
+
return {
|
|
11664
|
+
status: "cancelled",
|
|
11665
|
+
rows: []
|
|
11666
|
+
};
|
|
11667
|
+
}
|
|
11668
|
+
}
|
|
11669
|
+
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
11670
|
+
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
11671
|
+
await loader.load();
|
|
11672
|
+
assertPluginsResolvable$1(loader, "ideas sync");
|
|
11673
|
+
const issues = loader.has("issues") ? loader.get("issues") : void 0;
|
|
11674
|
+
let recent = [];
|
|
11675
|
+
let searchError;
|
|
11676
|
+
if (issues) try {
|
|
11677
|
+
recent = await issues.search({ limit: SEARCH_LIMIT });
|
|
11678
|
+
} catch (err) {
|
|
11679
|
+
searchError = err;
|
|
11680
|
+
}
|
|
11681
|
+
const searchFailed = searchError !== void 0;
|
|
11682
|
+
for (const { path, note } of ready) {
|
|
11683
|
+
if (!issues) {
|
|
11684
|
+
rows.push(row(path, "fail", "the config has no `issues` provider to file it with"));
|
|
11685
|
+
continue;
|
|
11686
|
+
}
|
|
11687
|
+
if (searchFailed) {
|
|
11688
|
+
rows.push(row(path, "fail", `could not check for an existing issue, so none was created: ${describeError(searchError)}`));
|
|
11689
|
+
continue;
|
|
11690
|
+
}
|
|
11691
|
+
let key;
|
|
11692
|
+
const existing = recent.find((issue) => issue.body?.includes(marker(path)));
|
|
11693
|
+
if (existing) key = existing.key;
|
|
11694
|
+
else try {
|
|
11695
|
+
({key} = await issues.create({
|
|
11696
|
+
summary: note.title,
|
|
11697
|
+
body: issueBody(note, path)
|
|
11698
|
+
}));
|
|
11699
|
+
} catch (err) {
|
|
11700
|
+
rows.push(row(path, "fail", `could not create the issue: ${describeError(err)}`));
|
|
11701
|
+
continue;
|
|
11702
|
+
}
|
|
11703
|
+
try {
|
|
11704
|
+
const current = io.read(join(dir, path));
|
|
11705
|
+
if (current === void 0) throw new Error("the note can no longer be read");
|
|
11706
|
+
io.write(join(dir, path), writeIssueKey(current, key));
|
|
11707
|
+
rows.push(row(path, "ok", `${existing ? "already filed" : "filed"} as ${key}`));
|
|
11708
|
+
} catch (err) {
|
|
11709
|
+
rows.push({
|
|
11710
|
+
...row(path, "fail", `issue ${key} was created but \`issue:\` was not written: ${describeError(err)}`),
|
|
11711
|
+
problems: [`add \`issue: ${key}\` to the note by hand`]
|
|
11712
|
+
});
|
|
11713
|
+
}
|
|
11714
|
+
}
|
|
11715
|
+
return finish(rows.sort((a, b) => a.id.localeCompare(b.id)));
|
|
11716
|
+
}
|
|
11717
|
+
// src/commands/ideas-sync/ideas-sync.command.ts
|
|
11718
|
+
const ideasSyncCommand = {
|
|
11719
|
+
command: "sync",
|
|
11720
|
+
describe: "File the idea notes that are ready as issues, and record the issue in each note",
|
|
11721
|
+
builder: (y) => y.option("yes", {
|
|
11722
|
+
type: "boolean",
|
|
11723
|
+
describe: "File without asking (required without a terminal)"
|
|
11724
|
+
}),
|
|
11725
|
+
handler: async (argv) => {
|
|
11726
|
+
const tokens = tokenContext$1(argv.token);
|
|
11727
|
+
if (!tokens) return;
|
|
11728
|
+
const loaded = await loadConfig(argv.cwd);
|
|
11729
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
11730
|
+
if ((await runIdeasSync({
|
|
11731
|
+
loaded,
|
|
11732
|
+
context: {
|
|
11733
|
+
repoRoot: argv.cwd,
|
|
11734
|
+
dryRun: argv.dryRun,
|
|
11735
|
+
...tokens,
|
|
11736
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
11737
|
+
},
|
|
11738
|
+
...argv.yes ? { yes: true } : {}
|
|
11739
|
+
})).status === "fail") process.exitCode = 1;
|
|
11740
|
+
}
|
|
11741
|
+
};
|
|
11742
|
+
// src/commands/ideas/ideas.command.ts
|
|
11743
|
+
const ideasCommand = {
|
|
11744
|
+
command: "ideas",
|
|
11745
|
+
describe: "Work with the idea notes that sit in front of the issue tracker",
|
|
11746
|
+
builder: (y) => y.command(ideasSyncCommand).command(groupMenu$1("ideas")),
|
|
11747
|
+
handler: () => {}
|
|
11748
|
+
};
|
|
11410
11749
|
// src/commands/menu/menu.command.ts
|
|
11411
11750
|
/**
|
|
11412
11751
|
* Print the dim version line once per terminal session — keyed by the
|
|
@@ -12106,22 +12445,42 @@ async function runMonitoringCheck(input) {
|
|
|
12106
12445
|
...input.runCheck ? { runCheck: input.runCheck } : {}
|
|
12107
12446
|
});
|
|
12108
12447
|
}
|
|
12109
|
-
// src/commands/monitoring-run-resolved/
|
|
12448
|
+
// src/commands/monitoring-run-resolved/verify-vercel-project/verify-vercel-project.ts
|
|
12110
12449
|
/**
|
|
12111
|
-
* `
|
|
12112
|
-
*
|
|
12113
|
-
*
|
|
12114
|
-
*
|
|
12115
|
-
*
|
|
12116
|
-
*
|
|
12117
|
-
* Safe to run with a credential present, since nothing here executes
|
|
12118
|
-
* PR-authored code — but a credential is only ever attached after
|
|
12119
|
-
* `verifyVercelDeploymentProject` confirms `url` actually belongs to
|
|
12120
|
-
* `vercelProject`: a URL merely ending in `.vercel.app` proves nothing,
|
|
12121
|
-
* since anyone can register their own Vercel project (sourcery review
|
|
12122
|
-
* on holocron#1032). No `vercelProject` given at all → the credential
|
|
12123
|
-
* is never attached, regardless of whether one is configured.
|
|
12450
|
+
* `true` only when Vercel's API confirms `url` resolves to a deployment
|
|
12451
|
+
* whose `projectId` matches `expectedProjectId` exactly. `false` for any
|
|
12452
|
+
* other outcome — a non-matching project, a non-2xx response, a
|
|
12453
|
+
* malformed body, or a transport failure — never throws, since every one
|
|
12454
|
+
* of those outcomes means the same thing to a caller: don't attach the
|
|
12455
|
+
* credential.
|
|
12124
12456
|
*/
|
|
12457
|
+
async function verifyVercelDeploymentProject(url, expectedProjectId, token, opts = {}) {
|
|
12458
|
+
const doFetch = opts.fetch ?? fetch;
|
|
12459
|
+
const baseUrl = opts.baseUrl ?? "https://api.vercel.com";
|
|
12460
|
+
let host;
|
|
12461
|
+
try {
|
|
12462
|
+
host = new URL(url).host;
|
|
12463
|
+
} catch {
|
|
12464
|
+
return false;
|
|
12465
|
+
}
|
|
12466
|
+
const params = new URLSearchParams({ url: host });
|
|
12467
|
+
if (opts.teamId) params.set("teamId", opts.teamId);
|
|
12468
|
+
let response;
|
|
12469
|
+
try {
|
|
12470
|
+
response = await doFetch(`${baseUrl}/v13/deployments/get?${params}`, { headers: { Authorization: `Bearer ${token}` } });
|
|
12471
|
+
} catch {
|
|
12472
|
+
return false;
|
|
12473
|
+
}
|
|
12474
|
+
if (!response.ok) return false;
|
|
12475
|
+
let body;
|
|
12476
|
+
try {
|
|
12477
|
+
body = await response.json();
|
|
12478
|
+
} catch {
|
|
12479
|
+
return false;
|
|
12480
|
+
}
|
|
12481
|
+
return (typeof body === "object" && body !== null && "projectId" in body ? body.projectId : void 0) === expectedProjectId;
|
|
12482
|
+
}
|
|
12483
|
+
// src/commands/monitoring-run-resolved/monitoring-run-resolved.ts
|
|
12125
12484
|
/**
|
|
12126
12485
|
* The shared gate every caller that might attach the Deployment
|
|
12127
12486
|
* Protection bypass header goes through — `monitoring check`'s direct
|
|
@@ -15025,7 +15384,7 @@ function workspaceFilterArgs(cwd, scope = {}) {
|
|
|
15025
15384
|
*
|
|
15026
15385
|
* $ pnpm install --frozen-lockfile
|
|
15027
15386
|
* $ pnpm build
|
|
15028
|
-
* $ pnpm
|
|
15387
|
+
* $ pnpm --filter @theholocron/cli run start:source package publish --initial
|
|
15029
15388
|
*
|
|
15030
15389
|
* `npm login --auth-type=web` runs automatically the first time — no
|
|
15031
15390
|
* separate manual step. `pnpm install` + `pnpm build` stay outside the
|
|
@@ -15179,7 +15538,7 @@ async function runPublish(input = {}) {
|
|
|
15179
15538
|
if (publish.stdout.includes("EOTP") || publish.stderr.includes("EOTP")) {
|
|
15180
15539
|
print("");
|
|
15181
15540
|
print(" → hint: your npm account requires 2FA for writes. Re-run with `--otp <code>`:");
|
|
15182
|
-
print(` pnpm
|
|
15541
|
+
print(` pnpm --filter @theholocron/cli run start:source package publish --initial --otp <6-digit-code>`);
|
|
15183
15542
|
}
|
|
15184
15543
|
for (const entry of newEntries) print(statusRow("fail", [
|
|
15185
15544
|
pad(entry.name, nameWidth),
|
|
@@ -16916,7 +17275,7 @@ function docsCoverageProbes(repoRoot, typedoc = runTypedoc(repoRoot), diff = rea
|
|
|
16916
17275
|
* Workflow files that no task generates and that are not marked `# HAND-MAINTAINED`, so the check would take them for
|
|
16917
17276
|
* stale generated files. Each is intentional.
|
|
16918
17277
|
*/
|
|
16919
|
-
const UNMANAGED_WORKFLOWS = {
|
|
17278
|
+
const UNMANAGED_WORKFLOWS = {};
|
|
16920
17279
|
// src/commands/probe/generated/check-generated.ts
|
|
16921
17280
|
const WORKFLOWS_DIR = ".github/workflows/";
|
|
16922
17281
|
/** Where two texts first differ: the line number and both lines, cut to fit a terminal. */
|
|
@@ -24454,9 +24813,21 @@ const tunnelCommand = {
|
|
|
24454
24813
|
builder: (y) => y.command(tunnelUpCommand).command(groupMenu$1("tunnel")),
|
|
24455
24814
|
handler: () => {}
|
|
24456
24815
|
};
|
|
24457
|
-
// src/cli.ts
|
|
24816
|
+
// src/cli/own-package-json.ts
|
|
24817
|
+
/**
|
|
24818
|
+
* The `name` and `version` of the package that `moduleUrl` belongs to, from the nearest `package.json` above it.
|
|
24819
|
+
* That is the package root whether the CLI runs from source (`src/cli/cli.ts`, through tsx) or built (`dist/cli.mjs`),
|
|
24820
|
+
* which a fixed `../package.json` would not be: the entry sits one folder deeper in source than it does built.
|
|
24821
|
+
*/
|
|
24822
|
+
function ownPackageJson(moduleUrl) {
|
|
24823
|
+
const from = dirname(fileURLToPath(moduleUrl));
|
|
24824
|
+
const root = findRootSync(from, "package.json");
|
|
24825
|
+
if (!root) throw new Error(`no package.json found above ${from}`);
|
|
24826
|
+
return JSON.parse(readFileSync(join(root, "package.json"), "utf-8"));
|
|
24827
|
+
}
|
|
24828
|
+
// src/cli/cli.ts
|
|
24458
24829
|
const env = createEnvLookup();
|
|
24459
|
-
const { name: CLI_PACKAGE_NAME, version: CLI_VERSION } =
|
|
24830
|
+
const { name: CLI_PACKAGE_NAME, version: CLI_VERSION } = ownPackageJson(import.meta.url);
|
|
24460
24831
|
/**
|
|
24461
24832
|
* Error class names whose `.message` is a complete, actionable sentence: printed on its own, with no usage dump and no
|
|
24462
24833
|
* stack trace. Any other error is printed too, so a command that throws a plain `Error` is never silent.
|
|
@@ -24518,7 +24889,7 @@ try {
|
|
|
24518
24889
|
org: argv.org
|
|
24519
24890
|
});
|
|
24520
24891
|
finishCommand = startCommand(name);
|
|
24521
|
-
}).command(cloneCommand).command(doctorCommand).command(skillsCommand).command(runCommand).command(configShowCommand).command(authCommand).command(menuCommand(CLI_VERSION)).command(repoCommand).command(newCommand).command(probeCommand).command(providerCommand).command(secretsCommand).command(notificationsCommand).command(githubAppCommand).command(specsCommand).command(tunnelCommand).command(projectCommand).command(migrateCommand).command(devCommand).command(syncCommand).command(packageCommand).command(deployCommand).command(monitoringCommand).command(projectCommand).strict().help().epilogue(`Execution contexts:
|
|
24892
|
+
}).command(cloneCommand).command(doctorCommand).command(skillsCommand).command(runCommand).command(configShowCommand).command(authCommand).command(menuCommand(CLI_VERSION)).command(repoCommand).command(newCommand).command(probeCommand).command(providerCommand).command(secretsCommand).command(notificationsCommand).command(githubAppCommand).command(specsCommand).command(tunnelCommand).command(projectCommand).command(migrateCommand).command(devCommand).command(syncCommand).command(ideasCommand).command(packageCommand).command(deployCommand).command(monitoringCommand).command(projectCommand).strict().help().epilogue(`Execution contexts:
|
|
24522
24893
|
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) => {
|
|
24523
24894
|
if (err instanceof Error && USER_FACING_ERRORS.has(err.name)) {
|
|
24524
24895
|
captureException(err);
|