index.d.ts 9.7 KB

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