Socket
Socket
Sign inDemoInstall

listr2

Package Overview
Dependencies
23
Maintainers
1
Versions
231
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.0-beta.17 to 6.0.0-beta.18

747

dist/index.d.ts

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

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

@@ -15,7 +15,7 @@ import * as colorette from 'colorette';

/**
* Request type of an event.
* Parameters for the given event in the {@link EventMap}.
*/
type EventData<Event extends string, Map extends Record<string, unknown>> = Event extends keyof Map ? Map[Event] : never;
/**
* For fast typing the event map.
* An event map of given events that defined the parameters and return types for firing a certain event.
*/

@@ -33,3 +33,9 @@ type EventMap<Events extends string> = Partial<Record<Events, unknown>>;

/**
* Indicates an UNICODE characters is coming up.
*/
declare const ANSI_ESCAPE = "\u001B[";
/**
* Generic ANSI escape characters for terminal based operations.
*/
declare const ANSI_ESCAPE_CODES: {

@@ -40,2 +46,5 @@ CURSOR_HIDE: string;

/**
* Environment variables for Listr.
*/
declare enum ListrEnvironmentVariables {

@@ -47,29 +56,57 @@ DISABLE_COLOR = "LISTR_DISABLE_COLOR",

/** Available task states. */
declare enum ListrTaskState {
WAITING = "WAITING",
STARTED = "STARTED",
COMPLETED = "COMPLETED",
FAILED = "FAILED",
SKIPPED = "SKIPPED",
ROLLING_BACK = "ROLLING_BACK",
ROLLED_BACK = "ROLLED_BACK",
RETRY = "RETRY",
PAUSED = "PAUSED",
PROMPT = "PROMPT",
PROMPT_COMPLETED = "PROMPT_COMPLETED"
/**
* The actual error type that is collected and to help identify where the error is triggered from.
*/
declare enum ListrErrorTypes {
/** Task has failed and will try to retry. */
WILL_RETRY = "WILL_RETRY",
/** Task has failed and will try to rollback. */
WILL_ROLLBACK = "WILL_ROLLBACK",
/** Task has failed, ran the rollback action but the rollback action itself has failed. */
HAS_FAILED_TO_ROLLBACK = "HAS_FAILED_TO_ROLLBACK",
/** Task has failed. */
HAS_FAILED = "HAS_FAILED",
/** Task has failed, but exitOnError is set to false, so will ignore this error. */
HAS_FAILED_WITHOUT_ERROR = "HAS_FAILED_WITHOUT_ERROR"
}
/** Generic events that occur throughout the whole listr task set. */
/**
* Events that are triggered by Listr.
*
* These are stateful and singleton events by being attached to the main Listr class and propagating to the subtasks.
*
* @see {@link https://listr2.kilic.dev/listr/events.html}
*/
declare enum ListrEventType {
/** Indicates that underlying renderer should refresh the current render. */
SHOULD_REFRESH_RENDER = "SHOUD_REFRESH_RENDER"
}
/** Internal events that occur inside listr task. */
/**
* Internal events that are fired from the Task.
*
* @see {@link https://listr2.kilic.dev/task/events.html}
*/
declare enum ListrTaskEventType {
/** Title has changed for the current Task. */
TITLE = "TITLE",
/**
* State has changed for the current Task.
*
* @see {@link module:listr2.ListrTaskState}
*/
STATE = "STATE",
/** The current Task has been marked as enabled. */
ENABLED = "ENABLED",
/** The current Task is currently processing subtasks. */
SUBTASK = "SUBTASK",
/** The current Task is now processing a prompt. */
PROMPT = "PROMPT",
/** The current Task is now dumping output. */
OUTPUT = "OUTPUT",
/**
* The current Task is now dumping a message.
*
* @see {module:Listr2.ListrTaskMessage}
*/
MESSAGE = "MESSAGE"

@@ -79,2 +116,32 @@ }

/**
* Tasks can be in various states during the execution.
*
* Whenever a state change occurs, the task will emit a {@link module:listr2.ListrTaskEventType.STATE} with the appropriate state.
*/
declare enum ListrTaskState {
/** Task has not started yet, waiting for pick-up. */
WAITING = "WAITING",
/** Task has started. */
STARTED = "STARTED",
/** Task has been completed. */
COMPLETED = "COMPLETED",
/** Task has failed. */
FAILED = "FAILED",
/** Task has been skipped. */
SKIPPED = "SKIPPED",
/** Task is currently trying to rollback. */
ROLLING_BACK = "ROLLING_BACK",
/** Task has rolledback successfully after failing. */
ROLLED_BACK = "ROLLED_BACK",
/** Task is currently retrying. */
RETRY = "RETRY",
/** Task is currently paused. */
PAUSED = "PAUSED",
/** Task is currently trying to process a prompt. */
PROMPT = "PROMPT",
/** Task has successfully processed the prompt. */
PROMPT_COMPLETED = "PROMPT_COMPLETED"
}
/**
* Tests to see if the object is an RxJS {@link Observable}

@@ -142,4 +209,3 @@ * @param obj the object to test

/**
* useIcons instead of text for log level
* @default false
* Use icons for the log levels.
*/

@@ -161,10 +227,25 @@ useIcons?: boolean;

user?: T;
/**
* Send the designated levels to `process.stderr`.
*/
toStderr?: Levels | string[];
}
interface ListrLoggerStyleMap<Levels extends string> {
/**
* Coloring of the levels.
*/
color?: Partial<Record<Levels, LoggerFormat>>;
/**
* Icons of the levels.
*/
icon?: Partial<Record<Levels, string>>;
}
interface LoggerFieldOptions<MultipleOnly extends boolean = false> {
/**
* Prefix fields for the log entry.
*/
prefix?: MultipleOnly extends false ? LoggerField | LoggerField[] : LoggerField[];
/**
* Suffix fields for the log entry.
*/
suffix?: MultipleOnly extends false ? LoggerField | LoggerField[] : LoggerField[];

@@ -174,5 +255,17 @@ }

interface LoggerFieldFn<Args extends any[] = any[]> {
/**
* The value of the given field.
*/
field: ((...args: Args) => string) | string;
/**
* Condition to display the given field.
*/
condition?: ((...args: Args) => boolean) | boolean;
/**
* Formatting/coloring of the field.
*/
format?: (...args: Args) => LoggerFormat;
/**
* Args to pass to other functions whenever this field is triggered.
*/
args?: Args;

@@ -182,7 +275,17 @@ }

interface LoggerRendererOptions<Levels extends string = ListrLogLevels> {
/**
* Inject your custom implementation of the ListrLogger.
*
* @see {@link https://listr2.kilic.dev/renderer/logger.html}
*/
logger?: typeof ListrLogger;
/**
* Inject your settings for the ListrLogger.
*
* @see {@link https://listr2.kilic.dev/renderer/logger.html}
*/
loggerOptions?: ListrLoggerOptions<Levels>;
}
/** Default loglevels for the logger */
/** Default ListrLogLevels for the logger */
declare enum ListrLogLevels {

@@ -390,3 +493,2 @@ STARTED = "STARTED",

error?: boolean;
cancelCallback?: (settings?: PromptSettings) => string | Error | PromptError | void;
stdout?: WriteStream | Writable;

@@ -447,3 +549,5 @@ enquirer?: Enquirer;

/**
* Extend the task to have more functionality while accessing from the outside.
* The original Task that is defined by the user is wrapped with the TaskWrapper to provide additional functionality.
*
* @see {@link https://listr2.kilic.dev/task/task.html}
*/

@@ -453,37 +557,61 @@ declare class TaskWrapper<Ctx, Renderer extends 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. */
/**
* Title of the current task.
*
* @see {@link https://listr2.kilic.dev/task/title.html}
*/
set title(title: string | string[]);
/** Get the output from the output channel. */
get output(): string;
/** Send a output to the output channel. */
/**
* Send output from the current task to the renderer.
*
* @see {@link https://listr2.kilic.dev/task/output.html}
*/
set output(output: string | any[]);
/** Send a output to the output channel. */
/** Send an output to the output channel as prompt. */
private set promptOutput(value);
/** Create a new subtask with given renderer selection from the parent task. */
/**
* Creates a new set of Listr subtasks.
*
* @see {@link https://listr2.kilic.dev/task/subtasks.html}
*/
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 an error that has to be collected and handled.
*
* @see {@link https://listr2.kilic.dev/task/error-handling.html}
*/
report(error: Error, type: ListrErrorTypes): void;
/** Skip current task. */
/**
* Skip the current task.
*
* @see {@link https://listr2.kilic.dev/task/skip.html}
*/
skip(message?: string, ...metadata: any[]): void;
/** Get the number of retrying, else returns false */
/**
* Check whether this task is currently in a retry state.
*
* @see {@link https://listr2.kilic.dev/task/retry.html}
*/
isRetrying(): Task<Ctx, Renderer>['retry'];
/**
* Create a new Enquirer prompt using prompt options.
* Create a new prompt for getting user input through `enquirer`.
*
* Since process.stdout is controlled by Listr, this will passthrough all Enquirer data through internal stdout.
* - `enquirer` is a optional peer dependency and has to be already installed separately.
*
* @see {@link https://listr2.kilic.dev/task/prompt.html}
*/
prompt<T = any>(options: PromptOptions | PromptOptions<true>[]): Promise<T>;
/** Cancels the current prompt attach to this task. */
/**
* Cancel the current active prompt, if there is any.
*
* @see {@link https://listr2.kilic.dev/task/prompt.html}
*/
cancelPrompt(options?: PromptCancelOptions): void;
/**
* Pass stream of data to internal stdout.
* Generates a fake stdout for your use case, where it will be tunnelled through Listr to handle the rendering process.
*
* 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.
* @see {@link https://listr2.kilic.dev/renderer/process-output.html}
*/

@@ -499,3 +627,3 @@ stdout(type?: ListrTaskEventType.OUTPUT | ListrTaskEventType.PROMPT): NodeJS.WritableStream;

/**
* Create a task from the given set of variables and make it runnable.
* Creates and handles a runnable instance of the Task.
*/

@@ -507,15 +635,15 @@ declare class Task<Ctx, Renderer extends ListrRendererFactory> extends ListrTaskEventManager {

rendererOptions: ListrGetRendererOptions<Renderer>;
/** Unique id per task, randomly generated in the uuid v4 format */
/** Unique id per task, can be used for identifying a Task. */
id: string;
/** The current state of the task. */
state: ListrTaskState;
/** Extend current task with multiple subtasks. */
/** Subtasks of the current task. */
subtasks: Task<Ctx, Renderer>[];
/** Title of the task */
/** Title of the task. */
title?: string;
/** Untouched unchanged title of the task */
/** Initial/Untouched version of the title for using whenever task has a reset. */
readonly initialTitle?: string;
/** Output data from the task. */
/** Output channel for the task. */
output?: string;
/** Current retry number of the task if retrying */
/** Current state of the retry process whenever the task is retrying. */
retry?: ListrTaskRetry;

@@ -528,19 +656,39 @@ /**

message: ListrTaskMessage;
/** Per task options for the current renderer of the task. */
/** Per-task options for the current renderer of the task. */
rendererTaskOptions: ListrGetRendererTaskOptions<Renderer>;
/** This will be triggered each time a new render should happen. */
/** Current prompt instance or prompt error whenever the task is prompting. */
prompt: ListrTaskPrompt;
/** Parent task of the current task. */
parent?: Task<Ctx, Renderer>;
/** Enable flag of this task. */
private enabled;
/** The task object itself, to further utilize it. */
/** User provided Task callback function to run. */
private taskFn;
constructor(listr: Listr<Ctx, any, any>, task: ListrTask<Ctx, any>, options: ListrOptions, rendererOptions: ListrGetRendererOptions<Renderer>);
/**
* Update the current state of the Task and emit the neccassary events.
*/
set state$(state: ListrTaskState);
/**
* Update the current output of the Task and emit the neccassary events.
*/
set output$(data: string);
/**
* Update the current prompt output of the Task and emit the neccassary events.
*/
set promptOutput$(data: string);
/**
* Update or extend the current message of the Task and emit the neccassary events.
*/
set message$(data: Task<Ctx, Renderer>['message']);
/**
* Update the current title of the Task and emit the neccassary events.
*/
set title$(title: string);
/**
* Current task path in the hierarchy.
*/
get path(): string[];
/**
* A function to check whether this task should run at all via enable.
* Checks whether the current task with the given context should be set as enabled.
*/

@@ -552,4 +700,5 @@ check(ctx: Ctx): Promise<boolean>;

hasFinalized(): boolean;
/** Returns whether this task is in progress. */
isPending(): boolean;
/** Returns whether this task is in progress. */
/** Returns whether this task has started. */
isStarted(): boolean;

@@ -568,2 +717,3 @@ /** Returns whether this task is skipped. */

isRetrying(): boolean;
/** Returns whether this task has some kind of reset like retry and rollback going on. */
hasReset(): boolean;

@@ -578,6 +728,7 @@ /** Returns whether enabled function resolves to true. */

isPaused(): boolean;
/** Pause the given task for certain time. */
pause(time: number): Promise<void>;
/** Run the current task. */
run(context: Ctx, wrapper: TaskWrapper<Ctx, Renderer>): Promise<void>;
emitShouldRefreshRender(): void;
private emitShouldRefreshRender;
}

@@ -588,3 +739,3 @@

declare enum ListrDefaultRendererLogLevels {
declare enum ListrDefaultRendererListrLogLevels {
SKIPPED_WITH_COLLAPSE = "SKIPPED_WITH_COLLAPSE",

@@ -606,5 +757,4 @@ SKIPPED_WITHOUT_COLLAPSE = "SKIPPED_WITHOUT_COLLAPSE",

}
declare const LISTR_DEFAULT_RENDERER_STYLE: ListrLoggerStyleMap<ListrDefaultRendererLogLevels>;
declare const LISTR_DEFAULT_RENDERER_STYLE: ListrLoggerStyleMap<ListrDefaultRendererListrLogLevels>;
/** Default updating renderer for Listr2 */
declare class DefaultRenderer implements ListrRenderer {

@@ -614,7 +764,4 @@ private readonly tasks;

private readonly events;
/** designates whether this renderer can output to a non-tty console */
static nonTTY: boolean;
/** renderer options for the defauult renderer */
static rendererOptions: ListrDefaultRendererOptions;
/** per task options for the default renderer */
static rendererTaskOptions: ListrDefaultRendererTaskOptions;

@@ -654,6 +801,3 @@ private bottom;

/**
* show duration for all tasks
*
* @default false
* @global global option that can not be temperated with subtasks
* Show duration for the tasks.
*/

@@ -668,5 +812,2 @@ timer?: PresetTimer;

* Useful for renderers to show the task time.
*
* @param {number} duration
* @returns {string}
*/

@@ -677,2 +818,5 @@ declare function parseTimer(duration: number): string;

interface RendererPresetTimestamp {
/**
* Show timestamp for each event that has been logged.
*/
timestamp?: PresetTimestamp;

@@ -685,115 +829,135 @@ }

type ListrDefaultRendererOptionsStyle = ListrLoggerStyleMap<ListrDefaultRendererLogLevels>;
type ListrDefaultRendererOptionsStyle = ListrLoggerStyleMap<ListrDefaultRendererListrLogLevels>;
type ListrDefaultRendererTask = Task<any, typeof DefaultRenderer>;
interface ListrDefaultRendererOptions extends RendererPresetTimer, LoggerRendererOptions<ListrDefaultRendererLogLevels> {
interface ListrDefaultRendererOptions extends RendererPresetTimer, LoggerRendererOptions<ListrDefaultRendererListrLogLevels> {
/**
* indentation per level of subtask
* Indentation per-level.
*
* @default 2
* - This is a global option that can only be changed through the main Listr class.
*
* @defaultValue `2`
*/
indentation?: number;
/**
* clear all the output generated by the renderer when the task finishes its execution
* Formats the output in to the given lines of `process.stdout.columns`.
*
* @default false
* @global global option that can not be temperated with subtasks
* - This is a global option that can only be changed through the main Listr class.
*
* @defaultValue `'wrap'`
*/
clearOutput?: boolean;
formatOutput?: 'truncate' | 'wrap';
/**
* show the subtasks of the current task
* Clear all the output generated by the renderer when the Listr completes the execution successfully.
*
* @default true
* - This is a global option that can only be changed through the main Listr class.
*
* @defaultValue `false`
*/
showSubtasks?: boolean;
clearOutput?: boolean;
/**
* collapse subtasks after current task completes its execution
* Only update the render whenever there is a incoming request through the hook.
*
* @default true
* - This is a global option that can only be changed through the main Listr class.
* - Useful for snapshot tests, where this will disable showing spinner and only update the screen if something else has happened in the task worthy to show.
*
* @defaultValue `false`
*/
collapseSubtasks?: boolean;
lazy?: boolean;
/**
* show skip messages or show the original title of the task, this will also disable collapseSkips mode
* Remove empty lines from the output section for decluterring multiple line output.
*
* You can disable showing the skip messages, even though you passed in a message by settings this option,
* if you want to keep the original task title intact.
*
* @default true
* @defaultValue `true`
*/
showSkipMessage?: boolean;
removeEmptyLines?: boolean;
/**
* collapse skip messages into a single message and overwrite the task title
* Spinner visually indicates that a task is running.
*
* @default true
* - You can always implement your own spinner, if the current one does not please you visually.
*/
collapseSkips?: boolean;
spinner?: Spinner;
/**
* suffix skip messages with [SKIPPED] when in collapseSkips mode
* Show the subtasks of the current task.
*
* @default true
* @defaultValue `true`
*/
suffixSkips?: boolean;
showSubtasks?: boolean;
/**
* shows the thrown error message or show the original title of the task, this will also disable collapseErrors mode
* You can disable showing the error messages, even though you passed in a message by settings this option,
* if you want to keep the original task title intact.
* Collapse subtasks after current task completes its execution.
*
* @default true
* @defaultValue `true`
*/
showErrorMessage?: boolean;
collapseSubtasks?: boolean;
/**
* collapse error messages into a single message and overwrite the task title
* Show skip messages or show the original title of the task.
*
* @default true
* - `true` will output the given skip message if there is any.
* - `false` will keep the current task title intact. This will also disable `collapseSkips`.
*
* @defaultValue `true`
*/
collapseErrors?: boolean;
showSkipMessage?: boolean;
/**
* suffix retry messages with [RETRY-${COUNT}] when retry is enabled for a task
* Collapse skip messages into a single message and overwrite the task title.
*
* @default true
* - `true` will collapse skiped tasks.
* - `false` will show the skip message as a data output under the current task title.
*
* @defaultValue `true`
*/
suffixRetries?: boolean;
collapseSkips?: boolean;
/**
* only update through triggers from renderhook
* Suffix skip messages to clearly indicate the task has been skipped with in `collapseSkips` mode.
*
* useful for tests and stuff. this will disable showing spinner and only update the screen if something else has
* happened in the task worthy to show
* - `true` will add `[SKIPPED]` as a suffix.
* - `false` will not add a suffix.
*
* @default false
* @global global option that can not be temperated with subtasks
* @defaultValue `false`
*/
lazy?: boolean;
suffixSkips?: boolean;
/**
* removes empty lines from the data output
* Show the error message or show the original title of the task.
*
* @default true
* - `true` will output the current error encountered with the task if there is any.
* - `false` will keep the current task title intact. This will also disable `collapseErrors`.
*
* @defaultValue `true`
*/
removeEmptyLines?: boolean;
showErrorMessage?: boolean;
/**
* formats data output depending on your requirements.
* Collapse error messages into a single message and overwrite the task title.
*
* @default 'wrap'
* @global global option that can not be temperated with subtasks
* - `true` will collapse the error message.
* - `false` will show the error message as a data output under the current task title.
*
* @defaultValue `true`
*/
formatOutput?: 'truncate' | 'wrap';
collapseErrors?: boolean;
/**
* Implement your own spinner.
* Suffix retry messages to clearly indicate the task is currently retrying.
*
* - `true` will add `[RETRY:COUNT]` as a suffix.
* - `false` will not add a suffix.
*
* @defaultValue `false`
*/
spinner?: Spinner;
suffixRetries?: boolean;
}
interface ListrDefaultRendererTaskOptions extends RendererPresetTimer {
/**
* write task output to the bottom bar instead of the gap under the task title itself.
* useful for a stream of data.
* @default false
* Write task output to the bottom bar instead of the gap under the task title itself.
* This can be useful for stream of data coming in and is the default mode for tasks without a title.
*
* `true` only keep 1 line of the latest data outputted by the task.
* `false` only keep 1 line of the latest data outputted by the task.
* `number` will keep designated data of the latest data outputted by the task.
* - `true` only keep 1 line of the latest data outputted by the task.
* - `number` will keep the defined amount of data as the last lines.
* - `false` will not use bottom bar if task has a title.
*
* @defaultValue `false`
*/
bottomBar?: boolean | number;
/**
* keep output after task finishes
* @default false
* Keep output of the task after task finishes.
*
* works both for the bottom bar and the default behavior
* - This can be enabled for both normal task output under the title and bottom bar.
*
* @defaultValue false
*/

@@ -806,7 +970,4 @@ persistentOutput?: boolean;

options: ListrSilentRendererOptions;
/** designates whether this renderer can output to a non-tty console */
static nonTTY: boolean;
/** renderer options for the silent renderer */
static rendererOptions: ListrSilentRendererOptions;
/** per task options for the silent renderer */
static rendererTaskOptions: ListrSilentRendererTaskOptions;

@@ -822,7 +983,2 @@ constructor(tasks: ListrSilentRendererTask[], options: ListrSilentRendererOptions);

/**
* This is the default renderer which is neither verbose or updating.
* It provides short output like update renderer, but does not disturb
* stdin during execution of listr tasks
*/
declare class SimpleRenderer implements ListrRenderer {

@@ -851,7 +1007,4 @@ private readonly tasks;

private readonly options;
/** designates whether this renderer can output to a non-tty console */
static nonTTY: boolean;
/** renderer options for the verbose renderer */
static rendererOptions: ListrTestRendererOptions;
/** per task options for the verbose renderer */
static rendererTaskOptions: ListrTestRendererTaskOptions;

@@ -875,9 +1028,35 @@ private readonly logger;

interface ListrTestRendererOptions extends LoggerRendererOptions {
/**
* Log subtasks.
*
* @defaultValue `true`
*/
subtasks?: boolean;
/**
* Log given task states.
*/
state?: ListrTaskState[];
/**
* Log output.
*/
output?: boolean;
/**
* Log prompt.
*/
prompt?: boolean;
/**
* Log title changes.
*/
title?: boolean;
/**
* Log given messages.
*/
messages?: (keyof ListrTaskMessage)[];
/**
* Log given messages to stderr instead of stdout.
*/
messagesToStderr?: (keyof ListrTaskMessage)[];
/**
* Serialize the given properties of the task inside the logs.
*/
task?: false | TestRendererSerializerTaskKeys[];

@@ -897,7 +1076,4 @@ }

private readonly options;
/** designates whether this renderer can output to a non-tty console */
static nonTTY: boolean;
/** renderer options for the verbose renderer */
static rendererOptions: ListrVerboseRendererOptions;
/** per task options for the verbose renderer */
static rendererTaskOptions: ListrVerboseRendererTaskOptions;

@@ -915,4 +1091,5 @@ private logger;

/**
* log title changes
* @default true
* Log the title changes of the task.
*
* @default `false`
*/

@@ -924,22 +1101,22 @@ logTitleChange?: boolean;

/** The default renderer value used in Listr2 applications */
/** Name of the default renderer. */
type ListrDefaultRendererValue = 'default';
/** Type of default renderer */
/** Type of default renderer. */
type ListrDefaultRenderer = typeof DefaultRenderer;
/** Name of default fallback renderer */
/** Name of simple renderer. */
type ListrSimpleRendererValue = 'simple';
/** Type of simple renderer. */
type ListrSimpleRenderer = typeof SimpleRenderer;
/** Name of verbose renderer. */
type ListrFallbackRendererValue = 'verbose';
/** Type of default fallback renderer */
/** Type of verbose renderer. */
type ListrFallbackRenderer = typeof VerboseRenderer;
/** Name of testing renderer */
/** Name of test renderer. */
type ListrTestRendererValue = 'test';
/** Type of testing renderer */
/** Type of test renderer. */
type ListrTestRenderer = typeof TestRenderer;
/** Silent rendere for internal usage */
/** Name of silent renderer. */
type ListrSilentRendererValue = 'silent';
/** Typeof silent renderer */
/** Type of silent renderer. */
type ListrSilentRenderer = typeof SilentRenderer;
/** Simple renderer that simplifies things */
type ListrSimpleRendererValue = 'simple';
/** Typeof simple renderer */
type ListrSimpleRenderer = typeof SimpleRenderer;
/**

@@ -963,22 +1140,26 @@ * Listr2 can process either the integrated renderers as string aliases,

/**
* Returns renderer per task options depending on the renderer type.
* Returns renderer per-task options depending on the renderer type.
*/
type ListrGetRendererTaskOptions<T extends ListrRendererValue> = T extends ListrRendererValue ? ListrGetRendererClassFromValue<T>['rendererTaskOptions'] : never;
/** Select renderer as default renderer */
/** Selection and options of the primary preferred renderer. */
interface ListrPrimaryRendererOptions<T extends ListrRendererValue> {
/** the default renderer */
/** Default renderer preferred. */
renderer?: T;
/** Renderer options depending on the current renderer */
/** Renderer options depending on the current renderer. */
rendererOptions?: ListrGetRendererOptions<T>;
}
/** Select a fallback renderer to fallback to in non-tty conditions */
/** Selection and options of the preferred fallback renderer. */
interface ListrSecondaryRendererOptions<T extends ListrRendererValue> {
/** the fallback renderer to fallback to on non-tty conditions */
/** Fallback renderer preferred. */
fallbackRenderer?: T;
/** Renderer options depending on the current renderer */
/** Renderer options depending on the fallback renderer. */
fallbackRendererOptions?: ListrGetRendererOptions<T>;
}
/** Renderer options for the base class, including setup for selecting default and fallback renderers. */
/** Renderer options for the parent Listr class, including setup for selecting default and fallback renderers. */
type ListrRendererOptions<Renderer extends ListrRendererValue, FallbackRenderer extends ListrRendererValue> = ListrPrimaryRendererOptions<Renderer> & ListrSecondaryRendererOptions<FallbackRenderer>;
/** The bones of a listr renderer. */
/**
* The definition of a ListrRenderer.
*
* @see {@link https://listr2.kilic.dev/renderer/renderer.html}
*/
declare class ListrRenderer {

@@ -998,22 +1179,5 @@ /** designate renderer global options that is specific to the current renderer */

}
/** Exported for javascript applications to extend the base renderer */
declare class ListrBaseRenderer implements ListrRenderer {
/** designate renderer global options that is specific to the current renderer */
static rendererOptions: Record<PropertyKey, any>;
/** designate renderer per task options that is specific to the current renderer */
static rendererTaskOptions: Record<PropertyKey, any>;
/** designate whether this renderer can work in non-tty environments */
static nonTTY: boolean;
tasks: Task<any, typeof ListrBaseRenderer>[];
options: typeof ListrBaseRenderer.rendererOptions;
/** A function to what to do on render */
render: () => void | Promise<void>;
/** A function to what to do on end of the render */
end: (err?: Error) => void;
/** create a new renderer */
constructor(tasks: readonly Task<any, typeof ListrBaseRenderer>[], options: typeof ListrBaseRenderer.rendererOptions, events?: ListrEventManager);
}
/** A renderer factory from the current type */
/** Factory of compatible Listr renderers. */
type ListrRendererFactory = typeof ListrRenderer;
/** Supported type of renderers for each type in the listr. */
/** Renderer selection for current Listr. */
interface SupportedRenderer<Renderer extends ListrRendererFactory> {

@@ -1024,22 +1188,23 @@ renderer: Renderer;

/** Listr Default Context */
/** Listr context. */
type ListrContext = any | undefined;
/**
* Options to set the behavior of this base task.
* Options to set the behavior of Listr.
*/
interface ListrOptions<Ctx = ListrContext> {
/**
* To inject a context through this options wrapper. Context can also be defined in run time.
* Inject a context through this options wrapper.
*
* @default {}
* @defaultValue `{}`
* @see {@link https://listr2.kilic.dev/listr/context.html}
*/
ctx?: Ctx;
/**
* Concurrency sets how many tasks will be run at the same time in parallel.
* Concurrency limits how many tasks will be running in parallel.
*
* @default false > Default is to run everything synchronously.
* - `false` will only run a single task at a time.
* - `true` will set it to `Infinity` to run all the tasks in parallel.
* - Given a `number` it will limit the concurrency to that number.
*
* `true` will set it to `Infinity`, `false` will set it to synchronous.
*
* If you pass in a `number` it will limit it to that number.
* @defaultValue `false`
*/

@@ -1050,3 +1215,6 @@ concurrent?: boolean | number;

*
* @default true > exit on any error coming from the tasks.
* - `true` will exit the current Listr whenever it encounters an error.
* - `false` will continue the execution of current Listr if it encounters an error.
*
* @defaultValue `true`
*/

@@ -1057,30 +1225,33 @@ exitOnError?: boolean;

*
* This is independent of exitOnError, since failure of a rollback can be a more critical operation comparing to
* This is independent of `exitOnError`, since failure of a rollback can be a more critical operation comparing to
* failing a single task.
*
* @default true > exit after rolling back tasks
* - `true` will stop the execution whenever a rollback happens.
* - `false` will continue after successfully recovering from a rollback.
*
* @defaultValue `true`
*/
exitAfterRollback?: boolean;
/**
* Collects errors to `ListrInstance.errors`
* Collects errors inside the `Listr.errors`.
*
* This can take up a lot of memory, so disabling it can fix out-of-memory errors
* - `false` will collect no errors.
* - `minimal` will only collect the error message and the location.
* - `full` will clone the current context and task in to the error instance.
*
* - 'full' will clone the current context and task in to the error instance
* - 'minimal' will only collect the error message and the location
* - false will collect no errors
*
* @default false
* @defaultValue `false`
* @see {@link https://listr2.kilic.dev/task/error-handling.html#collected-errors}
*/
collectErrors?: false | 'minimal' | 'full';
/**
* By default, Listr2 will track SIGINIT signal to update the renderer one last time before completely failing.
* Listr will track SIGINIT signal to update the renderer one last time before failing, therefore it needs to
* register exit listeners.
*
* @default true
* @defaultValue true
*/
registerSignalListeners?: boolean;
/**
* Determine the certain condition required to use the non-TTY renderer.
* Determine the certain condition required to use the fallback renderer.
*
* @default null > handled internally
* @defaultValue handled internally
*/

@@ -1091,27 +1262,27 @@ fallbackRendererCondition?: boolean | (() => boolean);

*
* @default null > handled internally
* @defaultValue handled internally
*/
silentRendererCondition?: boolean | (() => boolean);
/**
* Disabling the color, useful for tests and such.
* Disable the color output coming from Listr for all renderers.
*
* @default false
* @defaultValue `false`
*/
disableColor?: boolean;
/**
* Forces usage of color.
* Force use color, even though the underlying library detects your current output may not be compatible.
*
* @default false
* @defaultValue `false`
*/
forceColor?: boolean;
/**
* Forces TTY stdout eventhough current terminal might not support it.
* Forces TTY stdout even though your current output may not be compatible.
*
* @default false
* @defaultValue `false`
*/
forceTTY?: boolean;
/**
* Forces unicode eventhough current terminal might not support it.
* Forces unicode icons even though your current output may not be compatible.
*
* @default false
* @defaultValue `false`
*/

@@ -1123,2 +1294,5 @@ forceUnicode?: boolean;

injectWrapper?: {
/**
* Inject an `enquirer` instance for using with prompts.
*/
enquirer?: Enquirer<object>;

@@ -1128,6 +1302,4 @@ };

/**
* Parent class options.
* Parent Listr has more options where you can also change global settings.
*
* Parent class has more options where you can also select the and set renderer and non-tty renderer.
*
* Any subtasks will respect those options so they will be stripped of that properties.

@@ -1138,4 +1310,2 @@ */

/**
* Sub class options.
*
* Subtasks has reduced set options where the missing ones are explicitly set by the base class.

@@ -1146,3 +1316,7 @@ */

/** The internal error handling mechanism.. */
/**
* Internal error handling mechanism for Listr collects the errors and details for a failed task.
*
* @see {@link https://listr2.kilic.dev/task/error-handling.html}
*/
declare class ListrError<Ctx extends ListrContext = ListrContext> extends Error {

@@ -1157,17 +1331,6 @@ error: Error;

/**
* The actual error type that is collected and to help identify where the error is triggered from.
* Internal error handling mechanism for Listr prompts to identify the failing cause is coming from a prompt.
*
* @see {@link https://listr2.kilic.dev/task/prompts.html}
*/
declare enum ListrErrorTypes {
/** Task has failed and will try to retry. */
WILL_RETRY = "WILL_RETRY",
/** Task has failed and will try to rollback. */
WILL_ROLLBACK = "WILL_ROLLBACK",
/** Task has failed, ran the rollback action but the rollback action itself has failed. */
HAS_FAILED_TO_ROLLBACK = "HAS_FAILED_TO_ROLLBACK",
/** Task has failed. */
HAS_FAILED = "HAS_FAILED",
/** Task has failed, but exitOnError is set to false, so will ignore this error. */
HAS_FAILED_WITHOUT_ERROR = "HAS_FAILED_WITHOUT_ERROR"
}
/** The internal error handling mechanism for prompts only. */
declare class PromptError extends Error {

@@ -1178,6 +1341,17 @@ constructor(message: string);

/**
* ListrTask.
* Event map for Listr.
*
* Defines the task, conditions and options to run a specific task in the listr.
* @see {@link https://listr2.kilic.dev/listr/events.html}
* @see {@link module:listr2.ListrEventType}
*/
declare class ListrEventMap extends BaseEventMap implements EventMap<ListrEventType> {
[ListrEventType.SHOULD_REFRESH_RENDER]: never;
}
/**
* Defines the task, conditions and options to run a specific task in the Listr.
* This defines the external API for the task where {@link TaskWrapper} is used internally.
*
* @see {@link https://listr2.kilic.dev/task/task.html}
*/
interface ListrTask<Ctx = ListrContext, Renderer extends ListrRendererFactory = any> {

@@ -1187,31 +1361,39 @@ /**

*
* Give this task a title if you want to track it by name in the current renderer.
* Give this task a title to enchance it on the preferred 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.'
* - Tasks without a title will be hidden from view in renderers and will act as a background task.
*
* @see {@link https://listr2.kilic.dev/task/title.html}
*/
title?: string;
/**
* The task itself.
* The task itself in the form of a `Function`, `Promise`, `Listr`, `Observable` or `Stream`.
*
* 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 will be executed, whenever the provided criterion is met with the current state and whenever the time for that specific task has come.
*
* @see {@link https://listr2.kilic.dev/task/task.html}
*/
task: ListrTaskFn<Ctx, Renderer>;
/**
* Enable a task depending on the context.
*
* - The callback function will be evaluated before all the tasks start to check which tasks has been enabled.
* - The callback function will be evaluated again before the task starts.
*
* @see {@link https://listr2.kilic.dev/task/enable.html}
*/
enabled?: boolean | ((ctx: Ctx) => boolean | Promise<boolean>);
/**
* 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.
* - The callback function will be evaluated once before the task starts.
*
* @see {@link https://listr2.kilic.dev/task/skip.html}
*/
skip?: boolean | string | ((ctx: Ctx) => boolean | string | Promise<boolean | string>);
/**
* Enable a task depending on the context.
* Retries a task with the given amounts whenever a task fails.
*
* 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.
* @see {@link https://listr2.kilic.dev/task/retry.html}
*/
enabled?: boolean | ((ctx: Ctx) => boolean | Promise<boolean>);
/**
* Adds the given number of retry attempts to the task if the task fails.
*/
retry?: number | {

@@ -1222,17 +1404,18 @@ tries: number;

/**
* Runs a specific event if the current task or any of the subtasks has failed.
* The callback function that you provide will run whenever the attached task fails and
* give you the ability to revert your changes, before failing.
*
* 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.
* @see {@link https://listr2.kilic.dev/task/rollback.html}
*/
rollback?: ListrTaskFn<Ctx, Renderer>;
/**
* Set exit on the error option from task-level instead of setting it for all the subtasks.
* Determine the default behavior of exiting on errors for this attached task.
*/
exitOnError?: boolean | ((ctx: Ctx) => boolean | Promise<boolean>);
/**
* Per task options, that depends on the selected renderer.
* 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 of the current preferred renderer can be changed on task level.
* - These options depend on the implementation of the preferred renderer.
* - Whenever the preferred renderer has no options it will be displayed as never.
*/

@@ -1242,7 +1425,21 @@ options?: ListrGetRendererTaskOptions<Renderer>;

/**
* Task can be set of sync or async function, an Observable or a stream.
* Result of the processed task can be any of the supported types.
*/
type ListrTaskResult<Ctx> = string | Promise<any> | Listr<Ctx, ListrRendererValue, any> | Readable | NodeJS.ReadableStream | Observable<any>;
/**
* The callback function from the user that defines the task.
*/
type ListrTaskFn<Ctx, Renderer extends ListrRendererFactory> = (ctx: Ctx, task: TaskWrapper<Ctx, Renderer>) => void | ListrTaskResult<Ctx>;
/**
* Tasks can have attached prompts to them.
*
* - Whenever the prompt is running this should be with full with the instance of current prompt.
* - Whenever the prompt fails/cancelled it is tracked here as well due to some internal complication with `enquirer`.
*/
type ListrTaskPrompt = PromptInstance | PromptError;
/**
* Tasks can retry themselves when defined.
*
* - This holds the value of the current error and the current retry attempt.
*/
interface ListrTaskRetry {

@@ -1252,22 +1449,28 @@ count: number;

}
/**
* Task can provide additional information depending on the current state of the Task.
*
* TaskMessage is used to propagate these messages to the renderers for displaying them to the end-user.
*/
interface ListrTaskMessage {
/** Run time of the task, if it has been successfully resolved. */
/** Elapsed time of the current task, whenever the Task completes. */
duration?: number;
/** Error message of the task, if it has been failed. */
/** Error message from the current task, whenever the Task fails. */
error?: string;
/** Skip message of the task, if it has been skipped. */
/** Skip message from the current task, whenever the Task skips. */
skip?: string;
/** Rollback message of the task, if the rollback finishes */
/** Rollback message from the current task, whenever the Task finishes rollback. */
rollback?: string;
/** Retry messages */
/** Retry message from the current task, whenever the Task tries to retry. */
retry?: ListrTaskRetry;
/** When this task is last paused. */
/** Holds the time as epoch time of when will this task continue to execute. */
paused?: number;
}
/** Event map for generic listr events. */
declare class ListrEventMap extends BaseEventMap implements EventMap<ListrEventType> {
[ListrEventType.SHOULD_REFRESH_RENDER]: never;
}
/** Event map for internal listr events. */
/**
* Event map for Task.
*
* @see {@link https://listr2.kilic.dev/task/events.html}
* @see {@link module:listr2.ListrTaskEventType}
*/
declare class ListrTaskEventMap extends BaseEventMap implements EventMap<ListrTaskEventType> {

@@ -1325,2 +1528,2 @@ [ListrTaskEventType.STATE]: ListrTaskState;

export { ANSI_ESCAPE, ANSI_ESCAPE_CODES, BaseEventMap, Concurrency, DefaultRenderer, EventData, EventManager, EventMap, Figures, LISTR_DEFAULT_RENDERER_STYLE, LISTR_LOGGER_STYLE, Listr, ListrBaseClassOptions, ListrBaseRenderer, ListrContext, ListrDefaultRenderer, ListrDefaultRendererLogLevels, ListrDefaultRendererOptions, ListrDefaultRendererOptionsStyle, ListrDefaultRendererTask, ListrDefaultRendererTaskOptions, ListrDefaultRendererValue, ListrEnvironmentVariables, ListrError, ListrErrorTypes, ListrEventManager, ListrEventMap, ListrEventType, ListrFallbackRenderer, ListrFallbackRendererValue, ListrGetRendererClassFromValue, ListrGetRendererOptions, ListrGetRendererTaskOptions, ListrGetRendererValueFromClass, ListrLogLevels, ListrLogger, ListrLoggerOptions, ListrLoggerStyleMap, ListrOptions, ListrPrimaryRendererOptions, ListrRenderer, ListrRendererFactory, ListrRendererOptions, ListrRendererValue, ListrSecondaryRendererOptions, ListrSilentRenderer, ListrSilentRendererOptions, ListrSilentRendererTask, ListrSilentRendererTaskOptions, ListrSilentRendererValue, ListrSimpleRenderer, ListrSimpleRendererOptions, ListrSimpleRendererTask, ListrSimpleRendererTaskOptions, ListrSimpleRendererValue, ListrSubClassOptions, ListrTask, ListrTaskEventManager, ListrTaskEventMap, ListrTaskEventType, ListrTaskFn, ListrTaskMessage, Task as ListrTaskObject, ListrTaskPrompt, ListrTaskResult, ListrTaskRetry, ListrTaskState, TaskWrapper as ListrTaskWrapper, ListrTestRenderer, ListrTestRendererOptions, ListrTestRendererTask, ListrTestRendererTaskOptions, ListrTestRendererValue, ListrVerboseRendererOptions, ListrVerboseRendererTask, ListrVerboseRendererTaskOptions, LoggerField, LoggerFieldFn, LoggerFieldOptions, LoggerFormat, LoggerRendererOptions, Manager, PRESET_TIMER, PRESET_TIMESTAMP, PresetTimer, PresetTimestamp, ProcessOutput, ProcessOutputBuffer, ProcessOutputBufferEntry, ProcessOutputBufferOptions, ProcessOutputRendererOptions, ProcessOutputStream, PromptCancelOptions, PromptError, PromptInstance, PromptOptions, PromptOptionsMap, PromptOptionsType, PromptSettings, PromptTypes, RendererPresetTimer, RendererPresetTimestamp, SilentRenderer, SimpleRenderer, Spinner, SupportedRenderer, TestRenderer, TestRendererSerializer, TestRendererSerializerOutput, TestRendererSerializerTaskKeys, Unionize, VerboseRenderer, assertFunctionOrSelf, cleanseAnsi, cloneObject, color, createPrompt, delay, figures, getRenderer, getRendererClass, indent, isObservable, isUnicodeSupported, parseTimer, parseTimestamp, splat };
export { ANSI_ESCAPE, ANSI_ESCAPE_CODES, BaseEventMap, Concurrency, DefaultRenderer, EventData, EventManager, EventMap, Figures, LISTR_DEFAULT_RENDERER_STYLE, LISTR_LOGGER_STYLE, Listr, ListrBaseClassOptions, ListrContext, ListrDefaultRenderer, ListrDefaultRendererListrLogLevels, ListrDefaultRendererOptions, ListrDefaultRendererOptionsStyle, ListrDefaultRendererTask, ListrDefaultRendererTaskOptions, ListrDefaultRendererValue, ListrEnvironmentVariables, ListrError, ListrErrorTypes, ListrEventManager, ListrEventMap, ListrEventType, ListrFallbackRenderer, ListrFallbackRendererValue, ListrGetRendererClassFromValue, ListrGetRendererOptions, ListrGetRendererTaskOptions, ListrGetRendererValueFromClass, ListrLogLevels, ListrLogger, ListrLoggerOptions, ListrLoggerStyleMap, ListrOptions, ListrPrimaryRendererOptions, ListrRenderer, ListrRendererFactory, ListrRendererOptions, ListrRendererValue, ListrSecondaryRendererOptions, ListrSilentRenderer, ListrSilentRendererOptions, ListrSilentRendererTask, ListrSilentRendererTaskOptions, ListrSilentRendererValue, ListrSimpleRenderer, ListrSimpleRendererOptions, ListrSimpleRendererTask, ListrSimpleRendererTaskOptions, ListrSimpleRendererValue, ListrSubClassOptions, ListrTask, ListrTaskEventManager, ListrTaskEventMap, ListrTaskEventType, ListrTaskFn, ListrTaskMessage, Task as ListrTaskObject, ListrTaskPrompt, ListrTaskResult, ListrTaskRetry, ListrTaskState, TaskWrapper as ListrTaskWrapper, ListrTestRenderer, ListrTestRendererOptions, ListrTestRendererTask, ListrTestRendererTaskOptions, ListrTestRendererValue, ListrVerboseRendererOptions, ListrVerboseRendererTask, ListrVerboseRendererTaskOptions, LoggerField, LoggerFieldFn, LoggerFieldOptions, LoggerFormat, LoggerRendererOptions, Manager, PRESET_TIMER, PRESET_TIMESTAMP, PresetTimer, PresetTimestamp, ProcessOutput, ProcessOutputBuffer, ProcessOutputBufferEntry, ProcessOutputBufferOptions, ProcessOutputRendererOptions, ProcessOutputStream, PromptCancelOptions, PromptError, PromptInstance, PromptOptions, PromptOptionsMap, PromptOptionsType, PromptSettings, PromptTypes, RendererPresetTimer, RendererPresetTimestamp, SilentRenderer, SimpleRenderer, Spinner, SupportedRenderer, TestRenderer, TestRendererSerializer, TestRendererSerializerOutput, TestRendererSerializerTaskKeys, Unionize, VerboseRenderer, assertFunctionOrSelf, cleanseAnsi, cloneObject, color, createPrompt, delay, figures, getRenderer, getRendererClass, indent, isObservable, isUnicodeSupported, parseTimer, parseTimestamp, splat };
{
"name": "listr2",
"version": "6.0.0-beta.17",
"version": "6.0.0-beta.18",
"description": "Terminal task list reborn! Create beautiful CLI interfaces via easy and logical to implement task lists that feel alive and interactive.",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc