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 4.0.5 to 5.0.0

336

dist/index.js

@@ -1,44 +0,1 @@

var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined")
return require.apply(this, arguments);
throw new Error('Dynamic require of "' + x + '" is not supported');
});
var __reExport = (target, module, copyDefault, desc) => {
if (module && typeof module === "object" || typeof module === "function") {
for (let key of __getOwnPropNames(module))
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
__defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
}
return target;
};
var __toESM = (module, isNodeMode) => {
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", !isNodeMode && module && module.__esModule ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
};
// src/listr.ts

@@ -89,10 +46,9 @@ import pMap from "p-map";

this.task = task;
var _a2;
this.name = "ListrError";
this.path = [...(_a2 = task.listr.path) != null ? _a2 : [], task.title].join(" > ");
if ((task == null ? void 0 : task.options.collectErrors) === "full") {
this.path = [...task.listr.path ?? [], task.title].join(" > ");
if (task?.options.collectErrors === "full") {
this.task = cloneObject(task);
this.ctx = cloneObject(task.listr.ctx);
}
this.stack = error == null ? void 0 : error.stack;
this.stack = error?.stack;
}

@@ -132,4 +88,3 @@ };

import { createColors } from "colorette";
var _a;
var colorette_default = createColors({ useColor: ((_a = process.env) == null ? void 0 : _a.LISTR_DISABLE_COLOR) !== "1" });
var colorette_default = createColors({ useColor: process.env?.LISTR_DISABLE_COLOR !== "1" });

@@ -157,3 +112,4 @@ // src/utils/is-unicode-supported.ts

};
var FIGURES_FALLBACK = __spreadProps(__spreadValues({}, FIGURES_MAIN), {
var FIGURES_FALLBACK = {
...FIGURES_MAIN,
warning: "\u203C",

@@ -165,3 +121,3 @@ cross: "\xD7",

squareSmallFilled: "\u25A0"
});
};
var figures = isUnicodeSupported() ? FIGURES_MAIN : FIGURES_FALLBACK;

@@ -200,6 +156,6 @@

this.spinnerPosition = 0;
this.options = __spreadValues(__spreadValues({}, _DefaultRenderer.rendererOptions), this.options);
this.options = { ..._DefaultRenderer.rendererOptions, ...this.options };
}
getTaskOptions(task) {
return __spreadValues(__spreadValues({}, _DefaultRenderer.rendererTaskOptions), task.rendererTaskOptions);
return { ..._DefaultRenderer.rendererTaskOptions, ...task.rendererTaskOptions };
}

