@geekmidas/cli 10.0.0-alpha.36 → 10.0.0-alpha.38
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/dist/{HostingerProvider-GF6NAZAK.mjs → HostingerProvider-Bh6K7QYz.mjs} +2 -2
- package/dist/{HostingerProvider-GF6NAZAK.mjs.map → HostingerProvider-Bh6K7QYz.mjs.map} +1 -1
- package/dist/{ssm-FxeSAt35.cjs → aws-DkHdTV-p.cjs} +7 -6
- package/dist/aws-DkHdTV-p.cjs.map +1 -0
- package/dist/{ssm-BKN1Cg4z.mjs → aws-DojzQnLd.mjs} +7 -6
- package/dist/aws-DojzQnLd.mjs.map +1 -0
- package/dist/{bundler-D9IPNvDt.mjs → bundler--fyybf1N.mjs} +13 -7
- package/dist/bundler--fyybf1N.mjs.map +1 -0
- package/dist/{bundler-CYF5mWi9.cjs → bundler-By6_sXiL.cjs} +12 -6
- package/dist/bundler-By6_sXiL.cjs.map +1 -0
- package/dist/{config-Dss1WwtH.mjs → config-D1S2r0JN.mjs} +93 -70
- package/dist/config-D1S2r0JN.mjs.map +1 -0
- package/dist/{config-DgAHy8nY.cjs → config-j4krJZVq.cjs} +114 -73
- package/dist/config-j4krJZVq.cjs.map +1 -0
- package/dist/config.cjs +6 -3
- package/dist/config.d.cts +40 -19
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +40 -19
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +3 -3
- package/dist/{github-C99BMxf0.mjs → github-BPfmXtqk.mjs} +8 -11
- package/dist/github-BPfmXtqk.mjs.map +1 -0
- package/dist/{github-tZmMZ7td.cjs → github-BvK076ph.cjs} +10 -13
- package/dist/github-BvK076ph.cjs.map +1 -0
- package/dist/{index-DxXMtQNT.d.mts → index-CLH1DgsO.d.cts} +2 -2
- package/dist/{index-CAp22ul5.d.cts.map → index-CLH1DgsO.d.cts.map} +1 -1
- package/dist/{index-CAp22ul5.d.cts → index-CST2jOPH.d.mts} +2 -2
- package/dist/{index-DxXMtQNT.d.mts.map → index-CST2jOPH.d.mts.map} +1 -1
- package/dist/index.cjs +1071 -338
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1059 -326
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-CT8b3nt_.mjs → migrate-C2aYSZTn.mjs} +8 -6
- package/dist/migrate-C2aYSZTn.mjs.map +1 -0
- package/dist/{migrate-BsW4xBEO.cjs → migrate-DKn83skp.cjs} +7 -5
- package/dist/migrate-DKn83skp.cjs.map +1 -0
- package/dist/openapi.cjs +1 -1
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +1 -1
- package/dist/{ready-D1BCiaYU.mjs → ready-BTm_sMNU.mjs} +90 -6
- package/dist/ready-BTm_sMNU.mjs.map +1 -0
- package/dist/{ready-CXhoutix.cjs → ready-DxC0Z3No.cjs} +94 -4
- package/dist/ready-DxC0Z3No.cjs.map +1 -0
- package/dist/reconcile/public.d.cts +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/reconcile--I7V4Klj.mjs +34 -0
- package/dist/reconcile--I7V4Klj.mjs.map +1 -0
- package/dist/reconcile-CuCQBa5-.cjs +34 -0
- package/dist/reconcile-CuCQBa5-.cjs.map +1 -0
- package/dist/storage-BzaUxmqe.mjs +124 -0
- package/dist/storage-BzaUxmqe.mjs.map +1 -0
- package/dist/storage-CSGoC3bK.cjs +152 -0
- package/dist/storage-CSGoC3bK.cjs.map +1 -0
- package/dist/store-DQgxT_WR.cjs +211 -0
- package/dist/store-DQgxT_WR.cjs.map +1 -0
- package/dist/store-DeGATCS-.mjs +182 -0
- package/dist/store-DeGATCS-.mjs.map +1 -0
- package/dist/{types-BTiu5kwo.d.mts → types-B0EVAF6U.d.mts} +24 -10
- package/dist/types-B0EVAF6U.d.mts.map +1 -0
- package/dist/{types-Bj_FpeTc.d.cts → types-CHKCUKM0.d.cts} +24 -10
- package/dist/types-CHKCUKM0.d.cts.map +1 -0
- package/dist/vitest.cjs +8 -4
- package/dist/vitest.cjs.map +1 -1
- package/dist/vitest.d.cts +5 -4
- package/dist/vitest.d.cts.map +1 -1
- package/dist/vitest.d.mts +5 -4
- package/dist/vitest.d.mts.map +1 -1
- package/dist/vitest.mjs +8 -4
- package/dist/vitest.mjs.map +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-CsL76tpc.mjs → workspace-DOmIhiau.mjs} +2 -2
- package/dist/{workspace-CsL76tpc.mjs.map → workspace-DOmIhiau.mjs.map} +1 -1
- package/dist/{workspace-EmXwO2qM.mjs → workspace-Lm6dv2nz.mjs} +121 -40
- package/dist/workspace-Lm6dv2nz.mjs.map +1 -0
- package/dist/{workspace-CAJk6UmC.cjs → workspace-RYSYtHP7.cjs} +2 -2
- package/dist/{workspace-CAJk6UmC.cjs.map → workspace-RYSYtHP7.cjs.map} +1 -1
- package/dist/{workspace-C0X8xSXV.cjs → workspace-gfIrSEUp.cjs} +155 -38
- package/dist/workspace-gfIrSEUp.cjs.map +1 -0
- package/package.json +14 -14
- package/dist/bundler-CYF5mWi9.cjs.map +0 -1
- package/dist/bundler-D9IPNvDt.mjs.map +0 -1
- package/dist/config-DgAHy8nY.cjs.map +0 -1
- package/dist/config-Dss1WwtH.mjs.map +0 -1
- package/dist/github-C99BMxf0.mjs.map +0 -1
- package/dist/github-tZmMZ7td.cjs.map +0 -1
- package/dist/migrate-BsW4xBEO.cjs.map +0 -1
- package/dist/migrate-CT8b3nt_.mjs.map +0 -1
- package/dist/ready-CXhoutix.cjs.map +0 -1
- package/dist/ready-D1BCiaYU.mjs.map +0 -1
- package/dist/reconcile-BxZTV2vl.cjs +0 -332
- package/dist/reconcile-BxZTV2vl.cjs.map +0 -1
- package/dist/reconcile-yNq6Shau.mjs +0 -279
- package/dist/reconcile-yNq6Shau.mjs.map +0 -1
- package/dist/ssm-BKN1Cg4z.mjs.map +0 -1
- package/dist/ssm-FxeSAt35.cjs.map +0 -1
- package/dist/storage-BjTLjDDp.mjs +0 -297
- package/dist/storage-BjTLjDDp.mjs.map +0 -1
- package/dist/storage-C2JC31V9.cjs +0 -344
- package/dist/storage-C2JC31V9.cjs.map +0 -1
- package/dist/types-BTiu5kwo.d.mts.map +0 -1
- package/dist/types-Bj_FpeTc.d.cts.map +0 -1
- package/dist/workspace-C0X8xSXV.cjs.map +0 -1
- package/dist/workspace-EmXwO2qM.mjs.map +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
2
2
|
const require_discover = require("./discover-CroTIm0K.cjs");
|
|
3
|
-
const require_config = require("./config-
|
|
4
|
-
const require_workspace = require("./workspace-
|
|
5
|
-
const require_storage = require("./storage-
|
|
3
|
+
const require_config = require("./config-j4krJZVq.cjs");
|
|
4
|
+
const require_workspace = require("./workspace-RYSYtHP7.cjs");
|
|
5
|
+
const require_storage = require("./storage-CSGoC3bK.cjs");
|
|
6
|
+
const require_store = require("./store-DQgxT_WR.cjs");
|
|
7
|
+
const require_ready = require("./ready-DxC0Z3No.cjs");
|
|
6
8
|
let node_fs = require("node:fs");
|
|
7
9
|
let node_fs_promises = require("node:fs/promises");
|
|
8
10
|
let node_os = require("node:os");
|
|
@@ -101,14 +103,12 @@ async function savePortState(workspaceRoot, ports) {
|
|
|
101
103
|
* For workspace app: maps {APP}_DATABASE_URL → DATABASE_URL.
|
|
102
104
|
* @internal Exported for testing
|
|
103
105
|
*/
|
|
104
|
-
async function loadSecretsForApp(
|
|
106
|
+
async function loadSecretsForApp(store, stage, appName) {
|
|
105
107
|
let secrets = {};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
secrets = require_storage.toEmbeddableSecrets(stageSecrets);
|
|
111
|
-
}
|
|
108
|
+
const stageSecrets = await store.read(stage);
|
|
109
|
+
if (stageSecrets) {
|
|
110
|
+
logger.log(`🔐 Loading secrets from stage: ${stage}`);
|
|
111
|
+
secrets = require_storage.toEmbeddableSecrets(stageSecrets);
|
|
112
112
|
}
|
|
113
113
|
if (Object.keys(secrets).length === 0) return {};
|
|
114
114
|
if (!appName) return secrets;
|
|
@@ -202,20 +202,22 @@ async function prepareEntryCredentials(options) {
|
|
|
202
202
|
workspaceAppPort = appInfo.app.port;
|
|
203
203
|
secretsRoot = appInfo.workspaceRoot;
|
|
204
204
|
appName = appInfo.appName;
|
|
205
|
-
} catch {
|
|
205
|
+
} catch (error) {
|
|
206
|
+
if (!(error instanceof require_config.NotInAnApp || error instanceof require_config.ConfigNotFound)) throw error;
|
|
206
207
|
workspace = await require_config.loadWorkspaceConfig(cwd).then((loaded) => loaded.workspace).catch(() => void 0);
|
|
207
208
|
secretsRoot = workspace?.root ?? findSecretsRoot(cwd);
|
|
208
|
-
appName = require_config.getAppNameFromCwd(cwd) ?? void 0;
|
|
209
209
|
}
|
|
210
210
|
const resolvedPort = options.explicitPort ?? workspaceAppPort ?? 3e3;
|
|
211
211
|
const stage = options.stage ?? workspace?.stages.local;
|
|
212
|
-
const
|
|
212
|
+
const store = stage ? workspace ? await require_store.secretsStoreFor(workspace, stage) : new require_store.FileSecretsStore(secretsRoot) : void 0;
|
|
213
|
+
const credentials = store && stage ? await loadSecretsForApp(store, stage, appName) : {};
|
|
213
214
|
credentials.PORT = String(resolvedPort);
|
|
214
215
|
if (appInfo?.app.type === "mobile") credentials.RCT_METRO_PORT = String(resolvedPort);
|
|
215
216
|
const declaredKeys = [];
|
|
217
|
+
let reconciled;
|
|
216
218
|
if (workspace) {
|
|
217
219
|
const { reconcileWorkspace } = await Promise.resolve().then(() => workspace_exports);
|
|
218
|
-
|
|
220
|
+
reconciled = await reconcileWorkspace(workspace, {
|
|
219
221
|
stage: options.reconcileStage ?? workspace.stages.local,
|
|
220
222
|
start: options.startDocker ?? false
|
|
221
223
|
});
|
|
@@ -235,7 +237,8 @@ async function prepareEntryCredentials(options) {
|
|
|
235
237
|
appName,
|
|
236
238
|
secretsRoot,
|
|
237
239
|
appInfo,
|
|
238
|
-
declaredKeys
|
|
240
|
+
declaredKeys,
|
|
241
|
+
...reconciled ? { reconciled } : {}
|
|
239
242
|
};
|
|
240
243
|
}
|
|
241
244
|
//#endregion
|
|
@@ -395,8 +398,23 @@ const PORTS = {
|
|
|
395
398
|
label: "https edge"
|
|
396
399
|
}]
|
|
397
400
|
};
|
|
398
|
-
/** The
|
|
399
|
-
function
|
|
401
|
+
/** The port key — and container name, for an image — of an API's fake. */
|
|
402
|
+
function fakeKey(id) {
|
|
403
|
+
return `${(0, _geekmidas_manifest.kebabCase)(id)}-fake`;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* The ports a container needs published. Empty for one gkm does not know.
|
|
407
|
+
*
|
|
408
|
+
* `fakes` answers for the containers no table can: an external API's fake
|
|
409
|
+
* listens wherever its declaration says.
|
|
410
|
+
*/
|
|
411
|
+
function portsOf(container, fakes = {}) {
|
|
412
|
+
const fake = fakes[container];
|
|
413
|
+
if (fake?.port !== void 0) return [{
|
|
414
|
+
key: container,
|
|
415
|
+
inside: fake.port,
|
|
416
|
+
label: `${fake.id} fake`
|
|
417
|
+
}];
|
|
400
418
|
return PORTS[container] ?? [];
|
|
401
419
|
}
|
|
402
420
|
/** The key a container's primary port is allocated under. */
|
|
@@ -409,8 +427,9 @@ function primaryPortKey(container) {
|
|
|
409
427
|
* What allocation is handed: it assigns ports to names and knows nothing about
|
|
410
428
|
* what listens on them.
|
|
411
429
|
*/
|
|
412
|
-
function portKeys(containers) {
|
|
413
|
-
|
|
430
|
+
function portKeys(containers, fakes = {}) {
|
|
431
|
+
const keys = [...containers].sort().flatMap((container) => portsOf(container, fakes).map((port) => port.key));
|
|
432
|
+
return [.../* @__PURE__ */ new Set([...keys, ...Object.keys(fakes).sort()])];
|
|
414
433
|
}
|
|
415
434
|
/**
|
|
416
435
|
* The named volume a container's data lives in.
|
|
@@ -692,7 +711,8 @@ const CONTAINERLESS = {
|
|
|
692
711
|
credential: true,
|
|
693
712
|
"rest-api": true,
|
|
694
713
|
site: true,
|
|
695
|
-
"mobile-app": true
|
|
714
|
+
"mobile-app": true,
|
|
715
|
+
"external-api": true
|
|
696
716
|
};
|
|
697
717
|
/**
|
|
698
718
|
* Containers that cannot run alone.
|
|
@@ -712,7 +732,7 @@ const REQUIRES = { "redis-http": ["redis"] };
|
|
|
712
732
|
const ROLES = {
|
|
713
733
|
queue: "publisherConnectionString",
|
|
714
734
|
topic: "publisherConnectionString",
|
|
715
|
-
credential: "
|
|
735
|
+
credential: "credentials",
|
|
716
736
|
"mobile-app": "scheme"
|
|
717
737
|
};
|
|
718
738
|
/** The kinds whose container is the events backend's rather than their own. */
|
|
@@ -804,12 +824,25 @@ function containerFor(kind, events = DEFAULT_EVENTS, cache = require_discover.DE
|
|
|
804
824
|
function planFor(manifest, stage, order, options = {}) {
|
|
805
825
|
const containers = /* @__PURE__ */ new Set();
|
|
806
826
|
const resources = [];
|
|
827
|
+
const fakes = {};
|
|
807
828
|
const events = options.events ?? "pgboss";
|
|
808
829
|
const cache = options.cache ?? require_discover.DEFAULT_CACHE.aws;
|
|
809
830
|
for (const id of order) {
|
|
810
831
|
const declaration = manifest[id];
|
|
811
832
|
if (!declaration) continue;
|
|
812
|
-
const
|
|
833
|
+
const local = declaration.kind === "external-api" ? options.fakes?.[id] : void 0;
|
|
834
|
+
const fake = local && {
|
|
835
|
+
key: fakeKey(id),
|
|
836
|
+
...local
|
|
837
|
+
};
|
|
838
|
+
if (fake) fakes[fake.key] = {
|
|
839
|
+
id,
|
|
840
|
+
...fake.image ? {
|
|
841
|
+
image: fake.image,
|
|
842
|
+
port: fake.port
|
|
843
|
+
} : {}
|
|
844
|
+
};
|
|
845
|
+
const container = fake?.image ? fake.key : containerFor(declaration.kind, events, cache, "of" in declaration && typeof declaration.of === "string", options.edge !== false);
|
|
813
846
|
if (!container && !CONTAINERLESS[declaration.kind]) continue;
|
|
814
847
|
if (container) {
|
|
815
848
|
containers.add(container);
|
|
@@ -829,6 +862,11 @@ function planFor(manifest, stage, order, options = {}) {
|
|
|
829
862
|
...declaration.scheme ? { scheme: declaration.scheme } : {}
|
|
830
863
|
} : {},
|
|
831
864
|
...declaration.kind === "file-server" && declaration.open?.length ? { open: declaration.open } : {},
|
|
865
|
+
...fake ? { fake: {
|
|
866
|
+
key: fake.key,
|
|
867
|
+
credentials: fake.credentials
|
|
868
|
+
} } : {},
|
|
869
|
+
...declaration.kind === "external-api" && !fake ? { url: declaration.url } : {},
|
|
832
870
|
..."of" in declaration ? { of: declaration.of } : {},
|
|
833
871
|
..."schema" in declaration && declaration.schema ? { schema: declaration.schema } : {},
|
|
834
872
|
..."version" in declaration && declaration.version ? { version: declaration.version } : {},
|
|
@@ -865,6 +903,7 @@ function planFor(manifest, stage, order, options = {}) {
|
|
|
865
903
|
cache,
|
|
866
904
|
containers: [...containers],
|
|
867
905
|
resources,
|
|
906
|
+
...Object.keys(fakes).length ? { fakes } : {},
|
|
868
907
|
...workerBroker ? { workerBroker: true } : {}
|
|
869
908
|
};
|
|
870
909
|
}
|
|
@@ -988,6 +1027,7 @@ function envFor(plan, options) {
|
|
|
988
1027
|
const owner = ownerUrl(resource, plan, options.ports, options.project ?? "");
|
|
989
1028
|
if (owner) env[(0, _geekmidas_manifest.provideKey)(resource.id, "ownerUrl")] = owner;
|
|
990
1029
|
}
|
|
1030
|
+
if (resource.kind === "external-api" && url && resource.fake) env[(0, _geekmidas_manifest.provideKey)(resource.id, "credentials")] = resource.fake.credentials;
|
|
991
1031
|
if (resource.kind === "email" && url) {
|
|
992
1032
|
env[(0, _geekmidas_manifest.provideKey)(resource.id, "from")] = options.mailFrom ?? `noreply@${LOCAL_HOST}`;
|
|
993
1033
|
const inbox = options.ports[MAILPIT_INBOX_PORT];
|
|
@@ -1137,6 +1177,14 @@ function urlFor(resource, plan, ports, project, addresses = {}) {
|
|
|
1137
1177
|
if (resource.kind === "secret") return localSecret(project, plan, resource);
|
|
1138
1178
|
if (resource.kind === "mobile-app") return (0, _geekmidas_manifest.schemeBase)(project, resource.scheme);
|
|
1139
1179
|
if (resource.kind === "credential") return void 0;
|
|
1180
|
+
if (resource.kind === "external-api") {
|
|
1181
|
+
if (!resource.fake) return resource.url === void 0 ? void 0 : (0, _geekmidas_manifest.externalApiUrl)({
|
|
1182
|
+
id: resource.id,
|
|
1183
|
+
url: resource.url
|
|
1184
|
+
}, plan.stage);
|
|
1185
|
+
const port = ports[resource.fake.key];
|
|
1186
|
+
return port === void 0 ? void 0 : `http://${LOCAL_HOST}:${port}`;
|
|
1187
|
+
}
|
|
1140
1188
|
if (resource.kind === "rest-api" || resource.kind === "site") {
|
|
1141
1189
|
const address = addresses[resource.id];
|
|
1142
1190
|
const edge = plan.containers.includes("caddy") ? ports[primaryPortKey("caddy")] : void 0;
|
|
@@ -1337,20 +1385,21 @@ function dockerfileOf(appName, path) {
|
|
|
1337
1385
|
* two containers listening on the same port inside cannot be confused — and is
|
|
1338
1386
|
* rewritten to `<container>:<inside>`.
|
|
1339
1387
|
*/
|
|
1340
|
-
function inNetworkEnv(workspace, manifest) {
|
|
1388
|
+
function inNetworkEnv(workspace, manifest, fakes = {}) {
|
|
1341
1389
|
const plan = planFor(manifest, workspace.stages.local, (0, _geekmidas_manifest.provisionOrder)(manifest), {
|
|
1342
1390
|
localStage: workspace.stages.local,
|
|
1343
|
-
...backendsOf(workspace)
|
|
1391
|
+
...backendsOf(workspace),
|
|
1392
|
+
fakes
|
|
1344
1393
|
});
|
|
1345
1394
|
const placeholders = {};
|
|
1346
1395
|
const targets = /* @__PURE__ */ new Map();
|
|
1347
1396
|
let next = 49152;
|
|
1348
|
-
for (const container of [...plan.containers].sort()) for (const port of portsOf(container)) {
|
|
1397
|
+
for (const container of [...plan.containers].sort()) for (const port of portsOf(container, plan.fakes)) {
|
|
1349
1398
|
placeholders[port.key] = next;
|
|
1350
1399
|
targets.set(next, `${container}:${port.inside}`);
|
|
1351
1400
|
next += 1;
|
|
1352
1401
|
}
|
|
1353
|
-
for (const key of portKeys(plan.containers)) placeholders[key] ??= next++;
|
|
1402
|
+
for (const key of portKeys(plan.containers, plan.fakes)) placeholders[key] ??= next++;
|
|
1354
1403
|
const env = envFor(plan, {
|
|
1355
1404
|
ports: placeholders,
|
|
1356
1405
|
project: workspace.name,
|
|
@@ -1413,8 +1462,8 @@ function appEnvKeys(manifest, appName, runnables = {}) {
|
|
|
1413
1462
|
return keys;
|
|
1414
1463
|
}
|
|
1415
1464
|
/** One compose service per app the workspace runs, behind the apps profile. */
|
|
1416
|
-
function appServices(workspace, manifest, containers, runnables = {}) {
|
|
1417
|
-
const env = inNetworkEnv(workspace, manifest);
|
|
1465
|
+
function appServices(workspace, manifest, containers, runnables = {}, fakes = {}) {
|
|
1466
|
+
const env = inNetworkEnv(workspace, manifest, fakes);
|
|
1418
1467
|
const services = {};
|
|
1419
1468
|
for (const [name, app] of Object.entries(workspace.apps)) {
|
|
1420
1469
|
if (app.type === "mobile" || !app.port) continue;
|
|
@@ -1568,9 +1617,15 @@ function composeFor(plan, options) {
|
|
|
1568
1617
|
const volumes = {};
|
|
1569
1618
|
for (const container of [...plan.containers].sort()) {
|
|
1570
1619
|
const declared = container === "postgres" ? plan.resources.find((r) => r.version)?.version : void 0;
|
|
1571
|
-
const
|
|
1620
|
+
const fake = plan.fakes?.[container];
|
|
1621
|
+
const image = declared ? postgresImage(declared) : fake?.image ?? DEFAULT_IMAGES[container];
|
|
1572
1622
|
if (!image) throw new UnknownContainer(container);
|
|
1573
|
-
|
|
1623
|
+
const published = publish(container, options.ports, plan.fakes);
|
|
1624
|
+
services[container] = fake ? {
|
|
1625
|
+
image,
|
|
1626
|
+
restart: "unless-stopped",
|
|
1627
|
+
ports: published
|
|
1628
|
+
} : define(container, image, published);
|
|
1574
1629
|
const volume = volumeOf(container);
|
|
1575
1630
|
if (volume) volumes[volume] = {};
|
|
1576
1631
|
}
|
|
@@ -1789,8 +1844,8 @@ function define(container, image, published) {
|
|
|
1789
1844
|
* from the container's first, so MinIO's console cannot land on whatever was
|
|
1790
1845
|
* allocated to the next container.
|
|
1791
1846
|
*/
|
|
1792
|
-
function publish(container, ports) {
|
|
1793
|
-
return portsOf(container).map((port) => {
|
|
1847
|
+
function publish(container, ports, fakes) {
|
|
1848
|
+
return portsOf(container, fakes).map((port) => {
|
|
1794
1849
|
const assigned = ports[port.key];
|
|
1795
1850
|
if (assigned === void 0) throw new UnassignedPort(port.key);
|
|
1796
1851
|
return `${assigned}:${port.inside}`;
|
|
@@ -2395,6 +2450,13 @@ async function saveState(root, state) {
|
|
|
2395
2450
|
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(path), { recursive: true });
|
|
2396
2451
|
await (0, node_fs_promises.writeFile)(path, `${JSON.stringify(state, null, 2)}\n`);
|
|
2397
2452
|
}
|
|
2453
|
+
/**
|
|
2454
|
+
* Forget what was applied, so the next reconcile of this stage converges from
|
|
2455
|
+
* nothing — creating again whatever was dropped underneath the record.
|
|
2456
|
+
*/
|
|
2457
|
+
async function forgetState(root, stage) {
|
|
2458
|
+
await (0, node_fs_promises.rm)(statePath(root, stage), { force: true });
|
|
2459
|
+
}
|
|
2398
2460
|
function statePath(root, stage) {
|
|
2399
2461
|
return (0, node_path.join)(root, STATE_DIR, `${stage}.json`);
|
|
2400
2462
|
}
|
|
@@ -2469,11 +2531,12 @@ async function reconcile(options) {
|
|
|
2469
2531
|
events: options.events,
|
|
2470
2532
|
cache: options.cache,
|
|
2471
2533
|
extraContainers: options.extraContainers,
|
|
2534
|
+
...options.fakes ? { fakes: options.fakes } : {},
|
|
2472
2535
|
...options.edge === void 0 ? {} : { edge: options.edge }
|
|
2473
2536
|
});
|
|
2474
2537
|
const composePath = (0, node_path.join)(root, COMPOSE_PATH);
|
|
2475
|
-
const observed = await observedPorts(docker, composePath, plan.containers);
|
|
2476
|
-
const ports = await allocate(project, portKeys(plan.containers), {
|
|
2538
|
+
const observed = await observedPorts(docker, composePath, plan.containers, plan.fakes);
|
|
2539
|
+
const ports = await allocate(project, portKeys(plan.containers, plan.fakes), {
|
|
2477
2540
|
...options.saved,
|
|
2478
2541
|
...observed
|
|
2479
2542
|
}, probe);
|
|
@@ -2506,6 +2569,7 @@ async function reconcile(options) {
|
|
|
2506
2569
|
addresses,
|
|
2507
2570
|
env,
|
|
2508
2571
|
provisioned: [],
|
|
2572
|
+
fakes: options.fakes ?? {},
|
|
2509
2573
|
hash,
|
|
2510
2574
|
changed: false
|
|
2511
2575
|
};
|
|
@@ -2561,9 +2625,9 @@ async function create(plan, ports, sql, buckets, project) {
|
|
|
2561
2625
|
* Keyed the same way allocation keys them, so the two merge without either
|
|
2562
2626
|
* knowing about the other.
|
|
2563
2627
|
*/
|
|
2564
|
-
async function observedPorts(docker, composePath, containers) {
|
|
2628
|
+
async function observedPorts(docker, composePath, containers, fakes) {
|
|
2565
2629
|
const observed = {};
|
|
2566
|
-
for (const container of containers) for (const port of portsOf(container)) {
|
|
2630
|
+
for (const container of containers) for (const port of portsOf(container, fakes)) {
|
|
2567
2631
|
const running = await docker.publishedPort(composePath, container, port.inside);
|
|
2568
2632
|
if (running !== void 0) observed[port.key] = running;
|
|
2569
2633
|
}
|
|
@@ -2619,9 +2683,11 @@ async function write(path, content) {
|
|
|
2619
2683
|
* same state, differing only in the stage they pass.
|
|
2620
2684
|
*/
|
|
2621
2685
|
var workspace_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
2686
|
+
FAKE_ENV: () => FAKE_ENV,
|
|
2622
2687
|
backendsOf: () => backendsOf,
|
|
2623
2688
|
constructGlobs: () => constructGlobs,
|
|
2624
2689
|
derivedContainers: () => derivedContainers,
|
|
2690
|
+
fakesApply: () => fakesApply,
|
|
2625
2691
|
metroPorts: () => metroPorts,
|
|
2626
2692
|
reconcileWorkspace: () => reconcileWorkspace,
|
|
2627
2693
|
surfaceAddresses: () => surfaceAddresses
|
|
@@ -2664,6 +2730,19 @@ async function derivedContainers(workspace, stage, manifest) {
|
|
|
2664
2730
|
}).containers;
|
|
2665
2731
|
}
|
|
2666
2732
|
/**
|
|
2733
|
+
* Set by `gkm dev --fake` for the apps it starts. Each app's own `gkm dev`
|
|
2734
|
+
* reconciles too, and must answer the way the workspace did.
|
|
2735
|
+
*/
|
|
2736
|
+
const FAKE_ENV = "GKM_FAKE";
|
|
2737
|
+
/**
|
|
2738
|
+
* Whether external APIs are faked: always for `gkm test`, and for `gkm dev`
|
|
2739
|
+
* only when asked — by `--fake`, or by the workspace that started this app
|
|
2740
|
+
* with it. Never for anything acting on a deployed stage.
|
|
2741
|
+
*/
|
|
2742
|
+
function fakesApply(stage, fake, env = process.env) {
|
|
2743
|
+
return fake === true || stage === "test" || env["GKM_FAKE"] === "1";
|
|
2744
|
+
}
|
|
2745
|
+
/**
|
|
2667
2746
|
* Reconcile a workspace for one stage.
|
|
2668
2747
|
*
|
|
2669
2748
|
* Ports are loaded and saved around the call rather than inside it, so the loop
|
|
@@ -2677,6 +2756,7 @@ async function reconcileWorkspace(workspace, options) {
|
|
|
2677
2756
|
runnables
|
|
2678
2757
|
});
|
|
2679
2758
|
const manifest = options.manifest ?? discovered;
|
|
2759
|
+
const fakes = fakesApply(options.stage, options.fake) ? await require_ready.readFakes(workspace.root, manifest) : {};
|
|
2680
2760
|
const result = await reconcile({
|
|
2681
2761
|
root: workspace.root,
|
|
2682
2762
|
project: workspace.name,
|
|
@@ -2687,7 +2767,8 @@ async function reconcileWorkspace(workspace, options) {
|
|
|
2687
2767
|
saved: await loadPortState(workspace.root),
|
|
2688
2768
|
addresses: surfaceAddresses(workspace, manifest),
|
|
2689
2769
|
metroPorts: metroPorts(workspace, manifest),
|
|
2690
|
-
|
|
2770
|
+
fakes,
|
|
2771
|
+
apps: (containers) => appServices(workspace, manifest, containers, runnables, fakes),
|
|
2691
2772
|
...options.start === void 0 ? {} : { start: options.start }
|
|
2692
2773
|
});
|
|
2693
2774
|
await savePortState(workspace.root, { ...result.ports });
|
|
@@ -2744,6 +2825,12 @@ Object.defineProperty(exports, "COMPOSE_PATH", {
|
|
|
2744
2825
|
return COMPOSE_PATH;
|
|
2745
2826
|
}
|
|
2746
2827
|
});
|
|
2828
|
+
Object.defineProperty(exports, "FAKE_ENV", {
|
|
2829
|
+
enumerable: true,
|
|
2830
|
+
get: function() {
|
|
2831
|
+
return FAKE_ENV;
|
|
2832
|
+
}
|
|
2833
|
+
});
|
|
2747
2834
|
Object.defineProperty(exports, "LOCAL_CA_PATH", {
|
|
2748
2835
|
enumerable: true,
|
|
2749
2836
|
get: function() {
|
|
@@ -2798,12 +2885,24 @@ Object.defineProperty(exports, "eventsBackendFor", {
|
|
|
2798
2885
|
return eventsBackendFor;
|
|
2799
2886
|
}
|
|
2800
2887
|
});
|
|
2888
|
+
Object.defineProperty(exports, "fakeKey", {
|
|
2889
|
+
enumerable: true,
|
|
2890
|
+
get: function() {
|
|
2891
|
+
return fakeKey;
|
|
2892
|
+
}
|
|
2893
|
+
});
|
|
2801
2894
|
Object.defineProperty(exports, "findAvailablePort", {
|
|
2802
2895
|
enumerable: true,
|
|
2803
2896
|
get: function() {
|
|
2804
2897
|
return findAvailablePort;
|
|
2805
2898
|
}
|
|
2806
2899
|
});
|
|
2900
|
+
Object.defineProperty(exports, "forgetState", {
|
|
2901
|
+
enumerable: true,
|
|
2902
|
+
get: function() {
|
|
2903
|
+
return forgetState;
|
|
2904
|
+
}
|
|
2905
|
+
});
|
|
2807
2906
|
Object.defineProperty(exports, "isPortAvailable", {
|
|
2808
2907
|
enumerable: true,
|
|
2809
2908
|
get: function() {
|
|
@@ -2822,18 +2921,36 @@ Object.defineProperty(exports, "loadSecretsForApp", {
|
|
|
2822
2921
|
return loadSecretsForApp;
|
|
2823
2922
|
}
|
|
2824
2923
|
});
|
|
2924
|
+
Object.defineProperty(exports, "pgClient", {
|
|
2925
|
+
enumerable: true,
|
|
2926
|
+
get: function() {
|
|
2927
|
+
return pgClient;
|
|
2928
|
+
}
|
|
2929
|
+
});
|
|
2825
2930
|
Object.defineProperty(exports, "prepareEntryCredentials", {
|
|
2826
2931
|
enumerable: true,
|
|
2827
2932
|
get: function() {
|
|
2828
2933
|
return prepareEntryCredentials;
|
|
2829
2934
|
}
|
|
2830
2935
|
});
|
|
2936
|
+
Object.defineProperty(exports, "primaryPortKey", {
|
|
2937
|
+
enumerable: true,
|
|
2938
|
+
get: function() {
|
|
2939
|
+
return primaryPortKey;
|
|
2940
|
+
}
|
|
2941
|
+
});
|
|
2831
2942
|
Object.defineProperty(exports, "providerOf", {
|
|
2832
2943
|
enumerable: true,
|
|
2833
2944
|
get: function() {
|
|
2834
2945
|
return providerOf;
|
|
2835
2946
|
}
|
|
2836
2947
|
});
|
|
2948
|
+
Object.defineProperty(exports, "quoteIdentifier", {
|
|
2949
|
+
enumerable: true,
|
|
2950
|
+
get: function() {
|
|
2951
|
+
return quoteIdentifier;
|
|
2952
|
+
}
|
|
2953
|
+
});
|
|
2837
2954
|
Object.defineProperty(exports, "reconcileWorkspace", {
|
|
2838
2955
|
enumerable: true,
|
|
2839
2956
|
get: function() {
|
|
@@ -2865,4 +2982,4 @@ Object.defineProperty(exports, "workspace_exports", {
|
|
|
2865
2982
|
}
|
|
2866
2983
|
});
|
|
2867
2984
|
|
|
2868
|
-
//# sourceMappingURL=workspace-
|
|
2985
|
+
//# sourceMappingURL=workspace-gfIrSEUp.cjs.map
|