Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

listr2

Package Overview
Dependencies
Maintainers
1
Versions
235
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

listr2 - npm Package Compare versions

Comparing version 6.0.0-beta.5 to 6.0.0-beta.6

599

dist/index.d.ts

@@ -1,4 +0,4 @@

import Enquirer from 'enquirer';
import { Observable } from 'rxjs';
import { Writable, Readable } from 'stream';
import Enquirer from 'enquirer';
import { WriteStream } from 'fs';

@@ -17,2 +17,3 @@ import * as colorette from 'colorette';

SUBTASK = "SUBTASK",
PROMPT = "PROMPT",
OUTPUT = "OUTPUT",

@@ -38,5 +39,26 @@ MESSAGE = "MESSAGE"

declare class EventManager<Event extends string = string, Map extends Partial<Record<Event, unknown>> = Partial<Record<Event, any>>> {
private readonly emitter;
emit<E extends Event = Event>(dispatch: E, args?: EventData<E, Map>): void;
on<E extends Event = Event>(dispatch: E, handler: (data: EventData<E, Map>) => void): void;
once<E extends Event = Event>(dispatch: E, handler: (data: EventData<E, Map>) => void): void;
off<E extends Event = Event>(dispatch: E, handler?: (data: EventData<E, Map>) => void): void;
complete(): void;
}
declare const ANSI_ESCAPE = "\u001B[";
declare const ANSI_ESCAPE_CODES: {
CURSOR_HIDE: string;
CURSOR_SHOW: string;
};
declare enum ListrEnvironmentVariables {
DISABLE_COLOR = "LISTR_DISABLE_COLOR",
FORCE_UNICODE = "LISTR_FORCE_UNICODE",
FORCE_COLOR = "FORCE_COLOR"
}
/** Available task states. */
declare enum ListrTaskState {
UNINITIALIZED = "UNINITIALIZED",
WAITING = "WAITING",
STARTED = "STARTED",

@@ -48,12 +70,7 @@ COMPLETED = "COMPLETED",

ROLLED_BACK = "ROLLED_BACK",
RETRY = "RETRY"
RETRY = "RETRY",
PROMPT = "PROMPT",
PROMPT_COMPLETED = "PROMPT_COMPLETED"
}
declare class EventManager<Event extends string = string, Map extends Partial<Record<Event, unknown>> = Partial<Record<Event, any>>> {
private readonly emitter;
emit<E extends Event = Event>(dispatch: E, args?: EventData<E, Map>): void;
on<E extends Event = Event>(dispatch: E, handler: (data: EventData<E, Map>) => void): void;
complete(): void;
}
/**

@@ -72,2 +89,4 @@ * Tests to see if the object is an RxJS {@link Observable}

declare function cleanseAnsiOutput(chunk: string): string;
declare const color: colorette.Colorette;

@@ -114,3 +133,4 @@

ROLLBACK = "ROLLBACK",
RETRY = "RETRY"
RETRY = "RETRY",
PROMPT = "PROMPT"
}

@@ -125,17 +145,21 @@

constructor(options?: ListrLoggerOptions);
started(message: string, options?: LogEntityOptions): void;
failed(message: string, options?: LogEntityOptions): void;
skipped(message: string, options?: LogEntityOptions): void;
completed(message: string, options?: LogEntityOptions): void;
output(message: string, options?: LogEntityOptions): void;
title(message: string, options?: LogEntityOptions): void;
retry(message: string, options?: LogEntityOptions): void;
rollback(message: string, options?: LogEntityOptions): void;
started(message: string | any[], options?: LogEntityOptions): void;
failed(message: string | any[], options?: LogEntityOptions): void;
skipped(message: string | any[], options?: LogEntityOptions): void;
completed(message: string | any[], options?: LogEntityOptions): void;
output(message: string | any[], options?: LogEntityOptions): void;
title(message: string | any[], options?: LogEntityOptions): void;
retry(message: string | any[], options?: LogEntityOptions): void;
rollback(message: string | any[], options?: LogEntityOptions): void;
prompt(message: string | any[], options?: LogEntityOptions): void;
stdout(message: string | any[], options?: LogEntityOptions): void;
wrap(message: string, options?: {
format?: LoggerFormat;
}): string;
splat(...args: Parameters<typeof splat>): ReturnType<typeof splat>;
suffix(message: string, ...suffixes: LoggerField[]): string;
prefix(message: string, ...prefixes: LoggerField[]): string;
applyToEntity(message: string, options?: LogEntityOptions<true>): string;
protected format(level: LogLevels, message: string, options?: LogEntityOptions): string;
fields(message: string, options?: LogEntityOptions<true>): string;
icon<T extends RendererStyleMap<K>, K extends string>(map: T, level: K, icon?: string | false): string;
protected format(level: LogLevels, message: string | any[], options?: LogEntityOptions): string;
protected style(level: LogLevels, message: string): string;

@@ -154,3 +178,5 @@ }

entityOptions?: LogEntityOptions<true>;
style?: ListrLoggerOptionStyle;
}
type ListrLoggerOptionStyle = RendererStyleMap<LogLevels>;
interface LogEntityOptions<MultipleOnly extends boolean = false> {

@@ -172,7 +198,16 @@ prefix?: MultipleOnly extends false ? LoggerField | LoggerField[] : LoggerField[];

declare class ProcessOutputBuffer {
private buffer;
private readonly decoder;
get all(): string[];
get last(): string;
get length(): number;
write(data: Uint8Array | string, ...args: [(string | undefined)?, ((err?: Error) => void)?] | [((err?: Error) => void)?]): ReturnType<NodeJS.WriteStream['write']>;
reset(): void;
}
declare class ProcessOutputHook {
private stream;
private readonly decoder;
private history;
private readonly method;
private buffer;
constructor(stream: NodeJS.WriteStream);

@@ -195,4 +230,4 @@ get out(): NodeJS.WriteStream;

release(): void;
writeToStdout(buffer: string): boolean;
writeToStderr(buffer: string): boolean;
toStdout(buffer: string, eol?: boolean): boolean;
toStderr(buffer: string, eol?: boolean): boolean;
}

@@ -217,3 +252,3 @@

isRunning(): boolean;
start(cb?: () => void): void;
start(cb?: () => void, interval?: number): void;
stop(): void;

@@ -296,2 +331,5 @@ }

}
interface PromptCancelOptions {
throw?: boolean;
}
/** Returns all the prompt options depending on the type selected. */

