@wraps.dev/cli 3.17.4 → 3.17.5

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.js CHANGED
@@ -51330,7 +51330,7 @@ function assertValidInboundFlags(options) {
51330
51330
  if (options.unexpectedArg) {
51331
51331
  throw errors.invalidFlagUsage(
51332
51332
  `Unexpected argument: ${options.unexpectedArg}`,
51333
- `--root takes no value: "--root ${options.unexpectedArg}" (or "--root=${options.unexpectedArg}") sets --root and discards "${options.unexpectedArg}". To name the parent domain use --domain (inbound add); to pick the label use --subdomain <label> (inbound add) or --domain <label> (inbound init).`
51333
+ `--root takes no value: "--root ${options.unexpectedArg}" (or "--root=${options.unexpectedArg}") sets --root and discards "${options.unexpectedArg}". To name the parent domain use --domain <domain>; to pick the label use --subdomain <label>.`
51334
51334
  );
51335
51335
  }
51336
51336
  if (options.root && options.subdomain) {
@@ -51340,7 +51340,11 @@ function assertValidInboundFlags(options) {
51340
51340
  );
51341
51341
  }
51342
51342
  }
51343
- async function inboundInit(options) {
51343
+ async function inboundInit(rawOptions) {
51344
+ const legacyLabel = Boolean(
51345
+ rawOptions.domain && !rawOptions.domain.includes(".") && !rawOptions.subdomain && !rawOptions.root
51346
+ );
51347
+ const options = legacyLabel ? { ...rawOptions, domain: void 0, subdomain: rawOptions.domain } : rawOptions;
51344
51348
  assertValidInboundFlags(options);
51345
51349
  if (!isJsonMode()) {
51346
51350
  clack27.intro(
@@ -51373,7 +51377,15 @@ async function inboundInit(options) {
51373
51377
  throw errors.inboundRequiresOutbound();
51374
51378
  }
51375
51379
  let domain;
51376
- if (trackedDomains.length === 1) {
51380
+ if (options.domain) {
51381
+ if (!trackedDomains.some((d6) => d6.domain === options.domain)) {
51382
+ throw errors.invalidFlagUsage(
51383
+ `--domain ${options.domain} is not a domain Wraps tracks for email`,
51384
+ `Tracked domains: ${trackedDomains.map((d6) => d6.domain).join(", ")}. --domain names the parent domain; use --subdomain <label> for the label (--subdomain support under example.com receives on support.example.com).`
51385
+ );
51386
+ }
51387
+ domain = options.domain;
51388
+ } else if (trackedDomains.length === 1) {
51377
51389
  domain = trackedDomains[0].domain;
51378
51390
  } else if (options.yes || isJsonMode()) {
51379
51391
  const primaryTrackedDomain = trackedDomains.find((trackedDomain) => trackedDomain.isPrimary) || trackedDomains[0];
@@ -51399,6 +51411,11 @@ async function inboundInit(options) {
51399
51411
  const subdomain = options.root ? "" : options.subdomain ?? (options.yes ? "inbound" : await promptInboundSubdomain(domain));
51400
51412
  const receivingDomain = subdomain ? `${subdomain}.${domain}` : domain;
51401
51413
  clack27.log.info(`Receiving domain: ${pc28.cyan(receivingDomain)}`);
51414
+ if (legacyLabel) {
51415
+ clack27.log.warn(
51416
+ `--domain ${pc28.cyan(rawOptions.domain)} was read as the subdomain label, as in earlier versions. Use ${pc28.cyan(`--subdomain ${rawOptions.domain}`)}; --domain now names the parent domain.`
51417
+ );
51418
+ }
51402
51419
  const webhookUrl = options.webhookUrl || (options.yes ? void 0 : await promptWebhookUrl());
51403
51420
  const webhookSecret = randomBytes4(32).toString("hex");
51404
51421
  clack27.log.info(
@@ -51446,7 +51463,7 @@ async function inboundInit(options) {
51446
51463
  const stackConfig = buildEmailStackConfig(metadata, region, {
51447
51464
  emailConfig: updatedEmailConfig
51448
51465
  });
51449
- await progress.execute("Deploying inbound email infrastructure", async () => {
51466
+ const createStack = async () => {
51450
51467
  const stack = await pulumi21.automation.LocalWorkspace.createOrSelectStack(
51451
51468
  {
51452
51469
  stackName,
@@ -51461,6 +51478,26 @@ async function inboundInit(options) {
51461
51478
  }
51462
51479
  );
51463
51480
  await stack.setConfig("aws:region", { value: region });
51481
+ return stack;
51482
+ };
51483
+ if (options.preview) {
51484
+ const previewResult = await progress.execute(
51485
+ "Generating infrastructure preview",
51486
+ async () => previewWithResourceChanges(await createStack(), { diff: true })
51487
+ );
51488
+ displayPreview({
51489
+ changeSummary: previewResult.changeSummary,
51490
+ resourceChanges: previewResult.resourceChanges,
51491
+ commandName: "wraps email inbound init"
51492
+ });
51493
+ clack27.log.info(
51494
+ `Not covered by the preview: the SES receipt rule for ${pc28.cyan(receivingDomain)} and its DNS records.`
51495
+ );
51496
+ clack27.outro(pc28.green("Preview complete. Run without --preview to deploy."));
51497
+ return;
51498
+ }
51499
+ await progress.execute("Deploying inbound email infrastructure", async () => {
51500
+ const stack = await createStack();
51464
51501
  const pulumiOutput = [];
51465
51502
  await withLockRetry(
51466
51503
  () => withTimeout(
@@ -73509,8 +73546,8 @@ async function run() {
73509
73546
  case "init":
73510
73547
  await inboundInit({
73511
73548
  region: flags.region,
73512
- subdomain: flags.domain,
73513
- // reuse --domain flag for subdomain
73549
+ domain: flags.domain,
73550
+ subdomain: flags.subdomain,
73514
73551
  root: flags.root,
73515
73552
  yes: flags.yes,
73516
73553
  preview: flags.preview,