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 5.0.3 to 5.0.4

382

dist/index.d.ts

@@ -1,190 +0,6 @@

import { Observable, Subject } from 'rxjs';
import Enquirer from 'enquirer';
import { Readable, Writable } from 'stream';
import { Subject, Observable } from 'rxjs';
import { Writable, Readable } from 'stream';
import { WriteStream } from 'fs';
/** Type of listr internal events. */
declare enum ListrEventType {
TITLE = "TITLE",
STATE = "STATE",
ENABLED = "ENABLED",
SUBTASK = "SUBTASK",
DATA = "DATA",
MESSAGE = "MESSAGE"
}
/** Listr Default Context */
declare type ListrContext = any | undefined;
/**
* 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: (ctx: Ctx, task: TaskWrapper<Ctx, Renderer>) => void | ListrTaskResult<Ctx>;
/**
* 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?: (ctx: Ctx, task: TaskWrapper<Ctx, Renderer>) => void | ListrTaskResult<Ctx>;
/**
* 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>;
}
/**
* Options to set the behavior of this base task.
*/
interface ListrOptions<Ctx = ListrContext> {
/**
* To inject a context through this options wrapper. Context can also be defined in run time.
*
* @default {}
*/
ctx?: Ctx;
/**
* Concurrency sets how many tasks will be run at the same time in parallel.
*
* @default false > Default is to run everything synchronously.
*
* `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.
*/
concurrent?: boolean | number;
/**
* Determine the default behavior of exiting on errors.
*
* @default true > exit on any error coming from the tasks.
*/
exitOnError?: boolean;
/**
* Determine the behavior of exiting after rollback actions.
*
* 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
*/
exitAfterRollback?: boolean;
/**
* Collects errors to `ListrInstance.errors`
*
* This can take up a lot of memory, so disabling it can fix out-of-memory errors
*
* - '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 'minimal'
*/
collectErrors?: false | 'minimal' | 'full';
/**
* By default, Listr2 will track SIGINIT signal to update the renderer one last time before completely failing.
*
* @default true
*/
registerSignalListeners?: boolean;
/**
* Determine the certain condition required to use the non-TTY renderer.
*
* @default null > handled internally
*/
rendererFallback?: boolean | (() => boolean);
/**
* Determine the certain condition required to use the silent renderer.
*
* @default null > handled internally
*/
rendererSilent?: boolean | (() => boolean);
/**
* Disabling the color, useful for tests and such.
*
* @default false
*/
disableColor?: boolean;
/**
* Inject data directly to TaskWrapper.
*/
injectWrapper?: {
enquirer?: Enquirer<object>;
};
}
/**
* Task can be set of sync or async function, an Observable or a stream.
*/
declare type ListrTaskResult<Ctx> = string | Promise<any> | Listr<Ctx, ListrRendererValue, any> | Readable | NodeJS.ReadableStream | Observable<any>;
/**
* Parent class options.
*
* 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.
*/
declare type ListrBaseClassOptions<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue, FallbackRenderer extends ListrRendererValue = ListrFallbackRendererValue> = ListrOptions<Ctx> & ListrDefaultRendererOptions<Renderer> & ListrDefaultNonTTYRendererOptions<FallbackRenderer>;
/**
* Sub class options.
*
* Subtasks has reduced set options where the missing ones are explicitly set by the base class.
*/
declare type ListrSubClassOptions<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue> = ListrOptions<Ctx> & Omit<ListrDefaultRendererOptions<Renderer>, 'renderer'>;
/** The internal communication event. */
declare type ListrEvent = {
type: Exclude<ListrEventType, 'MESSAGE' | 'DATA'>;
data?: string | boolean;
} | {
type: ListrEventType.DATA;
data: string;
} | {
type: ListrEventType.MESSAGE;
data: Task<any, any>['message'];
};
/**
* Used to match event.type to ListrEvent permutations
*/
declare type ListrEventFromType<T extends ListrEventType, E = ListrEvent> = E extends {
type: infer U;
} ? T extends U ? E : never : never;
interface BasePromptOptions {

@@ -316,3 +132,3 @@ message: string | (() => string) | (() => Promise<string>);

/**
* Extend the task to have more functionality while accesing from the outside.
* Extend the task to have more functionality while accessing from the outside.
*/

@@ -352,3 +168,3 @@ declare class TaskWrapper<Ctx, Renderer extends ListrRendererFactory> {

* Since Listr2 takes control of process.stdout utilizing the default renderer, any data outputted to process.stdout
* will corupt its looks.
* will corrupt its looks.
*

@@ -637,2 +453,12 @@ * This returns a fake stream to pass any stream inside Listr as task data.

/** Type of listr internal events. */
declare enum ListrEventType {
TITLE = "TITLE",
STATE = "STATE",
ENABLED = "ENABLED",
SUBTASK = "SUBTASK",
DATA = "DATA",
MESSAGE = "MESSAGE"
}
/**

@@ -857,4 +683,178 @@ * This is the default renderer which is neither verbose or updating.

/** Listr Default Context */
declare type ListrContext = any | undefined;
/**
* 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: (ctx: Ctx, task: TaskWrapper<Ctx, Renderer>) => void | ListrTaskResult<Ctx>;
/**
* 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?: (ctx: Ctx, task: TaskWrapper<Ctx, Renderer>) => void | ListrTaskResult<Ctx>;
/**
* 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>;
}
/**
* Options to set the behavior of this base task.
*/
interface ListrOptions<Ctx = ListrContext> {
/**
* To inject a context through this options wrapper. Context can also be defined in run time.
*
* @default {}
*/
ctx?: Ctx;
/**
* Concurrency sets how many tasks will be run at the same time in parallel.
*
* @default false > Default is to run everything synchronously.
*
* `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.
*/
concurrent?: boolean | number;
/**
* Determine the default behavior of exiting on errors.
*
* @default true > exit on any error coming from the tasks.
*/
exitOnError?: boolean;
/**
* Determine the behavior of exiting after rollback actions.
*
* 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
*/
exitAfterRollback?: boolean;
/**
* Collects errors to `ListrInstance.errors`
*
* This can take up a lot of memory, so disabling it can fix out-of-memory errors
*
* - '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 'minimal'
*/
collectErrors?: false | 'minimal' | 'full';
/**
* By default, Listr2 will track SIGINIT signal to update the renderer one last time before completely failing.
*
* @default true
*/
registerSignalListeners?: boolean;
/**
* Determine the certain condition required to use the non-TTY renderer.
*
* @default null > handled internally
*/
rendererFallback?: boolean | (() => boolean);
/**
* Determine the certain condition required to use the silent renderer.
*
* @default null > handled internally
*/
rendererSilent?: boolean | (() => boolean);
/**
* Disabling the color, useful for tests and such.
*
* @default false
*/
disableColor?: boolean;
/**
* Inject data directly to TaskWrapper.
*/
injectWrapper?: {
enquirer?: Enquirer<object>;
};
}
/**
* Task can be set of sync or async function, an Observable or a stream.
*/
declare type ListrTaskResult<Ctx> = string | Promise<any> | Listr<Ctx, ListrRendererValue, any> | Readable | NodeJS.ReadableStream | Observable<any>;
/**
* Parent class options.
*
* 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.
*/
declare type ListrBaseClassOptions<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue, FallbackRenderer extends ListrRendererValue = ListrFallbackRendererValue> = ListrOptions<Ctx> & ListrDefaultRendererOptions<Renderer> & ListrDefaultNonTTYRendererOptions<FallbackRenderer>;
/**
* Sub class options.
*
* Subtasks has reduced set options where the missing ones are explicitly set by the base class.
*/
declare type ListrSubClassOptions<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue> = ListrOptions<Ctx> & Omit<ListrDefaultRendererOptions<Renderer>, 'renderer'>;
/** The internal communication event. */
declare type ListrEvent = {
type: Exclude<ListrEventType, 'MESSAGE' | 'DATA'>;
data?: string | boolean;
} | {
type: ListrEventType.DATA;
data: string;
} | {
type: ListrEventType.MESSAGE;
data: Task<any, any>['message'];
};
/**
* Used to match event.type to ListrEvent permutations
*/
declare type ListrEventFromType<T extends ListrEventType, E = ListrEvent> = E extends {
type: infer U;
} ? T extends U ? E : never : never;
/** The internal error handling mechanism.. */
declare class ListrError<Ctx extends Record<PropertyKey, any> = Record<PropertyKey, any>> extends Error {
declare class ListrError<Ctx extends ListrContext = ListrContext> extends Error {
error: Error;

@@ -890,3 +890,3 @@ type: ListrErrorTypes;

*/
declare class Listr<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue, FallbackRenderer extends ListrRendererValue = ListrFallbackRendererValue> {
declare class Listr<Ctx extends ListrContext = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue, FallbackRenderer extends ListrRendererValue = ListrFallbackRendererValue> {
task: ListrTask<Ctx, ListrGetRendererClassFromValue<Renderer>> | ListrTask<Ctx, ListrGetRendererClassFromValue<Renderer>>[];

@@ -914,3 +914,3 @@ options?: ListrBaseClassOptions<Ctx, Renderer, FallbackRenderer>;

*
* Useful for creating a single instace of Listr2 with pre-set settings.
* Useful for creating a single instance of Listr2 with pre-set settings.
*/

@@ -917,0 +917,0 @@ declare class Manager<Ctx = ListrContext, Renderer extends ListrRendererValue = 'default', FallbackRenderer extends ListrRendererValue = 'verbose'> {

{
"name": "listr2",
"version": "5.0.3",
"version": "5.0.4",
"description": "Terminal task list reborn! Create beautiful CLI interfaces via easy and logical to implement task lists that feel alive and interactive.",

@@ -83,6 +83,6 @@ "license": "MIT",

"@cenk1cenk2/cz-cc": "^1.5.3",
"@cenk1cenk2/eslint-config": "2.5.21",
"@cenk1cenk2/eslint-config": "2.5.26",
"@types/clone": "^2.1.1",
"@types/jest": "^28.1.6",
"@types/node": "^18.6.1",
"@types/jest": "^29.0.0",
"@types/node": "^18.7.15",
"@types/through": "^0.0.30",

@@ -92,4 +92,4 @@ "@types/wrap-ansi": "^3.0.0",

"enquirer": "^2.3.6",
"eslint": "^8.21.0",
"jest": "^28.1.3",
"eslint": "^8.23.0",
"jest": "^29.0.2",
"jest-mock-process": "^2.0.0",

@@ -100,9 +100,9 @@ "lint-staged": "^13.0.3",

"simple-git-hooks": "^2.8.0",
"ts-jest": "^28.0.7",
"ts-jest": "^28.0.8",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.0.0",
"tsup": "6.2.1",
"typedoc": "^0.23.10",
"typedoc-plugin-markdown": "^3.13.4",
"typescript": "^4.7.4"
"tsconfig-paths": "^4.1.0",
"tsup": "6.2.3",
"typedoc": "^0.23.14",
"typedoc-plugin-markdown": "^3.13.6",
"typescript": "^4.8.2"
},

@@ -109,0 +109,0 @@ "peerDependencies": {

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