@theholocron/cli 5.0.0-alpha.235 → 5.0.0-alpha.237
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/dist/cli.mjs +47 -6
- package/dist/cli.mjs.map +1 -1
- package/dist/plugin/capabilities.d.mts +5 -0
- package/package.json +4 -4
package/dist/cli.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { lintCommitMsgFile } from "@theholocron/astromech/lint";
|
|
|
10
10
|
import { LOG_LEVELS, NoopAnalyticsSink, NoopErrorSink, redactObject } from "@theholocron/observability/core";
|
|
11
11
|
import yargs from "yargs";
|
|
12
12
|
import { hideBin } from "yargs/helpers";
|
|
13
|
-
import { AuthError, ProviderApiError, ProviderApiError as ProviderApiError$1, createRestClient } from "@theholocron/http-client";
|
|
13
|
+
import { AuthError, ProviderApiError, ProviderApiError as ProviderApiError$1, createRestClient, onRetry } from "@theholocron/http-client";
|
|
14
14
|
import { createEnvLookup, firstEnv, withEnvPrefix } from "@theholocron/env-utils";
|
|
15
15
|
import { Entry, findCredentials } from "@napi-rs/keyring";
|
|
16
16
|
import { pathToFileURL } from "node:url";
|
|
@@ -24,7 +24,7 @@ import search from "@inquirer/search";
|
|
|
24
24
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
25
25
|
import ora from "ora";
|
|
26
26
|
import { findRootSync, isWorkspaceRoot, walkFilesSync } from "@theholocron/fs-utils";
|
|
27
|
-
import { access, copyFile, mkdir, open, readFile, readdir, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
27
|
+
import { access, copyFile, mkdir, open, readFile, readdir, realpath, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
28
28
|
import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
29
29
|
import { createServer } from "node:http";
|
|
30
30
|
import { stringifyJson } from "@theholocron/json-utils";
|
|
@@ -797,9 +797,13 @@ function createProgress(print, enabled = progressEnabled) {
|
|
|
797
797
|
discardStdin: false
|
|
798
798
|
}).start();
|
|
799
799
|
active = spinner;
|
|
800
|
+
const stopListening = onRetry((e) => {
|
|
801
|
+
spinner.text = `${label} (retrying ${e.vendor ?? "the request"}, attempt ${e.attempt} of ${e.of})`;
|
|
802
|
+
});
|
|
800
803
|
try {
|
|
801
804
|
return await fn();
|
|
802
805
|
} finally {
|
|
806
|
+
stopListening();
|
|
803
807
|
spinner.stop();
|
|
804
808
|
active = void 0;
|
|
805
809
|
}
|
|
@@ -6963,6 +6967,29 @@ function printNextSteps$1(print, inputs) {
|
|
|
6963
6967
|
print(" 7. Commit + push when capability is functionally complete.");
|
|
6964
6968
|
}
|
|
6965
6969
|
//#endregion
|
|
6970
|
+
//#region src/commands/probe/app-vault.ts
|
|
6971
|
+
/**
|
|
6972
|
+
* The vault of an app that carries its own `holocron.config` (`apps/comlink`, `apps/sentinel`): those configs govern where
|
|
6973
|
+
* the app's secrets live, apart from the root's. `undefined` when the app has no config of its own (the search for one
|
|
6974
|
+
* would otherwise walk up and find the root's), or its config declares no vault, or that config cannot be read.
|
|
6975
|
+
*/
|
|
6976
|
+
async function loadAppVault(appDir, context, importer) {
|
|
6977
|
+
let loaded;
|
|
6978
|
+
try {
|
|
6979
|
+
loaded = await loadConfig(appDir);
|
|
6980
|
+
} catch {
|
|
6981
|
+
return;
|
|
6982
|
+
}
|
|
6983
|
+
const [found, wanted] = await Promise.all([realpath(dirname(loaded.filepath)), realpath(appDir)]);
|
|
6984
|
+
if (found !== wanted) return void 0;
|
|
6985
|
+
const loader = new PluginLoader(loaded.resolved, {
|
|
6986
|
+
...context,
|
|
6987
|
+
repoRoot: appDir
|
|
6988
|
+
}, importer);
|
|
6989
|
+
await loader.load();
|
|
6990
|
+
return loader.has("vault") ? loader.get("vault") : void 0;
|
|
6991
|
+
}
|
|
6992
|
+
//#endregion
|
|
6966
6993
|
//#region src/commands/probe/comlink-probes.ts
|
|
6967
6994
|
/** The group of probes for the Comlink relay Worker (`apps/comlink`). It is an app, not a provider, so they are the CLI's own. */
|
|
6968
6995
|
const COMLINK_PROVIDER = "comlink";
|
|
@@ -6977,6 +7004,7 @@ function relayOf(loader) {
|
|
|
6977
7004
|
return {
|
|
6978
7005
|
host,
|
|
6979
7006
|
script: layout.relay?.script ?? "comlink",
|
|
7007
|
+
appDir: dirname(dirname(layout.relay?.code ?? "apps/comlink/dist/worker.js")),
|
|
6980
7008
|
source: errors.providerName.toLowerCase()
|
|
6981
7009
|
};
|
|
6982
7010
|
}
|
|
@@ -6995,6 +7023,15 @@ const testDelivery = () => JSON.stringify({
|
|
|
6995
7023
|
triggered_rule: "holocron probe"
|
|
6996
7024
|
}
|
|
6997
7025
|
});
|
|
7026
|
+
/** A secret by name from a vault: the bare name when the vault can take one, else as a reference. `undefined` if it cannot be read. */
|
|
7027
|
+
async function readSecret(vault, name) {
|
|
7028
|
+
if (!vault) return void 0;
|
|
7029
|
+
try {
|
|
7030
|
+
return await (vault.readSecret ? vault.readSecret(name) : vault.read(name)) || void 0;
|
|
7031
|
+
} catch {
|
|
7032
|
+
return;
|
|
7033
|
+
}
|
|
7034
|
+
}
|
|
6998
7035
|
function comlinkProbes(deps) {
|
|
6999
7036
|
const http = deps.fetch ?? fetch;
|
|
7000
7037
|
const env = deps.env ?? process.env;
|
|
@@ -7054,7 +7091,7 @@ function comlinkProbes(deps) {
|
|
|
7054
7091
|
summary: "Send the relay a correctly signed test alert, so a labelled embed lands in the errors channel. The message stays there.",
|
|
7055
7092
|
writes: true,
|
|
7056
7093
|
async run(probe) {
|
|
7057
|
-
const { host, source } = relayOf(deps.loader);
|
|
7094
|
+
const { host, source, appDir } = relayOf(deps.loader);
|
|
7058
7095
|
if (source !== "sentry") throw new Error(`deliver knows how to sign a Sentry delivery, not a ${source} one`);
|
|
7059
7096
|
const name = relaySecretBinding(source);
|
|
7060
7097
|
if (probe.dryRun) {
|
|
@@ -7065,8 +7102,9 @@ function comlinkProbes(deps) {
|
|
|
7065
7102
|
return;
|
|
7066
7103
|
}
|
|
7067
7104
|
let secret = env[name];
|
|
7068
|
-
if (!secret && deps.
|
|
7069
|
-
if (!secret
|
|
7105
|
+
if (!secret && deps.appVault) secret = await readSecret(await deps.appVault(appDir), name);
|
|
7106
|
+
if (!secret && deps.loader.has("vault")) secret = await readSecret(deps.loader.get("vault"), name);
|
|
7107
|
+
if (!secret) throw new Error(`no signing secret: set ${name} in the environment, or give ${appDir}/holocron.config a vault that holds it`);
|
|
7070
7108
|
probe.secret(secret);
|
|
7071
7109
|
const body = testDelivery();
|
|
7072
7110
|
const status = await probe.write("send a signed test alert to the relay", async () => {
|
|
@@ -7336,7 +7374,10 @@ async function runProbeCommand(input) {
|
|
|
7336
7374
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
7337
7375
|
await loader.load();
|
|
7338
7376
|
const groups = new Map(loader.probes());
|
|
7339
|
-
const comlink = comlinkProbes({
|
|
7377
|
+
const comlink = comlinkProbes({
|
|
7378
|
+
loader,
|
|
7379
|
+
appVault: (appDir) => loadAppVault(join(input.context.repoRoot, appDir), input.context)
|
|
7380
|
+
});
|
|
7340
7381
|
groups.set(CORE_PROVIDER, coreProbes(loader, /* @__PURE__ */ new Map([[COMLINK_PROVIDER, comlink]])));
|
|
7341
7382
|
groups.set(COMLINK_PROVIDER, comlink);
|
|
7342
7383
|
if (!input.provider) {
|