Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use picocolors instead chalk #1597

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"husky": "^8.0.3",
"less": "^4.2.0",
"node-libs-browser-okam": "^2.2.5",
"picocolors": "^1.1.0",
"playwright": "^1.39.0",
"portfinder": "^1.0.32",
"preact": "10.22.0",
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 @@ -203,10 +203,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 @@ -380,7 +378,7 @@ function checkConfig(opts) {

if (warningKeys.length) {
console.warn(
chalk.yellow(
c.yellow(
`
=====================================================================================================

Expand All @@ -397,7 +395,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
Loading