@wraps.dev/cli 3.17.1 → 3.17.2

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
@@ -22265,6 +22265,12 @@ Saved regions: ${savedRegions.join(", ")}` : "Pass --region or set AWS_REGION.\n
22265
22265
  `Usage: ${usage}`,
22266
22266
  "https://wraps.dev/docs/cli-reference"
22267
22267
  ),
22268
+ invalidFlagUsage: (message, suggestion) => new WrapsError(
22269
+ message,
22270
+ "INVALID_FLAG_USAGE",
22271
+ suggestion,
22272
+ "https://wraps.dev/docs/cli-reference"
22273
+ ),
22268
22274
  pulumiError: (message) => new WrapsError(
22269
22275
  `Infrastructure deployment failed: ${message}`,
22270
22276
  "PULUMI_ERROR",
@@ -47259,7 +47265,8 @@ function parseCliArgs(argv) {
47259
47265
  }
47260
47266
  return {
47261
47267
  flags: flags2,
47262
- sub: parsed._
47268
+ sub: parsed._,
47269
+ extraPositionals: parsed._.slice(4)
47263
47270
  };
47264
47271
  }
47265
47272
 
@@ -50210,7 +50217,22 @@ function reportInboundDNSCleanup(result, domain) {
50210
50217
  console.log();
50211
50218
  }
50212
50219
  }
50220
+ function assertValidInboundFlags(options) {
50221
+ if (options.unexpectedArg) {
50222
+ throw errors.invalidFlagUsage(
50223
+ `Unexpected argument: ${options.unexpectedArg}`,
50224
+ `--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).`
50225
+ );
50226
+ }
50227
+ if (options.root && options.subdomain) {
50228
+ throw errors.invalidFlagUsage(
50229
+ "--root and --subdomain cannot be used together",
50230
+ "--root receives mail on the parent domain itself; --subdomain <label> receives mail on <label>.<parent>. Pick one."
50231
+ );
50232
+ }
50233
+ }
50213
50234
  async function inboundInit(options) {
50235
+ assertValidInboundFlags(options);
50214
50236
  if (!isJsonMode()) {
50215
50237
  clack27.intro(
50216
50238
  pc28.bold(
@@ -51116,6 +51138,7 @@ Enable it: ${pc28.cyan("wraps email inbound init")}
51116
51138
  console.log();
51117
51139
  }
51118
51140
  async function inboundAdd(options) {
51141
+ assertValidInboundFlags(options);
51119
51142
  if (!isJsonMode()) {
51120
51143
  clack27.intro(pc28.bold("Add Inbound Receiving Domain"));
51121
51144
  }
@@ -55872,6 +55895,30 @@ import { join as join19 } from "path";
55872
55895
  import * as clack41 from "@clack/prompts";
55873
55896
  import pc42 from "picocolors";
55874
55897
 
55898
+ // src/utils/email/template-push-state.ts
55899
+ init_esm_shims();
55900
+ function isTemplateUnchanged(input) {
55901
+ const { entry, sourceHash, existsRemotely, dashboardConfigured, force } = input;
55902
+ if (force || !entry || entry.localHash !== sourceHash || !existsRemotely) {
55903
+ return false;
55904
+ }
55905
+ return !dashboardConfigured || entry.remoteHash === sourceHash;
55906
+ }
55907
+ function nextTemplateEntry(input) {
55908
+ const { previous, sourceHash, sesTemplateName, sesOk, apiResult, now } = input;
55909
+ const apiOk = apiResult?.success === true;
55910
+ if (!(sesOk || apiOk)) {
55911
+ return;
55912
+ }
55913
+ return {
55914
+ id: apiOk ? apiResult?.id : previous?.id,
55915
+ localHash: sourceHash,
55916
+ remoteHash: apiOk ? sourceHash : previous?.remoteHash,
55917
+ sesTemplateName,
55918
+ lastPushed: now
55919
+ };
55920
+ }
55921
+
55875
55922
  // src/utils/email/template-render.ts
55876
55923
  init_esm_shims();
55877
55924
  async function renderTemplateWithProxy(Component) {
@@ -56073,14 +56120,20 @@ async function templatesPush(options) {
56073
56120
  const compiled = [];
56074
56121
  const unchanged = [];
56075
56122
  const compileErrors = [];
56123
+ const dashboardConfigured = checkApiTarget(target).ok;
56076
56124
  for (const file of templateFiles) {
56077
56125
  const slug = file.replace(/\.tsx?$/, "");
56078
56126
  const filePath = join19(templatesDir, file);
56079
56127
  const source = await readFile8(filePath, "utf-8");
56080
56128
  const sourceHash = sha256(source);
56081
- const localHashMatches = lockfile.templates[slug]?.localHash === sourceHash;
56082
56129
  const existsRemotely = remoteTemplateSlugs === null || remoteTemplateSlugs.has(slug);
56083
- if (!options.force && localHashMatches && existsRemotely) {
56130
+ if (isTemplateUnchanged({
56131
+ entry: lockfile.templates[slug],
56132
+ sourceHash,
56133
+ existsRemotely,
56134
+ dashboardConfigured,
56135
+ force: options.force === true
56136
+ })) {
56084
56137
  unchanged.push(slug);
56085
56138
  continue;
56086
56139
  }
@@ -56154,17 +56207,16 @@ async function templatesPush(options) {
56154
56207
  const sesSucceeded = compiled.filter((t) => !sesFailed.has(t.slug));
56155
56208
  const apiResults = sesSucceeded.length > 0 ? await pushToAPI(sesSucceeded, target, progress, options.force, org?.id) : [];
56156
56209
  for (const t of compiled) {
56157
- const sesOk = sesResults.find((r6) => r6.slug === t.slug)?.success;
56158
- const apiResult = apiResults.find((r6) => r6.slug === t.slug);
56159
- const apiOk = apiResult?.success;
56160
- if (sesOk || apiOk) {
56161
- lockfile.templates[t.slug] = {
56162
- id: apiResult?.id,
56163
- localHash: t.sourceHash,
56164
- remoteHash: t.sourceHash,
56165
- sesTemplateName: t.sesTemplateName,
56166
- lastPushed: (/* @__PURE__ */ new Date()).toISOString()
56167
- };
56210
+ const entry = nextTemplateEntry({
56211
+ previous: lockfile.templates[t.slug],
56212
+ sourceHash: t.sourceHash,
56213
+ sesTemplateName: t.sesTemplateName,
56214
+ sesOk: sesResults.find((r6) => r6.slug === t.slug)?.success === true,
56215
+ apiResult: apiResults.find((r6) => r6.slug === t.slug),
56216
+ now: (/* @__PURE__ */ new Date()).toISOString()
56217
+ });
56218
+ if (entry) {
56219
+ lockfile.templates[t.slug] = entry;
56168
56220
  }
56169
56221
  }
56170
56222
  lockfile.lastSync = (/* @__PURE__ */ new Date()).toISOString();
@@ -71942,7 +71994,7 @@ if (process.argv.includes("--help") || process.argv.includes("-h")) {
71942
71994
  }
71943
71995
  var parsedCli = parseCliArgs(process.argv);
71944
71996
  var flags = parsedCli.flags;
71945
- var { sub } = parsedCli;
71997
+ var { sub, extraPositionals } = parsedCli;
71946
71998
  var [primaryCommand, subCommand] = sub;
71947
71999
  setJsonMode(flags.json === true);
71948
72000
  if (!primaryCommand) {
@@ -72126,6 +72178,12 @@ async function run() {
72126
72178
  telemetry.markNotificationShown();
72127
72179
  }
72128
72180
  try {
72181
+ if (extraPositionals.length > 0) {
72182
+ throw errors.invalidFlagUsage(
72183
+ `Unrecognized argument${extraPositionals.length > 1 ? "s" : ""}: ${extraPositionals.join(" ")}`,
72184
+ "A boolean flag (such as --root or --json) takes no value, so a value after it is discarded. Check the flags before these arguments, or run the command with --help."
72185
+ );
72186
+ }
72129
72187
  if (primaryCommand === "email" && subCommand) {
72130
72188
  switch (subCommand) {
72131
72189
  case "init":
@@ -72263,7 +72321,8 @@ async function run() {
72263
72321
  root: flags.root,
72264
72322
  yes: flags.yes,
72265
72323
  preview: flags.preview,
72266
- json: flags.json
72324
+ json: flags.json,
72325
+ unexpectedArg: sub[3]
72267
72326
  });
72268
72327
  break;
72269
72328
  case "destroy":
@@ -72300,7 +72359,8 @@ async function run() {
72300
72359
  root: flags.root,
72301
72360
  domain: flags.domain,
72302
72361
  yes: flags.yes,
72303
- json: flags.json
72362
+ json: flags.json,
72363
+ unexpectedArg: sub[3]
72304
72364
  });
72305
72365
  break;
72306
72366
  case "remove":