groundmail-cli 0.31.0 → 0.32.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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +68 -22
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -75,7 +75,7 @@ groundmail domains list
75
75
  groundmail domains verify example.com
76
76
  groundmail webhooks list
77
77
  groundmail emails list
78
- SENDGRID_API_KEY=… groundmail migrate sendgrid --dry-run # import from SendGrid, Postmark or Mailgun (beta)
78
+ SENDGRID_API_KEY=… groundmail migrate sendgrid --dry-run # import from SendGrid, Postmark, Mailgun, Resend or Amazon SES (beta)
79
79
  ```
80
80
 
81
81
  Run `groundmail --help` or `groundmail <command> --help` for flags.
package/dist/cli.js CHANGED
@@ -2051,7 +2051,7 @@ function trimUrl(value) {
2051
2051
  }
2052
2052
 
2053
2053
  // package.json
2054
- var version = "0.31.0";
2054
+ var version = "0.32.0";
2055
2055
 
2056
2056
  // src/user-agent.ts
2057
2057
  function buildUserAgent(own) {
@@ -4062,14 +4062,43 @@ async function switchWorkspace(argv, deps) {
4062
4062
  }
4063
4063
 
4064
4064
  // src/commands/migrate.ts
4065
- var PROVIDERS2 = ["sendgrid", "postmark", "mailgun"];
4065
+ var PROVIDERS2 = ["sendgrid", "postmark", "mailgun", "resend", "ses"];
4066
4066
  var RESOURCES = ["domains", "webhooks", "templates", "suppressions"];
4067
4067
  var KEY_ENV = {
4068
4068
  sendgrid: "SENDGRID_API_KEY",
4069
4069
  postmark: "POSTMARK_SERVER_TOKEN",
4070
- mailgun: "MAILGUN_API_KEY"
4070
+ mailgun: "MAILGUN_API_KEY",
4071
+ resend: "RESEND_API_KEY"
4071
4072
  };
4072
- var LABELS = { sendgrid: "SendGrid", postmark: "Postmark", mailgun: "Mailgun" };
4073
+ var LABELS = {
4074
+ sendgrid: "SendGrid",
4075
+ postmark: "Postmark",
4076
+ mailgun: "Mailgun",
4077
+ resend: "Resend",
4078
+ ses: "Amazon SES"
4079
+ };
4080
+ var AWS_REGION = /^[a-z]{2}(?:-gov)?-[a-z]+-\d{1,2}$/;
4081
+ function sesParams(args, env) {
4082
+ const accessKeyId = env.AWS_ACCESS_KEY_ID;
4083
+ const secret = env.AWS_SECRET_ACCESS_KEY;
4084
+ if (!accessKeyId || !secret) {
4085
+ return [
4086
+ "Missing AWS credentials. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (plus AWS_SESSION_TOKEN for temporary credentials),",
4087
+ 'or load them from your AWS CLI profile: eval "$(aws configure export-credentials --format env)".',
4088
+ "Use a key with the read-only import policy (https://docs.groundmail.dev/migrations#amazon-ses-iam-policy). It is used for this import only and never stored."
4089
+ ].join("\n");
4090
+ }
4091
+ const region = readFlag22(args, "--region") || env.AWS_REGION || env.AWS_DEFAULT_REGION;
4092
+ if (!region) return "Set the SES region with --region (for example --region us-east-1) or AWS_REGION. One region per import.";
4093
+ if (!AWS_REGION.test(region)) return `--region must be an AWS region such as us-east-1, not ${region}`;
4094
+ return {
4095
+ provider: "ses",
4096
+ aws_access_key_id: accessKeyId,
4097
+ aws_secret_access_key: secret,
4098
+ ...env.AWS_SESSION_TOKEN ? { aws_session_token: env.AWS_SESSION_TOKEN } : {},
4099
+ aws_region: region
4100
+ };
4101
+ }
4073
4102
  var VALUE_FLAGS3 = /* @__PURE__ */ new Set(["--api-key", "--base-url"]);
4074
4103
  function readFlag22(args, flag) {
4075
4104
  const index = args.indexOf(flag);
@@ -4088,7 +4117,9 @@ function formatMigrationSummary(m) {
4088
4117
  lines.push(` Domains ${n(m.domains.totals.imported)} of ${n(m.domains.totals.found)}`);
4089
4118
  }
4090
4119
  if (m.webhooks) {
4091
- lines.push(` Webhooks ${n(m.webhooks.totals.imported)} of ${n(m.webhooks.totals.found)} (created disabled)`);
4120
+ lines.push(
4121
+ m.provider === "ses" ? " Webhooks reported, not imported (SES has no webhooks; see the notes)" : ` Webhooks ${n(m.webhooks.totals.imported)} of ${n(m.webhooks.totals.found)} (created disabled)`
4122
+ );
4092
4123
  }
4093
4124
  if (m.templates) {
4094
4125
  const t = m.templates.totals;
@@ -4133,6 +4164,10 @@ function formatMigrationSummary(m) {
4133
4164
  lines.push("", "Next:");
4134
4165
  for (const line of m.attention) lines.push(` - ${line}`);
4135
4166
  }
4167
+ if (m.notes.length) {
4168
+ lines.push("", "Notes:");
4169
+ for (const line of m.notes) lines.push(` - ${line}`);
4170
+ }
4136
4171
  const node = m.code_changes?.find((c) => c.stack === "node");
4137
4172
  if (node) lines.push("", "Code change (Node.js):", node.diff);
4138
4173
  if (m.agent_prompt) lines.push("", "Prompt for your coding agent is in the JSON report (`agent_prompt`).");
@@ -4176,7 +4211,7 @@ async function runMigrateCommand(provider, args, env = process.env) {
4176
4211
  if (!provider || !PROVIDERS2.includes(provider)) {
4177
4212
  return {
4178
4213
  exitCode: 1,
4179
- error: "Usage: groundmail migrate <sendgrid|postmark|mailgun> [--dry-run] [--only templates,suppressions], groundmail migrate list, or groundmail migrate report <id> [--csv]"
4214
+ error: "Usage: groundmail migrate <sendgrid|postmark|mailgun|resend|ses> [--dry-run] [--only templates,suppressions], groundmail migrate list, or groundmail migrate report <id> [--csv]"
4180
4215
  };
4181
4216
  }
4182
4217
  const id = provider;
@@ -4184,21 +4219,29 @@ async function runMigrateCommand(provider, args, env = process.env) {
4184
4219
  if (!apiKey) {
4185
4220
  return { exitCode: 1, error: "Not signed in. Run `groundmail login`, or set GROUNDMAIL_API_KEY." };
4186
4221
  }
4187
- const providerKey = readFlag22(args, "--key") || env[KEY_ENV[id]];
4188
- if (!providerKey) {
4189
- return {
4190
- exitCode: 1,
4191
- error: `Missing ${LABELS[id]} key. Set ${KEY_ENV[id]} (or pass --key). It is used for this import only and never stored.`
4192
- };
4193
- }
4194
- const params = { provider: id, api_key: providerKey };
4195
- if (id === "postmark") {
4196
- const accountToken = readFlag22(args, "--account-token") || env.POSTMARK_ACCOUNT_TOKEN;
4197
- if (accountToken) params.account_api_key = accountToken;
4222
+ let params;
4223
+ if (id === "ses") {
4224
+ const ses = sesParams(args, env);
4225
+ if (typeof ses === "string") return { exitCode: 1, error: ses };
4226
+ params = ses;
4198
4227
  } else {
4199
- const region = readFlag22(args, "--region");
4200
- if (region === "us" || region === "eu") params.region = region;
4201
- else if (region) return { exitCode: 1, error: "--region must be us or eu" };
4228
+ const providerKey = readFlag22(args, "--key") || env[KEY_ENV[id]];
4229
+ if (!providerKey) {
4230
+ const resend = id === "resend" ? " Use a key with Full access (Resend \u2192 API Keys); a Sending access key cannot read your account." : "";
4231
+ return {
4232
+ exitCode: 1,
4233
+ error: `Missing ${LABELS[id]} key. Set ${KEY_ENV[id]} (or pass --key).${resend} It is used for this import only and never stored.`
4234
+ };
4235
+ }
4236
+ params = { provider: id, api_key: providerKey };
4237
+ if (id === "postmark") {
4238
+ const accountToken = readFlag22(args, "--account-token") || env.POSTMARK_ACCOUNT_TOKEN;
4239
+ if (accountToken) params.account_api_key = accountToken;
4240
+ } else if (id === "sendgrid" || id === "mailgun") {
4241
+ const region = readFlag22(args, "--region");
4242
+ if (region === "us" || region === "eu") params.region = region;
4243
+ else if (region) return { exitCode: 1, error: "--region must be us or eu" };
4244
+ }
4202
4245
  }
4203
4246
  const only = readFlag22(args, "--only");
4204
4247
  if (only) {
@@ -4214,7 +4257,7 @@ async function runMigrateCommand(provider, args, env = process.env) {
4214
4257
  const { Groundmail } = await import("groundmail");
4215
4258
  const baseUrl = readFlag22(args, "--base-url");
4216
4259
  const client2 = new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
4217
- console.error(`${params.dry_run ? "Previewing" : "Importing"} from ${LABELS[id]} (Beta)\u2026`);
4260
+ console.error(`${params.dry_run ? "Previewing" : "Importing"} from ${LABELS[id]}${params.provider === "ses" ? ` (${params.aws_region})` : ""} (Beta)\u2026`);
4218
4261
  const report = await client2.migrations.run(params, {
4219
4262
  onProgress: (m) => {
4220
4263
  if (m.has_more) {
@@ -4518,6 +4561,8 @@ var USAGE_LINES = [
4518
4561
  " groundmail migrate sendgrid [--dry-run] [--only templates,suppressions,domains,webhooks] [--region eu] import from SendGrid (Beta)",
4519
4562
  " groundmail migrate postmark [--dry-run] [--only \u2026] import from Postmark (Beta)",
4520
4563
  " groundmail migrate mailgun [--dry-run] [--only \u2026] [--region eu] import from Mailgun (Beta)",
4564
+ " groundmail migrate resend [--dry-run] [--only \u2026] import from Resend (Beta; a Full access key)",
4565
+ " groundmail migrate ses --region us-east-1 [--dry-run] [--only \u2026] import one Amazon SES region (Beta)",
4521
4566
  " groundmail migrate list your recent imports",
4522
4567
  " groundmail migrate report <id> [--csv] an import report (JSON, or CSV to stdout)",
4523
4568
  " groundmail integrations twilio status",
@@ -4532,7 +4577,8 @@ var FOOTER_LINES = [
4532
4577
  " CLOUDFLARE_API_TOKEN=\u2026 (optional local apply; else uses dashboard Integrations)",
4533
4578
  " VERCEL_API_TOKEN=\u2026 VERCEL_TEAM_ID=\u2026 (optional local apply; else uses dashboard Integrations)",
4534
4579
  " GODADDY_PAT=\u2026 or GODADDY_API_KEY=\u2026 GODADDY_API_SECRET=\u2026 (domains apply --provider godaddy)",
4535
- " SENDGRID_API_KEY / POSTMARK_SERVER_TOKEN (+ POSTMARK_ACCOUNT_TOKEN) / MAILGUN_API_KEY (migrate; used once, never stored)",
4580
+ " SENDGRID_API_KEY / POSTMARK_SERVER_TOKEN (+ POSTMARK_ACCOUNT_TOKEN) / MAILGUN_API_KEY / RESEND_API_KEY (migrate; used once, never stored)",
4581
+ " AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY (+ AWS_SESSION_TOKEN, AWS_REGION) (migrate ses; used once, never stored)",
4536
4582
  "",
4537
4583
  "Scopes: full, emails:send, emails:read, domains:read, domains:write, webhooks:write, templates:write,",
4538
4584
  " suppressions:write, account:read",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groundmail-cli",
3
- "version": "0.31.0",
3
+ "version": "0.32.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.30.0"
41
+ "groundmail": "0.31.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.5.0",