picgo
Version:
A tool for image uploading
32 lines (31 loc) • 1.48 kB
TypeScript
import type { Ora } from 'ora';
import type { IPicGo, IProgress } from '../../../types';
import type { IBuildInEvent } from '../../../utils/enum';
/**
* Options for a generic CLI progress renderer.
*
* The renderer picks one of three modes:
* - **TTY mode** — stdout is an interactive terminal AND `verbose=false`: ora spinner draws the
* progress bar in place (single line that updates).
* - **Verbose mode** — `verbose=true`: each event prints a full line, suitable for log redirection
* or when the operator wants per-event history.
* - **Non-TTY mode** — stdout is piped / CI: same as verbose, lines printed one at a time so
* downstream log capture isn't clobbered by spinner escape codes.
*
* The caller only provides two formatters: the inline label that follows the bar in TTY mode,
* and the full line text used in verbose / non-TTY modes.
*/
export interface IProgressRendererOptions<TProgress extends IProgress> {
ctx: IPicGo;
event: IBuildInEvent;
verbose: boolean;
/** Label appended after the progress bar in TTY mode. */
formatBarText: (payload: TProgress) => string;
/** Full line text printed in verbose / non-TTY modes. */
formatVerboseText: (payload: TProgress) => string;
}
export interface IProgressRendererHandle {
spinner: Ora;
dispose: () => void;
}
export declare const createProgressRenderer: <TProgress extends IProgress>(options: IProgressRendererOptions<TProgress>) => IProgressRendererHandle;