import 'reflect-metadata'; import { ChildProcess } from 'child_process'; import { CoreModels } from './core-models'; export declare namespace UtilsProcess { interface ResolvePromiseMsg { /** * until this string is in output of stdout */ stdout?: string | string[]; /** * until this string is in output of stderr */ stderr?: string | string[]; /** * by default only resolve when exit code is 0 */ resolveAfterAnyExitCode?: boolean; } export interface ProcessStartOptions { /** * by default is process.cwd(); */ cwd?: string; /** * by default is false */ showCommand?: boolean; /** * Modify output line by line */ outputLineReplace?: (outputLineStderOrStdout: string) => string; resolvePromiseMsg?: ResolvePromiseMsg; /** * Prefix messages output from child_process */ prefix?: string; /** * Try command again after fail after n milliseconds */ tryAgainWhenFailAfter?: number; askToTryAgainOnError?: boolean; exitOnErrorCallback?: (code: number) => void; /** * Use big buffer for big webpack logs * (it may slow down smaller processes execution) */ biggerBuffer?: boolean; hideOutput?: { stdout?: boolean; stderr?: boolean; }; } /** * TODO IMPLEMENT * start async node process */ export const startAsync: (command: string, cwd: string, options?: Omit) => Promise; /** * This let you start child process and resolve promise when some * condition is met. It is useful for example when you want to start * process and wait until some output is in stdout or stderr. */ export const startAsyncChildProcessCommandUntil: (command: string, options: { /** * tels when to resolve promise */ untilOptions: ResolvePromiseMsg; displayOutputInParentProcess?: boolean; resolveAfterAnyExitCode?: boolean; cwd?: string; }) => Promise; export const getGitBashPath: () => string; /** * TODO IMPLEMENT * start async node process */ export const startInNewTerminalWindow: (command: string, options?: Pick) => any; export const getBashOrShellName: () => "browser" | "cmd" | "powershell" | "gitbash" | "cygwin" | "unknown" | "bash" | "zsh" | "fish" | "sh"; /** * Get CPU and memory usage for a single PID. */ export const getUsageForPid: (pid: number) => Promise<{ cpu: number; memoryInGB: number; memoryInMB: number; }>; /** * Cross-platform function to list *direct* child PIDs of a given PID. * Uses the appropriate command depending on `process.platform`. */ export function getChildPidsOnce(pid: number): Promise; /** * Get CPU and memory usage for the current process (the Node.js process itself), * plus any child processes spawned by it. */ export const getCurrentProcessAndChildUsage: () => Promise<{ current: { cpu: number; memoryInMB: number; }; children: Array<{ pid: number; cpu: number; memoryInMB: number; }>; }>; /** * Kills all running Java processes cross‑platform. * @returns Promise true if processes were killed, false if none found */ export const killAllJava: () => Promise; export const killProcess: (pidOrProcess: number | ChildProcess) => Promise; export const killProcessOnPort: (port: number) => Promise; /** * Kills all Node.js processes except the current process. * Works on Windows, macOS, and Linux. * @returns {number} Number of processes killed */ export const killAllOtherNodeProcesses: () => Promise; export const isNodeVersionOk: (options?: { required?: string; log?: boolean; throwErrorIfNotOk?: boolean; }) => boolean; export const getPathOfExecutable: (command: string) => Promise; export {}; }