Initial import with skill sheet working
This commit is contained in:
81
node_modules/gulp-cli/lib/shared/log/copy-tree.js
generated
vendored
Normal file
81
node_modules/gulp-cli/lib/shared/log/copy-tree.js
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
'use strict';
|
||||
|
||||
function copyNode(node) {
|
||||
var newNode = {};
|
||||
Object.keys(node).forEach(function(key) {
|
||||
newNode[key] = node[key];
|
||||
});
|
||||
return newNode;
|
||||
}
|
||||
|
||||
var defaultNodeFactory = {
|
||||
topNode: copyNode,
|
||||
taskNode: copyNode,
|
||||
childNode: copyNode,
|
||||
};
|
||||
|
||||
function copyTree(tree, opts, nodeFactory) {
|
||||
opts = opts || {};
|
||||
|
||||
var depth = opts.tasksDepth;
|
||||
depth = typeof depth === 'number' ? ((depth < 1) ? 1 : depth) : null;
|
||||
|
||||
nodeFactory = nodeFactory || defaultNodeFactory;
|
||||
|
||||
var newTree = nodeFactory.topNode(tree);
|
||||
newTree.nodes = [];
|
||||
|
||||
if (Array.isArray(tree.nodes)) {
|
||||
tree.nodes.forEach(visit);
|
||||
}
|
||||
|
||||
function visit(node) {
|
||||
var newNode = nodeFactory.taskNode(node);
|
||||
newNode.nodes = [];
|
||||
newTree.nodes.push(newNode);
|
||||
|
||||
if (opts.compactTasks) {
|
||||
forEach(node.nodes, copyNotRecursively, newNode);
|
||||
|
||||
} else if (!depth || depth > 1) {
|
||||
forEach(node.nodes, copyRecursively, depth, 2, newNode);
|
||||
}
|
||||
}
|
||||
|
||||
function copyNotRecursively(child, newParent) {
|
||||
var newChild = nodeFactory.childNode(child);
|
||||
newChild.nodes = [];
|
||||
newParent.nodes.push(newChild);
|
||||
|
||||
if (child.branch) {
|
||||
forEach(child.nodes, copyNotRecursively, newChild);
|
||||
}
|
||||
}
|
||||
|
||||
function copyRecursively(child, maxDepth, nowDepth, newParent) {
|
||||
var newChild = nodeFactory.childNode(child);
|
||||
newChild.nodes = [];
|
||||
newParent.nodes.push(newChild);
|
||||
|
||||
if (!maxDepth || maxDepth > nowDepth) {
|
||||
forEach(child.nodes, copyRecursively, maxDepth, nowDepth + 1, newChild);
|
||||
}
|
||||
}
|
||||
|
||||
return newTree;
|
||||
}
|
||||
|
||||
function forEach(nodes, fn) {
|
||||
if (!Array.isArray(nodes)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var args = Array.prototype.slice.call(arguments, 2);
|
||||
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
fn.apply(nodes[i], [nodes[i]].concat(args));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = copyTree;
|
||||
|
48
node_modules/gulp-cli/lib/shared/log/format-hrtime.js
generated
vendored
Normal file
48
node_modules/gulp-cli/lib/shared/log/format-hrtime.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
var units = [
|
||||
[ 'h', 3600e9 ],
|
||||
[ 'min', 60e9 ],
|
||||
[ 's', 1e9 ],
|
||||
[ 'ms', 1e6 ],
|
||||
[ 'μs', 1e3 ],
|
||||
];
|
||||
|
||||
function formatHrTime(hrtime) {
|
||||
if (!Array.isArray(hrtime) || hrtime.length !== 2) {
|
||||
return '';
|
||||
}
|
||||
if (typeof hrtime[0] !== 'number' || typeof hrtime[1] !== 'number') {
|
||||
return '';
|
||||
}
|
||||
|
||||
var nano = hrtime[0] * 1e9 + hrtime[1];
|
||||
|
||||
for (var i = 0; i < units.length; i++) {
|
||||
if (nano < units[i][1]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nano >= units[i][1] * 10) {
|
||||
return Math.round(nano / units[i][1]) + ' ' + units[i][0];
|
||||
}
|
||||
|
||||
var s = String(Math.round(nano * 1e2 / units[i][1]));
|
||||
if (s.slice(-2) === '00') {
|
||||
s = s.slice(0, -2);
|
||||
} else if (s.slice(-1) === '0') {
|
||||
s = s.slice(0, -2) + '.' + s.slice(-2, -1);
|
||||
} else {
|
||||
s = s.slice(0, -2) + '.' + s.slice(-2);
|
||||
}
|
||||
return s + ' ' + units[i][0];
|
||||
}
|
||||
|
||||
if (nano > 0) {
|
||||
return nano + ' ns';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
module.exports = formatHrTime;
|
171
node_modules/gulp-cli/lib/shared/log/tasks.js
generated
vendored
Normal file
171
node_modules/gulp-cli/lib/shared/log/tasks.js
generated
vendored
Normal file
@ -0,0 +1,171 @@
|
||||
'use strict';
|
||||
|
||||
var stringWidth = require('string-width');
|
||||
var messages = require('@gulpjs/messages');
|
||||
|
||||
var isObject = require('../is-object');
|
||||
|
||||
function logTasks(tree, opts, getTask, translate) {
|
||||
if (opts.sortTasks) {
|
||||
tree.nodes = tree.nodes.sort(compareByLabel);
|
||||
}
|
||||
|
||||
var maxDepth = opts.tasksDepth;
|
||||
if (typeof maxDepth !== 'number') {
|
||||
maxDepth = 50;
|
||||
} else if (maxDepth < 1) {
|
||||
maxDepth = 1;
|
||||
}
|
||||
|
||||
var compactedTasks = opts.compactTasks ? tree.nodes : [];
|
||||
|
||||
var treeOpts = {
|
||||
maxDepth: maxDepth,
|
||||
compactedTasks: compactedTasks,
|
||||
getTask: getTask,
|
||||
};
|
||||
|
||||
printTaskTree(tree, treeOpts);
|
||||
|
||||
function printTaskTree(tree, opts) {
|
||||
var lines = [];
|
||||
lines.push({ label: tree.label });
|
||||
var maxLabelWidth = 0;
|
||||
|
||||
tree.nodes.forEach(function(node, idx, arr) {
|
||||
var isLast = idx === arr.length - 1;
|
||||
var w = createTreeLines(node, lines, opts, 1, '', isLast);
|
||||
maxLabelWidth = Math.max(maxLabelWidth, w);
|
||||
});
|
||||
|
||||
lines.forEach(function(line) {
|
||||
var s = line.label;
|
||||
if (line.desc) {
|
||||
var spaces = ' '.repeat(maxLabelWidth - line.width) + ' ';
|
||||
s += spaces + line.desc;
|
||||
}
|
||||
if (s) {
|
||||
// We don't need timestamps here
|
||||
console.log(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createTreeLines(node, lines, opts, depth, bars, isLast) {
|
||||
var task = { label: node.label, bars: bars, depth: depth };
|
||||
if (depth === 1) {
|
||||
var t = opts.getTask(node.label);
|
||||
task.desc = t.description;
|
||||
task.flags = t.flags;
|
||||
}
|
||||
|
||||
var isLeaf = isLeafNode(node, depth, opts);
|
||||
|
||||
var maxLabelWidth = addTaskToLines(task, lines, isLast, isLeaf);
|
||||
|
||||
if (!isLeaf) {
|
||||
bars += (isLast ? ' ' : translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_VERTICAL }));
|
||||
bars += ' '
|
||||
node.nodes.forEach(function(node, idx, arr) {
|
||||
var isLast = idx === arr.length - 1;
|
||||
createTreeLines(node, lines, opts, depth + 1, bars, isLast);
|
||||
});
|
||||
}
|
||||
|
||||
return maxLabelWidth;
|
||||
}
|
||||
|
||||
function addTaskToLines(task, lines, isLast, isLeaf) {
|
||||
var taskBars = task.bars + (isLast
|
||||
? translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_UP_AND_RIGHT })
|
||||
: translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_VERTICAL_AND_RIGHT })) +
|
||||
translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_HORIZONTAL });
|
||||
if (isLeaf) {
|
||||
taskBars += translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_HORIZONTAL });
|
||||
} else {
|
||||
taskBars += translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_DOWN_AND_HORIZONTAL });
|
||||
}
|
||||
taskBars += ' ';
|
||||
|
||||
var line = {};
|
||||
if (task.depth === 1) {
|
||||
line.label = taskBars + translate.message({ tag: messages.TASK_NAME, name: task.label });
|
||||
} else {
|
||||
line.label = taskBars + translate.message({ tag: messages.TASK_NAME, name: task.label });
|
||||
}
|
||||
line.width = stringWidth(line.label);
|
||||
|
||||
if (typeof task.desc === 'string' && task.desc) {
|
||||
line.desc = translate.message({ tag: messages.TASK_DESCRIPTION, description: task.desc });
|
||||
}
|
||||
lines.push(line);
|
||||
|
||||
var maxLabelWidth = line.width;
|
||||
|
||||
if (!isObject(task.flags)) {
|
||||
return maxLabelWidth;
|
||||
}
|
||||
|
||||
var flagBars = task.bars;
|
||||
if (isLast) {
|
||||
flagBars += ' ';
|
||||
} else {
|
||||
flagBars += translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_VERTICAL });
|
||||
}
|
||||
flagBars += ' ';
|
||||
|
||||
if (isLeaf) {
|
||||
flagBars += ' ';
|
||||
} else {
|
||||
flagBars += translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_VERTICAL });
|
||||
}
|
||||
flagBars += ' ';
|
||||
|
||||
Object.entries(task.flags).sort(flagSorter).forEach(addFlagsToLines);
|
||||
|
||||
function addFlagsToLines(ent) {
|
||||
if (typeof ent[0] !== 'string' || !ent[0]) return;
|
||||
var line = {};
|
||||
line.label = flagBars + translate.message({ tag: messages.TASK_FLAG, flag: ent[0] });
|
||||
line.width = stringWidth(line.label);
|
||||
|
||||
maxLabelWidth = Math.max(maxLabelWidth, line.width);
|
||||
|
||||
if (typeof ent[1] === 'string' && ent[1] !== '') {
|
||||
line.desc = translate.message({ tag: messages.TASK_FLAG_DESCRIPTION, description: ent[1] });
|
||||
}
|
||||
lines.push(line);
|
||||
}
|
||||
|
||||
return maxLabelWidth;
|
||||
}
|
||||
}
|
||||
|
||||
function isLeafNode(node, depth, opts) {
|
||||
if (depth >= opts.maxDepth) {
|
||||
return true;
|
||||
} else if (depth > 1 && opts.compactedTasks.includes(node)) {
|
||||
return true;
|
||||
} else if (!Array.isArray(node.nodes) || node.nodes.length === 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function compareByLabel(a, b) {
|
||||
/* istanbul ignore if */
|
||||
if (!b.label) {
|
||||
return -1;
|
||||
} else /* istanbul ignore if */ if (!a.label) {
|
||||
return 1;
|
||||
} else {
|
||||
return (a.label <= b.label) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
function flagSorter(a, b) {
|
||||
return (a[0] <= b[0]) ? -1 : 1;
|
||||
}
|
||||
|
||||
module.exports = logTasks;
|
||||
|
135
node_modules/gulp-cli/lib/shared/log/to-console.js
generated
vendored
Normal file
135
node_modules/gulp-cli/lib/shared/log/to-console.js
generated
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
'use strict';
|
||||
|
||||
var messages = require('@gulpjs/messages');
|
||||
|
||||
/* istanbul ignore next */
|
||||
function noop() {}
|
||||
|
||||
function toConsole(log, opts, translate) {
|
||||
// Return immediately if logging is
|
||||
// not desired.
|
||||
if (opts.tasksSimple || opts.tasksJson || opts.help || opts.version || opts.silent) {
|
||||
// Keep from crashing process when silent.
|
||||
log.on('error', noop);
|
||||
return function () {
|
||||
log.removeListener('error', noop);
|
||||
};
|
||||
}
|
||||
|
||||
// Default loglevel to info level (3).
|
||||
var loglevel = opts.logLevel || 3;
|
||||
|
||||
var deprecatedPrinted = false;
|
||||
log.on('deprecated', onDeprecated);
|
||||
|
||||
// -L: Logs error events.
|
||||
if (loglevel > 0) {
|
||||
log.on('error', onError);
|
||||
}
|
||||
|
||||
// -LL: Logs warn and error events.
|
||||
if (loglevel > 1) {
|
||||
log.on('warn', onWarn);
|
||||
}
|
||||
|
||||
// -LLL: Logs info, warn and error events.
|
||||
if (loglevel > 2) {
|
||||
log.on('info', onInfo);
|
||||
}
|
||||
|
||||
if (loglevel > 3) {
|
||||
log.on('debug', onDebug);
|
||||
}
|
||||
|
||||
return function () {
|
||||
log.removeListener('deprecated', onDeprecated);
|
||||
log.removeListener('error', onError);
|
||||
log.removeListener('warn', onWarn);
|
||||
log.removeListener('info', onInfo);
|
||||
log.removeListener('debug', onDebug);
|
||||
};
|
||||
|
||||
function onDeprecated() {
|
||||
if (!deprecatedPrinted) {
|
||||
var msg = { tag: messages.GULPLOG_DEPRECATED };
|
||||
// Get message and timestamp before printing anything to avoid
|
||||
// logging a half message if there's an error in one of them
|
||||
var message = translate.message(msg);
|
||||
var timestamp = translate.timestamp(msg);
|
||||
|
||||
if (message) {
|
||||
// Ensure timestamp is not written without a message
|
||||
if (timestamp) {
|
||||
process.stderr.write(timestamp + ' ');
|
||||
}
|
||||
console.error(message);
|
||||
}
|
||||
|
||||
deprecatedPrinted = true;
|
||||
}
|
||||
}
|
||||
|
||||
function onError(msg) {
|
||||
// Get message and timestamp before printing anything to avoid
|
||||
// logging a half message if there's an error in one of them
|
||||
var message = translate.message(msg);
|
||||
var timestamp = translate.timestamp(msg);
|
||||
|
||||
if (message) {
|
||||
// Ensure timestamp is not written without a message
|
||||
if (timestamp) {
|
||||
process.stderr.write(timestamp + ' ');
|
||||
}
|
||||
console.error(message);
|
||||
}
|
||||
}
|
||||
|
||||
// onWarn, onInfo, and onDebug are currently all the same
|
||||
// implementation but separated to change independently
|
||||
function onWarn(msg) {
|
||||
// Get message and timestamp before printing anything to avoid
|
||||
// logging a half message if there's an error in one of them
|
||||
var message = translate.message(msg);
|
||||
var timestamp = translate.timestamp(msg);
|
||||
|
||||
if (message) {
|
||||
// Ensure timestamp is not written without a message
|
||||
if (timestamp) {
|
||||
process.stdout.write(timestamp + ' ');
|
||||
}
|
||||
console.log(message);
|
||||
}
|
||||
}
|
||||
|
||||
function onInfo(msg) {
|
||||
// Get message and timestamp before printing anything to avoid
|
||||
// logging a half message if there's an error in one of them
|
||||
var message = translate.message(msg);
|
||||
var timestamp = translate.timestamp(msg);
|
||||
|
||||
if (message) {
|
||||
// Ensure timestamp is not written without a message
|
||||
if (timestamp) {
|
||||
process.stdout.write(timestamp + ' ');
|
||||
}
|
||||
console.log(message);
|
||||
}
|
||||
}
|
||||
|
||||
function onDebug(msg) {
|
||||
// Get message and timestamp before printing anything to avoid
|
||||
// logging a half message if there's an error in one of them
|
||||
var message = translate.message(msg);
|
||||
var timestamp = translate.timestamp(msg);
|
||||
|
||||
if (message) {
|
||||
// Ensure timestamp is not written without a message
|
||||
if (timestamp) {
|
||||
process.stdout.write(timestamp + ' ');
|
||||
}
|
||||
console.log(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = toConsole;
|
Reference in New Issue
Block a user