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