chore: replace chalk with picocolors

This commit is contained in:
Evan You 2023-10-20 10:23:18 +08:00
parent f23d951f90
commit ec5b36c770
8 changed files with 26 additions and 26 deletions

View File

@ -45,7 +45,6 @@
'typescript', 'typescript',
// ESM only // ESM only
'chalk',
'estree-walker' 'estree-walker'
] ]
} }

View File

@ -70,7 +70,6 @@
"@typescript-eslint/parser": "^6.7.2", "@typescript-eslint/parser": "^6.7.2",
"@vitest/coverage-istanbul": "^0.34.4", "@vitest/coverage-istanbul": "^0.34.4",
"@vue/consolidate": "0.17.3", "@vue/consolidate": "0.17.3",
"chalk": "^4.1.0",
"conventional-changelog-cli": "^4.1.0", "conventional-changelog-cli": "^4.1.0",
"enquirer": "^2.4.1", "enquirer": "^2.4.1",
"esbuild": "^0.19.3", "esbuild": "^0.19.3",
@ -87,6 +86,7 @@
"marked": "^9.1.1", "marked": "^9.1.1",
"minimist": "^1.2.8", "minimist": "^1.2.8",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"picocolors": "^1.0.0",
"prettier": "^3.0.3", "prettier": "^3.0.3",
"pretty-bytes": "^6.1.1", "pretty-bytes": "^6.1.1",
"pug": "^3.0.2", "pug": "^3.0.2",

View File

@ -47,9 +47,6 @@ importers:
'@vue/consolidate': '@vue/consolidate':
specifier: 0.17.3 specifier: 0.17.3
version: 0.17.3 version: 0.17.3
chalk:
specifier: ^4.1.0
version: 4.1.2
conventional-changelog-cli: conventional-changelog-cli:
specifier: ^4.1.0 specifier: ^4.1.0
version: 4.1.0 version: 4.1.0
@ -98,6 +95,9 @@ importers:
npm-run-all: npm-run-all:
specifier: ^4.1.5 specifier: ^4.1.5
version: 4.1.5 version: 4.1.5
picocolors:
specifier: ^1.0.0
version: 1.0.0
prettier: prettier:
specifier: ^3.0.3 specifier: ^3.0.3
version: 3.0.3 version: 3.0.3
@ -3959,6 +3959,7 @@ packages:
/js-tokens@4.0.0: /js-tokens@4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
requiresBuild: true
dev: true dev: true
/js-yaml@4.1.0: /js-yaml@4.1.0:

View File

