@geekmidas/cli 10.0.0-alpha.45 → 10.0.0-alpha.47

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 (88) hide show
  1. package/README.md +144 -183
  2. package/dist/{OpenApiTsGenerator-B4Kj_qNU.cjs → OpenApiTsGenerator-BN0PIZxd.cjs} +17 -71
  3. package/dist/OpenApiTsGenerator-BN0PIZxd.cjs.map +1 -0
  4. package/dist/{OpenApiTsGenerator-CEh3EKN3.mjs → OpenApiTsGenerator-BzIGy8KE.mjs} +17 -71
  5. package/dist/OpenApiTsGenerator-BzIGy8KE.mjs.map +1 -0
  6. package/dist/backends-B9V2XD2M.cjs +82 -0
  7. package/dist/backends-B9V2XD2M.cjs.map +1 -0
  8. package/dist/backends-CSuLl0YP.mjs +59 -0
  9. package/dist/backends-CSuLl0YP.mjs.map +1 -0
  10. package/dist/{config-CJ-PAb7M.cjs → config-CsYSyUya.cjs} +3 -3
  11. package/dist/{config-CJ-PAb7M.cjs.map → config-CsYSyUya.cjs.map} +1 -1
  12. package/dist/{config-5watB1D0.mjs → config-D8J5rrTb.mjs} +3 -3
  13. package/dist/{config-5watB1D0.mjs.map → config-D8J5rrTb.mjs.map} +1 -1
  14. package/dist/config.cjs +2 -2
  15. package/dist/config.d.cts +2 -2
  16. package/dist/config.d.mts +2 -2
  17. package/dist/config.mjs +2 -2
  18. package/dist/{discover-BLhf7V_J.mjs → discover-Cf2jAcgF.mjs} +4 -56
  19. package/dist/discover-Cf2jAcgF.mjs.map +1 -0
  20. package/dist/{discover-B0f_kuNN.cjs → discover-DXNviAh-.cjs} +3 -79
  21. package/dist/discover-DXNviAh-.cjs.map +1 -0
  22. package/dist/{emit-Bzq7JsMP.mjs → emit-C1e8qD08.mjs} +12 -43
  23. package/dist/emit-C1e8qD08.mjs.map +1 -0
  24. package/dist/{emit-BdoPFjZf.cjs → emit-Dmc1nvdS.cjs} +11 -54
  25. package/dist/emit-Dmc1nvdS.cjs.map +1 -0
  26. package/dist/encryption-C7OGMve_.cjs +91 -0
  27. package/dist/encryption-C7OGMve_.cjs.map +1 -0
  28. package/dist/encryption-DyQnPsZN.mjs +90 -0
  29. package/dist/encryption-DyQnPsZN.mjs.map +1 -0
  30. package/dist/{github-D5MthUlR.mjs → github-BfpadQWQ.mjs} +3 -3
  31. package/dist/{github-D5MthUlR.mjs.map → github-BfpadQWQ.mjs.map} +1 -1
  32. package/dist/{github-BAr8WGkR.cjs → github-BrI1tv6u.cjs} +3 -3
  33. package/dist/{github-BAr8WGkR.cjs.map → github-BrI1tv6u.cjs.map} +1 -1
  34. package/dist/{index-B3PeGOQp.d.cts → index-BQhJXpaQ.d.mts} +2 -2
  35. package/dist/{index-B3PeGOQp.d.cts.map → index-BQhJXpaQ.d.mts.map} +1 -1
  36. package/dist/{index-BOyaGcCm.d.mts → index-DHJePE0y.d.cts} +2 -2
  37. package/dist/{index-BOyaGcCm.d.mts.map → index-DHJePE0y.d.cts.map} +1 -1
  38. package/dist/index.cjs +444 -670
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.mjs +442 -668
  41. package/dist/index.mjs.map +1 -1
  42. package/dist/{migrate-PJi4b1ga.cjs → migrate-BgEY9pdP.cjs} +5 -5
  43. package/dist/{migrate-PJi4b1ga.cjs.map → migrate-BgEY9pdP.cjs.map} +1 -1
  44. package/dist/{migrate-BRklCm7b.mjs → migrate-DhxTIA0z.mjs} +5 -5
  45. package/dist/{migrate-BRklCm7b.mjs.map → migrate-DhxTIA0z.mjs.map} +1 -1
  46. package/dist/openapi.cjs +2 -2
  47. package/dist/openapi.d.cts +1 -1
  48. package/dist/openapi.d.mts +1 -1
  49. package/dist/openapi.mjs +2 -2
  50. package/dist/{ready-ZqOuNvKD.mjs → ready-WfT-eWlm.mjs} +50 -8
  51. package/dist/ready-WfT-eWlm.mjs.map +1 -0
  52. package/dist/{ready-3RfHxdA0.cjs → ready-lr2Fm-ep.cjs} +68 -8
  53. package/dist/ready-lr2Fm-ep.cjs.map +1 -0
  54. package/dist/reconcile/public.cjs +2 -4
  55. package/dist/reconcile/public.d.cts +6 -10
  56. package/dist/reconcile/public.d.cts.map +1 -1
  57. package/dist/reconcile/public.d.mts +6 -10
  58. package/dist/reconcile/public.d.mts.map +1 -1
  59. package/dist/reconcile/public.mjs +3 -3
  60. package/dist/{types-0R124hrY.d.mts → types-BbrNu83u.d.mts} +14 -109
  61. package/dist/{types-0R124hrY.d.mts.map → types-BbrNu83u.d.mts.map} +1 -1
  62. package/dist/{types-DfdYe31u.d.cts → types-DNqEsctD.d.cts} +14 -109
  63. package/dist/{types-DfdYe31u.d.cts.map → types-DNqEsctD.d.cts.map} +1 -1
  64. package/dist/vitest.cjs +1 -1
  65. package/dist/vitest.mjs +1 -1
  66. package/dist/workspace/index.cjs +1 -1
  67. package/dist/workspace/index.d.cts +2 -2
  68. package/dist/workspace/index.d.mts +2 -2
  69. package/dist/workspace/index.mjs +1 -1
  70. package/dist/{workspace-RYSYtHP7.cjs → workspace-DEibcoBe.cjs} +11 -25
  71. package/dist/{workspace-RYSYtHP7.cjs.map → workspace-DEibcoBe.cjs.map} +1 -1
  72. package/dist/{workspace-DOmIhiau.mjs → workspace-DNzWgM1J.mjs} +11 -25
  73. package/dist/{workspace-DOmIhiau.mjs.map → workspace-DNzWgM1J.mjs.map} +1 -1
  74. package/dist/{workspace-BKytVCzb.mjs → workspace-cb6U29EL.mjs} +59 -81
  75. package/dist/workspace-cb6U29EL.mjs.map +1 -0
  76. package/dist/{workspace-dV6f-3vv.cjs → workspace-vafrzZTC.cjs} +65 -105
  77. package/dist/workspace-vafrzZTC.cjs.map +1 -0
  78. package/package.json +14 -14
  79. package/dist/OpenApiTsGenerator-B4Kj_qNU.cjs.map +0 -1
  80. package/dist/OpenApiTsGenerator-CEh3EKN3.mjs.map +0 -1
  81. package/dist/discover-B0f_kuNN.cjs.map +0 -1
  82. package/dist/discover-BLhf7V_J.mjs.map +0 -1
  83. package/dist/emit-BdoPFjZf.cjs.map +0 -1
  84. package/dist/emit-Bzq7JsMP.mjs.map +0 -1
  85. package/dist/ready-3RfHxdA0.cjs.map +0 -1
  86. package/dist/ready-ZqOuNvKD.mjs.map +0 -1
  87. package/dist/workspace-BKytVCzb.mjs.map +0 -1
  88. package/dist/workspace-dV6f-3vv.cjs.map +0 -1
