chalk 2.2.2 → 2.4.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/index.js +3 -3
- package/index.js.flow +95 -0
- package/package.json +11 -6
- package/readme.md +12 -7
- package/types/index.d.ts +70 -65
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const escapeStringRegexp = require('escape-string-regexp');
|
|
3
3
|
const ansiStyles = require('ansi-styles');
|
|
4
|
-
const
|
|
4
|
+
const stdoutColor = require('supports-color').stdout;
|
|
5
5
|
|
|
6
6
|
const template = require('./templates.js');
|
|
7
7
|
|
|
@@ -19,7 +19,7 @@ function applyOptions(obj, options) {
|
|
|
19
19
|
options = options || {};
|
|
20
20
|
|
|
21
21
|
// Detect level if not set manually
|
|
22
|
-
const scLevel =
|
|
22
|
+
const scLevel = stdoutColor ? stdoutColor.level : 0;
|
|
23
23
|
obj.level = options.level === undefined ? scLevel : options.level;
|
|
24
24
|
obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
|
|
25
25
|
}
|
|
@@ -224,5 +224,5 @@ function chalkTag(chalk, strings) {
|
|
|
224
224
|
Object.defineProperties(Chalk.prototype, styles);
|
|
225
225
|
|
|
226
226
|
module.exports = Chalk(); // eslint-disable-line new-cap
|
|
227
|
-
module.exports.supportsColor =
|
|
227
|
+
module.exports.supportsColor = stdoutColor;
|
|
228
228
|
module.exports.default = module.exports; // For TypeScript
|
package/index.js.flow
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
type TemplateStringsArray = $ReadOnlyArray<string>;
|
|
4
|
+
|
|
5
|
+
export type Level = $Values<{
|
|
6
|
+
None: 0,
|
|
7
|
+
Basic: 1,
|
|
8
|
+
Ansi256: 2,
|
|
9
|
+
TrueColor: 3
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
export type ChalkOptions = {|
|
|
13
|
+
enabled?: boolean,
|
|
14
|
+
level?: Level
|
|
15
|
+
|};
|
|
16
|
+
|
|
17
|
+
export type ColorSupport = {|
|
|
18
|
+
level: Level,
|
|
19
|
+
hasBasic: boolean,
|
|
20
|
+
has256: boolean,
|
|
21
|
+
has16m: boolean
|
|
22
|
+
|};
|
|
23
|
+
|
|
24
|
+
export interface Chalk {
|
|
25
|
+
(...text: string[]): string,
|
|
26
|
+
(text: TemplateStringsArray, ...placeholders: string[]): string,
|
|
27
|
+
constructor(options?: ChalkOptions): Chalk,
|
|
28
|
+
enabled: boolean,
|
|
29
|
+
level: Level,
|
|
30
|
+
rgb(r: number, g: number, b: number): Chalk,
|
|
31
|
+
hsl(h: number, s: number, l: number): Chalk,
|
|
32
|
+
hsv(h: number, s: number, v: number): Chalk,
|
|
33
|
+
hwb(h: number, w: number, b: number): Chalk,
|
|
34
|
+
bgHex(color: string): Chalk,
|
|
35
|
+
bgKeyword(color: string): Chalk,
|
|
36
|
+
bgRgb(r: number, g: number, b: number): Chalk,
|
|
37
|
+
bgHsl(h: number, s: number, l: number): Chalk,
|
|
38
|
+
bgHsv(h: number, s: number, v: number): Chalk,
|
|
39
|
+
bgHwb(h: number, w: number, b: number): Chalk,
|
|
40
|
+
hex(color: string): Chalk,
|
|
41
|
+
keyword(color: string): Chalk,
|
|
42
|
+
|
|
43
|
+
+reset: Chalk,
|
|
44
|
+
+bold: Chalk,
|
|
45
|
+
+dim: Chalk,
|
|
46
|
+
+italic: Chalk,
|
|
47
|
+
+underline: Chalk,
|
|
48
|
+
+inverse: Chalk,
|
|
49
|
+
+hidden: Chalk,
|
|
50
|
+
+strikethrough: Chalk,
|
|
51
|
+
|
|
52
|
+
+visible: Chalk,
|
|
53
|
+
|
|
54
|
+
+black: Chalk,
|
|
55
|
+
+red: Chalk,
|
|
56
|
+
+green: Chalk,
|
|
57
|
+
+yellow: Chalk,
|
|
58
|
+
+blue: Chalk,
|
|
59
|
+
+magenta: Chalk,
|
|
60
|
+
+cyan: Chalk,
|
|
61
|
+
+white: Chalk,
|
|
62
|
+
+gray: Chalk,
|
|
63
|
+
+grey: Chalk,
|
|
64
|
+
+blackBright: Chalk,
|
|
65
|
+
+redBright: Chalk,
|
|
66
|
+
+greenBright: Chalk,
|
|
67
|
+
+yellowBright: Chalk,
|
|
68
|
+
+blueBright: Chalk,
|
|
69
|
+
+magentaBright: Chalk,
|
|
70
|
+
+cyanBright: Chalk,
|
|
71
|
+
+whiteBright: Chalk,
|
|
72
|
+
|
|
73
|
+
+bgBlack: Chalk,
|
|
74
|
+
+bgRed: Chalk,
|
|
75
|
+
+bgGreen: Chalk,
|
|
76
|
+
+bgYellow: Chalk,
|
|
77
|
+
+bgBlue: Chalk,
|
|
78
|
+
+bgMagenta: Chalk,
|
|
79
|
+
+bgCyan: Chalk,
|
|
80
|
+
+bgWhite: Chalk,
|
|
81
|
+
+bgBlackBright: Chalk,
|
|
82
|
+
+bgRedBright: Chalk,
|
|
83
|
+
+bgGreenBright: Chalk,
|
|
84
|
+
+bgYellowBright: Chalk,
|
|
85
|
+
+bgBlueBright: Chalk,
|
|
86
|
+
+bgMagentaBright: Chalk,
|
|
87
|
+
+bgCyanBright: Chalk,
|
|
88
|
+
+bgWhiteBrigh: Chalk,
|
|
89
|
+
|
|
90
|
+
supportsColor: ColorSupport
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
declare var chalk: Chalk;
|
|
94
|
+
|
|
95
|
+
export default chalk;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chalk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Terminal string styling done right",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "chalk/chalk",
|
|
@@ -8,14 +8,15 @@
|
|
|
8
8
|
"node": ">=4"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"test": "xo && tsc --project types && nyc ava",
|
|
11
|
+
"test": "xo && tsc --project types && flow --max-warnings=0 && nyc ava",
|
|
12
12
|
"bench": "matcha benchmark.js",
|
|
13
13
|
"coveralls": "nyc report --reporter=text-lcov | coveralls"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"index.js",
|
|
17
17
|
"templates.js",
|
|
18
|
-
"types/index.d.ts"
|
|
18
|
+
"types/index.d.ts",
|
|
19
|
+
"index.js.flow"
|
|
19
20
|
],
|
|
20
21
|
"keywords": [
|
|
21
22
|
"color",
|
|
@@ -41,14 +42,15 @@
|
|
|
41
42
|
"text"
|
|
42
43
|
],
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"ansi-styles": "^3.1
|
|
45
|
+
"ansi-styles": "^3.2.1",
|
|
45
46
|
"escape-string-regexp": "^1.0.5",
|
|
46
|
-
"supports-color": "^
|
|
47
|
+
"supports-color": "^5.3.0"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"ava": "*",
|
|
50
51
|
"coveralls": "^3.0.0",
|
|
51
|
-
"execa": "^0.
|
|
52
|
+
"execa": "^0.9.0",
|
|
53
|
+
"flow-bin": "^0.68.0",
|
|
52
54
|
"import-fresh": "^2.0.0",
|
|
53
55
|
"matcha": "^0.7.0",
|
|
54
56
|
"nyc": "^11.0.2",
|
|
@@ -61,6 +63,9 @@
|
|
|
61
63
|
"envs": [
|
|
62
64
|
"node",
|
|
63
65
|
"mocha"
|
|
66
|
+
],
|
|
67
|
+
"ignores": [
|
|
68
|
+
"test/_flow.js"
|
|
64
69
|
]
|
|
65
70
|
}
|
|
66
71
|
}
|
package/readme.md
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
> Terminal string styling done right
|
|
11
11
|
|
|
12
|
-
[](https://travis-ci.org/chalk/chalk) [](https://coveralls.io/github/chalk/chalk?branch=master) [](https://www.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/
|
|
12
|
+
[](https://travis-ci.org/chalk/chalk) [](https://coveralls.io/github/chalk/chalk?branch=master) [](https://www.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/xojs/xo) [](https://github.com/sindresorhus/awesome-nodejs)
|
|
13
13
|
|
|
14
14
|
### [See what's new in Chalk 2](https://github.com/chalk/chalk/releases/tag/v2.0.0)
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
<img src="https://cdn.rawgit.com/chalk/ansi-styles/8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" alt="" width="900">
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
## Highlights
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
- Doesn't extend `String.prototype`
|
|
27
27
|
- Clean and focused
|
|
28
28
|
- Actively maintained
|
|
29
|
-
- [Used by ~
|
|
29
|
+
- [Used by ~23,000 packages](https://www.npmjs.com/browse/depended/chalk) as of December 31, 2017
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
## Install
|
|
@@ -35,6 +35,10 @@
|
|
|
35
35
|
$ npm install chalk
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
<a href="https://www.patreon.com/sindresorhus">
|
|
39
|
+
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
|
|
40
|
+
</a>
|
|
41
|
+
|
|
38
42
|
|
|
39
43
|
## Usage
|
|
40
44
|
|
|
@@ -51,7 +55,7 @@ const chalk = require('chalk');
|
|
|
51
55
|
const log = console.log;
|
|
52
56
|
|
|
53
57
|
// Combine styled and normal strings
|
|
54
|
-
log(chalk.blue('Hello') + 'World' + chalk.red('!'));
|
|
58
|
+
log(chalk.blue('Hello') + ' World' + chalk.red('!'));
|
|
55
59
|
|
|
56
60
|
// Compose multiple styles using the chainable API
|
|
57
61
|
log(chalk.blue.bgRed.bold('Hello world!'));
|
|
@@ -124,7 +128,7 @@ Multiple arguments will be separated by space.
|
|
|
124
128
|
|
|
125
129
|
Color support is automatically detected, as is the level (see `chalk.level`). However, if you'd like to simply enable/disable Chalk, you can do so via the `.enabled` property.
|
|
126
130
|
|
|
127
|
-
Chalk is enabled by default unless
|
|
131
|
+
Chalk is enabled by default unless explicitly disabled via the constructor or `chalk.level` is `0`.
|
|
128
132
|
|
|
129
133
|
If you need to change this in a reusable module, create a new instance:
|
|
130
134
|
|
|
@@ -265,8 +269,8 @@ The following color models can be used:
|
|
|
265
269
|
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
|
|
266
270
|
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
|
|
267
271
|
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
|
|
268
|
-
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.
|
|
269
|
-
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.
|
|
272
|
+
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
|
|
273
|
+
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
|
|
270
274
|
- `ansi16`
|
|
271
275
|
- `ansi256`
|
|
272
276
|
|
|
@@ -296,6 +300,7 @@ If you're on Windows, do yourself a favor and use [`cmder`](http://cmder.net/) i
|
|
|
296
300
|
- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
|
|
297
301
|
- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
|
|
298
302
|
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
|
303
|
+
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
|
299
304
|
|
|
300
305
|
|
|
301
306
|
## Maintainers
|
package/types/index.d.ts
CHANGED
|
@@ -13,80 +13,85 @@ export interface ChalkOptions {
|
|
|
13
13
|
level?: Level;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export interface
|
|
16
|
+
export interface ChalkConstructor {
|
|
17
17
|
new (options?: ChalkOptions): Chalk;
|
|
18
18
|
(options?: ChalkOptions): Chalk;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ColorSupport {
|
|
22
|
+
level: Level;
|
|
23
|
+
hasBasic: boolean;
|
|
24
|
+
has256: boolean;
|
|
25
|
+
has16m: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface Chalk {
|
|
19
29
|
(...text: string[]): string;
|
|
20
30
|
(text: TemplateStringsArray, ...placeholders: string[]): string;
|
|
21
|
-
constructor:
|
|
31
|
+
constructor: ChalkConstructor;
|
|
22
32
|
enabled: boolean;
|
|
23
33
|
level: Level;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
bgRgb(r: number, g: number, b: number): Chalk;
|
|
37
|
-
bgHsl(h: number, s: number, l: number): Chalk;
|
|
38
|
-
bgHsv(h: number, s: number, v: number): Chalk;
|
|
39
|
-
bgHwb(h: number, w: number, b: number): Chalk;
|
|
40
|
-
hex(color: string): Chalk;
|
|
41
|
-
keyword(color: string): Chalk;
|
|
34
|
+
rgb(r: number, g: number, b: number): this;
|
|
35
|
+
hsl(h: number, s: number, l: number): this;
|
|
36
|
+
hsv(h: number, s: number, v: number): this;
|
|
37
|
+
hwb(h: number, w: number, b: number): this;
|
|
38
|
+
bgHex(color: string): this;
|
|
39
|
+
bgKeyword(color: string): this;
|
|
40
|
+
bgRgb(r: number, g: number, b: number): this;
|
|
41
|
+
bgHsl(h: number, s: number, l: number): this;
|
|
42
|
+
bgHsv(h: number, s: number, v: number): this;
|
|
43
|
+
bgHwb(h: number, w: number, b: number): this;
|
|
44
|
+
hex(color: string): this;
|
|
45
|
+
keyword(color: string): this;
|
|
42
46
|
|
|
43
|
-
reset:
|
|
44
|
-
bold:
|
|
45
|
-
dim:
|
|
46
|
-
italic:
|
|
47
|
-
underline:
|
|
48
|
-
inverse:
|
|
49
|
-
hidden:
|
|
50
|
-
strikethrough:
|
|
47
|
+
readonly reset: this;
|
|
48
|
+
readonly bold: this;
|
|
49
|
+
readonly dim: this;
|
|
50
|
+
readonly italic: this;
|
|
51
|
+
readonly underline: this;
|
|
52
|
+
readonly inverse: this;
|
|
53
|
+
readonly hidden: this;
|
|
54
|
+
readonly strikethrough: this;
|
|
51
55
|
|
|
52
|
-
visible:
|
|
56
|
+
readonly visible: this;
|
|
53
57
|
|
|
54
|
-
black:
|
|
55
|
-
red:
|
|
56
|
-
green:
|
|
57
|
-
yellow:
|
|
58
|
-
blue:
|
|
59
|
-
magenta:
|
|
60
|
-
cyan:
|
|
61
|
-
white:
|
|
62
|
-
gray:
|
|
63
|
-
grey:
|
|
64
|
-
blackBright:
|
|
65
|
-
redBright:
|
|
66
|
-
greenBright:
|
|
67
|
-
yellowBright:
|
|
68
|
-
blueBright:
|
|
69
|
-
magentaBright:
|
|
70
|
-
cyanBright:
|
|
71
|
-
whiteBright:
|
|
58
|
+
readonly black: this;
|
|
59
|
+
readonly red: this;
|
|
60
|
+
readonly green: this;
|
|
61
|
+
readonly yellow: this;
|
|
62
|
+
readonly blue: this;
|
|
63
|
+
readonly magenta: this;
|
|
64
|
+
readonly cyan: this;
|
|
65
|
+
readonly white: this;
|
|
66
|
+
readonly gray: this;
|
|
67
|
+
readonly grey: this;
|
|
68
|
+
readonly blackBright: this;
|
|
69
|
+
readonly redBright: this;
|
|
70
|
+
readonly greenBright: this;
|
|
71
|
+
readonly yellowBright: this;
|
|
72
|
+
readonly blueBright: this;
|
|
73
|
+
readonly magentaBright: this;
|
|
74
|
+
readonly cyanBright: this;
|
|
75
|
+
readonly whiteBright: this;
|
|
72
76
|
|
|
73
|
-
bgBlack:
|
|
74
|
-
bgRed:
|
|
75
|
-
bgGreen:
|
|
76
|
-
bgYellow:
|
|
77
|
-
bgBlue:
|
|
78
|
-
bgMagenta:
|
|
79
|
-
bgCyan:
|
|
80
|
-
bgWhite:
|
|
81
|
-
bgBlackBright:
|
|
82
|
-
bgRedBright:
|
|
83
|
-
bgGreenBright:
|
|
84
|
-
bgYellowBright:
|
|
85
|
-
bgBlueBright:
|
|
86
|
-
bgMagentaBright:
|
|
87
|
-
bgCyanBright:
|
|
88
|
-
bgWhiteBright:
|
|
77
|
+
readonly bgBlack: this;
|
|
78
|
+
readonly bgRed: this;
|
|
79
|
+
readonly bgGreen: this;
|
|
80
|
+
readonly bgYellow: this;
|
|
81
|
+
readonly bgBlue: this;
|
|
82
|
+
readonly bgMagenta: this;
|
|
83
|
+
readonly bgCyan: this;
|
|
84
|
+
readonly bgWhite: this;
|
|
85
|
+
readonly bgBlackBright: this;
|
|
86
|
+
readonly bgRedBright: this;
|
|
87
|
+
readonly bgGreenBright: this;
|
|
88
|
+
readonly bgYellowBright: this;
|
|
89
|
+
readonly bgBlueBright: this;
|
|
90
|
+
readonly bgMagentaBright: this;
|
|
91
|
+
readonly bgCyanBright: this;
|
|
92
|
+
readonly bgWhiteBright: this;
|
|
89
93
|
}
|
|
90
94
|
|
|
91
|
-
declare
|
|
92
|
-
|
|
95
|
+
declare const chalk: Chalk & { supportsColor: ColorSupport };
|
|
96
|
+
|
|
97
|
+
export default chalk
|