initial status

This commit is contained in:
Simon Priet
2021-09-05 12:34:08 +02:00
commit a041f9f575
9441 changed files with 627158 additions and 0 deletions

152
node_modules/listr2/dist/renderer/default.renderer.d.ts generated vendored Normal file
View File

@@ -0,0 +1,152 @@
import { ListrRenderer } from '../interfaces/renderer.interface';
import { Task } from '../lib/task';
/** Default updating renderer for Listr2 */
export declare class DefaultRenderer implements ListrRenderer {
tasks: Task<any, typeof DefaultRenderer>[];
options: typeof DefaultRenderer['rendererOptions'];
renderHook$?: Task<any, any>['renderHook$'];
/** designates whether this renderer can output to a non-tty console */
static nonTTY: boolean;
/** renderer options for the defauult renderer */
static rendererOptions: {
/**
* indentation per level of subtask
* @default 2
*/
indentation?: number;
/**
* clear output when task finishes
* @default false
* @global global option that can not be temperated with from subtasks
*/
clearOutput?: boolean;
/**
* show the subtasks of the current task if it returns a new listr
* @default true
* @global global option that can not be temperated with from subtasks
*/
showSubtasks?: boolean;
/**
* collapse subtasks after finish
* @default true
*/
collapse?: boolean;
/**
* collapse skip messages in to single message and override the task title
* @default true
*/
collapseSkips?: boolean;
/**
* show skip messages or show the original title of the task, this will also disable collapseSkips mode
*
* You can disable showing the skip messages, eventhough you passed in a message by settings this option,
* if you want to keep the original task title intacted.
* @default true
*/
showSkipMessage?: boolean;
/**
* suffix skip messages with [SKIPPED] when in collapseSkips mode
* @default true
*/
suffixSkips?: boolean;
/**
* collapse error messages in to single message in task title
* @default true
*/
collapseErrors?: 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, eventhough you passed in a message by settings this option,
* if you want to keep the original task title intacted.
* @default true
*/
showErrorMessage?: boolean;
/**
* suffix retry messages with [RETRY-${COUNT}] when retry is enabled for a task
* @default true
*/
suffixRetries?: boolean;
/**
* only update via renderhook
*
* useful for tests and stuff. this will disable showing spinner and only update the screen if the something else has
* happened in the task worthy to show
* @default false
* @global global option that can not be temperated with from subtasks
*/
lazy?: boolean;
/**
* show duration for all tasks
*
* overwrites per task renderer options
* @default false
* @global global option that can not be temperated with from subtasks
*/
showTimer?: boolean;
/**
* removes empty lines from the data output
*
* @default true
*/
removeEmptyLines?: boolean;
/**
* formats data output depending on your requirements.
* log-update mostly breaks if there is no wrap, so there is many options to choose your preference
*
* @default 'truncate'
* @global global option that can not be temperated with from subtasks
*/
formatOutput?: 'truncate' | 'wrap';
};
/** per task options for the default renderer */
static rendererTaskOptions: {
/**
* write task output to bottom bar instead of the gap under the task title itself.
* useful for stream of data.
* @default false
*
* `true` only keep 1 line of latest data outputted by the task.
* `false` only keep 1 line of latest data outputted by the task.
* `number` will keep designated data of latest data outputted by the task.
*/
bottomBar?: boolean | number;
/**
* keep output after task finishes
* @default false
*
* works both for bottom bar and the default behavior
*/
persistentOutput?: boolean;
/**
* show the task time if it was successful
*/
showTimer?: boolean;
};
private id?;
private bottomBar;
private promptBar;
private readonly spinner;
private spinnerPosition;
constructor(tasks: Task<any, typeof DefaultRenderer>[], options: typeof DefaultRenderer['rendererOptions'], renderHook$?: Task<any, any>['renderHook$']);
getTaskOptions(task: Task<any, typeof DefaultRenderer>): typeof DefaultRenderer['rendererTaskOptions'];
isBottomBar(task: Task<any, typeof DefaultRenderer>): boolean;
hasPersistentOutput(task: Task<any, typeof DefaultRenderer>): boolean;
hasTimer(task: Task<any, typeof DefaultRenderer>): boolean;
getSelfOrParentOption<T extends keyof typeof DefaultRenderer['rendererOptions']>(task: Task<any, typeof DefaultRenderer>, key: T): typeof DefaultRenderer['rendererOptions'][T];
getTaskTime(task: Task<any, typeof DefaultRenderer>): string;
createRender(options?: {
tasks?: boolean;
bottomBar?: boolean;
prompt?: boolean;
}): string;
render(): void;
end(): void;
private multiLineRenderer;
private renderBottomBar;
private renderPrompt;
private dumpData;
private formatString;
private indentMultilineOutput;
private getSymbol;
private addSuffixToMessage;
}

