From eef8c8c191d25deecde8c472e10a37c6f736e2e9 Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Mon, 30 Sep 2019 21:13:15 -0400 Subject: [PATCH 01/88] Replace level list with table in readme.md (#367) * Replace level list with table in readme.md * Capitalize table headings and center level numbers --- readme.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 4a3b646..6e52c05 100644 --- a/readme.md +++ b/readme.md @@ -132,12 +132,12 @@ If you need to change this in a reusable module, create a new instance: const ctx = new chalk.Instance({level: 0}); ``` -Levels are as follows: - -0. All colors disabled -1. Basic color support (16 colors) -2. 256 color support -3. Truecolor support (16 million colors) +| Level | Description | +| :---: | :--- | +| `0` | All colors disabled | +| `1` | Basic color support (16 colors) | +| `2` | 256 color support | +| `3` | Truecolor support (16 million colors) | ### chalk.supportsColor From fb8e85ab875eb95b55448fd615daacf8c325cf44 Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Tue, 8 Oct 2019 05:02:34 -0400 Subject: [PATCH 02/88] Add `ansi256` and `bgAnsi256` to TypeScript declarations (#368) --- index.d.ts | 10 ++++++++++ index.test-d.ts | 2 ++ readme.md | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 52dd5ae..c50c17e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -213,6 +213,11 @@ declare namespace chalk { */ hwb(hue: number, whiteness: number, blackness: number): Chalk; + /** + Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color. + */ + ansi256(index: number): Chalk; + /** Use HEX value to set background color. @@ -261,6 +266,11 @@ declare namespace chalk { */ bgHwb(hue: number, whiteness: number, blackness: number): Chalk; + /** + Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color. + */ + bgAnsi256(index: number): Chalk; + /** Modifier: Resets the current color chain. */ diff --git a/index.test-d.ts b/index.test-d.ts index bc3d17a..dd3ba99 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -49,12 +49,14 @@ expectType(chalk.rgb(0, 0, 0)); expectType(chalk.hsl(0, 0, 0)); expectType(chalk.hsv(0, 0, 0)); expectType(chalk.hwb(0, 0, 0)); +expectType(chalk.ansi256(0)); expectType(chalk.bgHex('#DEADED')); expectType(chalk.bgKeyword('orange')); expectType(chalk.bgRgb(0, 0, 0)); expectType(chalk.bgHsl(0, 0, 0)); expectType(chalk.bgHsv(0, 0, 0)); expectType(chalk.bgHwb(0, 0, 0)); +expectType(chalk.bgAnsi256(0)); // -- Modifiers -- expectType(chalk.reset('foo')); diff --git a/readme.md b/readme.md index 6e52c05..7322f2b 100644 --- a/readme.md +++ b/readme.md @@ -260,9 +260,9 @@ The following color models can be used: - [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')` - [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')` - [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')` -- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')` +- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')` - `ansi16` -- `ansi256` +- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')` ## Windows From 4de1841129cf3d0a1db7a5d6638402b7828e1731 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 8 Oct 2019 16:21:40 +0700 Subject: [PATCH 03/88] 3.0.0-beta.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 32ea3bd..d22089b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chalk", - "version": "3.0.0-beta.1", + "version": "3.0.0-beta.2", "description": "Terminal string styling done right", "license": "MIT", "repository": "chalk/chalk", From 628b5954cf1ea07a00dfed13d51bbd95f5d42de1 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 30 Oct 2019 19:38:56 +0700 Subject: [PATCH 04/88] Tidelift tasks --- readme.md | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/readme.md b/readme.md index 7322f2b..aa0070a 100644 --- a/readme.md +++ b/readme.md @@ -275,6 +275,13 @@ If you're on Windows, do yourself a favor and use [Windows Terminal](https://git [colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative. +## chalk for enterprise + +Available as part of the Tidelift Subscription. + +The maintainers of chalk and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) + + ## Related - [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module @@ -297,16 +304,3 @@ If you're on Windows, do yourself a favor and use [Windows Terminal](https://git - [Sindre Sorhus](https://github.com/sindresorhus) - [Josh Junon](https://github.com/qix-) - - ---- - -
- - Get professional support for Chalk with a Tidelift subscription - -
- - Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. -
-
From 18c280da2ea2d8a29556891f771c0f7bcf5678ab Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Sat, 9 Nov 2019 01:22:55 -0500 Subject: [PATCH 05/88] Add `ansi` and `bgAnsi` to TypeScript declaration (#369) --- index.d.ts | 17 +++++++++++++++++ index.test-d.ts | 2 ++ readme.md | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index c50c17e..7e22c45 100644 --- a/index.d.ts +++ b/index.d.ts @@ -213,6 +213,14 @@ declare namespace chalk { */ hwb(hue: number, whiteness: number, blackness: number): Chalk; + /** + 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. + + 30 <= code && code < 38 || 90 <= code && code < 98 + For example, 31 for red, 91 for redBright. + */ + ansi(code: number): Chalk; + /** Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color. */ @@ -266,6 +274,15 @@ declare namespace chalk { */ bgHwb(hue: number, whiteness: number, blackness: number): Chalk; + /** + 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. + + 30 <= code && code < 38 || 90 <= code && code < 98 + For example, 31 for red, 91 for redBright. + Use the foreground code, not the background code (for example, not 41, nor 101). + */ + bgAnsi(code: number): Chalk; + /** Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color. */ diff --git a/index.test-d.ts b/index.test-d.ts index dd3ba99..177d6de 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -49,6 +49,7 @@ expectType(chalk.rgb(0, 0, 0)); expectType(chalk.hsl(0, 0, 0)); expectType(chalk.hsv(0, 0, 0)); expectType(chalk.hwb(0, 0, 0)); +expectType(chalk.ansi(30)); expectType(chalk.ansi256(0)); expectType(chalk.bgHex('#DEADED')); expectType(chalk.bgKeyword('orange')); @@ -56,6 +57,7 @@ expectType(chalk.bgRgb(0, 0, 0)); expectType(chalk.bgHsl(0, 0, 0)); expectType(chalk.bgHsv(0, 0, 0)); expectType(chalk.bgHwb(0, 0, 0)); +expectType(chalk.bgAnsi(30)); expectType(chalk.bgAnsi256(0)); // -- Modifiers -- diff --git a/readme.md b/readme.md index aa0070a..54c4aff 100644 --- a/readme.md +++ b/readme.md @@ -261,7 +261,7 @@ The following color models can be used: - [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')` - [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')` - [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')` -- `ansi16` +- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')` - [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')` From b3930189a54aa84434a2f3ea7a18ec83d6a5ee92 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 9 Nov 2019 13:56:12 +0700 Subject: [PATCH 06/88] Meta tweaks --- package.json | 4 ++-- readme.md | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index d22089b..724c0d5 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,8 @@ }, "devDependencies": { "ava": "^2.4.0", - "coveralls": "^3.0.5", - "execa": "^2.0.3", + "coveralls": "^3.0.7", + "execa": "^3.2.0", "import-fresh": "^3.1.0", "matcha": "^0.7.0", "nyc": "^14.1.1", diff --git a/readme.md b/readme.md index 54c4aff..877cb93 100644 --- a/readme.md +++ b/readme.md @@ -13,8 +13,6 @@ -**This readme reflects the next major version that is currently in development. You probably want [the v2 readme](https://www.npmjs.com/package/chalk).** - ## Highlights From 20002d8bd1dfd6f68bfa8bdacba520ff6027a450 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 9 Nov 2019 13:58:44 +0700 Subject: [PATCH 07/88] 3.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 724c0d5..047adf9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chalk", - "version": "3.0.0-beta.2", + "version": "3.0.0", "description": "Terminal string styling done right", "license": "MIT", "repository": "chalk/chalk", From 0e6fecc7f7fd8158d3c96fb89608b8dfb744fdfa Mon Sep 17 00:00:00 2001 From: Edwin Kofler <24364012+eankeen@users.noreply.github.com> Date: Thu, 12 Dec 2019 12:12:22 -0800 Subject: [PATCH 08/88] Add link to replit run (#379) --- .replit | 2 ++ readme.md | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .replit diff --git a/.replit b/.replit new file mode 100644 index 0000000..cf3930d --- /dev/null +++ b/.replit @@ -0,0 +1,2 @@ +language = "nodejs" +run = "cd examples && node rainbow" diff --git a/readme.md b/readme.md index 877cb93..c38fa60 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,7 @@ > Terminal string styling done right -[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![npm dependents](https://badgen.net/npm/dependents/chalk)](https://www.npmjs.com/package/chalk?activeTab=dependents) [![Downloads](https://badgen.net/npm/dt/chalk)](https://www.npmjs.com/package/chalk) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) ![TypeScript-ready](https://img.shields.io/npm/types/chalk.svg) +[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![npm dependents](https://badgen.net/npm/dependents/chalk)](https://www.npmjs.com/package/chalk?activeTab=dependents) [![Downloads](https://badgen.net/npm/dt/chalk)](https://www.npmjs.com/package/chalk) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) ![TypeScript-ready](https://img.shields.io/npm/types/chalk.svg) [![run on repl.it](http://repl.it/badge/github/chalk/chalk)](https://repl.it/github/chalk/chalk) From 797461ee3232c0013afc9b51d18ea2ba87227f10 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 1 Jan 2020 19:05:40 +0100 Subject: [PATCH 09/88] Meta tweaks --- package.json | 3 ++- readme.md | 14 +------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 047adf9..0a4aaa9 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Terminal string styling done right", "license": "MIT", "repository": "chalk/chalk", + "funding": "https://github.com/chalk/chalk?sponsor=1", "main": "source", "engines": { "node": ">=8" @@ -49,7 +50,7 @@ "execa": "^3.2.0", "import-fresh": "^3.1.0", "matcha": "^0.7.0", - "nyc": "^14.1.1", + "nyc": "^15.0.0", "resolve-from": "^5.0.0", "tsd": "^0.7.4", "xo": "^0.25.3" diff --git a/readme.md b/readme.md index c38fa60..a0ca245 100644 --- a/readme.md +++ b/readme.md @@ -13,7 +13,6 @@ - ## Highlights - Expressive API @@ -24,8 +23,7 @@ - Doesn't extend `String.prototype` - Clean and focused - Actively maintained -- [Used by ~46,000 packages](https://www.npmjs.com/browse/depended/chalk) as of October 1, 2019 - +- [Used by ~50,000 packages](https://www.npmjs.com/browse/depended/chalk) as of January 1, 2020 ## Install @@ -33,7 +31,6 @@ $ npm install chalk ``` - ## Usage ```js @@ -107,7 +104,6 @@ console.log(chalk.green('Hello %s'), name); //=> 'Hello Sindre' ``` - ## API ### chalk.`