@geekmidas/cli 10.0.0-alpha.46 → 10.0.0-alpha.48
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/bin/gkm.mjs +9 -1
- package/bin/owning-tsconfig-jsx-register.mjs +18 -0
- package/bin/owning-tsconfig-jsx.mjs +108 -0
- package/dist/backends-B9V2XD2M.cjs +82 -0
- package/dist/backends-B9V2XD2M.cjs.map +1 -0
- package/dist/backends-CSuLl0YP.mjs +59 -0
- package/dist/backends-CSuLl0YP.mjs.map +1 -0
- package/dist/encryption-C7OGMve_.cjs +91 -0
- package/dist/encryption-C7OGMve_.cjs.map +1 -0
- package/dist/encryption-DyQnPsZN.mjs +90 -0
- package/dist/encryption-DyQnPsZN.mjs.map +1 -0
- package/dist/index.cjs +131 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +123 -43
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-Dp5HFzuQ.cjs → migrate-BgEY9pdP.cjs} +2 -2
- package/dist/{migrate-Dp5HFzuQ.cjs.map → migrate-BgEY9pdP.cjs.map} +1 -1
- package/dist/{migrate-B3opyC3o.mjs → migrate-DhxTIA0z.mjs} +2 -2
- package/dist/{migrate-B3opyC3o.mjs.map → migrate-DhxTIA0z.mjs.map} +1 -1
- package/dist/{ready-V6Ou6-B6.mjs → ready-WfT-eWlm.mjs} +2 -1
- package/dist/{ready-V6Ou6-B6.mjs.map → ready-WfT-eWlm.mjs.map} +1 -1
- package/dist/{ready-L7I68yXf.cjs → ready-lr2Fm-ep.cjs} +2 -1
- package/dist/{ready-L7I68yXf.cjs.map → ready-lr2Fm-ep.cjs.map} +1 -1
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/dist/{workspace-CHEC80sp.mjs → workspace-cb6U29EL.mjs} +56 -77
- package/dist/workspace-cb6U29EL.mjs.map +1 -0
- package/dist/{workspace-D9z2ymBW.cjs → workspace-vafrzZTC.cjs} +60 -99
- package/dist/workspace-vafrzZTC.cjs.map +1 -0
- package/package.json +14 -14
- package/dist/workspace-CHEC80sp.mjs.map +0 -1
- package/dist/workspace-D9z2ymBW.cjs.map +0 -1
|
@@ -4,7 +4,8 @@ const require_config = require("./config-CsYSyUya.cjs");
|
|
|
4
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-
|
|
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,61 +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 `deploy.default: 'sst'`, because it goes through SST.
|
|
277
|
-
*/
|
|
278
|
-
function providerOf(workspace) {
|
|
279
|
-
const target = workspace.deploy?.default;
|
|
280
|
-
return target === "dokploy" || target === "server" ? "server" : "aws";
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* The cache backend a target implies.
|
|
284
|
-
*
|
|
285
|
-
* The same answer locally and deployed: a local `gkm dev` for an AWS app still
|
|
286
|
-
* uses the Upstash protocol, because a backend that differed between the two
|
|
287
|
-
* would be worse than a slower one.
|
|
288
|
-
*/
|
|
289
|
-
function cacheBackendFor(on) {
|
|
290
|
-
return require_ready.DEFAULT_CACHE[on];
|
|
291
|
-
}
|
|
292
|
-
/** Where a declared bucket lives on a target. */
|
|
293
|
-
function storageBackendFor(on) {
|
|
294
|
-
return require_ready.DEFAULT_STORAGE[on];
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Which broker carries declared queues and topics on a target.
|
|
298
|
-
*
|
|
299
|
-
* Only consulted when something declares one; a project with no `Topic` or
|
|
300
|
-
* `Queue` has no events at all, whatever the target.
|
|
301
|
-
*/
|
|
302
|
-
function eventsBackendFor(on) {
|
|
303
|
-
return require_ready.DEFAULT_EVENTS[on];
|
|
304
|
-
}
|
|
305
|
-
//#endregion
|
|
306
253
|
//#region src/reconcile/containers.ts
|
|
307
254
|
/**
|
|
308
255
|
* What gkm knows about each container it can derive.
|
|
@@ -362,7 +309,8 @@ const PORTS = {
|
|
|
362
309
|
}, {
|
|
363
310
|
key: "minio-console",
|
|
364
311
|
inside: 9001,
|
|
365
|
-
label: "minio console"
|
|
312
|
+
label: "minio console",
|
|
313
|
+
web: true
|
|
366
314
|
}],
|
|
367
315
|
mailpit: [{
|
|
368
316
|
key: "mailpit",
|
|
@@ -371,7 +319,8 @@ const PORTS = {
|
|
|
371
319
|
}, {
|
|
372
320
|
key: "mailpit-web",
|
|
373
321
|
inside: 8025,
|
|
374
|
-
label: "mailpit inbox"
|
|
322
|
+
label: "mailpit inbox",
|
|
323
|
+
web: true
|
|
375
324
|
}],
|
|
376
325
|
redis: [{
|
|
377
326
|
key: "redis",
|
|
@@ -390,7 +339,8 @@ const PORTS = {
|
|
|
390
339
|
}, {
|
|
391
340
|
key: "rabbitmq-management",
|
|
392
341
|
inside: 15672,
|
|
393
|
-
label: "rabbitmq console"
|
|
342
|
+
label: "rabbitmq console",
|
|
343
|
+
web: true
|
|
394
344
|
}],
|
|
395
345
|
localstack: [{
|
|
396
346
|
key: "localstack",
|
|
@@ -422,6 +372,29 @@ function portsOf(container, fakes = {}) {
|
|
|
422
372
|
}];
|
|
423
373
|
return PORTS[container] ?? [];
|
|
424
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
|
+
}
|
|
425
398
|
/** The key a container's primary port is allocated under. */
|
|
426
399
|
function primaryPortKey(container) {
|
|
427
400
|
return portsOf(container)[0]?.key ?? container;
|
|
@@ -747,6 +720,7 @@ const CACHE_CONTAINERS = {
|
|
|
747
720
|
const CONTAINERLESS = {
|
|
748
721
|
secret: true,
|
|
749
722
|
credential: true,
|
|
723
|
+
encryption: true,
|
|
750
724
|
"rest-api": true,
|
|
751
725
|
site: true,
|
|
752
726
|
"mobile-app": true,
|
|
@@ -1211,6 +1185,7 @@ function workerBroker(plan, ports) {
|
|
|
1211
1185
|
*/
|
|
1212
1186
|
function urlFor(resource, plan, ports, project, addresses = {}) {
|
|
1213
1187
|
if (resource.kind === "secret") return localSecret(project, plan, resource);
|
|
1188
|
+
if (resource.kind === "encryption") return localKeyring(project, plan, resource);
|
|
1214
1189
|
if (resource.kind === "mobile-app") return (0, _geekmidas_manifest.schemeBase)(project, resource.scheme);
|
|
1215
1190
|
if (resource.kind === "credential") return void 0;
|
|
1216
1191
|
if (resource.kind === "external-api") {
|
|
@@ -1386,6 +1361,24 @@ var UnprovisionedEventsBackend = class extends Error {
|
|
|
1386
1361
|
}
|
|
1387
1362
|
};
|
|
1388
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
|
+
/**
|
|
1389
1382
|
* The value a secret resolves to locally.
|
|
1390
1383
|
*
|
|
1391
1384
|
* A hash of what identifies it, so it is stable, distinct per project, stage
|
|
@@ -2717,7 +2710,7 @@ async function reconcile(options) {
|
|
|
2717
2710
|
caddyfile,
|
|
2718
2711
|
postgres: postgresStatements(plan, project).map((statement) => statement.create).join(";\n")
|
|
2719
2712
|
});
|
|
2720
|
-
const
|
|
2713
|
+
const services = serviceAddresses(plan.containers, ports, plan.fakes);
|
|
2721
2714
|
const lan = plan.resources.some((r) => r.kind === "mobile-app") ? options.lanAddress === void 0 ? lanAddress() : options.lanAddress ?? void 0 : void 0;
|
|
2722
2715
|
const env = envFor(plan, {
|
|
2723
2716
|
ports,
|
|
@@ -2733,7 +2726,7 @@ async function reconcile(options) {
|
|
|
2733
2726
|
plan,
|
|
2734
2727
|
compose,
|
|
2735
2728
|
ports,
|
|
2736
|
-
|
|
2729
|
+
services,
|
|
2737
2730
|
env,
|
|
2738
2731
|
provisioned: [],
|
|
2739
2732
|
fakes: options.fakes ?? {},
|
|
@@ -2805,20 +2798,6 @@ async function observedPorts(docker, composePath, containers, fakes) {
|
|
|
2805
2798
|
}
|
|
2806
2799
|
return observed;
|
|
2807
2800
|
}
|
|
2808
|
-
/**
|
|
2809
|
-
* Where each container can be reached on this machine.
|
|
2810
|
-
*
|
|
2811
|
-
* The primary port only — a container's console is for a human to open, not
|
|
2812
|
-
* something an app connects to.
|
|
2813
|
-
*/
|
|
2814
|
-
function addressesFor(containers, ports) {
|
|
2815
|
-
const addresses = {};
|
|
2816
|
-
for (const container of containers) {
|
|
2817
|
-
const port = ports[primaryPortKey(container)];
|
|
2818
|
-
if (port !== void 0) addresses[container] = `localhost:${port}`;
|
|
2819
|
-
}
|
|
2820
|
-
return addresses;
|
|
2821
|
-
}
|
|
2822
2801
|
/** Write a file only when its content would change, so mtimes stay meaningful. */
|
|
2823
2802
|
/**
|
|
2824
2803
|
* Remove the routes of stages this project no longer reconciles.
|
|
@@ -2875,10 +2854,10 @@ function constructGlobs(workspace) {
|
|
|
2875
2854
|
}
|
|
2876
2855
|
/** The backends a workspace's target implies, as the plan takes them. */
|
|
2877
2856
|
function backendsOf(workspace) {
|
|
2878
|
-
const on = providerOf(workspace);
|
|
2857
|
+
const on = require_backends.providerOf(workspace);
|
|
2879
2858
|
return {
|
|
2880
|
-
events: eventsBackendFor(on),
|
|
2881
|
-
cache: cacheBackendFor(on)
|
|
2859
|
+
events: require_backends.eventsBackendFor(on),
|
|
2860
|
+
cache: require_backends.cacheBackendFor(on)
|
|
2882
2861
|
};
|
|
2883
2862
|
}
|
|
2884
2863
|
/**
|
|
@@ -3021,12 +3000,6 @@ Object.defineProperty(exports, "backendsOf", {
|
|
|
3021
3000
|
return backendsOf;
|
|
3022
3001
|
}
|
|
3023
3002
|
});
|
|
3024
|
-
Object.defineProperty(exports, "cacheBackendFor", {
|
|
3025
|
-
enumerable: true,
|
|
3026
|
-
get: function() {
|
|
3027
|
-
return cacheBackendFor;
|
|
3028
|
-
}
|
|
3029
|
-
});
|
|
3030
3003
|
Object.defineProperty(exports, "constructGlobs", {
|
|
3031
3004
|
enumerable: true,
|
|
3032
3005
|
get: function() {
|
|
@@ -3051,10 +3024,10 @@ Object.defineProperty(exports, "derivedContainers", {
|
|
|
3051
3024
|
return derivedContainers;
|
|
3052
3025
|
}
|
|
3053
3026
|
});
|
|
3054
|
-
Object.defineProperty(exports, "
|
|
3027
|
+
Object.defineProperty(exports, "describeServices", {
|
|
3055
3028
|
enumerable: true,
|
|
3056
3029
|
get: function() {
|
|
3057
|
-
return
|
|
3030
|
+
return describeServices;
|
|
3058
3031
|
}
|
|
3059
3032
|
});
|
|
3060
3033
|
Object.defineProperty(exports, "fakeKey", {
|
|
@@ -3117,12 +3090,6 @@ Object.defineProperty(exports, "primaryPortKey", {
|
|
|
3117
3090
|
return primaryPortKey;
|
|
3118
3091
|
}
|
|
3119
3092
|
});
|
|
3120
|
-
Object.defineProperty(exports, "providerOf", {
|
|
3121
|
-
enumerable: true,
|
|
3122
|
-
get: function() {
|
|
3123
|
-
return providerOf;
|
|
3124
|
-
}
|
|
3125
|
-
});
|
|
3126
3093
|
Object.defineProperty(exports, "quoteIdentifier", {
|
|
3127
3094
|
enumerable: true,
|
|
3128
3095
|
get: function() {
|
|
@@ -3147,12 +3114,6 @@ Object.defineProperty(exports, "rootSite", {
|
|
|
3147
3114
|
return rootSite;
|
|
3148
3115
|
}
|
|
3149
3116
|
});
|
|
3150
|
-
Object.defineProperty(exports, "storageBackendFor", {
|
|
3151
|
-
enumerable: true,
|
|
3152
|
-
get: function() {
|
|
3153
|
-
return storageBackendFor;
|
|
3154
|
-
}
|
|
3155
|
-
});
|
|
3156
3117
|
Object.defineProperty(exports, "workspace_exports", {
|
|
3157
3118
|
enumerable: true,
|
|
3158
3119
|
get: function() {
|
|
@@ -3160,4 +3121,4 @@ Object.defineProperty(exports, "workspace_exports", {
|
|
|
3160
3121
|
}
|
|
3161
3122
|
});
|
|
3162
3123
|
|
|
3163
|
-
//# sourceMappingURL=workspace-
|
|
3124
|
+
//# sourceMappingURL=workspace-vafrzZTC.cjs.map
|