@@ -1,10 +1,11 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
2
- const require_discover = require("./discover-B0f_kuNN.cjs");
3
- const require_config = require("./config-CJ-PAb7M.cjs");
4
- const require_workspace = require("./workspace-RYSYtHP7.cjs");
2
+ const require_discover = require("./discover-DXNviAh-.cjs");
3
+ const require_config = require("./config-CsYSyUya.cjs");
4
+ const require_workspace = require("./workspace-DEibcoBe.cjs");
5
5
  const require_storage = require("./storage-CSGoC3bK.cjs");
6
6
  const require_store = require("./store-DQgxT_WR.cjs");
7
- const require_ready = require("./ready-3RfHxdA0.cjs");
7
+ const require_ready = require("./ready-lr2Fm-ep.cjs");
8
+ const require_backends = require("./backends-B9V2XD2M.cjs");
8
9
  let node_fs = require("node:fs");
9
10
  let node_fs_promises = require("node:fs/promises");
10
11
  let node_os = require("node:os");
@@ -14,6 +15,7 @@ let _geekmidas_manifest = require("@geekmidas/manifest");
14
15
  let node_net = require("node:net");
15
16
  let dotenv = require("dotenv");
16
17
  let node_crypto = require("node:crypto");
18
+ let _geekmidas_constructs_encryption = require("@geekmidas/constructs/encryption");
17
19
  let _geekmidas_db_pg_roles = require("@geekmidas/db/pg/roles");
