portfree
Version:
A cross-platform CLI tool for managing processes running on specific ports
62 lines • 2.34 kB
TypeScript
import { Process as FreePortProcess } from '../models/process';
import { BaseAdapter } from '../adapters/base-adapter';
/**
* Port Manager core business logic
* Coordinates platform adapters to provide cross-platform port management functionality
*/
export declare class PortManager {
private adapter;
private _initialized;
private readonly logger;
private readonly getPlatformAdapterFn;
constructor(adapter?: BaseAdapter, getPlatformAdapterFn?: () => Promise<any>);
/**
* Initialize the port manager with the appropriate platform adapter
* @throws If platform adapter cannot be initialized
*/
initialize(): Promise<void>;
/**
* Check processes running on the specified port with detailed information
* @param port - Port number to check
* @returns Array of Process objects running on the port
* @throws If port number is invalid or port lookup fails
*/
checkPort(port: number | string): Promise<FreePortProcess[]>;
/**
* Kill a process by PID with error handling
* @param pid - Process ID to terminate
* @returns True if process was successfully terminated
* @throws If PID is invalid, insufficient permissions, or process termination fails
*/
killProcess(pid: number | string): Promise<boolean>;
/**
* Get detailed information about a process by PID
* @param pid - Process ID
* @returns Process details object
* @throws If PID is invalid or process details cannot be retrieved
*/
getProcessDetails(pid: number | string): Promise<{
pid: number;
user: string;
name: string;
command: string;
}>;
/**
* Check if a specific port is available (no processes running on it)
* @param port - Port number to check
* @returns True if port is available, false if occupied
* @throws If port number is invalid or port lookup fails
*/
isPortAvailable(port: number | string): Promise<boolean>;
/**
* Get the current platform adapter instance
* @returns Platform adapter instance or null if not initialized
*/
getAdapter(): BaseAdapter | null;
/**
* Check if the port manager is initialized
* @returns True if initialized
*/
isInitialized(): boolean;
}
//# sourceMappingURL=port-manager.d.ts.map