363
node_modules/listr2/dist/renderer/default.renderer.js generated vendored Normal file
View File

@@ -0,0 +1,363 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultRenderer = void 0;
const cliTruncate = require("cli-truncate");
const logUpdate = require("log-update");
const os_1 = require("os");
const cliWrap = require("wrap-ansi");
const colorette_1 = require("../utils/colorette");
const figures_1 = require("../utils/figures");
const indent_string_1 = require("../utils/indent-string");
const is_unicode_supported_1 = require("../utils/is-unicode-supported");
const parse_time_1 = require("../utils/parse-time");
/** Default updating renderer for Listr2 */
class DefaultRenderer {
constructor(tasks, options, renderHook$) {
this.tasks = tasks;
this.options = options;
this.renderHook$ = renderHook$;
this.bottomBar = {};
this.spinner = !is_unicode_supported_1.isUnicodeSupported() ? ['-', '\\', '|', '/'] : ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
this.spinnerPosition = 0;
this.options = { ...DefaultRenderer.rendererOptions, ...this.options };
}
getTaskOptions(task) {
return { ...DefaultRenderer.rendererTaskOptions, ...task.rendererTaskOptions };
}
isBottomBar(task) {
const bottomBar = this.getTaskOptions(task).bottomBar;
return typeof bottomBar === 'number' && bottomBar !== 0 || typeof bottomBar === 'boolean' && bottomBar !== false;
}
hasPersistentOutput(task) {
return this.getTaskOptions(task).persistentOutput === true;
}
hasTimer(task) {
return this.getTaskOptions(task).showTimer === true;
}
getSelfOrParentOption(task, key) {
var _a, _b, _c;
return (_b = (_a = task === null || task === void 0 ? void 0 : task.rendererOptions) === null || _a === void 0 ? void 0 : _a[key]) !== null && _b !== void 0 ? _b : (_c = this.options) === null || _c === void 0 ? void 0 : _c[key];
}
/* istanbul ignore next */
getTaskTime(task) {
return colorette_1.default.dim(`[${parse_time_1.parseTaskTime(task.message.duration)}]`);
}
createRender(options) {
options = {
...{
tasks: true,
bottomBar: true,
prompt: true
},
...options
};
const render = [];
const renderTasks = this.multiLineRenderer(this.tasks);
const renderBottomBar = this.renderBottomBar();
const renderPrompt = this.renderPrompt();
if (options.tasks && (renderTasks === null || renderTasks === void 0 ? void 0 : renderTasks.trim().length) > 0) {
render.push(renderTasks);
}
if (options.bottomBar && (renderBottomBar === null || renderBottomBar === void 0 ? void 0 : renderBottomBar.trim().length) > 0) {
render.push((render.length > 0 ? os_1.EOL : '') + renderBottomBar);
}
if (options.prompt && (renderPrompt === null || renderPrompt === void 0 ? void 0 : renderPrompt.trim().length) > 0) {
render.push((render.length > 0 ? os_1.EOL : '') + renderPrompt);
}
return render.length > 0 ? render.join(os_1.EOL) : '';
}
render() {
var _a;
// Do not render if we are already rendering
if (this.id) {
return;
}
const updateRender = () => logUpdate(this.createRender());
/* istanbul ignore if */
if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.lazy)) {
this.id = setInterval(() => {
this.spinnerPosition = ++this.spinnerPosition % this.spinner.length;
updateRender();
}, 100);
}
this.renderHook$.subscribe(() => {
updateRender();
});
}
end() {
clearInterval(this.id);
if (this.id) {
this.id = undefined;
}
// clear log updater
logUpdate.clear();
logUpdate.done();
// directly write to process.stdout, since logupdate only can update the seen height of terminal
if (!this.options.clearOutput) {
process.stdout.write(this.createRender({ prompt: false }) + os_1.EOL);
}
}
// eslint-disable-next-line
multiLineRenderer(tasks, level = 0) {
var _a, _b;
let output = [];
for (const task of tasks) {
if (task.isEnabled()) {
// Current Task Title
if (task.hasTitle()) {
if (!(tasks.some((task) => task.hasFailed()) && !task.hasFailed() && task.options.exitOnError !== false && !(task.isCompleted() || task.isSkipped()))) {
// if task is skipped
if (task.hasFailed() && this.getSelfOrParentOption(task, 'collapseErrors')) {
// current task title and skip change the title
output = [
...output,
this.formatString(!task.hasSubtasks() && task.message.error && this.getSelfOrParentOption(task, 'showErrorMessage') ? task.message.error : task.title, this.getSymbol(task), level)
];
}
else if (task.isSkipped() && this.getSelfOrParentOption(task, 'collapseSkips')) {
// current task title and skip change the title
output = [
...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)
];
}
else if (task.isRetrying() && this.getSelfOrParentOption(task, 'suffixRetries')) {
output = [...output, this.formatString(this.addSuffixToMessage(task.title, `RETRYING-${task.message.retry.count}`), this.getSymbol(task), level)];
}
else if (task.isCompleted() && task.hasTitle() && (this.getSelfOrParentOption(task, 'showTimer') || this.hasTimer(task))) {
// task with timer
output = [...output, this.formatString(`${task === null || task === void 0 ? void 0 : task.title} ${this.getTaskTime(task)}`, this.getSymbol(task), level)];
}
else {
// normal state
output = [...output, this.formatString(task.title, this.getSymbol(task), level)];
}
}
else {
// some sibling task but self has failed and this has stopped
output = [...output, this.formatString(task.title, colorette_1.default.red(figures_1.figures.squareSmallFilled), level)];
}
}
// task should not have subtasks since subtasks will handle the error already
// maybe it is a better idea to show the error or skip messages when show subtasks is disabled.
if (!task.hasSubtasks() || !this.getSelfOrParentOption(task, 'showSubtasks')) {
// without the collapse option for skip and errors
if (task.hasFailed() &&
this.getSelfOrParentOption(task, 'collapseErrors') === false &&
(this.getSelfOrParentOption(task, 'showErrorMessage') || !this.getSelfOrParentOption(task, 'showSubtasks'))) {
// show skip data if collapsing is not defined
output = [...output, this.dumpData(task, level, 'error')];
}
else if (task.isSkipped() &&
this.getSelfOrParentOption(task, 'collapseSkips') === false &&
(this.getSelfOrParentOption(task, 'showSkipMessage') || !this.getSelfOrParentOption(task, 'showSubtasks'))) {
// show skip data if collapsing is not defined
output = [...output, this.dumpData(task, level, 'skip')];
}
}
// Current Task Output
if (task === null || task === void 0 ? void 0 : task.output) {
if ((task.isPending() || task.isRetrying() || task.isRollingBack()) && task.isPrompt()) {
// data output to prompt bar if prompt
this.promptBar = task.output;
}
else if (this.isBottomBar(task) || !task.hasTitle()) {
// data output to bottom bar
const data = [this.dumpData(task, -1)];
// create new if there is no persistent storage created for bottom bar
if (!this.bottomBar[task.id]) {
this.bottomBar[task.id] = {};
this.bottomBar[task.id].data = [];
const bottomBar = this.getTaskOptions(task).bottomBar;
if (typeof bottomBar === 'boolean') {
this.bottomBar[task.id].items = 1;
}
else {
this.bottomBar[task.id].items = bottomBar;
}
}
// persistent bottom bar and limit items in it
if (!((_b = (_a = this.bottomBar[task.id]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.some((element) => data.includes(element))) && !task.isSkipped()) {
this.bottomBar[task.id].data = [...this.bottomBar[task.id].data, ...data];
}
}
else if (task.isPending() || task.isRetrying() || task.isRollingBack() || this.hasPersistentOutput(task)) {
// keep output if persistent output is set
output = [...output, this.dumpData(task, level)];
}
}
// render subtasks, some complicated conditionals going on
if (
// check if renderer option is on first
this.getSelfOrParentOption(task, 'showSubtasks') !== false &&
// if it doesnt have subtasks no need to check
task.hasSubtasks() &&
(task.isPending() ||
task.hasFailed() ||
task.isCompleted() && !task.hasTitle() ||
// have to be completed and have subtasks
task.isCompleted() && this.getSelfOrParentOption(task, 'collapse') === false && !task.subtasks.some((subtask) => subtask.rendererOptions.collapse === true) ||
// if any of the subtasks have the collapse option of
task.subtasks.some((subtask) => subtask.rendererOptions.collapse === false) ||
// if any of the subtasks has failed
task.subtasks.some((subtask) => subtask.hasFailed()) ||
// if any of the subtasks rolled back
task.subtasks.some((subtask) => subtask.hasRolledBack()))) {
// set level
const subtaskLevel = !task.hasTitle() ? level : level + 1;
// render the subtasks as in the same way
const subtaskRender = this.multiLineRenderer(task.subtasks, subtaskLevel);
if ((subtaskRender === null || subtaskRender === void 0 ? void 0 : subtaskRender.trim()) !== '' && !task.subtasks.every((subtask) => !subtask.hasTitle())) {
output = [...output, subtaskRender];
}
}
// after task is finished actions
if (task.isCompleted() || task.hasFailed() || task.isSkipped() || task.hasRolledBack()) {
// clean up prompts
this.promptBar = null;
// clean up bottom bar items if not indicated otherwise
if (!this.hasPersistentOutput(task)) {
delete this.bottomBar[task.id];
}
}
}
}
output = output.filter(Boolean);
if (output.length > 0) {
return output.join(os_1.EOL);
}
else {
return;
}
}
renderBottomBar() {
// parse through all objects return only the last mentioned items
if (Object.keys(this.bottomBar).length > 0) {
this.bottomBar = Object.keys(this.bottomBar).reduce((o, key) => {
if (!(o === null || o === void 0 ? void 0 : o[key])) {
o[key] = {};
}
o[key] = this.bottomBar[key];
this.bottomBar[key].data = this.bottomBar[key].data.slice(-this.bottomBar[key].items);
o[key].data = this.bottomBar[key].data;
return o;
}, {});
return Object.values(this.bottomBar)
.reduce((o, value) => o = [...o, ...value.data], [])
.filter(Boolean)
.join(os_1.EOL);
}
}
renderPrompt() {
if (this.promptBar) {
return this.promptBar;
}
}
dumpData(task, level, source = 'output') {
let data;
switch (source) {
case 'output':
data = task.output;
break;
case 'skip':
data = task.message.skip;
break;
case 'error':
data = task.message.error;
break;
}
// dont return anything on some occasions
if (task.hasTitle() && source === 'error' && data === task.title) {
return;
}
if (typeof data === 'string') {
return this.formatString(data, this.getSymbol(task, true), level + 1);
}
}
formatString(str, icon, level) {
// we dont like empty data around here
if (str.trim() === '') {
return;
}
str = `${icon} ${str}`;
let parsedStr;
let columns = process.stdout.columns ? process.stdout.columns : 80;
columns = columns - level * this.options.indentation - 2;
switch (this.options.formatOutput) {
case 'truncate':
parsedStr = str.split(os_1.EOL).map((s, i) => {
return cliTruncate(this.indentMultilineOutput(s, i), columns);
});
break;
case 'wrap':
parsedStr = cliWrap(str, columns, { hard: true })
.split(os_1.EOL)
.map((s, i) => this.indentMultilineOutput(s, i));
break;
default:
throw new Error('Format option for the renderer is wrong.');
}
// this removes the empty lines
if (this.options.removeEmptyLines) {
parsedStr = parsedStr.filter(Boolean);
}
return indent_string_1.indentString(parsedStr.join(os_1.EOL), level * this.options.indentation);
}
indentMultilineOutput(str, i) {
return i > 0 ? indent_string_1.indentString(str.trim(), 2) : str.trim();
}
// eslint-disable-next-line complexity
getSymbol(task, data = false) {
var _a, _b, _c;
if (task.isPending() && !data) {
return ((_a = this.options) === null || _a === void 0 ? void 0 : _a.lazy) || this.getSelfOrParentOption(task, 'showSubtasks') !== false && task.hasSubtasks() && !task.subtasks.every((subtask) => !subtask.hasTitle())
? colorette_1.default.yellow(figures_1.figures.pointer)
: colorette_1.default.yellowBright(this.spinner[this.spinnerPosition]);
}
else if (task.isCompleted() && !data) {
return task.hasSubtasks() && task.subtasks.some((subtask) => subtask.hasFailed()) ? colorette_1.default.yellow(figures_1.figures.warning) : colorette_1.default.green(figures_1.figures.tick);
}
else if (task.isRetrying() && !data) {
return ((_b = this.options) === null || _b === void 0 ? void 0 : _b.lazy) ? colorette_1.default.yellow(figures_1.figures.warning) : colorette_1.default.yellow(this.spinner[this.spinnerPosition]);
}
else if (task.isRollingBack() && !data) {
return ((_c = this.options) === null || _c === void 0 ? void 0 : _c.lazy) ? colorette_1.default.red(figures_1.figures.warning) : colorette_1.default.red(this.spinner[this.spinnerPosition]);
}
else if (task.hasRolledBack() && !data) {
return colorette_1.default.red(figures_1.figures.arrowLeft);
}
else if (task.hasFailed() && !data) {
return task.hasSubtasks() ? colorette_1.default.red(figures_1.figures.pointer) : colorette_1.default.red(figures_1.figures.cross);
}
else if (task.isSkipped() && !data && this.getSelfOrParentOption(task, 'collapseSkips') === false) {
return colorette_1.default.yellow(figures_1.figures.warning);
}
else if (task.isSkipped() && (data || this.getSelfOrParentOption(task, 'collapseSkips'))) {
return colorette_1.default.yellow(figures_1.figures.arrowDown);
}
return !data ? colorette_1.default.dim(figures_1.figures.squareSmallFilled) : figures_1.figures.pointerSmall;
}
addSuffixToMessage(message, suffix, condition) {
return (condition !== null && condition !== void 0 ? condition : true) ? message + colorette_1.default.dim(` [${suffix}]`) : message;
}
}
exports.DefaultRenderer = DefaultRenderer;
/** designates whether this renderer can output to a non-tty console */
DefaultRenderer.nonTTY = false;
/** renderer options for the defauult renderer */
DefaultRenderer.rendererOptions = {
indentation: 2,
clearOutput: false,
showSubtasks: true,
collapse: true,
collapseSkips: true,
showSkipMessage: true,
suffixSkips: true,
collapseErrors: true,
showErrorMessage: true,
suffixRetries: true,
lazy: false,
showTimer: false,
removeEmptyLines: true,
formatOutput: 'truncate'
};

