@geekmidas/cli 0.32.0 → 0.34.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/cli",
3
- "version": "0.32.0",
3
+ "version": "0.34.0",
4
4
  "description": "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs",
5
5
  "private": false,
6
6
  "type": "module",
@@ -49,10 +49,10 @@
49
49
  "openapi-typescript": "^7.4.2",
50
50
  "prompts": "~2.4.2",
51
51
  "@geekmidas/constructs": "~0.6.0",
52
- "@geekmidas/envkit": "~0.5.0",
53
52
  "@geekmidas/logger": "~0.4.0",
54
- "@geekmidas/errors": "~0.1.0",
55
- "@geekmidas/schema": "~0.1.0"
53
+ "@geekmidas/envkit": "~0.5.0",
54
+ "@geekmidas/schema": "~0.1.0",
55
+ "@geekmidas/errors": "~0.1.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/lodash.kebabcase": "^4.1.9",
@@ -77,7 +77,7 @@ describe('createEntryWrapper', () => {
77
77
 
78
78
  const content = await readFile(wrapperPath, 'utf-8');
79
79
 
80
- expect(content).toContain("import '/path/to/entry.ts'");
80
+ expect(content).toContain("await import('/path/to/entry.ts')");
81
81
  expect(content).not.toContain('Credentials');
82
82
  expect(content).toContain("Entry wrapper generated by 'gkm dev --entry'");
83
83
  });
@@ -96,7 +96,7 @@ describe('createEntryWrapper', () => {
96
96
  );
97
97
  expect(content).toContain(secretsPath);
98
98
  expect(content).toContain('Object.assign(Credentials');
99
- expect(content).toContain("import '/path/to/entry.ts'");
99
+ expect(content).toContain("await import('/path/to/entry.ts')");
100
100
  });
101
101
 
102
102
  it('should inject secrets before entry import', async () => {
@@ -109,7 +109,7 @@ describe('createEntryWrapper', () => {
109
109
  const content = await readFile(wrapperPath, 'utf-8');
110
110
 
111
111
  const credentialsIndex = content.indexOf('Credentials');
112
- const importIndex = content.indexOf("import '/path/to/entry.ts'");
112
+ const importIndex = content.indexOf("await import('/path/to/entry.ts')");
113
113
 
114
114
  expect(credentialsIndex).toBeGreaterThan(-1);
115
115
  expect(importIndex).toBeGreaterThan(-1);
package/src/dev/index.ts CHANGED
@@ -329,6 +329,7 @@ export async function devCommand(options: DevOptions): Promise<void> {
329
329
  let appRoot: string = process.cwd();
330
330
  let secretsRoot: string = process.cwd(); // Where .gkm/secrets/ lives
331
331
  let workspaceAppName: string | undefined; // Set if in workspace mode
332
+ let workspaceAppPort: number | undefined; // Port from workspace config
332
333
 
333
334
  if (appName) {
334
335
  // Try to load app-specific config from workspace
@@ -338,7 +339,8 @@ export async function devCommand(options: DevOptions): Promise<void> {
338
339
  appRoot = appConfig.appRoot;
339
340
  secretsRoot = appConfig.workspaceRoot;
340
341
  workspaceAppName = appConfig.appName;
341
- logger.log(`📦 Running app: ${appConfig.appName}`);
342
+ workspaceAppPort = appConfig.app.port;
343
+ logger.log(`📦 Running app: ${appConfig.appName} on port ${workspaceAppPort}`);
342
344
  } catch {
343
345
  // Not in a workspace or app not found in workspace - fall back to regular loading
344
346
  const loadedConfig = await loadWorkspaceConfig();
@@ -463,9 +465,10 @@ export async function devCommand(options: DevOptions): Promise<void> {
463
465
  }
464
466
 
465
467
  // Start the dev server
468
+ // Priority: explicit --port option > workspace app port > default 3000
466
469
  const devServer = new DevServer(
467
470
  resolved.providers[0] as LegacyProvider,
468
- options.port || 3000,
471
+ options.port ?? workspaceAppPort ?? 3000,
469
472
  options.portExplicit ?? false,
470
473
  enableOpenApi,
471
474
  telescope,
@@ -1291,12 +1294,14 @@ if (existsSync(secretsPath)) {
1291
1294
  `
1292
1295
  : '';
1293
1296
 
1297
+ // Use dynamic import() to ensure secrets are assigned before the entry file loads
1298
+ // Static imports are hoisted, so Object.assign would run after the entry file is loaded
1294
1299
  const content = `#!/usr/bin/env node
1295
1300
  /**
1296
1301
  * Entry wrapper generated by 'gkm dev --entry'
1297
1302
  */
1298
- ${credentialsInjection}// Import and run the user's entry file
1299
- import '${entryPath}';
1303
+ ${credentialsInjection}// Import and run the user's entry file (dynamic import ensures secrets load first)
1304
+ await import('${entryPath}');
1300
1305
  `;
1301
1306
 
1302
1307
  await writeFile(wrapperPath, content);
@@ -1329,14 +1334,20 @@ async function entryDevCommand(options: DevOptions): Promise<void> {
1329
1334
 
1330
1335
  // Determine secrets root (current dir or workspace root)
1331
1336
  const secretsRoot = findSecretsRoot(process.cwd());
1337
+ logger.log(`🔍 Secrets root: ${secretsRoot}`);
1332
1338
 
1333
1339
  // Determine app name for per-app secret mapping
1334
1340
  const appName = getAppNameFromCwd() ?? undefined;
1341
+ if (appName) {
1342
+ logger.log(`📦 App name: ${appName}`);
1343
+ }
1335
1344
 
1336
1345
  // Load secrets
1337
1346
  const appSecrets = await loadSecretsForApp(secretsRoot, appName);
1338
1347
  if (Object.keys(appSecrets).length > 0) {
1339
1348
  logger.log(`🔐 Loaded ${Object.keys(appSecrets).length} secret(s)`);
1349
+ } else {
1350
+ logger.log(`⚠️ No secrets found in ${secretsRoot}/.gkm/secrets/`);
1340
1351
  }
1341
1352
 
1342
1353
  // Write secrets to temp JSON file
@@ -22,7 +22,7 @@ export function generateAuthAppFiles(
22
22
  private: true,
23
23
  type: 'module',
24
24
  scripts: {
25
- dev: 'tsx watch src/index.ts',
25
+ dev: 'gkm dev --entry ./src/index.ts',
26
26
  build: 'tsc',
27
27
  start: 'node dist/index.js',
28
28
  typecheck: 'tsc --noEmit',
@@ -38,6 +38,7 @@ export function generateAuthAppFiles(
38
38
  pg: '~8.13.0',
39
39
  },
40
40
  devDependencies: {
41
+ '@geekmidas/cli': GEEKMIDAS_VERSIONS['@geekmidas/cli'],
41
42
  '@types/node': '~22.0.0',
42
43
  '@types/pg': '~8.11.0',
43
44
  tsx: '~4.20.0',