@geekmidas/cli 1.10.2 → 1.10.4

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/index.mjs CHANGED
@@ -8,7 +8,7 @@ import { getKeyPath, maskPassword, readStageSecrets, secretsExist, setCustomSecr
8
8
  import { DokployApi } from "./dokploy-api-2ldYoN3i.mjs";
9
9
  import { encryptSecrets } from "./encryption-BOH5M-f-.mjs";
10
10
  import { CachedStateProvider } from "./CachedStateProvider-BDq5WqSy.mjs";
11
- import { createStageSecrets, generateDbPassword, generateDbUrl, generateFullstackCustomSecrets, rotateServicePassword, writeDockerEnvFromSecrets } from "./fullstack-secrets-UZAFWuH4.mjs";
11
+ import { createStageSecrets, generateDbPassword, generateDbUrl, generateFullstackCustomSecrets, rotateServicePassword, writeDockerEnvFromSecrets } from "./fullstack-secrets-odm79Uo1.mjs";
12
12
  import { generateReactQueryCommand } from "./openapi-react-query-C4UdILaI.mjs";
13
13
  import { isSSMConfigured, pullSecrets, pushSecrets } from "./sync-CbeKrnQV.mjs";
14
14
  import { createRequire } from "node:module";
@@ -35,7 +35,7 @@ import prompts from "prompts";
35
35
 
36
36
  //#region package.json
37
37
  var name = "@geekmidas/cli";
38
- var version = "1.10.1";
38
+ var version = "1.10.3";
39
39
  var description = "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs";
40
40
  var private$1 = false;
41
41
  var type = "module";
@@ -1345,7 +1345,8 @@ async function workspaceDevCommand(workspace, options) {
1345
1345
  ], {
1346
1346
  cwd: workspace.root,
1347
1347
  stdio: "inherit",
1348
- env: turboEnv
1348
+ env: turboEnv,
1349
+ detached: true
1349
1350
  });
1350
1351
  let openApiWatcher = null;
1351
1352
  if (frontendApps.length > 0 && backendApps.length > 0) {
@@ -1391,14 +1392,24 @@ async function workspaceDevCommand(workspace, options) {
1391
1392
  isShuttingDown = true;
1392
1393
  logger$11.log("\n🛑 Shutting down workspace...");
1393
1394
  if (openApiWatcher) openApiWatcher.close().catch(() => {});
1394
- if (turboProcess.pid) try {
1395
- process.kill(-turboProcess.pid, "SIGTERM");
1395
+ const pid = turboProcess.pid;
1396
+ if (pid) try {
1397
+ process.kill(-pid, "SIGTERM");
1396
1398
  } catch {
1397
- turboProcess.kill("SIGTERM");
1399
+ try {
1400
+ process.kill(pid, "SIGTERM");
1401
+ } catch {}
1398
1402
  }
1399
1403
  setTimeout(() => {
1404
+ if (pid) try {
1405
+ process.kill(-pid, "SIGKILL");
1406
+ } catch {
1407
+ try {
1408
+ process.kill(pid, "SIGKILL");
1409
+ } catch {}
1410
+ }
1400
1411
  process.exit(0);
1401
- }, 2e3);
1412
+ }, 3e3);
1402
1413
  };
1403
1414
  process.on("SIGINT", shutdown);
1404
1415
  process.on("SIGTERM", shutdown);
@@ -7596,6 +7607,7 @@ export default defineWorkspace({
7596
7607
  path: 'apps/auth',
7597
7608
  port: 3002,
7598
7609
  entry: './src/index.ts',
7610
+ framework: 'better-auth',
7599
7611
  envParser: './src/config/env#envParser',
7600
7612
  logger: './src/config/logger#logger',
7601
7613
  },
@@ -7638,6 +7650,10 @@ export default defineWorkspace({
7638
7650
  default: 'dokploy',
7639
7651
  },`;
7640
7652
  config$1 += `
7653
+ secrets: {
7654
+ enabled: true,
7655
+ },`;
7656
+ config$1 += `
7641
7657
  });
