diff --git a/node_modules/npmlog/log.js b/node_modules/npmlog/log.js index 069154262e4d..85ab8a4c7905 100644 --- a/node_modules/npmlog/log.js +++ b/node_modules/npmlog/log.js @@ -13,8 +13,9 @@ var stream = process.stderr Object.defineProperty(log, 'stream', { set: function (newStream) { stream = newStream - if (this.gauge) + if (this.gauge) { this.gauge.setWriteTo(stream, stream) + } }, get: function () { return stream @@ -78,20 +79,23 @@ log.setGaugeTemplate = function (template) { } log.enableProgress = function () { - if (this.progressEnabled) + if (this.progressEnabled) { return + } this.progressEnabled = true this.tracker.on('change', this.showProgress) - if (this._paused) + if (this._paused) { return + } this.gauge.enable() } log.disableProgress = function () { - if (!this.progressEnabled) + if (!this.progressEnabled) { return + } this.progressEnabled = false this.tracker.removeListener('change', this.showProgress) this.gauge.disable() @@ -103,19 +107,23 @@ var mixinLog = function (tracker) { // mixin the public methods from log into the tracker // (except: conflicts and one's we handle specially) Object.keys(log).forEach(function (P) { - if (P[0] === '_') + if (P[0] === '_') { return + } if (trackerConstructors.filter(function (C) { return C === P - }).length) + }).length) { return + } - if (tracker[P]) + if (tracker[P]) { return + } - if (typeof log[P] !== 'function') + if (typeof log[P] !== 'function') { return + } var func = log[P] tracker[P] = function () { @@ -143,27 +151,31 @@ trackerConstructors.forEach(function (C) { }) log.clearProgress = function (cb) { - if (!this.progressEnabled) + if (!this.progressEnabled) { return cb && process.nextTick(cb) + } this.gauge.hide(cb) } log.showProgress = function (name, completed) { - if (!this.progressEnabled) + if (!this.progressEnabled) { return + } var values = {} - if (name) + if (name) { values.section = name + } var last = log.record[log.record.length - 1] if (last) { values.subsection = last.prefix var disp = log.disp[last.level] || last.level var logline = this._format(disp, log.style[last.level]) - if (last.prefix) + if (last.prefix) { logline += ' ' + this._format(last.prefix, this.prefixStyle) + } logline += ' ' + last.message.split(/\r?\n/)[0] values.logline = logline @@ -175,13 +187,15 @@ log.showProgress = function (name, completed) { // temporarily stop emitting, but don't drop log.pause = function () { this._paused = true - if (this.progressEnabled) + if (this.progressEnabled) { this.gauge.disable() + } } log.resume = function () { - if (!this._paused) + if (!this._paused) { return + } this._paused = false @@ -190,8 +204,9 @@ log.resume = function () { b.forEach(function (m) { this.emitLog(m) }, this) - if (this.progressEnabled) + if (this.progressEnabled) { this.gauge.enable() + } } log._buffer = [] @@ -220,8 +235,9 @@ log.log = function (lvl, prefix, message) { }) } } - if (stack) + if (stack) { a.unshift(stack + '\n') + } message = util.format.apply(util, a) var m = { @@ -234,8 +250,9 @@ log.log = function (lvl, prefix, message) { this.emit('log', m) this.emit('log.' + lvl, m) - if (m.prefix) + if (m.prefix) { this.emit(m.prefix, m) + } this.record.push(m) var mrs = this.maxRecordSize @@ -253,18 +270,22 @@ log.emitLog = function (m) { this._buffer.push(m) return } - if (this.progressEnabled) + if (this.progressEnabled) { this.gauge.pulse(m.prefix) + } var l = this.levels[m.level] - if (l === undefined) + if (l === undefined) { return + } - if (l < this.levels[this.level]) + if (l < this.levels[this.level]) { return + } - if (l > 0 && !isFinite(l)) + if (l > 0 && !isFinite(l)) { return + } // If 'disp' is null or undefined, use the lvl as a default // Allows: '', 0 as valid disp @@ -277,8 +298,9 @@ log.emitLog = function (m) { } this.write(disp, log.style[m.level]) var p = m.prefix || '' - if (p) + if (p) { this.write(' ') + } this.write(p, this.prefixStyle) this.write(' ' + line + '\n') @@ -287,52 +309,63 @@ log.emitLog = function (m) { } log._format = function (msg, style) { - if (!stream) + if (!stream) { return + } var output = '' if (this.useColor()) { style = style || {} var settings = [] - if (style.fg) + if (style.fg) { settings.push(style.fg) + } - if (style.bg) + if (style.bg) { settings.push('bg' + style.bg[0].toUpperCase() + style.bg.slice(1)) + } - if (style.bold) + if (style.bold) { settings.push('bold') + } - if (style.underline) + if (style.underline) { settings.push('underline') + } - if (style.inverse) + if (style.inverse) { settings.push('inverse') + } - if (settings.length) + if (settings.length) { output += consoleControl.color(settings) + } - if (style.beep) + if (style.beep) { output += consoleControl.beep() + } } output += msg - if (this.useColor()) + if (this.useColor()) { output += consoleControl.color('reset') + } return output } log.write = function (msg, style) { - if (!stream) + if (!stream) { return + } stream.write(this._format(msg, style)) } log.addLevel = function (lvl, n, style, disp) { // If 'disp' is null or undefined, use the lvl as a default - if (disp == null) + if (disp == null) { disp = lvl + } this.levels[lvl] = n this.style[lvl] = style @@ -340,8 +373,9 @@ log.addLevel = function (lvl, n, style, disp) { this[lvl] = function () { var a = new Array(arguments.length + 1) a[0] = lvl - for (var i = 0; i < arguments.length; i++) + for (var i = 0; i < arguments.length; i++) { a[i + 1] = arguments[i] + } return this.log.apply(this, a) }.bind(this) diff --git a/node_modules/npmlog/node_modules/are-we-there-yet/LICENSE.md b/node_modules/npmlog/node_modules/are-we-there-yet/LICENSE.md new file mode 100644 index 000000000000..845be76f64e7 --- /dev/null +++ b/node_modules/npmlog/node_modules/are-we-there-yet/LICENSE.md @@ -0,0 +1,18 @@ +ISC License + +Copyright npm, Inc. + +Permission to use, copy, modify, and/or distribute this +software for any purpose with or without fee is hereby +granted, provided that the above copyright notice and this +permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE +USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/npmlog/node_modules/are-we-there-yet/lib/index.js b/node_modules/npmlog/node_modules/are-we-there-yet/lib/index.js new file mode 100644 index 000000000000..57d8743fdad1 --- /dev/null +++ b/node_modules/npmlog/node_modules/are-we-there-yet/lib/index.js @@ -0,0 +1,4 @@ +'use strict' +exports.TrackerGroup = require('./tracker-group.js') +exports.Tracker = require('./tracker.js') +exports.TrackerStream = require('./tracker-stream.js') diff --git a/node_modules/npmlog/node_modules/are-we-there-yet/lib/tracker-base.js b/node_modules/npmlog/node_modules/are-we-there-yet/lib/tracker-base.js new file mode 100644 index 000000000000..6f436875578a --- /dev/null +++ b/node_modules/npmlog/node_modules/are-we-there-yet/lib/tracker-base.js @@ -0,0 +1,11 @@ +'use strict' +var EventEmitter = require('events').EventEmitter +var util = require('util') + +var trackerId = 0 +var TrackerBase = module.exports = function (name) { + EventEmitter.call(this) + this.id = ++trackerId + this.name = name +} +util.inherits(TrackerBase, EventEmitter) diff --git a/node_modules/npmlog/node_modules/are-we-there-yet/lib/tracker-group.js b/node_modules/npmlog/node_modules/are-we-there-yet/lib/tracker-group.js new file mode 100644 index 000000000000..9da13f8a7e11 --- /dev/null +++ b/node_modules/npmlog/node_modules/are-we-there-yet/lib/tracker-group.js @@ -0,0 +1,116 @@ +'use strict' +var util = require('util') +var TrackerBase = require('./tracker-base.js') +var Tracker = require('./tracker.js') +var TrackerStream = require('./tracker-stream.js') + +var TrackerGroup = module.exports = function (name) { + TrackerBase.call(this, name) + this.parentGroup = null + this.trackers = [] + this.completion = {} + this.weight = {} + this.totalWeight = 0 + this.finished = false + this.bubbleChange = bubbleChange(this) +} +util.inherits(TrackerGroup, TrackerBase) + +function bubbleChange (trackerGroup) { + return function (name, completed, tracker) { + trackerGroup.completion[tracker.id] = completed + if (trackerGroup.finished) { + return + } + trackerGroup.emit('change', name || trackerGroup.name, trackerGroup.completed(), trackerGroup) + } +} + +TrackerGroup.prototype.nameInTree = function () { + var names = [] + var from = this + while (from) { + names.unshift(from.name) + from = from.parentGroup + } + return names.join('/') +} + +TrackerGroup.prototype.addUnit = function (unit, weight) { + if (unit.addUnit) { + var toTest = this + while (toTest) { + if (unit === toTest) { + throw new Error( + 'Attempted to add tracker group ' + + unit.name + ' to tree that already includes it ' + + this.nameInTree(this)) + } + toTest = toTest.parentGroup + } + unit.parentGroup = this + } + this.weight[unit.id] = weight || 1 + this.totalWeight += this.weight[unit.id] + this.trackers.push(unit) + this.completion[unit.id] = unit.completed() + unit.on('change', this.bubbleChange) + if (!this.finished) { + this.emit('change', unit.name, this.completion[unit.id], unit) + } + return unit +} + +TrackerGroup.prototype.completed = function () { + if (this.trackers.length === 0) { + return 0 + } + var valPerWeight = 1 / this.totalWeight + var completed = 0 + for (var ii = 0; ii < this.trackers.length; ii++) { + var trackerId = this.trackers[ii].id + completed += + valPerWeight * this.weight[trackerId] * this.completion[trackerId] + } + return completed +} + +TrackerGroup.prototype.newGroup = function (name, weight) { + return this.addUnit(new TrackerGroup(name), weight) +} + +TrackerGroup.prototype.newItem = function (name, todo, weight) { + return this.addUnit(new Tracker(name, todo), weight) +} + +TrackerGroup.prototype.newStream = function (name, todo, weight) { + return this.addUnit(new TrackerStream(name, todo), weight) +} + +TrackerGroup.prototype.finish = function () { + this.finished = true + if (!this.trackers.length) { + this.addUnit(new Tracker(), 1, true) + } + for (var ii = 0; ii < this.trackers.length; ii++) { + var tracker = this.trackers[ii] + tracker.finish() + tracker.removeListener('change', this.bubbleChange) + } + this.emit('change', this.name, 1, this) +} + +var buffer = ' ' +TrackerGroup.prototype.debug = function (depth) { + depth = depth || 0 + var indent = depth ? buffer.substr(0, depth) : '' + var output = indent + (this.name || 'top') + ': ' + this.completed() + '\n' + this.trackers.forEach(function (tracker) { + if (tracker instanceof TrackerGroup) { + output += tracker.debug(depth + 1) + } else { + output += indent + ' ' + tracker.name + ': ' + tracker.completed() + '\n' + } + }) + return output +} diff --git a/node_modules/npmlog/node_modules/are-we-there-yet/lib/tracker-stream.js b/node_modules/npmlog/node_modules/are-we-there-yet/lib/tracker-stream.js new file mode 100644 index 000000000000..e1cf85055702 --- /dev/null +++ b/node_modules/npmlog/node_modules/are-we-there-yet/lib/tracker-stream.js @@ -0,0 +1,36 @@ +'use strict' +var util = require('util') +var stream = require('readable-stream') +var delegate = require('delegates') +var Tracker = require('./tracker.js') + +var TrackerStream = module.exports = function (name, size, options) { + stream.Transform.call(this, options) + this.tracker = new Tracker(name, size) + this.name = name + this.id = this.tracker.id + this.tracker.on('change', delegateChange(this)) +} +util.inherits(TrackerStream, stream.Transform) + +function delegateChange (trackerStream) { + return function (name, completion, tracker) { + trackerStream.emit('change', name, completion, trackerStream) + } +} + +TrackerStream.prototype._transform = function (data, encoding, cb) { + this.tracker.completeWork(data.length ? data.length : 1) + this.push(data) + cb() +} + +TrackerStream.prototype._flush = function (cb) { + this.tracker.finish() + cb() +} + +delegate(TrackerStream.prototype, 'tracker') + .method('completed') + .method('addWork') + .method('finish') diff --git a/node_modules/npmlog/node_modules/are-we-there-yet/lib/tracker.js b/node_modules/npmlog/node_modules/are-we-there-yet/lib/tracker.js new file mode 100644 index 000000000000..a8f8b3ba0139 --- /dev/null +++ b/node_modules/npmlog/node_modules/are-we-there-yet/lib/tracker.js @@ -0,0 +1,32 @@ +'use strict' +var util = require('util') +var TrackerBase = require('./tracker-base.js') + +var Tracker = module.exports = function (name, todo) { + TrackerBase.call(this, name) + this.workDone = 0 + this.workTodo = todo || 0 +} +util.inherits(Tracker, TrackerBase) + +Tracker.prototype.completed = function () { + return this.workTodo === 0 ? 0 : this.workDone / this.workTodo +} + +Tracker.prototype.addWork = function (work) { + this.workTodo += work + this.emit('change', this.name, this.completed(), this) +} + +Tracker.prototype.completeWork = function (work) { + this.workDone += work + if (this.workDone > this.workTodo) { + this.workDone = this.workTodo + } + this.emit('change', this.name, this.completed(), this) +} + +Tracker.prototype.finish = function () { + this.workTodo = this.workDone = 1 + this.emit('change', this.name, 1, this) +} diff --git a/node_modules/npmlog/node_modules/are-we-there-yet/package.json b/node_modules/npmlog/node_modules/are-we-there-yet/package.json new file mode 100644 index 000000000000..5714e09c3b37 --- /dev/null +++ b/node_modules/npmlog/node_modules/are-we-there-yet/package.json @@ -0,0 +1,53 @@ +{ + "name": "are-we-there-yet", + "version": "2.0.0", + "description": "Keep track of the overall completion of many disparate processes", + "main": "lib/index.js", + "scripts": { + "test": "tap", + "npmclilint": "npmcli-lint", + "lint": "eslint '**/*.js'", + "lintfix": "npm run lint -- --fix", + "posttest": "npm run lint", + "postsnap": "npm run lintfix --", + "preversion": "npm test", + "postversion": "npm publish", + "prepublishOnly": "git push origin --follow-tags", + "snap": "tap" + }, + "repository": { + "type": "git", + "url": "https://github.com/npm/are-we-there-yet.git" + }, + "author": "GitHub Inc.", + "license": "ISC", + "bugs": { + "url": "https://github.com/npm/are-we-there-yet/issues" + }, + "homepage": "https://github.com/npm/are-we-there-yet", + "devDependencies": { + "@npmcli/eslint-config": "^1.0.0", + "@npmcli/template-oss": "^1.0.2", + "eslint": "^7.32.0", + "eslint-plugin-node": "^11.1.0", + "tap": "^15.0.9" + }, + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + }, + "files": [ + "bin", + "lib" + ], + "engines": { + "node": ">=10" + }, + "tap": { + "branches": 68, + "statements": 92, + "functions": 86, + "lines": 92 + }, + "templateVersion": "1.0.2" +} diff --git a/node_modules/npmlog/package.json b/node_modules/npmlog/package.json index 5288b9ca0625..960ea9250d94 100644 --- a/node_modules/npmlog/package.json +++ b/node_modules/npmlog/package.json @@ -2,7 +2,7 @@ "author": "Isaac Z. Schlueter (http://blog.izs.me/)", "name": "npmlog", "description": "logger for npm", - "version": "5.0.0", + "version": "5.0.1", "repository": { "type": "git", "url": "https://github.com/npm/npmlog.git" @@ -20,7 +20,7 @@ "postsnap": "npm run lintfix --" }, "dependencies": { - "are-we-there-yet": "^1.1.5", + "are-we-there-yet": "^2.0.0", "console-control-strings": "^1.1.0", "gauge": "^3.0.0", "set-blocking": "^2.0.0" diff --git a/package-lock.json b/package-lock.json index 04dd0fe0c383..f6d1f71862d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -132,7 +132,7 @@ "npm-profile": "^5.0.3", "npm-registry-fetch": "^11.0.0", "npm-user-validate": "^1.0.1", - "npmlog": "^5.0.0", + "npmlog": "^5.0.1", "opener": "^1.5.2", "pacote": "^11.3.5", "parse-conflict-json": "^1.1.1", @@ -5567,17 +5567,30 @@ "inBundle": true }, "node_modules/npmlog": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.0.tgz", - "integrity": "sha512-ftpIiLjerL2tUg3dCqN8pOSoB90gqZlzv/gaZoxHaKjeLClrfJIEQ1Pdxi6qSzflz916Bljdy8dTWQ4J7hAFSQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", + "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==", "inBundle": true, "dependencies": { - "are-we-there-yet": "^1.1.5", + "are-we-there-yet": "^2.0.0", "console-control-strings": "^1.1.0", "gauge": "^3.0.0", "set-blocking": "^2.0.0" } }, + "node_modules/npmlog/node_modules/are-we-there-yet": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", + "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", + "inBundle": true, + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/null-check": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz", @@ -14560,14 +14573,25 @@ "integrity": "sha512-uQwcd/tY+h1jnEaze6cdX/LrhWhoBxfSknxentoqmIuStxUExxjWd3ULMLFPiFUrZKbOVMowH6Jq2FRWfmhcEw==" }, "npmlog": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.0.tgz", - "integrity": "sha512-ftpIiLjerL2tUg3dCqN8pOSoB90gqZlzv/gaZoxHaKjeLClrfJIEQ1Pdxi6qSzflz916Bljdy8dTWQ4J7hAFSQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", + "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==", "requires": { - "are-we-there-yet": "^1.1.5", + "are-we-there-yet": "^2.0.0", "console-control-strings": "^1.1.0", "gauge": "^3.0.0", "set-blocking": "^2.0.0" + }, + "dependencies": { + "are-we-there-yet": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", + "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + } + } } }, "null-check": { diff --git a/package.json b/package.json index f769d346ea47..1158e3b9d0d5 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,7 @@ "npm-profile": "^5.0.3", "npm-registry-fetch": "^11.0.0", "npm-user-validate": "^1.0.1", - "npmlog": "^5.0.0", + "npmlog": "^5.0.1", "opener": "^1.5.2", "pacote": "^11.3.5", "parse-conflict-json": "^1.1.1",