/** * TypeScriptServerLauncher - Generic library for launching TypeScript servers locally * * Features: * - Configurable port selection with preferred port and fallback ranges * - Process management with PID tracking * - Automatic dependency installation and builds * - Watch mode support for development * - Retry logic for port conflicts (EADDRINUSE) * - Custom build hooks */ export interface ServerLauncherConfig { /** * Project root directory (defaults to process.cwd()) */ projectRoot?: string; /** * Server directory relative to project root (e.g., 'backend') */ serverDir: string; /** * Command to start the server in development mode (e.g., ['npm', 'run', 'dev']) */ devCommand: string[]; /** * Command to start the server in production mode (e.g., ['npm', 'run', 'start']) */ startCommand: string[]; /** * Preferred port (will try this first) */ preferredPort?: number; /** * Minimum port for fallback search */ minPort?: number; /** * Maximum port for fallback search */ maxPort?: number; /** * Force reclaim the preferred port by terminating existing processes */ forcePort?: boolean; /** * Enable watch mode (auto-restart on file changes) */ watchMode?: boolean; /** * Custom environment variables */ env?: Record; /** * Maximum retries for EADDRINUSE errors */ maxRetries?: number; /** * PID file path (relative to serverDir, defaults to '.local-server.pid') */ pidFile?: string; /** * Build command (defaults to ['npm', 'run', 'build']) */ buildCommand?: string[]; /** * Skip dependency installation (defaults to false) */ skipDependencyInstall?: boolean; /** * Skip build step (defaults to false) */ skipBuild?: boolean; /** * Custom prepare script path (runs before build) */ prepareScriptPath?: string; /** * Hook called before build */ onBeforeBuild?: () => Promise | void; /** * Hook called after build */ onAfterBuild?: () => Promise | void; /** * Hook called when server starts successfully */ onServerStarted?: (port: number, pid: number) => Promise | void; /** * Hook called when server exits */ onServerExit?: (code: number | null) => Promise | void; } export declare class TypeScriptServerLauncher { private config; private serverProcess; private currentPort; constructor(config: ServerLauncherConfig); private get serverDirPath(); private get pidFilePath(); /** * Select an available port with preference and fallback logic */ private selectPort; /** * Run the build pipeline */ private runBuildPipeline; /** * Start the server process */ private startServerProcess; /** * Launch the server with build pipeline and retry logic */ launch(): Promise; /** * Stop the server if it's running */ stop(): Promise; /** * Get the current port the server is running on */ getPort(): number | null; /** * Get the server process PID */ getPid(): number | null; } //# sourceMappingURL=TypeScriptServerLauncher.d.ts.map