aboutsummaryrefslogtreecommitdiff
path: root/node_modules/consola/dist
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/consola/dist')
-rw-r--r--node_modules/consola/dist/consola.cjs.js428
-rw-r--r--node_modules/consola/dist/consola.js394
2 files changed, 822 insertions, 0 deletions
diff --git a/node_modules/consola/dist/consola.cjs.js b/node_modules/consola/dist/consola.cjs.js
new file mode 100644
index 00000000..5a99f4a9
--- /dev/null
+++ b/node_modules/consola/dist/consola.cjs.js
@@ -0,0 +1,428 @@
+'use strict';
+
+function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
+
+var chalk = _interopDefault(require('chalk'));
+var figures = _interopDefault(require('figures'));
+var startCase = _interopDefault(require('lodash/startCase'));
+var env = _interopDefault(require('std-env'));
+
+function _classCallCheck(instance, Constructor) {
+ if (!(instance instanceof Constructor)) {
+ throw new TypeError("Cannot call a class as a function");
+ }
+}
+
+function _defineProperties(target, props) {
+ for (var i = 0; i < props.length; i++) {
+ var descriptor = props[i];
+ descriptor.enumerable = descriptor.enumerable || false;
+ descriptor.configurable = true;
+ if ("value" in descriptor) descriptor.writable = true;
+ Object.defineProperty(target, descriptor.key, descriptor);
+ }
+}
+
+function _createClass(Constructor, protoProps, staticProps) {
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
+ if (staticProps) _defineProperties(Constructor, staticProps);
+ return Constructor;
+}
+
+function _toArray(arr) {
+ return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest();
+}
+
+function _arrayWithHoles(arr) {
+ if (Array.isArray(arr)) return arr;
+}
+
+function _iterableToArray(iter) {
+ if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
+}
+
+function _nonIterableRest() {
+ throw new TypeError("Invalid attempt to destructure non-iterable instance");
+}
+
+var types = {
+ fatal: {
+ level: 0,
+ color: 'red'
+ },
+ error: {
+ level: 0,
+ color: 'red'
+ },
+ warn: {
+ level: 1,
+ color: 'yellow'
+ },
+ log: {
+ level: 2,
+ color: 'white'
+ },
+ info: {
+ level: 2,
+ color: 'blue'
+ },
+ start: {
+ level: 3,
+ color: 'blue'
+ },
+ success: {
+ level: 3,
+ color: 'green'
+ },
+ ready: {
+ level: 3,
+ color: 'green'
+ },
+ debug: {
+ level: 4,
+ color: 'grey'
+ },
+ trace: {
+ level: 5,
+ color: 'white'
+ }
+};
+
+var Consola =
+/*#__PURE__*/
+function () {
+ function Consola() {
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
+
+ _classCallCheck(this, Consola);
+
+ this.reporters = options.reporters || [];
+ this.types = Object.assign({}, types, options.types);
+ this.level = options.level != null ? options.level : 3;
+ Object.assign(this, this.withDefaults());
+ }
+
+ _createClass(Consola, [{
+ key: "withDefaults",
+ value: function withDefaults(defaults) {
+ var logger = {};
+
+ for (var type in this.types) {
+ logger[type] = this._createLogFn(Object.assign({
+ type: type
+ }, this.types[type], defaults));
+ }
+
+ return logger;
+ }
+ }, {
+ key: "_createLogFn",
+ value: function _createLogFn(defaults) {
+ var _this = this;
+
+ return function (opts) {
+ if (!opts) {
+ return _this;
+ }
+
+ var logObj = Object.assign({
+ date: new Date()
+ }, defaults);
+
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
+ args[_key - 1] = arguments[_key];
+ }
+
+ var argsStr = Array.from(args).map(String).join(' ');
+
+ if (typeof opts === 'string') {
+ // String
+ logObj.message = opts;
+ logObj.additional = argsStr;
+ } else if (opts.stack) {
+ // Error
+ var _opts$stack$split = opts.stack.split('\n'),
+ _opts$stack$split2 = _toArray(_opts$stack$split),
+ message = _opts$stack$split2[0],
+ stack = _opts$stack$split2.slice(1);
+
+ logObj.message = message;
+ logObj.additional = (argsStr.length ? argsStr + '\n' : '') + stack.map(function (s) {
+ return s.trim();
+ }).join('\n');
+ } else {
+ // Object
+ Object.assign(logObj, opts);
+ }
+
+ _this._log(logObj);
+
+ return _this;
+ };
+ }
+ }, {
+ key: "_log",
+ value: function _log(logObj) {
+ if (logObj.level > this.level) {
+ return;
+ }
+
+ var _iteratorNormalCompletion = true;
+ var _didIteratorError = false;
+ var _iteratorError = undefined;
+
+ try {
+ for (var _iterator = this.reporters[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
+ var reporter = _step.value;
+ reporter.log(logObj);
+ }
+ } catch (err) {
+ _didIteratorError = true;
+ _iteratorError = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
+ _iterator.return();
+ }
+ } finally {
+ if (_didIteratorError) {
+ throw _iteratorError;
+ }
+ }
+ }
+
+ return this;
+ }
+ }, {
+ key: "add",
+ value: function add(reporter) {
+ this.reporters.push(reporter);
+ return this;
+ }
+ }, {
+ key: "clear",
+ value: function clear() {
+ this.reporters.splice(0);
+ return this;
+ }
+ }, {
+ key: "remove",
+ value: function remove(reporter) {
+ var i = this.reporters.indexOf(reporter);
+
+ if (i >= 0) {
+ return this.reporters.splice(i, 1);
+ }
+
+ return this;
+ }
+ }, {
+ key: "withScope",
+ value: function withScope(scope) {
+ return this.withDefaults({
+ scope: scope
+ });
+ }
+ }]);
+
+ return Consola;
+}(); // Upward compatibility support to >= v2
+Consola.prototype.addReporter = Consola.prototype.add;
+Consola.prototype.removeReporter = Consola.prototype.remove;
+Consola.prototype.removeReporter = Consola.prototype.clear;
+Consola.prototype.withTag = Consola.prototype.withScope;
+
+var BasicReporter =
+/*#__PURE__*/
+function () {
+ function BasicReporter(stream) {
+ _classCallCheck(this, BasicReporter);
+
+ this.stream = stream || process.stdout;
+ }
+
+ _createClass(BasicReporter, [{
+ key: "formatTag",
+ value: function formatTag(tag) {
+ return "[".concat(tag.toUpperCase(), "]");
+ }
+ }, {
+ key: "log",
+ value: function log(logObj) {
+ var l = [this.formatTag(logObj.date.toLocaleTimeString())];
+
+ if (logObj.scope) {
+ l.push(this.formatTag(logObj.scope));
+ }
+
+ l.push(logObj.message);
+ this.stream.write(l.join(' ') + '\n');
+
+ if (logObj.additional) {
+ this.stream.write(logObj.additional + '\n');
+ }
+ }
+ }]);
+
+ return BasicReporter;
+}();
+
+var NS_SEPARATOR = chalk.blue(figures(' › '));
+var ICONS = {
+ start: figures('●'),
+ info: figures('ℹ'),
+ success: figures('✔'),
+ error: figures('✖'),
+ fatal: figures('✖'),
+ warn: figures('⚠'),
+ debug: figures('…'),
+ trace: figures('…'),
+ default: figures('❯'),
+ ready: figures('♥')
+};
+
+var FancyReporter =
+/*#__PURE__*/
+function () {
+ function FancyReporter(stream) {
+
+ _classCallCheck(this, FancyReporter);
+
+ this.stream = stream || process.stderr;
+ }
+
+ _createClass(FancyReporter, [{
+ key: "formatBadge",
+ value: function formatBadge(type) {
+ var color = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'blue';
+ return chalk['bg' + startCase(color)].black(" ".concat(type.toUpperCase(), " ")) + ' ';
+ }
+ }, {
+ key: "formatTag",
+ value: function formatTag(type) {
+ var color = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'blue';
+ var icon = arguments.length > 2 ? arguments[2] : undefined;
+ return chalk[color]("".concat(icon, " ").concat(type.toLowerCase())) + ' ';
+ }
+ }, {
+ key: "clear",
+ value: function clear() {
+ this.stream.write(process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H');
+ }
+ }, {
+ key: "log",
+ value: function log(logObj) {
+ var message = logObj.message;
+
+ if (logObj.scope) {
+ message = (logObj.scope.replace(/:/g, '>') + '>').split('>').join(NS_SEPARATOR) + message;
+ }
+
+ if (logObj.clear) {
+ this.clear();
+ }
+
+ var icon = logObj.icon || ICONS[logObj.type] || ICONS.default;
+
+ if (logObj.badge) {
+ this.stream.write('\n\n' + this.formatBadge(logObj.type, logObj.color, icon) + message + '\n\n');
+ } else {
+ this.stream.write(this.formatTag(logObj.type, logObj.color, icon) + message + '\n');
+ }
+
+ if (logObj.additional) {
+ var lines = logObj.additional.split('\n').map(function (s) {
+ return ' ' + s;
+ }).join('\n');
+ this.stream.write(chalk[logObj.additionalStyle || 'grey'](lines) + '\n');
+ }
+ }
+ }]);
+
+ return FancyReporter;
+}();
+
+var JSONReporter =
+/*#__PURE__*/
+function () {
+ function JSONReporter(stream) {
+ _classCallCheck(this, JSONReporter);
+
+ this.stream = stream || process.stdout;
+ }
+
+ _createClass(JSONReporter, [{
+ key: "log",
+ value: function log(logObj) {
+ this.stream.write(JSON.stringify(logObj) + '\n');
+ }
+ }]);
+
+ return JSONReporter;
+}();
+
+// This reporter is compatible with Winston 3
+// https://github.com/winstonjs/winston
+var WinstonReporter =
+/*#__PURE__*/
+function () {
+ function WinstonReporter(logger) {
+ _classCallCheck(this, WinstonReporter);
+
+ this.logger = logger;
+ }
+
+ _createClass(WinstonReporter, [{
+ key: "log",
+ value: function log(logObj) {
+ this.logger.log({
+ level: levels[logObj.level] || 'info',
+ label: logObj.tag,
+ message: logObj.message,
+ timestamp: logObj.date.getTime() / 1000
+ });
+ }
+ }]);
+
+ return WinstonReporter;
+}();
+var levels = {
+ 0: 'error',
+ 1: 'warn',
+ 2: 'info',
+ 3: 'verbose',
+ 4: 'debug',
+ 5: 'silly'
+};
+
+var Reporters = {
+ BasicReporter: BasicReporter,
+ FancyReporter: FancyReporter,
+ JSONReporter: JSONReporter,
+ WinstonReporter: WinstonReporter
+};
+
+// duplicated instances when used with different packages/versions
+
+var consola = global && global.consola;
+
+if (!consola) {
+ consola = new Consola({
+ level: env.debug ? 4 : 3
+ });
+
+ if (env.minimalCLI) {
+ consola.add(new Reporters.BasicReporter());
+ } else {
+ consola.add(new Reporters.FancyReporter());
+ }
+
+ Object.assign(consola, {
+ Consola: Consola
+ }, Reporters);
+ global.consola = consola;
+}
+
+var consola$1 = consola;
+
+module.exports = consola$1;
diff --git a/node_modules/consola/dist/consola.js b/node_modules/consola/dist/consola.js
new file mode 100644
index 00000000..95b4ccb1
--- /dev/null
+++ b/node_modules/consola/dist/consola.js
@@ -0,0 +1,394 @@
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ (global.consola = factory());
+}(this, (function () { 'use strict';
+
+ var Types = {
+ // Level 0
+ fatal: {
+ level: 0
+ },
+ error: {
+ level: 0
+ },
+ // Level 1
+ warn: {
+ level: 1
+ },
+ // Level 2
+ log: {
+ level: 2
+ },
+ // Level 3
+ info: {
+ level: 3
+ },
+ success: {
+ level: 3
+ },
+ // Level 4
+ debug: {
+ level: 4
+ },
+ // Level 5
+ trace: {
+ level: 5
+ },
+ // Silent
+ silent: {
+ level: Infinity
+ },
+ // Legacy
+ ready: {
+ level: 3
+ },
+ start: {
+ level: 3
+ }
+ };
+
+ function isPlainObject(obj) {
+ return Object.prototype.toString.call(obj) === '[object Object]';
+ }
+ function isLogObj(arg) {
+ // Should be plain object
+ // Also contains either message or args field
+ return isPlainObject(arg) && Boolean(arg.message || arg.args);
+ }
+
+ let paused = false;
+ const queue = [];
+ class Consola {
+ constructor(options = {}) {
+ this._reporters = options.reporters || [];
+ this._types = options.types || Types;
+ this._level = options.level != null ? options.level : 3;
+ this._defaults = options.defaults || {};
+ this._async = typeof options.async !== 'undefined' ? options.async : null;
+ this._stdout = options.stdout;
+ this._stderr = options.stdout;
+ this._mockFn = options.mockFn; // Create logger functions for current instance
+
+ for (const type in this._types) {
+ this[type] = this._wrapLogFn(Object.assign({
+ type
+ }, this._types[type], this._defaults));
+ } // Use _mockFn if is set
+
+
+ if (this._mockFn) {
+ this.mockTypes();
+ }
+ }
+
+ get level() {
+ return this._level;
+ }
+
+ set level(newLevel) {
+ // Ensure that newLevel does not exceeds type level boundaries
+ let min = 0;
+ let max = 0;
+
+ for (const typeName in this._types) {
+ const type = this._types[typeName];
+
+ if (type.level > max) {
+ max = type.level;
+ } else if (type.level < min) {
+ min = type.level;
+ }
+ } // Set level
+
+
+ this._level = Math.min(max, Math.max(min, newLevel));
+ }
+
+ get stdout() {
+ return this._stdout || console._stdout; // eslint-disable-line no-console
+ }
+
+ get stderr() {
+ return this._stderr || console._stderr; // eslint-disable-line no-console
+ }
+
+ create(options) {
+ return new Consola(Object.assign({
+ reporters: this._reporters,
+ level: this._level,
+ types: this._types,
+ defaults: this._defaults,
+ stdout: this._stdout,
+ stderr: this._stderr,
+ mockFn: this._mockFn
+ }, options));
+ }
+
+ addReporter(reporter) {
+ this._reporters.push(reporter);
+
+ return this;
+ }
+
+ removeReporter(reporter) {
+ if (reporter) {
+ const i = this._reporters.indexOf(reporter);
+
+ if (i >= 0) {
+ return this._reporters.splice(i, 1);
+ }
+ } else {
+ this._reporters.splice(0);
+ }
+
+ return this;
+ }
+
+ setReporters(reporters) {
+ this._reporters = Array.isArray(reporters) ? reporters : [reporters];
+ }
+
+ withDefaults(defaults) {
+ return this.create({
+ defaults: Object.assign({}, this._defaults, defaults)
+ });
+ }
+
+ withTag(tag) {
+ return this.withDefaults({
+ tag: this._defaults.tag ? this._defaults.tag + ':' + tag : tag
+ });
+ }
+
+ wrapAll() {
+ this.wrapConsole();
+ this.wrapStd();
+ }
+
+ restoreAll() {
+ this.restoreConsole();
+ this.restoreStd();
+ }
+
+ wrapConsole() {
+ for (const type in this._types) {
+ // Backup original value
+ if (!console['__' + type]) {
+ // eslint-disable-line no-console
+ console['__' + type] = console[type]; // eslint-disable-line no-console
+ } // Override
+
+
+ console[type] = this[type]; // eslint-disable-line no-console
+ }
+ }
+
+ restoreConsole() {
+ for (const type in this._types) {
+ // Restore if backup is available
+ if (console['__' + type]) {
+ // eslint-disable-line no-console
+ console[type] = console['__' + type]; // eslint-disable-line no-console
+
+ delete console['__' + type]; // eslint-disable-line no-console
+ }
+ }
+ }
+
+ wrapStd() {
+ this._wrapStream(this.stdout, 'log');
+
+ this._wrapStream(this.stderr, 'log');
+ }
+
+ _wrapStream(stream, type) {
+ if (!stream) {
+ return;
+ } // Backup original value
+
+
+ if (!stream.__write) {
+ stream.__write = stream.write;
+ } // Override
+
+
+ stream.write = data => {
+ this[type](String(data).trim());
+ };
+ }
+
+ restoreStd() {
+ this._restoreStream(this.stdout);
+
+ this._restoreStream(this.stderr);
+ }
+
+ _restoreStream(stream) {
+ if (!stream) {
+ return;
+ }
+
+ if (stream.__write) {
+ stream.write = stream.__write;
+ delete stream.__write;
+ }
+ }
+
+ pauseLogs() {
+ paused = true;
+ }
+
+ resumeLogs() {
+ paused = false; // Process queue
+
+ const _queue = queue.splice(0);
+
+ for (const item of _queue) {
+ item[0]._logFn(item[1], item[2]);
+ }
+ }
+
+ mockTypes(mockFn) {
+ this._mockFn = mockFn || this._mockFn;
+
+ if (typeof this._mockFn !== 'function') {
+ return;
+ }
+
+ for (const type in this._types) {
+ this[type] = this._mockFn(type, this._types[type]) || this[type];
+ }
+ }
+
+ _wrapLogFn(defaults) {
+ function logFn() {
+ if (paused) {
+ queue.push([this, defaults, arguments]);
+ return;
+ }
+
+ return this._logFn(defaults, arguments);
+ }
+
+ return logFn.bind(this);
+ }
+
+ _logFn(defaults, args) {
+ if (defaults.level > this._level) {
+ return this._async ? Promise.resolve(false) : false;
+ } // Construct a new log object
+
+
+ const logObj = Object.assign({
+ date: new Date(),
+ args: []
+ }, defaults); // Consume arguments
+
+ if (args.length === 1 && isLogObj(args[0])) {
+ Object.assign(logObj, args[0]);
+ } else {
+ logObj.args = Array.from(args);
+ } // Aliases
+
+
+ if (logObj.message) {
+ logObj.args.unshift(logObj.message);
+ delete logObj.message;
+ }
+
+ if (logObj.additional) {
+ if (!Array.isArray(logObj.additional)) {
+ logObj.additional = logObj.additional.split('\n');
+ }
+
+ logObj.args.push('\n' + logObj.additional.join('\n'));
+ delete logObj.additional;
+ } // Log
+
+
+ if (this._async) {
+ return this._logAsync(logObj);
+ } else {
+ this._log(logObj);
+ }
+ }
+
+ _log(logObj) {
+ for (const reporter of this._reporters) {
+ reporter.log(logObj, {
+ async: false,
+ stdout: this.stdout,
+ stderr: this.stderr
+ });
+ }
+ }
+
+ _logAsync(logObj) {
+ return Promise.all(this._reporters.map(reporter => reporter.log(logObj, {
+ async: true,
+ stdout: this.stdout,
+ stderr: this.stderr
+ })));
+ }
+
+ } // Legacy support
+
+ Consola.prototype.add = Consola.prototype.addReporter;
+ Consola.prototype.remove = Consola.prototype.removeReporter;
+ Consola.prototype.clear = Consola.prototype.removeReporter;
+ Consola.prototype.withScope = Consola.prototype.withTag;
+ Consola.prototype.mock = Consola.prototype.mockTypes;
+ Consola.prototype.pause = Consola.prototype.pauseLogs;
+ Consola.prototype.resume = Consola.prototype.resumeLogs;
+
+ const TYPE_COLOR_MAP = {
+ 'info': 'cyan'
+ };
+ const LEVEL_COLOR_MAP = {
+ 0: 'red',
+ 1: 'yellow',
+ 2: 'white',
+ 3: 'green'
+ };
+
+ class BrowserReporter {
+ constructor(options) {
+ this.options = Object.assign({}, options);
+ }
+
+ log(logObj) {
+ // consoleLogFn
+ let consoleLogFn = console[logObj.type]; // eslint-disable-line no-console
+
+ if (!consoleLogFn) {
+ consoleLogFn = console[logObj.level < 2 ? 'error' : 'log']; // eslint-disable-line no-console
+ } // Type
+
+
+ const type = logObj.type.toUpperCase(); // Styles
+
+ const color = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level];
+ const styleColor = `color: ${color}; background-color: inherit;`;
+ const styleInherit = `color: inherit; background-color: inherit;`;
+ const styleAdditional = `color: ${logObj.additionalColor || 'grey'}; background-color: inherit;`; // Date
+
+ const date = new Date(logObj.date).toLocaleTimeString(); // Log to the console
+
+ consoleLogFn(`%c[${type}]%c[${date}]%c`, styleColor, styleAdditional, styleInherit, ...logObj.args);
+ }
+
+ }
+
+ if (!window.consola) {
+ // Create new consola instance
+ window.consola = new Consola({
+ reporters: [new BrowserReporter()]
+ });
+ }
+
+ var browser = window.consola;
+
+ return browser;
+
+})));