@geekmidas/cli 0.36.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.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.37.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,40 @@ 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 {
1583
+ secretsRoot = findSecretsRoot(cwd);
1584
+ appName = getAppNameFromCwd(cwd) ?? void 0;
1585
+ }
1586
+ const resolvedPort = options.explicitPort ?? workspaceAppPort ?? 3e3;
1587
+ const credentials = await loadSecretsForApp(secretsRoot, appName);
1588
+ credentials.PORT = String(resolvedPort);
1589
+ const secretsDir = join(secretsRoot, ".gkm");
1590
+ await mkdir(secretsDir, { recursive: true });
1591
+ const secretsJsonPath = join(secretsDir, "dev-secrets.json");
1592
+ await writeFile(secretsJsonPath, JSON.stringify(credentials, null, 2));
1593
+ return {
1594
+ credentials,
1595
+ resolvedPort,
1596
+ secretsJsonPath,
1597
+ appName,
1598
+ secretsRoot
1599
+ };
1600
+ }
1601
+ /**
1568
1602
  * Run any TypeScript file with secret injection.
1569
1603
  * Does not require gkm.config.ts.
1570
1604
  */
@@ -1575,37 +1609,15 @@ async function entryDevCommand(options) {
1575
1609
  if (!existsSync(entryPath)) throw new Error(`Entry file not found: ${entryPath}`);
1576
1610
  const defaultEnv = loadEnvFiles(".env");
1577
1611
  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
- }
1612
+ const { credentials, resolvedPort, secretsJsonPath, appName } = await prepareEntryCredentials({ explicitPort: options.port });
1613
+ if (appName) logger$8.log(`📦 App: ${appName} (port ${resolvedPort})`);
1614
+ logger$8.log(`🚀 Starting entry file: ${entry} on port ${resolvedPort}`);
1615
+ if (Object.keys(credentials).length > 1) logger$8.log(`🔐 Loaded ${Object.keys(credentials).length - 1} secret(s) + PORT`);
1604
1616
  const wrapperDir = join(process.cwd(), ".gkm");
1605
1617
  await mkdir(wrapperDir, { recursive: true });
1606
1618
  const wrapperPath = join(wrapperDir, "entry-wrapper.ts");
1607
1619
  await createEntryWrapper(wrapperPath, entryPath, secretsJsonPath);
1608
- const runner = new EntryRunner(wrapperPath, entryPath, watch, port);
1620
+ const runner = new EntryRunner(wrapperPath, entryPath, watch, resolvedPort);
1609
1621
  await runner.start();
1610
1622
  let isShuttingDown = false;
1611
1623
  const shutdown = () => {
@@ -5407,7 +5419,6 @@ docker/.env
5407
5419
 
5408
5420
  # IDE
5409
5421
  .idea/
5410
- .vscode/
5411
5422
  *.swp
5412
5423
  *.swo
5413
5424
 
@@ -5460,6 +5471,42 @@ export default defineConfig({
5460
5471
  },
5461
5472
  });
5462
5473
  `;
5474
+ const vscodeSettings = {
5475
+ "search.exclude": {
5476
+ "**/.sst": true,
5477
+ "**/.gkm": true,
5478
+ "**/.turbo": true
5479
+ },
5480
+ "editor.formatOnSave": true,
5481
+ "editor.defaultFormatter": "biomejs.biome",
5482
+ "editor.codeActionsOnSave": {
5483
+ "source.fixAll.biome": "always",
5484
+ "source.organizeImports.biome": "always",
5485
+ "source.organizeImports": "always"
5486
+ },
5487
+ "[typescriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
5488
+ "[typescript]": { "editor.defaultFormatter": "biomejs.biome" },
5489
+ "[javascript]": { "editor.defaultFormatter": "biomejs.biome" },
5490
+ "[json]": { "editor.defaultFormatter": "biomejs.biome" },
5491
+ "cSpell.words": [
5492
+ "betterauth",
5493
+ "dokploy",
5494
+ "envkit",
5495
+ "geekmidas",
5496
+ "healthcheck",
5497
+ "kysely",
5498
+ "testkit",
5499
+ "timestamptz",
5500
+ "turborepo",
5501
+ options.name
5502
+ ]
5503
+ };
5504
+ const vscodeExtensions = { recommendations: [
5505
+ "biomejs.biome",
5506
+ "streetsidesoftware.code-spell-checker",
5507
+ "dbaeumer.vscode-eslint",
5508
+ "ms-azuretools.vscode-docker"
5509
+ ] };
5463
5510
  const files = [
5464
5511
  {
5465
5512
  path: "package.json",
@@ -5488,6 +5535,14 @@ export default defineConfig({
5488
5535
  {
5489
5536
  path: ".gitignore",
5490
5537
  content: gitignore
5538
+ },
5539
+ {
5540
+ path: ".vscode/settings.json",
5541
+ content: `${JSON.stringify(vscodeSettings, null, " ")}\n`
5542
+ },
5543
+ {
5544
+ path: ".vscode/extensions.json",
5545
+ content: `${JSON.stringify(vscodeExtensions, null, " ")}\n`
5491
5546
  }
5492
5547
  ];
5493
5548
  if (isFullstack) files.push({