@node-core/utils 7.2.0 → 7.2.1
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/lib/ci/build-types/test_build.js +3 -3
- package/lib/ci/failure_aggregator.js +2 -2
- package/lib/ci/run_ci.js +3 -2
- package/lib/cli.js +6 -6
- package/lib/figures.js +6 -6
- package/lib/update-v8/backport.js +3 -4
- package/lib/verbosity.js +2 -4
- package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/README.md +4 -4
- package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.d.mts +21 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.mjs +46 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/LICENSE +22 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.d.ts +2 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.js +2 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.d.ts +35 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.js +1 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.d.ts +34 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.js +2 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/package.json +88 -0
- package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/package.json +25 -20
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.d.ts +48 -3
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.js +58 -19
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/package.json +1 -1
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/readme.md +36 -1
- package/node_modules/ansi-regex/index.js +9 -4
- package/node_modules/ansi-regex/package.json +1 -1
- package/node_modules/ansi-regex/readme.md +6 -0
- package/node_modules/ansi-styles/index.d.ts +12 -12
- package/node_modules/ansi-styles/index.js +3 -3
- package/node_modules/ansi-styles/package.json +4 -4
- package/node_modules/cli-truncate/index.d.ts +3 -3
- package/node_modules/cli-truncate/index.js +40 -14
- package/node_modules/cli-truncate/node_modules/string-width/index.js +133 -15
- package/node_modules/cli-truncate/node_modules/string-width/package.json +4 -4
- package/node_modules/cli-truncate/node_modules/string-width/readme.md +1 -1
- package/node_modules/cli-truncate/package.json +7 -7
- package/node_modules/cli-truncate/readme.md +2 -3
- package/node_modules/ghauth/.github/dependabot.yml +11 -3
- package/node_modules/ghauth/.github/workflows/depsound.yml +33 -0
- package/node_modules/ghauth/.github/workflows/test-and-release.yml +4 -4
- package/node_modules/ghauth/CHANGELOG.md +60 -0
- package/node_modules/ghauth/package.json +30 -6
- package/node_modules/js-yaml/README.md +20 -187
- package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs +1008 -946
- package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs.map +1 -1
- package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js +29 -23
- package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.cjs.js +1043 -583
- package/node_modules/js-yaml/dist/js-yaml.cjs.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.d.ts +877 -133
- package/node_modules/js-yaml/dist/js-yaml.mjs +995 -556
- package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -1
- package/node_modules/js-yaml/package.json +8 -7
- package/node_modules/listr2/dist/{index.d.cts → index.d.mts} +90 -60
- package/node_modules/listr2/dist/{index.js → index.mjs} +496 -373
- package/node_modules/listr2/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/listr2/node_modules/string-width/index.js +207 -0
- package/node_modules/listr2/node_modules/string-width/package.json +65 -0
- package/node_modules/listr2/node_modules/string-width/readme.md +66 -0
- package/node_modules/listr2/node_modules/wrap-ansi/index.d.ts +1 -1
- package/node_modules/listr2/node_modules/wrap-ansi/index.js +544 -116
- package/node_modules/listr2/node_modules/wrap-ansi/package.json +10 -13
- package/node_modules/listr2/node_modules/wrap-ansi/readme.md +2 -0
- package/node_modules/listr2/package.json +16 -19
- package/node_modules/log-update/index.d.ts +64 -1
- package/node_modules/log-update/index.js +268 -18
- package/node_modules/log-update/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/log-update/node_modules/string-width/index.js +207 -0
- package/node_modules/log-update/node_modules/string-width/package.json +65 -0
- package/node_modules/log-update/node_modules/string-width/readme.md +66 -0
- package/node_modules/log-update/node_modules/wrap-ansi/index.d.ts +1 -1
- package/node_modules/log-update/node_modules/wrap-ansi/index.js +544 -116
- package/node_modules/log-update/node_modules/wrap-ansi/package.json +10 -13
- package/node_modules/log-update/node_modules/wrap-ansi/readme.md +2 -0
- package/node_modules/log-update/package.json +14 -12
- package/node_modules/log-update/readme.md +61 -0
- package/node_modules/slice-ansi/index.d.ts +2 -2
- package/node_modules/slice-ansi/index.js +260 -112
- package/node_modules/slice-ansi/package.json +10 -9
- package/node_modules/slice-ansi/readme.md +3 -2
- package/node_modules/slice-ansi/tokenize-ansi.js +752 -0
- package/node_modules/smol-toml/README.md +205 -191
- package/node_modules/smol-toml/dist/date.d.ts +0 -1
- package/node_modules/smol-toml/dist/date.js +0 -1
- package/node_modules/smol-toml/dist/error.d.ts +0 -1
- package/node_modules/smol-toml/dist/error.js +0 -1
- package/node_modules/smol-toml/dist/extract.js +32 -65
- package/node_modules/smol-toml/dist/index.cjs +302 -288
- package/node_modules/smol-toml/dist/index.d.ts +0 -1
- package/node_modules/smol-toml/dist/index.js +0 -1
- package/node_modules/smol-toml/dist/parse.d.ts +1 -3
- package/node_modules/smol-toml/dist/parse.js +22 -21
- package/node_modules/smol-toml/dist/primitive.js +75 -76
- package/node_modules/smol-toml/dist/stringify.d.ts +0 -1
- package/node_modules/smol-toml/dist/stringify.js +43 -30
- package/node_modules/smol-toml/dist/struct.js +90 -93
- package/node_modules/smol-toml/dist/util.d.ts +1 -1
- package/node_modules/smol-toml/dist/util.js +36 -39
- package/node_modules/smol-toml/package.json +6 -6
- package/node_modules/strip-ansi/index.js +5 -0
- package/node_modules/strip-ansi/package.json +5 -5
- package/package.json +3 -5
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.cjs +0 -127
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.cts +0 -152
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.ts +0 -152
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.js +0 -92
- package/node_modules/chalk/package.json +0 -92
- package/node_modules/chalk/readme.md +0 -331
- package/node_modules/chalk/source/index.d.ts +0 -437
- package/node_modules/chalk/source/index.js +0 -261
- package/node_modules/chalk/source/utilities.js +0 -33
- package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +0 -299
- package/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -261
- package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +0 -1
- package/node_modules/chalk/source/vendor/supports-color/browser.js +0 -32
- package/node_modules/chalk/source/vendor/supports-color/index.d.ts +0 -55
- package/node_modules/chalk/source/vendor/supports-color/index.js +0 -206
- package/node_modules/colorette/LICENSE.md +0 -7
- package/node_modules/colorette/README.md +0 -134
- package/node_modules/colorette/index.cjs +0 -218
- package/node_modules/colorette/index.d.ts +0 -93
- package/node_modules/colorette/index.js +0 -150
- package/node_modules/colorette/package.json +0 -40
- package/node_modules/eventemitter3/LICENSE +0 -21
- package/node_modules/eventemitter3/README.md +0 -94
- package/node_modules/eventemitter3/dist/eventemitter3.esm.js +0 -347
- package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js +0 -1
- package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js.map +0 -1
- package/node_modules/eventemitter3/dist/eventemitter3.umd.js +0 -355
- package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js +0 -1
- package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js.map +0 -1
- package/node_modules/eventemitter3/index.d.ts +0 -135
- package/node_modules/eventemitter3/index.js +0 -336
- package/node_modules/eventemitter3/index.mjs +0 -4
- package/node_modules/eventemitter3/package.json +0 -67
- package/node_modules/figures/index.d.ts +0 -279
- package/node_modules/figures/index.js +0 -292
- package/node_modules/figures/package.json +0 -49
- package/node_modules/figures/readme.md +0 -337
- package/node_modules/listr2/dist/index.cjs +0 -2189
- package/node_modules/listr2/dist/index.d.ts +0 -1528
- package/node_modules/rfdc/.github/workflows/ci.yml +0 -21
- package/node_modules/rfdc/LICENSE +0 -15
- package/node_modules/rfdc/default.js +0 -3
- package/node_modules/rfdc/index.d.ts +0 -13
- package/node_modules/rfdc/index.js +0 -198
- package/node_modules/rfdc/index.test-d.ts +0 -13
- package/node_modules/rfdc/package.json +0 -73
- package/node_modules/rfdc/readme.md +0 -181
- package/node_modules/rfdc/test/index.js +0 -306
- package/node_modules/smol-toml/dist/date.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/date.js.map +0 -1
- package/node_modules/smol-toml/dist/error.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/error.js.map +0 -1
- package/node_modules/smol-toml/dist/extract.js.map +0 -1
- package/node_modules/smol-toml/dist/index.cjs.map +0 -1
- package/node_modules/smol-toml/dist/index.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/index.js.map +0 -1
- package/node_modules/smol-toml/dist/parse.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/parse.js.map +0 -1
- package/node_modules/smol-toml/dist/primitive.d.ts +0 -29
- package/node_modules/smol-toml/dist/primitive.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/primitive.js.map +0 -1
- package/node_modules/smol-toml/dist/stringify.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/stringify.js.map +0 -1
- package/node_modules/smol-toml/dist/struct.js.map +0 -1
- package/node_modules/smol-toml/dist/util.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/util.js.map +0 -1
- package/node_modules/smol-toml/src/date.ts +0 -152
- package/node_modules/smol-toml/src/error.ts +0 -77
- package/node_modules/smol-toml/src/extract.ts +0 -113
- package/node_modules/smol-toml/src/index.ts +0 -42
- package/node_modules/smol-toml/src/parse.ts +0 -184
- package/node_modules/smol-toml/src/primitive.ts +0 -249
- package/node_modules/smol-toml/src/stringify.ts +0 -191
- package/node_modules/smol-toml/src/struct.ts +0 -202
- package/node_modules/smol-toml/src/util.ts +0 -106
- /package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/LICENSE +0 -0
- /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.d.ts +0 -0
- /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.js +0 -0
- /package/node_modules/{chalk → ansi-escapes}/license +0 -0
- /package/node_modules/{figures → listr2/node_modules/string-width}/license +0 -0
- /package/node_modules/log-update/node_modules/{ansi-escapes → string-width}/license +0 -0
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import process from 'node:process';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import tty from 'node:tty';
|
|
4
|
-
|
|
5
|
-
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
6
|
-
/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
|
7
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {
|
|
8
|
-
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
|
9
|
-
const position = argv.indexOf(prefix + flag);
|
|
10
|
-
const terminatorPosition = argv.indexOf('--');
|
|
11
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const {env} = process;
|
|
15
|
-
|
|
16
|
-
let flagForceColor;
|
|
17
|
-
if (
|
|
18
|
-
hasFlag('no-color')
|
|
19
|
-
|| hasFlag('no-colors')
|
|
20
|
-
|| hasFlag('color=false')
|
|
21
|
-
|| hasFlag('color=never')
|
|
22
|
-
) {
|
|
23
|
-
flagForceColor = 0;
|
|
24
|
-
} else if (
|
|
25
|
-
hasFlag('color')
|
|
26
|
-
|| hasFlag('colors')
|
|
27
|
-
|| hasFlag('color=true')
|
|
28
|
-
|| hasFlag('color=always')
|
|
29
|
-
) {
|
|
30
|
-
flagForceColor = 1;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Whether `FORCE_COLOR` names a level. Shared with the exact-level check below so that the two cannot disagree on what counts as numeric.
|
|
34
|
-
function hasNumericForceColor() {
|
|
35
|
-
return /^\d+$/.test(env.FORCE_COLOR);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function envForceColor() {
|
|
39
|
-
if (!('FORCE_COLOR' in env)) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (env.FORCE_COLOR === 'false') {
|
|
44
|
-
return 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (env.FORCE_COLOR === 'true' || env.FORCE_COLOR.length === 0) {
|
|
48
|
-
return 1;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!hasNumericForceColor()) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function translateLevel(level) {
|
|
59
|
-
if (level === 0) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
level,
|
|
65
|
-
hasBasic: true,
|
|
66
|
-
has256: level >= 2,
|
|
67
|
-
has16m: level >= 3,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
72
|
-
const noFlagForceColor = envForceColor();
|
|
73
|
-
if (noFlagForceColor !== undefined) {
|
|
74
|
-
flagForceColor = noFlagForceColor;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
78
|
-
|
|
79
|
-
if (forceColor === 0) {
|
|
80
|
-
return 0;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (sniffFlags) {
|
|
84
|
-
if (hasFlag('color=16m')
|
|
85
|
-
|| hasFlag('color=full')
|
|
86
|
-
|| hasFlag('color=truecolor')) {
|
|
87
|
-
return 3;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (hasFlag('color=256')) {
|
|
91
|
-
return 2;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// A numeric `FORCE_COLOR` requests an exact level, while `FORCE_COLOR=true` and `FORCE_COLOR=` only enable color and let the level be detected.
|
|
96
|
-
if (forceColor !== undefined && hasNumericForceColor()) {
|
|
97
|
-
return forceColor;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Check for Azure DevOps pipelines.
|
|
101
|
-
// Has to be above the `!streamIsTTY` check.
|
|
102
|
-
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
|
103
|
-
return 1;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
107
|
-
return 0;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const min = forceColor || 0;
|
|
111
|
-
|
|
112
|
-
if (env.TERM === 'dumb') {
|
|
113
|
-
return min;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (process.platform === 'win32') {
|
|
117
|
-
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
118
|
-
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
119
|
-
const osRelease = os.release().split('.');
|
|
120
|
-
if (
|
|
121
|
-
Number(osRelease[0]) >= 10
|
|
122
|
-
&& Number(osRelease[2]) >= 10_586
|
|
123
|
-
) {
|
|
124
|
-
return Number(osRelease[2]) >= 14_931 ? 3 : 2;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return 1;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if ('CI' in env) {
|
|
131
|
-
if (['GITHUB_ACTIONS', 'GITEA_ACTIONS', 'CIRCLECI'].some(key => key in env)) {
|
|
132
|
-
return 3;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (['TRAVIS', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
136
|
-
return 1;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return min;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if ('TEAMCITY_VERSION' in env) {
|
|
143
|
-
return /^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (env.COLORTERM === 'truecolor') {
|
|
147
|
-
return 3;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (env.TERM === 'xterm-kitty') {
|
|
151
|
-
return 3;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (env.TERM === 'xterm-ghostty') {
|
|
155
|
-
return 3;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (env.TERM === 'wezterm') {
|
|
159
|
-
return 3;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if ('TERM_PROGRAM' in env) {
|
|
163
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.', 1)[0], 10);
|
|
164
|
-
|
|
165
|
-
switch (env.TERM_PROGRAM) {
|
|
166
|
-
case 'iTerm.app': {
|
|
167
|
-
return version >= 3 ? 3 : 2;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
case 'Apple_Terminal': {
|
|
171
|
-
return 2;
|
|
172
|
-
}
|
|
173
|
-
// No default
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (/-256(?:color)?$/i.test(env.TERM)) {
|
|
178
|
-
return 2;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
182
|
-
return 1;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if ('COLORTERM' in env) {
|
|
186
|
-
return 1;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return min;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export function createSupportsColor(stream, options = {}) {
|
|
193
|
-
const level = _supportsColor(stream, {
|
|
194
|
-
streamIsTTY: stream && stream.isTTY,
|
|
195
|
-
...options,
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
return translateLevel(level);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const supportsColor = {
|
|
202
|
-
stdout: createSupportsColor({isTTY: tty.isatty(1)}),
|
|
203
|
-
stderr: createSupportsColor({isTTY: tty.isatty(2)}),
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
export default supportsColor;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
Copyright © Jorge Bucaran <<https://jorgebucaran.com>>
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
# 🌈Colorette
|
|
2
|
-
|
|
3
|
-
> Easily set your terminal text color & styles.
|
|
4
|
-
|
|
5
|
-
- No dependecies
|
|
6
|
-
- Automatic color support detection
|
|
7
|
-
- Up to [2x faster](#benchmarks) than alternatives
|
|
8
|
-
- TypeScript support
|
|
9
|
-
- [`NO_COLOR`](https://no-color.org) friendly
|
|
10
|
-
- Node >= `10`
|
|
11
|
-
|
|
12
|
-
> [**Upgrading from Colorette `1.x`?**](https://github.com/jorgebucaran/colorette/issues/70)
|
|
13
|
-
|
|
14
|
-
## Quickstart
|
|
15
|
-
|
|
16
|
-
```js
|
|
17
|
-
import { blue, bold, underline } from "colorette"
|
|
18
|
-
|
|
19
|
-
console.log(
|
|
20
|
-
blue("I'm blue"),
|
|
21
|
-
bold(blue("da ba dee")),
|
|
22
|
-
underline(bold(blue("da ba daa")))
|
|
23
|
-
)
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Here's an example using [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals).
|
|
27
|
-
|
|
28
|
-
```js
|
|
29
|
-
console.log(`
|
|
30
|
-
There's a ${underline(blue("house"))},
|
|
31
|
-
With a ${bold(blue("window"))},
|
|
32
|
-
And a ${blue("corvette")}
|
|
33
|
-
And everything is blue
|
|
34
|
-
`)
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
You can also nest styles without breaking existing color sequences.
|
|
38
|
-
|
|
39
|
-
```js
|
|
40
|
-
console.log(bold(`I'm ${blue(`da ba ${underline("dee")} da ba`)} daa`))
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Need to override terminal color detection? You can do that too.
|
|
44
|
-
|
|
45
|
-
```js
|
|
46
|
-
import { createColors } from "colorette"
|
|
47
|
-
|
|
48
|
-
const { blue } = createColors({ useColor: false })
|
|
49
|
-
|
|
50
|
-
console.log(blue("Blue? Nope, nah"))
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Installation
|
|
54
|
-
|
|
55
|
-
```console
|
|
56
|
-
npm install colorette
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## API
|
|
60
|
-
|
|
61
|
-
### \<color\>()
|
|
62
|
-
|
|
63
|
-
> See all [supported colors](#supported-colors).
|
|
64
|
-
|
|
65
|
-
```js
|
|
66
|
-
import { blue } from "colorette"
|
|
67
|
-
|
|
68
|
-
blue("I'm blue") //=> \x1b[34mI'm blue\x1b[39m
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### createColors()
|
|
72
|
-
|
|
73
|
-
Override terminal color detection via `createColors({ useColor })`.
|
|
74
|
-
|
|
75
|
-
```js
|
|
76
|
-
import { createColors } from "colorette"
|
|
77
|
-
|
|
78
|
-
const { blue } = createColors({ useColor: false })
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### isColorSupported
|
|
82
|
-
|
|
83
|
-
`true` if your terminal supports color, `false` otherwise. Used internally, but exposed for convenience.
|
|
84
|
-
|
|
85
|
-
## Environment
|
|
86
|
-
|
|
87
|
-
You can override color detection from the CLI by setting the `--no-color` or `--color` flags.
|
|
88
|
-
|
|
89
|
-
```console
|
|
90
|
-
$ ./example.js --no-color | ./consumer.js
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Or if you can't use CLI flags, by setting the `NO_COLOR=` or `FORCE_COLOR=` environment variables.
|
|
94
|
-
|
|
95
|
-
```console
|
|
96
|
-
$ NO_COLOR= ./example.js | ./consumer.js
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## Supported colors
|
|
100
|
-
|
|
101
|
-
| Colors | Background Colors | Bright Colors | Bright Background Colors | Modifiers |
|
|
102
|
-
| ------- | ----------------- | ------------- | ------------------------ | ----------------- |
|
|
103
|
-
| black | bgBlack | blackBright | bgBlackBright | dim |
|
|
104
|
-
| red | bgRed | redBright | bgRedBright | **bold** |
|
|
105
|
-
| green | bgGreen | greenBright | bgGreenBright | hidden |
|
|
106
|
-
| yellow | bgYellow | yellowBright | bgYellowBright | _italic_ |
|
|
107
|
-
| blue | bgBlue | blueBright | bgBlueBright | <u>underline</u> |
|
|
108
|
-
| magenta | bgMagenta | magentaBright | bgMagentaBright | ~~strikethrough~~ |
|
|
109
|
-
| cyan | bgCyan | cyanBright | bgCyanBright | reset |
|
|
110
|
-
| white | bgWhite | whiteBright | bgWhiteBright | |
|
|
111
|
-
| gray | | | | |
|
|
112
|
-
|
|
113
|
-
## [Benchmarks](https://github.com/jorgebucaran/colorette/actions/workflows/bench.yml)
|
|
114
|
-
|
|
115
|
-
```console
|
|
116
|
-
npm --prefix bench start
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
```diff
|
|
120
|
-
chalk 1,786,703 ops/sec
|
|
121
|
-
kleur 1,618,960 ops/sec
|
|
122
|
-
colors 646,823 ops/sec
|
|
123
|
-
ansi-colors 786,149 ops/sec
|
|
124
|
-
picocolors 2,871,758 ops/sec
|
|
125
|
-
+ colorette 3,002,751 ops/sec
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## Acknowledgments
|
|
129
|
-
|
|
130
|
-
Colorette started out in 2015 by [@jorgebucaran](https://github.com/jorgebucaran) as a lightweight alternative to [Chalk](https://github.com/chalk/chalk) and was introduced originally as [Clor](https://github.com/jorgebucaran/colorette/commit/b01b5b9961ceb7df878583a3002e836fae9e37ce). Our terminal color detection logic borrows heavily from [@sindresorhus](https://github.com/sindresorhus) and [@Qix-](https://github.com/Qix-) work on Chalk. The idea of slicing strings to clear bleeding sequences was adapted from a similar technique used by [@alexeyraspopov](https://github.com/alexeyraspopov) in [picocolors](https://github.com/alexeyraspopov/picocolors). Thank you to all our contributors! <3
|
|
131
|
-
|
|
132
|
-
## License
|
|
133
|
-
|
|
134
|
-
[MIT](LICENSE.md)
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tty = require('tty');
|
|
6
|
-
|
|
7
|
-
function _interopNamespace(e) {
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () { return e[k]; }
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
n["default"] = e;
|
|
22
|
-
return Object.freeze(n);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var tty__namespace = /*#__PURE__*/_interopNamespace(tty);
|
|
26
|
-
|
|
27
|
-
const {
|
|
28
|
-
env = {},
|
|
29
|
-
argv = [],
|
|
30
|
-
platform = "",
|
|
31
|
-
} = typeof process === "undefined" ? {} : process;
|
|
32
|
-
|
|
33
|
-
const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
|
34
|
-
const isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
|
35
|
-
const isWindows = platform === "win32";
|
|
36
|
-
const isDumbTerminal = env.TERM === "dumb";
|
|
37
|
-
|
|
38
|
-
const isCompatibleTerminal =
|
|
39
|
-
tty__namespace && tty__namespace.isatty && tty__namespace.isatty(1) && env.TERM && !isDumbTerminal;
|
|
40
|
-
|
|
41
|
-
const isCI =
|
|
42
|
-
"CI" in env &&
|
|
43
|
-
("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
|
44
|
-
|
|
45
|
-
const isColorSupported =
|
|
46
|
-
!isDisabled &&
|
|
47
|
-
(isForced || (isWindows && !isDumbTerminal) || isCompatibleTerminal || isCI);
|
|
48
|
-
|
|
49
|
-
const replaceClose = (
|
|
50
|
-
index,
|
|
51
|
-
string,
|
|
52
|
-
close,
|
|
53
|
-
replace,
|
|
54
|
-
head = string.substring(0, index) + replace,
|
|
55
|
-
tail = string.substring(index + close.length),
|
|
56
|
-
next = tail.indexOf(close)
|
|
57
|
-
) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
58
|
-
|
|
59
|
-
const clearBleed = (index, string, open, close, replace) =>
|
|
60
|
-
index < 0
|
|
61
|
-
? open + string + close
|
|
62
|
-
: open + replaceClose(index, string, close, replace) + close;
|
|
63
|
-
|
|
64
|
-
const filterEmpty =
|
|
65
|
-
(open, close, replace = open, at = open.length + 1) =>
|
|
66
|
-
(string) =>
|
|
67
|
-
string || !(string === "" || string === undefined)
|
|
68
|
-
? clearBleed(
|
|
69
|
-
("" + string).indexOf(close, at),
|
|
70
|
-
string,
|
|
71
|
-
open,
|
|
72
|
-
close,
|
|
73
|
-
replace
|
|
74
|
-
)
|
|
75
|
-
: "";
|
|
76
|
-
|
|
77
|
-
const init = (open, close, replace) =>
|
|
78
|
-
filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
79
|
-
|
|
80
|
-
const colors = {
|
|
81
|
-
reset: init(0, 0),
|
|
82
|
-
bold: init(1, 22, "\x1b[22m\x1b[1m"),
|
|
83
|
-
dim: init(2, 22, "\x1b[22m\x1b[2m"),
|
|
84
|
-
italic: init(3, 23),
|
|
85
|
-
underline: init(4, 24),
|
|
86
|
-
inverse: init(7, 27),
|
|
87
|
-
hidden: init(8, 28),
|
|
88
|
-
strikethrough: init(9, 29),
|
|
89
|
-
black: init(30, 39),
|
|
90
|
-
red: init(31, 39),
|
|
91
|
-
green: init(32, 39),
|
|
92
|
-
yellow: init(33, 39),
|
|
93
|
-
blue: init(34, 39),
|
|
94
|
-
magenta: init(35, 39),
|
|
95
|
-
cyan: init(36, 39),
|
|
96
|
-
white: init(37, 39),
|
|
97
|
-
gray: init(90, 39),
|
|
98
|
-
bgBlack: init(40, 49),
|
|
99
|
-
bgRed: init(41, 49),
|
|
100
|
-
bgGreen: init(42, 49),
|
|
101
|
-
bgYellow: init(43, 49),
|
|
102
|
-
bgBlue: init(44, 49),
|
|
103
|
-
bgMagenta: init(45, 49),
|
|
104
|
-
bgCyan: init(46, 49),
|
|
105
|
-
bgWhite: init(47, 49),
|
|
106
|
-
blackBright: init(90, 39),
|
|
107
|
-
redBright: init(91, 39),
|
|
108
|
-
greenBright: init(92, 39),
|
|
109
|
-
yellowBright: init(93, 39),
|
|
110
|
-
blueBright: init(94, 39),
|
|
111
|
-
magentaBright: init(95, 39),
|
|
112
|
-
cyanBright: init(96, 39),
|
|
113
|
-
whiteBright: init(97, 39),
|
|
114
|
-
bgBlackBright: init(100, 49),
|
|
115
|
-
bgRedBright: init(101, 49),
|
|
116
|
-
bgGreenBright: init(102, 49),
|
|
117
|
-
bgYellowBright: init(103, 49),
|
|
118
|
-
bgBlueBright: init(104, 49),
|
|
119
|
-
bgMagentaBright: init(105, 49),
|
|
120
|
-
bgCyanBright: init(106, 49),
|
|
121
|
-
bgWhiteBright: init(107, 49),
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const createColors = ({ useColor = isColorSupported } = {}) =>
|
|
125
|
-
useColor
|
|
126
|
-
? colors
|
|
127
|
-
: Object.keys(colors).reduce(
|
|
128
|
-
(colors, key) => ({ ...colors, [key]: String }),
|
|
129
|
-
{}
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
const {
|
|
133
|
-
reset,
|
|
134
|
-
bold,
|
|
135
|
-
dim,
|
|
136
|
-
italic,
|
|
137
|
-
underline,
|
|
138
|
-
inverse,
|
|
139
|
-
hidden,
|
|
140
|
-
strikethrough,
|
|
141
|
-
black,
|
|
142
|
-
red,
|
|
143
|
-
green,
|
|
144
|
-
yellow,
|
|
145
|
-
blue,
|
|
146
|
-
magenta,
|
|
147
|
-
cyan,
|
|
148
|
-
white,
|
|
149
|
-
gray,
|
|
150
|
-
bgBlack,
|
|
151
|
-
bgRed,
|
|
152
|
-
bgGreen,
|
|
153
|
-
bgYellow,
|
|
154
|
-
bgBlue,
|
|
155
|
-
bgMagenta,
|
|
156
|
-
bgCyan,
|
|
157
|
-
bgWhite,
|
|
158
|
-
blackBright,
|
|
159
|
-
redBright,
|
|
160
|
-
greenBright,
|
|
161
|
-
yellowBright,
|
|
162
|
-
blueBright,
|
|
163
|
-
magentaBright,
|
|
164
|
-
cyanBright,
|
|
165
|
-
whiteBright,
|
|
166
|
-
bgBlackBright,
|
|
167
|
-
bgRedBright,
|
|
168
|
-
bgGreenBright,
|
|
169
|
-
bgYellowBright,
|
|
170
|
-
bgBlueBright,
|
|
171
|
-
bgMagentaBright,
|
|
172
|
-
bgCyanBright,
|
|
173
|
-
bgWhiteBright,
|
|
174
|
-
} = createColors();
|
|
175
|
-
|
|
176
|
-
exports.bgBlack = bgBlack;
|
|
177
|
-
exports.bgBlackBright = bgBlackBright;
|
|
178
|
-
exports.bgBlue = bgBlue;
|
|
179
|
-
exports.bgBlueBright = bgBlueBright;
|
|
180
|
-
exports.bgCyan = bgCyan;
|
|
181
|
-
exports.bgCyanBright = bgCyanBright;
|
|
182
|
-
exports.bgGreen = bgGreen;
|
|
183
|
-
exports.bgGreenBright = bgGreenBright;
|
|
184
|
-
exports.bgMagenta = bgMagenta;
|
|
185
|
-
exports.bgMagentaBright = bgMagentaBright;
|
|
186
|
-
exports.bgRed = bgRed;
|
|
187
|
-
exports.bgRedBright = bgRedBright;
|
|
188
|
-
exports.bgWhite = bgWhite;
|
|
189
|
-
exports.bgWhiteBright = bgWhiteBright;
|
|
190
|
-
exports.bgYellow = bgYellow;
|
|
191
|
-
exports.bgYellowBright = bgYellowBright;
|
|
192
|
-
exports.black = black;
|
|
193
|
-
exports.blackBright = blackBright;
|
|
194
|
-
exports.blue = blue;
|
|
195
|
-
exports.blueBright = blueBright;
|
|
196
|
-
exports.bold = bold;
|
|
197
|
-
exports.createColors = createColors;
|
|
198
|
-
exports.cyan = cyan;
|
|
199
|
-
exports.cyanBright = cyanBright;
|
|
200
|
-
exports.dim = dim;
|
|
201
|
-
exports.gray = gray;
|
|
202
|
-
exports.green = green;
|
|
203
|
-
exports.greenBright = greenBright;
|
|
204
|
-
exports.hidden = hidden;
|
|
205
|
-
exports.inverse = inverse;
|
|
206
|
-
exports.isColorSupported = isColorSupported;
|
|
207
|
-
exports.italic = italic;
|
|
208
|
-
exports.magenta = magenta;
|
|
209
|
-
exports.magentaBright = magentaBright;
|
|
210
|
-
exports.red = red;
|
|
211
|
-
exports.redBright = redBright;
|
|
212
|
-
exports.reset = reset;
|
|
213
|
-
exports.strikethrough = strikethrough;
|
|
214
|
-
exports.underline = underline;
|
|
215
|
-
exports.white = white;
|
|
216
|
-
exports.whiteBright = whiteBright;
|
|
217
|
-
exports.yellow = yellow;
|
|
218
|
-
exports.yellowBright = yellowBright;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
declare module "colorette" {
|
|
2
|
-
type Color = (text: string | number) => string
|
|
3
|
-
|
|
4
|
-
interface Colorette {
|
|
5
|
-
reset: Color
|
|
6
|
-
bold: Color
|
|
7
|
-
dim: Color
|
|
8
|
-
italic: Color
|
|
9
|
-
underline: Color
|
|
10
|
-
inverse: Color
|
|
11
|
-
hidden: Color
|
|
12
|
-
strikethrough: Color
|
|
13
|
-
black: Color
|
|
14
|
-
red: Color
|
|
15
|
-
green: Color
|
|
16
|
-
yellow: Color
|
|
17
|
-
blue: Color
|
|
18
|
-
magenta: Color
|
|
19
|
-
cyan: Color
|
|
20
|
-
white: Color
|
|
21
|
-
gray: Color
|
|
22
|
-
bgBlack: Color
|
|
23
|
-
bgRed: Color
|
|
24
|
-
bgGreen: Color
|
|
25
|
-
bgYellow: Color
|
|
26
|
-
bgBlue: Color
|
|
27
|
-
bgMagenta: Color
|
|
28
|
-
bgCyan: Color
|
|
29
|
-
bgWhite: Color
|
|
30
|
-
blackBright: Color
|
|
31
|
-
redBright: Color
|
|
32
|
-
greenBright: Color
|
|
33
|
-
yellowBright: Color
|
|
34
|
-
blueBright: Color
|
|
35
|
-
magentaBright: Color
|
|
36
|
-
cyanBright: Color
|
|
37
|
-
whiteBright: Color
|
|
38
|
-
bgBlackBright: Color
|
|
39
|
-
bgRedBright: Color
|
|
40
|
-
bgGreenBright: Color
|
|
41
|
-
bgYellowBright: Color
|
|
42
|
-
bgBlueBright: Color
|
|
43
|
-
bgMagentaBright: Color
|
|
44
|
-
bgCyanBright: Color
|
|
45
|
-
bgWhiteBright: Color
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const reset: Color
|
|
49
|
-
const bold: Color
|
|
50
|
-
const dim: Color
|
|
51
|
-
const italic: Color
|
|
52
|
-
const underline: Color
|
|
53
|
-
const inverse: Color
|
|
54
|
-
const hidden: Color
|
|
55
|
-
const strikethrough: Color
|
|
56
|
-
const black: Color
|
|
57
|
-
const red: Color
|
|
58
|
-
const green: Color
|
|
59
|
-
const yellow: Color
|
|
60
|
-
const blue: Color
|
|
61
|
-
const magenta: Color
|
|
62
|
-
const cyan: Color
|
|
63
|
-
const white: Color
|
|
64
|
-
const gray: Color
|
|
65
|
-
const bgBlack: Color
|
|
66
|
-
const bgRed: Color
|
|
67
|
-
const bgGreen: Color
|
|
68
|
-
const bgYellow: Color
|
|
69
|
-
const bgBlue: Color
|
|
70
|
-
const bgMagenta: Color
|
|
71
|
-
const bgCyan: Color
|
|
72
|
-
const bgWhite: Color
|
|
73
|
-
const blackBright: Color
|
|
74
|
-
const redBright: Color
|
|
75
|
-
const greenBright: Color
|
|
76
|
-
const yellowBright: Color
|
|
77
|
-
const blueBright: Color
|
|
78
|
-
const magentaBright: Color
|
|
79
|
-
const cyanBright: Color
|
|
80
|
-
const whiteBright: Color
|
|
81
|
-
const bgBlackBright: Color
|
|
82
|
-
const bgRedBright: Color
|
|
83
|
-
const bgGreenBright: Color
|
|
84
|
-
const bgYellowBright: Color
|
|
85
|
-
const bgBlueBright: Color
|
|
86
|
-
const bgMagentaBright: Color
|
|
87
|
-
const bgCyanBright: Color
|
|
88
|
-
const bgWhiteBright: Color
|
|
89
|
-
|
|
90
|
-
const isColorSupported: boolean
|
|
91
|
-
|
|
92
|
-
function createColors(options?: { useColor: boolean }): Colorette
|
|
93
|
-
}
|