@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url'
import path from 'node:path' import path from 'node:path'
import replace from '@rollup/plugin-replace' import replace from '@rollup/plugin-replace'
import json from '@rollup/plugin-json' import json from '@rollup/plugin-json'
import chalk from 'chalk' import pico from 'picocolors'
import commonJS from '@rollup/plugin-commonjs' import commonJS from '@rollup/plugin-commonjs'
import polyfillNode from 'rollup-plugin-polyfill-node' import polyfillNode from 'rollup-plugin-polyfill-node'
import { nodeResolve } from '@rollup/plugin-node-resolve' import { nodeResolve } from '@rollup/plugin-node-resolve'
@ -91,7 +91,7 @@ export default packageConfigs
function createConfig(format, output, plugins = []) { function createConfig(format, output, plugins = []) {
if (!output) { if (!output) {
console.log(chalk.yellow(`invalid format: "${format}"`)) console.log(pico.yellow(`invalid format: "${format}"`))
process.exit(1) process.exit(1)
} }

View File

@ -21,7 +21,7 @@ import { existsSync, readFileSync } from 'node:fs'
import path from 'node:path' import path from 'node:path'
import minimist from 'minimist' import minimist from 'minimist'
import { gzipSync, brotliCompressSync } from 'node:zlib' import { gzipSync, brotliCompressSync } from 'node:zlib'
import chalk from 'chalk' import pico from 'picocolors'
import { execa, execaSync } from 'execa' import { execa, execaSync } from 'execa'
import { cpus } from 'node:os' import { cpus } from 'node:os'
import { createRequire } from 'node:module' import { createRequire } from 'node:module'
@ -164,7 +164,7 @@ async function checkFileSize(filePath) {
const brotli = brotliCompressSync(file) const brotli = brotliCompressSync(file)
console.log( console.log(
`${chalk.gray(chalk.bold(fileName))} min:${prettyBytes( `${pico.gray(pico.bold(fileName))} min:${prettyBytes(
file.length file.length
)} / gzip:${prettyBytes(gzipped.length)} / brotli:${prettyBytes( )} / gzip:${prettyBytes(gzipped.length)} / brotli:${prettyBytes(
brotli.length brotli.length

View File

@ -2,7 +2,7 @@
import minimist from 'minimist' import minimist from 'minimist'
import fs from 'node:fs' import fs from 'node:fs'
import path from 'node:path' import path from 'node:path'
import chalk from 'chalk' import pico from 'picocolors'
import semver from 'semver' import semver from 'semver'
import enquirer from 'enquirer' import enquirer from 'enquirer'
import { execa } from 'execa' import { execa } from 'execa'
@ -73,16 +73,16 @@ const inc = i => semver.inc(currentVersion, i, preId)
const run = (bin, args, opts = {}) => const run = (bin, args, opts = {}) =>
execa(bin, args, { stdio: 'inherit', ...opts }) execa(bin, args, { stdio: 'inherit', ...opts })
const dryRun = (bin, args, opts = {}) => const dryRun = (bin, args, opts = {}) =>
console.log(chalk.blue(`[dryrun] ${bin} ${args.join(' ')}`), opts) console.log(pico.blue(`[dryrun] ${bin} ${args.join(' ')}`), opts)
const runIfNotDry = isDryRun ? dryRun : run const runIfNotDry = isDryRun ? dryRun : run
const getPkgRoot = pkg => path.resolve(__dirname, '../packages/' + pkg) const getPkgRoot = pkg => path.resolve(__dirname, '../packages/' + pkg)
const step = msg => console.log(chalk.cyan(msg)) const step = msg => console.log(pico.cyan(msg))
async function main() { async function main() {
if (!(await isInSyncWithRemote())) { if (!(await isInSyncWithRemote())) {
return return
} else { } else {
console.log(`${chalk.green(``)} commit is up-to-date with rmeote.\n`) console.log(`${pico.green(``)} commit is up-to-date with rmeote.\n`)
} }
let targetVersion = args._[0] let targetVersion = args._[0]
@ -285,7 +285,7 @@ async function main() {
if (skippedPackages.length) { if (skippedPackages.length) {
console.log( console.log(
chalk.yellow( pico.yellow(
`The following packages are skipped and NOT published:\n- ${skippedPackages.join( `The following packages are skipped and NOT published:\n- ${skippedPackages.join(
'\n- ' '\n- '
)}` )}`
@ -361,7 +361,7 @@ function updateDeps(pkg, depType, version, getNewPackageName) {
const newName = getNewPackageName(dep) const newName = getNewPackageName(dep)
const newVersion = newName === dep ? version : `npm:${newName}@${version}` const newVersion = newName === dep ? version : `npm:${newName}@${version}`
console.log( console.log(
chalk.yellow(`${pkg.name} -> ${depType} -> ${dep}@${newVersion}`) pico.yellow(`${pkg.name} -> ${depType} -> ${dep}@${newVersion}`)
) )
deps[dep] = newVersion deps[dep] = newVersion
} }
@ -407,10 +407,10 @@ async function publishPackage(pkgName, version) {
stdio: 'pipe' stdio: 'pipe'
} }
) )
console.log(chalk.green(`Successfully published ${pkgName}@${version}`)) console.log(pico.green(`Successfully published ${pkgName}@${version}`))
} catch (e) { } catch (e) {
if (e.stderr.match(/previously published/)) { if (e.stderr.match(/previously published/)) {
console.log(chalk.red(`Skipping already published: ${pkgName}`)) console.log(pico.red(`Skipping already published: ${pkgName}`))
} else { } else {
throw e throw e
} }

View File

@ -1,6 +1,6 @@
// @ts-check // @ts-check
import fs from 'node:fs' import fs from 'node:fs'
import chalk from 'chalk' import pico from 'picocolors'
import { createRequire } from 'node:module' import { createRequire } from 'node:module'
const require = createRequire(import.meta.url) const require = createRequire(import.meta.url)
@ -33,8 +33,8 @@ export function fuzzyMatchTarget(partialTargets, includeAllMatching) {
} else { } else {
console.log() console.log()
console.error( console.error(
` ${chalk.bgRed.white(' ERROR ')} ${chalk.red( ` ${pico.white(pico.bgRed(' ERROR '))} ${pico.red(
`Target ${chalk.underline(partialTargets)} not found!` `Target ${pico.underline(partialTargets)} not found!`
)}` )}`
) )
console.log() console.log()

View File

@ -1,5 +1,5 @@
// @ts-check // @ts-check
import chalk from 'chalk' import pico from 'picocolors'
import { readFileSync } from 'fs' import { readFileSync } from 'fs'
import path from 'path' import path from 'path'
@ -12,17 +12,17 @@ const commitRE =
if (!commitRE.test(msg)) { if (!commitRE.test(msg)) {
console.log() console.log()
console.error( console.error(
` ${chalk.bgRed.white(' ERROR ')} ${chalk.red( ` ${pico.white(pico.bgRed(' ERROR '))} ${pico.red(
`invalid commit message format.` `invalid commit message format.`
)}\n\n` + )}\n\n` +
chalk.red( pico.red(
` Proper commit message format is required for automated changelog generation. Examples:\n\n` ` Proper commit message format is required for automated changelog generation. Examples:\n\n`
) + ) +
` ${chalk.green(`feat(compiler): add 'comments' option`)}\n` + ` ${pico.green(`feat(compiler): add 'comments' option`)}\n` +
` ${chalk.green( ` ${pico.green(
`fix(v-model): handle events on blur (close #28)` `fix(v-model): handle events on blur (close #28)`
)}\n\n` + )}\n\n` +
chalk.red(` See .github/commit-convention.md for more details.\n`) pico.red(` See .github/commit-convention.md for more details.\n`)
) )
process.exit(1) process.exit(1)
} }