@aws-solutions-constructs/core 2.50.0 → 2.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +2 -0
- package/.jsii +50 -5
- package/node_modules/ansi-regex/index.js +8 -2
- package/node_modules/ansi-regex/license +4 -16
- package/node_modules/ansi-regex/package.json +53 -62
- package/node_modules/ansi-regex/readme.md +48 -9
- package/node_modules/aproba/index.js +33 -33
- package/node_modules/aproba/package.json +5 -4
- package/node_modules/are-we-there-yet/LICENSE.md +18 -0
- package/node_modules/are-we-there-yet/README.md +16 -3
- package/node_modules/are-we-there-yet/lib/tracker-base.js +13 -0
- package/node_modules/are-we-there-yet/lib/tracker-group.js +112 -0
- package/node_modules/are-we-there-yet/lib/tracker-stream.js +42 -0
- package/node_modules/are-we-there-yet/lib/tracker.js +34 -0
- package/node_modules/are-we-there-yet/package.json +38 -20
- package/node_modules/color-support/README.md +129 -0
- package/node_modules/color-support/bin.js +3 -0
- package/node_modules/color-support/browser.js +14 -0
- package/node_modules/color-support/index.js +134 -0
- package/node_modules/color-support/package.json +36 -0
- package/node_modules/gauge/LICENSE.md +20 -0
- package/node_modules/gauge/README.md +19 -16
- package/node_modules/gauge/{base-theme.js → lib/base-theme.js} +7 -3
- package/node_modules/gauge/lib/has-color.js +4 -0
- package/node_modules/gauge/{index.js → lib/index.js} +90 -34
- package/node_modules/gauge/{plumbing.js → lib/plumbing.js} +3 -1
- package/node_modules/gauge/{progress-bar.js → lib/progress-bar.js} +12 -6
- package/node_modules/gauge/{render-template.js → lib/render-template.js} +69 -28
- package/node_modules/gauge/{template-item.js → lib/template-item.js} +21 -7
- package/node_modules/gauge/{theme-set.js → lib/theme-set.js} +31 -24
- package/node_modules/gauge/lib/themes.js +56 -0
- package/node_modules/gauge/{wide-truncate.js → lib/wide-truncate.js} +9 -3
- package/node_modules/gauge/package.json +47 -42
- package/node_modules/is-fullwidth-code-point/index.js +40 -36
- package/node_modules/is-fullwidth-code-point/license +4 -16
- package/node_modules/is-fullwidth-code-point/package.json +40 -43
- package/node_modules/is-fullwidth-code-point/readme.md +8 -8
- package/node_modules/npmlog/LICENSE.md +20 -0
- package/node_modules/npmlog/{log.js → lib/log.js} +149 -58
- package/node_modules/npmlog/package.json +36 -12
- package/node_modules/signal-exit/LICENSE.txt +1 -1
- package/node_modules/signal-exit/README.md +56 -21
- package/node_modules/signal-exit/dist/cjs/browser.d.ts +12 -0
- package/node_modules/signal-exit/dist/cjs/browser.d.ts.map +1 -0
- package/node_modules/signal-exit/dist/cjs/browser.js +10 -0
- package/node_modules/signal-exit/dist/cjs/browser.js.map +1 -0
- package/node_modules/signal-exit/dist/cjs/index.d.ts +48 -0
- package/node_modules/signal-exit/dist/cjs/index.d.ts.map +1 -0
- package/node_modules/signal-exit/dist/cjs/index.js +279 -0
- package/node_modules/signal-exit/dist/cjs/index.js.map +1 -0
- package/node_modules/signal-exit/dist/cjs/package.json +3 -0
- package/node_modules/signal-exit/dist/cjs/signals.d.ts +29 -0
- package/node_modules/signal-exit/dist/cjs/signals.d.ts.map +1 -0
- package/node_modules/signal-exit/dist/cjs/signals.js +42 -0
- package/node_modules/signal-exit/dist/cjs/signals.js.map +1 -0
- package/node_modules/signal-exit/dist/mjs/browser.d.ts +12 -0
- package/node_modules/signal-exit/dist/mjs/browser.d.ts.map +1 -0
- package/node_modules/signal-exit/dist/mjs/browser.js +4 -0
- package/node_modules/signal-exit/dist/mjs/browser.js.map +1 -0
- package/node_modules/signal-exit/dist/mjs/index.d.ts +48 -0
- package/node_modules/signal-exit/dist/mjs/index.d.ts.map +1 -0
- package/node_modules/signal-exit/dist/mjs/index.js +275 -0
- package/node_modules/signal-exit/dist/mjs/index.js.map +1 -0
- package/node_modules/signal-exit/dist/mjs/package.json +3 -0
- package/node_modules/signal-exit/dist/mjs/signals.d.ts +29 -0
- package/node_modules/signal-exit/dist/mjs/signals.d.ts.map +1 -0
- package/node_modules/signal-exit/dist/mjs/signals.js +39 -0
- package/node_modules/signal-exit/dist/mjs/signals.js.map +1 -0
- package/node_modules/signal-exit/package.json +87 -19
- package/node_modules/string-width/index.js +29 -19
- package/node_modules/string-width/license +4 -16
- package/node_modules/string-width/package.json +54 -54
- package/node_modules/string-width/readme.md +17 -9
- package/node_modules/strip-ansi/index.js +2 -4
- package/node_modules/strip-ansi/license +4 -16
- package/node_modules/strip-ansi/package.json +52 -55
- package/node_modules/strip-ansi/readme.md +20 -7
- package/package.json +11 -10
- package/test/test-helper.d.ts +1 -1
- package/test/test-helper.js +5 -5
- package/node_modules/are-we-there-yet/CHANGES.md +0 -37
- package/node_modules/are-we-there-yet/LICENSE +0 -5
- package/node_modules/are-we-there-yet/tracker-base.js +0 -11
- package/node_modules/are-we-there-yet/tracker-group.js +0 -107
- package/node_modules/are-we-there-yet/tracker-stream.js +0 -36
- package/node_modules/are-we-there-yet/tracker.js +0 -30
- package/node_modules/code-point-at/index.js +0 -32
- package/node_modules/code-point-at/license +0 -21
- package/node_modules/code-point-at/package.json +0 -38
- package/node_modules/code-point-at/readme.md +0 -32
- package/node_modules/core-util-is/LICENSE +0 -19
- package/node_modules/core-util-is/README.md +0 -3
- package/node_modules/core-util-is/lib/util.js +0 -107
- package/node_modules/core-util-is/package.json +0 -38
- package/node_modules/delegates/.npmignore +0 -1
- package/node_modules/delegates/History.md +0 -22
- package/node_modules/delegates/License +0 -20
- package/node_modules/delegates/Makefile +0 -8
- package/node_modules/delegates/Readme.md +0 -94
- package/node_modules/delegates/index.js +0 -121
- package/node_modules/delegates/package.json +0 -13
- package/node_modules/delegates/test/index.js +0 -94
- package/node_modules/gauge/CHANGELOG.md +0 -160
- package/node_modules/gauge/LICENSE +0 -13
- package/node_modules/gauge/has-color.js +0 -12
- package/node_modules/gauge/themes.js +0 -54
- package/node_modules/inherits/LICENSE +0 -16
- package/node_modules/inherits/README.md +0 -42
- package/node_modules/inherits/inherits.js +0 -9
- package/node_modules/inherits/inherits_browser.js +0 -27
- package/node_modules/inherits/package.json +0 -29
- package/node_modules/isarray/.npmignore +0 -1
- package/node_modules/isarray/.travis.yml +0 -4
- package/node_modules/isarray/Makefile +0 -6
- package/node_modules/isarray/README.md +0 -60
- package/node_modules/isarray/component.json +0 -19
- package/node_modules/isarray/index.js +0 -5
- package/node_modules/isarray/package.json +0 -45
- package/node_modules/isarray/test.js +0 -20
- package/node_modules/number-is-nan/index.js +0 -4
- package/node_modules/number-is-nan/license +0 -21
- package/node_modules/number-is-nan/package.json +0 -35
- package/node_modules/number-is-nan/readme.md +0 -28
- package/node_modules/object-assign/index.js +0 -90
- package/node_modules/object-assign/license +0 -21
- package/node_modules/object-assign/package.json +0 -42
- package/node_modules/object-assign/readme.md +0 -61
- package/node_modules/process-nextick-args/index.js +0 -45
- package/node_modules/process-nextick-args/license.md +0 -19
- package/node_modules/process-nextick-args/package.json +0 -25
- package/node_modules/process-nextick-args/readme.md +0 -18
- package/node_modules/readable-stream/.travis.yml +0 -34
- package/node_modules/readable-stream/CONTRIBUTING.md +0 -38
- package/node_modules/readable-stream/GOVERNANCE.md +0 -136
- package/node_modules/readable-stream/LICENSE +0 -47
- package/node_modules/readable-stream/README.md +0 -58
- package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
- package/node_modules/readable-stream/duplex-browser.js +0 -1
- package/node_modules/readable-stream/duplex.js +0 -1
- package/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
- package/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
- package/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
- package/node_modules/readable-stream/lib/_stream_transform.js +0 -214
- package/node_modules/readable-stream/lib/_stream_writable.js +0 -685
- package/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -78
- package/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -84
- package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- package/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- package/node_modules/readable-stream/package.json +0 -52
- package/node_modules/readable-stream/passthrough.js +0 -1
- package/node_modules/readable-stream/readable-browser.js +0 -7
- package/node_modules/readable-stream/readable.js +0 -19
- package/node_modules/readable-stream/transform.js +0 -1
- package/node_modules/readable-stream/writable-browser.js +0 -1
- package/node_modules/readable-stream/writable.js +0 -8
- package/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/safe-buffer/index.js +0 -62
- package/node_modules/safe-buffer/package.json +0 -37
- package/node_modules/signal-exit/index.js +0 -202
- package/node_modules/signal-exit/signals.js +0 -53
- package/node_modules/string_decoder/.travis.yml +0 -50
- package/node_modules/string_decoder/LICENSE +0 -48
- package/node_modules/string_decoder/README.md +0 -47
- package/node_modules/string_decoder/lib/string_decoder.js +0 -296
- package/node_modules/string_decoder/package.json +0 -31
- package/node_modules/util-deprecate/History.md +0 -16
- package/node_modules/util-deprecate/LICENSE +0 -24
- package/node_modules/util-deprecate/README.md +0 -53
- package/node_modules/util-deprecate/browser.js +0 -67
- package/node_modules/util-deprecate/node.js +0 -6
- package/node_modules/util-deprecate/package.json +0 -27
- package/node_modules/wide-align/node_modules/ansi-regex/index.js +0 -10
- package/node_modules/wide-align/node_modules/ansi-regex/license +0 -9
- package/node_modules/wide-align/node_modules/ansi-regex/package.json +0 -55
- package/node_modules/wide-align/node_modules/ansi-regex/readme.md +0 -78
- package/node_modules/wide-align/node_modules/is-fullwidth-code-point/index.js +0 -50
- package/node_modules/wide-align/node_modules/is-fullwidth-code-point/license +0 -9
- package/node_modules/wide-align/node_modules/is-fullwidth-code-point/package.json +0 -42
- package/node_modules/wide-align/node_modules/is-fullwidth-code-point/readme.md +0 -39
- package/node_modules/wide-align/node_modules/string-width/index.js +0 -47
- package/node_modules/wide-align/node_modules/string-width/license +0 -9
- package/node_modules/wide-align/node_modules/string-width/package.json +0 -56
- package/node_modules/wide-align/node_modules/string-width/readme.md +0 -50
- package/node_modules/wide-align/node_modules/strip-ansi/index.js +0 -4
- package/node_modules/wide-align/node_modules/strip-ansi/license +0 -9
- package/node_modules/wide-align/node_modules/strip-ansi/package.json +0 -54
- package/node_modules/wide-align/node_modules/strip-ansi/readme.md +0 -46
- /package/node_modules/{wide-align/node_modules/ansi-regex → ansi-regex}/index.d.ts +0 -0
- /package/node_modules/are-we-there-yet/{index.js → lib/index.js} +0 -0
- /package/node_modules/{npmlog → color-support}/LICENSE +0 -0
- /package/node_modules/gauge/{error.js → lib/error.js} +0 -0
- /package/node_modules/gauge/{process.js → lib/process.js} +0 -0
- /package/node_modules/gauge/{set-immediate.js → lib/set-immediate.js} +0 -0
- /package/node_modules/gauge/{set-interval.js → lib/set-interval.js} +0 -0
- /package/node_modules/gauge/{spin.js → lib/spin.js} +0 -0
- /package/node_modules/{wide-align/node_modules/is-fullwidth-code-point → is-fullwidth-code-point}/index.d.ts +0 -0
- /package/node_modules/{wide-align/node_modules/string-width → string-width}/index.d.ts +0 -0
- /package/node_modules/{wide-align/node_modules/strip-ansi → strip-ansi}/index.d.ts +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const TrackerBase = require('./tracker-base.js')
|
|
3
|
+
const Tracker = require('./tracker.js')
|
|
4
|
+
const TrackerStream = require('./tracker-stream.js')
|
|
5
|
+
|
|
6
|
+
class TrackerGroup extends TrackerBase {
|
|
7
|
+
parentGroup = null
|
|
8
|
+
trackers = []
|
|
9
|
+
completion = {}
|
|
10
|
+
weight = {}
|
|
11
|
+
totalWeight = 0
|
|
12
|
+
finished = false
|
|
13
|
+
bubbleChange = bubbleChange(this)
|
|
14
|
+
|
|
15
|
+
nameInTree () {
|
|
16
|
+
var names = []
|
|
17
|
+
var from = this
|
|
18
|
+
while (from) {
|
|
19
|
+
names.unshift(from.name)
|
|
20
|
+
from = from.parentGroup
|
|
21
|
+
}
|
|
22
|
+
return names.join('/')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
addUnit (unit, weight) {
|
|
26
|
+
if (unit.addUnit) {
|
|
27
|
+
var toTest = this
|
|
28
|
+
while (toTest) {
|
|
29
|
+
if (unit === toTest) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
'Attempted to add tracker group ' +
|
|
32
|
+
unit.name + ' to tree that already includes it ' +
|
|
33
|
+
this.nameInTree(this))
|
|
34
|
+
}
|
|
35
|
+
toTest = toTest.parentGroup
|
|
36
|
+
}
|
|
37
|
+
unit.parentGroup = this
|
|
38
|
+
}
|
|
39
|
+
this.weight[unit.id] = weight || 1
|
|
40
|
+
this.totalWeight += this.weight[unit.id]
|
|
41
|
+
this.trackers.push(unit)
|
|
42
|
+
this.completion[unit.id] = unit.completed()
|
|
43
|
+
unit.on('change', this.bubbleChange)
|
|
44
|
+
if (!this.finished) {
|
|
45
|
+
this.emit('change', unit.name, this.completion[unit.id], unit)
|
|
46
|
+
}
|
|
47
|
+
return unit
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
completed () {
|
|
51
|
+
if (this.trackers.length === 0) {
|
|
52
|
+
return 0
|
|
53
|
+
}
|
|
54
|
+
var valPerWeight = 1 / this.totalWeight
|
|
55
|
+
var completed = 0
|
|
56
|
+
for (var ii = 0; ii < this.trackers.length; ii++) {
|
|
57
|
+
var trackerId = this.trackers[ii].id
|
|
58
|
+
completed +=
|
|
59
|
+
valPerWeight * this.weight[trackerId] * this.completion[trackerId]
|
|
60
|
+
}
|
|
61
|
+
return completed
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
newGroup (name, weight) {
|
|
65
|
+
return this.addUnit(new TrackerGroup(name), weight)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
newItem (name, todo, weight) {
|
|
69
|
+
return this.addUnit(new Tracker(name, todo), weight)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
newStream (name, todo, weight) {
|
|
73
|
+
return this.addUnit(new TrackerStream(name, todo), weight)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
finish () {
|
|
77
|
+
this.finished = true
|
|
78
|
+
if (!this.trackers.length) {
|
|
79
|
+
this.addUnit(new Tracker(), 1, true)
|
|
80
|
+
}
|
|
81
|
+
for (var ii = 0; ii < this.trackers.length; ii++) {
|
|
82
|
+
var tracker = this.trackers[ii]
|
|
83
|
+
tracker.finish()
|
|
84
|
+
tracker.removeListener('change', this.bubbleChange)
|
|
85
|
+
}
|
|
86
|
+
this.emit('change', this.name, 1, this)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
debug (depth = 0) {
|
|
90
|
+
const indent = ' '.repeat(depth)
|
|
91
|
+
let output = `${indent}${this.name || 'top'}: ${this.completed()}\n`
|
|
92
|
+
|
|
93
|
+
this.trackers.forEach(function (tracker) {
|
|
94
|
+
output += tracker instanceof TrackerGroup
|
|
95
|
+
? tracker.debug(depth + 1)
|
|
96
|
+
: `${indent} ${tracker.name}: ${tracker.completed()}\n`
|
|
97
|
+
})
|
|
98
|
+
return output
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function bubbleChange (trackerGroup) {
|
|
103
|
+
return function (name, completed, tracker) {
|
|
104
|
+
trackerGroup.completion[tracker.id] = completed
|
|
105
|
+
if (trackerGroup.finished) {
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
trackerGroup.emit('change', name || trackerGroup.name, trackerGroup.completed(), trackerGroup)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
module.exports = TrackerGroup
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const stream = require('stream')
|
|
3
|
+
const Tracker = require('./tracker.js')
|
|
4
|
+
|
|
5
|
+
class TrackerStream extends stream.Transform {
|
|
6
|
+
constructor (name, size, options) {
|
|
7
|
+
super(options)
|
|
8
|
+
this.tracker = new Tracker(name, size)
|
|
9
|
+
this.name = name
|
|
10
|
+
this.id = this.tracker.id
|
|
11
|
+
this.tracker.on('change', this.trackerChange.bind(this))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
trackerChange (name, completion) {
|
|
15
|
+
this.emit('change', name, completion, this)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_transform (data, encoding, cb) {
|
|
19
|
+
this.tracker.completeWork(data.length ? data.length : 1)
|
|
20
|
+
this.push(data)
|
|
21
|
+
cb()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_flush (cb) {
|
|
25
|
+
this.tracker.finish()
|
|
26
|
+
cb()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
completed () {
|
|
30
|
+
return this.tracker.completed()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
addWork (work) {
|
|
34
|
+
return this.tracker.addWork(work)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
finish () {
|
|
38
|
+
return this.tracker.finish()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = TrackerStream
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const TrackerBase = require('./tracker-base.js')
|
|
3
|
+
|
|
4
|
+
class Tracker extends TrackerBase {
|
|
5
|
+
constructor (name, todo) {
|
|
6
|
+
super(name)
|
|
7
|
+
this.workDone = 0
|
|
8
|
+
this.workTodo = todo || 0
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
completed () {
|
|
12
|
+
return this.workTodo === 0 ? 0 : this.workDone / this.workTodo
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
addWork (work) {
|
|
16
|
+
this.workTodo += work
|
|
17
|
+
this.emit('change', this.name, this.completed(), this)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
completeWork (work) {
|
|
21
|
+
this.workDone += work
|
|
22
|
+
if (this.workDone > this.workTodo) {
|
|
23
|
+
this.workDone = this.workTodo
|
|
24
|
+
}
|
|
25
|
+
this.emit('change', this.name, this.completed(), this)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
finish () {
|
|
29
|
+
this.workTodo = this.workDone = 1
|
|
30
|
+
this.emit('change', this.name, 1, this)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = Tracker
|
|
@@ -1,35 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "are-we-there-yet",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Keep track of the overall completion of many disparate processes",
|
|
5
|
-
"main": "index.js",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "
|
|
7
|
+
"test": "tap",
|
|
8
|
+
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
|
|
9
|
+
"lintfix": "npm run lint -- --fix",
|
|
10
|
+
"posttest": "npm run lint",
|
|
11
|
+
"postsnap": "npm run lintfix --",
|
|
12
|
+
"snap": "tap",
|
|
13
|
+
"postlint": "template-oss-check",
|
|
14
|
+
"template-oss-apply": "template-oss-apply --force"
|
|
8
15
|
},
|
|
9
16
|
"repository": {
|
|
10
17
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/
|
|
18
|
+
"url": "https://github.com/npm/are-we-there-yet.git"
|
|
12
19
|
},
|
|
13
|
-
"author": "
|
|
20
|
+
"author": "GitHub Inc.",
|
|
14
21
|
"license": "ISC",
|
|
15
22
|
"bugs": {
|
|
16
|
-
"url": "https://github.com/
|
|
23
|
+
"url": "https://github.com/npm/are-we-there-yet/issues"
|
|
17
24
|
},
|
|
18
|
-
"homepage": "https://github.com/
|
|
25
|
+
"homepage": "https://github.com/npm/are-we-there-yet",
|
|
19
26
|
"devDependencies": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"delegates": "^1.0.0",
|
|
25
|
-
"readable-stream": "^2.0.6"
|
|
27
|
+
"@npmcli/eslint-config": "^4.0.0",
|
|
28
|
+
"@npmcli/template-oss": "4.21.3",
|
|
29
|
+
"tap": "^16.0.1"
|
|
26
30
|
},
|
|
27
31
|
"files": [
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
"bin/",
|
|
33
|
+
"lib/"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
|
|
37
|
+
},
|
|
38
|
+
"tap": {
|
|
39
|
+
"branches": 68,
|
|
40
|
+
"statements": 92,
|
|
41
|
+
"functions": 86,
|
|
42
|
+
"lines": 92,
|
|
43
|
+
"nyc-arg": [
|
|
44
|
+
"--exclude",
|
|
45
|
+
"tap-snapshots/**"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"templateOSS": {
|
|
49
|
+
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
|
50
|
+
"version": "4.21.3",
|
|
51
|
+
"publish": true
|
|
52
|
+
}
|
|
35
53
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# color-support
|
|
2
|
+
|
|
3
|
+
A module which will endeavor to guess your terminal's level of color
|
|
4
|
+
support.
|
|
5
|
+
|
|
6
|
+
[](https://travis-ci.org/isaacs/color-support) [](https://coveralls.io/github/isaacs/color-support?branch=master)
|
|
7
|
+
|
|
8
|
+
This is similar to `supports-color`, but it does not read
|
|
9
|
+
`process.argv`.
|
|
10
|
+
|
|
11
|
+
1. If not in a node environment, not supported.
|
|
12
|
+
|
|
13
|
+
2. If stdout is not a TTY, not supported, unless the `ignoreTTY`
|
|
14
|
+
option is set.
|
|
15
|
+
|
|
16
|
+
3. If the `TERM` environ is `dumb`, not supported, unless the
|
|
17
|
+
`ignoreDumb` option is set.
|
|
18
|
+
|
|
19
|
+
4. If on Windows, then support 16 colors.
|
|
20
|
+
|
|
21
|
+
5. If using Tmux, then support 256 colors.
|
|
22
|
+
|
|
23
|
+
7. Handle continuous-integration servers. If `CI` or
|
|
24
|
+
`TEAMCITY_VERSION` are set in the environment, and `TRAVIS` is not
|
|
25
|
+
set, then color is not supported, unless `ignoreCI` option is set.
|
|
26
|
+
|
|
27
|
+
6. Guess based on the `TERM_PROGRAM` environ. These terminals support
|
|
28
|
+
16m colors:
|
|
29
|
+
|
|
30
|
+
- `iTerm.app` version 3.x supports 16m colors, below support 256
|
|
31
|
+
- `MacTerm` supports 16m colors
|
|
32
|
+
- `Apple_Terminal` supports 256 colors
|
|
33
|
+
- Have more things that belong on this list? Send a PR!
|
|
34
|
+
|
|
35
|
+
8. Make a guess based on the `TERM` environment variable. Any
|
|
36
|
+
`xterm-256color` will get 256 colors. Any screen, xterm, vt100,
|
|
37
|
+
color, ansi, cygwin, or linux `TERM` will get 16 colors.
|
|
38
|
+
|
|
39
|
+
9. If `COLORTERM` environment variable is set, then support 16 colors.
|
|
40
|
+
|
|
41
|
+
10. At this point, we assume that color is not supported.
|
|
42
|
+
|
|
43
|
+
## USAGE
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
var testColorSupport = require('color-support')
|
|
47
|
+
var colorSupport = testColorSupport(/* options object */)
|
|
48
|
+
|
|
49
|
+
if (!colorSupport) {
|
|
50
|
+
console.log('color is not supported')
|
|
51
|
+
} else if (colorSupport.has16m) {
|
|
52
|
+
console.log('\x1b[38;2;102;194;255m16m colors\x1b[0m')
|
|
53
|
+
} else if (colorSupport.has256) {
|
|
54
|
+
console.log('\x1b[38;5;119m256 colors\x1b[0m')
|
|
55
|
+
} else if (colorSupport.hasBasic) {
|
|
56
|
+
console.log('\x1b[31mbasic colors\x1b[0m')
|
|
57
|
+
} else {
|
|
58
|
+
console.log('this is impossible, but colors are not supported')
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
If you don't have any options to set, you can also just look at the
|
|
63
|
+
flags which will all be set on the test function itself. (Of course,
|
|
64
|
+
this doesn't return a falsey value when colors aren't supported, and
|
|
65
|
+
doesn't allow you to set options.)
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
var colorSupport = require('color-support')
|
|
69
|
+
|
|
70
|
+
if (colorSupport.has16m) {
|
|
71
|
+
console.log('\x1b[38;2;102;194;255m16m colors\x1b[0m')
|
|
72
|
+
} else if (colorSupport.has256) {
|
|
73
|
+
console.log('\x1b[38;5;119m256 colors\x1b[0m')
|
|
74
|
+
} else if (colorSupport.hasBasic) {
|
|
75
|
+
console.log('\x1b[31mbasic colors\x1b[0m')
|
|
76
|
+
} else {
|
|
77
|
+
console.log('colors are not supported')
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Options
|
|
82
|
+
|
|
83
|
+
You can pass in the following options.
|
|
84
|
+
|
|
85
|
+
* ignoreTTY - default false. Ignore the `isTTY` check.
|
|
86
|
+
* ignoreDumb - default false. Ignore `TERM=dumb` environ check.
|
|
87
|
+
* ignoreCI - default false. Ignore `CI` environ check.
|
|
88
|
+
* env - Object for environment vars. Defaults to `process.env`.
|
|
89
|
+
* stream - Stream for `isTTY` check. Defaults to `process.stdout`.
|
|
90
|
+
* term - String for `TERM` checking. Defaults to `env.TERM`.
|
|
91
|
+
* alwaysReturn - default false. Return an object when colors aren't
|
|
92
|
+
supported (instead of returning `false`).
|
|
93
|
+
* level - A number from 0 to 3. This will return a result for the
|
|
94
|
+
specified level. This is useful if you want to be able to set the
|
|
95
|
+
color support level explicitly as a number in an environment
|
|
96
|
+
variable or config, but then use the object flags in your program.
|
|
97
|
+
Except for `alwaysReturn` to return an object for level 0, all other
|
|
98
|
+
options are ignored, since no checking is done if a level is
|
|
99
|
+
explicitly set.
|
|
100
|
+
|
|
101
|
+
## Return Value
|
|
102
|
+
|
|
103
|
+
If no color support is available, then `false` is returned by default,
|
|
104
|
+
unless the `alwaysReturn` flag is set to `true`. This is so that the
|
|
105
|
+
simple question of "can I use colors or not" can treat any truthy
|
|
106
|
+
return as "yes".
|
|
107
|
+
|
|
108
|
+
Otherwise, the return object has the following fields:
|
|
109
|
+
|
|
110
|
+
* `level` - A number from 0 to 3
|
|
111
|
+
* `0` - No color support
|
|
112
|
+
* `1` - Basic (16) color support
|
|
113
|
+
* `2` - 256 color support
|
|
114
|
+
* `3` - 16 million (true) color support
|
|
115
|
+
* `hasBasic` - Boolean
|
|
116
|
+
* `has256` - Boolean
|
|
117
|
+
* `has16m` - Boolean
|
|
118
|
+
|
|
119
|
+
## CLI
|
|
120
|
+
|
|
121
|
+
You can run the `color-support` bin from the command line which will
|
|
122
|
+
just dump the values as this module calculates them in whatever env
|
|
123
|
+
it's run. It takes no command line arguments.
|
|
124
|
+
|
|
125
|
+
## Credits
|
|
126
|
+
|
|
127
|
+
This is a spiritual, if not actual, fork of
|
|
128
|
+
[supports-color](http://npm.im/supports-color) by the ever prolific
|
|
129
|
+
[Sindre Sorhus](http://npm.im/~sindresorhus).
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = colorSupport({ alwaysReturn: true }, colorSupport)
|
|
2
|
+
|
|
3
|
+
function colorSupport(options, obj) {
|
|
4
|
+
obj = obj || {}
|
|
5
|
+
options = options || {}
|
|
6
|
+
obj.level = 0
|
|
7
|
+
obj.hasBasic = false
|
|
8
|
+
obj.has256 = false
|
|
9
|
+
obj.has16m = false
|
|
10
|
+
if (!options.alwaysReturn) {
|
|
11
|
+
return false
|
|
12
|
+
}
|
|
13
|
+
return obj
|
|
14
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// call it on itself so we can test the export val for basic stuff
|
|
2
|
+
module.exports = colorSupport({ alwaysReturn: true }, colorSupport)
|
|
3
|
+
|
|
4
|
+
function hasNone (obj, options) {
|
|
5
|
+
obj.level = 0
|
|
6
|
+
obj.hasBasic = false
|
|
7
|
+
obj.has256 = false
|
|
8
|
+
obj.has16m = false
|
|
9
|
+
if (!options.alwaysReturn) {
|
|
10
|
+
return false
|
|
11
|
+
}
|
|
12
|
+
return obj
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function hasBasic (obj) {
|
|
16
|
+
obj.hasBasic = true
|
|
17
|
+
obj.has256 = false
|
|
18
|
+
obj.has16m = false
|
|
19
|
+
obj.level = 1
|
|
20
|
+
return obj
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function has256 (obj) {
|
|
24
|
+
obj.hasBasic = true
|
|
25
|
+
obj.has256 = true
|
|
26
|
+
obj.has16m = false
|
|
27
|
+
obj.level = 2
|
|
28
|
+
return obj
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function has16m (obj) {
|
|
32
|
+
obj.hasBasic = true
|
|
33
|
+
obj.has256 = true
|
|
34
|
+
obj.has16m = true
|
|
35
|
+
obj.level = 3
|
|
36
|
+
return obj
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function colorSupport (options, obj) {
|
|
40
|
+
options = options || {}
|
|
41
|
+
|
|
42
|
+
obj = obj || {}
|
|
43
|
+
|
|
44
|
+
// if just requesting a specific level, then return that.
|
|
45
|
+
if (typeof options.level === 'number') {
|
|
46
|
+
switch (options.level) {
|
|
47
|
+
case 0:
|
|
48
|
+
return hasNone(obj, options)
|
|
49
|
+
case 1:
|
|
50
|
+
return hasBasic(obj)
|
|
51
|
+
case 2:
|
|
52
|
+
return has256(obj)
|
|
53
|
+
case 3:
|
|
54
|
+
return has16m(obj)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
obj.level = 0
|
|
59
|
+
obj.hasBasic = false
|
|
60
|
+
obj.has256 = false
|
|
61
|
+
obj.has16m = false
|
|
62
|
+
|
|
63
|
+
if (typeof process === 'undefined' ||
|
|
64
|
+
!process ||
|
|
65
|
+
!process.stdout ||
|
|
66
|
+
!process.env ||
|
|
67
|
+
!process.platform) {
|
|
68
|
+
return hasNone(obj, options)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
var env = options.env || process.env
|
|
72
|
+
var stream = options.stream || process.stdout
|
|
73
|
+
var term = options.term || env.TERM || ''
|
|
74
|
+
var platform = options.platform || process.platform
|
|
75
|
+
|
|
76
|
+
if (!options.ignoreTTY && !stream.isTTY) {
|
|
77
|
+
return hasNone(obj, options)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!options.ignoreDumb && term === 'dumb' && !env.COLORTERM) {
|
|
81
|
+
return hasNone(obj, options)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (platform === 'win32') {
|
|
85
|
+
return hasBasic(obj)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (env.TMUX) {
|
|
89
|
+
return has256(obj)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!options.ignoreCI && (env.CI || env.TEAMCITY_VERSION)) {
|
|
93
|
+
if (env.TRAVIS) {
|
|
94
|
+
return has256(obj)
|
|
95
|
+
} else {
|
|
96
|
+
return hasNone(obj, options)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// TODO: add more term programs
|
|
101
|
+
switch (env.TERM_PROGRAM) {
|
|
102
|
+
case 'iTerm.app':
|
|
103
|
+
var ver = env.TERM_PROGRAM_VERSION || '0.'
|
|
104
|
+
if (/^[0-2]\./.test(ver)) {
|
|
105
|
+
return has256(obj)
|
|
106
|
+
} else {
|
|
107
|
+
return has16m(obj)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
case 'HyperTerm':
|
|
111
|
+
case 'Hyper':
|
|
112
|
+
return has16m(obj)
|
|
113
|
+
|
|
114
|
+
case 'MacTerm':
|
|
115
|
+
return has16m(obj)
|
|
116
|
+
|
|
117
|
+
case 'Apple_Terminal':
|
|
118
|
+
return has256(obj)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (/^xterm-256/.test(term)) {
|
|
122
|
+
return has256(obj)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(term)) {
|
|
126
|
+
return hasBasic(obj)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (env.COLORTERM) {
|
|
130
|
+
return hasBasic(obj)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return hasNone(obj, options)
|
|
134
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "color-support",
|
|
3
|
+
"version": "1.1.3",
|
|
4
|
+
"description": "A module which will endeavor to guess your terminal's level of color support.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"browser": "browser.js",
|
|
7
|
+
"bin": "bin.js",
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"tap": "^10.3.3"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "tap test/*.js --100 -J",
|
|
13
|
+
"preversion": "npm test",
|
|
14
|
+
"postversion": "npm publish",
|
|
15
|
+
"postpublish": "git push origin --all; git push origin --tags"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/isaacs/color-support.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"terminal",
|
|
23
|
+
"color",
|
|
24
|
+
"support",
|
|
25
|
+
"xterm",
|
|
26
|
+
"truecolor",
|
|
27
|
+
"256"
|
|
28
|
+
],
|
|
29
|
+
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
|
30
|
+
"license": "ISC",
|
|
31
|
+
"files": [
|
|
32
|
+
"browser.js",
|
|
33
|
+
"index.js",
|
|
34
|
+
"bin.js"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->
|
|
2
|
+
|
|
3
|
+
ISC License
|
|
4
|
+
|
|
5
|
+
Copyright npm, Inc.
|
|
6
|
+
|
|
7
|
+
Permission to use, copy, modify, and/or distribute this
|
|
8
|
+
software for any purpose with or without fee is hereby
|
|
9
|
+
granted, provided that the above copyright notice and this
|
|
10
|
+
permission notice appear in all copies.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL
|
|
13
|
+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
14
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
|
15
|
+
EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
17
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
18
|
+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
19
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
USE OR PERFORMANCE OF THIS SOFTWARE.
|