15
node_modules/listr2/dist/renderer/silent.renderer.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import { ListrRenderer } from '../interfaces/renderer.interface';
import { Task } from '../lib/task';
export declare class SilentRenderer implements ListrRenderer {
tasks: Task<any, typeof SilentRenderer>[];
options: typeof SilentRenderer['rendererOptions'];
/** designates whether this renderer can output to a non-tty console */
static nonTTY: boolean;
/** renderer options for the silent renderer */
static rendererOptions: never;
/** per task options for the silent renderer */
static rendererTaskOptions: never;
constructor(tasks: Task<any, typeof SilentRenderer>[], options: typeof SilentRenderer['rendererOptions']);
render(): void;
end(): void;
}

14
node_modules/listr2/dist/renderer/silent.renderer.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SilentRenderer = void 0;
class SilentRenderer {
constructor(tasks, options) {
this.tasks = tasks;
this.options = options;
}
render() { }
end() { }
}
exports.SilentRenderer = SilentRenderer;
/** designates whether this renderer can output to a non-tty console */
SilentRenderer.nonTTY = true;

48
node_modules/listr2/dist/renderer/simple.renderer.d.ts generated vendored Normal file
View File

@@ -0,0 +1,48 @@
import { ListrEventType } from '../constants/event.constants';
import { ListrEventFromType } from '../interfaces/listr.interface';
import { ListrRenderer } from '../interfaces/renderer.interface';
import { Task } from '../lib/task';
/**
* 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
*/
export declare class SimpleRenderer implements ListrRenderer {
readonly tasks: Task<any, typeof SimpleRenderer>[];
options: typeof SimpleRenderer['rendererOptions'];
static nonTTY: boolean;
static rendererOptions: {
/**
* if true this will add
* timestamp at the begin of the rendered line
*
* @example
*
* ```bash
* [12:33:44] ✔ Do something important
* ```
*
* @default false
*/
prefixWithTimestamp?: boolean;
/**
* choose between process.stdout and process.stderr
*
* @default stdout
*/
output?: 'stdout' | 'stderr';
};
static rendererTaskOptions: never;
/**
* Event type renderer map contains functions to process different task events
*/
eventTypeRendererMap: Partial<{
[P in ListrEventType]: (t: Task<any, typeof SimpleRenderer>, event: ListrEventFromType<P>) => void;
}>;
constructor(tasks: Task<any, typeof SimpleRenderer>[], options: typeof SimpleRenderer['rendererOptions']);
static now(): Date;
static formatTitle(task?: Task<any, typeof SimpleRenderer>): string;
log(output?: string): void;
end(): void;
render(tasks?: Task<any, typeof SimpleRenderer>[]): void;
}

