@theholocron/cli 5.0.0-alpha.394 → 5.0.0-alpha.396
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 +12 -2
- package/dist/cli.mjs +375 -78
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-u0AcPQ77.d.mts → config-system-CYv5GFIa.d.mts} +31 -2
- package/dist/{config-system-BVYtgrmR.mjs → config-system-CeVFoOau.mjs} +13 -0
- package/dist/{index-nzzQsd0r.d.mts → index-DbbyDvZi.d.mts} +52 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/plugin/capabilities.d.mts +2 -2
- package/dist/plugin/capabilities.mjs +2 -0
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/package.json +11 -10
package/dist/cli.mjs
CHANGED
|
@@ -83,6 +83,8 @@ const CARDINALITY = {
|
|
|
83
83
|
tunnels: "single",
|
|
84
84
|
/** `projects` has exactly one provider. */
|
|
85
85
|
projects: "single",
|
|
86
|
+
/** `ideas` has exactly one provider. Optional: no repo has to declare it. */
|
|
87
|
+
ideas: "single",
|
|
86
88
|
/** `credentials` can have several providers, tried in order. */
|
|
87
89
|
credentials: "many"
|
|
88
90
|
};
|
|
@@ -221,6 +223,17 @@ function validateGitHubApps(apps) {
|
|
|
221
223
|
}
|
|
222
224
|
});
|
|
223
225
|
}
|
|
226
|
+
/** Throws a {@link ConfigError} naming the first thing wrong with the `ideas` block. */
|
|
227
|
+
function validateIdeas(ideas) {
|
|
228
|
+
const nonEmpty = (value) => typeof value === "string" && value.trim() !== "";
|
|
229
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
230
|
+
if (!isObject(ideas)) throw new ConfigError$1("`ideas` must be an object: { states?, dir? (deprecated) }");
|
|
231
|
+
if (ideas.dir !== void 0 && !nonEmpty(ideas.dir)) throw new ConfigError$1("`ideas.dir` must be the path of the notes folder, got an empty value");
|
|
232
|
+
if (ideas.states !== void 0) {
|
|
233
|
+
if (!isObject(ideas.states)) throw new ConfigError$1("`ideas.states` must be an object: { file? }");
|
|
234
|
+
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");
|
|
235
|
+
}
|
|
236
|
+
}
|
|
224
237
|
/** Throws a {@link ConfigError} naming the first thing wrong with the `dev` block. */
|
|
225
238
|
function validateDev(dev) {
|
|
226
239
|
const nonEmpty = (value) => typeof value === "string" && value.trim() !== "";
|
|
@@ -277,6 +290,7 @@ function resolveConfig(raw) {
|
|
|
277
290
|
}
|
|
278
291
|
if (raw.dev !== void 0) validateDev(raw.dev);
|
|
279
292
|
if (raw.githubApps !== void 0) validateGitHubApps(raw.githubApps);
|
|
293
|
+
if (raw.ideas !== void 0) validateIdeas(raw.ideas);
|
|
280
294
|
validateVariablesSync(raw.repo?.variables);
|
|
281
295
|
const credentialsEntry = providers.credentials;
|
|
282
296
|
if (credentialsEntry?.cardinality === "many") for (const tuple of credentialsEntry.tuples) {
|
|
@@ -308,6 +322,7 @@ function resolveConfig(raw) {
|
|
|
308
322
|
credentials: raw.credentials,
|
|
309
323
|
dev: raw.dev,
|
|
310
324
|
githubApps: raw.githubApps,
|
|
325
|
+
ideas: raw.ideas,
|
|
311
326
|
log: raw.log,
|
|
312
327
|
telemetry: raw.telemetry,
|
|
313
328
|
eslint: raw.eslint
|
|
@@ -783,7 +798,8 @@ const COMMAND_CONTEXTS = {
|
|
|
783
798
|
"repo sync": "workspace",
|
|
784
799
|
"repo cleanup branches": "workspace",
|
|
785
800
|
"sync github": "workspace",
|
|
786
|
-
"sync issues": "workspace"
|
|
801
|
+
"sync issues": "workspace",
|
|
802
|
+
"ideas sync": "workspace"
|
|
787
803
|
};
|
|
788
804
|
/**
|
|
789
805
|
* The context for a command name from `argv._`. Falls back to the leading
|
|
@@ -1482,12 +1498,12 @@ async function runDoctorTokens(input) {
|
|
|
1482
1498
|
try {
|
|
1483
1499
|
module = await importer(pkg);
|
|
1484
1500
|
} catch (err) {
|
|
1485
|
-
rows.push(row$
|
|
1501
|
+
rows.push(row$10(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
|
|
1486
1502
|
continue;
|
|
1487
1503
|
}
|
|
1488
1504
|
for (const token of module.tokens ?? []) rows.push(await checkToken$1(token, module, env, readToken, now()));
|
|
1489
1505
|
}
|
|
1490
|
-
if (rows.length === 0) rows.push(row$
|
|
1506
|
+
if (rows.length === 0) rows.push(row$10("tokens", "skip", "no configured plugin lists the tokens it takes"));
|
|
1491
1507
|
printCheckRows(rows, print);
|
|
1492
1508
|
const summary = summariseChecks(rows);
|
|
1493
1509
|
printCheckSummary(summary, print);
|
|
@@ -1519,11 +1535,11 @@ async function loadCredentials(input) {
|
|
|
1519
1535
|
try {
|
|
1520
1536
|
await loader.load();
|
|
1521
1537
|
} catch (err) {
|
|
1522
|
-
return [row$
|
|
1538
|
+
return [row$10("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
|
|
1523
1539
|
}
|
|
1524
|
-
return loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$
|
|
1540
|
+
return loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$10(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
|
|
1525
1541
|
}
|
|
1526
|
-
function row$
|
|
1542
|
+
function row$10(id, status, detail) {
|
|
1527
1543
|
return {
|
|
1528
1544
|
id,
|
|
1529
1545
|
title: id,
|
|
@@ -1537,21 +1553,21 @@ async function checkToken$1(token, module, env, readToken, now) {
|
|
|
1537
1553
|
const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
|
|
1538
1554
|
const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
|
|
1539
1555
|
const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
|
|
1540
|
-
if (!value) return row$
|
|
1556
|
+
if (!value) return row$10(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron auth set ${keyringKey}\`)`);
|
|
1541
1557
|
const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
|
|
1542
|
-
if (!verify) return row$
|
|
1558
|
+
if (!verify) return row$10(keyringKey, "skip", "set, but its plugin cannot verify it");
|
|
1543
1559
|
const from = fromEnv ?? stored?.source ?? "keyring";
|
|
1544
1560
|
try {
|
|
1545
1561
|
const verified = await verify(value);
|
|
1546
|
-
if (!verified.ok) return row$
|
|
1562
|
+
if (!verified.ok) return row$10(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
|
|
1547
1563
|
const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
|
|
1548
|
-
if (!expiry) return row$
|
|
1564
|
+
if (!expiry) return row$10(keyringKey, "ok", `${verified.subject} (${from})`);
|
|
1549
1565
|
return expiry.soon ? {
|
|
1550
|
-
...row$
|
|
1566
|
+
...row$10(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
|
|
1551
1567
|
problems: [`${expiry.text}: renew it`]
|
|
1552
|
-
} : row$
|
|
1568
|
+
} : row$10(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
|
|
1553
1569
|
} catch (err) {
|
|
1554
|
-
return row$
|
|
1570
|
+
return row$10(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
|
|
1555
1571
|
}
|
|
1556
1572
|
}
|
|
1557
1573
|
// src/commands/doctor-tokens/doctor-tokens.command.ts
|
|
@@ -2133,6 +2149,14 @@ const githubAppCreateEntry = {
|
|
|
2133
2149
|
],
|
|
2134
2150
|
supportsDryRun: false
|
|
2135
2151
|
};
|
|
2152
|
+
// src/commands/ideas-sync/ideas-sync.entry.ts
|
|
2153
|
+
const ideasSyncEntry = {
|
|
2154
|
+
name: "ideas sync",
|
|
2155
|
+
description: "File the idea notes that are ready as issues and record the issue in each note",
|
|
2156
|
+
positionals: [],
|
|
2157
|
+
skipOptions: ["yes"],
|
|
2158
|
+
supportsDryRun: true
|
|
2159
|
+
};
|
|
2136
2160
|
// src/commands/migrate/migrate-issue/migrate-issue.entry.ts
|
|
2137
2161
|
const migrateIssueEntry = {
|
|
2138
2162
|
name: "migrate issue",
|
|
@@ -2803,6 +2827,7 @@ const registry = createCommandRegistry([
|
|
|
2803
2827
|
skipOptions: ["yes"],
|
|
2804
2828
|
supportsDryRun: true
|
|
2805
2829
|
},
|
|
2830
|
+
ideasSyncEntry,
|
|
2806
2831
|
{
|
|
2807
2832
|
name: "repo sync readme",
|
|
2808
2833
|
description: "Sync the Installation + Usage block in README.md from package.json",
|
|
@@ -3587,6 +3612,45 @@ const deployStageArgs = (y) => y.option("package-dir", {
|
|
|
3587
3612
|
type: "string",
|
|
3588
3613
|
describe: "Where to write the payload. Default: `.vercel-deploy` inside the package."
|
|
3589
3614
|
});
|
|
3615
|
+
// src/commands/deploy-stage/alpha-release/alpha-release.ts
|
|
3616
|
+
/**
|
|
3617
|
+
* The release npm's `alpha` dist-tag points at for `name`, with the peer ranges it declares
|
|
3618
|
+
* (`npm view <name>@alpha version peerDependencies --json`).
|
|
3619
|
+
*
|
|
3620
|
+
* @returns `undefined` when the package or its `alpha` tag does not exist (npm's E404).
|
|
3621
|
+
* @throws when npm cannot be run or the registry cannot be reached: staging then would pin whatever is
|
|
3622
|
+
* installed, which is the stale version this lookup exists to replace.
|
|
3623
|
+
*/
|
|
3624
|
+
function alphaRelease(name) {
|
|
3625
|
+
const result = spawnSync("npm", [
|
|
3626
|
+
"view",
|
|
3627
|
+
`${name}@alpha`,
|
|
3628
|
+
"version",
|
|
3629
|
+
"peerDependencies",
|
|
3630
|
+
"--json"
|
|
3631
|
+
], {
|
|
3632
|
+
encoding: "utf8",
|
|
3633
|
+
stdio: [
|
|
3634
|
+
"ignore",
|
|
3635
|
+
"pipe",
|
|
3636
|
+
"pipe"
|
|
3637
|
+
]
|
|
3638
|
+
});
|
|
3639
|
+
if (result.error) throw new Error(`cannot run npm to look up ${name}@alpha: ${result.error.message}`);
|
|
3640
|
+
if (result.status !== 0) {
|
|
3641
|
+
if (/E404|code E404/.test(`${result.stdout}${result.stderr}`)) return void 0;
|
|
3642
|
+
const reason = (result.stderr || result.stdout).split("\n").find((line) => line.trim()) ?? `exit ${result.status}`;
|
|
3643
|
+
throw new Error(`cannot look up ${name}@alpha on npm (is the registry reachable?): ${reason.trim()}`);
|
|
3644
|
+
}
|
|
3645
|
+
const parsed = JSON.parse(result.stdout);
|
|
3646
|
+
const view = typeof parsed === "string" ? { version: parsed } : parsed;
|
|
3647
|
+
if (typeof view.version !== "string") return void 0;
|
|
3648
|
+
const peers = view.peerDependencies;
|
|
3649
|
+
return {
|
|
3650
|
+
version: view.version,
|
|
3651
|
+
...peers && typeof peers === "object" ? { peerDependencies: peers } : {}
|
|
3652
|
+
};
|
|
3653
|
+
}
|
|
3590
3654
|
// src/commands/deploy-stage/installed-peers.ts
|
|
3591
3655
|
/**
|
|
3592
3656
|
* The `package.json` of `peer` as the package at `manifestPath` would resolve it: the closest `node_modules`
|
|
@@ -3626,6 +3690,40 @@ function installedPeers(packageDir, dependency) {
|
|
|
3626
3690
|
collectPeers(realpathSync(manifestPath), peers);
|
|
3627
3691
|
return peers;
|
|
3628
3692
|
}
|
|
3693
|
+
// src/commands/deploy-stage/pin-alpha-releases/pin-alpha-releases.ts
|
|
3694
|
+
const OWN_SCOPE = "@theholocron/";
|
|
3695
|
+
const ALPHA_VERSION = /-alpha\./;
|
|
3696
|
+
const EXACT_VERSION = /^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/;
|
|
3697
|
+
/**
|
|
3698
|
+
* Moves every `@theholocron/*` dependency installed at an `alpha` prerelease to the version npm's `alpha` tag points
|
|
3699
|
+
* at. A workspace package's `package.json` keeps the version it had when it was last committed, and a release only
|
|
3700
|
+
* writes the new one into the published copy, so the installed version of a plugin can be hundreds of releases behind
|
|
3701
|
+
* what npm serves, with a peer on a CLI it was never published with. A version that is not an `alpha` prerelease, a
|
|
3702
|
+
* package outside the scope and a package npm has no `alpha` tag for stay as they are.
|
|
3703
|
+
*
|
|
3704
|
+
* `mismatches` lists each exact peer a pinned release declares (`@theholocron/cli` is one) that differs from the
|
|
3705
|
+
* version staged for it, so a release cut between two lookups shows up instead of failing at runtime.
|
|
3706
|
+
*/
|
|
3707
|
+
function pinAlphaReleases(dependencies, lookup) {
|
|
3708
|
+
const pinned = {};
|
|
3709
|
+
const changes = [];
|
|
3710
|
+
const peerRanges = [];
|
|
3711
|
+
for (const [name, version] of Object.entries(dependencies)) {
|
|
3712
|
+
const release = name.startsWith(OWN_SCOPE) && ALPHA_VERSION.test(version) ? lookup(name) : void 0;
|
|
3713
|
+
pinned[name] = release?.version ?? version;
|
|
3714
|
+
if (release && release.version !== version) changes.push(`${name} ${version} → ${release.version}`);
|
|
3715
|
+
if (release?.peerDependencies) peerRanges.push([
|
|
3716
|
+
name,
|
|
3717
|
+
release.version,
|
|
3718
|
+
release.peerDependencies
|
|
3719
|
+
]);
|
|
3720
|
+
}
|
|
3721
|
+
return {
|
|
3722
|
+
dependencies: pinned,
|
|
3723
|
+
changes,
|
|
3724
|
+
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`))
|
|
3725
|
+
};
|
|
3726
|
+
}
|
|
3629
3727
|
// src/commands/deploy-stage/undeclared-externals.ts
|
|
3630
3728
|
/** `"@scope/pkg/sub"` → `"@scope/pkg"`, `"pkg/sub"` → `"pkg"`. */
|
|
3631
3729
|
function packageName(specifier) {
|
|
@@ -3720,8 +3818,10 @@ function vercelEngines(engines) {
|
|
|
3720
3818
|
* here. They stay in `dependencies` because a repo's own `holocron.config.ts`
|
|
3721
3819
|
* imports `@theholocron/cli` / `astromech/config` at runtime (only
|
|
3722
3820
|
* `defineConfig`, an identity function, so a version skew there is harmless).
|
|
3723
|
-
* Pinned versions still have to exist on npm
|
|
3724
|
-
*
|
|
3821
|
+
* Pinned versions still have to exist on npm. A workspace package's `package.json` is not updated when it is
|
|
3822
|
+
* 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
|
|
3823
|
+
* version), so an `@theholocron/*` dependency installed at an `alpha` prerelease is pinned to npm's `alpha` tag
|
|
3824
|
+
* instead (`pinAlphaReleases()`); the lookup fails when npm cannot be reached, rather than staging the stale version.
|
|
3725
3825
|
*/
|
|
3726
3826
|
function installedVersion(packageDir, name) {
|
|
3727
3827
|
const pkgPath = join(packageDir, "node_modules", name, "package.json");
|
|
@@ -3754,10 +3854,12 @@ function stageDeploy(input) {
|
|
|
3754
3854
|
].join("\n"));
|
|
3755
3855
|
const direct = Object.fromEntries(Object.keys(pkg.dependencies ?? {}).map((name) => [name, resolveVersion(packageDir, name)]));
|
|
3756
3856
|
const peers = Object.fromEntries(Object.keys(direct).flatMap((name) => Object.entries(resolvePeers(packageDir, name))).filter(([name]) => !(name in direct)));
|
|
3757
|
-
const dependencies = Object.fromEntries(Object.entries({
|
|
3857
|
+
const { dependencies, changes, mismatches } = pinAlphaReleases(Object.fromEntries(Object.entries({
|
|
3758
3858
|
...direct,
|
|
3759
3859
|
...peers
|
|
3760
|
-
}).sort(([a], [b]) => a.localeCompare(b)));
|
|
3860
|
+
}).sort(([a], [b]) => a.localeCompare(b))), input.alphaRelease ?? alphaRelease);
|
|
3861
|
+
for (const change of changes) print(` pinned to npm's alpha tag: ${change}`);
|
|
3862
|
+
for (const mismatch of mismatches) print(` warning: ${mismatch}`);
|
|
3761
3863
|
rmSync(outDir, {
|
|
3762
3864
|
recursive: true,
|
|
3763
3865
|
force: true
|
|
@@ -4906,7 +5008,7 @@ async function runDoctorCredentials(input) {
|
|
|
4906
5008
|
};
|
|
4907
5009
|
}
|
|
4908
5010
|
/** A row for the provider as a whole, or for one of its variables when `name` is given. */
|
|
4909
|
-
function row$
|
|
5011
|
+
function row$9(provider, status, detail, name) {
|
|
4910
5012
|
return name === void 0 ? {
|
|
4911
5013
|
id: provider,
|
|
4912
5014
|
title: provider,
|
|
@@ -4923,32 +5025,32 @@ function row$8(provider, status, detail, name) {
|
|
|
4923
5025
|
}
|
|
4924
5026
|
async function checkCredentials(input, loader) {
|
|
4925
5027
|
const { resolved } = input.loaded;
|
|
4926
|
-
if (!resolved.providers.credentials) return [row$
|
|
4927
|
-
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$
|
|
5028
|
+
if (!resolved.providers.credentials) return [row$9("credentials", "skip", "no `credentials` provider is configured")];
|
|
5029
|
+
const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$9(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
|
|
4928
5030
|
if (!loader.has("credentials")) return rows;
|
|
4929
5031
|
const expected = await expectedTokens(input);
|
|
4930
5032
|
const { tuples } = resolved.providers.credentials;
|
|
4931
5033
|
for (const impl of loader.get("credentials")) {
|
|
4932
5034
|
const tuple = tuples.find((t) => t.provider === impl.providerName);
|
|
4933
5035
|
const environment = tuple && credentialsEnvironment(tuple, resolved);
|
|
4934
|
-
rows.push(...environment ? await checkProvider(impl, environment, expected) : [row$
|
|
5036
|
+
rows.push(...environment ? await checkProvider(impl, environment, expected) : [row$9(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set")]);
|
|
4935
5037
|
}
|
|
4936
5038
|
return rows;
|
|
4937
5039
|
}
|
|
4938
5040
|
async function checkProvider(impl, environment, expected) {
|
|
4939
5041
|
const provider = impl.providerName;
|
|
4940
|
-
if (!impl.inspect) return [row$
|
|
4941
|
-
if (expected.length === 0) return [row$
|
|
5042
|
+
if (!impl.inspect) return [row$9(provider, "skip", "cannot list the variables without reading their values")];
|
|
5043
|
+
if (expected.length === 0) return [row$9(provider, "skip", "no configured plugin lists the tokens it takes")];
|
|
4942
5044
|
try {
|
|
4943
5045
|
const found = await impl.inspect(environment);
|
|
4944
5046
|
const held = new Set(found.names);
|
|
4945
5047
|
const where = found.environment === environment ? `"${found.environment}"` : `"${found.environment}" (the config writes "${environment}")`;
|
|
4946
5048
|
return expected.map(({ name, optional }) => {
|
|
4947
|
-
if (held.has(name)) return row$
|
|
4948
|
-
return optional ? row$
|
|
5049
|
+
if (held.has(name)) return row$9(provider, "ok", `present in ${where}`, name);
|
|
5050
|
+
return optional ? row$9(provider, "skip", `optional, not set in ${where}`, name) : row$9(provider, "fail", `missing from ${where}`, name);
|
|
4949
5051
|
});
|
|
4950
5052
|
} catch (err) {
|
|
4951
|
-
return [row$
|
|
5053
|
+
return [row$9(provider, "fail", errorMessage(err))];
|
|
4952
5054
|
}
|
|
4953
5055
|
}
|
|
4954
5056
|
/**
|
|
@@ -5779,7 +5881,7 @@ async function runDoctorDns(input) {
|
|
|
5779
5881
|
});
|
|
5780
5882
|
else if (!loader.has("dns")) {
|
|
5781
5883
|
const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
|
|
5782
|
-
for (const zone of zones) rows.push(row$
|
|
5884
|
+
for (const zone of zones) rows.push(row$8(zone, "skip", why));
|
|
5783
5885
|
for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
|
|
5784
5886
|
} else {
|
|
5785
5887
|
const dns = loader.get("dns");
|
|
@@ -5801,7 +5903,7 @@ async function runDoctorDns(input) {
|
|
|
5801
5903
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
5802
5904
|
};
|
|
5803
5905
|
}
|
|
5804
|
-
function row$
|
|
5906
|
+
function row$8(zone, status, detail, problems = []) {
|
|
5805
5907
|
return {
|
|
5806
5908
|
id: `dns-${zone}`,
|
|
5807
5909
|
title: `${zone} records exist`,
|
|
@@ -5830,7 +5932,7 @@ async function checkDomain(dns, deploy, project, hostname) {
|
|
|
5830
5932
|
return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
|
|
5831
5933
|
}
|
|
5832
5934
|
}
|
|
5833
|
-
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$
|
|
5935
|
+
async function checkZone(dns, zone, wanted, rowOf = (...args) => row$8(zone, ...args)) {
|
|
5834
5936
|
try {
|
|
5835
5937
|
const have = await dns.listRecords(zone);
|
|
5836
5938
|
const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
|
|
@@ -5965,7 +6067,7 @@ function installationSettingsUrl(account, id) {
|
|
|
5965
6067
|
return `https://github.com/settings/installations/${id}`;
|
|
5966
6068
|
}
|
|
5967
6069
|
// src/commands/doctor-github-app/app-rows.ts
|
|
5968
|
-
const row$
|
|
6070
|
+
const row$7 = (name, what, problems, ok) => ({
|
|
5969
6071
|
id: `${name}:${what}`,
|
|
5970
6072
|
title: `${name}: ${what}`,
|
|
5971
6073
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -5992,9 +6094,9 @@ function appRows(name, manifest, app, installations) {
|
|
|
5992
6094
|
return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
|
|
5993
6095
|
});
|
|
5994
6096
|
return [
|
|
5995
|
-
row$
|
|
5996
|
-
row$
|
|
5997
|
-
row$
|
|
6097
|
+
row$7(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
|
|
6098
|
+
row$7(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
|
|
6099
|
+
row$7(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
|
|
5998
6100
|
];
|
|
5999
6101
|
}
|
|
6000
6102
|
// src/commands/doctor-github-app/parse-manifest.ts
|
|
@@ -6052,7 +6154,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
6052
6154
|
assertPluginsResolvable$1(loader, "doctor github-app");
|
|
6053
6155
|
}
|
|
6054
6156
|
const rows = [];
|
|
6055
|
-
if (instances.length === 0) rows.push(row$
|
|
6157
|
+
if (instances.length === 0) rows.push(row$6("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
|
|
6056
6158
|
for (const instance of instances) rows.push(...await checkInstance(instance, loader, input));
|
|
6057
6159
|
printCheckRows(rows, print);
|
|
6058
6160
|
const summary = summariseChecks(rows);
|
|
@@ -6069,7 +6171,7 @@ async function runDoctorGitHubApp(input) {
|
|
|
6069
6171
|
...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
|
|
6070
6172
|
};
|
|
6071
6173
|
}
|
|
6072
|
-
function row$
|
|
6174
|
+
function row$6(name, what, status, detail) {
|
|
6073
6175
|
return {
|
|
6074
6176
|
id: `${name}:${what}`,
|
|
6075
6177
|
title: `${name}: ${what}`,
|
|
@@ -6112,19 +6214,19 @@ async function checkInstance(instance, loader, input) {
|
|
|
6112
6214
|
try {
|
|
6113
6215
|
manifest = parseManifest(readManifest(instance.manifest));
|
|
6114
6216
|
} catch (err) {
|
|
6115
|
-
return [row$
|
|
6217
|
+
return [row$6(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
|
|
6116
6218
|
}
|
|
6117
6219
|
const read = await readCredentials(instance, loader);
|
|
6118
|
-
if ("reason" in read) return [row$
|
|
6220
|
+
if ("reason" in read) return [row$6(name, "reachable", "skip", read.reason)];
|
|
6119
6221
|
const api = input.api ?? defaultApi;
|
|
6120
6222
|
const secrets = [read.creds.privateKey];
|
|
6121
6223
|
try {
|
|
6122
6224
|
const app = await api.getApp(read.creds);
|
|
6123
6225
|
const installations = await api.listAppInstallations(read.creds);
|
|
6124
6226
|
const owner = app.owner ? `, owned by ${app.owner.login}` : "";
|
|
6125
|
-
return [row$
|
|
6227
|
+
return [row$6(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
|
|
6126
6228
|
} catch (err) {
|
|
6127
|
-
return [row$
|
|
6229
|
+
return [row$6(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed(err, secrets)}`)];
|
|
6128
6230
|
}
|
|
6129
6231
|
}
|
|
6130
6232
|
// src/commands/doctor-github-app/doctor-github-app.command.ts
|
|
@@ -6191,7 +6293,7 @@ function datasetTargets(config) {
|
|
|
6191
6293
|
* dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
|
|
6192
6294
|
* a name, a token or a response that cannot be read is a skip with the reason.
|
|
6193
6295
|
*/
|
|
6194
|
-
const row$
|
|
6296
|
+
const row$5 = (id, title, status, detail, problems = []) => ({
|
|
6195
6297
|
id,
|
|
6196
6298
|
title,
|
|
6197
6299
|
status,
|
|
@@ -6208,7 +6310,7 @@ async function runDoctorLogs(input) {
|
|
|
6208
6310
|
if (!loader.has("logs")) {
|
|
6209
6311
|
const failure = loader.loadFailures().find((f) => f.key === "logs");
|
|
6210
6312
|
const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
|
|
6211
|
-
rows.push(row$
|
|
6313
|
+
rows.push(row$5("logs", "logs", "skip", why));
|
|
6212
6314
|
} else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
|
|
6213
6315
|
printCheckRows(rows, print);
|
|
6214
6316
|
const summary = summariseChecks(rows);
|
|
@@ -6232,38 +6334,38 @@ async function checkLogs(logs, targets) {
|
|
|
6232
6334
|
for (const target of targets) {
|
|
6233
6335
|
const id = `logs:dataset:${target.id}`;
|
|
6234
6336
|
const title = `dataset for ${target.label}`;
|
|
6235
|
-
if (!target.name) rows.push(row$
|
|
6236
|
-
else if (!token.usable) rows.push(row$
|
|
6237
|
-
else if (!logs.readDataset) rows.push(row$
|
|
6337
|
+
if (!target.name) rows.push(row$5(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
|
|
6338
|
+
else if (!token.usable) rows.push(row$5(id, title, "skip", `${target.name}: not checked, the token is not usable`));
|
|
6339
|
+
else if (!logs.readDataset) rows.push(row$5(id, title, "skip", `${logs.providerName} cannot read a dataset`));
|
|
6238
6340
|
else rows.push(...await checkDataset(logs, target, target.name, id, title));
|
|
6239
6341
|
}
|
|
6240
6342
|
const org = resolveValue$2(["AXIOM_ORG"], void 0, { prefix: PREFIX });
|
|
6241
|
-
rows.push(org ? row$
|
|
6343
|
+
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`));
|
|
6242
6344
|
return rows;
|
|
6243
6345
|
}
|
|
6244
6346
|
/** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
|
|
6245
6347
|
async function checkToken(logs) {
|
|
6246
6348
|
const title = "token is accepted";
|
|
6247
6349
|
if (!logs.checkToken) return {
|
|
6248
|
-
row: row$
|
|
6350
|
+
row: row$5("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
|
|
6249
6351
|
usable: true
|
|
6250
6352
|
};
|
|
6251
6353
|
try {
|
|
6252
6354
|
const result = await logs.checkToken();
|
|
6253
6355
|
if (result.ok) return {
|
|
6254
|
-
row: row$
|
|
6356
|
+
row: row$5("logs:token", title, "ok", `${logs.providerName} accepts the token`),
|
|
6255
6357
|
usable: true
|
|
6256
6358
|
};
|
|
6257
6359
|
const reason = result.reason ?? `${logs.providerName} refused the token`;
|
|
6258
6360
|
return {
|
|
6259
|
-
row: row$
|
|
6361
|
+
row: row$5("logs:token", title, "fail", reason, [reason]),
|
|
6260
6362
|
usable: false
|
|
6261
6363
|
};
|
|
6262
6364
|
} catch (err) {
|
|
6263
6365
|
const noToken = missingTokenReason(err);
|
|
6264
6366
|
const detail = noToken ?? `could not check the token: ${describeError(err)}`;
|
|
6265
6367
|
return {
|
|
6266
|
-
row: row$
|
|
6368
|
+
row: row$5("logs:token", title, "skip", detail),
|
|
6267
6369
|
usable: noToken === void 0
|
|
6268
6370
|
};
|
|
6269
6371
|
}
|
|
@@ -6273,13 +6375,13 @@ async function checkDataset(logs, target, name, id, title) {
|
|
|
6273
6375
|
const found = await logs.readDataset(name);
|
|
6274
6376
|
if (!found.exists) {
|
|
6275
6377
|
const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
|
|
6276
|
-
return [row$
|
|
6378
|
+
return [row$5(id, title, "fail", `${name} does not exist`, [problem])];
|
|
6277
6379
|
}
|
|
6278
6380
|
const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
|
|
6279
|
-
return [row$
|
|
6381
|
+
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)`)];
|
|
6280
6382
|
} catch (err) {
|
|
6281
6383
|
const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
|
|
6282
|
-
return [row$
|
|
6384
|
+
return [row$5(id, title, "skip", detail)];
|
|
6283
6385
|
}
|
|
6284
6386
|
}
|
|
6285
6387
|
// src/commands/doctor-logs/doctor-logs.command.ts
|
|
@@ -9268,7 +9370,7 @@ const info = (id, title, noun, extras) => ({
|
|
|
9268
9370
|
detail: `info: ${extras.length} ${noun} not in the template (never deleted)`,
|
|
9269
9371
|
problems: extras
|
|
9270
9372
|
});
|
|
9271
|
-
const row$
|
|
9373
|
+
const row$4 = (id, title, problems, ok) => ({
|
|
9272
9374
|
id,
|
|
9273
9375
|
title,
|
|
9274
9376
|
status: problems.length > 0 ? "fail" : "ok",
|
|
@@ -9304,19 +9406,19 @@ function viewProblems(want, found) {
|
|
|
9304
9406
|
function boardRows(boardName, template, state) {
|
|
9305
9407
|
const id = `project:${boardName}`;
|
|
9306
9408
|
const rows = [];
|
|
9307
|
-
rows.push(row$
|
|
9409
|
+
rows.push(row$4(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
|
|
9308
9410
|
const extraStatuses = state.statuses.filter((s) => !template.statuses.some((t) => t.name === s));
|
|
9309
9411
|
if (extraStatuses.length > 0) rows.push(info(`${id}:extra-statuses`, `${boardName}: extra statuses`, "status(es)", extraStatuses));
|
|
9310
|
-
for (const want of template.fields) rows.push(row$
|
|
9412
|
+
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));
|
|
9311
9413
|
const extraFields = state.fields.filter((f) => !template.fields.some((t) => t.name === f.name));
|
|
9312
9414
|
if (extraFields.length > 0) rows.push(info(`${id}:extra-fields`, `${boardName}: extra fields`, "field(s)", extraFields.map((f) => f.name)));
|
|
9313
|
-
for (const want of template.views) rows.push(row$
|
|
9415
|
+
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}` : ""}`));
|
|
9314
9416
|
const extraViews = state.views.filter((v) => !template.views.some((t) => t.name === v.name));
|
|
9315
9417
|
if (extraViews.length > 0) rows.push(info(`${id}:extra-views`, `${boardName}: extra views`, "view(s)", extraViews.map((v) => v.name)));
|
|
9316
9418
|
for (const name of template.rules ?? []) {
|
|
9317
9419
|
const found = state.rules.find((r) => r.name === name);
|
|
9318
9420
|
const problems = !found ? [`missing rule ${name}`] : found.enabled ? [] : [`rule ${name} is off`];
|
|
9319
|
-
rows.push(row$
|
|
9421
|
+
rows.push(row$4(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
|
|
9320
9422
|
}
|
|
9321
9423
|
return rows;
|
|
9322
9424
|
}
|
|
@@ -9376,7 +9478,7 @@ function itemRows(boardName, items) {
|
|
|
9376
9478
|
* never fail the run. A template file that does not read is a failure naming the file. `--post [channel]` shares the
|
|
9377
9479
|
* failing rows through the `notifications` provider's bot, like `doctor notifications --post`.
|
|
9378
9480
|
*/
|
|
9379
|
-
const row$
|
|
9481
|
+
const row$3 = (id, title, status, detail, problems = []) => ({
|
|
9380
9482
|
id,
|
|
9381
9483
|
title,
|
|
9382
9484
|
status,
|
|
@@ -9430,14 +9532,14 @@ async function checkBoards(input, loader) {
|
|
|
9430
9532
|
loader,
|
|
9431
9533
|
...input.io ? { io: input.io } : {}
|
|
9432
9534
|
});
|
|
9433
|
-
if (!opened.ok) return [row$
|
|
9535
|
+
if (!opened.ok) return [row$3("project", "project", opened.kind, opened.reason, opened.problems)];
|
|
9434
9536
|
const { projects, owner, boards, templates, templateProblems } = opened.context;
|
|
9435
9537
|
const rows = templateProblems.map((problem) => {
|
|
9436
9538
|
/* v8 ignore next -- split always returns at least one element; the fallback only satisfies noUncheckedIndexedAccess */
|
|
9437
9539
|
const file = problem.split(": ")[0] ?? problem;
|
|
9438
|
-
return row$
|
|
9540
|
+
return row$3(`project:template:${file}`, `template file ${file}`, "fail", problem);
|
|
9439
9541
|
});
|
|
9440
|
-
if (boards.length === 0) return [...rows, row$
|
|
9542
|
+
if (boards.length === 0) return [...rows, row$3("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
|
|
9441
9543
|
for (const declared of boards) {
|
|
9442
9544
|
const template = templates[declared.template];
|
|
9443
9545
|
const title = `${declared.name}: board exists and is open`;
|
|
@@ -9445,18 +9547,18 @@ async function checkBoards(input, loader) {
|
|
|
9445
9547
|
const board = await projects.find(owner, declared.name);
|
|
9446
9548
|
if (!board) {
|
|
9447
9549
|
const closed = (await projects.list(owner)).some((b) => b.name === declared.name && b.closed);
|
|
9448
|
-
rows.push(row$
|
|
9550
|
+
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`"]));
|
|
9449
9551
|
continue;
|
|
9450
9552
|
}
|
|
9451
|
-
rows.push(row$
|
|
9553
|
+
rows.push(row$3(`project:${declared.name}`, title, "ok", board.url));
|
|
9452
9554
|
if (!template) {
|
|
9453
|
-
rows.push(row$
|
|
9555
|
+
rows.push(row$3(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
|
|
9454
9556
|
continue;
|
|
9455
9557
|
}
|
|
9456
9558
|
rows.push(...boardRows(declared.name, template, await projects.read(owner, board)));
|
|
9457
|
-
rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$
|
|
9559
|
+
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")]);
|
|
9458
9560
|
} catch (err) {
|
|
9459
|
-
rows.push(row$
|
|
9561
|
+
rows.push(row$3(`project:${declared.name}`, title, "fail", describeError(err)));
|
|
9460
9562
|
}
|
|
9461
9563
|
}
|
|
9462
9564
|
return rows;
|
|
@@ -10131,19 +10233,19 @@ async function runDoctorRepo(input) {
|
|
|
10131
10233
|
const rows = [];
|
|
10132
10234
|
if (!loader.has("source")) {
|
|
10133
10235
|
const why = whyMissing(loader, "source", "no `source` provider to read the repository with");
|
|
10134
|
-
for (const check of checks) rows.push(row$
|
|
10236
|
+
for (const check of checks) rows.push(row$2(check, { skip: why }));
|
|
10135
10237
|
} else {
|
|
10136
10238
|
const source = loader.get("source");
|
|
10137
10239
|
for (const check of checks) {
|
|
10138
10240
|
if (typeof source[check.needs] !== "function") {
|
|
10139
|
-
rows.push(row$
|
|
10241
|
+
rows.push(row$2(check, { skip: `provider does not implement ${check.needs}` }));
|
|
10140
10242
|
continue;
|
|
10141
10243
|
}
|
|
10142
10244
|
try {
|
|
10143
|
-
rows.push(row$
|
|
10245
|
+
rows.push(row$2(check, await check.run(source)));
|
|
10144
10246
|
} catch (err) {
|
|
10145
10247
|
const noToken = missingTokenReason(err);
|
|
10146
|
-
if (noToken !== void 0) rows.push(row$
|
|
10248
|
+
if (noToken !== void 0) rows.push(row$2(check, { skip: noToken }));
|
|
10147
10249
|
else rows.push({
|
|
10148
10250
|
id: check.id,
|
|
10149
10251
|
title: check.title,
|
|
@@ -10169,7 +10271,7 @@ async function runDoctorRepo(input) {
|
|
|
10169
10271
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
10170
10272
|
};
|
|
10171
10273
|
}
|
|
10172
|
-
function row$
|
|
10274
|
+
function row$2(check, result) {
|
|
10173
10275
|
const { id, title } = check;
|
|
10174
10276
|
if ("skip" in result) return {
|
|
10175
10277
|
id,
|
|
@@ -10577,14 +10679,14 @@ async function runDoctorVariables(input) {
|
|
|
10577
10679
|
});
|
|
10578
10680
|
else if (!loader.has("source")) {
|
|
10579
10681
|
const why = whyMissing(loader, "source", "no `source` provider to read them with");
|
|
10580
|
-
for (const check of checks) rows.push(row(check, { skip: why }));
|
|
10682
|
+
for (const check of checks) rows.push(row$1(check, { skip: why }));
|
|
10581
10683
|
} else {
|
|
10582
10684
|
const source = loader.get("source");
|
|
10583
10685
|
for (const check of checks) try {
|
|
10584
|
-
rows.push(row(check, await check.run(source)));
|
|
10686
|
+
rows.push(row$1(check, await check.run(source)));
|
|
10585
10687
|
} catch (err) {
|
|
10586
10688
|
const noToken = missingTokenReason(err);
|
|
10587
|
-
if (noToken !== void 0) rows.push(row(check, { skip: noToken }));
|
|
10689
|
+
if (noToken !== void 0) rows.push(row$1(check, { skip: noToken }));
|
|
10588
10690
|
else rows.push({
|
|
10589
10691
|
id: check.id,
|
|
10590
10692
|
title: check.title,
|
|
@@ -10609,7 +10711,7 @@ async function runDoctorVariables(input) {
|
|
|
10609
10711
|
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
10610
10712
|
};
|
|
10611
10713
|
}
|
|
10612
|
-
function row(check, result) {
|
|
10714
|
+
function row$1(check, result) {
|
|
10613
10715
|
const { id, title } = check;
|
|
10614
10716
|
if ("skip" in result) return {
|
|
10615
10717
|
id,
|
|
@@ -11372,6 +11474,201 @@ const githubAppCommand = {
|
|
|
11372
11474
|
builder: (y) => y.command(githubAppCreateCommand).command(groupMenu$1("github-app")),
|
|
11373
11475
|
handler: () => {}
|
|
11374
11476
|
};
|
|
11477
|
+
// src/commands/ideas-sync/resolve-ideas-provider/resolve-ideas-provider.ts
|
|
11478
|
+
/**
|
|
11479
|
+
* The `ideas` provider `ideas sync` reads through: `providers.ideas` when the config names one. A config written
|
|
11480
|
+
* before the capability has only `ideas.dir` (#2004), so that, or `HOLOCRON_IDEAS_DIR` alone, reads as
|
|
11481
|
+
* `["obsidian", { dir }]`, the way a `HOLOCRON_` variable falls back to the bare name. `providers.ideas` wins over
|
|
11482
|
+
* `ideas.dir`. `undefined` when the config names no place for ideas at all.
|
|
11483
|
+
*/
|
|
11484
|
+
function resolveIdeasProvider(resolved, env) {
|
|
11485
|
+
const own = resolved.providers.ideas;
|
|
11486
|
+
if (own) return own;
|
|
11487
|
+
const dir = resolved.ideas?.dir;
|
|
11488
|
+
if (dir === void 0 && holocronEnv(env).get("IDEAS_DIR") === void 0) return void 0;
|
|
11489
|
+
return {
|
|
11490
|
+
cardinality: "single",
|
|
11491
|
+
tuple: {
|
|
11492
|
+
provider: "obsidian",
|
|
11493
|
+
packageName: resolvePluginPackage$1("obsidian"),
|
|
11494
|
+
options: dir === void 0 ? {} : { dir }
|
|
11495
|
+
}
|
|
11496
|
+
};
|
|
11497
|
+
}
|
|
11498
|
+
// src/commands/ideas-sync/run-ideas-sync/run-ideas-sync.ts
|
|
11499
|
+
/**
|
|
11500
|
+
* `holocron ideas sync` — files the idea notes that are ready.
|
|
11501
|
+
*
|
|
11502
|
+
* It reads every idea through the `ideas` provider (`providers.ideas`, or `ideas.dir` read as an Obsidian vault; the
|
|
11503
|
+
* Obsidian plugin skips folders whose name starts with `_` or `.`). An idea whose status is the filing state (default
|
|
11504
|
+
* `in-progress`) and that has no issue becomes an issue through the repo's `issues` provider, and the issue is then
|
|
11505
|
+
* recorded with `Ideas.markFiled` (for Obsidian, an `issue:` property in the tracker's own syntax), which is what makes
|
|
11506
|
+
* the step run once. An idea with attachments is reported and skipped, since an issue body cannot carry them. Only
|
|
11507
|
+
* ideas to be filed, and ideas that need the person's attention, get a row; the rest are counted. The issue body ends
|
|
11508
|
+
* with a hidden `<!-- holocron:idea <key> -->` line, and an issue that carries it is reused instead of making a second
|
|
11509
|
+
* one (found with `Issues.search`, the recent issues only). It never deletes anything, and an idea it cannot file is a
|
|
11510
|
+
* failing row (the run goes on). It writes, so it asks first unless `--dry-run` or `--yes` (without a terminal it refuses instead).
|
|
11511
|
+
*/
|
|
11512
|
+
/** The state that files a note when the config names none. */
|
|
11513
|
+
const DEFAULT_FILING_STATE = "in-progress";
|
|
11514
|
+
const row = (id, status, detail) => ({
|
|
11515
|
+
id,
|
|
11516
|
+
title: id,
|
|
11517
|
+
status,
|
|
11518
|
+
detail,
|
|
11519
|
+
problems: []
|
|
11520
|
+
});
|
|
11521
|
+
/**
|
|
11522
|
+
* 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
|
|
11523
|
+
* `issue:` could not be written is not filed twice.
|
|
11524
|
+
*/
|
|
11525
|
+
const marker = (key) => `<!-- holocron:idea ${key} -->`;
|
|
11526
|
+
/** The issue's body: the idea's text, the line that traces the issue to its idea, and the hidden marker. */
|
|
11527
|
+
const issueBody = (idea) => `${idea.body.trim()}\n\nFiled from idea: ${idea.title}\n${marker(idea.key)}`;
|
|
11528
|
+
/** How many recent issues are searched for the marker (the narrowest existing method, `Issues.search`). */
|
|
11529
|
+
const SEARCH_LIMIT = 100;
|
|
11530
|
+
async function runIdeasSync(input) {
|
|
11531
|
+
/* v8 ignore next -- the console is only used outside tests, which inject `print` */
|
|
11532
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
11533
|
+
const dryRun = Boolean(input.context.dryRun);
|
|
11534
|
+
let notReady = 0;
|
|
11535
|
+
const finish = (rows, status) => {
|
|
11536
|
+
printCheckRows(rows, print);
|
|
11537
|
+
const summary = summariseChecks(rows);
|
|
11538
|
+
printCheckSummary(summary, print);
|
|
11539
|
+
if (notReady > 0) print(` ${notReady} note(s) not ready (another status, or already filed), shown in no row`);
|
|
11540
|
+
return {
|
|
11541
|
+
status: status ?? (summary.fail > 0 ? "fail" : "ok"),
|
|
11542
|
+
rows
|
|
11543
|
+
};
|
|
11544
|
+
};
|
|
11545
|
+
print(style.header(`Holocron ideas sync${dryRun ? " (dry-run)" : ""}`));
|
|
11546
|
+
print("");
|
|
11547
|
+
const entry = resolveIdeasProvider(input.loaded.resolved, input.env);
|
|
11548
|
+
if (!entry) return finish([row("ideas", "fail", "no `ideas` provider: set `providers.ideas` (`[\"obsidian\", { dir }]`) in holocron.config or HOLOCRON_IDEAS_DIR")]);
|
|
11549
|
+
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
11550
|
+
const reader = input.ideasLoader ?? new PluginLoader({
|
|
11551
|
+
...input.loaded.resolved,
|
|
11552
|
+
providers: { ideas: entry }
|
|
11553
|
+
}, input.context);
|
|
11554
|
+
/* v8 ignore stop */
|
|
11555
|
+
await reader.load();
|
|
11556
|
+
assertPluginsResolvable$1(reader, "ideas sync");
|
|
11557
|
+
if (!reader.has("ideas")) {
|
|
11558
|
+
const failure = reader.loadFailures().find((f) => f.key === "ideas");
|
|
11559
|
+
return finish([row("ideas", "fail", `the \`ideas\` provider is not available${failure ? ` (${describeError(failure.error)})` : ""}`)]);
|
|
11560
|
+
}
|
|
11561
|
+
const ideas = reader.get("ideas");
|
|
11562
|
+
let records;
|
|
11563
|
+
try {
|
|
11564
|
+
records = await ideas.list();
|
|
11565
|
+
} catch (err) {
|
|
11566
|
+
return finish([row("ideas", "fail", describeError(err))]);
|
|
11567
|
+
}
|
|
11568
|
+
const fileState = input.loaded.resolved.ideas?.states?.file ?? DEFAULT_FILING_STATE;
|
|
11569
|
+
const rows = [];
|
|
11570
|
+
const ready = [];
|
|
11571
|
+
for (const idea of records) if (idea.error !== void 0) rows.push(row(idea.key, "fail", idea.error));
|
|
11572
|
+
else if (idea.status !== fileState || idea.issue !== void 0) notReady++;
|
|
11573
|
+
else if (idea.attachments.length > 0) rows.push(row(idea.key, "skip", `has embedded files an issue cannot carry (${idea.attachments.join(", ")}); not filed`));
|
|
11574
|
+
else ready.push(idea);
|
|
11575
|
+
if (ready.length === 0) return finish(rows);
|
|
11576
|
+
if (dryRun) {
|
|
11577
|
+
for (const idea of ready) rows.push(row(idea.key, "skip", `would file "${idea.title}"`));
|
|
11578
|
+
return finish(rows.sort((a, b) => a.id.localeCompare(b.id)));
|
|
11579
|
+
}
|
|
11580
|
+
if (!input.yes) {
|
|
11581
|
+
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`);
|
|
11582
|
+
if (!await (input.confirm ?? ((message) => confirm({
|
|
11583
|
+
message,
|
|
11584
|
+
default: false
|
|
11585
|
+
})))(`File ${ready.length} idea(s) as issues and record the issue in each note?`)) {
|
|
11586
|
+
print(` ${style.skip("cancelled; nothing was changed")}`);
|
|
11587
|
+
return {
|
|
11588
|
+
status: "cancelled",
|
|
11589
|
+
rows: []
|
|
11590
|
+
};
|
|
11591
|
+
}
|
|
11592
|
+
}
|
|
11593
|
+
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
11594
|
+
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
11595
|
+
await loader.load();
|
|
11596
|
+
assertPluginsResolvable$1(loader, "ideas sync");
|
|
11597
|
+
const issues = loader.has("issues") ? loader.get("issues") : void 0;
|
|
11598
|
+
let recent = [];
|
|
11599
|
+
let searchError;
|
|
11600
|
+
if (issues) try {
|
|
11601
|
+
recent = await issues.search({ limit: SEARCH_LIMIT });
|
|
11602
|
+
} catch (err) {
|
|
11603
|
+
searchError = err;
|
|
11604
|
+
}
|
|
11605
|
+
const searchFailed = searchError !== void 0;
|
|
11606
|
+
for (const idea of ready) {
|
|
11607
|
+
const path = idea.key;
|
|
11608
|
+
if (!issues) {
|
|
11609
|
+
rows.push(row(path, "fail", "the config has no `issues` provider to file it with"));
|
|
11610
|
+
continue;
|
|
11611
|
+
}
|
|
11612
|
+
if (searchFailed) {
|
|
11613
|
+
rows.push(row(path, "fail", `could not check for an existing issue, so none was created: ${describeError(searchError)}`));
|
|
11614
|
+
continue;
|
|
11615
|
+
}
|
|
11616
|
+
let key;
|
|
11617
|
+
const existing = recent.find((issue) => issue.body?.includes(marker(path)));
|
|
11618
|
+
if (existing) key = existing.key;
|
|
11619
|
+
else try {
|
|
11620
|
+
({key} = await issues.create({
|
|
11621
|
+
summary: idea.title,
|
|
11622
|
+
body: issueBody(idea)
|
|
11623
|
+
}));
|
|
11624
|
+
} catch (err) {
|
|
11625
|
+
rows.push(row(path, "fail", `could not create the issue: ${describeError(err)}`));
|
|
11626
|
+
continue;
|
|
11627
|
+
}
|
|
11628
|
+
try {
|
|
11629
|
+
await ideas.markFiled(path, key);
|
|
11630
|
+
rows.push(row(path, "ok", `${existing ? "already filed" : "filed"} as ${key}`));
|
|
11631
|
+
} catch (err) {
|
|
11632
|
+
rows.push({
|
|
11633
|
+
...row(path, "fail", `issue ${key} was created but \`issue:\` was not written: ${describeError(err)}`),
|
|
11634
|
+
problems: [`add \`issue: ${key}\` to the note by hand`]
|
|
11635
|
+
});
|
|
11636
|
+
}
|
|
11637
|
+
}
|
|
11638
|
+
return finish(rows.sort((a, b) => a.id.localeCompare(b.id)));
|
|
11639
|
+
}
|
|
11640
|
+
// src/commands/ideas-sync/ideas-sync.command.ts
|
|
11641
|
+
const ideasSyncCommand = {
|
|
11642
|
+
command: "sync",
|
|
11643
|
+
describe: "File the idea notes that are ready as issues, and record the issue in each note",
|
|
11644
|
+
builder: (y) => y.option("yes", {
|
|
11645
|
+
type: "boolean",
|
|
11646
|
+
describe: "File without asking (required without a terminal)"
|
|
11647
|
+
}),
|
|
11648
|
+
handler: async (argv) => {
|
|
11649
|
+
const tokens = tokenContext$1(argv.token);
|
|
11650
|
+
if (!tokens) return;
|
|
11651
|
+
const loaded = await loadConfig(argv.cwd);
|
|
11652
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
11653
|
+
if ((await runIdeasSync({
|
|
11654
|
+
loaded,
|
|
11655
|
+
context: {
|
|
11656
|
+
repoRoot: argv.cwd,
|
|
11657
|
+
dryRun: argv.dryRun,
|
|
11658
|
+
...tokens,
|
|
11659
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
11660
|
+
},
|
|
11661
|
+
...argv.yes ? { yes: true } : {}
|
|
11662
|
+
})).status === "fail") process.exitCode = 1;
|
|
11663
|
+
}
|
|
11664
|
+
};
|
|
11665
|
+
// src/commands/ideas/ideas.command.ts
|
|
11666
|
+
const ideasCommand = {
|
|
11667
|
+
command: "ideas",
|
|
11668
|
+
describe: "Work with the idea notes that sit in front of the issue tracker",
|
|
11669
|
+
builder: (y) => y.command(ideasSyncCommand).command(groupMenu$1("ideas")),
|
|
11670
|
+
handler: () => {}
|
|
11671
|
+
};
|
|
11375
11672
|
// src/commands/menu/menu.command.ts
|
|
11376
11673
|
/**
|
|
11377
11674
|
* Print the dim version line once per terminal session — keyed by the
|
|
@@ -15010,7 +15307,7 @@ function workspaceFilterArgs(cwd, scope = {}) {
|
|
|
15010
15307
|
*
|
|
15011
15308
|
* $ pnpm install --frozen-lockfile
|
|
15012
15309
|
* $ pnpm build
|
|
15013
|
-
* $ pnpm
|
|
15310
|
+
* $ pnpm --filter @theholocron/cli run start:source package publish --initial
|
|
15014
15311
|
*
|
|
15015
15312
|
* `npm login --auth-type=web` runs automatically the first time — no
|
|
15016
15313
|
* separate manual step. `pnpm install` + `pnpm build` stay outside the
|
|
@@ -15164,7 +15461,7 @@ async function runPublish(input = {}) {
|
|
|
15164
15461
|
if (publish.stdout.includes("EOTP") || publish.stderr.includes("EOTP")) {
|
|
15165
15462
|
print("");
|
|
15166
15463
|
print(" → hint: your npm account requires 2FA for writes. Re-run with `--otp <code>`:");
|
|
15167
|
-
print(` pnpm
|
|
15464
|
+
print(` pnpm --filter @theholocron/cli run start:source package publish --initial --otp <6-digit-code>`);
|
|
15168
15465
|
}
|
|
15169
15466
|
for (const entry of newEntries) print(statusRow("fail", [
|
|
15170
15467
|
pad(entry.name, nameWidth),
|
|
@@ -24515,7 +24812,7 @@ try {
|
|
|
24515
24812
|
org: argv.org
|
|
24516
24813
|
});
|
|
24517
24814
|
finishCommand = startCommand(name);
|
|
24518
|
-
}).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:
|
|
24815
|
+
}).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:
|
|
24519
24816
|
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) => {
|
|
24520
24817
|
if (err instanceof Error && USER_FACING_ERRORS.has(err.name)) {
|
|
24521
24818
|
captureException(err);
|