Skip to content

Commit

Permalink
deps: npmlog@6.0.0
Browse files Browse the repository at this point in the history
PR-URL: #4049
Credit: @wraithgar
Close: #4049
Reviewed-by: @fritzy
  • Loading branch information
wraithgar authored and fritzy committed Nov 18, 2021
1 parent 7b4aa59 commit 0801585
Show file tree
Hide file tree
Showing 41 changed files with 955 additions and 216 deletions.
13 changes: 0 additions & 13 deletions node_modules/gauge/LICENSE

This file was deleted.

20 changes: 20 additions & 0 deletions node_modules/gauge/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->

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.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ var progressBar = require('./progress-bar.js')

module.exports = {
activityIndicator: function (values, theme, width) {
if (values.spun == null) return
if (values.spun == null) {
return
}
return spin(theme, values.spun)
},
progressbar: function (values, theme, width) {
if (values.completed == null) return
if (values.completed == null) {
return
}
return progressBar(theme, width, values.completed)
}
},
}
45 changes: 45 additions & 0 deletions node_modules/gauge/lib/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var Gauge = require('./')
var gaugeDefault = require('./themes.js')
var onExit = require('signal-exit')

var activeGauge

onExit(function () {
activeGauge.disable()
})

var themes = gaugeDefault.getThemeNames()

