@geekmidas/cli 0.35.0 → 0.37.0

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.cjs CHANGED
@@ -27,7 +27,7 @@ const node_module = require_chunk.__toESM(require("node:module"));
27
27
 
28
28
  //#region package.json
29
29
  var name = "@geekmidas/cli";
30
- var version = "0.34.0";
30
+ var version = "0.37.0";
31
31
  var description = "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs";
32
32
  var private$1 = false;
33
33
  var type = "module";
@@ -1566,36 +1566,59 @@ await import('${entryPath}');
1566
1566
  await (0, node_fs_promises.writeFile)(wrapperPath, content);
1567
1567
  }
1568
1568
  /**
1569
+ * Prepare credentials for entry dev mode.
1570
+ * Loads workspace config, secrets, and injects PORT.
1571
+ * @internal Exported for testing
1572
+ */
1573
+ async function prepareEntryCredentials(options) {
1574
+ const cwd = options.cwd ?? process.cwd();
1575
+ let workspaceAppPort;
1576
+ let secretsRoot = cwd;
1577
+ let appName;
1578
+ try {
1579
+ const appConfig = await require_config.loadAppConfig(cwd);
1580
+ workspaceAppPort = appConfig.app.port;
1581
+ secretsRoot = appConfig.workspaceRoot;
1582
+ appName = appConfig.appName;
1583
+ } catch {
1584
+ secretsRoot = findSecretsRoot(cwd);
1585
+ appName = require_config.getAppNameFromCwd(cwd) ?? void 0;
1586
+ }
1587
+ const resolvedPort = options.explicitPort ?? workspaceAppPort ?? 3e3;
1588
+ const credentials = await loadSecretsForApp(secretsRoot, appName);
1589
+ credentials.PORT = String(resolvedPort);
1590
+ const secretsDir = (0, node_path.join)(secretsRoot, ".gkm");
1591
+ await (0, node_fs_promises.mkdir)(secretsDir, { recursive: true });
1592
+ const secretsJsonPath = (0, node_path.join)(secretsDir, "dev-secrets.json");
1593
+ await (0, node_fs_promises.writeFile)(secretsJsonPath, JSON.stringify(credentials, null, 2));
1594
+ return {
1595
+ credentials,
1596
+ resolvedPort,
1597
+ secretsJsonPath,
1598
+ appName,
1599
+ secretsRoot
1600
+ };
1601
+ }
1602
+ /**
1569
1603
  * Run any TypeScript file with secret injection.
1570
1604
  * Does not require gkm.config.ts.
1571
1605
  */
