UNPKG

docker-pilot

Version:

A powerful, scalable Docker CLI library for managing containerized applications of any size

122 lines 4.12 kB
/** * Command Runner for Docker Pilot * Executes system commands with proper error handling and logging */ import { ChildProcess } from 'child_process'; import { CommandResult } from '../types'; import { Logger } from '../utils/Logger'; export interface CommandRunnerOptions { timeout?: number; silent?: boolean; cwd?: string; env?: Record<string, string>; shell?: boolean; } export declare class CommandRunner { private logger; private defaultOptions; constructor(logger?: Logger, defaultOptions?: CommandRunnerOptions); /** * Execute command synchronously */ execSync(command: string, options?: CommandRunnerOptions & { encoding?: BufferEncoding; }): CommandResult; /** * Execute command asynchronously */ exec(command: string, options?: CommandRunnerOptions): Promise<CommandResult>; /** * Spawn a process for interactive or long-running commands */ spawn(command: string, args?: string[], options?: CommandRunnerOptions & { interactive?: boolean; onOutput?: (data: string) => void; onError?: (data: string) => void; onClose?: (code: number | null, signal: string | null) => void; }): ChildProcess; /** * Execute Docker command */ execDocker(subcommand: string, args?: string[], options?: CommandRunnerOptions): Promise<CommandResult>; /** * Execute Docker Compose command */ execDockerCompose(subcommand: string, args?: string[], options?: CommandRunnerOptions & { composeFile?: string; projectName?: string; }): Promise<CommandResult>; /** * Execute Docker Compose command synchronously */ execDockerComposeSync(subcommand: string, args?: string[], options?: CommandRunnerOptions & { composeFile?: string; projectName?: string; }): CommandResult; /** * Spawn Docker Compose command for interactive use */ spawnDockerCompose(subcommand: string, args?: string[], options?: CommandRunnerOptions & { composeFile?: string; projectName?: string; interactive?: boolean; onOutput?: (data: string) => void; onError?: (data: string) => void; onClose?: (code: number | null, signal: string | null) => void; }): ChildProcess; /** * Execute command with retry logic */ execWithRetry(command: string, options?: CommandRunnerOptions & { maxRetries?: number; retryDelay?: number; retryCondition?: (result: CommandResult) => boolean; }): Promise<CommandResult>; /** * Execute multiple commands in sequence */ execSequence(commands: string[], options?: CommandRunnerOptions & { stopOnError?: boolean; }): Promise<CommandResult[]>; /** * Execute multiple commands in parallel */ execParallel(commands: string[], options?: CommandRunnerOptions): Promise<CommandResult[]>; /** * Check if command exists in system PATH */ commandExists(command: string): Promise<boolean>; /** * Get command version */ getCommandVersion(command: string, versionFlag?: string): Promise<string | null>; /** * Kill process by PID */ killProcess(pid: number, signal?: string): Promise<boolean>; /** * Execute command with timeout */ execWithTimeout(command: string, timeoutMs: number, options?: CommandRunnerOptions): Promise<CommandResult>; /** * Execute command and return only success status */ execQuiet(command: string, options?: CommandRunnerOptions): Promise<boolean>; /** * Execute command and throw error if it fails */ execOrThrow(command: string, options?: CommandRunnerOptions): Promise<string>; /** * Set default options for all commands */ setDefaultOptions(options: Partial<CommandRunnerOptions>): void; /** * Get current default options */ getDefaultOptions(): CommandRunnerOptions; /** * Sleep utility for retry logic */ private sleep; } //# sourceMappingURL=CommandRunner.d.ts.map