1 | export { default as instance } from 'npmlog';
|
2 |
|
3 | /**
|
4 | Basic foreground colors.
|
5 |
|
6 | [More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
7 | */
|
8 | declare type ForegroundColor =
|
9 | | 'black'
|
10 | | 'red'
|
11 | | 'green'
|
12 | | 'yellow'
|
13 | | 'blue'
|
14 | | 'magenta'
|
15 | | 'cyan'
|
16 | | 'white'
|
17 | | 'gray'
|
18 | | 'grey'
|
19 | | 'blackBright'
|
20 | | 'redBright'
|
21 | | 'greenBright'
|
22 | | 'yellowBright'
|
23 | | 'blueBright'
|
24 | | 'magentaBright'
|
25 | | 'cyanBright'
|
26 | | 'whiteBright';
|
27 |
|
28 | /**
|
29 | Basic background colors.
|
30 |
|
31 | [More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
32 | */
|
33 | declare type BackgroundColor =
|
34 | | 'bgBlack'
|
35 | | 'bgRed'
|
36 | | 'bgGreen'
|
37 | | 'bgYellow'
|
38 | | 'bgBlue'
|
39 | | 'bgMagenta'
|
40 | | 'bgCyan'
|
41 | | 'bgWhite'
|
42 | | 'bgGray'
|
43 | | 'bgGrey'
|
44 | | 'bgBlackBright'
|
45 | | 'bgRedBright'
|
46 | | 'bgGreenBright'
|
47 | | 'bgYellowBright'
|
48 | | 'bgBlueBright'
|
49 | | 'bgMagentaBright'
|
50 | | 'bgCyanBright'
|
51 | | 'bgWhiteBright';
|
52 |
|
53 | /**
|
54 | Basic colors.
|
55 |
|
56 | [More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
57 | */
|
58 | declare type Color = ForegroundColor | BackgroundColor;
|
59 |
|
60 | declare type Modifiers =
|
61 | | 'reset'
|
62 | | 'bold'
|
63 | | 'dim'
|
64 | | 'italic'
|
65 | | 'underline'
|
66 | | 'inverse'
|
67 | | 'hidden'
|
68 | | 'strikethrough'
|
69 | | 'visible';
|
70 |
|
71 | declare namespace chalk {
|
72 | /**
|
73 | Levels:
|
74 | - `0` - All colors disabled.
|
75 | - `1` - Basic 16 colors support.
|
76 | - `2` - ANSI 256 colors support.
|
77 | - `3` - Truecolor 16 million colors support.
|
78 | */
|
79 | type Level = 0 | 1 | 2 | 3;
|
80 |
|
81 | interface Options {
|
82 | /**
|
83 | Specify the color support for Chalk.
|
84 |
|
85 | By default, color support is automatically detected based on the environment.
|
86 |
|
87 | Levels:
|
88 | - `0` - All colors disabled.
|
89 | - `1` - Basic 16 colors support.
|
90 | - `2` - ANSI 256 colors support.
|
91 | - `3` - Truecolor 16 million colors support.
|
92 | */
|
93 | level?: Level;
|
94 | }
|
95 |
|
96 | /**
|
97 | Return a new Chalk instance.
|
98 | */
|
99 | type Instance = new (options?: Options) => Chalk;
|
100 |
|
101 | /**
|
102 | Detect whether the terminal supports color.
|
103 | */
|
104 | interface ColorSupport {
|
105 | /**
|
106 | The color level used by Chalk.
|
107 | */
|
108 | level: Level;
|
109 |
|
110 | /**
|
111 | Return whether Chalk supports basic 16 colors.
|
112 | */
|
113 | hasBasic: boolean;
|
114 |
|
115 | /**
|
116 | Return whether Chalk supports ANSI 256 colors.
|
117 | */
|
118 | has256: boolean;
|
119 |
|
120 | /**
|
121 | Return whether Chalk supports Truecolor 16 million colors.
|
122 | */
|
123 | has16m: boolean;
|
124 | }
|
125 |
|
126 | interface ChalkFunction {
|
127 | /**
|
128 | Use a template string.
|
129 |
|
130 | @remarks Template literals are unsupported for nested calls (see [issue #341](https://github.com/chalk/chalk/issues/341))
|
131 |
|
132 | @example
|
133 | ```
|
134 | import chalk = require('chalk');
|
135 |
|
136 | log(chalk`
|
137 | CPU: {red ${cpu.totalPercent}%}
|
138 | RAM: {green ${ram.used / ram.total * 100}%}
|
139 | DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
140 | `);
|
141 | ```
|
142 |
|
143 | @example
|
144 | ```
|
145 | import chalk = require('chalk');
|
146 |
|
147 | log(chalk.red.bgBlack`2 + 3 = {bold ${2 + 3}}`)
|
148 | ```
|
149 | */
|
150 | (text: TemplateStringsArray, ...placeholders: unknown[]): string;
|
151 |
|
152 | (...text: unknown[]): string;
|
153 | }
|
154 |
|
155 | interface Chalk extends ChalkFunction {
|
156 | /**
|
157 | Return a new Chalk instance.
|
158 | */
|
159 | Instance: Instance;
|
160 |
|
161 | /**
|
162 | The color support for Chalk.
|
163 |
|
164 | By default, color support is automatically detected based on the environment.
|
165 |
|
166 | Levels:
|
167 | - `0` - All colors disabled.
|
168 | - `1` - Basic 16 colors support.
|
169 | - `2` - ANSI 256 colors support.
|
170 | - `3` - Truecolor 16 million colors support.
|
171 | */
|
172 | level: Level;
|
173 |
|
174 | /**
|
175 | Use HEX value to set text color.
|
176 |
|
177 | @param color - Hexadecimal value representing the desired color.
|
178 |
|
179 | @example
|
180 | ```
|
181 | import chalk = require('chalk');
|
182 |
|
183 | chalk.hex('#DEADED');
|
184 | ```
|
185 | */
|
186 | hex(color: string): Chalk;
|
187 |
|
188 | /**
|
189 | Use keyword color value to set text color.
|
190 |
|
191 | @param color - Keyword value representing the desired color.
|
192 |
|
193 | @example
|
194 | ```
|
195 | import chalk = require('chalk');
|
196 |
|
197 | chalk.keyword('orange');
|
198 | ```
|
199 | */
|
200 | keyword(color: string): Chalk;
|
201 |
|
202 | /**
|
203 | Use RGB values to set text color.
|
204 | */
|
205 | rgb(red: number, green: number, blue: number): Chalk;
|
206 |
|
207 | /**
|
208 | Use HSL values to set text color.
|
209 | */
|
210 | hsl(hue: number, saturation: number, lightness: number): Chalk;
|
211 |
|
212 | /**
|
213 | Use HSV values to set text color.
|
214 | */
|
215 | hsv(hue: number, saturation: number, value: number): Chalk;
|
216 |
|
217 | /**
|
218 | Use HWB values to set text color.
|
219 | */
|
220 | hwb(hue: number, whiteness: number, blackness: number): Chalk;
|
221 |
|
222 | /**
|
223 | Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.
|
224 |
|
225 | 30 <= code && code < 38 || 90 <= code && code < 98
|
226 | For example, 31 for red, 91 for redBright.
|
227 | */
|
228 | ansi(code: number): Chalk;
|
229 |
|
230 | /**
|
231 | Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
232 | */
|
233 | ansi256(index: number): Chalk;
|
234 |
|
235 | /**
|
236 | Use HEX value to set background color.
|
237 |
|
238 | @param color - Hexadecimal value representing the desired color.
|
239 |
|
240 | @example
|
241 | ```
|
242 | import chalk = require('chalk');
|
243 |
|
244 | chalk.bgHex('#DEADED');
|
245 | ```
|
246 | */
|
247 | bgHex(color: string): Chalk;
|
248 |
|
249 | /**
|
250 | Use keyword color value to set background color.
|
251 |
|
252 | @param color - Keyword value representing the desired color.
|
253 |
|
254 | @example
|
255 | ```
|
256 | import chalk = require('chalk');
|
257 |
|
258 | chalk.bgKeyword('orange');
|
259 | ```
|
260 | */
|
261 | bgKeyword(color: string): Chalk;
|
262 |
|
263 | /**
|
264 | Use RGB values to set background color.
|
265 | */
|
266 | bgRgb(red: number, green: number, blue: number): Chalk;
|
267 |
|
268 | /**
|
269 | Use HSL values to set background color.
|
270 | */
|
271 | bgHsl(hue: number, saturation: number, lightness: number): Chalk;
|
272 |
|
273 | /**
|
274 | Use HSV values to set background color.
|
275 | */
|
276 | bgHsv(hue: number, saturation: number, value: number): Chalk;
|
277 |
|
278 | /**
|
279 | Use HWB values to set background color.
|
280 | */
|
281 | bgHwb(hue: number, whiteness: number, blackness: number): Chalk;
|
282 |
|
283 | /**
|
284 | Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.
|
285 |
|
286 | 30 <= code && code < 38 || 90 <= code && code < 98
|
287 | For example, 31 for red, 91 for redBright.
|
288 | Use the foreground code, not the background code (for example, not 41, nor 101).
|
289 | */
|
290 | bgAnsi(code: number): Chalk;
|
291 |
|
292 | /**
|
293 | Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
294 | */
|
295 | bgAnsi256(index: number): Chalk;
|
296 |
|
297 | /**
|
298 | Modifier: Resets the current color chain.
|
299 | */
|
300 | readonly reset: Chalk;
|
301 |
|
302 | /**
|
303 | Modifier: Make text bold.
|
304 | */
|
305 | readonly bold: Chalk;
|
306 |
|
307 | /**
|
308 | Modifier: Emitting only a small amount of light.
|
309 | */
|
310 | readonly dim: Chalk;
|
311 |
|
312 | /**
|
313 | Modifier: Make text italic. (Not widely supported)
|
314 | */
|
315 | readonly italic: Chalk;
|
316 |
|
317 | /**
|
318 | Modifier: Make text underline. (Not widely supported)
|
319 | */
|
320 | readonly underline: Chalk;
|
321 |
|
322 | /**
|
323 | Modifier: Inverse background and foreground colors.
|
324 | */
|
325 | readonly inverse: Chalk;
|
326 |
|
327 | /**
|
328 | Modifier: Prints the text, but makes it invisible.
|
329 | */
|
330 | readonly hidden: Chalk;
|
331 |
|
332 | /**
|
333 | Modifier: Puts a horizontal line through the center of the text. (Not widely supported)
|
334 | */
|
335 | readonly strikethrough: Chalk;
|
336 |
|
337 | /**
|
338 | Modifier: Prints the text only when Chalk has a color support level > 0.
|
339 | Can be useful for things that are purely cosmetic.
|
340 | */
|
341 | readonly visible: Chalk;
|
342 |
|
343 | readonly black: Chalk;
|
344 | readonly red: Chalk;
|
345 | readonly green: Chalk;
|
346 | readonly yellow: Chalk;
|
347 | readonly blue: Chalk;
|
348 | readonly magenta: Chalk;
|
349 | readonly cyan: Chalk;
|
350 | readonly white: Chalk;
|
351 |
|
352 | /*
|
353 | Alias for `blackBright`.
|
354 | */
|
355 | readonly gray: Chalk;
|
356 |
|
357 | /*
|
358 | Alias for `blackBright`.
|
359 | */
|
360 | readonly grey: Chalk;
|
361 |
|
362 | readonly blackBright: Chalk;
|
363 | readonly redBright: Chalk;
|
364 | readonly greenBright: Chalk;
|
365 | readonly yellowBright: Chalk;
|
366 | readonly blueBright: Chalk;
|
367 | readonly magentaBright: Chalk;
|
368 | readonly cyanBright: Chalk;
|
369 | readonly whiteBright: Chalk;
|
370 |
|
371 | readonly bgBlack: Chalk;
|
372 | readonly bgRed: Chalk;
|
373 | readonly bgGreen: Chalk;
|
374 | readonly bgYellow: Chalk;
|
375 | readonly bgBlue: Chalk;
|
376 | readonly bgMagenta: Chalk;
|
377 | readonly bgCyan: Chalk;
|
378 | readonly bgWhite: Chalk;
|
379 |
|
380 | /*
|
381 | Alias for `bgBlackBright`.
|
382 | */
|
383 | readonly bgGray: Chalk;
|
384 |
|
385 | /*
|
386 | Alias for `bgBlackBright`.
|
387 | */
|
388 | readonly bgGrey: Chalk;
|
389 |
|
390 | readonly bgBlackBright: Chalk;
|
391 | readonly bgRedBright: Chalk;
|
392 | readonly bgGreenBright: Chalk;
|
393 | readonly bgYellowBright: Chalk;
|
394 | readonly bgBlueBright: Chalk;
|
395 | readonly bgMagentaBright: Chalk;
|
396 | readonly bgCyanBright: Chalk;
|
397 | readonly bgWhiteBright: Chalk;
|
398 | }
|
399 | }
|
400 |
|
401 | /**
|
402 | Main Chalk object that allows to chain styles together.
|
403 | Call the last one as a method with a string argument.
|
404 | Order doesn't matter, and later styles take precedent in case of a conflict.
|
405 | This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
406 | */
|
407 | declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
|
408 | supportsColor: chalk.ColorSupport | false;
|
409 | Level: chalk.Level;
|
410 | Color: Color;
|
411 | ForegroundColor: ForegroundColor;
|
412 | BackgroundColor: BackgroundColor;
|
413 | Modifiers: Modifiers;
|
414 | stderr: chalk.Chalk & {supportsColor: chalk.ColorSupport | false};
|
415 | };
|
416 |
|
417 | declare const colors: {
|
418 | pink: chalk.Chalk;
|
419 | purple: chalk.Chalk;
|
420 | orange: chalk.Chalk;
|
421 | green: chalk.Chalk;
|
422 | blue: chalk.Chalk;
|
423 | red: chalk.Chalk;
|
424 | gray: chalk.Chalk;
|
425 | };
|
426 | declare const logger: {
|
427 | verbose: (message: string) => void;
|
428 | info: (message: string) => void;
|
429 | plain: (message: string) => void;
|
430 | line: (count?: number) => void;
|
431 | warn: (message: string) => void;
|
432 | trace: ({ message, time }: {
|
433 | message: string;
|
434 | time: [number, number];
|
435 | }) => void;
|
436 | setLevel: (level?: string) => void;
|
437 | error: (message: Error | string) => void;
|
438 | };
|
439 |
|
440 | declare const once: {
|
441 | (type: 'verbose' | 'info' | 'warn' | 'error'): (message: string) => void;
|
442 | clear(): void;
|
443 | verbose: (message: string) => void;
|
444 | info: (message: string) => void;
|
445 | warn: (message: string) => void;
|
446 | error: (message: string) => void;
|
447 | };
|
448 | declare const deprecate: (message: string) => void;
|
449 |
|
450 | export { colors, deprecate, logger, once };
|