@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.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.35.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,36 +1565,59 @@ 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
  */
1571
1605
  async function entryDevCommand(options) {
1572
- const { entry, port = 3e3, watch = true } = options;
1606
+ const { entry, watch = true } = options;
1573
1607
  if (!entry) throw new Error("--entry requires a file path");
1574
1608
  const entryPath = resolve(process.cwd(), entry);
1575
1609
  if (!existsSync(entryPath)) throw new Error(`Entry file not found: ${entryPath}`);
1576
- logger$8.log(`🚀 Starting entry file: ${entry}`);
1577
1610
  const defaultEnv = loadEnvFiles(".env");
1578
1611
  if (defaultEnv.loaded.length > 0) logger$8.log(`📦 Loaded env: ${defaultEnv.loaded.join(", ")}`);
1579
- const secretsRoot = findSecretsRoot(process.cwd());
1580
- logger$8.log(`🔍 Secrets root: ${secretsRoot}`);
1581
- const appName = getAppNameFromCwd() ?? void 0;
1582
- if (appName) logger$8.log(`📦 App name: ${appName}`);
1583
- const appSecrets = await loadSecretsForApp(secretsRoot, appName);
1584
- if (Object.keys(appSecrets).length > 0) logger$8.log(`🔐 Loaded ${Object.keys(appSecrets).length} secret(s)`);
1585
- else logger$8.log(`⚠️ No secrets found in ${secretsRoot}/.gkm/secrets/`);
1586
- let secretsJsonPath;
1587
- if (Object.keys(appSecrets).length > 0) {
1588
- const secretsDir = join(secretsRoot, ".gkm");
1589
- await mkdir(secretsDir, { recursive: true });
1590
- secretsJsonPath = join(secretsDir, "dev-secrets.json");
1591
- await writeFile(secretsJsonPath, JSON.stringify(appSecrets, null, 2));
1592
- }
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`);
1593
1616
  const wrapperDir = join(process.cwd(), ".gkm");
1594
1617
  await mkdir(wrapperDir, { recursive: true });
1595
1618
  const wrapperPath = join(wrapperDir, "entry-wrapper.ts");
1596
1619
  await createEntryWrapper(wrapperPath, entryPath, secretsJsonPath);
1597
- const runner = new EntryRunner(wrapperPath, entryPath, watch, port);
1620
+ const runner = new EntryRunner(wrapperPath, entryPath, watch, resolvedPort);
1598
1621
  await runner.start();
1599
1622
  let isShuttingDown = false;
1600
1623
  const shutdown = () => {
@@ -5396,7 +5419,6 @@ docker/.env
5396
5419
 
5397
5420
  # IDE
5398
5421
  .idea/
5399
- .vscode/
5400
5422
  *.swp
5401
5423
  *.swo
5402
5424
 
@@ -5449,6 +5471,42 @@ export default defineConfig({
5449
5471
  },
5450
5472
  });
5451
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
+ ] };
5452
5510
  const files = [
5453
5511
  {
5454
5512
  path: "package.json",
@@ -5477,6 +5535,14 @@ export default defineConfig({
5477
5535
  {
5478
5536
  path: ".gitignore",
5479
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`
5480
5546
  }
5481
5547
  ];
5482
5548
  if (isFullstack) files.push({