@@ -217,4 +173,3 @@ isBottomBar(task) {

getSelfOrParentOption(task, key) {
var _a2, _b, _c;
return (_c = (_a2 = task == null ? void 0 : task.rendererOptions) == null ? void 0 : _a2[key]) != null ? _c : (_b = this.options) == null ? void 0 : _b[key];
return task?.rendererOptions?.[key] ?? this.options?.[key];
}

@@ -225,7 +180,10 @@ getTaskTime(task) {

createRender(options) {
options = __spreadValues(__spreadValues({}, {
tasks: true,
bottomBar: true,
prompt: true
}), options);
options = {
...{
tasks: true,
bottomBar: true,
prompt: true
},
...options
};
const render = [];

@@ -235,9 +193,9 @@ const renderTasks = this.multiLineRenderer(this.tasks);

const renderPrompt = this.renderPrompt();
if (options.tasks && (renderTasks == null ? void 0 : renderTasks.trim().length) > 0) {
if (options.tasks && renderTasks?.trim().length > 0) {
render.push(renderTasks);
}
if (options.bottomBar && (renderBottomBar == null ? void 0 : renderBottomBar.trim().length) > 0) {
if (options.bottomBar && renderBottomBar?.trim().length > 0) {
render.push((render.length > 0 ? EOL : "") + renderBottomBar);
}
if (options.prompt && (renderPrompt == null ? void 0 : renderPrompt.trim().length) > 0) {
if (options.prompt && renderPrompt?.trim().length > 0) {
render.push((render.length > 0 ? EOL : "") + renderPrompt);

@@ -248,3 +206,2 @@ }

render() {
var _a2;
if (this.id) {

@@ -254,3 +211,3 @@ return;

const updateRender = () => logUpdate(this.createRender());
if (!((_a2 = this.options) == null ? void 0 : _a2.lazy)) {
if (!this.options?.lazy) {
this.id = setInterval(() => {

@@ -277,3 +234,2 @@ this.spinnerPosition = ++this.spinnerPosition % this.spinner.length;

multiLineRenderer(tasks, level = 0) {
var _a2, _b;
let output = [];

@@ -287,3 +243,7 @@ for (const task of tasks) {

...output,
this.formatString(!task.hasSubtasks() && task.message.error && this.getSelfOrParentOption(task, "showErrorMessage") ? task.message.error : task.title, this.getSymbol(task), level)
this.formatString(
!task.hasSubtasks() && task.message.error && this.getSelfOrParentOption(task, "showErrorMessage") ? task.message.error : task.title,
this.getSymbol(task),
level
)
];

@@ -293,3 +253,11 @@ } else if (task.isSkipped() && this.getSelfOrParentOption(task, "collapseSkips")) {

...output,
this.formatString(this.addSuffixToMessage(task.message.skip && this.getSelfOrParentOption(task, "showSkipMessage") ? task.message.skip : task.title, "SKIPPED", this.getSelfOrParentOption(task, "suffixSkips")), this.getSymbol(task), level)
this.formatString(
this.addSuffixToMessage(
task.message.skip && this.getSelfOrParentOption(task, "showSkipMessage") ? task.message.skip : task.title,
"SKIPPED",
this.getSelfOrParentOption(task, "suffixSkips")
),
this.getSymbol(task),
level
)
];

@@ -299,3 +267,3 @@ } else if (task.isRetrying() && this.getSelfOrParentOption(task, "suffixRetries")) {

} else if (task.isCompleted() && task.hasTitle() && (this.getSelfOrParentOption(task, "showTimer") || this.hasTimer(task))) {
output = [...output, this.formatString(`${task == null ? void 0 : task.title} ${this.getTaskTime(task)}`, this.getSymbol(task), level)];
output = [...output, this.formatString(`${task?.title} ${this.getTaskTime(task)}`, this.getSymbol(task), level)];
} else {

@@ -315,3 +283,3 @@ output = [...output, this.formatString(task.title, this.getSymbol(task), level)];

}
if (task == null ? void 0 : task.output) {
if (task?.output) {
if ((task.isPending() || task.isRetrying() || task.isRollingBack()) && task.isPrompt()) {

@@ -331,3 +299,3 @@ this.promptBar = task.output;

}
if (!((_b = (_a2 = this.bottomBar[task.id]) == null ? void 0 : _a2.data) == null ? void 0 : _b.some((element) => data.includes(element))) && !task.isSkipped()) {
if (!this.bottomBar[task.id]?.data?.some((element) => data.includes(element)) && !task.isSkipped()) {
this.bottomBar[task.id].data = [...this.bottomBar[task.id].data, ...data];

@@ -342,3 +310,3 @@ }

const subtaskRender = this.multiLineRenderer(task.subtasks, subtaskLevel);
if ((subtaskRender == null ? void 0 : subtaskRender.trim()) !== "" && !task.subtasks.every((subtask) => !subtask.hasTitle())) {
if (subtaskRender?.trim() !== "" && !task.subtasks.every((subtask) => !subtask.hasTitle())) {
output = [...output, subtaskRender];

@@ -365,3 +333,3 @@ }

this.bottomBar = Object.keys(this.bottomBar).reduce((o, key) => {
if (!(o == null ? void 0 : o[key])) {
if (!o?.[key]) {
o[key] = {};

@@ -431,11 +399,10 @@ }

getSymbol(task, data = false) {
var _a2, _b, _c;
if (task.isPending() && !data) {
return ((_a2 = this.options) == null ? void 0 : _a2.lazy) || this.getSelfOrParentOption(task, "showSubtasks") !== false && task.hasSubtasks() && !task.subtasks.every((subtask) => !subtask.hasTitle()) ? colorette_default.yellow(figures.pointer) : colorette_default.yellowBright(this.spinner[this.spinnerPosition]);
return this.options?.lazy || this.getSelfOrParentOption(task, "showSubtasks") !== false && task.hasSubtasks() && !task.subtasks.every((subtask) => !subtask.hasTitle()) ? colorette_default.yellow(figures.pointer) : colorette_default.yellowBright(this.spinner[this.spinnerPosition]);
} else if (task.isCompleted() && !data) {
return task.hasSubtasks() && task.subtasks.some((subtask) => subtask.hasFailed()) ? colorette_default.yellow(figures.warning) : colorette_default.green(figures.tick);
} else if (task.isRetrying() && !data) {
return ((_b = this.options) == null ? void 0 : _b.lazy) ? colorette_default.yellow(figures.warning) : colorette_default.yellow(this.spinner[this.spinnerPosition]);
return this.options?.lazy ? colorette_default.yellow(figures.warning) : colorette_default.yellow(this.spinner[this.spinnerPosition]);
} else if (task.isRollingBack() && !data) {
return ((_c = this.options) == null ? void 0 : _c.lazy) ? colorette_default.red(figures.warning) : colorette_default.red(this.spinner[this.spinnerPosition]);
return this.options?.lazy ? colorette_default.red(figures.warning) : colorette_default.red(this.spinner[this.spinnerPosition]);
} else if (task.hasRolledBack() && !data) {

@@ -453,3 +420,3 @@ return colorette_default.red(figures.arrowLeft);

addSuffixToMessage(message, suffix, condition) {
return (condition != null ? condition : true) ? message + colorette_default.dim(` [${suffix}]`) : message;
return condition ?? true ? message + colorette_default.dim(` [${suffix}]`) : message;
}

@@ -534,3 +501,3 @@ };

};
this.options = __spreadValues(__spreadValues({}, _SimpleRenderer.rendererOptions), options);
this.options = { ..._SimpleRenderer.rendererOptions, ...options };
}

@@ -541,3 +508,3 @@ static now() {

static formatTitle(task) {
return (task == null ? void 0 : task.title) ? ` ${task.title}` : "";
return task?.title ? ` ${task.title}` : "";
}

@@ -559,7 +526,6 @@ log(output) {

render(tasks) {
if (tasks == null ? void 0 : tasks.length) {
if (tasks?.length) {
tasks.forEach((task) => {
task.subscribe((event) => {
var _a2, _b;
(_b = (_a2 = this.eventTypeRendererMap)[event.type]) == null ? void 0 : _b.call(_a2, task, event);
this.eventTypeRendererMap[event.type]?.(task, event);
}, this.log);

@@ -644,3 +610,2 @@ });

logColoring({ level, message }) {
var _a2, _b, _c, _d, _e, _f, _g, _h;
let icon;

@@ -652,3 +617,3 @@ let coloring = (input) => {

case "FAILED" /* FAILED */:
if ((_a2 = this.options) == null ? void 0 : _a2.useIcons) {
if (this.options?.useIcons) {
coloring = colorette_default.red;

@@ -661,3 +626,3 @@ icon = figures.cross;

case "SKIPPED" /* SKIPPED */:
if ((_b = this.options) == null ? void 0 : _b.useIcons) {
if (this.options?.useIcons) {
coloring = colorette_default.yellow;

@@ -670,3 +635,3 @@ icon = figures.arrowDown;

case "SUCCESS" /* SUCCESS */:
if ((_c = this.options) == null ? void 0 : _c.useIcons) {
if (this.options?.useIcons) {
coloring = colorette_default.green;

@@ -679,3 +644,3 @@ icon = figures.tick;

case "DATA" /* DATA */:
if ((_d = this.options) == null ? void 0 : _d.useIcons) {
if (this.options?.useIcons) {
icon = figures.arrowRight;

@@ -687,3 +652,3 @@ } else {

case "STARTED" /* STARTED */:
if ((_e = this.options) == null ? void 0 : _e.useIcons) {
if (this.options?.useIcons) {
icon = figures.pointer;

@@ -695,3 +660,3 @@ } else {

case "TITLE" /* TITLE */:
if ((_f = this.options) == null ? void 0 : _f.useIcons) {
if (this.options?.useIcons) {
icon = figures.checkboxOn;

@@ -703,3 +668,3 @@ } else {

case "RETRY" /* RETRY */:
if ((_g = this.options) == null ? void 0 : _g.useIcons) {
if (this.options?.useIcons) {
coloring = colorette_default.yellow;

@@ -712,3 +677,3 @@ icon = figures.pointer;

case "ROLLBACK" /* ROLLBACK */:
if ((_h = this.options) == null ? void 0 : _h.useIcons) {
if (this.options?.useIcons) {
coloring = colorette_default.red;

@@ -733,11 +698,10 @@ icon = figures.arrowLeft;

this.options = options;
var _a2, _b, _c, _d;
if (((_a2 = this.options) == null ? void 0 : _a2.logger) && ((_b = this.options) == null ? void 0 : _b.options)) {
if (this.options?.logger && this.options?.options) {
this.logger = new this.options.logger(this.options.options);
} else if ((_c = this.options) == null ? void 0 : _c.logger) {
} else if (this.options?.logger) {
this.logger = new this.options.logger();
} else {
this.logger = new Logger({ useIcons: (_d = this.options) == null ? void 0 : _d.useIcons });
this.logger = new Logger({ useIcons: this.options?.useIcons });
}
this.options = __spreadValues(__spreadValues({}, _VerboseRenderer.rendererOptions), this.options);
this.options = { ..._VerboseRenderer.rendererOptions, ...this.options };
}

@@ -750,38 +714,40 @@ render() {

verboseRenderer(tasks) {
return tasks == null ? void 0 : tasks.forEach((task) => {
task.subscribe((event) => {
var _a2, _b, _c, _d, _e, _f, _g, _h;
if (task.isEnabled()) {
const taskTitle = task.hasTitle() ? task.title : "Task without title.";
if (event.type === "SUBTASK" /* SUBTASK */ && task.hasSubtasks()) {
this.verboseRenderer(task.subtasks);
} else if (event.type === "STATE" /* STATE */) {
if (((_a2 = this.options) == null ? void 0 : _a2.logEmptyTitle) !== false || task.hasTitle()) {
if (task.isPending()) {
this.logger.start(taskTitle);
} else if (task.isCompleted()) {
this.logger.success(taskTitle + (((_b = this.options) == null ? void 0 : _b.showTimer) && ((_c = task.message) == null ? void 0 : _c.duration) ? ` [${parseTaskTime(task.message.duration)}]` : ""));
return tasks?.forEach((task) => {
task.subscribe(
(event) => {
if (task.isEnabled()) {
const taskTitle = task.hasTitle() ? task.title : "Task without title.";
if (event.type === "SUBTASK" /* SUBTASK */ && task.hasSubtasks()) {
this.verboseRenderer(task.subtasks);
} else if (event.type === "STATE" /* STATE */) {
if (this.options?.logEmptyTitle !== false || task.hasTitle()) {
if (task.isPending()) {
this.logger.start(taskTitle);
} else if (task.isCompleted()) {
this.logger.success(taskTitle + (this.options?.showTimer && task.message?.duration ? ` [${parseTaskTime(task.message.duration)}]` : ""));
}
}
} else if (event.type === "DATA" /* DATA */ && !!event.data) {
this.logger.data(String(event.data));
} else if (event.type === "TITLE" /* TITLE */) {
if (this.options?.logTitleChange !== false) {
this.logger.title(String(event.data));
}
} else if (event.type === "MESSAGE" /* MESSAGE */) {
if (event.data?.error) {
this.logger.fail(String(event.data.error));
} else if (event.data?.skip) {
this.logger.skip(String(event.data.skip));
} else if (event.data?.rollback) {
this.logger.rollback(String(event.data.rollback));
} else if (event.data?.retry) {
this.logger.retry(`[${event.data.retry.count}] ` + String(taskTitle));
}
}
} else if (event.type === "DATA" /* DATA */ && !!event.data) {
this.logger.data(String(event.data));
} else if (event.type === "TITLE" /* TITLE */) {
if (((_d = this.options) == null ? void 0 : _d.logTitleChange) !== false) {
this.logger.title(String(event.data));
}
} else if (event.type === "MESSAGE" /* MESSAGE */) {
if ((_e = event.data) == null ? void 0 : _e.error) {
this.logger.fail(String(event.data.error));
} else if ((_f = event.data) == null ? void 0 : _f.skip) {
this.logger.skip(String(event.data.skip));
} else if ((_g = event.data) == null ? void 0 : _g.rollback) {
this.logger.rollback(String(event.data.rollback));
} else if ((_h = event.data) == null ? void 0 : _h.retry) {
this.logger.retry(`[${event.data.retry.count}] ` + String(taskTitle));
}
}
},
(err) => {
this.logger.fail(err);
}
}, (err) => {
this.logger.fail(err);
});
);
});

@@ -848,9 +814,8 @@ }

this.message = {};
var _a2, _b, _c, _d, _e, _f;
this.id = generateUUID();
this.title = (_a2 = this.tasks) == null ? void 0 : _a2.title;
this.initialTitle = (_b = this.tasks) == null ? void 0 : _b.title;
this.title = this.tasks?.title;
this.initialTitle = this.tasks?.title;
this.task = this.tasks.task;
this.skip = (_d = (_c = this.tasks) == null ? void 0 : _c.skip) != null ? _d : false;
this.enabledFn = (_f = (_e = this.tasks) == null ? void 0 : _e.enabled) != null ? _f : true;
this.skip = this.tasks?.skip ?? false;
this.enabledFn = this.tasks?.enabled ?? true;
this.rendererTaskOptions = this.tasks.options;

@@ -884,3 +849,3 @@ this.renderHook$ = this.listr.renderHook$;

set message$(data) {
this.message = __spreadValues(__spreadValues({}, this.message), data);
this.message = { ...this.message, ...data };
this.next({

@@ -908,4 +873,3 @@ type: "MESSAGE" /* MESSAGE */,

hasSubtasks() {
var _a2;
return ((_a2 = this.subtasks) == null ? void 0 : _a2.length) > 0;
return this.subtasks?.length > 0;
}

@@ -937,3 +901,3 @@ isPending() {

hasTitle() {
return typeof (this == null ? void 0 : this.title) === "string";
return typeof this?.title === "string";
}

@@ -944,6 +908,5 @@ isPrompt() {

async run(context, wrapper) {
var _a2, _b, _c, _d, _e;
const handleResult = (result) => {
if (result instanceof Listr) {
result.options = __spreadValues(__spreadValues({}, this.options), result.options);
result.options = { ...this.options, ...result.options };
result.rendererClass = getRenderer("silent").renderer;

@@ -996,3 +959,3 @@ result.renderHook$.subscribe(() => {

try {
const retryCount = ((_a2 = this.tasks) == null ? void 0 : _a2.retry) && ((_b = this.tasks) == null ? void 0 : _b.retry) > 0 ? this.tasks.retry + 1 : 1;
const retryCount = this.tasks?.retry && this.tasks?.retry > 0 ? this.tasks.retry + 1 : 1;
for (let retries = 1; retries <= retryCount; retries++) {

@@ -1023,3 +986,3 @@ try {

}
if ((_c = this.tasks) == null ? void 0 : _c.rollback) {
if (this.tasks?.rollback) {
wrapper.report(error, "WILL_ROLLBACK" /* WILL_ROLLBACK */);

@@ -1036,3 +999,3 @@ try {

}
if (((_d = this.listr.options) == null ? void 0 : _d.exitAfterRollback) !== false) {
if (this.listr.options?.exitAfterRollback !== false) {
throw new Error(this.title);

@@ -1042,3 +1005,3 @@ }

this.state$ = "FAILED" /* FAILED */;
if (this.listr.options.exitOnError !== false && await assertFunctionOrSelf((_e = this.tasks) == null ? void 0 : _e.exitOnError, context) !== false) {
if (this.listr.options.exitOnError !== false && await assertFunctionOrSelf(this.tasks?.exitOnError, context) !== false) {
wrapper.report(error, "HAS_FAILED" /* HAS_FAILED */);

@@ -1068,3 +1031,3 @@ throw error;

this.task.prompt = new PromptError(errorMsg);
} else if ((settings == null ? void 0 : settings.error) !== false) {
} else if (settings?.error !== false) {
throw new Error(errorMsg);

@@ -1077,3 +1040,3 @@ } else {

let cancelCallback;
if (settings == null ? void 0 : settings.cancelCallback) {
if (settings?.cancelCallback) {
cancelCallback = settings.cancelCallback;

@@ -1084,3 +1047,3 @@ } else {

if (!Array.isArray(options)) {
options = [__spreadProps(__spreadValues({}, options), { name: "default" })];
options = [{ ...options, name: "default" }];
} else if (options.length === 1) {

@@ -1092,7 +1055,6 @@ options = options.reduce((o, option) => {

options = options.reduce((o, option) => {
var _a2;
return [
...o,
Object.assign(option, {
stdout: this instanceof TaskWrapper ? (_a2 = settings == null ? void 0 : settings.stdout) != null ? _a2 : this.stdout() : process.stdout,
stdout: this instanceof TaskWrapper ? settings?.stdout ?? this.stdout() : process.stdout,
onCancel: cancelCallback.bind(this, settings)

@@ -1103,7 +1065,7 @@ })

let enquirer;
if (settings == null ? void 0 : settings.enquirer) {
if (settings?.enquirer) {
enquirer = settings.enquirer;
} else {
try {
enquirer = new (await Promise.resolve().then(() => __toESM(__require("enquirer"), 1))).default();
enquirer = new (await import("enquirer")).default();
} catch (e) {

@@ -1172,13 +1134,11 @@ this.task.prompt = new PromptError("Enquirer is a peer dependency that must be installed separately.");

report(error, type) {
var _a2, _b, _c;
if (this.task.options.collectErrors !== false) {
this.errors.push(new ListrError(error, type, this.task));
}
this.task.message$ = { error: (_c = (_b = error.message) != null ? _b : (_a2 = this.task) == null ? void 0 : _a2.title) != null ? _c : "Task with no title." };
this.task.message$ = { error: error.message ?? this.task?.title ?? "Task with no title." };
}
skip(message) {
var _a2, _b;
this.task.state$ = "SKIPPED" /* SKIPPED */;
if (message) {
this.task.message$ = { skip: (_b = message != null ? message : (_a2 = this.task) == null ? void 0 : _a2.title) != null ? _b : "Task with no title." };
this.task.message$ = { skip: message ?? this.task?.title ?? "Task with no title." };
}

@@ -1190,4 +1150,3 @@ }

async prompt(options) {
var _a2;
return createPrompt.bind(this)(options, __spreadValues({}, (_a2 = this.options) == null ? void 0 : _a2.injectWrapper));
return createPrompt.bind(this)(options, { ...this.options?.injectWrapper });
}

@@ -1222,12 +1181,14 @@ cancelPrompt(throwError = false) {

this.path = [];
var _a2, _b, _c;
this.options = __spreadValues(__spreadValues({}, {
concurrent: false,
renderer: "default",
nonTTYRenderer: "verbose",
exitOnError: true,
exitAfterRollback: true,
collectErrors: "minimal",
registerSignalListeners: true
}), options);
this.options = {
...{
concurrent: false,
renderer: "default",
nonTTYRenderer: "verbose",
exitOnError: true,
exitAfterRollback: true,
collectErrors: "minimal",
registerSignalListeners: true
},
...options
};
if (this.options.concurrent === true) {

@@ -1240,3 +1201,3 @@ this.concurrency = Infinity;

}
const renderer = getRenderer(this.options.renderer, this.options.nonTTYRenderer, (_a2 = this.options) == null ? void 0 : _a2.rendererFallback, (_b = this.options) == null ? void 0 : _b.rendererSilent);
const renderer = getRenderer(this.options.renderer, this.options.nonTTYRenderer, this.options?.rendererFallback, this.options?.rendererSilent);
this.rendererClass = renderer.renderer;

@@ -1248,3 +1209,3 @@ if (!renderer.nonTTY) {

}
this.add(task != null ? task : []);
this.add(task ?? []);
if (parentTask) {

@@ -1264,3 +1225,3 @@ this.path = [...parentTask.listr.path, parentTask.title];

}
if ((_c = this.options) == null ? void 0 : _c.disableColor) {
if (this.options?.disableColor) {
process.env.LISTR_DISABLE_COLOR = "1";

@@ -1272,7 +1233,6 @@ }

tasks.forEach((task2) => {
this.tasks.push(new Task(this, task2, this.options, __spreadValues(__spreadValues({}, this.rendererClassOptions), task2.options)));
this.tasks.push(new Task(this, task2, this.options, { ...this.rendererClassOptions, ...task2.options }));
});
}
async run(context) {
var _a2, _b, _c;
if (!this.renderer) {

@@ -1282,9 +1242,13 @@ this.renderer = new this.rendererClass(this.tasks, this.rendererClassOptions, this.renderHook$);

this.renderer.render();
this.ctx = (_c = (_b = (_a2 = this.options) == null ? void 0 : _a2.ctx) != null ? _b : context) != null ? _c : {};
this.ctx = this.options?.ctx ?? context ?? {};
await this.checkAll(this.ctx);
try {
await pMap(this.tasks, async (task) => {
await task.check(this.ctx);
return this.runTask(task, this.ctx, this.err);
}, { concurrency: this.concurrency });
await pMap(
this.tasks,
async (task) => {
await task.check(this.ctx);
return this.runTask(task, this.ctx, this.err);
},
{ concurrency: this.concurrency }
);
this.renderer.end();

@@ -1321,7 +1285,7 @@ } catch (err) {

add(tasks, options) {
options = __spreadValues(__spreadValues({}, this.options), options);
options = { ...this.options, ...options };
this.tasks = [...this.tasks, this.indent(tasks, options)];
}
async runAll(options) {
options = __spreadValues(__spreadValues({}, this.options), options);
options = { ...this.options, ...options };
const ctx = await this.run(this.tasks, options);

@@ -1335,12 +1299,14 @@ this.tasks = [];

indent(tasks, options, taskOptions) {
options = __spreadValues(__spreadValues({}, this.options), options);
options = { ...this.options, ...options };
let newTask;
if (typeof tasks === "function") {
newTask = __spreadProps(__spreadValues({}, taskOptions), {
newTask = {
...taskOptions,
task: (ctx) => this.newListr(tasks(ctx), options)
});
};
} else {
newTask = __spreadProps(__spreadValues({}, taskOptions), {
newTask = {
...taskOptions,
task: () => this.newListr(tasks, options)
});
};
}

@@ -1350,3 +1316,3 @@ return newTask;

async run(tasks, options) {
options = __spreadValues(__spreadValues({}, this.options), options);
options = { ...this.options, ...options };
const task = this.newListr(tasks, options);

@@ -1353,0 +1319,0 @@ const ctx = await task.run();

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

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

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

@@ -38,3 +38,3 @@ "scripts": {

"dev:test": "TS_NODE_PROJECT=tests/tsconfig.json node --inspect=0.0.0.0:${DEBUG_PORT:-9229} -r tsconfig-paths/register -r ts-node/register node_modules/jest/bin/jest.js --verbose --watchAll --config ./tests/jest.config.cjs",
"docs": "typedoc --options .typedoc.json --hideInPageTOC --hideBreadcrumbs"
"docs:api": "typedoc --options .typedoc.json --hideInPageTOC --hideBreadcrumbs"
},

@@ -75,7 +75,7 @@ "simple-git-hooks": {

"cli-truncate": "^2.1.0",
"colorette": "^2.0.16",
"colorette": "^2.0.19",
"log-update": "^4.0.0",
"p-map": "^4.0.0",
"rfdc": "^1.3.0",
"rxjs": "^7.5.5",
"rxjs": "^7.5.6",
"through": "^2.3.8",

@@ -85,7 +85,7 @@ "wrap-ansi": "^7.0.0"

"devDependencies": {
"@cenk1cenk2/cz-cc": "^1.4.11",
"@cenk1cenk2/eslint-config": "2.5.5",
"@cenk1cenk2/cz-cc": "^1.5.3",
"@cenk1cenk2/eslint-config": "2.5.21",
"@types/clone": "^2.1.1",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.14",
"@types/jest": "^28.1.6",
"@types/node": "^18.6.1",
"@types/through": "^0.0.30",

@@ -95,16 +95,16 @@ "@types/wrap-ansi": "^3.0.0",

"enquirer": "^2.3.6",
"eslint": "^8.8.0",
"jest": "^27.4.7",
"jest-mock-process": "^1.4.1",
"lint-staged": "^12.3.2",
"prettier": "^2.5.1",
"eslint": "^8.20.0",
"jest": "^28.1.3",
"jest-mock-process": "^2.0.0",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"simple-git-hooks": "^2.7.0",
"ts-jest": "^27.1.3",
"ts-node": "^10.4.0",
"tsconfig-paths": "^3.12.0",
"tsup": "5.11.13",
"typedoc": "^0.22.11",
"typedoc-plugin-markdown": "^3.11.12",
"typescript": "^4.6.0-dev.20220131"
"simple-git-hooks": "^2.8.0",
"ts-jest": "^28.0.7",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.0.0",
"tsup": "6.2.0",
"typedoc": "^0.23.9",
"typedoc-plugin-markdown": "^3.13.4",
"typescript": "^4.7.4"
},

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

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