119
node_modules/listr2/dist/renderer/simple.renderer.js generated vendored Normal file
View File

@@ -0,0 +1,119 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimpleRenderer = void 0;
const log_update_1 = require("log-update");
const os_1 = require("os");
const event_constants_1 = require("../constants/event.constants");
const colorette_1 = require("../utils/colorette");
const figures_1 = require("../utils/figures");
/**
* 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
*/
class SimpleRenderer {
constructor(tasks, options) {
this.tasks = tasks;
this.options = options;
/**
* Event type renderer map contains functions to process different task events
*/
this.eventTypeRendererMap = {
[event_constants_1.ListrEventType.SUBTASK]: (task) => {
if (task.hasTitle()) {
// if Task has subtasks where we want to log the group indication
this.log(`${colorette_1.default.blue(figures_1.figures.pointer)} ${task.title}`);
}
if (task.hasSubtasks()) {
this.render(task.subtasks);
}
},
[event_constants_1.ListrEventType.STATE]: (task) => {
if (task.isCompleted() && task.hasTitle()) {
// The title is only logged at the end of the task execution
this.log(`${colorette_1.default.green(figures_1.figures.tick)} ${task.title}`);
}
},
[event_constants_1.ListrEventType.DATA]: (task, event) => {
// ! This is where it gets dirty
// * We want the prompt to stay visible after confirmation
if (task.isPrompt() && !String(event.data).match(/^\n$/)) {
log_update_1.stderr(`${event.data}`);
}
else {
this.log(`${figures_1.figures.pointerSmall} ${event.data}`);
}
},
[event_constants_1.ListrEventType.MESSAGE]: (task, event) => {
if (event.data.error) {
// error message
const title = SimpleRenderer.formatTitle(task);
this.log(`${colorette_1.default.red(figures_1.figures.cross)}${title}: ${event.data.error}`);
}
else if (event.data.skip) {
// Skip message
const title = SimpleRenderer.formatTitle(task);
const skip = task.title !== event.data.skip ? `: ${event.data.skip}` : '';
this.log(`${colorette_1.default.yellow(figures_1.figures.arrowDown)}${title} [${colorette_1.default.yellow(`skipped${skip}`)}]`);
}
else if (event.data.rollback) {
// rollback message
const title = SimpleRenderer.formatTitle(task);
this.log(`${colorette_1.default.red(figures_1.figures.arrowLeft)}${title}: ${event.data.rollback}`);
}
else if (event.data.retry) {
// Retry Message
const title = SimpleRenderer.formatTitle(task);
this.log(`[${colorette_1.default.yellow(`${event.data.retry.count}`)}]${title}`);
}
}
// * We do not log out initial title. Only the final one.
// [ListrEventType.TITLE]: (t, e) => this.renderTitle(t, e),
};
this.options = { ...SimpleRenderer.rendererOptions, ...options };
}
// This is used for mocks, since mocking Date is cumbesome
static now() {
return new Date();
}
// Used to sanitize title output
static formatTitle(task) {
return (task === null || task === void 0 ? void 0 : task.title) ? ` ${task.title}` : '';
}
// Writes sanitized output
log(output) {
const logOut = (msg) => {
// Need appent \n to mimic console.log
process[this.options.output].write(msg.endsWith(os_1.EOL) ? msg : `${msg}${os_1.EOL}`);
};
if (!this.options.prefixWithTimestamp) {
logOut(`${output}`);
return;
}
const now = SimpleRenderer.now();
const timestamp = String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0') + ':' + String(now.getSeconds()).padStart(2, '0');
logOut(`${colorette_1.default.dim(`[${timestamp}]`)} ${output}`);
}
// eslint-disable-next-line
end() { }
// yes this is a misuse :)
render(tasks) {
if (tasks === null || tasks === void 0 ? void 0 : tasks.length) {
tasks.forEach((task) => {
task.subscribe((event) => {
var _a, _b;
// Here event type will match event.type anyway
(_b = (_a = this.eventTypeRendererMap)[event.type]) === null || _b === void 0 ? void 0 : _b.call(_a, task, event);
}, this.log);
});
}
else {
this.render(this.tasks);
}
}
}
exports.SimpleRenderer = SimpleRenderer;
// Designate this renderer as tty or nonTTY
SimpleRenderer.nonTTY = true;
// designate your renderer options that will be showed inside the `ListrOptions` as rendererOptions
SimpleRenderer.rendererOptions = { prefixWithTimestamp: false, output: 'stdout' };

