@geekmidas/cli 10.0.0-alpha.76 → 10.0.0-alpha.78
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/{LegacyStateStore-dyq07_Ir.mjs → LegacyStateStore-Ceq7A_75.mjs} +2 -2
- package/dist/{LegacyStateStore-dyq07_Ir.mjs.map → LegacyStateStore-Ceq7A_75.mjs.map} +1 -1
- package/dist/{LegacyStateStore-DwngfJxr.cjs → LegacyStateStore-Z-EKUGSX.cjs} +2 -2
- package/dist/{LegacyStateStore-DwngfJxr.cjs.map → LegacyStateStore-Z-EKUGSX.cjs.map} +1 -1
- package/dist/{LocalStateStore-B0NCde8Z.cjs → LocalStateStore-Bocb8dmZ.cjs} +2 -2
- package/dist/{LocalStateStore-B0NCde8Z.cjs.map → LocalStateStore-Bocb8dmZ.cjs.map} +1 -1
- package/dist/{LocalStateStore-DLxCCatI.mjs → LocalStateStore-C72bwpG2.mjs} +2 -2
- package/dist/{LocalStateStore-DLxCCatI.mjs.map → LocalStateStore-C72bwpG2.mjs.map} +1 -1
- package/dist/{S3StateStore-BOenb-3o.cjs → S3StateStore-35YfcdL_.cjs} +2 -2
- package/dist/{S3StateStore-BOenb-3o.cjs.map → S3StateStore-35YfcdL_.cjs.map} +1 -1
- package/dist/{S3StateStore-CGK_4hlo.mjs → S3StateStore-C9upSW5o.mjs} +2 -2
- package/dist/{S3StateStore-CGK_4hlo.mjs.map → S3StateStore-C9upSW5o.mjs.map} +1 -1
- package/dist/{SSMStateStore-DYeD__7p.cjs → SSMStateStore-W-Ps22AQ.cjs} +2 -2
- package/dist/{SSMStateStore-DYeD__7p.cjs.map → SSMStateStore-W-Ps22AQ.cjs.map} +1 -1
- package/dist/{SSMStateStore-B_5_RqY-.mjs → SSMStateStore-dOmFO6g1.mjs} +2 -2
- package/dist/{SSMStateStore-B_5_RqY-.mjs.map → SSMStateStore-dOmFO6g1.mjs.map} +1 -1
- package/dist/{add-j2yI3cbS.cjs → add-BvOICikp.cjs} +8 -8
- package/dist/{add-j2yI3cbS.cjs.map → add-BvOICikp.cjs.map} +1 -1
- package/dist/{add-B7IMXzou.mjs → add-D2XKszYP.mjs} +3 -3
- package/dist/{add-B7IMXzou.mjs.map → add-D2XKszYP.mjs.map} +1 -1
- package/dist/{bundler-Cf6OgaOe.cjs → bundler-C6T-1OLT.cjs} +5 -5
- package/dist/{bundler-Cf6OgaOe.cjs.map → bundler-C6T-1OLT.cjs.map} +1 -1
- package/dist/{bundler-DO6bHhnb.mjs → bundler-CtHzKqnZ.mjs} +5 -5
- package/dist/{bundler-DO6bHhnb.mjs.map → bundler-CtHzKqnZ.mjs.map} +1 -1
- package/dist/{cli-BCPOHmg9.mjs → cli-BgPyhx1i.mjs} +3 -3
- package/dist/{cli-BCPOHmg9.mjs.map → cli-BgPyhx1i.mjs.map} +1 -1
- package/dist/{cli-CNanUB7a.cjs → cli-K6Vj_pPW.cjs} +4 -4
- package/dist/{cli-CNanUB7a.cjs.map → cli-K6Vj_pPW.cjs.map} +1 -1
- package/dist/{compose-h_6oNnHC.cjs → compose-B7MC19eC.cjs} +668 -110
- package/dist/compose-B7MC19eC.cjs.map +1 -0
- package/dist/{compose-Dq4VCtu5.mjs → compose-DByK353T.mjs} +606 -66
- package/dist/compose-DByK353T.mjs.map +1 -0
- package/dist/{config-CqAvPP-f.d.mts → config-Bql0AmJt.d.mts} +3 -3
- package/dist/{config-CWyhLSY1.d.cts.map → config-Bql0AmJt.d.mts.map} +1 -1
- package/dist/{config-CWyhLSY1.d.cts → config-DlNpHK8p.d.cts} +3 -3
- package/dist/{config-CqAvPP-f.d.mts.map → config-DlNpHK8p.d.cts.map} +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +1 -1
- package/dist/deploy/public.cjs +12 -12
- package/dist/deploy/public.d.cts +3 -3
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts +3 -3
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +6 -6
- package/dist/{deploy-CVXEx7Nm.mjs → deploy-BerP7ppB.mjs} +5 -5
- package/dist/{deploy-CVXEx7Nm.mjs.map → deploy-BerP7ppB.mjs.map} +1 -1
- package/dist/{deploy-CT3R9de9.cjs → deploy-Dt42xiQA.cjs} +11 -11
- package/dist/{deploy-CT3R9de9.cjs.map → deploy-Dt42xiQA.cjs.map} +1 -1
- package/dist/{dokploy-eSGmlhhj.cjs → dokploy-NG9UrVrP.cjs} +2 -2
- package/dist/{dokploy-eSGmlhhj.cjs.map → dokploy-NG9UrVrP.cjs.map} +1 -1
- package/dist/{dokploy-CYm2ozFs.mjs → dokploy-ssZQRK2C.mjs} +2 -2
- package/dist/{dokploy-CYm2ozFs.mjs.map → dokploy-ssZQRK2C.mjs.map} +1 -1
- package/dist/{encryption-vS3Qzw73.cjs → encryption-CbMI24fI.cjs} +6 -6
- package/dist/{encryption-vS3Qzw73.cjs.map → encryption-CbMI24fI.cjs.map} +1 -1
- package/dist/{encryption-DC0rsR1W.mjs → encryption-De6MN0O5.mjs} +3 -3
- package/dist/{encryption-DC0rsR1W.mjs.map → encryption-De6MN0O5.mjs.map} +1 -1
- package/dist/{engine-C0N2d1i5.cjs → engine-CoCsNoW_.cjs} +73 -68
- package/dist/{engine-C0N2d1i5.cjs.map → engine-CoCsNoW_.cjs.map} +1 -1
- package/dist/{engine-BOO5TWZd.mjs → engine-DOjGIgl4.mjs} +9 -4
- package/dist/{engine-BOO5TWZd.mjs.map → engine-DOjGIgl4.mjs.map} +1 -1
- package/dist/{github-CEaFDL6t.mjs → github-CwX9z89E.mjs} +3 -3
- package/dist/{github-CEaFDL6t.mjs.map → github-CwX9z89E.mjs.map} +1 -1
- package/dist/{github-ClkdCOL9.cjs → github-D9vGqdLk.cjs} +7 -7
- package/dist/{github-ClkdCOL9.cjs.map → github-D9vGqdLk.cjs.map} +1 -1
- package/dist/{index-DOxmDKqv.d.mts → index-BXO0vlme.d.mts} +2 -2
- package/dist/{index-Ccu0f_2m.d.cts.map → index-BXO0vlme.d.mts.map} +1 -1
- package/dist/{index-Ccu0f_2m.d.cts → index-Rs0Fua-q.d.cts} +2 -2
- package/dist/{index-DOxmDKqv.d.mts.map → index-Rs0Fua-q.d.cts.map} +1 -1
- package/dist/index.cjs +180 -219
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +108 -147
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-BRbYtFXG.cjs → migrate-B4GBvCNY.cjs} +5 -5
- package/dist/{migrate-BRbYtFXG.cjs.map → migrate-B4GBvCNY.cjs.map} +1 -1
- package/dist/{migrate-D3NAT7Ns.mjs → migrate-BQ4wVKq_.mjs} +3 -3
- package/dist/{migrate-D3NAT7Ns.mjs.map → migrate-BQ4wVKq_.mjs.map} +1 -1
- package/dist/{migrate-DrO2p9Rl.mjs → migrate-CNKaQl3K.mjs} +3 -3
- package/dist/{migrate-DrO2p9Rl.mjs.map → migrate-CNKaQl3K.mjs.map} +1 -1
- package/dist/{migrate-D5_-ylI1.cjs → migrate-Cgoy58Sh.cjs} +8 -8
- package/dist/{migrate-D5_-ylI1.cjs.map → migrate-Cgoy58Sh.cjs.map} +1 -1
- 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/reconcile/public.d.cts +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/{resolve-Fa1Ii0BK.cjs → resolve-CEaqRBzY.cjs} +3 -3
- package/dist/{resolve-Fa1Ii0BK.cjs.map → resolve-CEaqRBzY.cjs.map} +1 -1
- package/dist/{resolve-C1muFos5.mjs → resolve-mvaystiE.mjs} +3 -3
- package/dist/{resolve-C1muFos5.mjs.map → resolve-mvaystiE.mjs.map} +1 -1
- package/dist/{rollback-C9N5lKVf.cjs → rollback-F3P-rA-r.cjs} +7 -7
- package/dist/{rollback-C9N5lKVf.cjs.map → rollback-F3P-rA-r.cjs.map} +1 -1
- package/dist/{rollback-DeQzbRqM.mjs → rollback-S2C-Y9pB.mjs} +5 -5
- package/dist/{rollback-DeQzbRqM.mjs.map → rollback-S2C-Y9pB.mjs.map} +1 -1
- package/dist/{runtime-Cm7QA53H.d.cts → runtime-D9AxGzrw.d.cts} +2 -2
- package/dist/{runtime-BSvzPqXW.d.mts.map → runtime-D9AxGzrw.d.cts.map} +1 -1
- package/dist/{runtime-BSvzPqXW.d.mts → runtime-Dflki3Vs.d.mts} +2 -2
- package/dist/{runtime-Cm7QA53H.d.cts.map → runtime-Dflki3Vs.d.mts.map} +1 -1
- package/dist/{sniffer-Y6GQOCXB.cjs → sniffer-BjG-1mlD.cjs} +6 -6
- package/dist/{sniffer-Y6GQOCXB.cjs.map → sniffer-BjG-1mlD.cjs.map} +1 -1
- package/dist/{sniffer-DR8AlRCk.mjs → sniffer-ByWtH28i.mjs} +6 -6
- package/dist/{sniffer-DR8AlRCk.mjs.map → sniffer-ByWtH28i.mjs.map} +1 -1
- package/dist/{state-C2qi0iQw.cjs → stale-BsiPJI7Y.cjs} +111 -25
- package/dist/stale-BsiPJI7Y.cjs.map +1 -0
- package/dist/{state-CUecOCNJ.mjs → stale-C5FqIVc8.mjs} +106 -26
- package/dist/stale-C5FqIVc8.mjs.map +1 -0
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.d.cts +2 -2
- package/dist/target/public.d.mts +2 -2
- package/dist/target/public.mjs +1 -1
- package/dist/{types-BdptGBFS.d.cts → types-ByY0zi3n.d.cts} +42 -3
- package/dist/types-ByY0zi3n.d.cts.map +1 -0
- package/dist/{types-OxE0OAn2.d.mts → types-DKxkXsKC.d.mts} +42 -3
- package/dist/types-DKxkXsKC.d.mts.map +1 -0
- 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-QUTqYmVy.mjs → workspace-BBdqmkch.mjs} +114 -17
- package/dist/workspace-BBdqmkch.mjs.map +1 -0
- package/dist/{workspace-DOm81oUo.cjs → workspace-Bp8FEkF-.cjs} +130 -15
- package/dist/workspace-Bp8FEkF-.cjs.map +1 -0
- package/package.json +15 -15
- package/dist/compose-Dq4VCtu5.mjs.map +0 -1
- package/dist/compose-h_6oNnHC.cjs.map +0 -1
- package/dist/state-C2qi0iQw.cjs.map +0 -1
- package/dist/state-CUecOCNJ.mjs.map +0 -1
- package/dist/types-BdptGBFS.d.cts.map +0 -1
- package/dist/types-OxE0OAn2.d.mts.map +0 -1
- package/dist/workspace-DOm81oUo.cjs.map +0 -1
- package/dist/workspace-QUTqYmVy.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -5,20 +5,20 @@ const require_run = require("./run-fVZ-rLnc.cjs");
|
|
|
5
5
|
const require_credentials = require("./credentials-BVs7mrtw.cjs");
|
|
6
6
|
const require_discover = require("./discover-D1It5r_h.cjs");
|
|
7
7
|
const require_derive = require("./derive-DAbo49sm.cjs");
|
|
8
|
-
const require_workspace = require("./workspace-
|
|
8
|
+
const require_workspace = require("./workspace-Bp8FEkF-.cjs");
|
|
9
9
|
const require_config = require("./config.cjs");
|
|
10
|
-
const
|
|
10
|
+
const require_stale = require("./stale-BsiPJI7Y.cjs");
|
|
11
11
|
const require_EndpointGenerator = require("./EndpointGenerator-CP6sBvQV.cjs");
|
|
12
12
|
const require_openapi = require("./openapi.cjs");
|
|
13
13
|
const require_SubscriberGenerator = require("./SubscriberGenerator-CajwOa5W.cjs");
|
|
14
14
|
const require_appPorts = require("./appPorts-Cu79hJF6.cjs");
|
|
15
15
|
const require_drivers = require("./drivers-BdvtCKc7.cjs");
|
|
16
16
|
const require_emit = require("./emit-Dmc1nvdS.cjs");
|
|
17
|
-
const require_sniffer = require("./sniffer-
|
|
18
|
-
const require_deploy = require("./deploy-
|
|
19
|
-
const require_compose = require("./compose-
|
|
17
|
+
const require_sniffer = require("./sniffer-BjG-1mlD.cjs");
|
|
18
|
+
const require_deploy = require("./deploy-Dt42xiQA.cjs");
|
|
19
|
+
const require_compose = require("./compose-B7MC19eC.cjs");
|
|
20
20
|
const require_credentialSchemas = require("./credentialSchemas-DCR4Wd1W.cjs");
|
|
21
|
-
const require_LocalStateStore = require("./LocalStateStore-
|
|
21
|
+
const require_LocalStateStore = require("./LocalStateStore-Bocb8dmZ.cjs");
|
|
22
22
|
const require_utils = require("./utils-D2Nk1Nv2.cjs");
|
|
23
23
|
const require_ready = require("./ready-BB9xS4S9.cjs");
|
|
24
24
|
let node_path = require("node:path");
|
|
@@ -53,7 +53,7 @@ crypto = require_rolldown_runtime.__toESM(crypto, 1);
|
|
|
53
53
|
let _geekmidas_constructs_functions = require("@geekmidas/constructs/functions");
|
|
54
54
|
let _geekmidas_constructs_topic = require("@geekmidas/constructs/topic");
|
|
55
55
|
//#region package.json
|
|
56
|
-
var version = "10.0.0-alpha.
|
|
56
|
+
var version = "10.0.0-alpha.78";
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region src/prompt.ts
|
|
59
59
|
/**
|
|
@@ -136,7 +136,7 @@ const logger$8 = console;
|
|
|
136
136
|
* Validate Dokploy token by making a test API call
|
|
137
137
|
*/
|
|
138
138
|
async function validateDokployToken(endpoint, token) {
|
|
139
|
-
const { DokployApi } = await Promise.resolve().then(() => require("./sniffer-
|
|
139
|
+
const { DokployApi } = await Promise.resolve().then(() => require("./sniffer-BjG-1mlD.cjs")).then((n) => n.dokploy_api_exports);
|
|
140
140
|
return new DokployApi({
|
|
141
141
|
baseUrl: endpoint,
|
|
142
142
|
token
|
|
@@ -304,7 +304,7 @@ function installation(platform, certificate) {
|
|
|
304
304
|
*/
|
|
305
305
|
async function trustCommand(options = {}) {
|
|
306
306
|
const { workspace } = await require_config.loadWorkspaceConfig();
|
|
307
|
-
const certificate = (0, node_path.join)(workspace.root,
|
|
307
|
+
const certificate = (0, node_path.join)(workspace.root, require_stale.LOCAL_CA_PATH);
|
|
308
308
|
if (!(0, node_fs.existsSync)(certificate)) throw new NoLocalAuthority(certificate);
|
|
309
309
|
const { describe, asks, steps } = installation(process.platform, certificate);
|
|
310
310
|
logger$7.log(`\n🔐 Trusting the local authority in ${describe}`);
|
|
@@ -1488,7 +1488,7 @@ async function serveFakes(fakes, ports) {
|
|
|
1488
1488
|
const served = [];
|
|
1489
1489
|
for (const [id, local] of Object.entries(fakes)) {
|
|
1490
1490
|
if (local.image) continue;
|
|
1491
|
-
const port = ports[
|
|
1491
|
+
const port = ports[require_stale.fakeKey(id)];
|
|
1492
1492
|
if (port === void 0) continue;
|
|
1493
1493
|
const { handler } = (await import((0, node_url.pathToFileURL)(local.file).href)).default;
|
|
1494
1494
|
const server = serve({
|
|
@@ -1531,16 +1531,16 @@ var NoCommandSpecified = class extends Error {
|
|
|
1531
1531
|
async function execCommand(commandArgs, options = {}) {
|
|
1532
1532
|
const cwd = options.cwd ?? process.cwd();
|
|
1533
1533
|
if (!commandArgs[0]) throw new NoCommandSpecified();
|
|
1534
|
-
const defaultEnv =
|
|
1534
|
+
const defaultEnv = require_stale.loadEnvFiles(".env");
|
|
1535
1535
|
if (defaultEnv.loaded.length > 0) logger$6.log(`📦 Loaded env: ${defaultEnv.loaded.join(", ")}`);
|
|
1536
|
-
const { credentials, secretsJsonPath, appName } =
|
|
1536
|
+
const { credentials, secretsJsonPath, appName } = require_stale.isImageBuild() ? await imageBuildEntry(cwd) : await require_stale.prepareEntryCredentials({ cwd });
|
|
1537
1537
|
if (appName) logger$6.log(`📦 App: ${appName}`);
|
|
1538
1538
|
const secretCount = Object.keys(credentials).filter((k) => k !== "PORT").length;
|
|
1539
|
-
if (secretCount > 0 && !
|
|
1539
|
+
if (secretCount > 0 && !require_stale.isImageBuild()) logger$6.log(`🔐 Loaded ${secretCount} secret(s)`);
|
|
1540
1540
|
const preloadDir = (0, node_path.join)(cwd, ".gkm");
|
|
1541
1541
|
await (0, node_fs_promises.mkdir)(preloadDir, { recursive: true });
|
|
1542
1542
|
const preloadPath = (0, node_path.join)(preloadDir, "credentials-preload.mjs");
|
|
1543
|
-
await
|
|
1543
|
+
await require_stale.createCredentialsPreload(preloadPath, secretsJsonPath);
|
|
1544
1544
|
const [cmd, ...args] = commandArgs;
|
|
1545
1545
|
logger$6.log(`🚀 Running: ${[cmd, ...args].join(" ")}`);
|
|
1546
1546
|
const nodeOptions = [(process.env.NODE_OPTIONS ?? "").replace(/--import[= ]\S+/g, "").trim(), `--import=${preloadPath}`].filter(Boolean).join(" ");
|
|
@@ -1568,7 +1568,7 @@ async function execCommand(commandArgs, options = {}) {
|
|
|
1568
1568
|
* secret read and no address resolved.
|
|
1569
1569
|
*/
|
|
1570
1570
|
async function imageBuildEntry(cwd) {
|
|
1571
|
-
const credentials =
|
|
1571
|
+
const credentials = require_stale.imageBuildCredentials();
|
|
1572
1572
|
logger$6.log(`🐳 Image build: ${Object.keys(credentials).length} public value(s) from the build args`);
|
|
1573
1573
|
const dir = (0, node_path.join)(cwd, ".gkm");
|
|
1574
1574
|
await (0, node_fs_promises.mkdir)(dir, { recursive: true });
|
|
@@ -1649,7 +1649,7 @@ const SUBSCRIBERS_ENV = "GKM_SUBSCRIBERS";
|
|
|
1649
1649
|
async function devCommand(options) {
|
|
1650
1650
|
if (options.subscribers === false) process.env[SUBSCRIBERS_ENV] = "off";
|
|
1651
1651
|
if (options.entry) return entryDevCommand(options);
|
|
1652
|
-
const defaultEnv =
|
|
1652
|
+
const defaultEnv = require_stale.loadEnvFiles(".env");
|
|
1653
1653
|
if (defaultEnv.loaded.length > 0) logger$5.log(`📦 Loaded env: ${defaultEnv.loaded.join(", ")}`);
|
|
1654
1654
|
const appConfig = await require_config.loadAppConfig().catch((error) => {
|
|
1655
1655
|
if (error instanceof require_config.NotInAnApp || error instanceof require_config.NotABackendApp) return;
|
|
@@ -1665,7 +1665,7 @@ async function devCommand(options) {
|
|
|
1665
1665
|
const secretsRoot = appConfig.workspaceRoot;
|
|
1666
1666
|
const workspaceAppName = appConfig.appName;
|
|
1667
1667
|
const assigned = await require_appPorts.assignAppPorts(appConfig.workspace, [workspaceAppName], {
|
|
1668
|
-
free:
|
|
1668
|
+
free: require_stale.isPortAvailable,
|
|
1669
1669
|
holder: require_appPorts.holderOf
|
|
1670
1670
|
});
|
|
1671
1671
|
if (assigned.running.length > 0) throw new WorkspacePortsInUse(assigned.running);
|
|
@@ -1683,7 +1683,7 @@ async function devCommand(options) {
|
|
|
1683
1683
|
});
|
|
1684
1684
|
}
|
|
1685
1685
|
if (config.env) {
|
|
1686
|
-
const { loaded, missing } =
|
|
1686
|
+
const { loaded, missing } = require_stale.loadEnvFiles(config.env, appRoot);
|
|
1687
1687
|
if (loaded.length > 0) logger$5.log(`📦 Loaded env: ${loaded.join(", ")}`);
|
|
1688
1688
|
if (missing.length > 0) logger$5.warn(`⚠️ Missing env files: ${missing.join(", ")}`);
|
|
1689
1689
|
}
|
|
@@ -1696,8 +1696,8 @@ async function devCommand(options) {
|
|
|
1696
1696
|
appRoot,
|
|
1697
1697
|
target: "server",
|
|
1698
1698
|
enableOpenApi,
|
|
1699
|
-
cacheBackend:
|
|
1700
|
-
eventsBackend:
|
|
1699
|
+
cacheBackend: require_stale.cacheBackendFor(require_stale.providerOf(workspace ?? config)),
|
|
1700
|
+
eventsBackend: require_stale.eventsBackendFor(require_stale.providerOf(workspace ?? config)),
|
|
1701
1701
|
telescope,
|
|
1702
1702
|
databaseApi: true,
|
|
1703
1703
|
hooks,
|
|
@@ -1711,16 +1711,16 @@ async function devCommand(options) {
|
|
|
1711
1711
|
let secretsJsonPath;
|
|
1712
1712
|
let publicUrl;
|
|
1713
1713
|
let manifest;
|
|
1714
|
-
const appSecrets = await
|
|
1714
|
+
const appSecrets = await require_stale.loadSecretsForApp(workspace ? await require_stale.secretsStoreFor(workspace, config.stages.local) : new require_stale.FileSecretsStore(secretsRoot), config.stages.local);
|
|
1715
1715
|
if (workspace) {
|
|
1716
|
-
const reconciled = await
|
|
1716
|
+
const reconciled = await require_stale.reconcileWorkspace(workspace, {
|
|
1717
1717
|
stage: workspace.stages.local,
|
|
1718
1718
|
...options.fake ? { fake: true } : {},
|
|
1719
1719
|
progress: (message) => logger$5.log(message)
|
|
1720
1720
|
});
|
|
1721
1721
|
if (reconciled.services.length > 0) {
|
|
1722
1722
|
logger$5.log("🐳 Services");
|
|
1723
|
-
for (const line of
|
|
1723
|
+
for (const line of require_stale.describeServices(reconciled.services)) logger$5.log(line);
|
|
1724
1724
|
}
|
|
1725
1725
|
Object.assign(appSecrets, reconciled.env);
|
|
1726
1726
|
const own = reconciled.plan.resources.find((r) => (r.kind === "rest-api" || r.kind === "site") && require_derive.appKey(r.id) === workspaceAppName);
|
|
@@ -1999,8 +1999,8 @@ async function validateFrontendApps(workspace) {
|
|
|
1999
1999
|
async function loadDevSecrets(workspace) {
|
|
2000
2000
|
if (!workspace.secrets.enabled) return {};
|
|
2001
2001
|
const stage = workspace.stages.local;
|
|
2002
|
-
const secrets = await (await
|
|
2003
|
-
if (secrets) return
|
|
2002
|
+
const secrets = await (await require_stale.secretsStoreFor(workspace, stage)).read(stage);
|
|
2003
|
+
if (secrets) return require_stale.toEmbeddableSecrets(secrets);
|
|
2004
2004
|
return {};
|
|
2005
2005
|
}
|
|
2006
2006
|
/**
|
|
@@ -2015,7 +2015,7 @@ async function loadDevSecrets(workspace) {
|
|
|
2015
2015
|
async function workspaceDevCommand(configured, options) {
|
|
2016
2016
|
const scoped = options.app ? [options.app] : options.filter ? [] : Object.keys(configured.apps);
|
|
2017
2017
|
const assigned = await require_appPorts.assignAppPorts(configured, scoped, {
|
|
2018
|
-
free:
|
|
2018
|
+
free: require_stale.isPortAvailable,
|
|
2019
2019
|
holder: require_appPorts.holderOf
|
|
2020
2020
|
});
|
|
2021
2021
|
if (assigned.running.length > 0) throw new WorkspacePortsInUse(assigned.running);
|
|
@@ -2042,14 +2042,14 @@ async function workspaceDevCommand(configured, options) {
|
|
|
2042
2042
|
if (hasErrors) throw new Error("Frontend app validation failed. Fix the issues above and try again.");
|
|
2043
2043
|
}
|
|
2044
2044
|
const rawSecrets = await loadDevSecrets(workspace);
|
|
2045
|
-
const reconciled = await
|
|
2045
|
+
const reconciled = await require_stale.reconcileWorkspace(workspace, {
|
|
2046
2046
|
stage: workspace.stages.local,
|
|
2047
2047
|
...options.fake ? { fake: true } : {},
|
|
2048
2048
|
progress: (message) => logger$5.log(message)
|
|
2049
2049
|
});
|
|
2050
2050
|
if (reconciled.services.length > 0) {
|
|
2051
2051
|
logger$5.log("🐳 Services");
|
|
2052
|
-
for (const line of
|
|
2052
|
+
for (const line of require_stale.describeServices(reconciled.services)) logger$5.log(line);
|
|
2053
2053
|
}
|
|
2054
2054
|
const secretsEnv = {
|
|
2055
2055
|
...rawSecrets,
|
|
@@ -2059,9 +2059,9 @@ async function workspaceDevCommand(configured, options) {
|
|
|
2059
2059
|
for (const { id, port } of fakes) logger$5.log(`🎭 ${id} fake: http://localhost:${port}`);
|
|
2060
2060
|
logger$5.log(options.migrate || options.seed ? "🗄️ Migrating the databases" : "🗄️ Checking for pending migrations");
|
|
2061
2061
|
if (options.migrate || options.seed) {
|
|
2062
|
-
const { prepareDevDatabases } = await Promise.resolve().then(() => require("./migrate-
|
|
2062
|
+
const { prepareDevDatabases } = await Promise.resolve().then(() => require("./migrate-Cgoy58Sh.cjs"));
|
|
2063
2063
|
await prepareDevDatabases(workspace, reconciled.env, { seed: !!options.seed });
|
|
2064
|
-
} else await Promise.resolve().then(() => require("./migrate-
|
|
2064
|
+
} else await Promise.resolve().then(() => require("./migrate-Cgoy58Sh.cjs")).then(({ reportPendingMigrations }) => reportPendingMigrations(workspace, reconciled.env)).catch((error) => {
|
|
2065
2065
|
logger$5.log(`⚠️ Could not check for pending migrations: ${error instanceof Error ? error.message : String(error)}`);
|
|
2066
2066
|
});
|
|
2067
2067
|
const appUrls = {};
|
|
@@ -2147,7 +2147,7 @@ async function workspaceDevCommand(configured, options) {
|
|
|
2147
2147
|
...secretsEnv,
|
|
2148
2148
|
NODE_ENV: "development",
|
|
2149
2149
|
...configPath ? { GKM_CONFIG_PATH: configPath } : {},
|
|
2150
|
-
...options.fake ? { [
|
|
2150
|
+
...options.fake ? { [require_stale.FAKE_ENV]: "1" } : {},
|
|
2151
2151
|
[DISCOVERY_QUIET_ENV]: "1"
|
|
2152
2152
|
};
|
|
2153
2153
|
logger$5.log(`🚀 Starting ${appCount} app(s) — each builds before it answers, and says so when it is ready`);
|
|
@@ -2210,16 +2210,16 @@ async function entryDevCommand(options) {
|
|
|
2210
2210
|
if (!entry) throw new Error("--entry requires a file path");
|
|
2211
2211
|
const entryPath = (0, node_path.resolve)(process.cwd(), entry);
|
|
2212
2212
|
if (!(0, node_fs.existsSync)(entryPath)) throw new Error(`Entry file not found: ${entryPath}`);
|
|
2213
|
-
const defaultEnv =
|
|
2213
|
+
const defaultEnv = require_stale.loadEnvFiles(".env");
|
|
2214
2214
|
if (defaultEnv.loaded.length > 0) logger$5.log(`📦 Loaded env: ${defaultEnv.loaded.join(", ")}`);
|
|
2215
|
-
const { credentials, resolvedPort, secretsJsonPath, appName } = await
|
|
2215
|
+
const { credentials, resolvedPort, secretsJsonPath, appName } = await require_stale.prepareEntryCredentials({ explicitPort: options.portExplicit ? options.port : void 0 });
|
|
2216
2216
|
if (appName) logger$5.log(`📦 App: ${appName} (port ${resolvedPort})`);
|
|
2217
2217
|
logger$5.log(`🚀 Starting entry file: ${entry} on port ${resolvedPort}`);
|
|
2218
2218
|
if (Object.keys(credentials).length > 1) logger$5.log(`🔐 Loaded ${Object.keys(credentials).length - 1} secret(s) + PORT`);
|
|
2219
2219
|
const wrapperDir = (0, node_path.join)(process.cwd(), ".gkm");
|
|
2220
2220
|
await (0, node_fs_promises.mkdir)(wrapperDir, { recursive: true });
|
|
2221
2221
|
const wrapperPath = (0, node_path.join)(wrapperDir, "entry-wrapper.ts");
|
|
2222
|
-
await
|
|
2222
|
+
await require_stale.createEntryWrapper(wrapperPath, entryPath, secretsJsonPath);
|
|
2223
2223
|
const runner = new EntryRunner(wrapperPath, entryPath, watch, resolvedPort);
|
|
2224
2224
|
await runner.start();
|
|
2225
2225
|
let isShuttingDown = false;
|
|
@@ -2528,10 +2528,10 @@ var DevServer = class {
|
|
|
2528
2528
|
this.startTime = Date.now();
|
|
2529
2529
|
if (this.isRunning) await this.stop();
|
|
2530
2530
|
if (this.portExplicit) {
|
|
2531
|
-
if (!await
|
|
2531
|
+
if (!await require_stale.isPortAvailable(this.requestedPort)) throw new DevPortInUse(this.requestedPort, listenerOn(this.requestedPort));
|
|
2532
2532
|
this.actualPort = this.requestedPort;
|
|
2533
2533
|
} else {
|
|
2534
|
-
this.actualPort = await
|
|
2534
|
+
this.actualPort = await require_stale.findAvailablePort(this.requestedPort);
|
|
2535
2535
|
if (this.actualPort !== this.requestedPort) logger$5.log(`ℹ️ Port ${this.requestedPort} was in use, using port ${this.actualPort} instead`);
|
|
2536
2536
|
}
|
|
2537
2537
|
const serverEntryPath = (0, node_path.join)(this.appRoot, ".gkm", "server", "server.ts");
|
|
@@ -2602,7 +2602,7 @@ var DevServer = class {
|
|
|
2602
2602
|
await this.stop();
|
|
2603
2603
|
let attempts = 0;
|
|
2604
2604
|
while (attempts < 30) {
|
|
2605
|
-
if (await
|
|
2605
|
+
if (await require_stale.isPortAvailable(portToReuse)) break;
|
|
2606
2606
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
2607
2607
|
attempts++;
|
|
2608
2608
|
}
|
|
@@ -2943,7 +2943,7 @@ async function buildCommand(options) {
|
|
|
2943
2943
|
}
|
|
2944
2944
|
}
|
|
2945
2945
|
const config = loadedConfig.type !== "workspace" ? await require_config.loadConfig() : (0, node_path.resolve)(process.cwd()) === (0, node_path.resolve)(loadedConfig.workspace.root) ? rootGkmConfig(loadedConfig.workspace) : (await require_config.loadAppConfig()).gkmConfig;
|
|
2946
|
-
const target = options.provider ??
|
|
2946
|
+
const target = options.provider ?? require_stale.providerOf(loadedConfig.workspace);
|
|
2947
2947
|
const workspaceRoot = loadedConfig.workspace.root;
|
|
2948
2948
|
const appRoot = process.cwd();
|
|
2949
2949
|
const output = await buildOneApp({
|
|
@@ -2975,15 +2975,15 @@ async function declaredIn(config, cwd) {
|
|
|
2975
2975
|
*/
|
|
2976
2976
|
function backendsOf(workspace) {
|
|
2977
2977
|
return {
|
|
2978
|
-
cache:
|
|
2978
|
+
cache: require_stale.cacheBackendFor(require_stale.providerOf(workspace)),
|
|
2979
2979
|
email: "ses"
|
|
2980
2980
|
};
|
|
2981
2981
|
}
|
|
2982
2982
|
/** One app's build, from its config and the command's options. */
|
|
2983
2983
|
async function buildOneApp(input) {
|
|
2984
2984
|
const { config, options, workspace, appRoot, target } = input;
|
|
2985
|
-
const cacheBackend = options.cache ??
|
|
2986
|
-
const eventsBackend =
|
|
2985
|
+
const cacheBackend = options.cache ?? require_stale.cacheBackendFor(require_stale.providerOf(workspace));
|
|
2986
|
+
const eventsBackend = require_stale.eventsBackendFor(require_stale.providerOf(workspace));
|
|
2987
2987
|
const production = normalizeProductionConfig(options.production ?? false);
|
|
2988
2988
|
if (production) logger$4.log(`🏭 Building for PRODUCTION`);
|
|
2989
2989
|
logger$4.log(`Building for ${target}`);
|
|
@@ -3069,7 +3069,7 @@ async function buildApp(input) {
|
|
|
3069
3069
|
if (production?.bundle && !input.skipBundle) {
|
|
3070
3070
|
const outputDir = (0, node_path.join)(appRoot, ".gkm", "server");
|
|
3071
3071
|
const entryPoint = await writeSurfaceServer(outputDir, production);
|
|
3072
|
-
const { bundleServer } = await Promise.resolve().then(() => require("./bundler-
|
|
3072
|
+
const { bundleServer } = await Promise.resolve().then(() => require("./bundler-C6T-1OLT.cjs"));
|
|
3073
3073
|
await bundleServer({
|
|
3074
3074
|
entryPoint,
|
|
3075
3075
|
outputDir: (0, node_path.join)(outputDir, "dist"),
|
|
@@ -3113,9 +3113,9 @@ async function buildApp(input) {
|
|
|
3113
3113
|
};
|
|
3114
3114
|
const endpointGenerator = new require_EndpointGenerator.EndpointGenerator();
|
|
3115
3115
|
const functionGenerator = new FunctionGenerator();
|
|
3116
|
-
const cronGenerator = new
|
|
3116
|
+
const cronGenerator = new require_stale.CronGenerator();
|
|
3117
3117
|
const subscriberGenerator = new require_SubscriberGenerator.SubscriberGenerator();
|
|
3118
|
-
const queueGenerator = new
|
|
3118
|
+
const queueGenerator = new require_stale.QueueGenerator();
|
|
3119
3119
|
const topicGenerator = new TopicGenerator();
|
|
3120
3120
|
const code = constructGlobs;
|
|
3121
3121
|
const [loadedEndpoints, allFunctions, allCrons, allSubscribers, allQueues, allTopics] = await Promise.all([
|
|
@@ -3154,7 +3154,7 @@ async function buildApp(input) {
|
|
|
3154
3154
|
const appName = Object.entries(input.workspace.apps).find(([, app]) => (0, node_path.resolve)(input.workspace.root, app.path) === (0, node_path.resolve)(appRoot))?.[0];
|
|
3155
3155
|
await buildWorkers({
|
|
3156
3156
|
context: buildContext,
|
|
3157
|
-
workers:
|
|
3157
|
+
workers: require_stale.workerUnits(input.workspace, declared, background).filter((unit) => unit.app === appName),
|
|
3158
3158
|
serverDir: (0, node_path.join)(appRoot, ".gkm", "server"),
|
|
3159
3159
|
crons: allCrons,
|
|
3160
3160
|
queues: allQueues,
|
|
@@ -3177,7 +3177,7 @@ async function buildApp(input) {
|
|
|
3177
3177
|
* runnables built from that worker, and nothing built from another.
|
|
3178
3178
|
*/
|
|
3179
3179
|
async function buildWorkers(input) {
|
|
3180
|
-
const generator = new
|
|
3180
|
+
const generator = new require_stale.WorkerGenerator();
|
|
3181
3181
|
for (const worker of input.workers) {
|
|
3182
3182
|
const owned = (list) => list.filter(({ construct }) => construct.owner === worker.id);
|
|
3183
3183
|
const crons = owned(input.crons);
|
|
@@ -3186,15 +3186,15 @@ async function buildWorkers(input) {
|
|
|
3186
3186
|
const entryPoint = await generator.build({
|
|
3187
3187
|
context: input.context,
|
|
3188
3188
|
workerId: worker.id,
|
|
3189
|
-
outputDir:
|
|
3189
|
+
outputDir: require_stale.workerEntryDir(input.serverDir, worker.id),
|
|
3190
3190
|
crons,
|
|
3191
3191
|
queues,
|
|
3192
3192
|
subscribers
|
|
3193
3193
|
});
|
|
3194
3194
|
logger$4.log(`Generated worker ${worker.id}: ${crons.length} crons, ${queues.length} queues, ${subscribers.length} subscribers`);
|
|
3195
3195
|
if (!input.bundle) continue;
|
|
3196
|
-
const { bundleServer } = await Promise.resolve().then(() => require("./bundler-
|
|
3197
|
-
const outfile =
|
|
3196
|
+
const { bundleServer } = await Promise.resolve().then(() => require("./bundler-C6T-1OLT.cjs"));
|
|
3197
|
+
const outfile = require_stale.workerBundleName(worker.id);
|
|
3198
3198
|
await bundleServer({
|
|
3199
3199
|
entryPoint,
|
|
3200
3200
|
outputDir: (0, node_path.join)(input.serverDir, "dist"),
|
|
@@ -3263,7 +3263,7 @@ async function buildForTarget(target, context, appRoot, workspaceRoot, endpointG
|
|
|
3263
3263
|
let masterKey;
|
|
3264
3264
|
if (context.production?.bundle && !skipBundle) {
|
|
3265
3265
|
logger$4.log(`\n📦 Bundling production server...`);
|
|
3266
|
-
const { bundleServer } = await Promise.resolve().then(() => require("./bundler-
|
|
3266
|
+
const { bundleServer } = await Promise.resolve().then(() => require("./bundler-C6T-1OLT.cjs"));
|
|
3267
3267
|
const allConstructs = [
|
|
3268
3268
|
...endpoints.map((e) => e.construct),
|
|
3269
3269
|
...functions.map((f) => f.construct),
|
|
@@ -3394,7 +3394,7 @@ async function workspaceBuildCommand(workspace, options) {
|
|
|
3394
3394
|
const buildOrder = require_workspace.getAppBuildOrder(workspace);
|
|
3395
3395
|
logger$4.log(` Build order: ${buildOrder.join(" → ")}`);
|
|
3396
3396
|
try {
|
|
3397
|
-
const target = options.provider ??
|
|
3397
|
+
const target = options.provider ?? require_stale.providerOf(workspace);
|
|
3398
3398
|
const builds = [];
|
|
3399
3399
|
for (const appName of buildOrder) {
|
|
3400
3400
|
const app = workspace.apps[appName];
|
|
@@ -3517,18 +3517,19 @@ async function composeCommand(options, deps = {}) {
|
|
|
3517
3517
|
if (options.push && !options.build) throw new require_compose.ComposePushNeedsBuild();
|
|
3518
3518
|
const pulls = !options.build && (options.pull || options.tag !== void 0);
|
|
3519
3519
|
if (options.digestsFile && !options.push && !pulls) throw new require_compose.ComposePinNeedsPull();
|
|
3520
|
-
const allowDevServices =
|
|
3520
|
+
const allowDevServices = require_stale.parseDevServices(options.allowDevServices);
|
|
3521
3521
|
const cwd = (0, node_path.resolve)(options.cwd ?? process.cwd());
|
|
3522
3522
|
const { workspace } = await require_config.loadWorkspaceConfig(cwd);
|
|
3523
3523
|
const { stage } = options;
|
|
3524
3524
|
if (options.down) {
|
|
3525
3525
|
const override = require_compose.stackOverrideFile(workspace.root, stage);
|
|
3526
3526
|
const ref = {
|
|
3527
|
-
project: require_compose.composeProject(
|
|
3527
|
+
project: require_compose.composeProject(require_stale.deployIdentity(workspace, stage)),
|
|
3528
3528
|
file: (0, node_path.join)(workspace.root, require_compose.stackDir(stage), "docker-compose.yml"),
|
|
3529
3529
|
...(0, node_fs.existsSync)(override) ? { overrides: [override] } : {},
|
|
3530
3530
|
cwd: workspace.root
|
|
3531
3531
|
};
|
|
3532
|
+
if (await require_compose.removeEdgeRoutes(require_compose.edgeDir(deps.env ?? process.env), ref.project)) console.log(`🌐 Removed ${ref.project}'s routes from ${require_compose.EDGE_PROJECT}.`);
|
|
3532
3533
|
await (deps.docker ?? require_compose.dockerCompose).down(ref);
|
|
3533
3534
|
console.log(`🛑 Stopped ${ref.project}. Its volumes are kept.`);
|
|
3534
3535
|
return;
|
|
@@ -4033,13 +4034,6 @@ const SERVICE_DEFAULTS = {
|
|
|
4033
4034
|
region: "us-east-1"
|
|
4034
4035
|
}
|
|
4035
4036
|
};
|
|
4036
|
-
/** Default credentials for pgboss (not a Docker service, reuses postgres) */
|
|
4037
|
-
const PGBOSS_DEFAULTS = {
|
|
4038
|
-
host: "localhost",
|
|
4039
|
-
port: 5432,
|
|
4040
|
-
username: "pgboss",
|
|
4041
|
-
database: "app"
|
|
4042
|
-
};
|
|
4043
4037
|
/**
|
|
4044
4038
|
* Generate credentials for a specific service.
|
|
4045
4039
|
*/
|
|
@@ -4079,14 +4073,6 @@ function generateMinioEndpoint(creds) {
|
|
|
4079
4073
|
return `http://${host}:${port}`;
|
|
4080
4074
|
}
|
|
4081
4075
|
/**
|
|
4082
|
-
* Generate connection URL for pg-boss (uses PostgreSQL protocol).
|
|
4083
|
-
* Format: pgboss://user:pass@host:port/db?schema=pgboss
|
|
4084
|
-
*/
|
|
4085
|
-
function generatePgBossUrl(creds) {
|
|
4086
|
-
const { username, password, host, port, database } = creds;
|
|
4087
|
-
return `pgboss://${username}:${encodeURIComponent(password)}@${host}:${port}/${database}?schema=pgboss`;
|
|
4088
|
-
}
|
|
4089
|
-
/**
|
|
4090
4076
|
* Generate connection URLs from service credentials.
|
|
4091
4077
|
*/
|
|
4092
4078
|
function generateConnectionUrls(services) {
|
|
@@ -4094,7 +4080,6 @@ function generateConnectionUrls(services) {
|
|
|
4094
4080
|
if (services.postgres) urls.DATABASE_URL = generatePostgresUrl(services.postgres);
|
|
4095
4081
|
if (services.redis) urls.REDIS_URL = generateRedisUrl(services.redis);
|
|
4096
4082
|
if (services.minio) urls.STORAGE_ENDPOINT = generateMinioEndpoint(services.minio);
|
|
4097
|
-
if (services.pgboss) urls.EVENT_PUBLISHER_CONNECTION_STRING = generatePgBossUrl(services.pgboss);
|
|
4098
4083
|
if (services.mailpit) {
|
|
4099
4084
|
urls.SMTP_HOST = services.mailpit.host;
|
|
4100
4085
|
urls.SMTP_PORT = String(services.mailpit.port);
|
|
@@ -4118,13 +4103,6 @@ function createStageSecrets(stage, services, options) {
|
|
|
4118
4103
|
serviceCredentials.minio.username = options.projectName;
|
|
4119
4104
|
}
|
|
4120
4105
|
}
|
|
4121
|
-
if (serviceCredentials.postgres && !serviceCredentials.pgboss) serviceCredentials.pgboss = {
|
|
4122
|
-
...PGBOSS_DEFAULTS,
|
|
4123
|
-
password: generateSecurePassword(),
|
|
4124
|
-
host: serviceCredentials.postgres.host,
|
|
4125
|
-
port: serviceCredentials.postgres.port,
|
|
4126
|
-
database: serviceCredentials.postgres.database
|
|
4127
|
-
};
|
|
4128
4106
|
return {
|
|
4129
4107
|
stage,
|
|
4130
4108
|
createdAt: now,
|
|
@@ -4987,25 +4965,25 @@ function loadPackageJson() {
|
|
|
4987
4965
|
* Run: pnpm --filter @geekmidas/cli sync-versions
|
|
4988
4966
|
*/
|
|
4989
4967
|
const GEEKMIDAS_VERSIONS = {
|
|
4990
|
-
"@geekmidas/audit": "~10.0.0-alpha.
|
|
4991
|
-
"@geekmidas/auth": "~10.0.0-alpha.
|
|
4992
|
-
"@geekmidas/cache": "~10.0.0-alpha.
|
|
4993
|
-
"@geekmidas/client": "~10.0.0-alpha.
|
|
4994
|
-
"@geekmidas/cloud": "~10.0.0-alpha.
|
|
4995
|
-
"@geekmidas/constructs": "~10.0.0-alpha.
|
|
4996
|
-
"@geekmidas/db": "~10.0.0-alpha.
|
|
4997
|
-
"@geekmidas/emailkit": "~10.0.0-alpha.
|
|
4998
|
-
"@geekmidas/envkit": "~10.0.0-alpha.
|
|
4999
|
-
"@geekmidas/errors": "~10.0.0-alpha.
|
|
5000
|
-
"@geekmidas/events": "~10.0.0-alpha.
|
|
5001
|
-
"@geekmidas/logger": "~10.0.0-alpha.
|
|
5002
|
-
"@geekmidas/manifest": "~10.0.0-alpha.
|
|
5003
|
-
"@geekmidas/rate-limit": "~10.0.0-alpha.
|
|
5004
|
-
"@geekmidas/schema": "~10.0.0-alpha.
|
|
5005
|
-
"@geekmidas/services": "~10.0.0-alpha.
|
|
5006
|
-
"@geekmidas/storage": "~10.0.0-alpha.
|
|
5007
|
-
"@geekmidas/telescope": "~10.0.0-alpha.
|
|
5008
|
-
"@geekmidas/testkit": "~10.0.0-alpha.
|
|
4968
|
+
"@geekmidas/audit": "~10.0.0-alpha.78",
|
|
4969
|
+
"@geekmidas/auth": "~10.0.0-alpha.78",
|
|
4970
|
+
"@geekmidas/cache": "~10.0.0-alpha.78",
|
|
4971
|
+
"@geekmidas/client": "~10.0.0-alpha.78",
|
|
4972
|
+
"@geekmidas/cloud": "~10.0.0-alpha.78",
|
|
4973
|
+
"@geekmidas/constructs": "~10.0.0-alpha.78",
|
|
4974
|
+
"@geekmidas/db": "~10.0.0-alpha.78",
|
|
4975
|
+
"@geekmidas/emailkit": "~10.0.0-alpha.78",
|
|
4976
|
+
"@geekmidas/envkit": "~10.0.0-alpha.78",
|
|
4977
|
+
"@geekmidas/errors": "~10.0.0-alpha.78",
|
|
4978
|
+
"@geekmidas/events": "~10.0.0-alpha.78",
|
|
4979
|
+
"@geekmidas/logger": "~10.0.0-alpha.78",
|
|
4980
|
+
"@geekmidas/manifest": "~10.0.0-alpha.78",
|
|
4981
|
+
"@geekmidas/rate-limit": "~10.0.0-alpha.78",
|
|
4982
|
+
"@geekmidas/schema": "~10.0.0-alpha.78",
|
|
4983
|
+
"@geekmidas/services": "~10.0.0-alpha.78",
|
|
4984
|
+
"@geekmidas/storage": "~10.0.0-alpha.78",
|
|
4985
|
+
"@geekmidas/telescope": "~10.0.0-alpha.78",
|
|
4986
|
+
"@geekmidas/testkit": "~10.0.0-alpha.78",
|
|
5009
4987
|
"@geekmidas/cli": `~${loadPackageJson().version}`
|
|
5010
4988
|
};
|
|
5011
4989
|
//#endregion
|
|
@@ -5588,7 +5566,7 @@ function deploy(options) {
|
|
|
5588
5566
|
role-to-assume: \${{ vars.AWS_ROLE_ARN }}
|
|
5589
5567
|
aws-region: ${options.region}
|
|
5590
5568
|
` : "";
|
|
5591
|
-
const keyDir = `~/.gkm/keys/${
|
|
5569
|
+
const keyDir = `~/.gkm/keys/${require_stale.projectKey({ name: options.name })}`;
|
|
5592
5570
|
const stageSecrets = sst ? credentials : `
|
|
5593
5571
|
# The stage's secrets are kept in the encrypted .gkm/secrets/<stage>.json,
|
|
5594
5572
|
# and each environment holds its key as GKM_SECRETS_KEY. .gkm/ is
|
|
@@ -6850,7 +6828,6 @@ docker-compose.constructs.yml
|
|
|
6850
6828
|
.env
|
|
6851
6829
|
.env.local
|
|
6852
6830
|
.env.*.local
|
|
6853
|
-
docker/.env
|
|
6854
6831
|
|
|
6855
6832
|
# IDE
|
|
6856
6833
|
.idea/
|
|
@@ -9919,18 +9896,17 @@ async function initCommand(projectName, options = {}) {
|
|
|
9919
9896
|
};
|
|
9920
9897
|
if (isFullstack) {
|
|
9921
9898
|
customSecrets.AUTH_PORT = "3002";
|
|
9922
|
-
customSecrets.AUTH_URL = "http://localhost:3002";
|
|
9923
9899
|
customSecrets.BETTER_AUTH_SECRET = `better-auth-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
9924
9900
|
customSecrets.BETTER_AUTH_URL = "http://localhost:3002";
|
|
9925
9901
|
customSecrets.BETTER_AUTH_TRUSTED_ORIGINS = "http://localhost:3000,http://localhost:3001";
|
|
9926
9902
|
}
|
|
9927
9903
|
devSecrets.custom = customSecrets;
|
|
9928
9904
|
const keys = {
|
|
9929
|
-
key:
|
|
9905
|
+
key: require_stale.projectKey({ name }),
|
|
9930
9906
|
legacy: [(0, node_path.basename)(targetDir)]
|
|
9931
9907
|
};
|
|
9932
|
-
await new
|
|
9933
|
-
const keyPath =
|
|
9908
|
+
await new require_stale.FileSecretsStore(targetDir, keys).write(local, devSecrets);
|
|
9909
|
+
const keyPath = require_stale.getKeyPath(local, keys);
|
|
9934
9910
|
console.log(` Secrets: .gkm/secrets/${local}.json (encrypted)`);
|
|
9935
9911
|
console.log(` Key: ${keyPath}\n`);
|
|
9936
9912
|
if (!options.skipInstall) {
|
|
@@ -10083,27 +10059,18 @@ var NotAnAwsRegion = class extends Error {
|
|
|
10083
10059
|
//#endregion
|
|
10084
10060
|
//#region src/setup/fullstack-secrets.ts
|
|
10085
10061
|
/**
|
|
10086
|
-
* Generate a secure random password for database users.
|
|
10087
|
-
* Uses a combination of timestamp and random bytes for uniqueness.
|
|
10088
|
-
*/
|
|
10089
|
-
function generateDbPassword() {
|
|
10090
|
-
return `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}${Math.random().toString(36).slice(2)}`;
|
|
10091
|
-
}
|
|
10092
|
-
/**
|
|
10093
|
-
* Generate database URL for an app.
|
|
10094
|
-
* All apps connect to the same database, but use different users/schemas.
|
|
10095
|
-
*/
|
|
10096
|
-
function generateDbUrl(appName, password, projectName, host = "localhost", port = 5432) {
|
|
10097
|
-
return `postgresql://${appName.replace(/-/g, "_")}:${password}@${host}:${port}/${`${projectName.replace(/-/g, "_")}_dev`}`;
|
|
10098
|
-
}
|
|
10099
|
-
/**
|
|
10100
10062
|
* Generate fullstack-aware custom secrets for a workspace.
|
|
10101
10063
|
*
|
|
10102
10064
|
* Generates:
|
|
10103
10065
|
* - Common secrets: PORT, LOG_LEVEL, JWT_SECRET (no `NODE_ENV` — the command
|
|
10104
10066
|
* decides that; see `gkm init`)
|
|
10105
|
-
* - Per-app database passwords and URLs for backend apps with db service
|
|
10106
10067
|
* - Better-auth secrets for apps using the better-auth framework
|
|
10068
|
+
*
|
|
10069
|
+
* No address of anything a construct declares — a database's or a tenant's
|
|
10070
|
+
* URL, a surface's or a site's. Those are derived from the construct, with
|
|
10071
|
+
* passwords from the stage, and one stored here would be a value set by hand,
|
|
10072
|
+
* which wins over the derived one: a `localhost` URL handed to a container,
|
|
10073
|
+
* with a password no role has.
|
|
10107
10074
|
*/
|
|
10108
10075
|
function generateFullstackCustomSecrets(workspace, containers = []) {
|
|
10109
10076
|
const hasDb = containers.includes("postgres");
|
|
@@ -10113,22 +10080,10 @@ function generateFullstackCustomSecrets(workspace, containers = []) {
|
|
|
10113
10080
|
JWT_SECRET: `dev-${Date.now()}-${Math.random().toString(36).slice(2)}`
|
|
10114
10081
|
};
|
|
10115
10082
|
if (!hasDb) return customs;
|
|
10116
|
-
const
|
|
10117
|
-
|
|
10118
|
-
if (appConfig.type === "web") {
|
|
10119
|
-
frontendPorts.push(appConfig.port);
|
|
10120
|
-
const upperName = appName.toUpperCase();
|
|
10121
|
-
customs[`${upperName}_URL`] = `http://localhost:${appConfig.port}`;
|
|
10122
|
-
continue;
|
|
10123
|
-
}
|
|
10124
|
-
if (appConfig.type === "mobile") continue;
|
|
10125
|
-
const password = generateDbPassword();
|
|
10126
|
-
const upperName = appName.toUpperCase();
|
|
10127
|
-
customs[`${upperName}_DATABASE_URL`] = generateDbUrl(appName, password, workspace.name);
|
|
10128
|
-
customs[`${upperName}_DB_PASSWORD`] = password;
|
|
10083
|
+
for (const appConfig of Object.values(workspace.apps)) {
|
|
10084
|
+
if (appConfig.type === "web" || appConfig.type === "mobile") continue;
|
|
10129
10085
|
if (appConfig.framework === "better-auth") {
|
|
10130
10086
|
customs.AUTH_PORT = String(appConfig.port);
|
|
10131
|
-
customs.AUTH_URL = `http://localhost:${appConfig.port}`;
|
|
10132
10087
|
customs.BETTER_AUTH_SECRET = `better-auth-${Date.now()}-${generateSecurePassword(16)}`;
|
|
10133
10088
|
customs.BETTER_AUTH_URL = `http://localhost:${appConfig.port}`;
|
|
10134
10089
|
}
|
|
@@ -10136,25 +10091,6 @@ function generateFullstackCustomSecrets(workspace, containers = []) {
|
|
|
10136
10091
|
if (customs.BETTER_AUTH_SECRET) customs.BETTER_AUTH_TRUSTED_ORIGINS = Object.values(workspace.apps).map((a) => a.port).map((p) => `http://localhost:${p}`).join(",");
|
|
10137
10092
|
return customs;
|
|
10138
10093
|
}
|
|
10139
|
-
/**
|
|
10140
|
-
* Extract *_DB_PASSWORD keys from secrets and write docker/.env.
|
|
10141
|
-
*
|
|
10142
|
-
* The docker/.env file contains database passwords that the PostgreSQL
|
|
10143
|
-
* init script reads to create per-app database users.
|
|
10144
|
-
*/
|
|
10145
|
-
async function writeDockerEnvFromSecrets(secrets, workspaceRoot) {
|
|
10146
|
-
const dbPasswordEntries = Object.entries(secrets.custom).filter(([key]) => key.endsWith("_DB_PASSWORD"));
|
|
10147
|
-
if (secrets.services.pgboss && !dbPasswordEntries.some(([key]) => key === "PGBOSS_DB_PASSWORD")) dbPasswordEntries.push(["PGBOSS_DB_PASSWORD", secrets.services.pgboss.password]);
|
|
10148
|
-
if (dbPasswordEntries.length === 0) return;
|
|
10149
|
-
const envContent = `# Auto-generated docker environment file
|
|
10150
|
-
# Contains database passwords for docker-compose postgres init
|
|
10151
|
-
# This file is gitignored - do not commit to version control
|
|
10152
|
-
${dbPasswordEntries.map(([key, value]) => `${key}=${value}`).join("\n")}
|
|
10153
|
-
`;
|
|
10154
|
-
const envPath = (0, node_path.join)(workspaceRoot, "docker", ".env");
|
|
10155
|
-
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(envPath), { recursive: true });
|
|
10156
|
-
await (0, node_fs_promises.writeFile)(envPath, envContent);
|
|
10157
|
-
}
|
|
10158
10094
|
//#endregion
|
|
10159
10095
|
//#region src/secrets/index.ts
|
|
10160
10096
|
const logger$2 = console;
|
|
@@ -10165,9 +10101,9 @@ const logger$2 = console;
|
|
|
10165
10101
|
*/
|
|
10166
10102
|
async function storeFor(stage) {
|
|
10167
10103
|
try {
|
|
10168
|
-
return await
|
|
10104
|
+
return await require_stale.secretsStoreFor(await require_config.loadWorkspaceSettings(), stage);
|
|
10169
10105
|
} catch (error) {
|
|
10170
|
-
if (error instanceof require_config.ConfigNotFound) return new
|
|
10106
|
+
if (error instanceof require_config.ConfigNotFound) return new require_stale.FileSecretsStore(process.cwd());
|
|
10171
10107
|
throw error;
|
|
10172
10108
|
}
|
|
10173
10109
|
}
|
|
@@ -10238,9 +10174,50 @@ async function secretsSetCommand(key, value, options) {
|
|
|
10238
10174
|
process.exit(1);
|
|
10239
10175
|
}
|
|
10240
10176
|
await assertCredentialValue(key, secretValue, stage);
|
|
10241
|
-
await store.write(stage,
|
|
10177
|
+
await store.write(stage, require_stale.withCustomSecret(secrets, key, secretValue));
|
|
10242
10178
|
logger$2.log(`\n✓ Secret "${key}" set for stage "${stage}" (${store.name})`);
|
|
10243
10179
|
}
|
|
10180
|
+
/** `gkm secrets:unset` for a key the stage does not hold. */
|
|
10181
|
+
var SecretNotSet = class extends Error {
|
|
10182
|
+
key;
|
|
10183
|
+
stage;
|
|
10184
|
+
constructor(key, stage) {
|
|
10185
|
+
super(`The stage '${stage}' holds no secret '${key}'. List what it holds with gkm secrets:show --stage ${stage}.`);
|
|
10186
|
+
this.key = key;
|
|
10187
|
+
this.stage = stage;
|
|
10188
|
+
this.name = "SecretNotSet";
|
|
10189
|
+
}
|
|
10190
|
+
};
|
|
10191
|
+
/** `gkm secrets:unset` on a stage that has no secrets at all. */
|
|
10192
|
+
var StageSecretsNotFound = class extends Error {
|
|
10193
|
+
stage;
|
|
10194
|
+
constructor(stage) {
|
|
10195
|
+
super(`The stage '${stage}' has no secrets, so there is nothing to remove.`);
|
|
10196
|
+
this.stage = stage;
|
|
10197
|
+
this.name = "StageSecretsNotFound";
|
|
10198
|
+
}
|
|
10199
|
+
};
|
|
10200
|
+
/**
|
|
10201
|
+
* Remove a custom secret from a stage, in the stage's own store — the file,
|
|
10202
|
+
* SSM or Secrets Manager. The rest of the stage is written back as it was.
|
|
10203
|
+
*
|
|
10204
|
+
* @throws {StageSecretsNotFound} when the stage holds no secrets
|
|
10205
|
+
* @throws {SecretNotSet} when it holds none by that key
|
|
10206
|
+
*/
|
|
10207
|
+
async function secretsUnsetCommand(key, options) {
|
|
10208
|
+
const { stage } = options;
|
|
10209
|
+
const store = await storeFor(stage);
|
|
10210
|
+
const secrets = await store.read(stage);
|
|
10211
|
+
if (!secrets) throw new StageSecretsNotFound(stage);
|
|
10212
|
+
if (!(key in secrets.custom)) throw new SecretNotSet(key, stage);
|
|
10213
|
+
const { [key]: _removed, ...custom } = secrets.custom;
|
|
10214
|
+
await store.write(stage, {
|
|
10215
|
+
...secrets,
|
|
10216
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10217
|
+
custom
|
|
10218
|
+
});
|
|
10219
|
+
logger$2.log(`\n✓ Secret "${key}" removed from stage "${stage}" (${store.name})`);
|
|
10220
|
+
}
|
|
10244
10221
|
/**
|
|
10245
10222
|
* A third party's credentials, checked against the schema of the construct
|
|
10246
10223
|
* that reads them before they are stored — what the app would otherwise
|
|
@@ -10260,7 +10237,7 @@ async function assertCredentialValue(key, value, stage) {
|
|
|
10260
10237
|
}
|
|
10261
10238
|
const check = await (await require_credentialSchemas.loadCredentialSchemas({
|
|
10262
10239
|
root: workspace.root,
|
|
10263
|
-
patterns:
|
|
10240
|
+
patterns: require_stale.constructGlobs(workspace)
|
|
10264
10241
|
})).check(key, value);
|
|
10265
10242
|
if (!check.ok) throw new require_credentialSchemas.CredentialsInvalid(stage, [{
|
|
10266
10243
|
key,
|
|
@@ -10286,7 +10263,7 @@ async function secretsShowCommand(options) {
|
|
|
10286
10263
|
logger$2.log(` host: ${creds.host}`);
|
|
10287
10264
|
logger$2.log(` port: ${creds.port}`);
|
|
10288
10265
|
logger$2.log(` username: ${creds.username}`);
|
|
10289
|
-
logger$2.log(` password: ${reveal ? creds.password :
|
|
10266
|
+
logger$2.log(` password: ${reveal ? creds.password : require_stale.maskPassword(creds.password)}`);
|
|
10290
10267
|
if (creds.database) logger$2.log(` database: ${creds.database}`);
|
|
10291
10268
|
if (creds.bucket) logger$2.log(` bucket: ${creds.bucket}`);
|
|
10292
10269
|
}
|
|
@@ -10296,7 +10273,7 @@ async function secretsShowCommand(options) {
|
|
|
10296
10273
|
if (secrets.urls.STORAGE_ENDPOINT) logger$2.log(` STORAGE_ENDPOINT: ${secrets.urls.STORAGE_ENDPOINT}`);
|
|
10297
10274
|
if (Object.keys(secrets.custom).length > 0) {
|
|
10298
10275
|
logger$2.log("\nCustom Secrets:");
|
|
10299
|
-
for (const [key, value] of Object.entries(secrets.custom)) logger$2.log(` ${key}: ${reveal ? value :
|
|
10276
|
+
for (const [key, value] of Object.entries(secrets.custom)) logger$2.log(` ${key}: ${reveal ? value : require_stale.maskPassword(value)}`);
|
|
10300
10277
|
}
|
|
10301
10278
|
if (!reveal) logger$2.log("\nUse --reveal to show actual values");
|
|
10302
10279
|
}
|
|
@@ -10376,7 +10353,7 @@ async function secretsImportCommand(file, options) {
|
|
|
10376
10353
|
function maskUrl(url) {
|
|
10377
10354
|
try {
|
|
10378
10355
|
const parsed = new URL(url);
|
|
10379
|
-
if (parsed.password) parsed.password =
|
|
10356
|
+
if (parsed.password) parsed.password = require_stale.maskPassword(parsed.password);
|
|
10380
10357
|
return parsed.toString();
|
|
10381
10358
|
} catch {
|
|
10382
10359
|
return url;
|
|
@@ -10397,8 +10374,7 @@ const logger$1 = console;
|
|
|
10397
10374
|
* Orchestrates:
|
|
10398
10375
|
* 1. Load workspace config
|
|
10399
10376
|
* 2. Resolve secrets (local → the stage's store → generate fresh)
|
|
10400
|
-
* 3.
|
|
10401
|
-
* 4. Start Docker services
|
|
10377
|
+
* 3. Start Docker services
|
|
10402
10378
|
*/
|
|
10403
10379
|
async function setupCommand(options = {}) {
|
|
10404
10380
|
logger$1.log("\n🔧 Setting up the local environment...\n");
|
|
@@ -10411,20 +10387,13 @@ async function setupCommand(options = {}) {
|
|
|
10411
10387
|
}
|
|
10412
10388
|
const stage = options.stage ?? loadedConfig.workspace.stages.local;
|
|
10413
10389
|
const { workspace } = loadedConfig;
|
|
10414
|
-
const isMultiApp = Object.keys(workspace.apps).length > 1;
|
|
10415
10390
|
logger$1.log(`📦 Workspace: ${workspace.name}`);
|
|
10416
10391
|
logger$1.log(`📱 Apps: ${Object.keys(workspace.apps).join(", ")}`);
|
|
10417
10392
|
logger$1.log(`🔑 Stage: ${stage}\n`);
|
|
10418
|
-
|
|
10419
|
-
if (!secrets) {
|
|
10393
|
+
if (!await resolveSecrets(stage, workspace, options)) {
|
|
10420
10394
|
logger$1.error("❌ Failed to resolve secrets. Exiting.");
|
|
10421
10395
|
process.exit(1);
|
|
10422
10396
|
}
|
|
10423
|
-
const containers = await require_state.derivedContainers(workspace, stage);
|
|
10424
|
-
if (isMultiApp && containers.includes("postgres")) {
|
|
10425
|
-
await writeDockerEnvFromSecrets(secrets, workspace.root);
|
|
10426
|
-
logger$1.log("📄 Generated docker/.env with database passwords");
|
|
10427
|
-
}
|
|
10428
10397
|
if (!options.skipDocker) {
|
|
10429
10398
|
logger$1.log("");
|
|
10430
10399
|
await reconcileLocal(workspace, stage, options);
|
|
@@ -10439,7 +10408,7 @@ async function setupCommand(options = {}) {
|
|
|
10439
10408
|
* free and quiet.
|
|
10440
10409
|
*/
|
|
10441
10410
|
async function reconcileLocal(workspace, stage, options) {
|
|
10442
|
-
const result = await
|
|
10411
|
+
const result = await require_stale.reconcileWorkspace(workspace, { stage });
|
|
10443
10412
|
if (result.plan.containers.length === 0) {
|
|
10444
10413
|
logger$1.log("🐳 No containers declared");
|
|
10445
10414
|
return;
|
|
@@ -10449,7 +10418,7 @@ async function reconcileLocal(workspace, stage, options) {
|
|
|
10449
10418
|
return;
|
|
10450
10419
|
}
|
|
10451
10420
|
logger$1.log("🐳 Services");
|
|
10452
|
-
for (const line of
|
|
10421
|
+
for (const line of require_stale.describeServices(result.services)) logger$1.log(line);
|
|
10453
10422
|
const url = result.plan.resources.filter((r) => r.kind === "rest-api" || r.kind === "site" || r.kind === "file-server").map((r) => result.env[r.envKey]).find((address) => address?.startsWith("https://"));
|
|
10454
10423
|
if (url) await ensureTrusted(workspace.root, url, { ...options.yes ? { assumeYes: true } : {} });
|
|
10455
10424
|
}
|
|
@@ -10466,11 +10435,11 @@ async function resolveSecrets(stage, workspace, options) {
|
|
|
10466
10435
|
logger$1.log("🔐 Generating fresh secrets (--force)...");
|
|
10467
10436
|
return generateFreshSecrets(stage, workspace);
|
|
10468
10437
|
}
|
|
10469
|
-
const store = await
|
|
10438
|
+
const store = await require_stale.secretsStoreFor(workspace, stage);
|
|
10470
10439
|
const secrets = await store.read(stage);
|
|
10471
10440
|
if (secrets) {
|
|
10472
10441
|
logger$1.log("🔐 Using existing secrets");
|
|
10473
|
-
const reconciled = reconcileSecrets(secrets, workspace, await
|
|
10442
|
+
const reconciled = reconcileSecrets(secrets, workspace, await require_stale.derivedContainers(workspace, stage));
|
|
10474
10443
|
if (reconciled) await store.write(stage, reconciled);
|
|
10475
10444
|
return reconciled ?? secrets;
|
|
10476
10445
|
}
|
|
@@ -10521,24 +10490,6 @@ function reconcileSecrets(secrets, workspace, containers = []) {
|
|
|
10521
10490
|
logger$1.log(` 🔄 Adding missing service credentials: ${name}`);
|
|
10522
10491
|
changed = true;
|
|
10523
10492
|
}
|
|
10524
|
-
if (result.services.postgres && !result.services.pgboss) {
|
|
10525
|
-
result = {
|
|
10526
|
-
...result,
|
|
10527
|
-
services: {
|
|
10528
|
-
...result.services,
|
|
10529
|
-
pgboss: {
|
|
10530
|
-
host: result.services.postgres.host,
|
|
10531
|
-
port: result.services.postgres.port,
|
|
10532
|
-
username: "pgboss",
|
|
10533
|
-
password: generateSecurePassword(),
|
|
10534
|
-
database: result.services.postgres.database ?? "app"
|
|
10535
|
-
}
|
|
10536
|
-
}
|
|
10537
|
-
};
|
|
10538
|
-
result.urls = generateConnectionUrls(result.services);
|
|
10539
|
-
logger$1.log(" 🔄 Adding missing service credentials: pgboss");
|
|
10540
|
-
changed = true;
|
|
10541
|
-
}
|
|
10542
10493
|
if (Object.keys(workspace.apps).length > 1) {
|
|
10543
10494
|
const expected = generateFullstackCustomSecrets(workspace, containers);
|
|
10544
10495
|
const missing = {};
|
|
@@ -10590,9 +10541,9 @@ function createFreshWorkspaceSecrets(stage, workspace, containers = []) {
|
|
|
10590
10541
|
*/
|
|
10591
10542
|
async function ensureStageSecrets(stage, cwd = process.cwd()) {
|
|
10592
10543
|
const { workspace } = await require_config.loadWorkspaceConfig(cwd);
|
|
10593
|
-
const store = await
|
|
10544
|
+
const store = await require_stale.secretsStoreFor(workspace, stage);
|
|
10594
10545
|
if (await store.read(stage)) return false;
|
|
10595
|
-
const secrets = createFreshWorkspaceSecrets(stage, workspace, await
|
|
10546
|
+
const secrets = createFreshWorkspaceSecrets(stage, workspace, await require_stale.derivedContainers(workspace, stage));
|
|
10596
10547
|
await store.write(stage, secrets);
|
|
10597
10548
|
return true;
|
|
10598
10549
|
}
|
|
@@ -10600,8 +10551,8 @@ async function ensureStageSecrets(stage, cwd = process.cwd()) {
|
|
|
10600
10551
|
* Generate fresh secrets for the workspace.
|
|
10601
10552
|
*/
|
|
10602
10553
|
async function generateFreshSecrets(stage, workspace) {
|
|
10603
|
-
const secrets = createFreshWorkspaceSecrets(stage, workspace, await
|
|
10604
|
-
const store = await
|
|
10554
|
+
const secrets = createFreshWorkspaceSecrets(stage, workspace, await require_stale.derivedContainers(workspace, stage));
|
|
10555
|
+
const store = await require_stale.secretsStoreFor(workspace, stage);
|
|
10605
10556
|
await store.write(stage, secrets);
|
|
10606
10557
|
logger$1.log(` Secrets written to the "${stage}" store (${store.name})`);
|
|
10607
10558
|
return secrets;
|
|
@@ -10641,7 +10592,7 @@ function printSummary(workspace, stage) {
|
|
|
10641
10592
|
* A no-op when nothing is recorded — no run yet, or one already torn down —
|
|
10642
10593
|
* so running it twice, or before a setup, is harmless.
|
|
10643
10594
|
*/
|
|
10644
|
-
async function dropTestDatabases(cwd, root, sql =
|
|
10595
|
+
async function dropTestDatabases(cwd, root, sql = require_stale.pgClient) {
|
|
10645
10596
|
const readyPath = (0, node_path.join)(cwd, require_ready.TEST_READY_FILE);
|
|
10646
10597
|
const ready = await readReady(readyPath);
|
|
10647
10598
|
const recorded = ready?.databases;
|
|
@@ -10649,9 +10600,9 @@ async function dropTestDatabases(cwd, root, sql = require_state.pgClient) {
|
|
|
10649
10600
|
const client = sql(recorded.port);
|
|
10650
10601
|
for (const name of recorded.names) {
|
|
10651
10602
|
if (!name.endsWith(`_test`)) throw new NotATestDatabase(name);
|
|
10652
|
-
await client.query(void 0, `DROP DATABASE IF EXISTS ${
|
|
10603
|
+
await client.query(void 0, `DROP DATABASE IF EXISTS ${require_stale.quoteIdentifier(name)} WITH (FORCE)`);
|
|
10653
10604
|
}
|
|
10654
|
-
await
|
|
10605
|
+
await require_stale.forgetState(root, require_workspace.TEST_STAGE);
|
|
10655
10606
|
const { databases: _dropped, ...rest } = ready;
|
|
10656
10607
|
await (0, node_fs_promises.writeFile)(readyPath, JSON.stringify(rest, null, 2));
|
|
10657
10608
|
return recorded.names;
|
|
@@ -10691,10 +10642,10 @@ async function testCommand(options = {}) {
|
|
|
10691
10642
|
const { ensureStageSecrets } = await Promise.resolve().then(() => setup_exports);
|
|
10692
10643
|
if (await ensureStageSecrets(stage, cwd)) console.log(` 🔐 Generated fresh ${stage} secrets (auto-setup)`);
|
|
10693
10644
|
}
|
|
10694
|
-
const defaultEnv =
|
|
10645
|
+
const defaultEnv = require_stale.loadEnvFiles(".env");
|
|
10695
10646
|
if (defaultEnv.loaded.length > 0) console.log(` 📦 Loaded env: ${defaultEnv.loaded.join(", ")}`);
|
|
10696
10647
|
if (!options.prepare) await teardown(cwd);
|
|
10697
|
-
const result = await
|
|
10648
|
+
const result = await require_stale.prepareEntryCredentials({
|
|
10698
10649
|
stage,
|
|
10699
10650
|
startDocker: !options.prepare,
|
|
10700
10651
|
secretsFileName: "test-secrets.json",
|
|
@@ -10715,14 +10666,14 @@ async function testCommand(options = {}) {
|
|
|
10715
10666
|
await (0, node_fs_promises.writeFile)(result.secretsJsonPath, JSON.stringify(finalCredentials, null, 2));
|
|
10716
10667
|
const gkmDir = (0, node_path.join)(cwd, ".gkm");
|
|
10717
10668
|
const preloadPath = (0, node_path.join)(gkmDir, "test-credentials-preload.ts");
|
|
10718
|
-
await
|
|
10669
|
+
await require_stale.createCredentialsPreload(preloadPath, result.secretsJsonPath);
|
|
10719
10670
|
const workspace = await require_config.loadWorkspaceConfig(cwd).then((loaded) => loaded.workspace).catch(() => void 0);
|
|
10720
10671
|
const manifestPath = workspace ? await require_ready.writeTestHarness({
|
|
10721
10672
|
root: workspace.root,
|
|
10722
10673
|
targets: [workspace.root, ...Object.values(workspace.apps).map((app) => (0, node_path.isAbsolute)(app.path) ? app.path : (0, node_path.join)(workspace.root, app.path))],
|
|
10723
|
-
patterns:
|
|
10724
|
-
cacheBackend:
|
|
10725
|
-
eventsBackend:
|
|
10674
|
+
patterns: require_stale.constructGlobs(workspace),
|
|
10675
|
+
cacheBackend: require_stale.backendsOf(workspace).cache,
|
|
10676
|
+
eventsBackend: require_stale.backendsOf(workspace).events,
|
|
10726
10677
|
stage: require_workspace.TEST_STAGE,
|
|
10727
10678
|
env: finalCredentials,
|
|
10728
10679
|
factories: (0, node_path.join)(workspace.root, workspace.test.factories ?? "test/factories")
|
|
@@ -10785,8 +10736,8 @@ async function teardown(cwd) {
|
|
|
10785
10736
|
* the plan provisions, on the port the shared container answers.
|
|
10786
10737
|
*/
|
|
10787
10738
|
function testDatabases(reconciled) {
|
|
10788
|
-
const port = reconciled?.ports[
|
|
10789
|
-
const names = reconciled ?
|
|
10739
|
+
const port = reconciled?.ports[require_stale.primaryPortKey("postgres")];
|
|
10740
|
+
const names = reconciled ? require_stale.postgresDatabaseNames(reconciled.plan) : [];
|
|
10790
10741
|
return port !== void 0 && names.length > 0 ? { databases: {
|
|
10791
10742
|
port,
|
|
10792
10743
|
names
|
|
@@ -10797,11 +10748,11 @@ function testDatabases(reconciled) {
|
|
|
10797
10748
|
* starts without the reference data the app needs.
|
|
10798
10749
|
*/
|
|
10799
10750
|
async function migrateTestStage(workspace, env) {
|
|
10800
|
-
const { migrateAndSeed } = await Promise.resolve().then(() => require("./migrate-
|
|
10751
|
+
const { migrateAndSeed } = await Promise.resolve().then(() => require("./migrate-Cgoy58Sh.cjs"));
|
|
10801
10752
|
const { discover } = await Promise.resolve().then(() => require("./discover-D1It5r_h.cjs")).then((n) => n.discover_exports);
|
|
10802
10753
|
const sources = {};
|
|
10803
10754
|
const manifest = await discover({
|
|
10804
|
-
patterns:
|
|
10755
|
+
patterns: require_stale.constructGlobs(workspace),
|
|
10805
10756
|
cwd: workspace.root,
|
|
10806
10757
|
sources
|
|
10807
10758
|
});
|
|
@@ -11230,7 +11181,7 @@ program.command("migrate").description("Apply each database construct's migratio
|
|
|
11230
11181
|
try {
|
|
11231
11182
|
const globalOptions = program.opts();
|
|
11232
11183
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
11233
|
-
const { migrateCommand } = await Promise.resolve().then(() => require("./migrate-
|
|
11184
|
+
const { migrateCommand } = await Promise.resolve().then(() => require("./migrate-Cgoy58Sh.cjs"));
|
|
11234
11185
|
await migrateCommand({
|
|
11235
11186
|
...options,
|
|
11236
11187
|
...construct ? { construct } : {}
|
|
@@ -11244,7 +11195,7 @@ program.command("seed").description("Migrate, then run each database construct's
|
|
|
11244
11195
|
try {
|
|
11245
11196
|
const globalOptions = program.opts();
|
|
11246
11197
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
11247
|
-
const { seedCommand } = await Promise.resolve().then(() => require("./migrate-
|
|
11198
|
+
const { seedCommand } = await Promise.resolve().then(() => require("./migrate-Cgoy58Sh.cjs"));
|
|
11248
11199
|
await seedCommand({
|
|
11249
11200
|
...options,
|
|
11250
11201
|
...construct ? { construct } : {}
|
|
@@ -11258,7 +11209,7 @@ program.command("migration").description("Write a construct's next migration: an
|
|
|
11258
11209
|
try {
|
|
11259
11210
|
const globalOptions = program.opts();
|
|
11260
11211
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
11261
|
-
const { migrationCommand } = await Promise.resolve().then(() => require("./migrate-
|
|
11212
|
+
const { migrationCommand } = await Promise.resolve().then(() => require("./migrate-Cgoy58Sh.cjs"));
|
|
11262
11213
|
await migrationCommand({
|
|
11263
11214
|
construct,
|
|
11264
11215
|
...name ? { name } : {}
|
|
@@ -11297,7 +11248,7 @@ program.command("docker").description("Generate Docker deployment files").option
|
|
|
11297
11248
|
try {
|
|
11298
11249
|
const globalOptions = program.opts();
|
|
11299
11250
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
11300
|
-
await
|
|
11251
|
+
await require_stale.dockerCommand(options);
|
|
11301
11252
|
} catch (error) {
|
|
11302
11253
|
console.error(formatError(error));
|
|
11303
11254
|
process.exit(1);
|
|
@@ -11317,7 +11268,7 @@ program.command("prepack").description("Generate Docker files for production dep
|
|
|
11317
11268
|
try {
|
|
11318
11269
|
const globalOptions = program.opts();
|
|
11319
11270
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
11320
|
-
await
|
|
11271
|
+
await require_stale.dockerCommand({
|
|
11321
11272
|
build: options.build,
|
|
11322
11273
|
push: options.push,
|
|
11323
11274
|
tag: options.tag,
|
|
@@ -11348,11 +11299,21 @@ program.command("secrets:set").description("Set a custom secret for a stage").ar
|
|
|
11348
11299
|
process.exit(1);
|
|
11349
11300
|
}
|
|
11350
11301
|
});
|
|
11302
|
+
program.command("secrets:unset").description("Remove a custom secret from a stage").argument("<key>", "Secret key (e.g., API_KEY)").requiredOption("--stage <stage>", "Stage name").action(async (key, options) => {
|
|
11303
|
+
try {
|
|
11304
|
+
const globalOptions = program.opts();
|
|
11305
|
+
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
11306
|
+
await secretsUnsetCommand(key, options);
|
|
11307
|
+
} catch (error) {
|
|
11308
|
+
console.error(formatError(error));
|
|
11309
|
+
process.exit(1);
|
|
11310
|
+
}
|
|
11311
|
+
});
|
|
11351
11312
|
program.command("secrets:add").description("Build the keys a stage must be given — buckets, mail, file servers, third parties' credentials — across every app").requiredOption("--stage <stage>", "Stage name").option("--missing", "Only the keys the stage has not set").option("--json", "Print the keys as JSON and ask nothing").action(async (options) => {
|
|
11352
11313
|
try {
|
|
11353
11314
|
const globalOptions = program.opts();
|
|
11354
11315
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
11355
|
-
const { secretsAddCommand } = await Promise.resolve().then(() => require("./add-
|
|
11316
|
+
const { secretsAddCommand } = await Promise.resolve().then(() => require("./add-BvOICikp.cjs"));
|
|
11356
11317
|
await secretsAddCommand(options);
|
|
11357
11318
|
} catch (error) {
|
|
11358
11319
|
console.error(formatError(error));
|
|
@@ -11363,7 +11324,7 @@ program.command("encryption:rotate").description("Add a new current key to an En
|
|
|
11363
11324
|
try {
|
|
11364
11325
|
const globalOptions = program.opts();
|
|
11365
11326
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
11366
|
-
const { encryptionRotateCommand } = await Promise.resolve().then(() => require("./encryption-
|
|
11327
|
+
const { encryptionRotateCommand } = await Promise.resolve().then(() => require("./encryption-CbMI24fI.cjs"));
|
|
11367
11328
|
await encryptionRotateCommand(construct, options);
|
|
11368
11329
|
} catch (error) {
|
|
11369
11330
|
console.error(formatError(error));
|
|
@@ -11374,7 +11335,7 @@ program.command("encryption:retire").description("Remove an old key from an Encr
|
|
|
11374
11335
|
try {
|
|
11375
11336
|
const globalOptions = program.opts();
|
|
11376
11337
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
11377
|
-
const { encryptionRetireCommand } = await Promise.resolve().then(() => require("./encryption-
|
|
11338
|
+
const { encryptionRetireCommand } = await Promise.resolve().then(() => require("./encryption-CbMI24fI.cjs"));
|
|
11378
11339
|
await encryptionRetireCommand(construct, key, options);
|
|
11379
11340
|
} catch (error) {
|
|
11380
11341
|
console.error(formatError(error));
|
|
@@ -11417,7 +11378,7 @@ program.command("secrets:reconcile").description("Backfill missing custom secret
|
|
|
11417
11378
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
11418
11379
|
const { loadWorkspaceConfig } = await Promise.resolve().then(() => require("./config.cjs"));
|
|
11419
11380
|
const { reconcileMissingSecrets } = await Promise.resolve().then(() => require("./reconcile-CuCQBa5-.cjs"));
|
|
11420
|
-
const { secretsStoreFor } = await Promise.resolve().then(() => require("./
|
|
11381
|
+
const { secretsStoreFor } = await Promise.resolve().then(() => require("./stale-BsiPJI7Y.cjs")).then((n) => n.store_exports);
|
|
11421
11382
|
const { workspace } = await loadWorkspaceConfig();
|
|
11422
11383
|
const stage = options.stage ?? workspace.stages.local;
|
|
11423
11384
|
const store = await secretsStoreFor(workspace, stage);
|
|
@@ -11426,7 +11387,7 @@ program.command("secrets:reconcile").description("Backfill missing custom secret
|
|
|
11426
11387
|
console.error(`No secrets found for stage "${stage}". Run "gkm secrets:init --stage ${stage}" first.`);
|
|
11427
11388
|
process.exit(1);
|
|
11428
11389
|
}
|
|
11429
|
-
const { derivedContainers } = await Promise.resolve().then(() => require("./
|
|
11390
|
+
const { derivedContainers } = await Promise.resolve().then(() => require("./stale-BsiPJI7Y.cjs")).then((n) => n.workspace_exports);
|
|
11430
11391
|
const result = reconcileMissingSecrets(secrets, workspace, await derivedContainers(workspace, stage));
|
|
11431
11392
|
if (!result) {
|
|
11432
11393
|
console.log(`\n✓ Secrets for stage "${stage}" are up-to-date`);
|
|
@@ -11444,7 +11405,7 @@ program.command("secrets:migrate").description("Copy a deployed stage's secrets
|
|
|
11444
11405
|
try {
|
|
11445
11406
|
const globalOptions = program.opts();
|
|
11446
11407
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
11447
|
-
const { secretsMigrateCommand } = await Promise.resolve().then(() => require("./migrate-
|
|
11408
|
+
const { secretsMigrateCommand } = await Promise.resolve().then(() => require("./migrate-B4GBvCNY.cjs"));
|
|
11448
11409
|
await secretsMigrateCommand(options);
|
|
11449
11410
|
} catch (error) {
|
|
11450
11411
|
console.error(formatError(error));
|
|
@@ -11452,7 +11413,7 @@ program.command("secrets:migrate").description("Copy a deployed stage's secrets
|
|
|
11452
11413
|
}
|
|
11453
11414
|
});
|
|
11454
11415
|
program.command("deploy").description("Deploy a stage through its target").option("--target <name>", "Deploy target: dokploy, compose, sst, or one named in deploy.targets (default: deploy.default)").option("--provider <provider>", "[DEPRECATED] Use --target instead").requiredOption("--stage <stage>", "Deployment stage (e.g., production, staging)").option("--tag <tag>", "Image tag (default: stage-timestamp; compose: the commit). Compose pulls a given tag").option("--skip-push", "Skip pushing image to registry").option("--skip-build", "Skip build step (use existing build)").option("--json", "Write events as JSON lines instead of progress; never prompts").option("--dry-run", "Show what would be created or reused; change, build and push nothing").option("--atomic", "If the release fails, roll back every app it released, not only the failed ones").option("--allow-dev-services <list>", "Server targets: run MinIO and/or Mailpit (minio,mailpit) for mail and buckets the stage's secrets don't configure. Not production-grade").action(async (options) => {
|
|
11455
|
-
const { deployCli } = await Promise.resolve().then(() => require("./cli-
|
|
11416
|
+
const { deployCli } = await Promise.resolve().then(() => require("./cli-K6Vj_pPW.cjs"));
|
|
11456
11417
|
const globalOptions = program.opts();
|
|
11457
11418
|
const code = await deployCli({
|
|
11458
11419
|
cwd: (0, node_path.resolve)(globalOptions.cwd ?? process.cwd()),
|
|
@@ -11469,7 +11430,7 @@ program.command("deploy").description("Deploy a stage through its target").optio
|
|
|
11469
11430
|
});
|
|
11470
11431
|
program.command("deploy:rollback").description("Put a stage's app back on its previous release (Dokploy): one app with --app, every app with --atomic").requiredOption("--stage <stage>", "A deployed stage").option("--app <app>", "The app to roll back").option("--atomic", "Roll back every app that has an earlier release").action(async (options) => {
|
|
11471
11432
|
try {
|
|
11472
|
-
const { rollbackStage } = await Promise.resolve().then(() => require("./rollback-
|
|
11433
|
+
const { rollbackStage } = await Promise.resolve().then(() => require("./rollback-F3P-rA-r.cjs")).then((n) => n.rollback_exports);
|
|
11473
11434
|
const { terminalCredentials } = await Promise.resolve().then(() => require("./terminal-BL5E0xbR.cjs"));
|
|
11474
11435
|
const globalOptions = program.opts();
|
|
11475
11436
|
await rollbackStage({
|
|
@@ -11505,7 +11466,7 @@ program.command("deploy:github").description("Let GitHub Actions deploy a stage:
|
|
|
11505
11466
|
try {
|
|
11506
11467
|
const globalOptions = program.opts();
|
|
11507
11468
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
11508
|
-
const { deployGithubCommand } = await Promise.resolve().then(() => require("./github-
|
|
11469
|
+
const { deployGithubCommand } = await Promise.resolve().then(() => require("./github-D9vGqdLk.cjs"));
|
|
11509
11470
|
await deployGithubCommand(options);
|
|
11510
11471
|
} catch (error) {
|
|
11511
11472
|
console.error(formatError(error));
|