@theholocron/cli 5.0.0-alpha.512 → 5.0.0-alpha.514
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 +50 -20
- package/dist/cli.mjs.map +1 -1
- package/dist/{index-D_e9vKTW.d.mts → index-ur4G1f2k.d.mts} +6 -0
- package/dist/index.d.mts +1 -1
- package/dist/plugin/capabilities.d.mts +1 -1
- package/dist/presets.d.mts +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -691,7 +691,7 @@ commands and the config are provider-neutral; Discord is the first provider.
|
|
|
691
691
|
|
|
692
692
|
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?, alerts? }` 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`). A channel's own `webhook.avatar` and the layout's `webhookAvatar` take the same forms, a path or `https://` URL, or `{ url, image }` (the URL first, the file in the repo as the fallback); a relative path is read from the repository root. `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). `alerts: { failure?, recovery?, degraded?, sslExpiry?, sslExpiryThreshold? }` (`MonitoringAlertSettings`, passed as `ensureAlertChannel({ ..., alerts })`) sets what the alert channel alerts about: a new channel defaults to failure, recovery and degraded on and `sslExpiry` off, and on an existing channel a setting left out is left alone. A check in the `monitoring` provider's `checks` can route itself with `alertChannels: ["Message to #uptime"]` (`MonitoringCheckInput.alertChannels`, the alert channel names): it is then subscribed to those channels only, and a name no feed declares is refused by `setup`. `inspectAlertChannel` returns the channel's `alerts` and the `misrouted` checks that `doctor notifications` reports. 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).
|
|
693
693
|
|
|
694
|
-
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. A service other than the error tracker is declared in `relay.sources: { <id>: { capability, name?, events?, scope?, options? } }` and carried by a channel with `feeds.relay.<id>`: `setup` asks the provider of `capability` to make the vendor's webhook (optional `ensureRelaySource`, found again by its URL, never deleted), hands the Worker `COMLINK_<ID>_SECRET` (when the provider made or chose a secret) and `COMLINK_<ID>_WEBHOOK` in the same deploy, and `doctor notifications` adds a `relay-source:<id>` row (optional `inspectRelaySource`). 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.
|
|
694
|
+
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. A service other than the error tracker is declared in `relay.sources: { <id>: { capability, provider?, name?, events?, scope?, options? } }` and carried by a channel with `feeds.relay.<id>`: `provider` names the plugin for a capability the root config gives to another one (`vercel` for `deployment`; the layout check validates its shape, and loading it is the next change, #2522, #2523); `setup` asks the provider of `capability` to make the vendor's webhook (optional `ensureRelaySource`, found again by its URL, never deleted), hands the Worker `COMLINK_<ID>_SECRET` (when the provider made or chose a secret) and `COMLINK_<ID>_WEBHOOK` in the same deploy, and `doctor notifications` adds a `relay-source:<id>` row (optional `inspectRelaySource`). 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.
|
|
695
695
|
|
|
696
696
|
`holocron sync secrets --env <environment> --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 `setup notifications` 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.
|
|
697
697
|
|
package/dist/cli.mjs
CHANGED
|
@@ -12548,6 +12548,8 @@ const RELAY_SOURCE_CAPABILITIES = [
|
|
|
12548
12548
|
];
|
|
12549
12549
|
/** An id is a URL path segment and part of a Worker binding name, so it is lower-case letters and digits. */
|
|
12550
12550
|
const ID$1 = /^[a-z][a-z0-9]*$/;
|
|
12551
|
+
/** A plugin's name, as `providers.<capability>` spells it: lower-case letters, digits and hyphens (`vercel`, `1password`). */
|
|
12552
|
+
const PROVIDER = /^[a-z0-9][a-z0-9-]*$/;
|
|
12551
12553
|
/**
|
|
12552
12554
|
* The first reason the layout's relay sources cannot work, or undefined. `errorsSource` is the error tracker's id when a
|
|
12553
12555
|
* channel is fed by it, since the tracker's binding names are taken. Pure: it reads the layout and nothing else.
|
|
@@ -12562,6 +12564,7 @@ function relaySourcesProblem(layout, errorsSource) {
|
|
|
12562
12564
|
if (!ID$1.test(id)) return `relay source \`${id}\`: the id must be lower-case letters and digits, starting with a letter (it is a path and part of a binding name)`;
|
|
12563
12565
|
if (errorsSource !== void 0 && id === errorsSource) return `relay source \`${id}\` is the error tracker's own source — it is set up by \`relay.errors\`, not \`relay.sources\``;
|
|
12564
12566
|
if (!RELAY_SOURCE_CAPABILITIES.includes(spec?.capability)) return `relay source \`${id}\`: \`capability\` must be one of ${RELAY_SOURCE_CAPABILITIES.join(", ")}`;
|
|
12567
|
+
if (spec.provider !== void 0 && !(typeof spec.provider === "string" && PROVIDER.test(spec.provider))) return `relay source \`${id}\`: \`provider\` must be a plugin name, lower-case letters, digits and hyphens (\`vercel\`)`;
|
|
12565
12568
|
for (const key of ["events", "scope"]) {
|
|
12566
12569
|
const list = spec[key];
|
|
12567
12570
|
if (list !== void 0 && !(Array.isArray(list) && list.every((item) => typeof item === "string"))) return `relay source \`${id}\`: \`${key}\` must be a list of strings`;
|
|
@@ -13321,14 +13324,57 @@ async function runNotificationsSetup(input$1) {
|
|
|
13321
13324
|
print(` ${(changed ? style.success : style.skip)(`${verb} ${errors.providerName} ${what} ${name}${detail}`)}`);
|
|
13322
13325
|
made(changed);
|
|
13323
13326
|
}
|
|
13324
|
-
if (!result.clientSecret) print(` ${style.warn(`${errors.providerName} did not give the integration's signing secret (it may only show it once, when the integration is made), so the Worker keeps the one it has. To set it: copy it from the integration's page, add it to
|
|
13327
|
+
if (!result.clientSecret) print(` ${style.warn(`${errors.providerName} did not give the integration's signing secret (it may only show it once, when the integration is made), so the Worker keeps the one it has. To set it: copy it from the integration's page, add it to the vault as COMLINK_${errors.providerName.toUpperCase()}_SECRET and run holocron sync secrets --env prod`)}`);
|
|
13325
13328
|
});
|
|
13329
|
+
const wanted = [...errors ? [errors.providerName] : [], ...declaredSources.map((d) => d.id)];
|
|
13330
|
+
const bindingsFor = () => wanted.flatMap((source) => {
|
|
13331
|
+
const webhook = relayWebhooks.get(source);
|
|
13332
|
+
const signingSecret = signingSecrets.get(source);
|
|
13333
|
+
return webhook ? [{
|
|
13334
|
+
source,
|
|
13335
|
+
webhook,
|
|
13336
|
+
...signingSecret ? { signingSecret } : {}
|
|
13337
|
+
}] : [];
|
|
13338
|
+
});
|
|
13339
|
+
const deployWorker = (bindings) => deployRelay({
|
|
13340
|
+
relay: layout.relay,
|
|
13341
|
+
sources: bindings,
|
|
13342
|
+
repoRoot: input$1.context.repoRoot,
|
|
13343
|
+
workers,
|
|
13344
|
+
dns,
|
|
13345
|
+
...input$1.readRelayCode ? { readCode: input$1.readRelayCode } : {}
|
|
13346
|
+
});
|
|
13347
|
+
const chosen = /* @__PURE__ */ new Map();
|
|
13348
|
+
if (!dryRun) {
|
|
13349
|
+
for (const source of declaredSources) {
|
|
13350
|
+
const provider = sourceProviders.get(source.id);
|
|
13351
|
+
if (!provider.inspectRelaySource || !relayWebhooks.has(source.id)) continue;
|
|
13352
|
+
try {
|
|
13353
|
+
if (!(await provider.inspectRelaySource({
|
|
13354
|
+
source: source.id,
|
|
13355
|
+
url: `https://${layout.relay.host}/${source.id}`,
|
|
13356
|
+
name: source.spec.name ?? source.id.charAt(0).toUpperCase() + source.id.slice(1),
|
|
13357
|
+
...source.spec.events ? { events: source.spec.events } : {},
|
|
13358
|
+
...source.spec.scope ? { scope: source.spec.scope } : {},
|
|
13359
|
+
...source.spec.options ? { options: source.spec.options } : {}
|
|
13360
|
+
})).exists) chosen.set(source.id, newRelaySecret());
|
|
13361
|
+
} catch {}
|
|
13362
|
+
}
|
|
13363
|
+
if (chosen.size > 0) {
|
|
13364
|
+
for (const [id, secret] of chosen) signingSecrets.set(id, secret);
|
|
13365
|
+
await attempt(`relay ${layout.relay.host} (before its webhooks)`, async () => {
|
|
13366
|
+
const deployed = await deployWorker(bindingsFor());
|
|
13367
|
+
print(` ${style.success(`deployed ${deployed.script} at ${deployed.host} for ${[...chosen.keys()].join(", ")}`)}`);
|
|
13368
|
+
tally.ok++;
|
|
13369
|
+
});
|
|
13370
|
+
}
|
|
13371
|
+
}
|
|
13326
13372
|
for (const source of declaredSources) {
|
|
13327
13373
|
const provider = sourceProviders.get(source.id);
|
|
13328
13374
|
await attempt(`${provider.providerName} relay source ${source.id}`, async () => {
|
|
13329
13375
|
const ensured = await ensureRelaySource(source, provider, {
|
|
13330
13376
|
host: layout.relay.host,
|
|
13331
|
-
newSecret: newRelaySecret
|
|
13377
|
+
newSecret: () => chosen.get(source.id) ?? newRelaySecret()
|
|
13332
13378
|
}, {
|
|
13333
13379
|
print,
|
|
13334
13380
|
made,
|
|
@@ -13350,26 +13396,10 @@ async function runNotificationsSetup(input$1) {
|
|
|
13350
13396
|
tally.skip++;
|
|
13351
13397
|
return;
|
|
13352
13398
|
}
|
|
13353
|
-
const
|
|
13354
|
-
const bindings = wanted.flatMap((source) => {
|
|
13355
|
-
const webhook = relayWebhooks.get(source);
|
|
13356
|
-
const signingSecret = signingSecrets.get(source);
|
|
13357
|
-
return webhook ? [{
|
|
13358
|
-
source,
|
|
13359
|
-
webhook,
|
|
13360
|
-
...signingSecret ? { signingSecret } : {}
|
|
13361
|
-
}] : [];
|
|
13362
|
-
});
|
|
13399
|
+
const bindings = bindingsFor();
|
|
13363
13400
|
const missing = wanted.filter((source) => !relayWebhooks.has(source));
|
|
13364
13401
|
if (bindings.length === 0) throw new Error("no relay webhook to give the Worker (its channel failed above)");
|
|
13365
|
-
const deployed = await
|
|
13366
|
-
relay: layout.relay,
|
|
13367
|
-
sources: bindings,
|
|
13368
|
-
repoRoot: input$1.context.repoRoot,
|
|
13369
|
-
workers,
|
|
13370
|
-
dns,
|
|
13371
|
-
...input$1.readRelayCode ? { readCode: input$1.readRelayCode } : {}
|
|
13372
|
-
});
|
|
13402
|
+
const deployed = await deployWorker(bindings);
|
|
13373
13403
|
print(` ${style.success(`deployed ${deployed.script} at ${deployed.host}`)}`);
|
|
13374
13404
|
tally.ok++;
|
|
13375
13405
|
if (missing.length > 0) throw new Error(`no relay webhook for ${missing.join(", ")} (its channel failed above), so the Worker has none`);
|