Fix dependabot issues

This commit is contained in:
Andrew Eisenberg 2021-10-21 15:24:20 -07:00
parent c89d9bd8b0
commit 531c6ba7c8
705 changed files with 53406 additions and 20466 deletions

96
node_modules/ora/index.js generated vendored
View file

@ -7,22 +7,21 @@ const logSymbols = require('log-symbols');
const stripAnsi = require('strip-ansi');
const wcwidth = require('wcwidth');
const isInteractive = require('is-interactive');
const MuteStream = require('mute-stream');
const isUnicodeSupported = require('is-unicode-supported');
const {BufferListStream} = require('bl');
const TEXT = Symbol('text');
const PREFIX_TEXT = Symbol('prefixText');
const ASCII_ETX_CODE = 0x03; // Ctrl+C emits this code
class StdinDiscarder {
constructor() {
this.requests = 0;
this.mutedStream = new MuteStream();
this.mutedStream = new BufferListStream();
this.mutedStream.pipe(process.stdout);
this.mutedStream.mute();
const self = this;
const self = this; // eslint-disable-line unicorn/no-this-assignment
this.ourEmit = function (event, data, ...args) {
const {stdin} = process;
if (self.requests > 0 || stdin.emit === self.ourEmit) {
@ -92,10 +91,14 @@ class StdinDiscarder {
}
}
const stdinDiscarder = new StdinDiscarder();
let stdinDiscarder;
class Ora {
constructor(options) {
if (!stdinDiscarder) {
stdinDiscarder = new StdinDiscarder();
}
if (typeof options === 'string') {
options = {
text: options
@ -118,6 +121,7 @@ class Ora {
this.stream = this.options.stream;
this.id = undefined;
this.isEnabled = typeof this.options.isEnabled === 'boolean' ? this.options.isEnabled : isInteractive({stream: this.stream});
this.isSilent = typeof this.options.isSilent === 'boolean' ? this.options.isSilent : false;
// Set *after* `this.stream`
this.text = this.options.text;
@ -159,15 +163,15 @@ class Ora {
}
this._spinner = spinner;
} else if (process.platform === 'win32') {
} else if (!isUnicodeSupported()) {
this._spinner = cliSpinners.line;
} else if (spinner === undefined) {
// Set default spinner
this._spinner = cliSpinners.dots;
} else if (cliSpinners[spinner]) {
} else if (spinner !== 'default' && cliSpinners[spinner]) {
this._spinner = cliSpinners[spinner];
} else {
throw new Error(`There is no built-in spinner named '${spinner}'. See https://github.com/sindresorhus/cli-spinners/blob/master/spinners.json for a full list.`);
throw new Error(`There is no built-in spinner named '${spinner}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`);
}
this._updateInterval(this._spinner.interval);
@ -177,30 +181,67 @@ class Ora {
return this[TEXT];
}
set text(value) {
this[TEXT] = value;
this.updateLineCount();
}
get prefixText() {
return this[PREFIX_TEXT];
}
set prefixText(value) {
this[PREFIX_TEXT] = value;
this.updateLineCount();
}
get isSpinning() {
return this.id !== undefined;
}
getFullPrefixText(prefixText = this[PREFIX_TEXT], postfix = ' ') {
if (typeof prefixText === 'string') {
return prefixText + postfix;
}
if (typeof prefixText === 'function') {
return prefixText() + postfix;
}
return '';
}
updateLineCount() {
const columns = this.stream.columns || 80;
const fullPrefixText = (typeof this[PREFIX_TEXT] === 'string') ? this[PREFIX_TEXT] + '-' : '';
this.lineCount = stripAnsi(fullPrefixText + '--' + this[TEXT]).split('\n').reduce((count, line) => {
return count + Math.max(1, Math.ceil(wcwidth(line) / columns));
}, 0);
const fullPrefixText = this.getFullPrefixText(this.prefixText, '-');
this.lineCount = 0;
for (const line of stripAnsi(fullPrefixText + '--' + this[TEXT]).split('\n')) {
this.lineCount += Math.max(1, Math.ceil(wcwidth(line) / columns));
}
}
set text(value) {
this[TEXT] = value;
this.updateLineCount();
get isEnabled() {
return this._isEnabled && !this.isSilent;
}
set prefixText(value) {
this[PREFIX_TEXT] = value;
this.updateLineCount();
set isEnabled(value) {
if (typeof value !== 'boolean') {
throw new TypeError('The `isEnabled` option must be a boolean');
}
this._isEnabled = value;
}
get isSilent() {
return this._isSilent;
}
set isSilent(value) {
if (typeof value !== 'boolean') {
throw new TypeError('The `isSilent` option must be a boolean');
}
this._isSilent = value;
}
frame() {
@ -238,6 +279,10 @@ class Ora {
}
render() {
if (this.isSilent) {
return this;
}
this.clear();
this.stream.write(this.frame());
this.linesToClear = this.lineCount;
@ -250,6 +295,10 @@ class Ora {
this.text = text;
}
if (this.isSilent) {
return this;
}
if (!this.isEnabled) {
if (this.text) {
this.stream.write(`- ${this.text}\n`);
@ -315,13 +364,16 @@ class Ora {
}
stopAndPersist(options = {}) {
if (this.isSilent) {
return this;
}
const prefixText = options.prefixText || this.prefixText;
const fullPrefixText = (typeof prefixText === 'string' && prefixText !== '') ? prefixText + ' ' : '';
const text = options.text || this.text;
const fullText = (typeof text === 'string') ? ' ' + text : '';
this.stop();
this.stream.write(`${fullPrefixText}${options.symbol || ' '}${fullText}\n`);
this.stream.write(`${this.getFullPrefixText(prefixText, ' ')}${options.symbol || ' '}${fullText}\n`);
return this;
}
@ -346,7 +398,7 @@ module.exports.promise = (action, options) => {
try {
await action;
spinner.succeed();
} catch (_) {
} catch {
spinner.fail();
}
})();