@theholocron/cli 5.0.0-alpha.221 → 5.0.0-alpha.223
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 +1 -1
- package/dist/cli.mjs +74 -4
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.mjs +1 -1
- package/dist/plugin/capabilities.d.mts +44 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -550,7 +550,7 @@ commands and the config are provider-neutral; Discord is the first provider.
|
|
|
550
550
|
|
|
551
551
|
Channels fed by another service are declared with `feeds` on the channel: `{ name: "uptime", webhook: true, feeds: { monitoring: true } }` (the object form `{ name?, webhook?, avatar? }` overrides the alert channel's name, default `Message to #<channel>`, the dedicated webhook's name, default the provider's, and gives that webhook a picture, a file path or `https://` URL, or `{ url, image }` (the URL is tried first, the file in the repo is the fallback), else the provider's own icon (`Monitoring.icon`, a URL and an embedded `data:` image; Checkly provides one), else the layout's `webhookAvatar`, else the layout's `webhookAvatar`). `setup` gives the channel a dedicated webhook and hands its URL straight to the `monitoring` provider through `Monitoring.ensureAlertChannel({ name, format: "discord", url? })`, which finds an alert channel of that name or creates one and subscribes every check; the URL is never stored as a secret. It needs a `monitoring` provider that implements `ensureAlertChannel` (Checkly does). Two feeds may not share an alert channel name, and a feed's webhook may not share the channel's own webhook name (compared without regard to case).
|
|
552
552
|
|
|
553
|
-
Channels fed by the error tracker add `feeds: { errors: true }` and a layout `relay: { host, zone?, script?, code? }`: `setup` makes a dedicated webhook, points `host` at the Comlink Worker (a proxied DNS record via `dns`), and deploys it via `workers.deployScript` with the webhook URL as `COMLINK_<SOURCE>_WEBHOOK`. The URL never leaves the Worker's secret; other secrets on the script are kept. Needs `errors`, `workers` and `dns`; only one channel may be fed.
|
|
553
|
+
Channels fed by the error tracker add `feeds: { errors: true }` and a layout `relay: { host, zone?, script?, code? }`: `setup` makes a dedicated webhook, points `host` at the Comlink Worker (a proxied DNS record via `dns`), and deploys it via `workers.deployScript` with the webhook URL as `COMLINK_<SOURCE>_WEBHOOK`. The URL never leaves the Worker's secret; other secrets on the script are kept. With `relay.errors: { projects, integration?, rule?, frequency? }` it also ensures the tracker's integration and alert rule (`errors.ensureRelay`) and deploys the Worker with the integration's signing secret. Needs `errors`, `workers` and `dns`; only one channel may be fed.
|
|
554
554
|
|
|
555
555
|
`holocron secrets sync <env> --worker <script>` also sets every key of the vault environment on a deployed Worker as a secret, through the optional `Workers.setSecret(script, name, value)` (write-only; the Cloudflare plugin implements it). The Worker must already exist. Sync only adds and updates: it never removes a binding, because a Worker also holds secrets that are not in the vault (for Comlink, the `COMLINK_<SOURCE>_WEBHOOK` that `notifications setup` sets), so a key deleted from the vault must be deleted from the Worker separately. Keys are written one at a time and each is reported; if one fails, the exit code is 1 and re-running finishes the rest, since every write is idempotent.
|
|
556
556
|
|
package/dist/cli.mjs
CHANGED
|
@@ -134,7 +134,7 @@ function createFeatureResolver(config) {
|
|
|
134
134
|
const env = makeEnv(input.env);
|
|
135
135
|
const keyring = input.keyring ?? getToken;
|
|
136
136
|
const token = input.cliToken || env.get(config.envName) || keyring(config.keyringKey);
|
|
137
|
-
if (!token) throw new AuthError(`no GitHub token found for this operation. Pass --token <
|
|
137
|
+
if (!token) throw new AuthError(`no ${config.vendor ?? "GitHub"} token found for this operation. Pass --token <token>, set ${config.envName}, or run: holocron auth set ${config.keyringKey} <token>`);
|
|
138
138
|
return token;
|
|
139
139
|
};
|
|
140
140
|
}
|
|
@@ -4893,6 +4893,8 @@ function errorsFeedWebhook(feed, errors) {
|
|
|
4893
4893
|
const capitalised = (name) => name.charAt(0).toUpperCase() + name.slice(1);
|
|
4894
4894
|
/** The Worker binding that holds the webhook URL for a source (the contract `apps/comlink` reads). */
|
|
4895
4895
|
const relayWebhookBinding = (source) => `COMLINK_${source.toUpperCase()}_WEBHOOK`;
|
|
4896
|
+
/** The Worker binding that holds a source's signing secret (the contract `apps/comlink` reads). */
|
|
4897
|
+
const relaySecretBinding = (source) => `COMLINK_${source.toUpperCase()}_SECRET`;
|
|
4896
4898
|
/** Whether any channel in the layout is fed by the error tracker. */
|
|
4897
4899
|
function wantsRelay(layout) {
|
|
4898
4900
|
return (layout.categories ?? []).some((c) => (c.channels ?? []).some((ch) => ch.feeds?.errors));
|
|
@@ -4944,7 +4946,10 @@ async function deployRelay(input) {
|
|
|
4944
4946
|
const script = relay.script ?? "comlink";
|
|
4945
4947
|
await workers.deployScript(script, {
|
|
4946
4948
|
code,
|
|
4947
|
-
secrets: {
|
|
4949
|
+
secrets: {
|
|
4950
|
+
[relayWebhookBinding(input.source)]: input.webhook,
|
|
4951
|
+
...input.signingSecret ? { [relaySecretBinding(input.source)]: input.signingSecret } : {}
|
|
4952
|
+
},
|
|
4948
4953
|
routes: [`${relay.host}/*`]
|
|
4949
4954
|
});
|
|
4950
4955
|
await dns.upsertRecord(relayZone(relay), {
|
|
@@ -5416,6 +5421,43 @@ async function runNotificationsSetup(input$1) {
|
|
|
5416
5421
|
}
|
|
5417
5422
|
if (errors && workers && dns && wantsRelay(layout)) {
|
|
5418
5423
|
print(`\n${style.header("Relay")}`);
|
|
5424
|
+
const tracker = layout.relay.errors;
|
|
5425
|
+
let signingSecret;
|
|
5426
|
+
if (tracker && errors.ensureRelay) await attempt(`${errors.providerName} alert relay`, async () => {
|
|
5427
|
+
const integration = tracker.integration ?? "Comlink";
|
|
5428
|
+
const rule = tracker.rule ?? "Errors to Discord (Comlink)";
|
|
5429
|
+
if (dryRun) {
|
|
5430
|
+
print(` ${style.skip(`would ensure the ${errors.providerName} integration ${integration} and the alert rule ${rule} on ${tracker.projects.join(", ")}`)}`);
|
|
5431
|
+
tally.skip += 2;
|
|
5432
|
+
return;
|
|
5433
|
+
}
|
|
5434
|
+
const result = await errors.ensureRelay({
|
|
5435
|
+
name: integration,
|
|
5436
|
+
webhookUrl: `https://${layout.relay.host}/${errors.providerName}`,
|
|
5437
|
+
projects: tracker.projects,
|
|
5438
|
+
rule: {
|
|
5439
|
+
name: rule,
|
|
5440
|
+
...tracker.frequency ? { frequency: tracker.frequency } : {}
|
|
5441
|
+
}
|
|
5442
|
+
});
|
|
5443
|
+
signingSecret = result.clientSecret;
|
|
5444
|
+
for (const [what, name, outcome] of [[
|
|
5445
|
+
"integration",
|
|
5446
|
+
integration,
|
|
5447
|
+
result.integration
|
|
5448
|
+
], [
|
|
5449
|
+
"alert rule",
|
|
5450
|
+
rule,
|
|
5451
|
+
result.rule
|
|
5452
|
+
]]) {
|
|
5453
|
+
const changed = outcome.created || outcome.updated.length > 0;
|
|
5454
|
+
const verb = outcome.created ? "created" : changed ? "updated" : "exists ";
|
|
5455
|
+
const detail = outcome.updated.length > 0 ? `: ${outcome.updated.join(", ")}` : "";
|
|
5456
|
+
print(` ${(changed ? style.success : style.skip)(`${verb} ${errors.providerName} ${what} ${name}${detail}`)}`);
|
|
5457
|
+
made(changed);
|
|
5458
|
+
}
|
|
5459
|
+
if (!signingSecret) print(` ${style.warn(`${errors.providerName} would not show the integration's signing secret to this token, so the Worker keeps the one it has (it needs a token with every scope the integration has)`)}`);
|
|
5460
|
+
});
|
|
5419
5461
|
await attempt(`relay ${layout.relay.host}`, async () => {
|
|
5420
5462
|
if (dryRun) {
|
|
5421
5463
|
print(` ${style.skip(`would deploy the relay Worker at ${layout.relay.host}`)}`);
|
|
@@ -5427,6 +5469,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
5427
5469
|
relay: layout.relay,
|
|
5428
5470
|
source: errors.providerName,
|
|
5429
5471
|
webhook: relayWebhook,
|
|
5472
|
+
...signingSecret ? { signingSecret } : {},
|
|
5430
5473
|
repoRoot: input$1.context.repoRoot,
|
|
5431
5474
|
workers,
|
|
5432
5475
|
dns,
|
|
@@ -7771,6 +7814,12 @@ function describeScope(scope) {
|
|
|
7771
7814
|
* If it doesn't, the command errors with a hint to populate the keys
|
|
7772
7815
|
* individually via `holocron secrets set` (also planned for v5.1).
|
|
7773
7816
|
*/
|
|
7817
|
+
/** Why there is no `workers` provider: the plugin's own load error when it failed to load (e.g. a missing account id). */
|
|
7818
|
+
function workersMissing(loader) {
|
|
7819
|
+
const base = "--worker needs a `workers` provider in holocron.config.ts";
|
|
7820
|
+
const failure = loader.loadFailures().find((f) => f.key === "workers");
|
|
7821
|
+
return failure ? `${base} (\`${failure.provider}\` failed to load: ${describeProviderError(failure.error)})` : base;
|
|
7822
|
+
}
|
|
7774
7823
|
async function runSecretsSync(input) {
|
|
7775
7824
|
const print = input.print ?? ((line) => console.log(line));
|
|
7776
7825
|
const logger = input.logger ?? getLogger();
|
|
@@ -7788,7 +7837,24 @@ async function runSecretsSync(input) {
|
|
|
7788
7837
|
print("");
|
|
7789
7838
|
const vault = loader.get("vault");
|
|
7790
7839
|
if (!vault.readEnvironment) throw new Error(`vault provider (${vault.providerName}) does not implement readEnvironment — sync needs bulk env reads`);
|
|
7791
|
-
|
|
7840
|
+
let envVars;
|
|
7841
|
+
try {
|
|
7842
|
+
envVars = await withSpinner(`Reading vault environment ${input.environmentId}…`, () => vault.readEnvironment(input.environmentId));
|
|
7843
|
+
} catch (err) {
|
|
7844
|
+
const message = describeProviderError(err);
|
|
7845
|
+
print(` ${style.fail(`could not read vault environment ${input.environmentId}: ${message}`)}`);
|
|
7846
|
+
logger.warn({
|
|
7847
|
+
environment: input.environmentId,
|
|
7848
|
+
reason: logReason(err)
|
|
7849
|
+
}, "secrets sync: vault read failed");
|
|
7850
|
+
return summarise([{
|
|
7851
|
+
destination: `vault:${vault.providerName}`,
|
|
7852
|
+
scope: `environment=${input.environmentId}`,
|
|
7853
|
+
key: "(all)",
|
|
7854
|
+
status: "fail",
|
|
7855
|
+
message
|
|
7856
|
+
}], logger, print, dryRun);
|
|
7857
|
+
}
|
|
7792
7858
|
const keys = Object.keys(envVars).sort();
|
|
7793
7859
|
print(style.step(`read ${keys.length} keys from vault`));
|
|
7794
7860
|
print("");
|
|
@@ -7839,7 +7905,7 @@ async function runSecretsSync(input) {
|
|
|
7839
7905
|
scope: `script=${script}`,
|
|
7840
7906
|
key: "(all)",
|
|
7841
7907
|
status: "fail",
|
|
7842
|
-
message: workers ? `workers provider (${workers.providerName}) cannot set secrets` :
|
|
7908
|
+
message: workers ? `workers provider (${workers.providerName}) cannot set secrets` : workersMissing(loader)
|
|
7843
7909
|
};
|
|
7844
7910
|
rows.push(row);
|
|
7845
7911
|
print(formatRow(row));
|
|
@@ -7850,6 +7916,10 @@ async function runSecretsSync(input) {
|
|
|
7850
7916
|
print(formatRow(rows[rows.length - 1]));
|
|
7851
7917
|
}
|
|
7852
7918
|
}
|
|
7919
|
+
return summarise(rows, logger, print, dryRun);
|
|
7920
|
+
}
|
|
7921
|
+
/** Log every row, then print and log the summary. Shared by a finished run and one that stopped at the vault. */
|
|
7922
|
+
function summarise(rows, logger, print, dryRun) {
|
|
7853
7923
|
for (const r of rows) logger[r.status === "fail" ? "warn" : "info"]({
|
|
7854
7924
|
destination: r.destination,
|
|
7855
7925
|
scope: r.scope,
|