UNPKG

@vxrn/takeout-cli

Version:

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

76 lines 2.23 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: !0 }); }, __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); return to; }; var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod); var ports_exports = {}; __export(ports_exports, { TAKEOUT_PORTS: () => TAKEOUT_PORTS, checkAllPorts: () => checkAllPorts, checkPort: () => checkPort, getConflictingPorts: () => getConflictingPorts, hasPortConflicts: () => hasPortConflicts }); module.exports = __toCommonJS(ports_exports); var import_node_child_process = require("node:child_process"); function isPortInUse(port) { try { const output = (0, import_node_child_process.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); }