UNPKG

@vxrn/takeout-cli

Version:

CLI tools for Takeout starter kit - interactive onboarding and project setup

54 lines (53 loc) 1.27 kB
import { execSync } from "node:child_process"; function isPortInUse(port) { try { var 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 }; } } var TAKEOUT_PORTS = { postgres: 5432, zero: 4848, web: 8081, minio: 9090, minioConsole: 9091 }; function checkPort(port, name) { var { 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(function (c) { return c.inUse; }); } function getConflictingPorts(checks) { return checks.filter(function (c) { return c.inUse; }); } export { TAKEOUT_PORTS, checkAllPorts, checkPort, getConflictingPorts, hasPortConflicts }; //# sourceMappingURL=ports.native.js.map