@wraps.dev/cli 2.17.20 → 2.17.21

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
@@ -23755,7 +23755,11 @@ async function templatesPush(options) {
23755
23755
  return;
23756
23756
  }
23757
23757
  const sesResults = await pushToSES(compiled, progress);
23758
- const apiResults = await pushToAPI(compiled, token, progress, options.force);
23758
+ const sesFailed = new Set(
23759
+ sesResults.filter((r) => !r.success).map((r) => r.slug)
23760
+ );
23761
+ const sesSucceeded = compiled.filter((t) => !sesFailed.has(t.slug));
23762
+ const apiResults = sesSucceeded.length > 0 ? await pushToAPI(sesSucceeded, token, progress, options.force) : [];
23759
23763
  for (const t of compiled) {
23760
23764
  const sesOk = sesResults.find((r) => r.slug === t.slug)?.success;
23761
23765
  const apiResult = apiResults.find((r) => r.slug === t.slug);
@@ -23961,41 +23965,42 @@ async function pushToSES(templates, progress) {
23961
23965
  return templates.map((t) => ({ slug: t.slug, success: false }));
23962
23966
  }
23963
23967
  const {
23964
- SESClient: SESClient7,
23965
- GetTemplateCommand,
23966
- CreateTemplateCommand,
23967
- UpdateTemplateCommand
23968
- } = await import("@aws-sdk/client-ses");
23969
- const ses = new SESClient7({ region });
23968
+ SESv2Client: SESv2Client9,
23969
+ CreateEmailTemplateCommand,
23970
+ UpdateEmailTemplateCommand
23971
+ } = await import("@aws-sdk/client-sesv2");
23972
+ const ses = new SESv2Client9({ region });
23970
23973
  try {
23971
23974
  progress.start(
23972
23975
  `Pushing ${templates.length} template${templates.length === 1 ? "" : "s"} to SES`
23973
23976
  );
23974
23977
  const settled = await Promise.allSettled(
23975
23978
  templates.map(async (t) => {
23976
- const templateData = {
23977
- TemplateName: t.sesTemplateName,
23978
- SubjectPart: t.subject,
23979
- HtmlPart: t.compiledHtml,
23980
- TextPart: t.compiledText
23979
+ const templateContent = {
23980
+ Subject: t.subject,
23981
+ Html: t.compiledHtml,
23982
+ Text: t.compiledText
23981
23983
  };
23982
- let exists = false;
23983
23984
  try {
23984
23985
  await ses.send(
23985
- new GetTemplateCommand({ TemplateName: t.sesTemplateName })
23986
+ new CreateEmailTemplateCommand({
23987
+ TemplateName: t.sesTemplateName,
23988
+ TemplateContent: templateContent
23989
+ })
23986
23990
  );
23987
- exists = true;
23988
23991
  } catch (err) {
23989
23992
  const e = err;
23990
- if (e.name !== "TemplateDoesNotExistException") {
23993
+ if (e.name === "AlreadyExistsException") {
23994
+ await ses.send(
23995
+ new UpdateEmailTemplateCommand({
23996
+ TemplateName: t.sesTemplateName,
23997
+ TemplateContent: templateContent
23998
+ })
23999
+ );
24000
+ } else {
23991
24001
  throw err;
23992
24002
  }
23993
24003
  }
23994
- if (exists) {
23995
- await ses.send(new UpdateTemplateCommand({ Template: templateData }));
23996
- } else {
23997
- await ses.send(new CreateTemplateCommand({ Template: templateData }));
23998
- }
23999
24004
  return { slug: t.slug };
24000
24005
  })
24001
24006
  );