提交 d6834a79 编写于 作者: fxy060608's avatar fxy060608

fix: replace chalk with picocolors

上级 2d8c340b
......@@ -46,6 +46,8 @@ module.exports = {
files: [
'packages/{uni-cli-shared,uni-cli-nvue,uni-app-vite,uni-h5-vite,uni-mp-vite,uni-mp-compiler,vite-plugin-uni}/**',
'packages/*/vite.config.ts',
'.eslintrc.js',
'scripts/**',
],
rules: {
'no-restricted-globals': ['error', ...DOMGlobals],
......
......@@ -30,7 +30,6 @@
"@vue/server-renderer": "3.2.26",
"@vue/shared": "3.2.26",
"base64url": "^3.0.1",
"chalk": "^4.1.1",
"chokidar": "^3.5.2",
"compare-versions": "^3.6.0",
"debug": "^4.3.2",
......@@ -45,6 +44,7 @@
"merge": "^2.1.1",
"mime": "^3.0.0",
"module-alias": "^2.2.2",
"picocolors": "^1.0.0",
"postcss-import": "^14.0.2",
"postcss-load-config": "^3.1.0",
"postcss-modules": "^4.2.2",
......
import path from 'path'
import chalk from 'chalk'
import colors from 'picocolors'
import { LogErrorOptions } from 'vite'
import { normalizePath } from '../utils'
import { Formatter } from '../logs/format'
......@@ -75,16 +75,16 @@ function buildErrorMessage(
): string {
if (err.plugin) {
args.push(
`${chalk.magenta('[plugin:' + err.plugin + ']')} ${chalk.red(
`${colors.magenta('[plugin:' + err.plugin + ']')} ${colors.red(
err.message
)}`
)
} else {
args.push(chalk.red(err.message))
args.push(colors.red(err.message))
}
if (err.id) {
args.push(
`at ${chalk.cyan(
`at ${colors.cyan(
normalizePath(
path.relative(process.env.UNI_INPUT_DIR, err.id.split('?')[0])
) +
......@@ -96,7 +96,7 @@ function buildErrorMessage(
)
}
if (err.frame) {
args.push(chalk.yellow(pad(err.frame)))
args.push(colors.yellow(pad(err.frame)))
}
if (includeStack && err.stack) {
args.push(pad(cleanStack(err.stack)))
......
import fs from 'fs'
import path from 'path'
import glob from 'fast-glob'
import chalk from 'chalk'
import colors from 'picocolors'
import postcssrc from 'postcss-load-config'
import { dataToEsm } from '@rollup/pluginutils'
import { PluginContext, RollupError, SourceMap } from 'rollup'
......@@ -567,7 +567,7 @@ async function compileCSS(
column: message.column,
})}`
}
config.logger.warn(chalk.yellow(msg))
config.logger.warn(colors.yellow(msg))
}
}
......@@ -716,7 +716,7 @@ export async function minifyCSS(css: string, config: ResolvedConfig) {
if (warnings.length) {
const msgs = await formatMessages(warnings, { kind: 'warning' })
config.logger.warn(
chalk.yellow(`warnings when minifying css:\n${msgs.join('\n')}`)
colors.yellow(`warnings when minifying css:\n${msgs.join('\n')}`)
)
}
return code
......
......@@ -36,13 +36,13 @@
"@vue/compiler-sfc": "3.2.26",
"@vue/shared": "3.2.26",
"cac": "^6.7.3",
"chalk": "^4.1.1",
"debug": "^4.3.2",
"estree-walker": "^2.0.2",
"express": "^4.17.1",
"fs-extra": "^10.0.0",
"hash-sum": "^2.0.0",
"jsonc-parser": "^3.0.0"
"jsonc-parser": "^3.0.0",
"picocolors": "^1.0.0"
},
"devDependencies": {
"@types/debug": "^4.1.7",
......
import fs from 'fs'
import path from 'path'
import chalk from 'chalk'
import colors from 'picocolors'
import {
createLogger,
createServer as createViteServer,
......@@ -28,8 +28,8 @@ export async function createServer(options: CliOptions & ServerOptions) {
const logger = server.config.logger
logger.info(
chalk.cyan(`\n vite v${require('vite/package.json').version}`) +
chalk.green(` dev server running at:\n`),
colors.cyan(`\n vite v${require('vite/package.json').version}`) +
colors.green(` dev server running at:\n`),
{
clear: !server.config.logger.hasWarned,
}
......
import fs from 'fs'
import os from 'os'
import path from 'path'
import chalk from 'chalk'
import colors from 'picocolors'
import { performance } from 'perf_hooks'
import { BuildOptions, InlineConfig, Logger } from 'vite'
......@@ -209,7 +209,7 @@ export function printStartupDuration(
// @ts-ignore
const startupDuration = performance.now() - global.__vite_start_time
logger.info(
`${whitespace ? `\n ` : ''}${chalk.cyan(
`${whitespace ? `\n ` : ''}${colors.cyan(
`ready in ${Math.ceil(startupDuration)}ms.`
)}\n`
)
......
......@@ -24,7 +24,6 @@ importers:
'@vue/runtime-core': 3.2.26
'@vue/runtime-dom': 3.2.26
'@vue/shared': 3.2.26
chalk: ^4.1.1
core-js: ^2.6.12
enquirer: ^2.3.6
eslint: ^7.17.0
......@@ -35,6 +34,7 @@ importers:
mini-types: ^0.1.7
minimist: ^1.2.5
miniprogram-api-typings: ^3.4.4
picocolors: ^1.0.0
prettier: ^2.4.1
rollup: ^2.57.0
rollup-plugin-jscc: ^2.0.0
......@@ -71,7 +71,6 @@ importers:
'@vue/runtime-core': 3.2.26
'@vue/runtime-dom': 3.2.26
'@vue/shared': 3.2.26
chalk: 4.1.2
core-js: 2.6.12
enquirer: 2.3.6
eslint: 7.32.0
......@@ -82,6 +81,7 @@ importers:
mini-types: 0.1.7
minimist: 1.2.5
miniprogram-api-typings: 3.4.4
picocolors: 1.0.0
prettier: 2.5.1
rollup: 2.60.2
rollup-plugin-jscc: 2.0.0_rollup@2.60.2
......@@ -372,7 +372,6 @@ importers:
'@vue/server-renderer': 3.2.26
'@vue/shared': 3.2.26
base64url: ^3.0.1
chalk: ^4.1.1
chokidar: ^3.5.2
compare-versions: ^3.6.0
debug: ^4.3.2
......@@ -387,6 +386,7 @@ importers:
merge: ^2.1.1
mime: ^3.0.0
module-alias: ^2.2.2
picocolors: ^1.0.0
postcss: ^8.4.5
postcss-import: ^14.0.2
postcss-load-config: ^3.1.0
......@@ -408,7 +408,6 @@ importers:
'@vue/server-renderer': 3.2.26_vue@3.2.26
'@vue/shared': 3.2.26
base64url: 3.0.1
chalk: 4.1.2
chokidar: 3.5.2
compare-versions: 3.6.0
debug: 4.3.3
......@@ -423,6 +422,7 @@ importers:
merge: 2.1.1
mime: 3.0.0
module-alias: 2.2.2
picocolors: 1.0.0
postcss-import: 14.0.2_postcss@8.4.5
postcss-load-config: 3.1.0
postcss-modules: 4.2.2_postcss@8.4.5
......@@ -806,7 +806,6 @@ importers:
'@vue/compiler-sfc': 3.2.26
'@vue/shared': 3.2.26
cac: ^6.7.3
chalk: ^4.1.1
chokidar: ^3.5.2
debug: ^4.3.2
estree-walker: ^2.0.2
......@@ -814,6 +813,7 @@ importers:
fs-extra: ^10.0.0
hash-sum: ^2.0.0
jsonc-parser: ^3.0.0
picocolors: ^1.0.0
dependencies:
'@babel/core': 7.16.5
'@babel/plugin-syntax-import-meta': 7.10.4_@babel+core@7.16.5
......@@ -829,13 +829,13 @@ importers:
'@vue/compiler-sfc': 3.2.26
'@vue/shared': 3.2.26
cac: 6.7.12
chalk: 4.1.2
debug: 4.3.3
estree-walker: 2.0.2
express: 4.17.1
fs-extra: 10.0.0
hash-sum: 2.0.0
jsonc-parser: 3.0.0
picocolors: 1.0.0
devDependencies:
'@types/debug': 4.1.7
'@types/express': 4.17.13
......@@ -3580,6 +3580,7 @@ packages:
engines: {node: '>=8'}
dependencies:
color-convert: 2.0.1
dev: true
/ansi-styles/5.2.0:
resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==}
......@@ -4052,6 +4053,7 @@ packages:
dependencies:
ansi-styles: 4.3.0
supports-color: 7.2.0
dev: true
/char-regex/1.0.2:
resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==}
......@@ -4162,12 +4164,14 @@ packages:
engines: {node: '>=7.0.0'}
dependencies:
color-name: 1.1.4
dev: true
/color-name/1.1.3:
resolution: {integrity: sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=}
/color-name/1.1.4:
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
dev: true
/colorette/2.0.16:
resolution: {integrity: sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g==}
......@@ -8500,6 +8504,7 @@ packages:
engines: {node: '>=8'}
dependencies:
has-flag: 4.0.0
dev: true
/supports-color/8.1.1:
resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==}
......
const fs = require('fs-extra')
const path = require('path')
const chalk = require('chalk')
const colors = require('picocolors')
exports.extract = async function extract(target) {
const pkgDir = path.resolve(`packages/${target}`)
console.log()
console.log(
chalk.bold(chalk.yellow(`Rolling up type definitions for ${target}...`))
colors.bold(colors.yellow(`Rolling up type definitions for ${target}...`))
)
// build types
const { Extractor, ExtractorConfig } = require('@microsoft/api-extractor')
const extractorConfigPath = path.resolve(pkgDir, `api-extractor.json`)
const extractorConfig = ExtractorConfig.loadFileAndPrepare(
extractorConfigPath
)
const extractorConfig =
ExtractorConfig.loadFileAndPrepare(extractorConfigPath)
const extractorResult = Extractor.invoke(extractorConfig, {
localBuild: true,
showVerboseMessages: true
showVerboseMessages: true,
})
if (extractorResult.succeeded) {
console.log(
chalk.bold(chalk.green(`API Extractor completed successfully.`))
colors.bold(colors.green(`API Extractor completed successfully.`))
)
} else {
console.error(
......
const fs = require('fs-extra')
const path = require('path')
const chalk = require('chalk')
const colors = require('picocolors')
const execa = require('execa')
const { spawn } = require('child_process')
......@@ -88,7 +88,7 @@ async function buildAll(targets) {
}
async function build(target) {
console.log(`\n${chalk.blueBright(chalk.bold(target))}:`)
console.log(`\n${colors.bold(target)}:`)
const pkgDir = path.resolve(`packages/${target}`)
const pkg = require(`${pkgDir}/package.json`)
......
const args = require('minimist')(process.argv.slice(2))
const fs = require('fs')
const path = require('path')
const chalk = require('chalk')
const colors = require('picocolors')
const semver = require('semver')
const currentVersion = require('../package.json').version
const { prompt } = require('enquirer')
......@@ -22,10 +22,10 @@ const bin = (name) => path.resolve(__dirname, '../node_modules/.bin/' + name)
const run = (bin, args, opts = {}) =>
execa(bin, args, { stdio: 'inherit', ...opts })
const dryRun = (bin, args, opts = {}) =>
console.log(chalk.blue(`[dryrun] ${bin} ${args.join(' ')}`), opts)
console.log(colors.blue(`[dryrun] ${bin} ${args.join(' ')}`), opts)
const runIfNotDry = isDryRun ? dryRun : run
const getPkgRoot = (pkg) => path.resolve(__dirname, '../packages/' + pkg)
const step = (msg) => console.log(chalk.cyan(msg))
const step = (msg) => console.log(colors.cyan(msg))
async function main() {
const targetVersion = (
......@@ -106,7 +106,7 @@ async function main() {
if (skippedPackages.length) {
console.log(
chalk.yellow(
colors.yellow(
`The following packages are skipped and NOT published:\n- ${skippedPackages.join(
'\n- '
)}`
......@@ -142,7 +142,7 @@ function updateDeps(pkg, depType, version) {
packages.includes(dep.replace(/^@dcloudio\//, ''))
) {
console.log(
chalk.yellow(`${pkg.name} -> ${depType} -> ${dep}@${version}`)
colors.yellow(`${pkg.name} -> ${depType} -> ${dep}@${version}`)
)
deps[dep] = version
}
......@@ -181,10 +181,10 @@ async function publishPackage(pkgName, version, runIfNotDry) {
stdio: 'pipe',
}
)
console.log(chalk.green(`Successfully published ${pkgName}@${version}`))
console.log(colors.green(`Successfully published ${pkgName}@${version}`))
} catch (e) {
if (e.stderr.match(/previously published/)) {
console.log(chalk.red(`Skipping already published: ${pkgName}`))
console.log(colors.red(`Skipping already published: ${pkgName}`))
} else {
throw e
}
......
const fs = require('fs')
const path = require('path')
const chalk = require('chalk')
const colors = require('picocolors')
const { prompt } = require('enquirer')
const { resolvePackages } = require('./utils')
const args = process.argv.slice(2)
......@@ -38,7 +38,7 @@ function updateDeps(pkg, depType, module, oldVersion, newVersion) {
if (deps[name].includes(oldVersion)) {
deps[name] = deps[name].replace(oldVersion, newVersion)
console.log(
chalk.yellow(`${pkg.name} -> ${depType} -> ${name}@${newVersion}`)
colors.yellow(`${pkg.name} -> ${depType} -> ${name}@${newVersion}`)
)
}
}
......
const fs = require('fs')
const path = require('path')
const chalk = require('chalk')
const colors = require('picocolors')
const priority = {
'uni-shared': 100,
......@@ -65,8 +65,8 @@ exports.fuzzyMatchTarget = (partialTargets, includeAllMatching) => {
} else {
console.log()
console.error(
` ${chalk.bgRed.white(' ERROR ')} ${chalk.red(
`Target ${chalk.underline(partialTargets)} not found!`
` ${colors.bgRed.white(' ERROR ')} ${colors.red(
`Target ${colors.underline(partialTargets)} not found!`
)}`
)
console.log()
......
// Invoked on the commit-msg git hook by yorkie.
const chalk = require('chalk')
const colors = require('picocolors')
const msgPath = process.env.GIT_PARAMS
const msg = require('fs')
.readFileSync(msgPath, 'utf-8')
.trim()
const msg = require('fs').readFileSync(msgPath, 'utf-8').trim()
const commitRE = /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/
const commitRE =
/^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/
if (!commitRE.test(msg)) {
console.log()
console.error(
` ${chalk.bgRed.white(' ERROR ')} ${chalk.red(
` ${colors.bgRed.white(' ERROR ')} ${colors.red(
`invalid commit message format.`
)}\n\n` +
chalk.red(
colors.red(
` Proper commit message format is required for automated changelog generation. Examples:\n\n`
) +
` ${chalk.green(`feat(compiler): add 'comments' option`)}\n` +
` ${chalk.green(
` ${colors.green(`feat(compiler): add 'comments' option`)}\n` +
` ${colors.green(
`fix(v-model): handle events on blur (close #28)`
)}\n\n` +
chalk.red(` See .github/commit-convention.md for more details.\n`)
colors.red(` See .github/commit-convention.md for more details.\n`)
)
process.exit(1)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册