@wraps.dev/cli 2.17.11 → 2.17.12
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
|
@@ -23498,47 +23498,66 @@ async function pushToSES(templates, progress) {
|
|
|
23498
23498
|
UpdateTemplateCommand
|
|
23499
23499
|
} = await import("@aws-sdk/client-ses");
|
|
23500
23500
|
const ses = new SESClient6({ region });
|
|
23501
|
-
|
|
23502
|
-
|
|
23503
|
-
|
|
23504
|
-
|
|
23505
|
-
|
|
23506
|
-
|
|
23507
|
-
|
|
23508
|
-
|
|
23509
|
-
|
|
23510
|
-
|
|
23511
|
-
|
|
23512
|
-
|
|
23513
|
-
|
|
23514
|
-
|
|
23515
|
-
|
|
23516
|
-
|
|
23517
|
-
|
|
23518
|
-
|
|
23519
|
-
|
|
23501
|
+
try {
|
|
23502
|
+
progress.start(
|
|
23503
|
+
`Pushing ${templates.length} template${templates.length === 1 ? "" : "s"} to SES`
|
|
23504
|
+
);
|
|
23505
|
+
const settled = await Promise.allSettled(
|
|
23506
|
+
templates.map(async (t) => {
|
|
23507
|
+
const templateData = {
|
|
23508
|
+
TemplateName: t.sesTemplateName,
|
|
23509
|
+
SubjectPart: t.subject,
|
|
23510
|
+
HtmlPart: t.compiledHtml,
|
|
23511
|
+
TextPart: t.compiledText
|
|
23512
|
+
};
|
|
23513
|
+
let exists = false;
|
|
23514
|
+
try {
|
|
23515
|
+
await ses.send(
|
|
23516
|
+
new GetTemplateCommand({ TemplateName: t.sesTemplateName })
|
|
23517
|
+
);
|
|
23518
|
+
exists = true;
|
|
23519
|
+
} catch (err) {
|
|
23520
|
+
const e = err;
|
|
23521
|
+
if (e.name !== "TemplateDoesNotExistException") {
|
|
23522
|
+
throw err;
|
|
23523
|
+
}
|
|
23520
23524
|
}
|
|
23521
|
-
|
|
23522
|
-
|
|
23523
|
-
|
|
23525
|
+
if (exists) {
|
|
23526
|
+
await ses.send(new UpdateTemplateCommand({ Template: templateData }));
|
|
23527
|
+
} else {
|
|
23528
|
+
await ses.send(new CreateTemplateCommand({ Template: templateData }));
|
|
23529
|
+
}
|
|
23530
|
+
return { slug: t.slug };
|
|
23531
|
+
})
|
|
23532
|
+
);
|
|
23533
|
+
const failures = [];
|
|
23534
|
+
for (let i = 0; i < templates.length; i++) {
|
|
23535
|
+
const result = settled[i];
|
|
23536
|
+
if (result.status === "fulfilled") {
|
|
23537
|
+
results.push({ slug: result.value.slug, success: true });
|
|
23524
23538
|
} else {
|
|
23525
|
-
|
|
23539
|
+
const msg = result.reason instanceof Error ? result.reason.message : String(result.reason);
|
|
23540
|
+
results.push({ slug: templates[i].slug, success: false });
|
|
23541
|
+
failures.push(`${templates[i].slug}: ${msg}`);
|
|
23526
23542
|
}
|
|
23527
|
-
|
|
23528
|
-
|
|
23529
|
-
|
|
23530
|
-
|
|
23531
|
-
|
|
23532
|
-
|
|
23533
|
-
if (result.status === "fulfilled") {
|
|
23534
|
-
results.push({ slug: result.value.slug, success: true });
|
|
23543
|
+
}
|
|
23544
|
+
const successCount = results.filter((r) => r.success).length;
|
|
23545
|
+
if (failures.length === 0) {
|
|
23546
|
+
progress.succeed(
|
|
23547
|
+
`Pushed ${successCount} template${successCount === 1 ? "" : "s"} to SES`
|
|
23548
|
+
);
|
|
23535
23549
|
} else {
|
|
23536
|
-
|
|
23537
|
-
|
|
23538
|
-
|
|
23550
|
+
progress.succeed(
|
|
23551
|
+
`Pushed ${successCount}/${templates.length} templates to SES`
|
|
23552
|
+
);
|
|
23553
|
+
for (const f of failures) {
|
|
23554
|
+
progress.fail(`SES push failed: ${f}`);
|
|
23555
|
+
}
|
|
23539
23556
|
}
|
|
23557
|
+
return results;
|
|
23558
|
+
} finally {
|
|
23559
|
+
ses.destroy();
|
|
23540
23560
|
}
|
|
23541
|
-
return results;
|
|
23542
23561
|
}
|
|
23543
23562
|
async function fetchRemoteTemplateSlugs(token, progress) {
|
|
23544
23563
|
if (!token) {
|
|
@@ -23637,8 +23656,9 @@ async function pushToAPI(templates, token, progress, force) {
|
|
|
23637
23656
|
throw new Error(`API returned ${resp.status}: ${body}`);
|
|
23638
23657
|
}
|
|
23639
23658
|
} catch (err) {
|
|
23659
|
+
const cause = err instanceof Error && err.cause instanceof Error ? `: ${err.cause.message}` : "";
|
|
23640
23660
|
const msg = err instanceof Error ? err.message : String(err);
|
|
23641
|
-
progress.fail(`Dashboard sync failed: ${msg}`);
|
|
23661
|
+
progress.fail(`Dashboard sync failed: ${msg}${cause}`);
|
|
23642
23662
|
for (const t of templates) {
|
|
23643
23663
|
results.push({ slug: t.slug, success: false });
|
|
23644
23664
|
}
|
|
@@ -23682,9 +23702,10 @@ async function pushToAPI(templates, token, progress, force) {
|
|
|
23682
23702
|
throw new Error(`API returned ${resp.status}: ${body}`);
|
|
23683
23703
|
}
|
|
23684
23704
|
} catch (err) {
|
|
23705
|
+
const cause = err instanceof Error && err.cause instanceof Error ? `: ${err.cause.message}` : "";
|
|
23685
23706
|
const msg = err instanceof Error ? err.message : String(err);
|
|
23686
23707
|
results.push({ slug: t.slug, success: false });
|
|
23687
|
-
progress.fail(`Dashboard sync failed for ${t.slug}: ${msg}`);
|
|
23708
|
+
progress.fail(`Dashboard sync failed for ${t.slug}: ${msg}${cause}`);
|
|
23688
23709
|
}
|
|
23689
23710
|
}
|
|
23690
23711
|
return results;
|