@igniter-js/cli 0.2.63 → 0.2.64
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.js +72 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -20000,6 +20000,74 @@ async function handleGenerateProcedure(name, feature) {
|
|
|
20000
20000
|
logger5.warn(`'generate procedure' is not yet fully implemented. Use 'generate feature --schema' instead.`);
|
|
20001
20001
|
}
|
|
20002
20002
|
|
|
20003
|
+
// src/lib/port-manager.ts
|
|
20004
|
+
init_logger();
|
|
20005
|
+
import { spawn as spawn3 } from "child_process";
|
|
20006
|
+
async function killProcessOnPort(port) {
|
|
20007
|
+
const isWindows = process.platform === "win32";
|
|
20008
|
+
const isMac = process.platform === "darwin";
|
|
20009
|
+
const isLinux = process.platform === "linux";
|
|
20010
|
+
try {
|
|
20011
|
+
let command;
|
|
20012
|
+
let args;
|
|
20013
|
+
if (isWindows) {
|
|
20014
|
+
command = "cmd";
|
|
20015
|
+
args = ["/c", `netstat -ano | findstr :${port} | findstr LISTENING`];
|
|
20016
|
+
} else if (isMac || isLinux) {
|
|
20017
|
+
command = "lsof";
|
|
20018
|
+
args = ["-ti", `:${port}`];
|
|
20019
|
+
} else {
|
|
20020
|
+
logger.warn(`Unsupported platform: ${process.platform}. Skipping port cleanup.`);
|
|
20021
|
+
return;
|
|
20022
|
+
}
|
|
20023
|
+
const child = spawn3(command, args, { stdio: ["pipe", "pipe", "pipe"] });
|
|
20024
|
+
let stdout = "";
|
|
20025
|
+
let stderr = "";
|
|
20026
|
+
child.stdout.on("data", (data) => {
|
|
20027
|
+
stdout += data.toString();
|
|
20028
|
+
});
|
|
20029
|
+
child.stderr.on("data", (data) => {
|
|
20030
|
+
stderr += data.toString();
|
|
20031
|
+
});
|
|
20032
|
+
await new Promise((resolve5) => {
|
|
20033
|
+
child.on("close", async (code) => {
|
|
20034
|
+
if (code === 0 && stdout.trim()) {
|
|
20035
|
+
const pids = stdout.trim().split("\n").filter((line) => line.trim());
|
|
20036
|
+
if (pids.length > 0) {
|
|
20037
|
+
logger.info(`Found ${pids.length} process(es) using port ${port}. Killing...`);
|
|
20038
|
+
for (const pid of pids) {
|
|
20039
|
+
try {
|
|
20040
|
+
if (isWindows) {
|
|
20041
|
+
const parts = pid.trim().split(/\s+/);
|
|
20042
|
+
const actualPid = parts[parts.length - 1];
|
|
20043
|
+
spawn3("taskkill", ["/PID", actualPid, "/F"], { stdio: "inherit" });
|
|
20044
|
+
} else {
|
|
20045
|
+
process.kill(parseInt(pid.trim()), "SIGTERM");
|
|
20046
|
+
setTimeout(() => {
|
|
20047
|
+
try {
|
|
20048
|
+
process.kill(parseInt(pid.trim()), "SIGKILL");
|
|
20049
|
+
} catch (e) {
|
|
20050
|
+
}
|
|
20051
|
+
}, 2e3);
|
|
20052
|
+
}
|
|
20053
|
+
} catch (error) {
|
|
20054
|
+
logger.warn(`Failed to kill process ${pid}:`, error);
|
|
20055
|
+
}
|
|
20056
|
+
}
|
|
20057
|
+
await new Promise((resolve6) => setTimeout(resolve6, 1e3));
|
|
20058
|
+
logger.info(`Port ${port} freed successfully.`);
|
|
20059
|
+
}
|
|
20060
|
+
} else if (code !== 0 && stderr) {
|
|
20061
|
+
logger.debug(`Port check command failed (this is normal if no processes are using the port): ${stderr}`);
|
|
20062
|
+
}
|
|
20063
|
+
resolve5();
|
|
20064
|
+
});
|
|
20065
|
+
});
|
|
20066
|
+
} catch (error) {
|
|
20067
|
+
logger.warn(`Failed to check/kill processes on port ${port}:`, error);
|
|
20068
|
+
}
|
|
20069
|
+
}
|
|
20070
|
+
|
|
20003
20071
|
// src/index.ts
|
|
20004
20072
|
var program = new Command();
|
|
20005
20073
|
program.name("igniter").description("CLI for Igniter.js type-safe client generation").version("1.0.0").option("--debug", "Enable debug mode for detailed logging", false).hook("preAction", (thisCommand) => {
|
|
@@ -20058,6 +20126,9 @@ program.command("init").description("Create a new Igniter.js project with intera
|
|
|
20058
20126
|
}
|
|
20059
20127
|
});
|
|
20060
20128
|
program.command("dev").description("Start development mode with framework and Igniter (interactive dashboard and OpenAPI docs by default)").option("--framework <type>", `Framework type (${getFrameworkList()}, generic)`).option("--output <dir>", "Output directory for generated client files", "src/").option("--port <number>", "Port for the dev server", "3000").option("--cmd <command>", "Custom command to start dev server").option("--no-framework", "Disable framework dev server (Igniter only)").option("--no-interactive", "Disable interactive mode (use regular concurrent mode)").option("--docs-output <dir>", "Output directory for OpenAPI docs", "./src/docs").action(async (options) => {
|
|
20129
|
+
const port = parseInt(options.port) || 3e3;
|
|
20130
|
+
logger.info(`Checking and freeing port ${port}...`);
|
|
20131
|
+
await killProcessOnPort(port);
|
|
20061
20132
|
const detectedFramework = detectFramework();
|
|
20062
20133
|
const framework = options.framework ? isFrameworkSupported(options.framework) ? options.framework : "generic" : detectedFramework;
|
|
20063
20134
|
const useInteractive = options.interactive !== false;
|
|
@@ -20082,7 +20153,7 @@ program.command("dev").description("Start development mode with framework and Ig
|
|
|
20082
20153
|
command: frameworkCommand,
|
|
20083
20154
|
color: "green",
|
|
20084
20155
|
cwd: process.cwd(),
|
|
20085
|
-
env: { PORT:
|
|
20156
|
+
env: { PORT: port.toString(), NODE_ENV: "development" }
|
|
20086
20157
|
});
|
|
20087
20158
|
}
|
|
20088
20159
|
}
|