groundmail-cli 0.23.0 → 0.24.0
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 +27 -16
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -510,6 +510,7 @@ async function createAutomationsClient(apiKey, baseUrl) {
|
|
|
510
510
|
return new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
|
|
511
511
|
}
|
|
512
512
|
async function readAutomationDefinition(args) {
|
|
513
|
+
const folderFlag = readFlag9(args, "--folder");
|
|
513
514
|
const file = readFlag9(args, "--file");
|
|
514
515
|
if (file) {
|
|
515
516
|
try {
|
|
@@ -518,7 +519,8 @@ async function readAutomationDefinition(args) {
|
|
|
518
519
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
519
520
|
return { ok: false, error: "--file must contain a JSON object" };
|
|
520
521
|
}
|
|
521
|
-
|
|
522
|
+
const value = parsed;
|
|
523
|
+
return { ok: true, value: folderFlag !== void 0 ? { ...value, folder: folderFlag } : value };
|
|
522
524
|
} catch (error) {
|
|
523
525
|
return {
|
|
524
526
|
ok: false,
|
|
@@ -545,7 +547,8 @@ async function readAutomationDefinition(args) {
|
|
|
545
547
|
value: {
|
|
546
548
|
...name ? { name } : {},
|
|
547
549
|
...triggerEvent ? { trigger: { type: "event", event: triggerEvent } } : {},
|
|
548
|
-
...steps !== void 0 ? { steps } : {}
|
|
550
|
+
...steps !== void 0 ? { steps } : {},
|
|
551
|
+
...folderFlag !== void 0 ? { folder: folderFlag } : {}
|
|
549
552
|
}
|
|
550
553
|
};
|
|
551
554
|
}
|
|
@@ -595,7 +598,7 @@ async function runCreateCommand(args, env = process.env) {
|
|
|
595
598
|
}
|
|
596
599
|
const definition = await readAutomationDefinition(args);
|
|
597
600
|
if (!definition.ok) return { exitCode: 1, error: definition.error };
|
|
598
|
-
const { name, trigger, steps } = definition.value;
|
|
601
|
+
const { name, trigger, steps, folder } = definition.value;
|
|
599
602
|
if (!name || typeof name !== "string") {
|
|
600
603
|
return { exitCode: 1, error: "Required: --name or name in --file" };
|
|
601
604
|
}
|
|
@@ -610,7 +613,8 @@ async function runCreateCommand(args, env = process.env) {
|
|
|
610
613
|
const result = await client2.automations.create({
|
|
611
614
|
name,
|
|
612
615
|
trigger,
|
|
613
|
-
steps
|
|
616
|
+
steps,
|
|
617
|
+
...typeof folder === "string" && folder.trim() ? { folder } : {}
|
|
614
618
|
});
|
|
615
619
|
console.log(JSON.stringify(result));
|
|
616
620
|
return { exitCode: 0 };
|
|
@@ -630,11 +634,11 @@ async function runUpdateCommand(args, env = process.env) {
|
|
|
630
634
|
if (!id) return { exitCode: 1, error: "Required flag: --id" };
|
|
631
635
|
const definition = await readAutomationDefinition(args);
|
|
632
636
|
if (!definition.ok) return { exitCode: 1, error: definition.error };
|
|
633
|
-
const { name, trigger, steps } = definition.value;
|
|
634
|
-
if (!name && !trigger && !steps) {
|
|
637
|
+
const { name, trigger, steps, folder } = definition.value;
|
|
638
|
+
if (!name && !trigger && !steps && folder === void 0) {
|
|
635
639
|
return {
|
|
636
640
|
exitCode: 1,
|
|
637
|
-
error: "Nothing to update. Pass --file and/or --name/--trigger/--steps."
|
|
641
|
+
error: "Nothing to update. Pass --file and/or --name/--trigger/--steps/--folder."
|
|
638
642
|
};
|
|
639
643
|
}
|
|
640
644
|
try {
|
|
@@ -642,7 +646,8 @@ async function runUpdateCommand(args, env = process.env) {
|
|
|
642
646
|
const result = await client2.automations.update(id, {
|
|
643
647
|
...name ? { name } : {},
|
|
644
648
|
...trigger ? { trigger } : {},
|
|
645
|
-
...steps ? { steps } : {}
|
|
649
|
+
...steps ? { steps } : {},
|
|
650
|
+
...folder !== void 0 ? { folder } : {}
|
|
646
651
|
});
|
|
647
652
|
console.log(JSON.stringify(result));
|
|
648
653
|
return { exitCode: 0 };
|
|
@@ -1441,7 +1446,7 @@ function trimUrl(value) {
|
|
|
1441
1446
|
}
|
|
1442
1447
|
|
|
1443
1448
|
// package.json
|
|
1444
|
-
var version = "0.
|
|
1449
|
+
var version = "0.24.0";
|
|
1445
1450
|
|
|
1446
1451
|
// src/user-agent.ts
|
|
1447
1452
|
function buildUserAgent(own) {
|
|
@@ -2823,6 +2828,7 @@ async function runCreateCommand3(args, env = process.env) {
|
|
|
2823
2828
|
const text = readFlag20(args, "--text");
|
|
2824
2829
|
const alias = readFlag20(args, "--alias");
|
|
2825
2830
|
const category = readFlag20(args, "--category");
|
|
2831
|
+
const folder = readFlag20(args, "--folder");
|
|
2826
2832
|
const unsubscribeEnabled = args.includes("--unsubscribe-enabled");
|
|
2827
2833
|
if (!name) {
|
|
2828
2834
|
return { exitCode: 1, error: 'Missing name. Pass --name "Welcome"' };
|
|
@@ -2842,7 +2848,8 @@ async function runCreateCommand3(args, env = process.env) {
|
|
|
2842
2848
|
...text ? { text } : {},
|
|
2843
2849
|
...alias ? { alias } : {},
|
|
2844
2850
|
...category ? { category } : {},
|
|
2845
|
-
...unsubscribeEnabled ? { unsubscribe_enabled: true } : {}
|
|
2851
|
+
...unsubscribeEnabled ? { unsubscribe_enabled: true } : {},
|
|
2852
|
+
...folder?.trim() ? { folder } : {}
|
|
2846
2853
|
});
|
|
2847
2854
|
console.log(JSON.stringify(result));
|
|
2848
2855
|
return { exitCode: 0 };
|
|
@@ -2862,7 +2869,8 @@ var POSITIONAL_FLAGS11 = [
|
|
|
2862
2869
|
"--subject",
|
|
2863
2870
|
"--html",
|
|
2864
2871
|
"--text",
|
|
2865
|
-
"--variable"
|
|
2872
|
+
"--variable",
|
|
2873
|
+
"--folder"
|
|
2866
2874
|
];
|
|
2867
2875
|
async function runUpdateCommand4(args, env = process.env) {
|
|
2868
2876
|
const options = parseTemplatesCommonArgs(args);
|
|
@@ -2881,12 +2889,13 @@ async function runUpdateCommand4(args, env = process.env) {
|
|
|
2881
2889
|
const alias = readFlag20(args, "--set-alias");
|
|
2882
2890
|
const variables = readFlags3(args, "--variable");
|
|
2883
2891
|
const category = readFlag20(args, "--category");
|
|
2892
|
+
const folder = readFlag20(args, "--folder");
|
|
2884
2893
|
const unsubscribeEnabled = args.includes("--unsubscribe-enabled");
|
|
2885
2894
|
const unsubscribeDisabled = args.includes("--no-unsubscribe-enabled");
|
|
2886
|
-
if (!name && !subject && !html && !text && !alias && variables.length === 0 && !category && !unsubscribeEnabled && !unsubscribeDisabled) {
|
|
2895
|
+
if (!name && !subject && !html && !text && !alias && variables.length === 0 && !category && folder === void 0 && !unsubscribeEnabled && !unsubscribeDisabled) {
|
|
2887
2896
|
return {
|
|
2888
2897
|
exitCode: 1,
|
|
2889
|
-
error: "Nothing to update. Pass --name, --subject, --html, --text, --set-alias, --category, --variable, or unsubscribe flags."
|
|
2898
|
+
error: "Nothing to update. Pass --name, --subject, --html, --text, --set-alias, --category, --variable, --folder, or unsubscribe flags."
|
|
2890
2899
|
};
|
|
2891
2900
|
}
|
|
2892
2901
|
try {
|
|
@@ -2900,7 +2909,8 @@ async function runUpdateCommand4(args, env = process.env) {
|
|
|
2900
2909
|
...variables.length > 0 ? { variables } : {},
|
|
2901
2910
|
...category ? { category } : {},
|
|
2902
2911
|
...unsubscribeEnabled ? { unsubscribe_enabled: true } : {},
|
|
2903
|
-
...unsubscribeDisabled ? { unsubscribe_enabled: false } : {}
|
|
2912
|
+
...unsubscribeDisabled ? { unsubscribe_enabled: false } : {},
|
|
2913
|
+
...folder !== void 0 ? { folder } : {}
|
|
2904
2914
|
});
|
|
2905
2915
|
console.log(JSON.stringify(result));
|
|
2906
2916
|
return { exitCode: 0 };
|
|
@@ -3730,6 +3740,7 @@ var USAGE_LINES = [
|
|
|
3730
3740
|
" groundmail automations create --file ./otp-sms.json",
|
|
3731
3741
|
" groundmail automations get --id <automation-id>",
|
|
3732
3742
|
" groundmail automations update --id <automation-id> --file ./welcome.json",
|
|
3743
|
+
' groundmail automations update --id <automation-id> --folder Onboarding (--folder "" takes it out of any folder)',
|
|
3733
3744
|
" groundmail automations activate --id <automation-id>",
|
|
3734
3745
|
" groundmail automations pause --id <automation-id>",
|
|
3735
3746
|
" groundmail automations delete --id <automation-id>",
|
|
@@ -3745,9 +3756,9 @@ var USAGE_LINES = [
|
|
|
3745
3756
|
" groundmail templates list [--status draft|published]",
|
|
3746
3757
|
" groundmail templates starters",
|
|
3747
3758
|
" groundmail templates from-starter password-reset",
|
|
3748
|
-
' groundmail templates create --name Welcome --subject "Hi" --html "<p>Hi</p>" [--category transactional|product] [--unsubscribe-enabled]',
|
|
3759
|
+
' groundmail templates create --name Welcome --subject "Hi" --html "<p>Hi</p>" [--category transactional|product] [--unsubscribe-enabled] [--folder Onboarding]',
|
|
3749
3760
|
" groundmail templates get --id tpl_\u2026",
|
|
3750
|
-
" groundmail templates update --id tpl_\u2026 [--name \u2026] [--subject \u2026] [--html \u2026] [--text \u2026] [--set-alias \u2026] [--category transactional|product] [--unsubscribe-enabled|--no-unsubscribe-enabled]",
|
|
3761
|
+
" groundmail templates update --id tpl_\u2026 [--name \u2026] [--subject \u2026] [--html \u2026] [--text \u2026] [--set-alias \u2026] [--category transactional|product] [--unsubscribe-enabled|--no-unsubscribe-enabled] [--folder \u2026]",
|
|
3751
3762
|
" groundmail templates publish --id tpl_\u2026",
|
|
3752
3763
|
` groundmail templates push ./emails/welcome.tsx --alias welcome [--subject "Welcome"] [--props '{"name":"Ada"}'] [--publish]`,
|
|
3753
3764
|
" groundmail templates versions --id tpl_\u2026",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "groundmail-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Groundmail CLI — send transactional email from the terminal",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"prepublishOnly": "npm run build"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"groundmail": "0.
|
|
41
|
+
"groundmail": "0.21.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsup": "^8.5.0",
|