import { TaskReporterTask } from './TaskReporterTask.js'; import type { TaskReporterLogLevelOptions } from './types/TaskReporterLogLevelOptions.js'; /** * Options for the TaskReporter instance. */ export interface TaskReporterOptions extends TaskReporterLogLevelOptions { /** * Product name to display. */ productName?: string; /** * Version of the product to display. */ version?: string; /** * Description of the product to display next to the product name. * If it uses ANSI codes, use the function version to ensure plain text mode is respected. */ description?: string | (() => string); /** * Help message to display. */ helpMessage?: string; /** * Plain text mode. This will disable sticky rendering which requires ansi support. */ plainTextMode?: boolean; /** * Log all console output to a file */ logFile?: boolean; /** * If true, the reporter will track force-shown completed tasks and any non-task console outputs, * and reprint them on `reset()`. (Without this option, `reset()` is a no-op.) * Only relevant when running in an interactive context such as `cloudpack start`. * * WARNING: This option likely needs to be set on initial `TaskReporter` creation, since it's * intended to capture all console outputs from the start of the program. */ enableReset?: boolean; /** * This will be used as the working directory for the log file. * Required if `logFile` is true. */ cwd?: string; } interface TaskReporterCompleteParams { /** * If set, this will be printed instead of the default task summary. * Ignored if `TaskReporterOptions.showSummary` was false. */ summary?: string; /** * If true, show the help message after the summary. * Ignored if `TaskReporterOptions.showSummary` was false. */ showHelp?: boolean; } /** * A reporter for tasks. This is used to report the status of tasks to the console. */ export declare class TaskReporter { private _options; private _writer; private _pendingTasks; private _runningTasks; private _runningTaskStickies; /** * List of tasks that are forced to show and console outputs that are not part of a task. * Only initialized if `options.enableReset` is true, since this is only needed for the reset * functionality of an interactive command (such as `cloudpack start`), and is just a * waste of memory otherwise. */ private _savedOutputs; /** * Delta in heap usage for each task (bytes). Only populated if `options.showHeapUsage` is set. * NOTE: These might not be meaningful since multiple tasks can execute in parallel (no way to * isolate which task actually used the memory), and we don't know when GC might happen. */ private _taskHeapDeltas; /** * Whether the reporter is not completed (false), in the process of completing, or has fully completed. * (Many operations should be skipped if either in progress or completed, but a few need to run * during the completion process.) */ private _completed; private _originalConsoleMethods; private _ignoredLogMessages; private _maxHeapSize; /** Number of completed tasks with each status */ private _summary; /** Number of completed tasks with any status */ private _completedCount; /** Prefixes for log messages, respecting the current `plainTextMode` setting */ private _messagePrefixes; constructor(options?: TaskReporterOptions); /** * Add a partial string to match on console logging. When found, we ignore the message. */ ignoreLogMessage(partialMatch: string): void; /** * Set options. If the product name changes, this will also print the product info. */ setOptions(options: TaskReporterOptions): void; getOptions(): Readonly; /** * Add a task to the reporter. If `pending` is true, the task will be initially * in a waiting state. Otherwise it will assume to be in a started state. */ addTask(name: string, pending?: boolean): TaskReporterTask; /** * Complete reporting: mark all pending tasks as skipped, all running tasks as aborted, * clear stickies, and print the summary. Throws an error if called more than once. * * NOTE: To dispose associated resources, you must call `reporter.dispose()`. * This is separate since disposal is async, and the reporter may need to complete * synchronously in certain scenarios (such as process exit handling). */ complete(params?: TaskReporterCompleteParams): void; /** Dispose resources after completion */ dispose(): Promise; /** Returns whether any tasks have failed (does not consider `console.error`) */ hasErrors(): boolean; /** * Determines the effective log method to use for a message. * This handles special cases like Node.js deprecation warnings that should be * treated as warnings even if they come through console.error. */ private _getEffectiveLogMethod; /** * Detects if a message is a Node.js deprecation warning. * Node.js deprecation warnings typically follow the pattern: * (node:PID) [DEPXXXX] DeprecationWarning: ... */ private _isNodeDeprecationWarning; private _overrideConsoleLogging; private _reportProductInfo; private _reportMessage; private _reportTaskComplete; /** * Clear the screen and reset the reporter. * WARNING: This is a no-op unless `options.enableReset` is set to true. * * If enabled, this will clear the screen and scrollback, then reprint the product info. * Unless `clearOutputs` is true, it will also reprint any console outputs and force-shown tasks. * * @param clearOutputs If true, clears any previous saved outputs. */ reset(clearOutputs?: boolean): void; private _reportSummary; private _updateStickies; } export {}; //# sourceMappingURL=TaskReporter.d.ts.map