@geekmidas/cli 0.8.0 → 0.9.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 +16 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +16 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/dev/index.ts +22 -6
- package/src/index.ts +5 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"typescript": "^5.8.2",
|
|
51
51
|
"vitest": "^3.2.4",
|
|
52
52
|
"zod": "~4.1.13",
|
|
53
|
-
"@geekmidas/testkit": "0.
|
|
53
|
+
"@geekmidas/testkit": "0.4.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@geekmidas/
|
|
57
|
-
"@geekmidas/logger": "~0.
|
|
58
|
-
"@geekmidas/
|
|
59
|
-
"@geekmidas/
|
|
60
|
-
"@geekmidas/
|
|
56
|
+
"@geekmidas/constructs": "~0.3.0",
|
|
57
|
+
"@geekmidas/logger": "~0.3.0",
|
|
58
|
+
"@geekmidas/envkit": "~0.2.0",
|
|
59
|
+
"@geekmidas/schema": "~0.1.0",
|
|
60
|
+
"@geekmidas/telescope": "~0.2.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependenciesMeta": {
|
|
63
63
|
"@geekmidas/telescope": {
|
package/src/dev/index.ts
CHANGED
|
@@ -230,6 +230,7 @@ export function normalizeHooksConfig(
|
|
|
230
230
|
|
|
231
231
|
export interface DevOptions {
|
|
232
232
|
port?: number;
|
|
233
|
+
portExplicit?: boolean;
|
|
233
234
|
enableOpenApi?: boolean;
|
|
234
235
|
}
|
|
235
236
|
|
|
@@ -332,6 +333,7 @@ export async function devCommand(options: DevOptions): Promise<void> {
|
|
|
332
333
|
const devServer = new DevServer(
|
|
333
334
|
resolved.providers[0] as LegacyProvider,
|
|
334
335
|
options.port || 3000,
|
|
336
|
+
options.portExplicit ?? false,
|
|
335
337
|
enableOpenApi,
|
|
336
338
|
telescope,
|
|
337
339
|
studio,
|
|
@@ -499,6 +501,7 @@ class DevServer {
|
|
|
499
501
|
constructor(
|
|
500
502
|
private provider: LegacyProvider,
|
|
501
503
|
private requestedPort: number,
|
|
504
|
+
private portExplicit: boolean,
|
|
502
505
|
private enableOpenApi: boolean,
|
|
503
506
|
private telescope?: NormalizedTelescopeConfig,
|
|
504
507
|
private studio?: NormalizedStudioConfig,
|
|
@@ -512,13 +515,26 @@ class DevServer {
|
|
|
512
515
|
await this.stop();
|
|
513
516
|
}
|
|
514
517
|
|
|
515
|
-
//
|
|
516
|
-
|
|
518
|
+
// Check port availability
|
|
519
|
+
if (this.portExplicit) {
|
|
520
|
+
// Port was explicitly specified - throw if unavailable
|
|
521
|
+
const available = await isPortAvailable(this.requestedPort);
|
|
522
|
+
if (!available) {
|
|
523
|
+
throw new Error(
|
|
524
|
+
`Port ${this.requestedPort} is already in use. ` +
|
|
525
|
+
`Either stop the process using that port or omit -p/--port to auto-select an available port.`,
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
this.actualPort = this.requestedPort;
|
|
529
|
+
} else {
|
|
530
|
+
// Find an available port starting from the default
|
|
531
|
+
this.actualPort = await findAvailablePort(this.requestedPort);
|
|
517
532
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
533
|
+
if (this.actualPort !== this.requestedPort) {
|
|
534
|
+
logger.log(
|
|
535
|
+
`ℹ️ Port ${this.requestedPort} was in use, using port ${this.actualPort} instead`,
|
|
536
|
+
);
|
|
537
|
+
}
|
|
522
538
|
}
|
|
523
539
|
|
|
524
540
|
const serverEntryPath = join(
|
package/src/index.ts
CHANGED
|
@@ -111,7 +111,7 @@ program
|
|
|
111
111
|
program
|
|
112
112
|
.command('dev')
|
|
113
113
|
.description('Start development server with automatic reload')
|
|
114
|
-
.option('--port <port>', 'Port to run the development server on'
|
|
114
|
+
.option('-p, --port <port>', 'Port to run the development server on')
|
|
115
115
|
.option(
|
|
116
116
|
'--enable-openapi',
|
|
117
117
|
'Enable OpenAPI documentation for development server',
|
|
@@ -126,6 +126,7 @@ program
|
|
|
126
126
|
|
|
127
127
|
await devCommand({
|
|
128
128
|
port: options.port ? Number.parseInt(options.port) : 3000,
|
|
129
|
+
portExplicit: !!options.port,
|
|
129
130
|
enableOpenApi: options.enableOpenapi ?? true,
|
|
130
131
|
});
|
|
131
132
|
} catch (error) {
|
|
@@ -169,22 +170,14 @@ program
|
|
|
169
170
|
|
|
170
171
|
program
|
|
171
172
|
.command('openapi')
|
|
172
|
-
.description(
|
|
173
|
-
|
|
174
|
-
)
|
|
175
|
-
.option(
|
|
176
|
-
'--output <path>',
|
|
177
|
-
'Output file path for the OpenAPI spec',
|
|
178
|
-
'openapi.ts',
|
|
179
|
-
)
|
|
180
|
-
.option('--json', 'Generate JSON instead of TypeScript (legacy)', false)
|
|
181
|
-
.action(async (options: { output?: string; json?: boolean }) => {
|
|
173
|
+
.description('Generate OpenAPI specification from endpoints')
|
|
174
|
+
.action(async () => {
|
|
182
175
|
try {
|
|
183
176
|
const globalOptions = program.opts();
|
|
184
177
|
if (globalOptions.cwd) {
|
|
185
178
|
process.chdir(globalOptions.cwd);
|
|
186
179
|
}
|
|
187
|
-
await openapiCommand(
|
|
180
|
+
await openapiCommand({});
|
|
188
181
|
} catch (error) {
|
|
189
182
|
console.error('OpenAPI generation failed:', (error as Error).message);
|
|
190
183
|
process.exit(1);
|