18
20
  let _geekmidas_events_sns_url = require("@geekmidas/events/sns/url");
19
21
  _geekmidas_events_sns_url = require_rolldown_runtime.__toESM(_geekmidas_events_sns_url, 1);
@@ -248,62 +250,6 @@ async function prepareEntryCredentials(options) {
248
250
  };
249
251
  }
250
252
  //#endregion
251
- //#region src/workspace/backends.ts
252
- /**
253
- * Which backend each declared kind resolves to — decided by where the project
254
- * deploys, and by nothing else.
255
- *
256
- * These used to be read out of a `services:` block, where one key answered two
257
- * questions: *does this exist* and *what backs it*. The first is the manifest's
258
- * — a declared `Cache` is why there is a cache — and the second is the deploy
259
- * target's, because the right cache for a Lambda is not the right cache for a
260
- * box already running Postgres. With both answered elsewhere there was nothing
261
- * left for the block to say, so it is gone and these read the target.
262
- *
263
- * Mail has no answer here at all: every provider speaks SMTP, so the provider
264
- * is whichever one the stage's mail URL points at.
265
- */
266
- /**
267
- * Which family of defaults a workspace's deploy target belongs to.
268
- *
269
- * One question, asked once: **does this target run containers the project
270
- * controls?** Dokploy and a bare server do, so a bucket or a cache can live
271
- * beside the app; AWS, Vercel and Cloudflare do not, so the default has to be
272
- * something managed. That is the whole of the distinction, and it is why
273
- * `MainProvider` is the right axis rather than the deploy target's own name —
274
- * three targets share one answer.
275
- *
276
- * An AWS deploy names no `deploy.default` at all, because it goes through SST,
277
- * which is why the absence is what selects `aws`.
278
- */
279
- function providerOf(workspace) {
280
- const target = workspace.deploy?.default;
281
- return target === "dokploy" || target === "server" ? "server" : "aws";
282
- }
283
- /**
284
- * The cache backend a target implies.
285
- *
286
- * The same answer locally and deployed: a local `gkm dev` for an AWS app still
287
- * uses the Upstash protocol, because a backend that differed between the two
288
- * would be worse than a slower one.
289
- */
290
- function cacheBackendFor(on) {
291
- return require_discover.DEFAULT_CACHE[on];
292
- }
293
- /** Where a declared bucket lives on a target. */
294
- function storageBackendFor(on) {
295
- return require_discover.DEFAULT_STORAGE[on];
296
- }
297
- /**
298
- * Which broker carries declared queues and topics on a target.
299
- *
300
- * Only consulted when something declares one; a project with no `Topic` or
301
- * `Queue` has no events at all, whatever the target.
302
- */
303
- function eventsBackendFor(on) {
304
- return require_discover.DEFAULT_EVENTS[on];
305
- }
306
- //#endregion
307
253
  //#region src/reconcile/containers.ts
308
254
  /**
309
255
  * What gkm knows about each container it can derive.
@@ -363,7 +309,8 @@ const PORTS = {
363
309
  }, {
364
310
  key: "minio-console",
365
311
  inside: 9001,
366
- label: "minio console"
312
+ label: "minio console",
313
+ web: true
367
314
  }],
368
315
  mailpit: [{
369
316
  key: "mailpit",
@@ -372,7 +319,8 @@ const PORTS = {
372
319
  }, {
373
320
  key: "mailpit-web",
374
321
  inside: 8025,
375
- label: "mailpit inbox"
322
+ label: "mailpit inbox",
323
+ web: true
376
324
  }],
377
325
  redis: [{
378
326
  key: "redis",
@@ -391,7 +339,8 @@ const PORTS = {
391
339
  }, {
392
340
  key: "rabbitmq-management",
393
341
  inside: 15672,
394
- label: "rabbitmq console"
342
+ label: "rabbitmq console",
343
+ web: true
395
344
  }],
396
345
  localstack: [{
397
346
  key: "localstack",
@@ -423,6 +372,29 @@ function portsOf(container, fakes = {}) {
423
372
  }];
424
373
  return PORTS[container] ?? [];
425
374
  }
375
+ /**
376
+ * Every port the containers publish — not only the one an app connects to.
377
+ *
378
+ * The consoles and the inbox are most of why these are real containers, and an
379
+ * inbox nobody can find is an inbox nobody opens: a sign-in link gets fished
380
+ * out of `docker ps` instead.
381
+ */
382
+ function serviceAddresses(containers, ports, fakes = {}) {
383
+ return containers.flatMap((container) => portsOf(container, fakes).flatMap((port) => {
384
+ const assigned = ports[port.key];
385
+ if (assigned === void 0) return [];
386
+ return [{
387
+ container,
388
+ label: port.label,
389
+ address: port.web ? `http://localhost:${assigned}` : `localhost:${assigned}`
390
+ }];
391
+ }));
392
+ }
393
+ /** The lines `gkm dev` and `gkm setup` print under the services heading. */
394
+ function describeServices(services) {
395
+ const width = Math.max(0, ...services.map(({ label }) => label.length));
396
+ return services.map(({ label, address }) => ` ${label.padEnd(width)} ${address}`);
397
+ }
426
398
  /** The key a container's primary port is allocated under. */
