@geekmidas/cli 1.10.19 → 1.10.21

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @geekmidas/cli
2
2
 
3
+ ## 1.10.21
4
+
5
+ ### Patch Changes
6
+
7
+ - ✨ [`9b56519`](https://github.com/geekmidas/toolbox/commit/9b5651989ccd1ca55c8b7150647c850eda056213) Thanks [@geekmidas](https://github.com/geekmidas)! - Add debugging and complete traces
8
+
9
+ ## 1.10.20
10
+
11
+ ### Patch Changes
12
+
13
+ - 🐛 [`02991d4`](https://github.com/geekmidas/toolbox/commit/02991d410c4f2fab5fbaa568300e5d8943b3ba45) Thanks [@geekmidas](https://github.com/geekmidas)! - Fix dev command port credentials resolution
14
+
3
15
  ## 1.10.19
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -4,7 +4,7 @@ const require_workspace = require('./workspace-4SP3Gx4Y.cjs');
4
4
  const require_config = require('./config-D3ORuiUs.cjs');
5
5
  const require_credentials = require('./credentials-C8DWtnMY.cjs');
6
6
  const require_storage = require('./storage-DLEb8Dkd.cjs');
7
- const require_openapi = require('./openapi-CsCNpSf8.cjs');
7
+ const require_openapi = require('./openapi-N_iCUhJU.cjs');
8
8
  const require_dokploy_api = require('./dokploy-api-DLgvEQlr.cjs');
9
9
  const require_encryption = require('./encryption-BE0UOb8j.cjs');
10
10
  const require_CachedStateProvider = require('./CachedStateProvider-D73dCqfH.cjs');
@@ -35,7 +35,7 @@ const prompts = require_chunk.__toESM(require("prompts"));
35
35
 
36
36
  //#region package.json
37
37
  var name = "@geekmidas/cli";
38
- var version = "1.10.18";
38
+ var version = "1.10.20";
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";
@@ -740,8 +740,7 @@ async function prepareEntryCredentials(options) {
740
740
  workspaceAppPort = appInfo.app.port;
741
741
  secretsRoot = appInfo.workspaceRoot;
742
742
  appName = appInfo.appName;
743
- } catch (error) {
744
- logger$13.log(`⚠️ Could not load workspace config: ${error.message}`);
743
+ } catch {
745
744
  secretsRoot = findSecretsRoot(cwd);
746
745
  appName = require_config.getAppNameFromCwd(cwd) ?? void 0;
747
746
  }
@@ -1254,6 +1253,7 @@ async function devCommand(options) {
1254
1253
  let secretsRoot = process.cwd();
1255
1254
  let workspaceAppName;
1256
1255
  let workspaceAppPort;
1256
+ let workspace;
1257
1257
  if (appName) try {
1258
1258
  const appConfig = await require_config.loadAppConfig();
1259
1259
  config = appConfig.gkmConfig;
@@ -1261,6 +1261,7 @@ async function devCommand(options) {
1261
1261
  secretsRoot = appConfig.workspaceRoot;
1262
1262
  workspaceAppName = appConfig.appName;
1263
1263
  workspaceAppPort = appConfig.app.port;
1264
+ workspace = appConfig.workspace;
1264
1265
  logger$11.log(`📦 Running app: ${appConfig.appName} on port ${workspaceAppPort}`);
1265
1266
  if (appConfig.app.entry) {
1266
1267
  logger$11.log(`📄 Using entry point: ${appConfig.app.entry}`);
@@ -1324,6 +1325,16 @@ async function devCommand(options) {
1324
1325
  const runtime = config.runtime ?? "node";
1325
1326
  let secretsJsonPath;
1326
1327
  const appSecrets = await loadSecretsForApp(secretsRoot, workspaceAppName);
1328
+ const resolvedPorts = await resolveServicePorts(secretsRoot);
1329
+ if (Object.keys(resolvedPorts.ports).length > 0) {
1330
+ const rewritten = rewriteUrlsWithPorts(appSecrets, resolvedPorts);
1331
+ Object.assign(appSecrets, rewritten);
1332
+ logger$11.log(`🔌 Applied ${Object.keys(resolvedPorts.ports).length} port mapping(s)`);
1333
+ }
1334
+ if (workspace && workspaceAppName) {
1335
+ const depEnv = require_workspace.getDependencyEnvVars(workspace, workspaceAppName);
1336
+ Object.assign(appSecrets, depEnv);
1337
+ }
1327
1338
  if (Object.keys(appSecrets).length > 0) {
1328
1339
  const secretsDir = (0, node_path.join)(secretsRoot, ".gkm");
1329
1340
  await (0, node_fs_promises.mkdir)(secretsDir, { recursive: true });
@@ -1386,7 +1397,9 @@ async function devCommand(options) {
1386
1397
  logger$11.log("✅ Rebuild complete, restarting server...");
1387
1398
  await devServer.restart();
1388
1399
  } catch (error) {
1389
- logger$11.error("❌ Rebuild failed:", error.message);
1400
+ const err = error;
1401
+ logger$11.error(`❌ Rebuild failed: ${err.message}`);
1402
+ if (err.stack) logger$11.error(err.stack);
1390
1403
  }
1391
1404
  }, 300);
1392
1405
  });
@@ -2398,6 +2411,34 @@ function assembleManifestField(infos, constructs) {
2398
2411
  return groupInfosByPartition(infos, constructs);
2399
2412
  }
2400
2413
 
2414
+ //#endregion
2415
+ //#region src/debug.ts
2416
+ let _debug = false;
2417
+ /**
2418
+ * Enable debug mode globally.
2419
+ * When enabled, verbose error details are shown everywhere.
2420
+ */
2421
+ function enableDebug() {
2422
+ _debug = true;
2423
+ }
2424
+ /**
2425
+ * Format a fatal error for display.
2426
+ * Always includes the full stack trace since these are process-ending errors.
2427
+ */
2428
+ function formatError(error) {
2429
+ if (!(error instanceof Error)) return String(error);
2430
+ let output$2 = error.stack ?? error.message;
2431
+ let cause = error.cause;
2432
+ while (cause) if (cause instanceof Error) {
2433
+ output$2 += `\n\nCaused by: ${cause.stack ?? cause.message}`;
2434
+ cause = cause.cause;
2435
+ } else {
2436
+ output$2 += `\n\nCaused by: ${String(cause)}`;
2437
+ break;
2438
+ }
2439
+ return output$2;
2440
+ }
2441
+
2401
2442
  //#endregion
2402
2443
  //#region src/deploy/state.ts
2403
2444
  /**
@@ -6787,10 +6828,10 @@ const GEEKMIDAS_VERSIONS = {
6787
6828
  "@geekmidas/audit": "~2.0.0",
6788
6829
  "@geekmidas/auth": "~2.0.0",
6789
6830
  "@geekmidas/cache": "~1.1.0",
6790
- "@geekmidas/client": "~4.0.0",
6831
+ "@geekmidas/client": "~4.0.1",
6791
6832
  "@geekmidas/cloud": "~1.0.0",
6792
- "@geekmidas/constructs": "~3.0.2",
6793
- "@geekmidas/db": "~1.0.0",
6833
+ "@geekmidas/constructs": "~3.0.3",
6834
+ "@geekmidas/db": "~1.0.1",
6794
6835
  "@geekmidas/emailkit": "~1.0.0",
6795
6836
  "@geekmidas/envkit": "~1.0.4",
6796
6837
  "@geekmidas/errors": "~1.0.0",
@@ -12139,14 +12180,17 @@ function executeUpgrade(upgradable, pm, cwd) {
12139
12180
  //#endregion
12140
12181
  //#region src/index.ts
12141
12182
  const program = new commander.Command();
12142
- program.name("gkm").description("GeekMidas backend framework CLI").version(package_default.version).option("--cwd <path>", "Change working directory");
12183
+ program.name("gkm").description("GeekMidas backend framework CLI").version(package_default.version).option("--cwd <path>", "Change working directory").option("--debug", "Enable debug mode (verbose errors with stack traces)").hook("preAction", () => {
12184
+ const opts = program.opts();
12185
+ if (opts.debug) enableDebug();
12186
+ });
12143
12187
  program.command("init").description("Scaffold a new project").argument("[name]", "Project name").option("--template <template>", "Project template (minimal, api, serverless, worker)").option("--skip-install", "Skip dependency installation", false).option("-y, --yes", "Skip prompts, use defaults", false).option("--monorepo", "Setup as monorepo with packages/models", false).option("--api-path <path>", "API app path in monorepo (default: apps/api)").option("--pm <manager>", "Package manager (pnpm, npm, yarn, bun)").action(async (name$1, options) => {
12144
12188
  try {
12145
12189
  const globalOptions = program.opts();
12146
12190
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12147
12191
  await initCommand(name$1, options);
12148
12192
  } catch (error) {
12149
- console.error(error instanceof Error ? error.message : "Command failed");
12193
+ console.error(formatError(error));
12150
12194
  process.exit(1);
12151
12195
  }
12152
12196
  });
@@ -12156,7 +12200,7 @@ program.command("setup").description("Setup development environment (secrets, Do
12156
12200
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12157
12201
  await setupCommand(options);
12158
12202
  } catch (error) {
12159
- console.error(error instanceof Error ? error.message : "Command failed");
12203
+ console.error(formatError(error));
12160
12204
  process.exit(1);
12161
12205
  }
12162
12206
  });
@@ -12189,7 +12233,7 @@ program.command("build").description("Build handlers from endpoints, functions,
12189
12233
  stage: options.stage
12190
12234
  });
12191
12235
  } catch (error) {
12192
- console.error(error instanceof Error ? error.message : "Command failed");
12236
+ console.error(formatError(error));
12193
12237
  process.exit(1);
12194
12238
  }
12195
12239
  });
@@ -12205,7 +12249,7 @@ program.command("dev").description("Start development server with automatic relo
12205
12249
  watch: options.watch
12206
12250
  });
12207
12251
  } catch (error) {
12208
- console.error(error instanceof Error ? error.message : "Command failed");
12252
+ console.error(formatError(error));
12209
12253
  process.exit(1);
12210
12254
  }
12211
12255
  });
@@ -12215,7 +12259,7 @@ program.command("exec").description("Run a command with secrets injected into Cr
12215
12259
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12216
12260
  await execCommand(commandArgs);
12217
12261
  } catch (error) {
12218
- console.error(error instanceof Error ? error.message : "Command failed");
12262
+ console.error(formatError(error));
12219
12263
  process.exit(1);
12220
12264
  }
12221
12265
  });
@@ -12228,7 +12272,7 @@ program.command("test").description("Run tests with secrets loaded from environm
12228
12272
  pattern
12229
12273
  });
12230
12274
  } catch (error) {
12231
- console.error(error instanceof Error ? error.message : "Command failed");
12275
+ console.error(formatError(error));
12232
12276
  process.exit(1);
12233
12277
  }
12234
12278
  });
@@ -12253,7 +12297,7 @@ program.command("openapi").description("Generate OpenAPI specification from endp
12253
12297
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12254
12298
  await require_openapi.openapiCommand({});
12255
12299
  } catch (error) {
12256
- console.error(error instanceof Error ? error.message : "Command failed");
12300
+ console.error(formatError(error));
12257
12301
  process.exit(1);
12258
12302
  }
12259
12303
  });
@@ -12263,7 +12307,7 @@ program.command("generate:react-query").description("Generate React Query hooks
12263
12307
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12264
12308
  await require_openapi_react_query.generateReactQueryCommand(options);
12265
12309
  } catch (error) {
12266
- console.error(error instanceof Error ? error.message : "Command failed");
12310
+ console.error(formatError(error));
12267
12311
  process.exit(1);
12268
12312
  }
12269
12313
  });
@@ -12273,7 +12317,7 @@ program.command("docker").description("Generate Docker deployment files").option
12273
12317
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12274
12318
  await dockerCommand(options);
12275
12319
  } catch (error) {
12276
- console.error(error instanceof Error ? error.message : "Command failed");
12320
+ console.error(formatError(error));
12277
12321
  process.exit(1);
12278
12322
  }
12279
12323
  });
@@ -12302,7 +12346,7 @@ program.command("prepack").description("Generate Docker files for production dep
12302
12346
  const _imageRef = registry ? `${registry}/api:${tag}` : `api:${tag}`;
12303
12347
  }
12304
12348
  } catch (error) {
12305
- console.error(error instanceof Error ? error.message : "Command failed");
12349
+ console.error(formatError(error));
12306
12350
  process.exit(1);
12307
12351
  }
12308
12352
  });
@@ -12312,7 +12356,7 @@ program.command("secrets:init").description("Initialize secrets for a deployment
12312
12356
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12313
12357
  await secretsInitCommand(options);
12314
12358
  } catch (error) {
12315
- console.error(error instanceof Error ? error.message : "Command failed");
12359
+ console.error(formatError(error));
12316
12360
  process.exit(1);
12317
12361
  }
12318
12362
  });
@@ -12322,7 +12366,7 @@ program.command("secrets:set").description("Set a custom secret for a stage").ar
12322
12366
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12323
12367
  await secretsSetCommand(key, value, options);
12324
12368
  } catch (error) {
12325
- console.error(error instanceof Error ? error.message : "Command failed");
12369
+ console.error(formatError(error));
12326
12370
  process.exit(1);
12327
12371
  }
12328
12372
  });
@@ -12332,7 +12376,7 @@ program.command("secrets:show").description("Show secrets for a stage").required
12332
12376
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12333
12377
  await secretsShowCommand(options);
12334
12378
  } catch (error) {
12335
- console.error(error instanceof Error ? error.message : "Command failed");
12379
+ console.error(formatError(error));
12336
12380
  process.exit(1);
12337
12381
  }
12338
12382
  });
@@ -12342,7 +12386,7 @@ program.command("secrets:rotate").description("Rotate service passwords").requir
12342
12386
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12343
12387
  await secretsRotateCommand(options);
12344
12388
  } catch (error) {
12345
- console.error(error instanceof Error ? error.message : "Command failed");
12389
+ console.error(formatError(error));
12346
12390
  process.exit(1);
12347
12391
  }
12348
12392
  });
@@ -12352,7 +12396,7 @@ program.command("secrets:import").description("Import secrets from a JSON file")
12352
12396
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12353
12397
  await secretsImportCommand(file, options);
12354
12398
  } catch (error) {
12355
- console.error(error instanceof Error ? error.message : "Command failed");
12399
+ console.error(formatError(error));
12356
12400
  process.exit(1);
12357
12401
  }
12358
12402
  });
@@ -12377,7 +12421,7 @@ program.command("secrets:push").description("Push secrets to remote provider (SS
12377
12421
  await pushSecrets$1(options.stage, workspace);
12378
12422
  console.log(`\n✓ Secrets pushed for stage "${options.stage}"`);
12379
12423
  } catch (error) {
12380
- console.error(error instanceof Error ? error.message : "Command failed");
12424
+ console.error(formatError(error));
12381
12425
  process.exit(1);
12382
12426
  }
12383
12427
  });
@@ -12404,7 +12448,7 @@ program.command("secrets:pull").description("Pull secrets from remote provider (
12404
12448
  await writeStageSecrets$1(secrets, workspace.root);
12405
12449
  console.log(`\n✓ Secrets pulled for stage "${options.stage}"`);
12406
12450
  } catch (error) {
12407
- console.error(error instanceof Error ? error.message : "Command failed");
12451
+ console.error(formatError(error));
12408
12452
  process.exit(1);
12409
12453
  }
12410
12454
  });
@@ -12430,7 +12474,7 @@ program.command("secrets:reconcile").description("Backfill missing custom secret
12430
12474
  console.log(`\n✓ Reconciled ${result.addedKeys.length} missing secret(s) for stage "${options.stage}":`);
12431
12475
  for (const key of result.addedKeys) console.log(` + ${key}`);
12432
12476
  } catch (error) {
12433
- console.error(error instanceof Error ? error.message : "Command failed");
12477
+ console.error(formatError(error));
12434
12478
  process.exit(1);
12435
12479
  }
12436
12480
  });
@@ -12455,7 +12499,7 @@ program.command("deploy").description("Deploy application to a provider").requir
12455
12499
  skipBuild: options.skipBuild
12456
12500
  });
12457
12501
  } catch (error) {
12458
- console.error(error instanceof Error ? error.message : "Deploy failed");
12502
+ console.error(formatError(error));
12459
12503
  process.exit(1);
12460
12504
  }
12461
12505
  });
@@ -12471,7 +12515,7 @@ program.command("deploy:init").description("Initialize Dokploy deployment (creat
12471
12515
  registryId: options.registryId
12472
12516
  });
12473
12517
  } catch (error) {
12474
- console.error(error instanceof Error ? error.message : "Failed to initialize deployment");
12518
+ console.error(formatError(error));
12475
12519
  process.exit(1);
12476
12520
  }
12477
12521
  });
@@ -12498,7 +12542,7 @@ program.command("deploy:list").description("List Dokploy resources (projects, re
12498
12542
  });
12499
12543
  }
12500
12544
  } catch (error) {
12501
- console.error(error instanceof Error ? error.message : "Failed to list resources");
12545
+ console.error(formatError(error));
12502
12546
  process.exit(1);
12503
12547
  }
12504
12548
  });
@@ -12516,7 +12560,7 @@ program.command("login").description("Authenticate with a deployment service").o
12516
12560
  endpoint: options.endpoint
12517
12561
  });
12518
12562
  } catch (error) {
12519
- console.error(error instanceof Error ? error.message : "Failed to login");
12563
+ console.error(formatError(error));
12520
12564
  process.exit(1);
12521
12565
  }
12522
12566
  });
@@ -12526,7 +12570,7 @@ program.command("logout").description("Remove stored credentials").option("--ser
12526
12570
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12527
12571
  await logoutCommand({ service: options.service });
12528
12572
  } catch (error) {
12529
- console.error(error instanceof Error ? error.message : "Failed to logout");
12573
+ console.error(formatError(error));
12530
12574
  process.exit(1);
12531
12575
  }
12532
12576
  });
@@ -12536,7 +12580,7 @@ program.command("whoami").description("Show current authentication status").acti
12536
12580
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12537
12581
  await whoamiCommand();
12538
12582
  } catch (error) {
12539
- console.error(error instanceof Error ? error.message : "Failed to get status");
12583
+ console.error(formatError(error));
12540
12584
  process.exit(1);
12541
12585
  }
12542
12586
  });
@@ -12546,7 +12590,7 @@ program.command("state:pull").description("Pull deployment state from remote to
12546
12590
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12547
12591
  await statePullCommand(options);
12548
12592
  } catch (error) {
12549
- console.error(error instanceof Error ? error.message : "Command failed");
12593
+ console.error(formatError(error));
12550
12594
  process.exit(1);
12551
12595
  }
12552
12596
  });
@@ -12556,7 +12600,7 @@ program.command("state:push").description("Push deployment state from local to r
12556
12600
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12557
12601
  await statePushCommand(options);
12558
12602
  } catch (error) {
12559
- console.error(error instanceof Error ? error.message : "Command failed");
12603
+ console.error(formatError(error));
12560
12604
  process.exit(1);
12561
12605
  }
12562
12606
  });
@@ -12566,7 +12610,7 @@ program.command("state:show").description("Show deployment state for a stage").r
12566
12610
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12567
12611
  await stateShowCommand(options);
12568
12612
  } catch (error) {
12569
- console.error(error instanceof Error ? error.message : "Command failed");
12613
+ console.error(formatError(error));
12570
12614
  process.exit(1);
12571
12615
  }
12572
12616
  });
@@ -12576,7 +12620,7 @@ program.command("state:diff").description("Compare local and remote deployment s
12576
12620
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12577
12621
  await stateDiffCommand(options);
12578
12622
  } catch (error) {
12579
- console.error(error instanceof Error ? error.message : "Command failed");
12623
+ console.error(formatError(error));
12580
12624
  process.exit(1);
12581
12625
  }
12582
12626
  });
@@ -12586,7 +12630,7 @@ program.command("upgrade").description("Upgrade all @geekmidas packages to their
12586
12630
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
12587
12631
  await upgradeCommand(options);
12588
12632
  } catch (error) {
12589
- console.error(error instanceof Error ? error.message : "Command failed");
12633
+ console.error(formatError(error));
12590
12634
  process.exit(1);
12591
12635
  }
12592
12636
  });