nextBar()
function nextBar () {
var themeName = themes.shift()

console.log('Demoing output for ' + themeName)

var gt = new Gauge(process.stderr, {
updateInterval: 50,
theme: themeName,
cleanupOnExit: false,
})
activeGauge = gt

var progress = 0

var cnt = 0
var pulse = setInterval(function () {
gt.pulse('this is a thing that happened ' + (++cnt))
}, 110)
var prog = setInterval(function () {
progress += 0.04
gt.show(themeName + ':' + Math.round(progress * 1000), progress)
if (progress >= 1) {
clearInterval(prog)
clearInterval(pulse)
gt.disable()
if (themes.length) {
nextBar()
}
}
}, 100)
gt.show()
}
File renamed without changes.
File renamed without changes.
121 changes: 89 additions & 32 deletions node_modules/gauge/index.js → node_modules/gauge/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Gauge (arg1, arg2) {
this._status = {
spun: 0,
section: '',
subsection: ''
subsection: '',
}
this._paused = false // are we paused for back pressure?
this._disabled = true // are all progress bar updates disabled?
Expand All @@ -50,10 +50,10 @@ function Gauge (arg1, arg2) {
this._theme = options.theme
var theme = this._computeTheme(options.theme)
var template = options.template || [
{type: 'progressbar', length: 20},
{type: 'activityIndicator', kerning: 1, length: 1},
{type: 'section', kerning: 1, default: ''},
{type: 'subsection', kerning: 1, default: ''}
{ type: 'progressbar', length: 20 },
{ type: 'activityIndicator', kerning: 1, length: 1 },
{ type: 'section', kerning: 1, default: '' },
{ type: 'subsection', kerning: 1, default: '' },
]
this.setWriteTo(writeTo, options.tty)
var PlumbingClass = options.Plumbing || Plumbing
Expand All @@ -79,17 +79,28 @@ Gauge.prototype.isEnabled = function () {

Gauge.prototype.setTemplate = function (template) {
this._gauge.setTemplate(template)
if (this._showing) this._requestRedraw()
if (this._showing) {
this._requestRedraw()
}
}

Gauge.prototype._computeTheme = function (theme) {
if (!theme) theme = {}
if (!theme) {
theme = {}
}
if (typeof theme === 'string') {
theme = this._themes.getTheme(theme)
} else if (theme && (Object.keys(theme).length === 0 || theme.hasUnicode != null || theme.hasColor != null)) {
} else if (
theme &&
(Object.keys(theme).length === 0 || theme.hasUnicode != null || theme.hasColor != null)
) {
var useUnicode = theme.hasUnicode == null ? hasUnicode() : theme.hasUnicode
var useColor = theme.hasColor == null ? hasColor : theme.hasColor
theme = this._themes.getDefault({hasUnicode: useUnicode, hasColor: useColor, platform: theme.platform})
theme = this._themes.getDefault({
hasUnicode: useUnicode,
hasColor: useColor,
platform: theme.platform,
})
}
return theme
}
Expand All @@ -101,13 +112,17 @@ Gauge.prototype.setThemeset = function (themes) {

Gauge.prototype.setTheme = function (theme) {
this._gauge.setTheme(this._computeTheme(theme))
if (this._showing) this._requestRedraw()
if (this._showing) {
this._requestRedraw()
}
this._theme = theme
}

Gauge.prototype._requestRedraw = function () {
this._needsRedraw = true
if (!this._fixedFramerate) this._doRedraw()
if (!this._fixedFramerate) {
this._doRedraw()
}
}

Gauge.prototype.getWidth = function () {
Expand All @@ -116,33 +131,49 @@ Gauge.prototype.getWidth = function () {

Gauge.prototype.setWriteTo = function (writeTo, tty) {
var enabled = !this._disabled
if (enabled) this.disable()
if (enabled) {
this.disable()
}
this._writeTo = writeTo
this._tty = tty ||
(writeTo === process.stderr && process.stdout.isTTY && process.stdout) ||
(writeTo.isTTY && writeTo) ||
this._tty
if (this._gauge) this._gauge.setWidth(this.getWidth())
if (enabled) this.enable()
if (this._gauge) {
this._gauge.setWidth(this.getWidth())
}
if (enabled) {
this.enable()
}
}

Gauge.prototype.enable = function () {
if (!this._disabled) return
if (!this._disabled) {
return
}
this._disabled = false
if (this._tty) this._enableEvents()
if (this._showing) this.show()
if (this._tty) {
this._enableEvents()
}
if (this._showing) {
this.show()
}
}

Gauge.prototype.disable = function () {
if (this._disabled) return
if (this._disabled) {
return
}
if (this._showing) {
this._lastUpdateAt = null
this._showing = false
this._doRedraw()
this._showing = true
}
this._disabled = true
if (this._tty) this._disableEvents()
if (this._tty) {
this._disableEvents()
}
}

Gauge.prototype._enableEvents = function () {
Expand All @@ -152,19 +183,29 @@ Gauge.prototype._enableEvents = function () {
this._tty.on('resize', this._$$handleSizeChange)
if (this._fixedFramerate) {
this.redrawTracker = setInterval(this._$$doRedraw, this._updateInterval)
if (this.redrawTracker.unref) this.redrawTracker.unref()
if (this.redrawTracker.unref) {
this.redrawTracker.unref()
}
}
}

Gauge.prototype._disableEvents = function () {
this._tty.removeListener('resize', this._$$handleSizeChange)
if (this._fixedFramerate) clearInterval(this.redrawTracker)
if (this._removeOnExit) this._removeOnExit()
if (this._fixedFramerate) {
clearInterval(this.redrawTracker)
}
if (this._removeOnExit) {
this._removeOnExit()
}
}

Gauge.prototype.hide = function (cb) {
if (this._disabled) return cb && process.nextTick(cb)
if (!this._showing) return cb && process.nextTick(cb)
if (this._disabled) {
return cb && process.nextTick(cb)
}
if (!this._showing) {
return cb && process.nextTick(cb)
}
this._showing = false
this._doRedraw()
cb && setImmediate(cb)
Expand All @@ -181,16 +222,24 @@ Gauge.prototype.show = function (section, completed) {
this._status[key] = section[key]
}
}
if (completed != null) this._status.completed = completed
if (this._disabled) return
if (completed != null) {
this._status.completed = completed
}
if (this._disabled) {
return
}
this._requestRedraw()
}

Gauge.prototype.pulse = function (subsection) {
this._status.subsection = subsection || ''
this._status.spun++
if (this._disabled) return
if (!this._showing) return
if (this._disabled) {
return
}
if (!this._showing) {
return
}
this._requestRedraw()
}

Expand All @@ -200,10 +249,14 @@ Gauge.prototype._handleSizeChange = function () {
}

Gauge.prototype._doRedraw = function () {
if (this._disabled || this._paused) return
if (this._disabled || this._paused) {
return
}
if (!this._fixedFramerate) {
var now = Date.now()
if (this._lastUpdateAt && now - this._lastUpdateAt < this._updateInterval) return
if (this._lastUpdateAt && now - this._lastUpdateAt < this._updateInterval) {
return
}
this._lastUpdateAt = now
}
if (!this._showing && this._onScreen) {
Expand All @@ -214,15 +267,19 @@ Gauge.prototype._doRedraw = function () {
}
return this._writeTo.write(result)
}
if (!this._showing && !this._onScreen) return
if (!this._showing && !this._onScreen) {
return
}
if (this._showing && !this._onScreen) {
this._onScreen = true
this._needsRedraw = true
if (this._hideCursor) {
this._writeTo.write(this._gauge.hideCursor())
}
}
if (!this._needsRedraw) return
if (!this._needsRedraw) {
return
}
if (!this._writeTo.write(this._gauge.show(this._status))) {
this._paused = true
this._writeTo.on('drain', callWith(this, function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ var renderTemplate = require('./render-template.js')
var validate = require('aproba')

var Plumbing = module.exports = function (theme, template, width) {
if (!width) width = 80
if (!width) {
width = 80
}
validate('OAN', [theme, template, width])
this.showing = false
this.theme = theme
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ var stringWidth = require('string-width')

module.exports = function (theme, width, completed) {
validate('ONN', [theme, width, completed])
if (completed < 0) completed = 0
if (completed > 1) completed = 1
if (width <= 0) return ''
if (completed < 0) {
completed = 0
}
if (completed > 1) {
completed = 1
}
if (width <= 0) {
return ''
}
var sofar = Math.round(width * completed)
var rest = width - sofar
var template = [
{type: 'complete', value: repeat(theme.complete, sofar), length: sofar},
{type: 'remaining', value: repeat(theme.remaining, rest), length: rest}
{ type: 'complete', value: repeat(theme.complete, sofar), length: sofar },
{ type: 'remaining', value: repeat(theme.remaining, rest), length: rest },
]
return renderTemplate(width, template, theme)
}
Expand Down
Loading

0 comments on commit 0801585

Please sign in to comment.