From 102ef04febba0c7f86f27ead9fa4050a950e87c3 Mon Sep 17 00:00:00 2001 From: Richie McColl Date: Fri, 19 Dec 2025 15:01:16 +0200 Subject: [PATCH 1/5] feat: add migration guide for chalk to util styletext codemod --- .../en/blog/migrations/chalk-to-styletext.mdx | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx diff --git a/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx b/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx new file mode 100644 index 0000000000000..0561c984beac7 --- /dev/null +++ b/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx @@ -0,0 +1,67 @@ +--- +date: '2025-12-19T00:00:00.000Z' +category: migrations +title: Chalk to Node.js util styleText +layout: blog-post +author: richiemccoll +--- + +# Migrate from Chalk to Node.js util styleText + +## `chalk-to-util-styletext` + +This codemod aims to help you reduce external dependencies by transforming chalk method calls to use the native Node.js styling functionality. It will also handle automatic removal of the `chalk` package from the package.json. + +### Compatible Features: + +- Basic colors (red, green, blue, yellow, etc.) +- Bright colors (redBright, greenBright, etc.) +- Background colors (bgRed, bgGreen, etc.) +- Text modifiers (bold, dim, italic, underline, strikethrough, etc.) +- Style chaining via array syntax +- Environment variable support (NO_COLOR, NODE_DISABLE_COLORS, FORCE_COLOR) + +### Non-Compatible Features: + +- Custom RGB colors (chalk.rgb(), chalk.hex()) +- 256-color palette (chalk.ansi256()) +- Template literal syntax (chalk...``) + -Advanced modifiers with limited terminal support (overline, blink, etc.) + +The source code for this codemod can be found in the [chalk-to-util-styletext directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/chalk-to-util-styletext). + +You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/chalk-to-util-styletext). + +```bash +npx codemod @nodejs/chalk-to-util-styletext +``` + +### Example: + +```js displayName="Before" +import chalk from 'chalk'; + +console.log(chalk.red('Error message')); + +console.log(chalk.red.bold('Important error')); + +const red = chalk.red; +console.log(red('Error')); + +const boldBlue = chalk.blue.bold; +console.log(boldBlue('Info')); +``` + +```js displayName="After" +import { styleText } from 'node:util'; + +console.log(styleText('red', 'Error message')); + +console.log(styleText(['red', 'bold'], 'Important error')); + +const red = text => styleText('red', text); +console.log(red('Error')); + +const boldBlue = text => styleText(['blue', 'bold'], text); +console.log(boldBlue('Info')); +``` From f9d81801df2160c3c02fcb8cf962bfc125a50057 Mon Sep 17 00:00:00 2001 From: Richie McColl Date: Fri, 19 Dec 2025 15:12:37 +0200 Subject: [PATCH 2/5] chore: fix formatting --- apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx b/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx index 0561c984beac7..48f3b10092d6d 100644 --- a/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx +++ b/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx @@ -26,7 +26,7 @@ This codemod aims to help you reduce external dependencies by transforming chalk - Custom RGB colors (chalk.rgb(), chalk.hex()) - 256-color palette (chalk.ansi256()) - Template literal syntax (chalk...``) - -Advanced modifiers with limited terminal support (overline, blink, etc.) +- Advanced modifiers with limited terminal support (overline, blink, etc.) The source code for this codemod can be found in the [chalk-to-util-styletext directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/chalk-to-util-styletext). From 4c08f373145c7494463790cb793576b6db13d603 Mon Sep 17 00:00:00 2001 From: Richie McColl Date: Mon, 22 Dec 2025 10:50:52 +0200 Subject: [PATCH 3/5] feat: update authors.json --- apps/site/authors.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/site/authors.json b/apps/site/authors.json index 646f4d2be3b06..921742c7e1781 100644 --- a/apps/site/authors.json +++ b/apps/site/authors.json @@ -222,6 +222,11 @@ "name": "Richard Lau", "website": "https://github.com/richardlau" }, + "Richie McColl": { + "id": "richiemccoll", + "name": "Richie McColl", + "website": "https://github.com/richiemccoll" + }, "Robin Bender Ginn": { "id": "rginn", "name": "Robin Bender Ginn", From 6e7d37ee2add2ebd9e56f23fb36ac5d0ce4b60e3 Mon Sep 17 00:00:00 2001 From: Richie McColl Date: Tue, 6 Jan 2026 11:03:20 +0200 Subject: [PATCH 4/5] feat: add version notes --- .../site/pages/en/blog/migrations/chalk-to-styletext.mdx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx b/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx index 48f3b10092d6d..92bf9525ed6df 100644 --- a/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx +++ b/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx @@ -28,6 +28,15 @@ This codemod aims to help you reduce external dependencies by transforming chalk - Template literal syntax (chalk...``) - Advanced modifiers with limited terminal support (overline, blink, etc.) +### Prerequisites: + +#### Node.js Version Requirements + +- Node.js v20.12.0 or later (for util.styleText) +- `util.styleText` became stable in Node.js v22.13.0 (and v23.5.0) + +### Usage: + The source code for this codemod can be found in the [chalk-to-util-styletext directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/chalk-to-util-styletext). You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/chalk-to-util-styletext). From 1d353e29112c8d9419c8837b5ccd6d7eb8509112 Mon Sep 17 00:00:00 2001 From: Richie McColl Date: Mon, 19 Jan 2026 18:55:03 +0200 Subject: [PATCH 5/5] fix: review comments --- .../pages/en/blog/migrations/chalk-to-styletext.mdx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx b/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx index 92bf9525ed6df..e4c24a1e90d9d 100644 --- a/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx +++ b/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx @@ -1,5 +1,5 @@ --- -date: '2025-12-19T00:00:00.000Z' +date: '2026-01-19T00:00:00.000Z' category: migrations title: Chalk to Node.js util styleText layout: blog-post @@ -10,7 +10,7 @@ author: richiemccoll ## `chalk-to-util-styletext` -This codemod aims to help you reduce external dependencies by transforming chalk method calls to use the native Node.js styling functionality. It will also handle automatic removal of the `chalk` package from the package.json. +This codemod aims to help you reduce external dependencies by transforming chalk method calls to use the native Node.js styling functionality. It will also handle automatic removal of the [`chalk`](https://github.com/chalk/chalk) package from the package.json. ### Compatible Features: @@ -35,6 +35,8 @@ This codemod aims to help you reduce external dependencies by transforming chalk - Node.js v20.12.0 or later (for util.styleText) - `util.styleText` became stable in Node.js v22.13.0 (and v23.5.0) +> If your package supports a version earlier than 22, this creates a breaking change, which means you must bump the major version of your package. + ### Usage: The source code for this codemod can be found in the [chalk-to-util-styletext directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/chalk-to-util-styletext). @@ -74,3 +76,7 @@ console.log(red('Error')); const boldBlue = text => styleText(['blue', 'bold'], text); console.log(boldBlue('Info')); ``` + +## Recognition + +We would like to thank the maintainers of [`chalk`](https://github.com/chalk/chalk) for their support of the package over time and for its contributions to the ecosystem.