aboutsummaryrefslogtreecommitdiff
path: root/node_modules/webpackbar/dist
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/webpackbar/dist')
-rw-r--r--node_modules/webpackbar/dist/cjs.js3
-rw-r--r--node_modules/webpackbar/dist/description.js42
-rw-r--r--node_modules/webpackbar/dist/index.js189
-rw-r--r--node_modules/webpackbar/dist/options.json9
-rw-r--r--node_modules/webpackbar/dist/profile.js77
-rw-r--r--node_modules/webpackbar/dist/utils.js144
6 files changed, 464 insertions, 0 deletions
diff --git a/node_modules/webpackbar/dist/cjs.js b/node_modules/webpackbar/dist/cjs.js
new file mode 100644
index 00000000..61cc3574
--- /dev/null
+++ b/node_modules/webpackbar/dist/cjs.js
@@ -0,0 +1,3 @@
+'use strict';
+
+module.exports = require('./index').default; \ No newline at end of file
diff --git a/node_modules/webpackbar/dist/description.js b/node_modules/webpackbar/dist/description.js
new file mode 100644
index 00000000..c56f1503
--- /dev/null
+++ b/node_modules/webpackbar/dist/description.js
@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = getDescription;
+
+var _lodash = require('lodash');
+
+var _lodash2 = _interopRequireDefault(_lodash);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+const DB = {
+ loader: {
+ get: loader => _lodash2.default.startCase(loader)
+ },
+ ext: {
+ get: ext => `${ext} files`,
+ vue: 'Vue Single File components',
+ js: 'JavaScript files',
+ sass: 'SASS files',
+ scss: 'SASS files',
+ unknown: 'Unknown files'
+ }
+};
+
+function getDescription(category, keyword) {
+ if (!DB[category]) {
+ return _lodash2.default.startCase(keyword);
+ }
+
+ if (DB[category][keyword]) {
+ return DB[category][keyword];
+ }
+
+ if (DB[category].get) {
+ return DB[category].get(keyword);
+ }
+
+ return '-';
+} \ No newline at end of file
diff --git a/node_modules/webpackbar/dist/index.js b/node_modules/webpackbar/dist/index.js
new file mode 100644
index 00000000..6c834442
--- /dev/null
+++ b/node_modules/webpackbar/dist/index.js
@@ -0,0 +1,189 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _webpack = require('webpack');
+
+var _webpack2 = _interopRequireDefault(_webpack);
+
+var _chalk = require('chalk');
+
+var _chalk2 = _interopRequireDefault(_chalk);
+
+var _lodash = require('lodash');
+
+var _lodash2 = _interopRequireDefault(_lodash);
+
+var _logUpdate = require('log-update');
+
+var _logUpdate2 = _interopRequireDefault(_logUpdate);
+
+var _stdEnv = require('std-env');
+
+var _stdEnv2 = _interopRequireDefault(_stdEnv);
+
+var _consola = require('consola');
+
+var _consola2 = _interopRequireDefault(_consola);
+
+var _prettyTime = require('pretty-time');
+
+var _prettyTime2 = _interopRequireDefault(_prettyTime);
+
+var _profile = require('./profile');
+
+var _profile2 = _interopRequireDefault(_profile);
+
+var _utils = require('./utils');
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+const sharedState = {};
+
+const defaults = {
+ name: 'webpack',
+ color: 'green',
+ profile: false,
+ compiledIn: true,
+ done: null,
+ minimal: _stdEnv2.default.minimalCLI,
+ stream: null
+};
+
+const hasRunning = () => Object.values(sharedState).find(s => s.isRunning);
+
+const $logUpdate = _logUpdate2.default.create(process.stderr, {
+ showCursor: false
+});
+
+class WebpackBarPlugin extends _webpack2.default.ProgressPlugin {
+ constructor(options) {
+ super();
+
+ this.options = Object.assign({}, defaults, options);
+
+ // this.handler will be called by webpack.ProgressPlugin
+ this.handler = (percent, msg, ...details) => this.updateProgress(percent, msg, details);
+
+ this._render = _lodash2.default.throttle(this.render, 100);
+
+ this.logUpdate = this.options.logUpdate || $logUpdate;
+
+ if (!this.state) {
+ sharedState[this.options.name] = {
+ isRunning: false,
+ color: this.options.color,
+ profile: this.options.profile ? new _profile2.default(this.options.name) : null
+ };
+ }
+ }
+
+ get state() {
+ return sharedState[this.options.name];
+ }
+
+ get stream() {
+ return this.options.stream || process.stderr;
+ }
+
+ apply(compiler) {
+ super.apply(compiler);
+
+ const hook = stats => {
+ this.state.stats = stats;
+ if (!hasRunning()) {
+ this.logUpdate.clear();
+ this.done();
+ }
+ };
+
+ if (compiler.hooks) {
+ compiler.hooks.done.tap('WebpackBar', hook);
+ } else {
+ compiler.plugin('done', hook);
+ }
+ }
+
+ done() {
+ if (this.options.profile) {
+ const stats = this.state.profile.getStats();
+ const statsStr = (0, _utils.formatStats)(stats);
+ this.stream.write(`\n${statsStr}\n`);
+ }
+
+ if (typeof this.options.done === 'function') {
+ this.options.done(sharedState, this);
+ }
+ }
+
+ updateProgress(percent, msg, details) {
+ const progress = Math.floor(percent * 100);
+ const isRunning = progress < 100;
+
+ const wasRunning = this.state.isRunning;
+
+ Object.assign(this.state, {
+ progress,
+ msg: isRunning && msg ? msg : '',
+ details: details || [],
+ request: (0, _utils.parseRequst)(details[2]),
+ isRunning
+ });
+
+ if (!wasRunning && isRunning) {
+ // Started
+ delete this.state.stats;
+ this.state.start = process.hrtime();
+ if (this.options.minimal) {
+ _consola2.default.info(`Compiling ${this.options.name}`);
+ }
+ } else if (wasRunning && !isRunning) {
+ // Finished
+ const time = process.hrtime(this.state.start);
+ if (this.options.minimal) {
+ _consola2.default.success(`Compiled ${this.options.name} in ${(0, _prettyTime2.default)(time)}`);
+ } else {
+ this.logUpdate.clear();
+ if (this.options.compiledIn) {
+ _consola2.default.success(`${this.options.name} compiled in ${(0, _prettyTime2.default)(time, 'ms')}`);
+ }
+ }
+ delete this.state.start;
+ }
+
+ if (this.options.profile) {
+ this.state.profile.onRequest(this.state.request);
+ }
+
+ this._render();
+ }
+
+ render() {
+ if (this.options.minimal) {
+ return;
+ }
+
+ const columns = this.stream.columns || 80;
+
+ const stateLines = _lodash2.default.sortBy(Object.keys(sharedState), n => n).map(name => {
+ const state = sharedState[name];
+ const color = (0, _utils.colorize)(state.color);
+
+ if (!state.isRunning) {
+ const color2 = state.progress === 100 ? color : _chalk2.default.grey;
+ return color2(`${_utils.BULLET} ${name}\n`);
+ }
+
+ return `${[color(_utils.BULLET), color(name), (0, _utils.renderBar)(state.progress, state.color), state.msg, `(${state.progress || 0}%)`, _chalk2.default.grey(state.details && state.details[0] || ''), _chalk2.default.grey(state.details && state.details[1] || '')].join(' ')}\n ${state.request ? _chalk2.default.grey((0, _utils.elipsesLeft)((0, _utils.formatRequest)(state.request), columns - 2)) : ''}\n`;
+ });
+
+ if (hasRunning()) {
+ const title = _chalk2.default.underline.blue('Compiling');
+ const log = `\n${title}\n\n${stateLines.join('\n')}`;
+ this.logUpdate(log);
+ }
+ }
+}
+exports.default = WebpackBarPlugin; \ No newline at end of file
diff --git a/node_modules/webpackbar/dist/options.json b/node_modules/webpackbar/dist/options.json
new file mode 100644
index 00000000..066dc78c
--- /dev/null
+++ b/node_modules/webpackbar/dist/options.json
@@ -0,0 +1,9 @@
+{
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "boolean"
+ }
+ },
+ "additionalProperties": false
+}
diff --git a/node_modules/webpackbar/dist/profile.js b/node_modules/webpackbar/dist/profile.js
new file mode 100644
index 00000000..15825568
--- /dev/null
+++ b/node_modules/webpackbar/dist/profile.js
@@ -0,0 +1,77 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _path = require('path');
+
+var _path2 = _interopRequireDefault(_path);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+class Profile {
+ constructor(name) {
+ this.name = name;
+ this.requests = [];
+ }
+
+ onRequest(request) {
+ // Measure time for last request
+ if (this.requests.length) {
+ const lastReq = this.requests[this.requests.length - 1];
+ if (lastReq.start) {
+ lastReq.time = process.hrtime(lastReq.start);
+ delete lastReq.start;
+ }
+ }
+
+ // Ignore requests without any file or loaders
+ if (!request.file || !request.loaders.length) {
+ return;
+ }
+
+ this.requests.push({
+ request,
+ start: process.hrtime()
+ });
+ }
+
+ getStats() {
+ const loaderStats = {};
+ const extStats = {};
+
+ const getStat = (stats, name) => {
+ if (!stats[name]) {
+ // eslint-disable-next-line no-param-reassign
+ stats[name] = {
+ count: 0,
+ time: [0, 0]
+ };
+ }
+ return stats[name];
+ };
+
+ const addToStat = (stats, name, count, time) => {
+ const stat = getStat(stats, name);
+ stat.count += count;
+ stat.time[0] += time[0];
+ stat.time[1] += time[1];
+ };
+
+ this.requests.forEach(({ request, time = [0, 0] }) => {
+ request.loaders.forEach(loader => {
+ addToStat(loaderStats, loader, 1, time);
+ });
+
+ const ext = request.file && _path2.default.extname(request.file).substr(1);
+ addToStat(extStats, ext && ext.length ? ext : 'unknown', 1, time);
+ });
+
+ return {
+ ext: extStats,
+ loader: loaderStats
+ };
+ }
+}
+exports.default = Profile; \ No newline at end of file
diff --git a/node_modules/webpackbar/dist/utils.js b/node_modules/webpackbar/dist/utils.js
new file mode 100644
index 00000000..fbf23762
--- /dev/null
+++ b/node_modules/webpackbar/dist/utils.js
@@ -0,0 +1,144 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.formatStats = exports.formatRequest = exports.parseRequst = exports.renderBar = exports.colorize = exports.TICK = exports.BULLET = undefined;
+exports.elipses = elipses;
+exports.elipsesLeft = elipsesLeft;
+
+var _path = require('path');
+
+var _path2 = _interopRequireDefault(_path);
+
+var _chalk = require('chalk');
+
+var _chalk2 = _interopRequireDefault(_chalk);
+
+var _lodash = require('lodash');
+
+var _lodash2 = _interopRequireDefault(_lodash);
+
+var _figures = require('figures');
+
+var _figures2 = _interopRequireDefault(_figures);
+
+var _table = require('table');
+
+var _prettyTime = require('pretty-time');
+
+var _prettyTime2 = _interopRequireDefault(_prettyTime);
+
+var _description = require('./description');
+
+var _description2 = _interopRequireDefault(_description);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+const BAR_LENGTH = 25;
+const BLOCK_CHAR = '█';
+const BLOCK_CHAR2 = '█';
+const NEXT = _chalk2.default.blue((0, _figures2.default)(' › '));
+
+const BULLET = exports.BULLET = (0, _figures2.default)('●');
+const TICK = exports.TICK = _chalk2.default.green((0, _figures2.default)('✔'));
+
+const colorize = exports.colorize = color => {
+ if (color[0] === '#') {
+ return _chalk2.default.hex(color);
+ }
+
+ return _chalk2.default[color] || _chalk2.default.keyword(color);
+};
+
+const renderBar = exports.renderBar = (progress, color) => {
+ const w = progress * (BAR_LENGTH / 100);
+ const bg = _chalk2.default.white(BLOCK_CHAR);
+ const fg = colorize(color)(BLOCK_CHAR2);
+
+ return _lodash2.default.range(BAR_LENGTH).map(i => i < w ? fg : bg).join('');
+};
+
+const hasValue = s => s && s.length;
+
+const nodeModules = `${_path2.default.delimiter}node_modules${_path2.default.delimiter}`;
+const removeAfter = (delimiter, str) => _lodash2.default.first(str.split(delimiter));
+const removeBefore = (delimiter, str) => _lodash2.default.last(str.split(delimiter));
+
+const firstMatch = (regex, str) => {
+ const m = regex.exec(str);
+ return m ? m[0] : null;
+};
+
+const parseRequst = exports.parseRequst = requestStr => {
+ const parts = (requestStr || '').split('!');
+
+ const file = _path2.default.relative(process.cwd(), removeAfter('?', removeBefore(nodeModules, parts.pop())));
+
+ const loaders = parts.map(part => firstMatch(/[a-z0-9-@]+-loader/, part)).filter(hasValue);
+
+ return {
+ file: hasValue(file) ? file : null,
+ loaders
+ };
+};
+
+const formatRequest = exports.formatRequest = request => {
+ const loaders = request.loaders.join(NEXT);
+
+ if (!loaders.length) {
+ return request.file || '';
+ }
+
+ return `${loaders}${NEXT}${request.file}`;
+};
+
+const formatStats = exports.formatStats = allStats => {
+ const lines = [];
+
+ Object.keys(allStats).forEach(category => {
+ const stats = allStats[category];
+
+ lines.push(`Stats by ${_chalk2.default.bold(_lodash2.default.startCase(category))}`);
+
+ let totalRequests = 0;
+ const totalTime = [0, 0];
+
+ const data = [[_lodash2.default.startCase(category), 'Requests', 'Time', 'Time/Request', 'Description']];
+
+ Object.keys(stats).forEach(item => {
+ const stat = stats[item];
+
+ totalRequests += stat.count || 0;
+
+ const description = (0, _description2.default)(category, item);
+
+ totalTime[0] += stat.time[0];
+ totalTime[1] += stat.time[1];
+
+ const avgTime = [stat.time[0] / stat.count, stat.time[1] / stat.count];
+
+ data.push([item, stat.count || '-', (0, _prettyTime2.default)(stat.time), (0, _prettyTime2.default)(avgTime), description]);
+ });
+
+ data.push(['Total', totalRequests, (0, _prettyTime2.default)(totalTime), '', '']);
+
+ lines.push((0, _table.table)(data));
+ });
+
+ return lines.join('\n\n');
+};
+
+function elipses(str, n) {
+ if (str.length <= n - 3) {
+ return str;
+ }
+ return `${str.substr(0, n - 1)}...`;
+}
+
+function elipsesLeft(str, n) {
+ if (str.length <= n - 3) {
+ return str;
+ }
+ return `...${str.substr(str.length - n - 1)}`;
+} \ No newline at end of file