@stewardhq/cli 0.1.0 → 0.3.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/bin.js +48 -6
  2. package/package.json +4 -5
package/dist/bin.js CHANGED
@@ -437,6 +437,10 @@ async function catalogCommand(ctx, out, args) {
437
437
  return providerErrors > 0 ? 1 : 0;
438
438
  }
439
439
  const POSTGRES_IMAGE = "postgres:17.6-alpine";
440
+ /** Local mail catcher for billing emails (SMTP inside the compose network, web UI on the host). */
441
+ const MAILPIT_IMAGE = "axllent/mailpit:v1.31.1";
442
+ const MAILPIT_SERVICE = "mailpit";
443
+ const MAILPIT_UI_PORT = 8025;
440
444
  const STATE_DIR = ".steward";
441
445
  const COMPOSE_FILE = `${STATE_DIR}/compose.yml`;
442
446
  const CREDENTIALS_FILE = `${STATE_DIR}/credentials.json`;
@@ -475,7 +479,9 @@ function composeFile(options) {
475
479
  ["STEWARD_DEV_PRODUCT", options.product],
476
480
  ["STEWARD_DEV_CREDENTIALS_FILE", `${CONTAINER_STATE_DIR}/credentials.json`],
477
481
  ["STEWARD_DEV_APP_URL", options.appUrl],
478
- ...options.webhookUrl !== void 0 ? [["STEWARD_DEV_WEBHOOK_URL", options.webhookUrl]] : []
482
+ ...options.webhookUrl !== void 0 ? [["STEWARD_DEV_WEBHOOK_URL", options.webhookUrl]] : [],
483
+ ["STEWARD_SMTP_URL", `smtp://${MAILPIT_SERVICE}:1025`],
484
+ ["STEWARD_EMAIL_FROM", "billing@steward.localhost"]
479
485
  ];
480
486
  return `${[
481
487
  "# steward dev tarafından üretildi — elle düzenlemeyin, her `steward dev` yeniden yazar.",
@@ -510,6 +516,8 @@ function composeFile(options) {
510
516
  " depends_on:",
511
517
  " db:",
512
518
  " condition: service_healthy",
519
+ ` ${MAILPIT_SERVICE}:`,
520
+ " condition: service_started",
513
521
  " ports:",
514
522
  ` - ${q(`127.0.0.1:${options.port}:${CONTAINER_PORT}`)}`,
515
523
  " environment:",
@@ -518,6 +526,10 @@ function composeFile(options) {
518
526
  ` - ${q("host.docker.internal:host-gateway")}`,
519
527
  " volumes:",
520
528
  ` - ${q(`.:${CONTAINER_STATE_DIR}`)}`,
529
+ ` ${MAILPIT_SERVICE}:`,
530
+ ` image: ${q(MAILPIT_IMAGE)}`,
531
+ " ports:",
532
+ ` - ${q(`127.0.0.1:${options.mailPort ?? 8025}:${MAILPIT_UI_PORT}`)}`,
521
533
  "volumes:",
522
534
  " db: {}"
523
535
  ].join("\n")}\n`;
@@ -673,6 +685,12 @@ function formatDoctorReport(report, cliWarnings) {
673
685
  }
674
686
  }
675
687
  lines.push(`dunning ${report.dunning.dryRun ? "dry-run (askı/sonlandırma uygulanmaz)" : "etkin"}`);
