@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.mjs CHANGED
@@ -19,7 +19,7 @@ import prompts from "prompts";
19
19
 
20
20
  //#region package.json
21
21
  var name = "@geekmidas/cli";
22
- var version = "0.8.0";
22
+ var version = "0.9.0";
23
23
  var description = "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs";
24
24
  var private$1 = false;
25
25
  var type = "module";
@@ -620,7 +620,7 @@ async function devCommand(options) {
620
620
  await buildServer(config$1, buildContext, resolved.providers[0], enableOpenApi);
621
621
  if (enableOpenApi) await generateOpenApi(config$1);
622
622
  const runtime = config$1.runtime ?? "node";
623
- const devServer = new DevServer(resolved.providers[0], options.port || 3e3, enableOpenApi, telescope, studio, runtime);
623
+ const devServer = new DevServer(resolved.providers[0], options.port || 3e3, options.portExplicit ?? false, enableOpenApi, telescope, studio, runtime);
624
624
  await devServer.start();
625
625
  const envParserFile = config$1.envParser.split("#")[0];
626
626
  const loggerFile = config$1.logger.split("#")[0];
@@ -712,9 +712,10 @@ var DevServer = class {
712
712
  serverProcess = null;
713
713
  isRunning = false;
714
714
  actualPort;
715
- constructor(provider, requestedPort, enableOpenApi, telescope, studio, runtime = "node") {
715
+ constructor(provider, requestedPort, portExplicit, enableOpenApi, telescope, studio, runtime = "node") {
716
716
  this.provider = provider;
717
717
  this.requestedPort = requestedPort;
718
+ this.portExplicit = portExplicit;
718
719
  this.enableOpenApi = enableOpenApi;
719
720
  this.telescope = telescope;
720
721
  this.studio = studio;
@@ -723,8 +724,14 @@ var DevServer = class {
723
724
  }
724
725
  async start() {
725
726
  if (this.isRunning) await this.stop();
726
- this.actualPort = await findAvailablePort(this.requestedPort);
727
- if (this.actualPort !== this.requestedPort) logger$2.log(`ℹ️ Port ${this.requestedPort} was in use, using port ${this.actualPort} instead`);
727
+ if (this.portExplicit) {
728
+ const available = await isPortAvailable(this.requestedPort);
729
+ if (!available) throw new Error(`Port ${this.requestedPort} is already in use. Either stop the process using that port or omit -p/--port to auto-select an available port.`);
730
+ this.actualPort = this.requestedPort;
731
+ } else {
732
+ this.actualPort = await findAvailablePort(this.requestedPort);
733
+ if (this.actualPort !== this.requestedPort) logger$2.log(`ℹ️ Port ${this.requestedPort} was in use, using port ${this.actualPort} instead`);
734
+ }
728
735
  const serverEntryPath = join$1(process.cwd(), ".gkm", this.provider, "server.ts");
729
736
  await this.createServerEntry();
730
737
  logger$2.log(`\n✨ Starting server on port ${this.actualPort}...`);
@@ -2700,12 +2707,13 @@ program.command("build").description("Build handlers from endpoints, functions,
2700
2707
  process.exit(1);
2701
2708
  }
2702
2709
  });
2703
- program.command("dev").description("Start development server with automatic reload").option("--port <port>", "Port to run the development server on", "3000").option("--enable-openapi", "Enable OpenAPI documentation for development server", true).action(async (options) => {
2710
+ program.command("dev").description("Start development server with automatic reload").option("-p, --port <port>", "Port to run the development server on").option("--enable-openapi", "Enable OpenAPI documentation for development server", true).action(async (options) => {
2704
2711
  try {
2705
2712
  const globalOptions = program.opts();
2706
2713
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
2707
2714
  await devCommand({
2708
2715
  port: options.port ? Number.parseInt(options.port) : 3e3,
2716
+ portExplicit: !!options.port,
2709
2717
  enableOpenApi: options.enableOpenapi ?? true
2710
2718
  });
2711
2719
  } catch (error) {
@@ -2728,11 +2736,11 @@ program.command("api").description("Manage REST API endpoints").action(() => {
2728
2736
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
2729
2737
  process.stdout.write("REST API management - coming soon\n");
2730
2738
  });
2731
- program.command("openapi").description("Generate OpenAPI specification from endpoints (TypeScript by default)").option("--output <path>", "Output file path for the OpenAPI spec", "openapi.ts").option("--json", "Generate JSON instead of TypeScript (legacy)", false).action(async (options) => {
2739
+ program.command("openapi").description("Generate OpenAPI specification from endpoints").action(async () => {
2732
2740
  try {
2733
2741
  const globalOptions = program.opts();
2734
2742
  if (globalOptions.cwd) process.chdir(globalOptions.cwd);
2735
- await openapiCommand(options);
2743
+ await openapiCommand({});
2736
2744
  } catch (error) {
2737
2745
  console.error("OpenAPI generation failed:", error.message);
2738
2746
  process.exit(1);