Skip to content

Commit

Permalink
refactor: use picocolors instead chalk
Browse files Browse the repository at this point in the history
  • Loading branch information
wChenonly committed Sep 13, 2024
1 parent e9af895 commit 465d040
Show file tree
Hide file tree
Showing 9 changed files with 11,277 additions and 9,613 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"react-error-overlay": "6.0.9",
"picocolors": "^1.1.0",
"react-refresh": "^0.14.0",
"sass": "^1.77.8",
"semver": "^7.5.4",
Expand Down
12 changes: 5 additions & 7 deletions packages/bundler-mako/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const http = require('http');
const assert = require('assert');
const { createProxy, createHttpsServer } = require('@umijs/bundler-utils');
const lodash = require('lodash');
const chalk = require('chalk');
const c = require('picocolors');
const { parseTsconfig } = require('get-tsconfig');
const {
createProxyMiddleware,
Expand Down Expand Up @@ -241,10 +241,8 @@ function getDevBanner(protocol, host, port, ip) {
const hostStr = host === '0.0.0.0' ? 'localhost' : host;
const messages = [];
messages.push(' App listening at:');
messages.push(
` - Local: ${chalk.cyan(`${protocol}//${hostStr}:${port}`)}`,
);
messages.push(` - Network: ${chalk.cyan(`${protocol}//${ip}:${port}`)}`);
messages.push(` - Local: ${c.cyan(`${protocol}//${hostStr}:${port}`)}`);
messages.push(` - Network: ${c.cyan(`${protocol}//${ip}:${port}`)}`);
return messages.join('\n');
}

Expand Down Expand Up @@ -418,7 +416,7 @@ function checkConfig(opts) {

if (warningKeys.length) {
console.warn(
chalk.yellow(
c.yellow(
`
=====================================================================================================
Expand All @@ -435,7 +433,7 @@ function checkConfig(opts) {
Mako bundler does not support the following options:
- ${warningKeys.join('\n - ')}
So this project may fail in compile-time or error in runtime, ${chalk.bold(
So this project may fail in compile-time or error in runtime, ${c.bold(
'please test and release carefully',
)}.
=====================================================================================================
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler-mako/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dependencies": {
"@umijs/bundler-utils": "^4.0.81",
"@umijs/mako": "0.8.12",
"chalk": "^4.1.2",
"picocolors": "^1.1.0",
"compression": "^1.7.4",
"connect-history-api-fallback": "^2.0.0",
"cors": "^2.8.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/mako/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@swc/helpers": "0.5.1",
"@types/resolve": "^1.20.6",
"chalk": "^4.1.2",
"picocolors": "^1.1.0",
"less": "^4.2.0",
"less-plugin-resolve": "^1.0.2",
"lodash": "^4.17.21",
Expand Down Expand Up @@ -87,4 +87,4 @@
"@umijs/mako-linux-x64-musl": "0.8.12"
},
"repository": "[email protected]:umijs/mako.git"
}
}
4 changes: 2 additions & 2 deletions packages/mako/src/checker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import path from 'path';
import chalk from 'chalk';
import c from 'picocolors';
import semver from 'semver';

let BLACKLIST_PACKAGES: any = {
Expand Down Expand Up @@ -28,7 +28,7 @@ export function check(root: string) {
version &&
semver.satisfies(version, BLACKLIST_PACKAGES[name].version)
) {
console.error(chalk.red(`Error: ${BLACKLIST_PACKAGES[name].message}`));
console.error(c.red(`Error: ${BLACKLIST_PACKAGES[name].message}`));
process.exit(1);
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/mako/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import c from 'picocolors';
import yParser from 'yargs-parser';
import { check } from './checker';

Expand All @@ -7,7 +7,7 @@ import { check } from './checker';
// so that we can print extra information
process.env.MAKO_CLI = '1';
console.log();
console.log(chalk.bold(`Mako v${require('../package.json').version}`));
console.log(c.bold(`Mako v${require('../package.json').version}`));
console.log();

let argv = yParser(process.argv.slice(2));
Expand Down
Loading

0 comments on commit 465d040

Please sign in to comment.