688
+ if (report.emails) {
689
+ const { emails } = report;
690
+ const problems = [...emails.transportConfigured ? [] : ["no transport"], ...emails.senderConfigured ? [] : ["no sender"]];
691
+ const disabled = emails.disabledTemplates.length > 0 ? ` · disabled: ${emails.disabledTemplates.join(", ")}` : "";
692
+ lines.push(`emails ${emails.ready ? "ready ✓" : `not sending ✗${problems.length > 0 ? ` (${problems.join(", ")})` : ""}`}${disabled}`);
693
+ }
676
694
  for (const severity of SEVERITY_ORDER) {
677
695
  const items = all.filter((w) => w.severity === severity);
678
696
  if (items.length === 0) continue;
@@ -721,11 +739,12 @@ async function doctorCommand(ctx, out, args) {
721
739
  //#region src/commands/dev.ts
722
740
  const DEV_USAGE = `Kullanım:
723
741
  steward dev [--product <kod>] [--catalog <dosya>] [--port 3002] [--app-url <url>]
724
- [--webhook-url <url>] [--image <imaj>] [--timeout <sn>]
742
+ [--webhook-url <url>] [--mail-port 8025] [--image <imaj>] [--timeout <sn>]
725
743
  steward dev reset --yes
726
744
 
727
745
  Yerel steward: dev imajı + Postgres (Docker compose, yalnızca 127.0.0.1), sahte
728
746
  ödeme sağlayıcısı; hosted checkout ve portal http://localhost:<port>/public altında.
747
+ Billing emails are caught by Mailpit: http://localhost:<mail-port>.
729
748
 
730
749
  1. .steward/compose.yml yazılır, .steward/ .gitignore'a eklenir (yoksa)
731
750
  2. docker compose -f .steward/compose.yml up -d, /health beklenir
@@ -741,6 +760,7 @@ Yerel steward: dev imajı + Postgres (Docker compose, yalnızca 127.0.0.1), saht
741
760
  --port <n> host portu (varsayılan 3002)
742
761
  --app-url <url> ürünün yerel adresi (varsayılan http://localhost:3000)
743
762
  --webhook-url <url> webhook alıcısı, ör. http://host.docker.internal:3000/api/billing/events
763
+ --mail-port <n> host port of the Mailpit web UI (default 8025)
744
764
  --image <imaj> dev imajı. İlk dev imajı yayınına kadar ZORUNLU (varsayılan
745
765
  etiket yer tutucu): ghcr.io/z9cloud/steward:dev-<etiket> ya da
746
766
  steward reposunda docker build --target dev -t steward-dev:local .
@@ -757,6 +777,7 @@ const DEV_OPTIONS = {
757
777
  port: { type: "string" },
758
778
  "app-url": { type: "string" },
759
779
  "webhook-url": { type: "string" },
780
+ "mail-port": { type: "string" },
760
781
  image: { type: "string" },
761
782
  timeout: { type: "string" }
762
783
  };
@@ -936,6 +957,7 @@ async function devCommand(ctx, out, args) {
936
957
  out.err(`ürün kodu: ${product} (${inferred.from}; değiştirmek için --product)`);
937
958
  }
938
959
  const port = parsePositiveInt(values.port ?? "3002", "--port", { max: 65535 });
960
+ const mailPort = parsePositiveInt(values["mail-port"] ?? String(8025), "--mail-port", { max: 65535 });
939
961
  const appUrl = parseHttpUrl(values["app-url"] ?? "http://localhost:3000", "--app-url");
940
962
  const webhookUrl = values["webhook-url"] !== void 0 ? parseHttpUrl(values["webhook-url"], "--webhook-url") : void 0;
941
963
  const image = checkImage(values.image ?? "ghcr.io/z9cloud/steward:dev-unreleased");
@@ -953,6 +975,7 @@ async function devCommand(ctx, out, args) {
953
975
  projectDir: resolve(ctx.cwd),
954
976
  product,
955
977
  port,
978
+ mailPort,
956
979
  appUrl,
957
980
  ...webhookUrl !== void 0 ? { webhookUrl } : {},
958
981
  image,
@@ -968,7 +991,7 @@ async function devCommand(ctx, out, args) {
968
991
  "up",
969
992
  "-d"
970
993
  ], { cwd: ctx.cwd });
971
- if (up.code !== 0) throw new CliError(`docker compose up başarısız (çıkış ${up.code}); port ${port} kullanımda olabilir (--port)`);
994
+ if (up.code !== 0) throw new CliError(`docker compose up failed (exit ${up.code}); port ${port} or ${mailPort} may be in use (--port, --mail-port)`);
972
995
  const deadline = ctx.now() + timeoutSeconds * 1e3;
973
996
  const health = await waitForHealth(ctx, baseUrl, deadline, timeoutSeconds);
974
997
  if (health.env === "production") throw new CliError(`${image} üretim imajı (env: production): dev imajı verin (ghcr.io/z9cloud/steward:dev-<etiket>)`);
@@ -1013,6 +1036,7 @@ async function devCommand(ctx, out, args) {
1013
1036
  for (const line of formatDoctorSummary(report)) out.err(line);
1014
1037
  out.out(`steward dev hazır: ${baseUrl} (ürün ${product}${health.env !== null ? `, env ${health.env}` : ""})`);
1015
1038
  out.out(` hosted checkout/portal: ${baseUrl}/public/… · uygulamanızı başlatın (ör. pnpm dev)`);
1039
+ out.out(` billing emails (Mailpit): http://localhost:${mailPort}`);
1016
1040
  out.out(` durdur: docker compose -f ${COMPOSE_FILE} down · sıfırla: steward dev reset --yes`);
1017
1041
  return exitCode;
1018
1042
  }
@@ -1252,12 +1276,15 @@ const SETTINGS_USAGE = `Kullanım:
1252
1276
  steward settings set [--app-url <url>] [--privacy-url <url>] [--terms-url <url>]
1253
1277
  [--branding <json>] [--default-locale tr|en]
1254
1278
  [--checkout-ttl <dakika>] [--portal-ttl <dakika>]
1255
- [--extra-return-origins <a,b>]
1279
+ [--extra-return-origins <a,b>] [--emails <json>]
1256
1280
 
1257
1281
  Ürün ayarları (GET/PATCH /v1/admin/settings). Verilmeyen alan değişmez; boş değer
1258
1282
  (--privacy-url "") alanı temizler, --branding null markayı temizler, --branding
1259
1283
  '{"name":"Acme","supportEmail":"destek@acme.com"}' sığ birleşir (alanı null ile
1260
1284
  temizleyin). --extra-return-origins "" listeyi boşaltır.
1285
+ --emails '{"billingPath":"/{LOCALE}/billing","templates":{"invoice_issued":{"enabled":false}}}'
1286
+ sets billing emails (sender: from.name, from.address; templates merge per
1287
+ template, null resets a field or template; --emails null resets all).
1261
1288
 
1262
1289
  Bağlantı: STEWARD_ADMIN_URL + STEWARD_ADMIN_API_KEY (ortam, yoksa ./.env.local).`;
1263
1290
  const SET_OPTIONS = {
@@ -1269,7 +1296,8 @@ const SET_OPTIONS = {
1269
1296
  "default-locale": { type: "string" },
1270
1297
  "checkout-ttl": { type: "string" },
1271
1298
  "portal-ttl": { type: "string" },
1272
- "extra-return-origins": { type: "string" }
1299
+ "extra-return-origins": { type: "string" },
1300
+ emails: { type: "string" }
1273
1301
  };
1274
1302
  const orNull = (value) => value.trim() === "" ? null : value.trim();
1275
1303
  /** Bayraklardan yama; sözleşme şemasıyla doğrulanır (geçersizse istek gönderilmez). */
@@ -1292,6 +1320,20 @@ function buildSettingsPatch(values) {
1292
1320
  patch.branding = branding;
1293
1321
  }
1294
1322
  }
1323
+ if (values.emails !== void 0) {
1324
+ const text = values.emails.trim();
1325
+ if (text === "" || text === "null") patch.emails = null;
1326
+ else {
1327
+ let emails;
1328
+ try {
1329
+ emails = JSON.parse(text);
1330
+ } catch {
1331
+ throw new UsageError("--emails: must be a JSON object, e.g. '{\"billingPath\":\"/billing\"}'");
1332
+ }
1333
+ if (typeof emails !== "object" || emails === null || Array.isArray(emails)) throw new UsageError("--emails: must be a JSON object");
1334
+ patch.emails = emails;
1335
+ }
1336
+ }
1295
1337
  if (values["default-locale"] !== void 0) patch.defaultLocale = values["default-locale"].trim();
1296
1338
  if (values["checkout-ttl"] !== void 0) patch.checkoutTtlMinutes = parsePositiveInt(values["checkout-ttl"], "--checkout-ttl");
1297
1339
  if (values["portal-ttl"] !== void 0) patch.portalTtlMinutes = parsePositiveInt(values["portal-ttl"], "--portal-ttl");
@@ -1340,7 +1382,7 @@ async function settingsCommand(ctx, out, args) {
1340
1382
  }
1341
1383
  //#endregion
1342
1384
  //#region src/main.ts
1343
- const CLI_VERSION = "0.1.0";
1385
+ const CLI_VERSION = "0.3.0";
1344
1386
  const USAGE = `steward — Steward CLI (@stewardhq/cli ${CLI_VERSION})
1345
1387
 
1346
1388
  Kullanım: steward <komut> [seçenekler]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stewardhq/cli",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Steward CLI: local dev loop (steward dev), doctor, catalog push, settings and webhook endpoint management.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -19,18 +19,17 @@
19
19
  ],
20
20
  "publishConfig": {
21
21
  "access": "public",
22
- "registry": "https://registry.npmjs.org",
23
- "provenance": true
22
+ "registry": "https://registry.npmjs.org"
24
23
  },
25
24
  "dependencies": {
26
- "@stewardhq/sdk": "^0.1.0-rc.0"
25
+ "@stewardhq/sdk": "^0.3.0"
27
26
  },
28
27
  "devDependencies": {
29
28
  "@types/node": "^24.13.3",
30
29
  "tsdown": "^0.23.0",
31
30
  "tsx": "^4.19.0",
32
31
  "typescript": "^5.9.0",
33
- "vitest": "^3.0.0"
32
+ "vitest": "^5.0.1"
34
33
  },
35
34
  "scripts": {
36
35
  "build": "tsdown",