427
399
  function primaryPortKey(container) {
428
400
  return portsOf(container)[0]?.key ?? container;
@@ -748,6 +720,7 @@ const CACHE_CONTAINERS = {
748
720
  const CONTAINERLESS = {
749
721
  secret: true,
750
722
  credential: true,
723
+ encryption: true,
751
724
  "rest-api": true,
752
725
  site: true,
753
726
  "mobile-app": true,
@@ -844,7 +817,7 @@ function resourceName(id, kind, stage, localStage) {
844
817
  * broker the project selected, which is why the backend is an argument here
845
818
  * rather than a second pass that adds containers after the fact.
846
819
  */
847
- function containerFor(kind, events = DEFAULT_EVENTS, cache = require_discover.DEFAULT_CACHE.aws, derived = false, edge = true) {
820
+ function containerFor(kind, events = DEFAULT_EVENTS, cache = require_ready.DEFAULT_CACHE.aws, derived = false, edge = true) {
848
821
  if (EVENT_KINDS[kind]) return EVENT_CONTAINERS[events] ?? CONTAINERS.database;
849
822
  if (kind === "file-server") return edge ? "caddy" : CONTAINERS.objects;
850
823
  if (kind === "cache") {
@@ -865,7 +838,7 @@ function planFor(manifest, stage, order, options = {}) {
865
838
  const resources = [];
866
839
  const fakes = {};
867
840
  const events = options.events ?? "pgboss";
868
- const cache = options.cache ?? require_discover.DEFAULT_CACHE.aws;
841
+ const cache = options.cache ?? require_ready.DEFAULT_CACHE.aws;
869
842
  for (const id of order) {
870
843
  const declaration = manifest[id];
871
844
  if (!declaration) continue;
@@ -1212,6 +1185,7 @@ function workerBroker(plan, ports) {
1212
1185
  */
1213
1186
  function urlFor(resource, plan, ports, project, addresses = {}) {
1214
1187
  if (resource.kind === "secret") return localSecret(project, plan, resource);
1188
+ if (resource.kind === "encryption") return localKeyring(project, plan, resource);
1215
1189
  if (resource.kind === "mobile-app") return (0, _geekmidas_manifest.schemeBase)(project, resource.scheme);
1216
1190
  if (resource.kind === "credential") return void 0;
1217
1191
  if (resource.kind === "external-api") {
@@ -1387,6 +1361,24 @@ var UnprovisionedEventsBackend = class extends Error {
1387
1361
  }
1388
1362
  };
1389
1363
  /**
1364
+ * The keyring an `Encryption` construct resolves to locally.
1365
+ *
1366
+ * Derived like a secret — stable across restarts, distinct per project, stage
1367
+ * and construct, never written to disk — so what `gkm dev` encrypted yesterday
1368
+ * still opens today. One key, because nothing local is worth rotating: a
1369
+ * server stage's keyring is generated and rotated in its secrets instead.
1370
+ */
1371
+ function localKeyring(project, plan, resource) {
1372
+ const derive = (purpose) => (0, node_crypto.createHash)("sha256").update(`${project}:${plan.stage}:${resource.id}:${purpose}`).digest();
1373
+ return (0, _geekmidas_constructs_encryption.formatKeyring)({
1374
+ keys: [{
1375
+ id: "k1",
1376
+ key: derive("k1")
1377
+ }],
1378
+ index: derive("index")
1379
+ });
1380
+ }
1381
+ /**
1390
1382
  * The value a secret resolves to locally.
1391
1383
  *
1392
1384
  * A hash of what identifies it, so it is stable, distinct per project, stage
@@ -2718,7 +2710,7 @@ async function reconcile(options) {
2718
2710
  caddyfile,
2719
2711
  postgres: postgresStatements(plan, project).map((statement) => statement.create).join(";\n")
2720
2712
  });
2721
- const addresses = addressesFor(plan.containers, ports);
2713
+ const services = serviceAddresses(plan.containers, ports, plan.fakes);
2722
2714
  const lan = plan.resources.some((r) => r.kind === "mobile-app") ? options.lanAddress === void 0 ? lanAddress() : options.lanAddress ?? void 0 : void 0;
2723
2715
  const env = envFor(plan, {
2724
2716
  ports,
@@ -2734,7 +2726,7 @@ async function reconcile(options) {
2734
2726
  plan,
2735
2727
  compose,
2736
2728
  ports,
2737
- addresses,
2729
+ services,
2738
2730
  env,
2739
2731
  provisioned: [],
2740
2732
  fakes: options.fakes ?? {},
@@ -2806,20 +2798,6 @@ async function observedPorts(docker, composePath, containers, fakes) {
2806
2798
  }
2807
2799
  return observed;
2808
2800
  }
2809
- /**
2810
- * Where each container can be reached on this machine.
2811
- *
2812
- * The primary port only — a container's console is for a human to open, not
2813
- * something an app connects to.
2814
- */
2815
- function addressesFor(containers, ports) {
2816
- const addresses = {};
2817
- for (const container of containers) {
2818
- const port = ports[primaryPortKey(container)];
2819
- if (port !== void 0) addresses[container] = `localhost:${port}`;
2820
- }
2821
- return addresses;
2822
- }
2823
2801
  /** Write a file only when its content would change, so mtimes stay meaningful. */
2824
2802
  /**
2825
2803
  * Remove the routes of stages this project no longer reconciles.
@@ -2876,10 +2854,10 @@ function constructGlobs(workspace) {
2876
2854
  }
2877
2855
  /** The backends a workspace's target implies, as the plan takes them. */
2878
2856
  function backendsOf(workspace) {
2879
- const on = providerOf(workspace);
2857
+ const on = require_backends.providerOf(workspace);
2880
2858
  return {
2881
- events: eventsBackendFor(on),
2882
- cache: cacheBackendFor(on)
2859
+ events: require_backends.eventsBackendFor(on),
2860
+ cache: require_backends.cacheBackendFor(on)
2883
2861
  };
2884
2862
  }
2885
2863
  /**
@@ -3022,12 +3000,6 @@ Object.defineProperty(exports, "backendsOf", {
3022
3000
  return backendsOf;
3023
3001
  }
3024
3002
  });
3025
- Object.defineProperty(exports, "cacheBackendFor", {
3026
- enumerable: true,
3027
- get: function() {
3028
- return cacheBackendFor;
3029
- }
3030
- });
3031
3003
  Object.defineProperty(exports, "constructGlobs", {
3032
3004
  enumerable: true,
3033
3005
  get: function() {
@@ -3052,10 +3024,10 @@ Object.defineProperty(exports, "derivedContainers", {
3052
3024
  return derivedContainers;
3053
3025
  }
3054
3026
  });
3055
- Object.defineProperty(exports, "eventsBackendFor", {
3027
+ Object.defineProperty(exports, "describeServices", {
3056
3028
  enumerable: true,
3057
3029
  get: function() {
3058
- return eventsBackendFor;
3030
+ return describeServices;
3059
3031
  }
3060
3032
  });
3061
3033
  Object.defineProperty(exports, "fakeKey", {
@@ -3118,12 +3090,6 @@ Object.defineProperty(exports, "primaryPortKey", {
3118
3090
  return primaryPortKey;
3119
3091
  }
3120
3092
  });
3121
- Object.defineProperty(exports, "providerOf", {
3122
- enumerable: true,
3123
- get: function() {
3124
- return providerOf;
3125
- }
3126
- });
3127
3093
  Object.defineProperty(exports, "quoteIdentifier", {
3128
3094
  enumerable: true,
3129
3095
  get: function() {
@@ -3148,12 +3114,6 @@ Object.defineProperty(exports, "rootSite", {
3148
3114
  return rootSite;
3149
3115
  }
3150
3116
  });
3151
- Object.defineProperty(exports, "storageBackendFor", {
3152
- enumerable: true,
3153
- get: function() {
3154
- return storageBackendFor;
3155
- }
3156
- });
3157
3117
  Object.defineProperty(exports, "workspace_exports", {
3158
3118
  enumerable: true,
3159
3119
  get: function() {
@@ -3161,4 +3121,4 @@ Object.defineProperty(exports, "workspace_exports", {
3161
3121
  }
3162
3122
  });
3163
3123
 
3164
- //# sourceMappingURL=workspace-dV6f-3vv.cjs.map
3124
+ //# sourceMappingURL=workspace-vafrzZTC.cjs.map