7642
7658
  `;
7643
7659
  return config$1;
@@ -11216,7 +11232,11 @@ async function resolveSecrets(stage, workspace, options) {
11216
11232
  if (secretsExist(stage, workspace.root)) {
11217
11233
  logger$1.log("🔐 Using existing local secrets");
11218
11234
  const secrets = await readStageSecrets(stage, workspace.root);
11219
- if (secrets) return secrets;
11235
+ if (secrets) {
11236
+ const reconciled = reconcileSecrets(secrets, workspace);
11237
+ if (reconciled) await writeStageSecrets(reconciled, workspace.root);
11238
+ return reconciled ?? secrets;
11239
+ }
11220
11240
  }
11221
11241
  if (isSSMConfigured(workspace)) {
11222
11242
  logger$1.log("☁️ Checking for remote secrets in SSM...");
@@ -11236,6 +11256,29 @@ async function resolveSecrets(stage, workspace, options) {
11236
11256
  return generateFreshSecrets(stage, workspace, options);
11237
11257
  }
11238
11258
  /**
11259
+ * Reconcile existing secrets with expected workspace-derived keys.
11260
+ * Adds missing keys (e.g. BETTER_AUTH_*) without overwriting existing values.
11261
+ * Returns the updated secrets if changes were made, or null if no changes needed.
11262
+ * @internal Exported for testing
11263
+ */
11264
+ function reconcileSecrets(secrets, workspace) {
11265
+ const isMultiApp = Object.keys(workspace.apps).length > 1;
11266
+ if (!isMultiApp) return null;
11267
+ const expected = generateFullstackCustomSecrets(workspace);
11268
+ const missing = {};
11269
+ for (const [key, value] of Object.entries(expected)) if (!(key in secrets.custom)) missing[key] = value;
11270
+ if (Object.keys(missing).length === 0) return null;
11271
+ logger$1.log(` 🔄 Adding missing secrets: ${Object.keys(missing).join(", ")}`);
11272
+ return {
11273
+ ...secrets,
11274
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
11275
+ custom: {
11276
+ ...secrets.custom,
11277
+ ...missing
11278
+ }
11279
+ };
11280
+ }
11281
+ /**
11239
11282
  * Generate fresh secrets for the workspace.
11240
11283
  */
11241
11284
  async function generateFreshSecrets(stage, workspace, options) {
@@ -11346,6 +11389,24 @@ async function testCommand(options = {}) {
11346
11389
  }
11347
11390
  } catch {}
11348
11391
  console.log("");
11392
+ const allSecrets = {
11393
+ ...secretsEnv,
11394
+ ...dependencyEnv
11395
+ };
11396
+ const gkmDir = join(cwd, ".gkm");
11397
+ await mkdir(gkmDir, { recursive: true });
11398
+ const secretsJsonPath = join(gkmDir, "test-secrets.json");
11399
+ await writeFile(secretsJsonPath, JSON.stringify(allSecrets, null, 2));
11400
+ const preloadPath = join(gkmDir, "test-credentials-preload.ts");
11401
+ await createCredentialsPreload(preloadPath, secretsJsonPath);
11402
+ const existingNodeOptions = process.env.NODE_OPTIONS ?? "";
11403
+ const tsxImport = "--import=tsx";
11404
+ const preloadImport = `--import=${preloadPath}`;
11405
+ const nodeOptions = [
11406
+ existingNodeOptions,
11407
+ tsxImport,
11408
+ preloadImport
11409
+ ].filter(Boolean).join(" ");
11349
11410
  const args = [];
11350
11411
  if (options.run) args.push("run");
11351
11412
  else if (options.watch) args.push("--watch");
@@ -11357,9 +11418,9 @@ async function testCommand(options = {}) {
11357
11418
  stdio: "inherit",
11358
11419
  env: {
11359
11420
  ...process.env,
11360
- ...secretsEnv,
11361
- ...dependencyEnv,
11362
- NODE_ENV: "test"
11421
+ ...allSecrets,
11422
+ NODE_ENV: "test",
11423
+ NODE_OPTIONS: nodeOptions
11363
11424
  }
11364
11425
  });
11365
11426
  return new Promise((resolve$1, reject) => {
@@ -11790,7 +11851,7 @@ program.command("secrets:push").description("Push secrets to remote provider (SS
11790
11851
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
11791
11852
  const { loadWorkspaceConfig: loadWorkspaceConfig$1 } = await import("./config.mjs");
11792
11853
  const { pushSecrets: pushSecrets$1 } = await import("./sync-6FoT41G3.mjs");
11793
- const { reconcileMissingSecrets } = await import("./reconcile-D2WCDQue.mjs");
11854
+ const { reconcileMissingSecrets } = await import("./reconcile-WzC1oAUV.mjs");
11794
11855
  const { readStageSecrets: readStageSecrets$1, writeStageSecrets: writeStageSecrets$1 } = await import("./storage-Dx_jZbq6.mjs");
11795
11856
  const { workspace } = await loadWorkspaceConfig$1();
11796
11857
  const secrets = await readStageSecrets$1(options.stage, workspace.root);
@@ -11816,7 +11877,7 @@ program.command("secrets:pull").description("Pull secrets from remote provider (
11816
11877
  const { loadWorkspaceConfig: loadWorkspaceConfig$1 } = await import("./config.mjs");
11817
11878
  const { pullSecrets: pullSecrets$1 } = await import("./sync-6FoT41G3.mjs");
11818
11879
  const { writeStageSecrets: writeStageSecrets$1 } = await import("./storage-Dx_jZbq6.mjs");
11819
- const { reconcileMissingSecrets } = await import("./reconcile-D2WCDQue.mjs");
11880
+ const { reconcileMissingSecrets } = await import("./reconcile-WzC1oAUV.mjs");
11820
11881
  const { workspace } = await loadWorkspaceConfig$1();
11821
11882
  let secrets = await pullSecrets$1(options.stage, workspace);
11822
11883
  if (!secrets) {
@@ -11841,7 +11902,7 @@ program.command("secrets:reconcile").description("Backfill missing custom secret
11841
11902
  const globalOptions = program.opts();
11842
11903
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
11843
11904
  const { loadWorkspaceConfig: loadWorkspaceConfig$1 } = await import("./config.mjs");
11844
- const { reconcileMissingSecrets } = await import("./reconcile-D2WCDQue.mjs");
11905
+ const { reconcileMissingSecrets } = await import("./reconcile-WzC1oAUV.mjs");
11845
11906
  const { readStageSecrets: readStageSecrets$1, writeStageSecrets: writeStageSecrets$1 } = await import("./storage-Dx_jZbq6.mjs");
11846
11907
  const { workspace } = await loadWorkspaceConfig$1();
11847
11908
  const secrets = await readStageSecrets$1(options.stage, workspace.root);