@vxrn/takeout-cli
Version:
CLI tools for Takeout starter kit - interactive onboarding and project setup
48 lines (47 loc) • 1.19 kB
JavaScript
import { execSync } from "node:child_process";
function isPortInUse(port) {
try {
const output = execSync(`lsof -i :${port} -t`, {
encoding: "utf-8",
stdio: ["pipe", "pipe", "ignore"]
}).trim(), pid = output ? Number.parseInt(output.split(`
`)[0] || "8081", 10) : void 0;
return { inUse: !!output, pid };
} catch {
return { inUse: !1 };
}
}
const TAKEOUT_PORTS = {
postgres: 5432,
zero: 4848,
web: 8081,
minio: 9090,
minioConsole: 9091
};
function checkPort(port, name) {
const { inUse, pid } = isPortInUse(port);
return { port, name, inUse, pid };
}
function checkAllPorts() {
return [
checkPort(TAKEOUT_PORTS.postgres, "PostgreSQL"),
checkPort(TAKEOUT_PORTS.zero, "Zero Sync"),
checkPort(TAKEOUT_PORTS.web, "Web Server"),
checkPort(TAKEOUT_PORTS.minio, "MinIO (S3)"),
checkPort(TAKEOUT_PORTS.minioConsole, "MinIO Console")
];
}
function hasPortConflicts(checks) {
return checks.some((c) => c.inUse);
}
function getConflictingPorts(checks) {
return checks.filter((c) => c.inUse);
}
export {
TAKEOUT_PORTS,
checkAllPorts,
checkPort,
getConflictingPorts,
hasPortConflicts
};
//# sourceMappingURL=ports.js.map