View File

@@ -0,0 +1,42 @@
import { ListrRenderer } from '../interfaces/renderer.interface';
import { Task } from '../lib/task';
import { Logger } from '../utils/logger';
export declare class VerboseRenderer implements ListrRenderer {
tasks: Task<any, typeof VerboseRenderer>[];
options: typeof VerboseRenderer['rendererOptions'];
/** designates whether this renderer can output to a non-tty console */
static nonTTY: boolean;
/** renderer options for the verbose renderer */
static rendererOptions: {
/**
* useIcons instead of text for log level
* @default false
*/
useIcons?: boolean;
/**
* inject a custom loger
*/
logger?: new (...args: any) => Logger;
/**
* log tasks with empty titles
* @default true
*/
logEmptyTitle?: boolean;
/**
* log title changes
* @default true
*/
logTitleChange?: boolean;
/**
* show duration for all tasks
*/
showTimer?: boolean;
};
/** per task options for the verbose renderer */
static rendererTaskOptions: never;
private logger;
constructor(tasks: Task<any, typeof VerboseRenderer>[], options: typeof VerboseRenderer['rendererOptions']);
render(): void;
end(): void;
private verboseRenderer;
}

91
node_modules/listr2/dist/renderer/verbose.renderer.js generated vendored Normal file
View File