@@ -357,3 +395,2 @@ type PromptOptions<T extends boolean = false> = Unionize<{

declare function createPrompt(this: any, options: PromptOptions | PromptOptions<true>[], settings?: PromptSettings): Promise<any>;
declare function destroyPrompt(this: TaskWrapper<any, any>, throwError?: boolean): void;

@@ -375,5 +412,157 @@ declare function getRendererClass(renderer: ListrRendererValue): ListrRendererFactory;

declare class Concurrency {
private concurrency;
private count;
private queue;
constructor(options: {
concurrency: number;
});
add<T>(fn: () => Promise<T>): Promise<T>;
private flush;
private run;
}
/** Generate a basic uuid with no requirement of being unbelievable unique. */
declare function generateUUID(): string;
/**
* Extend the task to have more functionality while accessing from the outside.
*/
declare class TaskWrapper<Ctx, Renderer extends ListrRendererFactory> {
task: Task<Ctx, ListrRendererFactory>;
private options;
private errors;
constructor(task: Task<Ctx, ListrRendererFactory>, options: ListrBaseClassOptions<Ctx, any, any>);
/** Get the title of the current task. */
get title(): string;
/** Change the title of the current task. */
set title(title: string | string[]);
/** Get the output from the output channel. */
get output(): string;
/** Send a output to the output channel. */
set output(output: string | any[]);
/** Send a output to the output channel. */
private set promptOutput(value);
/** Create a new subtask with given renderer selection from the parent task. */
newListr<NewCtx = Ctx>(task: ListrTask<NewCtx, Renderer> | ListrTask<NewCtx, Renderer>[] | ((parent: Omit<this, 'skip' | 'enabled'>) => ListrTask<NewCtx, Renderer> | ListrTask<NewCtx, Renderer>[]), options?: ListrSubClassOptions<NewCtx, Renderer>): Listr<NewCtx, any, any>;
/** Report a error in process for error collection. */
report(error: Error, type: ListrErrorTypes): void;
/** Skip current task. */
skip(message?: string, ...metadata: any[]): void;
/** Get the number of retrying, else returns false */
isRetrying(): Task<Ctx, Renderer>['retry'];
/**
* Create a new Enquirer prompt using prompt options.
*
* Since process.stdout is controlled by Listr, this will passthrough all Enquirer data through internal stdout.
*/
prompt<T = any>(options: PromptOptions | PromptOptions<true>[]): Promise<T>;
/** Cancels the current prompt attach to this task. */
cancelPrompt(options?: PromptCancelOptions): void;
/**
* Pass stream of data to internal stdout.
*
* Since Listr2 takes control of process.stdout utilizing the default renderer, any data outputted to process.stdout
* will corrupt its looks.
*
* This returns a fake stream to pass any stream inside Listr as task data.
*/
stdout(type?: ListrTaskEventType.OUTPUT | ListrTaskEventType.PROMPT): NodeJS.WritableStream;
/** Run this task. */
run(ctx: Ctx): Promise<void>;
}
/**
* Create a task from the given set of variables and make it runnable.
*/
declare class Task<Ctx, Renderer extends ListrRendererFactory> extends EventManager<ListrTaskEventType, ListrTaskEventMap> {
listr: Listr<Ctx, any, any>;
task: ListrTask<Ctx, any>;
options: ListrOptions;
rendererOptions: ListrGetRendererOptions<Renderer>;
/** Unique id per task, randomly generated in the uuid v4 format */
id: string;
/** The current state of the task. */
state: ListrTaskState;
/** Extend current task with multiple subtasks. */
subtasks: Task<Ctx, Renderer>[];
/** Title of the task */
title?: string;
/** Untouched unchanged title of the task */
readonly initialTitle?: string;
/** Output data from the task. */
output?: string;
/** Current retry number of the task if retrying */
retry?: ListrTaskRetry;
/**
* A channel for messages.
*
* This requires a separate channel for messages like error, skip or runtime messages to further utilize in the renderers.
*/
message: ListrTaskMessage;
/** Per task options for the current renderer of the task. */
rendererTaskOptions: ListrGetRendererTaskOptions<Renderer>;
/** This will be triggered each time a new render should happen. */
prompt: ListrTaskPrompt;
parent?: Task<Ctx, Renderer>;
private enabled;
/** The task object itself, to further utilize it. */
private taskFn;
constructor(listr: Listr<Ctx, any, any>, task: ListrTask<Ctx, any>, options: ListrOptions, rendererOptions: ListrGetRendererOptions<Renderer>);
set state$(state: ListrTaskState);
set output$(data: string);
set promptOutput$(data: string);
set message$(data: Task<Ctx, Renderer>['message']);
set title$(title: string);
/**
* A function to check whether this task should run at all via enable.
*/
check(ctx: Ctx): Promise<boolean>;
/** Returns whether this task has subtasks. */
hasSubtasks(): boolean;
/** Returns whether this task is finalized in someform. */
hasFinalized(): boolean;
isPending(): boolean;
/** Returns whether this task is in progress. */
isStarted(): boolean;
/** Returns whether this task is skipped. */
isSkipped(): boolean;
/** Returns whether this task has been completed. */
isCompleted(): boolean;
/** Returns whether this task has been failed. */
hasFailed(): boolean;
/** Returns whether this task has an active rollback task going on. */
isRollingBack(): boolean;
/** Returns whether the rollback action was successful. */
hasRolledBack(): boolean;
/** Returns whether this task has an actively retrying task going on. */
isRetrying(): boolean;
hasReset(): boolean;
/** Returns whether enabled function resolves to true. */
isEnabled(): boolean;
/** Returns whether this task actually has a title. */
hasTitle(): boolean;
/** Returns whether this task has a prompt inside. */
isPrompt(): boolean;
/** Run the current task. */
run(context: Ctx, wrapper: TaskWrapper<Ctx, Renderer>): Promise<void>;
emitShouldRefreshRender(): void;
}
declare enum ListrDefaultRendererLogLevels {
SKIPPED_WITH_COLLAPSE = "SKIPPED_WITH_COLLAPSE",
SKIPPED_WITHOUT_COLLAPSE = "SKIPPED_WITHOUT_COLLAPSE",
OUTPUT = "OUTPUT",
PENDING = "PENDING",
COMPLETED = "COMPLETED",
COMPLETED_WITH_FAILED_SUBTASKS = "COMPLETED_WITH_FAILED_SUBTASKS",
COMPLETED_WITH_SISTER_TASKS_FAILED = "COMPLETED_WITH_SISTER_TASKS_FAILED",
RETRY = "RETRY",
ROLLING_BACK = "ROLLING_BACK",
ROLLED_BACK = "ROLLED_BACK",
FAILED = "FAILED",
FAILED_WITH_FAILED_SUBTASKS = "FAILED_WITH_SUBTASKS",
WAITING = "WAITING"
}
type PresetTimer = LoggerFieldFn<[number]>;

@@ -399,5 +588,5 @@ interface RendererPresetTimer {

declare class DefaultRenderer implements ListrRenderer {
tasks: Task<any, typeof DefaultRenderer>[];
options: (typeof DefaultRenderer)['rendererOptions'];
events: EventManager<ListrEventType, ListrEventMap>;
private readonly tasks;
private readonly options;
private readonly events;
/** designates whether this renderer can output to a non-tty console */

@@ -484,9 +673,2 @@ static nonTTY: boolean;

/**
* activate update through triggers from render hook
*
* @default true
* @global global option that can not be temperated with subtasks
*/
eager?: boolean;
/**
* removes empty lines from the data output

@@ -504,2 +686,9 @@ *

formatOutput?: 'truncate' | 'wrap';
/**
* Options for styling with icon and color.
*
* @global global option that can not be temperated with subtasks
*/
style?: ListrDefaultRendererOptionsStyle;
spinner?: Spinner;
} & RendererPresetTimer & LoggerRendererOptions;

@@ -526,15 +715,17 @@ /** per task options for the default renderer */

} & RendererPresetTimer;
private bottomBar;
private promptBar;
private bottom;
private prompt;
private activePrompt;
private readonly spinner;
private readonly logger;
private readonly updater;
constructor(tasks: Task<any, typeof DefaultRenderer>[], options: (typeof DefaultRenderer)['rendererOptions'], events: EventManager<ListrEventType, ListrEventMap>);
constructor(tasks: ListrDefaultRendererTasks, options: ListrDefaultRendererOptions, events: EventManager<ListrEventType, ListrEventMap>);
getTaskOptions(task: Task<any, typeof DefaultRenderer>): (typeof DefaultRenderer)['rendererTaskOptions'];
isBottomBar(task: Task<any, typeof DefaultRenderer>): boolean;
hasPersistentOutput(task: Task<any, typeof DefaultRenderer>): boolean;
getSelfOrParentOption<K extends keyof (typeof DefaultRenderer)['rendererOptions']>(task: Task<any, typeof DefaultRenderer>, key: K): (typeof DefaultRenderer)['rendererOptions'][K];
getSelfOrParentOption<K extends keyof ListrDefaultRendererOptions>(task: Task<any, typeof DefaultRenderer>, key: K): ListrDefaultRendererOptions[K];
render(): void;
update(): void;
end(): void;
createRender(options?: {
create(options?: {
tasks?: boolean;

@@ -544,3 +735,3 @@ bottomBar?: boolean;

}): string;
protected style(task: Task<ListrContext, typeof DefaultRenderer>, data?: boolean): string;
protected style(task: Task<ListrContext, typeof DefaultRenderer>, output?: boolean): string;
protected format(message: string, icon: string, level: number): string[];

@@ -554,2 +745,6 @@ private renderer;

type ListrDefaultRendererOptionsStyle = RendererStyleMap<ListrDefaultRendererLogLevels>;
type ListrDefaultRendererTasks = Task<any, typeof DefaultRenderer>[];
type ListrDefaultRendererOptions = (typeof DefaultRenderer)['rendererOptions'];
declare class SilentRenderer implements ListrRenderer {

@@ -575,4 +770,4 @@ tasks: Task<any, typeof SilentRenderer>[];

declare class SimpleRenderer implements ListrRenderer {
readonly tasks: Task<any, typeof SimpleRenderer>[];
options: (typeof SimpleRenderer)['rendererOptions'];
private readonly tasks;
private options;
static nonTTY: boolean;

@@ -582,100 +777,15 @@ static rendererOptions: RendererPresetTimer & RendererPresetTimestamp & LoggerRendererOptions;

private readonly logger;
private readonly updater;
constructor(tasks: Task<any, typeof SimpleRenderer>[], options: (typeof SimpleRenderer)['rendererOptions']);
constructor(tasks: ListrSimpleRendererTasks, options: ListrSimpleRendererOptions);
end(): void;
render(): void;
getSelfOrParentOption<K extends keyof (typeof SimpleRenderer)['rendererOptions']>(task: Task<any, typeof SimpleRenderer>, key: K): (typeof SimpleRenderer)['rendererOptions'][K];
getSelfOrParentOption<K extends keyof ListrSimpleRendererOptions>(task: Task<any, typeof SimpleRenderer>, key: K): ListrSimpleRendererOptions[K];
private renderer;
}
declare enum ListrEnvironmentVariables {
DISABLE_COLOR = "LISTR_DISABLE_COLOR",
FORCE_UNICODE = "LISTR_FORCE_UNICODE",
FORCE_COLOR = "FORCE_COLOR"
}
type ListrSimpleRendererTasks = Task<any, typeof SimpleRenderer>[];
type ListrSimpleRendererOptions = (typeof SimpleRenderer)['rendererOptions'];
/**
* ListrTask.
*
* Defines the task, conditions and options to run a specific task in the listr.
*/
interface ListrTask<Ctx = ListrContext, Renderer extends ListrRendererFactory = any> {
/**
* Title of the task.
*
* Give this task a title if you want to track it by name in the current renderer.
*
* Tasks without a title will hide in the default renderer and are useful for running a background instance.
* On verbose renderer, state changes from these tasks will log as 'Task without a title.'
*/
title?: string;
/**
* The task itself.
*
* Task can be a sync or async function, an Observable, or a Stream.
* Task will be executed, if the certain criteria of the state are met and whenever the time for that specific task has come.
*/
task: ListrTaskFn<Ctx, Renderer>;
/**
* Skip this task depending on the context.
*
* The function that has been passed in will be evaluated at the runtime when the task tries to initially run.
*/
skip?: boolean | string | ((ctx: Ctx) => boolean | string | Promise<boolean | string>);
/**
* Enable a task depending on the context.
*
* The function that has been passed in will be evaluated at the initial creation of the Listr class for rendering purposes,
* as well as re-evaluated when the time for that specific task has come.
*/
enabled?: boolean | ((ctx: Ctx) => boolean | Promise<boolean>);
/**
* Adds the given number of retry attempts to the task if the task fails.
*/
retry?: number;
/**
* Runs a specific event if the current task or any of the subtasks has failed.
*
* Mostly useful for rollback purposes for subtasks.
* But can also be useful whenever a task is failed and some measures have to be taken to ensure the state is not changed.
*/
rollback?: ListrTaskFn<Ctx, Renderer>;
/**
* Set exit on the error option from task-level instead of setting it for all the subtasks.
*/
exitOnError?: boolean | ((ctx: Ctx) => boolean | Promise<boolean>);
/**
* Per task options, that depends on the selected renderer.
*
* These options depend on the implementation of the selected renderer. If the selected renderer has no options it will
* be displayed as never.
*/
options?: ListrGetRendererTaskOptions<Renderer>;
}
/**
* Task can be set of sync or async function, an Observable or a stream.
*/
type ListrTaskResult<Ctx> = string | Promise<any> | Listr<Ctx, ListrRendererValue, any> | Readable | NodeJS.ReadableStream | Observable<any>;
type ListrTaskFn<Ctx, Renderer extends ListrRendererFactory> = (ctx: Ctx, task: TaskWrapper<Ctx, Renderer>) => void | ListrTaskResult<Ctx>;
type ListrTaskPrompt = undefined | PromptInstance | PromptError;
interface ListrTaskRetry {
count: number;
withError?: Error;
}
interface ListrTaskMessage {
/** Run time of the task, if it has been successfully resolved. */
duration?: number;
/** Error message of the task, if it has been failed. */
error?: string;
/** Skip message of the task, if it has been skipped. */
skip?: string;
/** Rollback message of the task, if the rollback finishes */
rollback?: string;
/** Retry messages */
retry?: ListrTaskRetry;
}
declare class TestRenderer implements ListrRenderer {
tasks: Task<any, typeof TestRenderer>[];
options: (typeof TestRenderer)['rendererOptions'];
private readonly tasks;
private readonly options;
/** designates whether this renderer can output to a non-tty console */

@@ -688,2 +798,3 @@ static nonTTY: boolean;

output?: boolean;
prompt?: boolean;
title?: boolean;

@@ -696,3 +807,3 @@ messages?: (keyof ListrTaskMessage)[];

private readonly logger;
constructor(tasks: Task<any, typeof TestRenderer>[], options: (typeof TestRenderer)['rendererOptions']);
constructor(tasks: ListrTestRendererTasks, options: ListrTestRendererOptions);
render(): void;

@@ -702,2 +813,5 @@ end(): void;

}
type ListrTestRendererTasks = Task<any, typeof TestRenderer>[];
type ListrTestRendererOptions = (typeof TestRenderer)['rendererOptions'];
declare class TestRendererEvent<T extends ListrTaskEventType> {

@@ -712,4 +826,4 @@ event: T;

declare class VerboseRenderer implements ListrRenderer {
tasks: Task<any, typeof VerboseRenderer>[];
options: (typeof VerboseRenderer)['rendererOptions'];
private readonly tasks;
private readonly options;
/** designates whether this renderer can output to a non-tty console */

@@ -728,9 +842,12 @@ static nonTTY: boolean;

private logger;
constructor(tasks: Task<any, typeof VerboseRenderer>[], options: (typeof VerboseRenderer)['rendererOptions']);
constructor(tasks: ListrVerboseRendererTasks, options: ListrVerboseRendererOptions);
render(): void;
end(): void;
getSelfOrParentOption<K extends keyof (typeof VerboseRenderer)['rendererOptions']>(task: Task<any, typeof VerboseRenderer>, key: K): (typeof VerboseRenderer)['rendererOptions'][K];
getSelfOrParentOption<K extends keyof ListrVerboseRendererOptions>(task: Task<any, typeof VerboseRenderer>, key: K): ListrVerboseRendererOptions[K];
private renderer;
}
type ListrVerboseRendererTasks = Task<any, typeof VerboseRenderer>[];
type ListrVerboseRendererOptions = (typeof VerboseRenderer)['rendererOptions'];
/** The default renderer value used in Listr2 applications */

@@ -772,9 +889,9 @@ type ListrDefaultRendererValue = 'default';

*/
type ListrGetRendererOptions<T extends ListrRendererValue> = T extends ListrDefaultRendererValue ? ListrDefaultRenderer['rendererOptions'] : T extends ListrSimpleRendererValue ? ListrSimpleRenderer['rendererOptions'] : T extends ListrFallbackRendererValue ? ListrFallbackRenderer['rendererOptions'] : T extends ListrTestRendererValue ? ListrTestRenderer['rendererOptions'] : T extends ListrSilentRenderer ? ListrSilentRenderer['rendererOptions'] : T extends ListrRendererFactory ? T['rendererOptions'] : never;
type ListrGetRendererOptions<T extends ListrRendererValue> = T extends ListrRendererValue ? ListrGetRendererClassFromValue<T>['rendererOptions'] : never;
/**
* Returns renderer per task options depending on the renderer type.
*/
type ListrGetRendererTaskOptions<T extends ListrRendererValue> = T extends ListrDefaultRendererValue ? ListrDefaultRenderer['rendererTaskOptions'] : T extends ListrSimpleRendererValue ? ListrSimpleRenderer : T extends ListrFallbackRendererValue ? ListrFallbackRenderer['rendererTaskOptions'] : T extends ListrTestRendererValue ? ListrTestRenderer['rendererTaskOptions'] : T extends ListrSilentRenderer ? ListrSilentRenderer['rendererTaskOptions'] : T extends ListrRendererFactory ? T['rendererTaskOptions'] : never;
type ListrGetRendererTaskOptions<T extends ListrRendererValue> = T extends ListrRendererValue ? ListrGetRendererClassFromValue<T>['rendererTaskOptions'] : never;
/** Select renderer as default renderer */
interface ListrDefaultRendererOptions<T extends ListrRendererValue> {
interface ListrPrimaryRendererOptions<T extends ListrRendererValue> {
/** the default renderer */

@@ -786,10 +903,10 @@ renderer?: T;

/** Select a fallback renderer to fallback to in non-tty conditions */
interface ListrDefaultNonTTYRendererOptions<T extends ListrRendererValue> {
interface ListrSecondaryRendererOptions<T extends ListrRendererValue> {
/** the fallback renderer to fallback to on non-tty conditions */
nonTTYRenderer?: T;
fallbackRenderer?: T;
/** Renderer options depending on the current renderer */
nonTTYRendererOptions?: ListrGetRendererOptions<T>;
fallbackRendererOptions?: ListrGetRendererOptions<T>;
}
/** Renderer options for the base class, including setup for selecting default and fallback renderers. */
type ListrRendererOptions<Renderer extends ListrRendererValue, FallbackRenderer extends ListrRendererValue> = ListrDefaultRendererOptions<Renderer> & ListrDefaultNonTTYRendererOptions<FallbackRenderer>;
type ListrRendererOptions<Renderer extends ListrRendererValue, FallbackRenderer extends ListrRendererValue> = ListrPrimaryRendererOptions<Renderer> & ListrSecondaryRendererOptions<FallbackRenderer>;
/** The bones of a listr renderer. */

@@ -825,3 +942,3 @@ declare class ListrRenderer {

/** create a new renderer */
constructor(tasks: Task<any, typeof ListrBaseRenderer>[], options: typeof ListrBaseRenderer.rendererOptions, events?: EventManager<ListrEventType, ListrEventMap>);
constructor(tasks: readonly Task<any, typeof ListrBaseRenderer>[], options: typeof ListrBaseRenderer.rendererOptions, events?: EventManager<ListrEventType, ListrEventMap>);
}

@@ -833,4 +950,8 @@ /** A renderer factory from the current type */

renderer: ListrRendererFactory;
nonTTY: boolean;
isFallbackRenderer: boolean;
}
interface RendererStyleMap<Levels extends string> {
color: Partial<Record<Levels, LoggerFormat>>;
icon: Partial<Record<Levels, string>>;
}

@@ -942,3 +1063,3 @@ /** Listr Default Context */

*/
type ListrBaseClassOptions<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue, FallbackRenderer extends ListrRendererValue = ListrFallbackRendererValue> = ListrOptions<Ctx> & ListrDefaultRendererOptions<Renderer> & ListrDefaultNonTTYRendererOptions<FallbackRenderer>;
type ListrBaseClassOptions<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue, FallbackRenderer extends ListrRendererValue = ListrFallbackRendererValue> = ListrOptions<Ctx> & ListrPrimaryRendererOptions<Renderer> & ListrSecondaryRendererOptions<FallbackRenderer>;
/**

@@ -949,3 +1070,3 @@ * Sub class options.

*/
type ListrSubClassOptions<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue> = ListrOptions<Ctx> & Omit<ListrDefaultRendererOptions<Renderer>, 'renderer'>;
type ListrSubClassOptions<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue> = ListrOptions<Ctx> & Omit<ListrPrimaryRendererOptions<Renderer>, 'renderer'>;

@@ -982,120 +1103,81 @@ /** The internal error handling mechanism.. */

/**
* Extend the task to have more functionality while accessing from the outside.
* ListrTask.
*
* Defines the task, conditions and options to run a specific task in the listr.
*/
declare class TaskWrapper<Ctx, Renderer extends ListrRendererFactory> {
task: Task<Ctx, ListrRendererFactory>;
private options;
private errors;
constructor(task: Task<Ctx, ListrRendererFactory>, options: ListrBaseClassOptions<Ctx, any, any>);
/** Get the title of the current task. */
get title(): string;
/** Change the title of the current task. */
set title(title: string | string[]);
/** Get the output from the output channel. */
get output(): string;
/** Send a output to the output channel. */
set output(output: string | string[]);
/** Create a new subtask with given renderer selection from the parent task. */
newListr<NewCtx = Ctx>(task: ListrTask<NewCtx, Renderer> | ListrTask<NewCtx, Renderer>[] | ((parent: Omit<this, 'skip' | 'enabled'>) => ListrTask<NewCtx, Renderer> | ListrTask<NewCtx, Renderer>[]), options?: ListrSubClassOptions<NewCtx, Renderer>): Listr<NewCtx, any, any>;
/** Report a error in process for error collection. */
report(error: Error, type: ListrErrorTypes): void;
/** Skip current task. */
skip(message?: string, ...metadata: any[]): void;
/** Get the number of retrying, else returns false */
isRetrying(): Task<Ctx, Renderer>['retry'];
interface ListrTask<Ctx = ListrContext, Renderer extends ListrRendererFactory = any> {
/**
* Create a new Enquirer prompt using prompt options.
* Title of the task.
*
* Since process.stdout is controlled by Listr, this will passthrough all Enquirer data through internal stdout.
* Give this task a title if you want to track it by name in the current renderer.
*
* Tasks without a title will hide in the default renderer and are useful for running a background instance.
* On verbose renderer, state changes from these tasks will log as 'Task without a title.'
*/
prompt<T = any>(options: PromptOptions | PromptOptions<true>[]): Promise<T>;
/** Cancels the current prompt attach to this task. */
cancelPrompt(throwError?: boolean): void;
title?: string;
/**
* Pass stream of data to internal stdout.
* The task itself.
*
* Since Listr2 takes control of process.stdout utilizing the default renderer, any data outputted to process.stdout
* will corrupt its looks.
* Task can be a sync or async function, an Observable, or a Stream.
* Task will be executed, if the certain criteria of the state are met and whenever the time for that specific task has come.
*/
task: ListrTaskFn<Ctx, Renderer>;
/**
* Skip this task depending on the context.
*
* This returns a fake stream to pass any stream inside Listr as task data.
* The function that has been passed in will be evaluated at the runtime when the task tries to initially run.
*/
stdout(): NodeJS.WriteStream & NodeJS.WritableStream;
/** Run this task. */
run(ctx: Ctx): Promise<void>;
}
/**
* Create a task from the given set of variables and make it runnable.
*/
declare class Task<Ctx, Renderer extends ListrRendererFactory> extends EventManager<ListrTaskEventType, ListrTaskEventMap> {
listr: Listr<Ctx, any, any>;
task: ListrTask<Ctx, any>;
options: ListrOptions;
rendererOptions: ListrGetRendererOptions<Renderer>;
/** Unique id per task, randomly generated in the uuid v4 format */
id: string;
/** The current state of the task. */
state: ListrTaskState;
/** Extend current task with multiple subtasks. */
subtasks: Task<Ctx, Renderer>[];
/** Title of the task */
title?: string;
/** Untouched unchanged title of the task */
readonly initialTitle?: string;
/** Output data from the task. */
output?: string;
/** Current retry number of the task if retrying */
retry?: ListrTaskRetry;
skip?: boolean | string | ((ctx: Ctx) => boolean | string | Promise<boolean | string>);
/**
* A channel for messages.
* Enable a task depending on the context.
*
* This requires a separate channel for messages like error, skip or runtime messages to further utilize in the renderers.
* The function that has been passed in will be evaluated at the initial creation of the Listr class for rendering purposes,
* as well as re-evaluated when the time for that specific task has come.
*/
message: ListrTaskMessage;
/** Per task options for the current renderer of the task. */
rendererTaskOptions: ListrGetRendererTaskOptions<Renderer>;
/** This will be triggered each time a new render should happen. */
prompt: ListrTaskPrompt;
parent?: Task<Ctx, Renderer>;
private enabled;
/** The task object itself, to further utilize it. */
private taskFn;
constructor(listr: Listr<Ctx, any, any>, task: ListrTask<Ctx, any>, options: ListrOptions, rendererOptions: ListrGetRendererOptions<Renderer>);
set state$(state: ListrTaskState);
set output$(data: string);
set message$(data: Task<Ctx, Renderer>['message']);
set title$(title: string);
enabled?: boolean | ((ctx: Ctx) => boolean | Promise<boolean>);
/**
* A function to check whether this task should run at all via enable.
* Adds the given number of retry attempts to the task if the task fails.
*/
check(ctx: Ctx): Promise<void>;
/** Returns whether this task has subtasks. */
hasSubtasks(): boolean;
/** Returns whether this task is finalized in someform. */
hasFinalized(): boolean;
isPending(): boolean;
/** Returns whether this task is in progress. */
isStarted(): boolean;
/** Returns whether this task is skipped. */
isSkipped(): boolean;
/** Returns whether this task has been completed. */
isCompleted(): boolean;
/** Returns whether this task has been failed. */
hasFailed(): boolean;
/** Returns whether this task has an active rollback task going on. */
isRollingBack(): boolean;
/** Returns whether the rollback action was successful. */
hasRolledBack(): boolean;
/** Returns whether this task has an actively retrying task going on. */
isRetrying(): boolean;
/** Returns whether enabled function resolves to true. */
isEnabled(): boolean;
/** Returns whether this task actually has a title. */
hasTitle(): boolean;
/** Returns whether this task has a prompt inside. */
isPrompt(): boolean;
/** Run the current task. */
run(context: Ctx, wrapper: TaskWrapper<Ctx, Renderer>): Promise<void>;
private emitShouldRefreshRender;
retry?: number;
/**
* Runs a specific event if the current task or any of the subtasks has failed.
*
* Mostly useful for rollback purposes for subtasks.
* But can also be useful whenever a task is failed and some measures have to be taken to ensure the state is not changed.
*/
rollback?: ListrTaskFn<Ctx, Renderer>;
/**
* Set exit on the error option from task-level instead of setting it for all the subtasks.
*/
exitOnError?: boolean | ((ctx: Ctx) => boolean | Promise<boolean>);
/**
* Per task options, that depends on the selected renderer.
*
* These options depend on the implementation of the selected renderer. If the selected renderer has no options it will
* be displayed as never.
*/
options?: ListrGetRendererTaskOptions<Renderer>;
}
/**
* Task can be set of sync or async function, an Observable or a stream.
*/
type ListrTaskResult<Ctx> = string | Promise<any> | Listr<Ctx, ListrRendererValue, any> | Readable | NodeJS.ReadableStream | Observable<any>;
type ListrTaskFn<Ctx, Renderer extends ListrRendererFactory> = (ctx: Ctx, task: TaskWrapper<Ctx, Renderer>) => void | ListrTaskResult<Ctx>;
type ListrTaskPrompt = PromptInstance | PromptError;
interface ListrTaskRetry {
count: number;
withError?: Error;
}
interface ListrTaskMessage {
/** Run time of the task, if it has been successfully resolved. */
duration?: number;
/** Error message of the task, if it has been failed. */
error?: string;
/** Skip message of the task, if it has been skipped. */
skip?: string;
/** Rollback message of the task, if the rollback finishes */
rollback?: string;
/** Retry messages */
retry?: ListrTaskRetry;
}

@@ -1113,3 +1195,4 @@ /** Event map for generic listr events. */

[ListrTaskEventType.OUTPUT]: string;
[ListrTaskEventType.MESSAGE]: Task<any, any>['message'];
[ListrTaskEventType.MESSAGE]: ListrTaskMessage;
[ListrTaskEventType.PROMPT]: string;
}

@@ -1157,2 +1240,2 @@

export { DefaultRenderer, Figures, Listr, ListrBaseClassOptions, ListrBaseRenderer, ListrContext, ListrDefaultNonTTYRendererOptions, ListrDefaultRenderer, ListrDefaultRendererOptions, ListrDefaultRendererValue, ListrEnvironmentVariables, ListrError, ListrErrorTypes, ListrEventType, ListrFallbackRenderer, ListrFallbackRendererValue, ListrGetRendererClassFromValue, ListrGetRendererOptions, ListrGetRendererTaskOptions, ListrGetRendererValueFromClass, ListrLogger, ListrLoggerOptions, ListrOptions, ListrRenderer, ListrRendererFactory, ListrRendererOptions, ListrRendererValue, ListrSilentRenderer, ListrSilentRendererValue, ListrSimpleRenderer, ListrSimpleRendererValue, ListrSubClassOptions, ListrTask, ListrTaskEventType, ListrTaskFn, ListrTaskMessage, Task as ListrTaskObject, ListrTaskPrompt, ListrTaskResult, ListrTaskRetry, ListrTaskState, TaskWrapper as ListrTaskWrapper, ListrTestRenderer, ListrTestRendererValue, LogEntityOptions, LogLevels, LoggerField, LoggerFieldFn, LoggerFormat, LoggerRendererOptions, Manager, PresetTimer, PresetTimestamp, ProcessOutput, ProcessOutputHook, ProcessOutputRendererOptions, PromptError, PromptInstance, PromptOptions, PromptOptionsMap, PromptOptionsType, PromptSettings, PromptTypes, RENDERER_TIMER, RENDERER_TIMESTAMP, RendererPresetTimer, RendererPresetTimestamp, SilentRenderer, SimpleRenderer, Spinner, SupportedRenderer, TestRenderer, TestRendererEvent, Unionize, VerboseRenderer, assertFunctionOrSelf, cloneObject, color, createPrompt, destroyPrompt, figures, generateUUID, getRenderer, getRendererClass, indentString, isObservable, isUnicodeSupported, parseTaskTime, parseTimestamp, splat };
export { ANSI_ESCAPE, ANSI_ESCAPE_CODES, Concurrency, DefaultRenderer, Figures, Listr, ListrBaseClassOptions, ListrBaseRenderer, ListrContext, ListrDefaultRenderer, ListrDefaultRendererLogLevels, ListrDefaultRendererOptions, ListrDefaultRendererOptionsStyle, ListrDefaultRendererTasks, ListrDefaultRendererValue, ListrEnvironmentVariables, ListrError, ListrErrorTypes, ListrEventType, ListrFallbackRenderer, ListrFallbackRendererValue, ListrGetRendererClassFromValue, ListrGetRendererOptions, ListrGetRendererTaskOptions, ListrGetRendererValueFromClass, ListrLogger, ListrLoggerOptionStyle, ListrLoggerOptions, ListrOptions, ListrPrimaryRendererOptions, ListrRenderer, ListrRendererFactory, ListrRendererOptions, ListrRendererValue, ListrSecondaryRendererOptions, ListrSilentRenderer, ListrSilentRendererValue, ListrSimpleRenderer, ListrSimpleRendererOptions, ListrSimpleRendererTasks, ListrSimpleRendererValue, ListrSubClassOptions, ListrTask, ListrTaskEventType, ListrTaskFn, ListrTaskMessage, Task as ListrTaskObject, ListrTaskPrompt, ListrTaskResult, ListrTaskRetry, ListrTaskState, TaskWrapper as ListrTaskWrapper, ListrTestRenderer, ListrTestRendererOptions, ListrTestRendererTasks, ListrTestRendererValue, ListrVerboseRendererOptions, ListrVerboseRendererTasks, LogEntityOptions, LogLevels, LoggerField, LoggerFieldFn, LoggerFormat, LoggerRendererOptions, Manager, PresetTimer, PresetTimestamp, ProcessOutput, ProcessOutputBuffer, ProcessOutputHook, ProcessOutputRendererOptions, PromptCancelOptions, PromptError, PromptInstance, PromptOptions, PromptOptionsMap, PromptOptionsType, PromptSettings, PromptTypes, RENDERER_TIMER, RENDERER_TIMESTAMP, RendererPresetTimer, RendererPresetTimestamp, RendererStyleMap, SilentRenderer, SimpleRenderer, Spinner, SupportedRenderer, TestRenderer, TestRendererEvent, Unionize, VerboseRenderer, assertFunctionOrSelf, cleanseAnsiOutput, cloneObject, color, createPrompt, figures, generateUUID, getRenderer, getRendererClass, indentString, isObservable, isUnicodeSupported, parseTaskTime, parseTimestamp, splat };
{
"name": "listr2",
"version": "6.0.0-beta.5",
"version": "6.0.0-beta.6",
"description": "Terminal task list reborn! Create beautiful CLI interfaces via easy and logical to implement task lists that feel alive and interactive.",

@@ -23,3 +23,3 @@ "license": "MIT",

"engines": {
"node": "^14.13.1 || >=16.0.0"
"node": ">=16.0.0"
},

@@ -76,5 +76,3 @@ "scripts": {

"log-update": "^4.0.0",
"p-map": "^4.0.0",
"rfdc": "^1.3.0",
"through": "^2.3.8",
"wrap-ansi": "^7.0.0"

@@ -81,0 +79,0 @@ },

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc