-
-
Notifications
You must be signed in to change notification settings - Fork 31
feat(chalk-to-util-styletext): introduce #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AugustinMauroy
merged 40 commits into
nodejs:main
from
richiemccoll:feat/chalk-styletext-migration
Dec 15, 2025
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
4fac653
feat(chalk-to-util-styletext): add workflow with basic test
richiemccoll 21781d6
feat(chalk-to-util-styletext): sync lockfile
richiemccoll 6944457
feat(chalk-to-util-styletext): add commonjs require case
richiemccoll e628155
Merge branch 'main' into feat/chalk-styletext-migration
richiemccoll eaf5469
feat(chalk-to-util-styletext): add bg color case
richiemccoll 8b29e26
feat(chalk-to-util-styletext): add chained case
richiemccoll 0c2b44a
feat(chalk-to-util-styletext): add advanced modifiers case
richiemccoll 54b3bb9
feat(chalk-to-util-styletext): add more modifiers to test case
richiemccoll 90d0648
feat(chalk-to-util-styletext): add modifiers test case
richiemccoll 1bf1736
feat(chalk-to-util-styletext): add mixed imports test case
richiemccoll 6a14179
feat(chalk-to-util-styletext): add dynamic imports test case
richiemccoll cefb46c
Merge branch 'main' into feat/chalk-styletext-migration
richiemccoll 324fb50
feat(chalk-to-util-styletext): refactoring
richiemccoll fa51707
feat(chalk-to-util-styletext): code review comments
richiemccoll 27a0ad2
Merge branch 'main' into feat/chalk-styletext-migration
richiemccoll 0482005
feat(chalk-to-util-styletext): code review comments
richiemccoll 8c762aa
Merge branch 'feat/chalk-styletext-migration' of github.com:richiemcc…
richiemccoll f2a5a8b
feat(chalk-to-util-styletext): handle different import cases
richiemccoll 09e8eaf
feat(chalk-to-util-styletext): add unsupported features test
richiemccoll 412f1ee
Merge branch 'main' into feat/chalk-styletext-migration
richiemccoll 34c97cd
feat(chalk-to-util-styletext): warn on unsupported method
richiemccoll 6d5433d
Merge branch 'feat/chalk-styletext-migration' of github.com:richiemcc…
richiemccoll 661902f
feat(chalk-to-util-styletext): handle method assignments
richiemccoll 3f41a08
feat(chalk-to-util-styletext): handle complex chaining
richiemccoll 0a88554
Merge branch 'main' into feat/chalk-styletext-migration
richiemccoll 4681188
feat(chalk-to-util-styletext): add esm import all test case
richiemccoll c556127
Merge branch 'feat/chalk-styletext-migration' of github.com:richiemcc…
richiemccoll 6c591b4
feat(chalk-to-util-styletext): update README
richiemccoll 8193bd7
feat(chalk-to-util-styletext): remove dependency util
richiemccoll 2270b25
Merge branch 'main' into feat/chalk-styletext-migration
richiemccoll 752e3b6
feat(chalk-to-util-styletext): add capabilities
richiemccoll 779d2a2
feat(chalk-to-util-styletext): add remove-dependencies integration test
richiemccoll eee225b
Merge branch 'main' into feat/chalk-styletext-migration
richiemccoll 76c44dd
Merge branch 'feat/chalk-styletext-migration' of github.com:richiemcc…
richiemccoll 72c45b6
feat(chalk-to-util-styletext): remove tsconfig
richiemccoll 841b379
feat(chalk-to-util-styletext): code review comments
richiemccoll 5fd422f
feat(chalk-to-util-styletext): formatting
richiemccoll e6f600b
Merge branch 'main' into feat/chalk-styletext-migration
richiemccoll b21ea01
Merge branch 'main' into feat/chalk-styletext-migration
richiemccoll eb346e0
feat: use allow list
richiemccoll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Chalk to util.styleText | ||
|
|
||
| This recipe migrates from the external `chalk` package to Node.js built-in `util.styleText` API. It transforms chalk method calls to use the native Node.js styling functionality. | ||
|
|
||
| ## Examples | ||
|
|
||
| ```diff | ||
| - import chalk from 'chalk'; | ||
| + import { styleText } from 'node:util'; | ||
| - console.log(chalk.red('Error message')); | ||
| + console.log(styleText('red', 'Error message')); | ||
| - console.log(chalk.green('Success message')); | ||
| + console.log(styleText('green', 'Success message')); | ||
| - console.log(chalk.blue('Info message')); | ||
| + console.log(styleText('blue', 'Info message')); | ||
| ``` | ||
|
|
||
| ```diff | ||
| - import chalk from 'chalk'; | ||
| + import { styleText } from 'node:util'; | ||
| - console.log(chalk.red.bold('Important error')); | ||
| + console.log(styleText(['red', 'bold'], 'Important error')); | ||
| - console.log(chalk.green.underline('Success with emphasis')); | ||
| + console.log(styleText(['green', 'underline'], 'Success with emphasis')); | ||
| ``` | ||
|
|
||
| ```diff | ||
| - const chalk = require('chalk'); | ||
| + const { styleText } = require('node:util'); | ||
| - const red = chalk.red; | ||
| + const red = (text) => styleText('red', text); | ||
| - const boldBlue = chalk.blue.bold; | ||
| + const boldBlue = (text) => styleText(['blue', 'bold'], text); | ||
| - console.log(red('Error')); | ||
| + console.log(red('Error')); | ||
| - console.log(boldBlue('Info')); | ||
| + console.log(boldBlue('Info')); | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| Run this codemod with: | ||
|
|
||
| ```sh | ||
| npx codemod nodejs/chalk-to-util-styletext | ||
| ``` | ||
|
|
||
| ## Compatibility | ||
|
|
||
| - **Removes chalk dependency** from package.json automatically | ||
| - **Supports most chalk methods**: colors, background colors, and text modifiers | ||
| - **Unsupported methods**: `hex()`, `rgb()`, `ansi256()`, `bgAnsi256()`, `visible()` (warnings will be shown) | ||
|
|
||
| ## Limitations | ||
|
|
||
| - **Complex conditional expressions** in some contexts may need manual review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| schema_version: "1.0" | ||
| name: "@nodejs/chalk-to-util-styletext" | ||
| version: 1.0.0 | ||
| capabilities: | ||
| - fs | ||
| - child_process | ||
| description: Migrate from the chalk package to Node.js's built-in util.styleText API | ||
| author: Richie McColl | ||
| license: MIT | ||
| workflow: workflow.yaml | ||
| category: migration | ||
|
|
||
| targets: | ||
| languages: | ||
| - javascript | ||
| - typescript | ||
|
|
||
| keywords: | ||
| - transformation | ||
| - migration | ||
|
|
||
| registry: | ||
| access: public | ||
| visibility: public | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "name": "@nodejs/chalk-to-util-styletext", | ||
| "version": "1.0.0", | ||
| "description": "Migrate from the chalk package to Node.js's built-in util.styleText API", | ||
| "type": "module", | ||
| "scripts": { | ||
| "test": "npx codemod jssg test -l typescript ./src/workflow.ts ./" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/nodejs/userland-migrations.git", | ||
| "directory": "recipes/chalk-to-util-styletext", | ||
| "bugs": "https://github.com/nodejs/userland-migrations/issues" | ||
| }, | ||
| "author": "Richie McColl", | ||
| "license": "MIT", | ||
| "homepage": "https://github.com/nodejs/userland-migrations/blob/main/recipes/chalk-to-util-styletext/README.md", | ||
| "devDependencies": { | ||
| "@codemod.com/jssg-types": "^1.0.9" | ||
| }, | ||
| "dependencies": { | ||
| "@nodejs/codemod-utils": "*" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import removeDependencies from '@nodejs/codemod-utils/remove-dependencies'; | ||
|
|
||
| /** | ||
| * Remove chalk and @types/chalk dependencies from package.json | ||
| */ | ||
| export default function removeChalkDependencies(): string | null { | ||
| return removeDependencies(['chalk', '@types/chalk']); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.