1572
1606
  async function entryDevCommand(options) {
1573
- const { entry, port = 3e3, watch = true } = options;
1607
+ const { entry, watch = true } = options;
1574
1608
  if (!entry) throw new Error("--entry requires a file path");
1575
1609
  const entryPath = (0, node_path.resolve)(process.cwd(), entry);
1576
1610
  if (!(0, node_fs.existsSync)(entryPath)) throw new Error(`Entry file not found: ${entryPath}`);
1577
- logger$8.log(`🚀 Starting entry file: ${entry}`);
1578
1611
  const defaultEnv = loadEnvFiles(".env");
1579
1612
  if (defaultEnv.loaded.length > 0) logger$8.log(`📦 Loaded env: ${defaultEnv.loaded.join(", ")}`);
1580
- const secretsRoot = findSecretsRoot(process.cwd());
1581
- logger$8.log(`🔍 Secrets root: ${secretsRoot}`);
1582
- const appName = require_config.getAppNameFromCwd() ?? void 0;
1583
- if (appName) logger$8.log(`📦 App name: ${appName}`);
1584
- const appSecrets = await loadSecretsForApp(secretsRoot, appName);
1585
- if (Object.keys(appSecrets).length > 0) logger$8.log(`🔐 Loaded ${Object.keys(appSecrets).length} secret(s)`);
1586
- else logger$8.log(`⚠️ No secrets found in ${secretsRoot}/.gkm/secrets/`);
1587
- let secretsJsonPath;
1588
- if (Object.keys(appSecrets).length > 0) {
1589
- const secretsDir = (0, node_path.join)(secretsRoot, ".gkm");
1590
- await (0, node_fs_promises.mkdir)(secretsDir, { recursive: true });
1591
- secretsJsonPath = (0, node_path.join)(secretsDir, "dev-secrets.json");
1592
- await (0, node_fs_promises.writeFile)(secretsJsonPath, JSON.stringify(appSecrets, null, 2));
1593
- }
1613
+ const { credentials, resolvedPort, secretsJsonPath, appName } = await prepareEntryCredentials({ explicitPort: options.port });
1614
+ if (appName) logger$8.log(`📦 App: ${appName} (port ${resolvedPort})`);
1615
+ logger$8.log(`🚀 Starting entry file: ${entry} on port ${resolvedPort}`);
1616
+ if (Object.keys(credentials).length > 1) logger$8.log(`🔐 Loaded ${Object.keys(credentials).length - 1} secret(s) + PORT`);
1594
1617
  const wrapperDir = (0, node_path.join)(process.cwd(), ".gkm");
1595
1618
  await (0, node_fs_promises.mkdir)(wrapperDir, { recursive: true });
1596
1619
  const wrapperPath = (0, node_path.join)(wrapperDir, "entry-wrapper.ts");
1597
1620
  await createEntryWrapper(wrapperPath, entryPath, secretsJsonPath);
1598
- const runner = new EntryRunner(wrapperPath, entryPath, watch, port);
1621
+ const runner = new EntryRunner(wrapperPath, entryPath, watch, resolvedPort);
1599
1622
  await runner.start();
1600
1623
  let isShuttingDown = false;
1601
1624
  const shutdown = () => {
@@ -5397,7 +5420,6 @@ docker/.env
5397
5420
 
5398
5421
  # IDE
5399
5422
  .idea/
5400
- .vscode/
5401
5423
  *.swp
5402
5424
  *.swo
5403
5425
 
@@ -5450,6 +5472,42 @@ export default defineConfig({
5450
5472
  },
5451
5473
  });
5452
5474
  `;
5475
+ const vscodeSettings = {
5476
+ "search.exclude": {
5477
+ "**/.sst": true,
5478
+ "**/.gkm": true,
5479
+ "**/.turbo": true
5480
+ },
5481
+ "editor.formatOnSave": true,
5482
+ "editor.defaultFormatter": "biomejs.biome",
5483
+ "editor.codeActionsOnSave": {
5484
+ "source.fixAll.biome": "always",
5485
+ "source.organizeImports.biome": "always",
5486
+ "source.organizeImports": "always"
5487
+ },
5488
+ "[typescriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
5489
+ "[typescript]": { "editor.defaultFormatter": "biomejs.biome" },
5490
+ "[javascript]": { "editor.defaultFormatter": "biomejs.biome" },
5491
+ "[json]": { "editor.defaultFormatter": "biomejs.biome" },
5492
+ "cSpell.words": [
5493
+ "betterauth",
5494
+ "dokploy",
5495
+ "envkit",
5496
+ "geekmidas",
5497
+ "healthcheck",
5498
+ "kysely",
5499
+ "testkit",
5500
+ "timestamptz",
5501
+ "turborepo",
5502
+ options.name
5503
+ ]
5504
+ };
5505
+ const vscodeExtensions = { recommendations: [
5506
+ "biomejs.biome",
5507
+ "streetsidesoftware.code-spell-checker",
5508
+ "dbaeumer.vscode-eslint",
5509
+ "ms-azuretools.vscode-docker"
5510
+ ] };
5453
5511
  const files = [
5454
5512
  {
5455
5513
  path: "package.json",
@@ -5478,6 +5536,14 @@ export default defineConfig({
5478
5536
  {
5479
5537
  path: ".gitignore",
5480
5538
  content: gitignore
5539
+ },
5540
+ {
5541
+ path: ".vscode/settings.json",
5542
+ content: `${JSON.stringify(vscodeSettings, null, " ")}\n`
5543
+ },
5544
+ {
5545
+ path: ".vscode/extensions.json",
5546
+ content: `${JSON.stringify(vscodeExtensions, null, " ")}\n`
5481
5547
  }
5482
5548
  ];
5483
5549
  if (isFullstack) files.push({