Unverified Commit d8c4700a authored by Sukka's avatar Sukka Committed by GitHub

refactor(codemod): replace chalk with picocolors (#53115)

The PR replaces `chalk` inside `@next/codemod` with `picocolors`.

Generally, `@next/codemod` is used through `npx`/`pnpx` as it serves as a sort of "one-time fix". By replacing `chalk` with the `picocolors` (which is 14 times smaller and 2 times faster), we can speed up the installation process of `npx @next/codemod`.

Currently, `@next/codemod` has about 10k downloads per week, so I guess this PR is worth it:

<img width="441" alt="image" src="https://github.com/vercel/next.js/assets/40715044/a32fd6e0-bbe6-48e8-985d-83393c141b23">

In my next PR, I will replace `chalk` inside `create-next-app` with `picocolors` as well.
parent 909dad55
...@@ -13,7 +13,7 @@ import inquirer from 'inquirer' ...@@ -13,7 +13,7 @@ import inquirer from 'inquirer'
import meow from 'meow' import meow from 'meow'
import path from 'path' import path from 'path'
import execa from 'execa' import execa from 'execa'
import chalk from 'chalk' import { yellow } from 'picocolors'
import isGitClean from 'is-git-clean' import isGitClean from 'is-git-clean'
import { uninstallPackage } from '../lib/uninstall-package' import { uninstallPackage } from '../lib/uninstall-package'
...@@ -38,7 +38,7 @@ export function checkGitStatus(force) { ...@@ -38,7 +38,7 @@ export function checkGitStatus(force) {
} else { } else {
console.log('Thank you for using @next/codemod!') console.log('Thank you for using @next/codemod!')
console.log( console.log(
chalk.yellow( yellow(
'\nBut before we continue, please stash or commit your git changes.' '\nBut before we continue, please stash or commit your git changes.'
) )
) )
......
/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable import/no-extraneous-dependencies */
import chalk from 'chalk' import { yellow } from 'picocolors'
import spawn from 'cross-spawn' import spawn from 'cross-spawn'
interface InstallArgs { interface InstallArgs {
...@@ -70,9 +70,9 @@ export function install( ...@@ -70,9 +70,9 @@ export function install(
*/ */
args = ['install'] args = ['install']
if (!isOnline) { if (!isOnline) {
console.log(chalk.yellow('You appear to be offline.')) console.log(yellow('You appear to be offline.'))
if (useYarn) { if (useYarn) {
console.log(chalk.yellow('Falling back to the local Yarn cache.')) console.log(yellow('Falling back to the local Yarn cache.'))
console.log() console.log()
args.push('--offline') args.push('--offline')
} else { } else {
......
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
"directory": "packages/next-codemod" "directory": "packages/next-codemod"
}, },
"dependencies": { "dependencies": {
"chalk": "4.1.0",
"cheerio": "1.0.0-rc.9", "cheerio": "1.0.0-rc.9",
"execa": "4.0.3", "execa": "4.0.3",
"globby": "11.0.1", "globby": "11.0.1",
"inquirer": "7.3.3", "inquirer": "7.3.3",
"is-git-clean": "1.1.0", "is-git-clean": "1.1.0",
"jscodeshift": "0.13.1", "jscodeshift": "0.13.1",
"meow": "7.0.1" "meow": "7.0.1",
"picocolors": "1.0.0"
}, },
"files": [ "files": [
"transforms/*.js", "transforms/*.js",
......
...@@ -915,7 +915,6 @@ importers: ...@@ -915,7 +915,6 @@ importers:
packages/next-codemod: packages/next-codemod:
specifiers: specifiers:
'@types/jscodeshift': 0.11.0 '@types/jscodeshift': 0.11.0
chalk: 4.1.0
cheerio: 1.0.0-rc.9 cheerio: 1.0.0-rc.9
execa: 4.0.3 execa: 4.0.3
globby: 11.0.1 globby: 11.0.1
...@@ -923,8 +922,8 @@ importers: ...@@ -923,8 +922,8 @@ importers:
is-git-clean: 1.1.0 is-git-clean: 1.1.0
jscodeshift: 0.13.1 jscodeshift: 0.13.1
meow: 7.0.1 meow: 7.0.1
picocolors: 1.0.0
dependencies: dependencies:
chalk: 4.1.0
cheerio: 1.0.0-rc.9 cheerio: 1.0.0-rc.9
execa: 4.0.3 execa: 4.0.3
globby: 11.0.1 globby: 11.0.1
...@@ -932,6 +931,7 @@ importers: ...@@ -932,6 +931,7 @@ importers:
is-git-clean: 1.1.0 is-git-clean: 1.1.0
jscodeshift: 0.13.1_@babel+preset-env@7.22.2 jscodeshift: 0.13.1_@babel+preset-env@7.22.2
meow: 7.0.1 meow: 7.0.1
picocolors: 1.0.0
devDependencies: devDependencies:
'@types/jscodeshift': 0.11.0 '@types/jscodeshift': 0.11.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment