Skip to content

Commit

Permalink
refactor(codemod): replace chalk with picocolors (#53115)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SukkaW committed Jul 24, 2023
1 parent 909dad5 commit d8c4700
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/next-codemod/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import inquirer from 'inquirer'
import meow from 'meow'
import path from 'path'
import execa from 'execa'
import chalk from 'chalk'
import { yellow } from 'picocolors'
import isGitClean from 'is-git-clean'
import { uninstallPackage } from '../lib/uninstall-package'

Expand All @@ -38,7 +38,7 @@ export function checkGitStatus(force) {
} else {
console.log('Thank you for using @next/codemod!')
console.log(
chalk.yellow(
yellow(
'\nBut before we continue, please stash or commit your git changes.'
)
)
Expand Down
6 changes: 3 additions & 3 deletions packages/next-codemod/lib/install.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
import chalk from 'chalk'
import { yellow } from 'picocolors'
import spawn from 'cross-spawn'

interface InstallArgs {
Expand Down Expand Up @@ -70,9 +70,9 @@ export function install(
*/
args = ['install']
if (!isOnline) {
console.log(chalk.yellow('You appear to be offline.'))
console.log(yellow('You appear to be offline.'))
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()
args.push('--offline')
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/next-codemod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"directory": "packages/next-codemod"
},
"dependencies": {
"chalk": "4.1.0",
"cheerio": "1.0.0-rc.9",
"execa": "4.0.3",
"globby": "11.0.1",
"inquirer": "7.3.3",
"is-git-clean": "1.1.0",
"jscodeshift": "0.13.1",
"meow": "7.0.1"
"meow": "7.0.1",
"picocolors": "1.0.0"
},
"files": [
"transforms/*.js",
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d8c4700

Please sign in to comment.