@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.js
CHANGED
|
@@ -19996,6 +19996,74 @@ async function handleGenerateProcedure(name, feature) {
|
|
|
19996
19996
|
logger5.warn(`'generate procedure' is not yet fully implemented. Use 'generate feature --schema' instead.`);
|
|
19997
19997
|
}
|
|
19998
19998
|
|
|
19999
|
+
// src/lib/port-manager.ts
|
|
20000
|
+
var import_child_process = require("child_process");
|
|
20001
|
+
init_logger();
|
|
20002
|
+
async function killProcessOnPort(port) {
|
|
20003
|
+
const isWindows = process.platform === "win32";
|
|
20004
|
+
const isMac = process.platform === "darwin";
|
|
20005
|
+
const isLinux = process.platform === "linux";
|
|
20006
|
+
try {
|
|
20007
|
+
let command;
|
|
20008
|
+
let args;
|
|
20009
|
+
if (isWindows) {
|
|
20010
|
+
command = "cmd";
|
|
20011
|
+
args = ["/c", `netstat -ano | findstr :${port} | findstr LISTENING`];
|
|
20012
|
+
} else if (isMac || isLinux) {
|
|
20013
|
+
command = "lsof";
|
|
20014
|
+
args = ["-ti", `:${port}`];
|
|
20015
|
+
} else {
|
|
20016
|
+
logger.warn(`Unsupported platform: ${process.platform}. Skipping port cleanup.`);
|
|
20017
|
+
return;
|
|
20018
|
+
}
|
|
20019
|
+
const child = (0, import_child_process.spawn)(command, args, { stdio: ["pipe", "pipe", "pipe"] });
|
|
20020
|
+
let stdout = "";
|
|
20021
|
+
let stderr = "";
|
|
20022
|
+
child.stdout.on("data", (data) => {
|
|
20023
|
+
stdout += data.toString();
|
|
20024
|
+
});
|
|
20025
|
+
child.stderr.on("data", (data) => {
|
|
20026
|
+
stderr += data.toString();
|
|
20027
|
+
});
|
|
20028
|
+
await new Promise((resolve5) => {
|
|
20029
|
+
child.on("close", async (code) => {
|
|
20030
|
+
if (code === 0 && stdout.trim()) {
|
|
20031
|
+
const pids = stdout.trim().split("\n").filter((line) => line.trim());
|
|
20032
|
+
if (pids.length > 0) {
|
|
20033
|
+
logger.info(`Found ${pids.length} process(es) using port ${port}. Killing...`);
|
|
20034
|
+
for (const pid of pids) {
|
|
20035
|
+
try {
|
|
20036
|
+
if (isWindows) {
|
|
20037
|
+
const parts = pid.trim().split(/\s+/);
|
|
20038
|
+
const actualPid = parts[parts.length - 1];
|
|
20039
|
+
(0, import_child_process.spawn)("taskkill", ["/PID", actualPid, "/F"], { stdio: "inherit" });
|
|
20040
|
+
} else {
|
|
20041
|
+
process.kill(parseInt(pid.trim()), "SIGTERM");
|
|
20042
|
+
setTimeout(() => {
|
|
20043
|
+
try {
|
|
20044
|
+
process.kill(parseInt(pid.trim()), "SIGKILL");
|
|
20045
|
+
} catch (e) {
|
|
20046
|
+
}
|
|
20047
|
+
}, 2e3);
|
|
20048
|
+
}
|
|
20049
|
+
} catch (error) {
|
|
20050
|
+
logger.warn(`Failed to kill process ${pid}:`, error);
|
|
20051
|
+
}
|
|
20052
|
+
}
|
|
20053
|
+
await new Promise((resolve6) => setTimeout(resolve6, 1e3));
|
|
20054
|
+
logger.info(`Port ${port} freed successfully.`);
|
|
20055
|
+
}
|
|
20056
|
+
} else if (code !== 0 && stderr) {
|
|
20057
|
+
logger.debug(`Port check command failed (this is normal if no processes are using the port): ${stderr}`);
|
|
20058
|
+
}
|
|
20059
|
+
resolve5();
|
|
20060
|
+
});
|
|
20061
|
+
});
|
|
20062
|
+
} catch (error) {
|
|
20063
|
+
logger.warn(`Failed to check/kill processes on port ${port}:`, error);
|
|
20064
|
+
}
|
|
20065
|
+
}
|
|
20066
|
+
|
|
19999
20067
|
// src/index.ts
|
|
20000
20068
|
var program = new import_commander.Command();
|
|
20001
20069
|
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) => {
|
|
@@ -20054,6 +20122,9 @@ program.command("init").description("Create a new Igniter.js project with intera
|
|
|
20054
20122
|
}
|
|
20055
20123
|
});
|
|
20056
20124
|
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) => {
|
|
20125
|
+
const port = parseInt(options.port) || 3e3;
|
|
20126
|
+
logger.info(`Checking and freeing port ${port}...`);
|
|
20127
|
+
await killProcessOnPort(port);
|
|
20057
20128
|
const detectedFramework = detectFramework();
|
|
20058
20129
|
const framework = options.framework ? isFrameworkSupported(options.framework) ? options.framework : "generic" : detectedFramework;
|
|
20059
20130
|
const useInteractive = options.interactive !== false;
|
|
@@ -20078,7 +20149,7 @@ program.command("dev").description("Start development mode with framework and Ig
|
|
|
20078
20149
|
command: frameworkCommand,
|
|
20079
20150
|
color: "green",
|
|
20080
20151
|
cwd: process.cwd(),
|
|
20081
|
-
env: { PORT:
|
|
20152
|
+
env: { PORT: port.toString(), NODE_ENV: "development" }
|
|
20082
20153
|
});
|
|
20083
20154
|
}
|
|
20084
20155
|
}
|