@@ -0,0 +1,91 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VerboseRenderer = void 0;
const event_constants_1 = require("../constants/event.constants");
const logger_1 = require("../utils/logger");
const parse_time_1 = require("../utils/parse-time");
class VerboseRenderer {
constructor(tasks, options) {
var _a, _b;
this.tasks = tasks;
this.options = options;
if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.logger)) {
this.logger = new logger_1.Logger({ useIcons: (_b = this.options) === null || _b === void 0 ? void 0 : _b.useIcons });
} /* istanbul ignore next */
else {
this.logger = new this.options.logger();
}
this.options = { ...VerboseRenderer.rendererOptions, ...this.options };
}
render() {
this.verboseRenderer(this.tasks);
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
end() { }
// verbose renderer multi-level
verboseRenderer(tasks) {
return tasks === null || tasks === void 0 ? void 0 : tasks.forEach((task) => {
task.subscribe(
// eslint-disable-next-line complexity
(event) => {
var _a, _b, _c, _d, _e, _f, _g, _h;
if (task.isEnabled()) {
// render depending on the state
const taskTitle = task.hasTitle() ? task.title : 'Task without title.';
if (event.type === event_constants_1.ListrEventType.SUBTASK && task.hasSubtasks()) {
// render lower level if multi-level
this.verboseRenderer(task.subtasks);
}
else if (event.type === event_constants_1.ListrEventType.STATE) {
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.logEmptyTitle) !== false || task.hasTitle()) {
if (task.isPending()) {
this.logger.start(taskTitle);
}
else if (task.isCompleted()) {
this.logger.success(taskTitle + (((_b = this.options) === null || _b === void 0 ? void 0 : _b.showTimer) && ((_c = task.message) === null || _c === void 0 ? void 0 : _c.duration) ? ` [${parse_time_1.parseTaskTime(task.message.duration)}]` : ''));
}
}
}
else if (event.type === event_constants_1.ListrEventType.DATA && !!event.data) {
this.logger.data(String(event.data));
}
else if (event.type === event_constants_1.ListrEventType.TITLE) {
if (((_d = this.options) === null || _d === void 0 ? void 0 : _d.logTitleChange) !== false) {
this.logger.title(String(event.data));
}
}
else if (event.type === event_constants_1.ListrEventType.MESSAGE) {
if ((_e = event.data) === null || _e === void 0 ? void 0 : _e.error) {
// error message
this.logger.fail(String(event.data.error));
}
else if ((_f = event.data) === null || _f === void 0 ? void 0 : _f.skip) {
// skip message
this.logger.skip(String(event.data.skip));
}
else if ((_g = event.data) === null || _g === void 0 ? void 0 : _g.rollback) {
// rollback message
this.logger.rollback(String(event.data.rollback));
}
else if ((_h = event.data) === null || _h === void 0 ? void 0 : _h.retry) {
// inform of retry count
this.logger.retry(`[${event.data.retry.count}] ` + String(taskTitle));
}
}
}
},
/* istanbul ignore next */ (err) => {
this.logger.fail(err);
});
});
}
}
exports.VerboseRenderer = VerboseRenderer;
/** designates whether this renderer can output to a non-tty console */
VerboseRenderer.nonTTY = true;
/** renderer options for the verbose renderer */
VerboseRenderer.rendererOptions = {
useIcons: false,
logEmptyTitle: true,
logTitleChange: true
};