@geekmidas/cli 0.36.0 → 0.38.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.mjs CHANGED
@@ -26,7 +26,7 @@ import prompts from "prompts";
26
26
 
27
27
  //#region package.json
28
28
  var name = "@geekmidas/cli";
29
- var version = "0.36.0";
29
+ var version = "0.38.0";
30
30
  var description = "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs";
31
31
  var private$1 = false;
32
32
  var type = "module";
@@ -1565,6 +1565,41 @@ await import('${entryPath}');
1565
1565
  await writeFile(wrapperPath, content);
1566
1566
  }
1567
1567
  /**
1568
+ * Prepare credentials for entry dev mode.
1569
+ * Loads workspace config, secrets, and injects PORT.
1570
+ * @internal Exported for testing
1571
+ */
1572
+ async function prepareEntryCredentials(options) {
1573
+ const cwd = options.cwd ?? process.cwd();
1574
+ let workspaceAppPort;
1575
+ let secretsRoot = cwd;
1576
+ let appName;
1577
+ try {
1578
+ const appConfig = await loadAppConfig(cwd);
1579
+ workspaceAppPort = appConfig.app.port;
1580
+ secretsRoot = appConfig.workspaceRoot;
1581
+ appName = appConfig.appName;
1582
+ } catch (error) {
1583
+ logger$8.log(`⚠️ Could not load workspace config: ${error.message}`);
1584
+ secretsRoot = findSecretsRoot(cwd);
1585
+ appName = 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 = join(secretsRoot, ".gkm");
1591
+ await mkdir(secretsDir, { recursive: true });
1592
+ const secretsJsonPath = join(secretsDir, "dev-secrets.json");
1593
+ await writeFile(secretsJsonPath, JSON.stringify(credentials, null, 2));
1594
+ return {
1595
+ credentials,
1596
+ resolvedPort,
1597
+ secretsJsonPath,
1598
+ appName,
1599
+ secretsRoot
1600
+ };
1601
+ }
1602
+ /**
1568
1603
  * Run any TypeScript file with secret injection.
1569
1604
  * Does not require gkm.config.ts.
1570
1605
  */
@@ -1575,37 +1610,15 @@ async function entryDevCommand(options) {
1575
1610
  if (!existsSync(entryPath)) throw new Error(`Entry file not found: ${entryPath}`);
1576
1611
  const defaultEnv = loadEnvFiles(".env");
1577
1612
  if (defaultEnv.loaded.length > 0) logger$8.log(`📦 Loaded env: ${defaultEnv.loaded.join(", ")}`);
1578
- let workspaceAppPort;
1579
- let secretsRoot = process.cwd();
1580
- let appName;
1581
- try {
1582
- const appConfig = await loadAppConfig();
1583
- workspaceAppPort = appConfig.app.port;
1584
- secretsRoot = appConfig.workspaceRoot;
1585
- appName = appConfig.appName;
1586
- logger$8.log(`📦 App: ${appName} (port ${workspaceAppPort})`);
1587
- } catch {
1588
- secretsRoot = findSecretsRoot(process.cwd());
1589
- appName = getAppNameFromCwd() ?? void 0;
1590
- if (appName) logger$8.log(`📦 App name: ${appName}`);
1591
- }
1592
- const port = options.port ?? workspaceAppPort ?? 3e3;
1593
- logger$8.log(`🚀 Starting entry file: ${entry} on port ${port}`);
1594
- const appSecrets = await loadSecretsForApp(secretsRoot, appName);
1595
- if (Object.keys(appSecrets).length > 0) logger$8.log(`🔐 Loaded ${Object.keys(appSecrets).length} secret(s)`);
1596
- else logger$8.log(`⚠️ No secrets found in ${secretsRoot}/.gkm/secrets/`);
1597
- let secretsJsonPath;
1598
- if (Object.keys(appSecrets).length > 0) {
1599
- const secretsDir = join(secretsRoot, ".gkm");
1600
- await mkdir(secretsDir, { recursive: true });
1601
- secretsJsonPath = join(secretsDir, "dev-secrets.json");
1602
- await writeFile(secretsJsonPath, JSON.stringify(appSecrets, null, 2));
1603
- }
1613
+ const { credentials, resolvedPort, secretsJsonPath, appName } = await prepareEntryCredentials({ explicitPort: options.portExplicit ? options.port : void 0 });
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`);
1604
1617
  const wrapperDir = join(process.cwd(), ".gkm");
1605
1618
  await mkdir(wrapperDir, { recursive: true });
1606
1619
  const wrapperPath = join(wrapperDir, "entry-wrapper.ts");
1607
1620
  await createEntryWrapper(wrapperPath, entryPath, secretsJsonPath);
1608
- const runner = new EntryRunner(wrapperPath, entryPath, watch, port);
1621
+ const runner = new EntryRunner(wrapperPath, entryPath, watch, resolvedPort);
1609
1622
  await runner.start();
1610
1623
  let isShuttingDown = false;
1611
1624
  const shutdown = () => {
@@ -5407,7 +5420,6 @@ docker/.env
5407
5420
 
5408
5421
  # IDE
5409
5422
  .idea/
5410
- .vscode/
5411
5423
  *.swp
5412
5424
  *.swo
5413
5425
 
@@ -5460,6 +5472,42 @@ export default defineConfig({
5460
5472
  },
5461
5473
  });
5462
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
+ ] };
5463
5511
  const files = [
5464
5512
  {
5465
5513
  path: "package.json",
@@ -5488,6 +5536,14 @@ export default defineConfig({
5488
5536
  {
5489
5537
  path: ".gitignore",
5490
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`
5491
5547
  }
5492
5548
  ];
5493
5549
  if (isFullstack) files.push({