@theholocron/cli 5.0.0-alpha.222 → 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 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 <PAT>, set ${config.envName}, or run: holocron auth set ${config.keyringKey} <PAT>`);
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: { [relayWebhookBinding(input.source)]: input.webhook },
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,