groundmail-cli 0.19.0 → 0.20.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 (2) hide show
  1. package/dist/cli.js +19 -5
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -69,6 +69,9 @@ async function runSendCommand(args, deps) {
69
69
  unsubscribe: options.unsubscribe
70
70
  });
71
71
  stdout(JSON.stringify(result));
72
+ if (result.test) {
73
+ stderr("Test send: simulated, nothing was delivered. Its status and webhooks are marked test.");
74
+ }
72
75
  return 0;
73
76
  } catch (error) {
74
77
  stderr(error instanceof Error ? error.message : String(error));
@@ -389,10 +392,16 @@ async function runListCommand(args, deps) {
389
392
  const limitRaw = readFlag7(args, "--limit");
390
393
  const cursor = readFlag7(args, "--cursor");
391
394
  const limit = limitRaw ? Number(limitRaw) : void 0;
395
+ if (args.includes("--test") && args.includes("--live")) {
396
+ stderr("Pass --test or --live, not both.");
397
+ return { exitCode: 1, error: "conflicting flags" };
398
+ }
399
+ const test = args.includes("--test") ? true : args.includes("--live") ? false : void 0;
392
400
  try {
393
401
  const result = await deps.listEmails({
394
402
  ...limit != null && Number.isFinite(limit) ? { limit } : {},
395
- ...cursor ? { cursor } : {}
403
+ ...cursor ? { cursor } : {},
404
+ ...test !== void 0 ? { test } : {}
396
405
  });
397
406
  stdout(JSON.stringify(result));
398
407
  return { exitCode: 0 };
@@ -1288,7 +1297,7 @@ function trimUrl(value) {
1288
1297
  }
1289
1298
 
1290
1299
  // package.json
1291
- var version = "0.19.0";
1300
+ var version = "0.20.0";
1292
1301
 
1293
1302
  // src/user-agent.ts
1294
1303
  function buildUserAgent(own) {
@@ -2146,6 +2155,7 @@ async function runCreateKeyCommandWithClient(args, env = process.env) {
2146
2155
  if (scopes && !scopes.ok) return { exitCode: 1, error: scopes.error };
2147
2156
  const domainsFlag = readFlag16(args, "--allowed-domains");
2148
2157
  const allowedDomains = domainsFlag?.split(/[\s,]+/).map((domain) => domain.trim()).filter(Boolean);
2158
+ const test = args.includes("--test");
2149
2159
  try {
2150
2160
  const response = await apiRequest(baseUrl, "/api-keys", {
2151
2161
  apiKey,
@@ -2154,13 +2164,17 @@ async function runCreateKeyCommandWithClient(args, env = process.env) {
2154
2164
  ...name ? { name } : {},
2155
2165
  ...scope && !scopes ? { scope } : {},
2156
2166
  ...scopes?.ok ? { scopes: scopes.scope.split(" ") } : {},
2157
- ...allowedDomains?.length ? { allowed_domains: allowedDomains } : {}
2167
+ ...allowedDomains?.length ? { allowed_domains: allowedDomains } : {},
2168
+ ...test ? { test: true } : {}
2158
2169
  }
2159
2170
  });
2160
2171
  if (!response.ok) {
2161
2172
  return { exitCode: 1, error: errorMessage(response, "Could not create the key") };
2162
2173
  }
2163
2174
  console.log(JSON.stringify(response.body));
2175
+ if (test) {
2176
+ console.error("Test key: sends with it run every check and fire webhooks, but nothing is delivered. https://docs.groundmail.dev/testing");
2177
+ }
2164
2178
  return { exitCode: 0 };
2165
2179
  } catch (error) {
2166
2180
  return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
@@ -3325,7 +3339,7 @@ var USAGE_LINES = [
3325
3339
  " groundmail received-emails get inb_...",
3326
3340
  ' groundmail emails send --from you@domain.com --to user@example.com --subject "Hello" --html "<p>Hi</p>" [--category transactional|product] [--unsubscribe]',
3327
3341
  " groundmail emails batch --file ./emails.json",
3328
- " groundmail emails list [--limit 25] [--cursor \u2026]",
3342
+ " groundmail emails list [--limit 25] [--cursor \u2026] [--test | --live]",
3329
3343
  " groundmail emails insights [--window 7d|30d]",
3330
3344
  " groundmail emails get --id msg_\u2026",
3331
3345
  " groundmail emails cancel --id msg_\u2026",
@@ -3363,7 +3377,7 @@ var USAGE_LINES = [
3363
3377
  ' groundmail templates duplicate --id tpl_\u2026 [--name "Copy"]',
3364
3378
  " groundmail templates delete --id tpl_\u2026",
3365
3379
  " groundmail keys list",
3366
- " groundmail keys create [--name Default] [--scopes emails:send,domains:read] [--allowed-domains example.com]",
3380
+ " groundmail keys create [--name Default] [--scopes emails:send,domains:read] [--allowed-domains example.com] [--test] --test: a gm_test_ key, sends are simulated",
3367
3381
  " groundmail keys delete --id <api-key-id>",
3368
3382
  " groundmail migrate sendgrid [--dry-run] [--only templates,suppressions,domains,webhooks] [--region eu] import from SendGrid (Beta)",
3369
3383
  " groundmail migrate postmark [--dry-run] [--only \u2026] import from Postmark (Beta)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groundmail-cli",
3
- "version": "0.19.0",
3
+ "version": "0.20.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.16.0"
41
+ "groundmail": "0.17.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.5.0",