@theholocron/cli 5.0.0-alpha.512 → 5.0.0-alpha.513

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 CHANGED
@@ -13321,14 +13321,57 @@ async function runNotificationsSetup(input$1) {
13321
13321
  print(` ${(changed ? style.success : style.skip)(`${verb} ${errors.providerName} ${what} ${name}${detail}`)}`);
13322
13322
  made(changed);
13323
13323
  }
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 Doppler as COMLINK_${errors.providerName.toUpperCase()}_SECRET and run holocron sync secrets --env prod`)}`);
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 the vault as COMLINK_${errors.providerName.toUpperCase()}_SECRET and run holocron sync secrets --env prod`)}`);
13325
13325
  });
13326
+ const wanted = [...errors ? [errors.providerName] : [], ...declaredSources.map((d) => d.id)];
13327
+ const bindingsFor = () => wanted.flatMap((source) => {
13328
+ const webhook = relayWebhooks.get(source);
13329
+ const signingSecret = signingSecrets.get(source);
13330
+ return webhook ? [{
13331
+ source,
13332
+ webhook,
13333
+ ...signingSecret ? { signingSecret } : {}
13334
+ }] : [];
13335
+ });
13336
+ const deployWorker = (bindings) => deployRelay({
13337
+ relay: layout.relay,
13338
+ sources: bindings,
13339
+ repoRoot: input$1.context.repoRoot,
13340
+ workers,
13341
+ dns,
13342
+ ...input$1.readRelayCode ? { readCode: input$1.readRelayCode } : {}
13343
+ });
13344
+ const chosen = /* @__PURE__ */ new Map();
13345
+ if (!dryRun) {
13346
+ for (const source of declaredSources) {
13347
+ const provider = sourceProviders.get(source.id);
13348
+ if (!provider.inspectRelaySource || !relayWebhooks.has(source.id)) continue;
13349
+ try {
13350
+ if (!(await provider.inspectRelaySource({
13351
+ source: source.id,
13352
+ url: `https://${layout.relay.host}/${source.id}`,
13353
+ name: source.spec.name ?? source.id.charAt(0).toUpperCase() + source.id.slice(1),
13354
+ ...source.spec.events ? { events: source.spec.events } : {},
13355
+ ...source.spec.scope ? { scope: source.spec.scope } : {},
13356
+ ...source.spec.options ? { options: source.spec.options } : {}
13357
+ })).exists) chosen.set(source.id, newRelaySecret());
13358
+ } catch {}
13359
+ }
13360
+ if (chosen.size > 0) {
13361
+ for (const [id, secret] of chosen) signingSecrets.set(id, secret);
13362
+ await attempt(`relay ${layout.relay.host} (before its webhooks)`, async () => {
13363
+ const deployed = await deployWorker(bindingsFor());
13364
+ print(` ${style.success(`deployed ${deployed.script} at ${deployed.host} for ${[...chosen.keys()].join(", ")}`)}`);
13365
+ tally.ok++;
13366
+ });
13367
+ }
13368
+ }
13326
13369
  for (const source of declaredSources) {
13327
13370
  const provider = sourceProviders.get(source.id);
13328
13371
  await attempt(`${provider.providerName} relay source ${source.id}`, async () => {
13329
13372
  const ensured = await ensureRelaySource(source, provider, {
13330
13373
  host: layout.relay.host,
13331
- newSecret: newRelaySecret
13374
+ newSecret: () => chosen.get(source.id) ?? newRelaySecret()
13332
13375
  }, {
13333
13376
  print,
13334
13377
  made,
@@ -13350,26 +13393,10 @@ async function runNotificationsSetup(input$1) {
13350
13393
  tally.skip++;
13351
13394
  return;
13352
13395
  }
13353
- const wanted = [...errors ? [errors.providerName] : [], ...declaredSources.map((d) => d.id)];
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
- });
13396
+ const bindings = bindingsFor();
13363
13397
  const missing = wanted.filter((source) => !relayWebhooks.has(source));
13364
13398
  if (bindings.length === 0) throw new Error("no relay webhook to give the Worker (its channel failed above)");
13365
- const deployed = await deployRelay({
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
- });
13399
+ const deployed = await deployWorker(bindings);
13373
13400
  print(` ${style.success(`deployed ${deployed.script} at ${deployed.host}`)}`);
13374
13401
  tally.ok++;
13375
13402
  if (missing.length > 0) throw new Error(`no relay webhook for ${missing.join(", ")} (its channel failed above), so the Worker has none`);