@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.
- package/README.md +144 -183
- package/dist/{OpenApiTsGenerator-B4Kj_qNU.cjs → OpenApiTsGenerator-BN0PIZxd.cjs} +17 -71
- package/dist/OpenApiTsGenerator-BN0PIZxd.cjs.map +1 -0
- package/dist/{OpenApiTsGenerator-CEh3EKN3.mjs → OpenApiTsGenerator-BzIGy8KE.mjs} +17 -71
- package/dist/OpenApiTsGenerator-BzIGy8KE.mjs.map +1 -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/{config-CJ-PAb7M.cjs → config-CsYSyUya.cjs} +3 -3
- package/dist/{config-CJ-PAb7M.cjs.map → config-CsYSyUya.cjs.map} +1 -1
- package/dist/{config-5watB1D0.mjs → config-D8J5rrTb.mjs} +3 -3
- package/dist/{config-5watB1D0.mjs.map → config-D8J5rrTb.mjs.map} +1 -1
- package/dist/config.cjs +2 -2
- package/dist/config.d.cts +2 -2
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +2 -2
- package/dist/{discover-BLhf7V_J.mjs → discover-Cf2jAcgF.mjs} +4 -56
- package/dist/discover-Cf2jAcgF.mjs.map +1 -0
- package/dist/{discover-B0f_kuNN.cjs → discover-DXNviAh-.cjs} +3 -79
- package/dist/discover-DXNviAh-.cjs.map +1 -0
- package/dist/{emit-Bzq7JsMP.mjs → emit-C1e8qD08.mjs} +12 -43
- package/dist/emit-C1e8qD08.mjs.map +1 -0
- package/dist/{emit-BdoPFjZf.cjs → emit-Dmc1nvdS.cjs} +11 -54
- package/dist/emit-Dmc1nvdS.cjs.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/{github-D5MthUlR.mjs → github-BfpadQWQ.mjs} +3 -3
- package/dist/{github-D5MthUlR.mjs.map → github-BfpadQWQ.mjs.map} +1 -1
- package/dist/{github-BAr8WGkR.cjs → github-BrI1tv6u.cjs} +3 -3
- package/dist/{github-BAr8WGkR.cjs.map → github-BrI1tv6u.cjs.map} +1 -1
- package/dist/{index-B3PeGOQp.d.cts → index-BQhJXpaQ.d.mts} +2 -2
- package/dist/{index-B3PeGOQp.d.cts.map → index-BQhJXpaQ.d.mts.map} +1 -1
- package/dist/{index-BOyaGcCm.d.mts → index-DHJePE0y.d.cts} +2 -2
- package/dist/{index-BOyaGcCm.d.mts.map → index-DHJePE0y.d.cts.map} +1 -1
- package/dist/index.cjs +444 -670
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +442 -668
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-PJi4b1ga.cjs → migrate-BgEY9pdP.cjs} +5 -5
- package/dist/{migrate-PJi4b1ga.cjs.map → migrate-BgEY9pdP.cjs.map} +1 -1
- package/dist/{migrate-BRklCm7b.mjs → migrate-DhxTIA0z.mjs} +5 -5
- package/dist/{migrate-BRklCm7b.mjs.map → migrate-DhxTIA0z.mjs.map} +1 -1
- package/dist/openapi.cjs +2 -2
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +2 -2
- package/dist/{ready-ZqOuNvKD.mjs → ready-WfT-eWlm.mjs} +50 -8
- package/dist/ready-WfT-eWlm.mjs.map +1 -0
- package/dist/{ready-3RfHxdA0.cjs → ready-lr2Fm-ep.cjs} +68 -8
- package/dist/ready-lr2Fm-ep.cjs.map +1 -0
- package/dist/reconcile/public.cjs +2 -4
- package/dist/reconcile/public.d.cts +6 -10
- package/dist/reconcile/public.d.cts.map +1 -1
- package/dist/reconcile/public.d.mts +6 -10
- package/dist/reconcile/public.d.mts.map +1 -1
- package/dist/reconcile/public.mjs +3 -3
- package/dist/{types-0R124hrY.d.mts → types-BbrNu83u.d.mts} +14 -109
- package/dist/{types-0R124hrY.d.mts.map → types-BbrNu83u.d.mts.map} +1 -1
- package/dist/{types-DfdYe31u.d.cts → types-DNqEsctD.d.cts} +14 -109
- package/dist/{types-DfdYe31u.d.cts.map → types-DNqEsctD.d.cts.map} +1 -1
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-RYSYtHP7.cjs → workspace-DEibcoBe.cjs} +11 -25
- package/dist/{workspace-RYSYtHP7.cjs.map → workspace-DEibcoBe.cjs.map} +1 -1
- package/dist/{workspace-DOmIhiau.mjs → workspace-DNzWgM1J.mjs} +11 -25
- package/dist/{workspace-DOmIhiau.mjs.map → workspace-DNzWgM1J.mjs.map} +1 -1
- package/dist/{workspace-BKytVCzb.mjs → workspace-cb6U29EL.mjs} +59 -81
- package/dist/workspace-cb6U29EL.mjs.map +1 -0
- package/dist/{workspace-dV6f-3vv.cjs → workspace-vafrzZTC.cjs} +65 -105
- package/dist/workspace-vafrzZTC.cjs.map +1 -0
- package/package.json +14 -14
- package/dist/OpenApiTsGenerator-B4Kj_qNU.cjs.map +0 -1
- package/dist/OpenApiTsGenerator-CEh3EKN3.mjs.map +0 -1
- package/dist/discover-B0f_kuNN.cjs.map +0 -1
- package/dist/discover-BLhf7V_J.mjs.map +0 -1
- package/dist/emit-BdoPFjZf.cjs.map +0 -1
- package/dist/emit-Bzq7JsMP.mjs.map +0 -1
- package/dist/ready-3RfHxdA0.cjs.map +0 -1
- package/dist/ready-ZqOuNvKD.mjs.map +0 -1
- package/dist/workspace-BKytVCzb.mjs.map +0 -1
- package/dist/workspace-dV6f-3vv.cjs.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { c as loadWorkspaceAppInfo, f as appKey, l as loadWorkspaceConfig, r as NotInAnApp, t as ConfigNotFound } from "./config-
|
|
4
|
-
import { E as TEST_STAGE, t as allConstructGlobs } from "./workspace-
|
|
2
|
+
import { t as discover } from "./discover-Cf2jAcgF.mjs";
|
|
3
|
+
import { c as loadWorkspaceAppInfo, f as appKey, l as loadWorkspaceConfig, r as NotInAnApp, t as ConfigNotFound } from "./config-D8J5rrTb.mjs";
|
|
4
|
+
import { E as TEST_STAGE, t as allConstructGlobs } from "./workspace-DNzWgM1J.mjs";
|
|
5
5
|
import { i as toEmbeddableSecrets } from "./storage-BzaUxmqe.mjs";
|
|
6
6
|
import { i as FileSecretsStore, n as secretsStoreFor } from "./store-DeGATCS-.mjs";
|
|
7
|
-
import { l as readFakes } from "./ready-
|
|
7
|
+
import { l as readFakes, u as DEFAULT_CACHE } from "./ready-WfT-eWlm.mjs";
|
|
8
|
+
import { n as eventsBackendFor, r as providerOf, t as cacheBackendFor } from "./backends-CSuLl0YP.mjs";
|
|
8
9
|
import { existsSync } from "node:fs";
|
|
9
10
|
import { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
10
11
|
import { networkInterfaces } from "node:os";
|
|
@@ -14,6 +15,7 @@ import { DEFAULT_POSTGRES_VERSION, cacheTable, cookieDomain, dependenciesOf, dep
|
|
|
14
15
|
import { createServer } from "node:net";
|
|
15
16
|
import { config } from "dotenv";
|
|
16
17
|
import { createHash } from "node:crypto";
|
|
18
|
+
import { formatKeyring } from "@geekmidas/constructs/encryption";
|
|
17
19
|
import { ownerRole, readerRole, roleStatements } from "@geekmidas/db/pg/roles";
|
|
18
20
|
import * as snsUrl from "@geekmidas/events/sns/url";
|
|
19
21
|
import * as sqsUrl from "@geekmidas/events/sqs/url";
|
|
@@ -246,62 +248,6 @@ async function prepareEntryCredentials(options) {
|
|
|
246
248
|
};
|
|
247
249
|
}
|
|
248
250
|
//#endregion
|
|
249
|
-
//#region src/workspace/backends.ts
|
|
250
|
-
/**
|
|
251
|
-
* Which backend each declared kind resolves to — decided by where the project
|
|
252
|
-
* deploys, and by nothing else.
|
|
253
|
-
*
|
|
254
|
-
* These used to be read out of a `services:` block, where one key answered two
|
|
255
|
-
* questions: *does this exist* and *what backs it*. The first is the manifest's
|
|
256
|
-
* — a declared `Cache` is why there is a cache — and the second is the deploy
|
|
257
|
-
* target's, because the right cache for a Lambda is not the right cache for a
|
|
258
|
-
* box already running Postgres. With both answered elsewhere there was nothing
|
|
259
|
-
* left for the block to say, so it is gone and these read the target.
|
|
260
|
-
*
|
|
261
|
-
* Mail has no answer here at all: every provider speaks SMTP, so the provider
|
|
262
|
-
* is whichever one the stage's mail URL points at.
|
|
263
|
-
*/
|
|
264
|
-
/**
|
|
265
|
-
* Which family of defaults a workspace's deploy target belongs to.
|
|
266
|
-
*
|
|
267
|
-
* One question, asked once: **does this target run containers the project
|
|
268
|
-
* controls?** Dokploy and a bare server do, so a bucket or a cache can live
|
|
269
|
-
* beside the app; AWS, Vercel and Cloudflare do not, so the default has to be
|
|
270
|
-
* something managed. That is the whole of the distinction, and it is why
|
|
271
|
-
* `MainProvider` is the right axis rather than the deploy target's own name —
|
|
272
|
-
* three targets share one answer.
|
|
273
|
-
*
|
|
274
|
-
* An AWS deploy names no `deploy.default` at all, because it goes through SST,
|
|
275
|
-
* which is why the absence is what selects `aws`.
|
|
276
|
-
*/
|
|
277
|
-
function providerOf(workspace) {
|
|
278
|
-
const target = workspace.deploy?.default;
|
|
279
|
-
return target === "dokploy" || target === "server" ? "server" : "aws";
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* The cache backend a target implies.
|
|
283
|
-
*
|
|
284
|
-
* The same answer locally and deployed: a local `gkm dev` for an AWS app still
|
|
285
|
-
* uses the Upstash protocol, because a backend that differed between the two
|
|
286
|
-
* would be worse than a slower one.
|
|
287
|
-
*/
|
|
288
|
-
function cacheBackendFor(on) {
|
|
289
|
-
return DEFAULT_CACHE[on];
|
|
290
|
-
}
|
|
291
|
-
/** Where a declared bucket lives on a target. */
|
|
292
|
-
function storageBackendFor(on) {
|
|
293
|
-
return DEFAULT_STORAGE[on];
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Which broker carries declared queues and topics on a target.
|
|
297
|
-
*
|
|
298
|
-
* Only consulted when something declares one; a project with no `Topic` or
|
|
299
|
-
* `Queue` has no events at all, whatever the target.
|
|
300
|
-
*/
|
|
301
|
-
function eventsBackendFor(on) {
|
|
302
|
-
return DEFAULT_EVENTS$1[on];
|
|
303
|
-
}
|
|
304
|
-
//#endregion
|
|
305
251
|
//#region src/reconcile/containers.ts
|
|
306
252
|
/**
|
|
307
253
|
* What gkm knows about each container it can derive.
|
|
@@ -361,7 +307,8 @@ const PORTS = {
|
|
|
361
307
|
}, {
|
|
362
308
|
key: "minio-console",
|
|
363
309
|
inside: 9001,
|
|
364
|
-
label: "minio console"
|
|
310
|
+
label: "minio console",
|
|
311
|
+
web: true
|
|
365
312
|
}],
|
|
366
313
|
mailpit: [{
|
|
367
314
|
key: "mailpit",
|
|
@@ -370,7 +317,8 @@ const PORTS = {
|
|
|
370
317
|
}, {
|
|
371
318
|
key: "mailpit-web",
|
|
372
319
|
inside: 8025,
|
|
373
|
-
label: "mailpit inbox"
|
|
320
|
+
label: "mailpit inbox",
|
|
321
|
+
web: true
|
|
374
322
|
}],
|
|
375
323
|
redis: [{
|
|
376
324
|
key: "redis",
|
|
@@ -389,7 +337,8 @@ const PORTS = {
|
|
|
389
337
|
}, {
|
|
390
338
|
key: "rabbitmq-management",
|
|
391
339
|
inside: 15672,
|
|
392
|
-
label: "rabbitmq console"
|
|
340
|
+
label: "rabbitmq console",
|
|
341
|
+
web: true
|
|
393
342
|
}],
|
|
394
343
|
localstack: [{
|
|
395
344
|
key: "localstack",
|
|
@@ -421,6 +370,29 @@ function portsOf(container, fakes = {}) {
|
|
|
421
370
|
}];
|
|
422
371
|
return PORTS[container] ?? [];
|
|
423
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Every port the containers publish — not only the one an app connects to.
|
|
375
|
+
*
|
|
376
|
+
* The consoles and the inbox are most of why these are real containers, and an
|
|
377
|
+
* inbox nobody can find is an inbox nobody opens: a sign-in link gets fished
|
|
378
|
+
* out of `docker ps` instead.
|
|
379
|
+
*/
|
|
380
|
+
function serviceAddresses(containers, ports, fakes = {}) {
|
|
381
|
+
return containers.flatMap((container) => portsOf(container, fakes).flatMap((port) => {
|
|
382
|
+
const assigned = ports[port.key];
|
|
383
|
+
if (assigned === void 0) return [];
|
|
384
|
+
return [{
|
|
385
|
+
container,
|
|
386
|
+
label: port.label,
|
|
387
|
+
address: port.web ? `http://localhost:${assigned}` : `localhost:${assigned}`
|
|
388
|
+
}];
|
|
389
|
+
}));
|
|
390
|
+
}
|
|
391
|
+
/** The lines `gkm dev` and `gkm setup` print under the services heading. */
|
|
392
|
+
function describeServices(services) {
|
|
393
|
+
const width = Math.max(0, ...services.map(({ label }) => label.length));
|
|
394
|
+
return services.map(({ label, address }) => ` ${label.padEnd(width)} ${address}`);
|
|
395
|
+
}
|
|
424
396
|
/** The key a container's primary port is allocated under. */
|
|
425
397
|
function primaryPortKey(container) {
|
|
426
398
|
return portsOf(container)[0]?.key ?? container;
|
|
@@ -746,6 +718,7 @@ const CACHE_CONTAINERS = {
|
|
|
746
718
|
const CONTAINERLESS = {
|
|
747
719
|
secret: true,
|
|
748
720
|
credential: true,
|
|
721
|
+
encryption: true,
|
|
749
722
|
"rest-api": true,
|
|
750
723
|
site: true,
|
|
751
724
|
"mobile-app": true,
|
|
@@ -1210,6 +1183,7 @@ function workerBroker(plan, ports) {
|
|
|
1210
1183
|
*/
|
|
1211
1184
|
function urlFor(resource, plan, ports, project, addresses = {}) {
|
|
1212
1185
|
if (resource.kind === "secret") return localSecret(project, plan, resource);
|
|
1186
|
+
if (resource.kind === "encryption") return localKeyring(project, plan, resource);
|
|
1213
1187
|
if (resource.kind === "mobile-app") return schemeBase(project, resource.scheme);
|
|
1214
1188
|
if (resource.kind === "credential") return void 0;
|
|
1215
1189
|
if (resource.kind === "external-api") {
|
|
@@ -1385,6 +1359,24 @@ var UnprovisionedEventsBackend = class extends Error {
|
|
|
1385
1359
|
}
|
|
1386
1360
|
};
|
|
1387
1361
|
/**
|
|
1362
|
+
* The keyring an `Encryption` construct resolves to locally.
|
|
1363
|
+
*
|
|
1364
|
+
* Derived like a secret — stable across restarts, distinct per project, stage
|
|
1365
|
+
* and construct, never written to disk — so what `gkm dev` encrypted yesterday
|
|
1366
|
+
* still opens today. One key, because nothing local is worth rotating: a
|
|
1367
|
+
* server stage's keyring is generated and rotated in its secrets instead.
|
|
1368
|
+
*/
|
|
1369
|
+
function localKeyring(project, plan, resource) {
|
|
1370
|
+
const derive = (purpose) => createHash("sha256").update(`${project}:${plan.stage}:${resource.id}:${purpose}`).digest();
|
|
1371
|
+
return formatKeyring({
|
|
1372
|
+
keys: [{
|
|
1373
|
+
id: "k1",
|
|
1374
|
+
key: derive("k1")
|
|
1375
|
+
}],
|
|
1376
|
+
index: derive("index")
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1388
1380
|
* The value a secret resolves to locally.
|
|
1389
1381
|
*
|
|
1390
1382
|
* A hash of what identifies it, so it is stable, distinct per project, stage
|
|
@@ -2716,7 +2708,7 @@ async function reconcile(options) {
|
|
|
2716
2708
|
caddyfile,
|
|
2717
2709
|
postgres: postgresStatements(plan, project).map((statement) => statement.create).join(";\n")
|
|
2718
2710
|
});
|
|
2719
|
-
const
|
|
2711
|
+
const services = serviceAddresses(plan.containers, ports, plan.fakes);
|
|
2720
2712
|
const lan = plan.resources.some((r) => r.kind === "mobile-app") ? options.lanAddress === void 0 ? lanAddress() : options.lanAddress ?? void 0 : void 0;
|
|
2721
2713
|
const env = envFor(plan, {
|
|
2722
2714
|
ports,
|
|
@@ -2732,7 +2724,7 @@ async function reconcile(options) {
|
|
|
2732
2724
|
plan,
|
|
2733
2725
|
compose,
|
|
2734
2726
|
ports,
|
|
2735
|
-
|
|
2727
|
+
services,
|
|
2736
2728
|
env,
|
|
2737
2729
|
provisioned: [],
|
|
2738
2730
|
fakes: options.fakes ?? {},
|
|
@@ -2804,20 +2796,6 @@ async function observedPorts(docker, composePath, containers, fakes) {
|
|
|
2804
2796
|
}
|
|
2805
2797
|
return observed;
|
|
2806
2798
|
}
|
|
2807
|
-
/**
|
|
2808
|
-
* Where each container can be reached on this machine.
|
|
2809
|
-
*
|
|
2810
|
-
* The primary port only — a container's console is for a human to open, not
|
|
2811
|
-
* something an app connects to.
|
|
2812
|
-
*/
|
|
2813
|
-
function addressesFor(containers, ports) {
|
|
2814
|
-
const addresses = {};
|
|
2815
|
-
for (const container of containers) {
|
|
2816
|
-
const port = ports[primaryPortKey(container)];
|
|
2817
|
-
if (port !== void 0) addresses[container] = `localhost:${port}`;
|
|
2818
|
-
}
|
|
2819
|
-
return addresses;
|
|
2820
|
-
}
|
|
2821
2799
|
/** Write a file only when its content would change, so mtimes stay meaningful. */
|
|
2822
2800
|
/**
|
|
2823
2801
|
* Remove the routes of stages this project no longer reconciles.
|
|
@@ -2990,6 +2968,6 @@ function localAddress(port) {
|
|
|
2990
2968
|
return `http://localhost:${port}`;
|
|
2991
2969
|
}
|
|
2992
2970
|
//#endregion
|
|
2993
|
-
export {
|
|
2971
|
+
export { loadEnvFiles as C, isPortAvailable as S, prepareEntryCredentials as T, fakeKey as _, reconcileWorkspace as a, createEntryWrapper as b, LOCAL_CA_PATH as c, postgresDatabaseNames as d, quoteIdentifier as f, describeServices as g, rootSite as h, derivedContainers as i, forgetState as l, resourceName as m, backendsOf as n, workspace_exports as o, pgClient as p, constructGlobs as r, COMPOSE_PATH as s, FAKE_ENV as t, applyPostgres as u, primaryPortKey as v, loadSecretsForApp as w, findAvailablePort as x, createCredentialsPreload as y };
|
|
2994
2972
|
|
|
2995
|
-
//# sourceMappingURL=workspace-
|
|
2973
|
+
//# sourceMappingURL=workspace-cb6U29EL.mjs.map
|