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