From 40f758fbc0b16b793451bb3026f73670962e0bd8 Mon Sep 17 00:00:00 2001 From: Arthur Ming Date: Thu, 10 Feb 2022 22:54:02 +0800 Subject: [PATCH] chore: use colors instead of chalk --- package.json | 10 +++++----- scripts/build.js | 6 +++--- scripts/publish.js | 18 +++++++++--------- scripts/release.js | 18 +++++++++--------- yarn.lock | 4 ++-- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index efda6716..19d16aae 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,10 @@ "release:alpha": "node scripts/release.js --preId alpha", "release:beta": "node scripts/release.js --preId beta", "prepare": "npx husky install", - "publish-npm": "node scripts/publish.js " + "publish-npm": "node scripts/publish.js" + }, + "dependencies": { + "tslib": "^2.3.1" }, "devDependencies": { "@commitlint/cli": "^16.0.1", @@ -43,7 +46,7 @@ "@typescript-eslint/eslint-plugin": "^5.6.0", "@typescript-eslint/eslint-plugin-tslint": "^5.6.0", "@typescript-eslint/parser": "^5.6.0", - "chalk": "^4.1.2", + "colors": "1.4.0", "conventional-changelog-cli": "^2.2.2", "enquirer": "^2.3.6", "eslint": "^8.6.0", @@ -67,8 +70,5 @@ }, "resolutions": { "**/**/axios": ">=0.21.1" - }, - "dependencies": { - "tslib": "^2.3.1" } } diff --git a/scripts/build.js b/scripts/build.js index aa8cac31..69b4da94 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -6,7 +6,7 @@ // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -const chalk = require('chalk'); +const colors = require('colors/safe'); const fs = require('fs/promises'); const fsEx = require('fs-extra'); const path = require('path'); @@ -37,7 +37,7 @@ async function buildTarget(target) { }) .map(f => fs.copyFile(f.src, f.dest)); await Promise.all(copyTasks); - console.log(`${chalk.blue(target.name)} ${chalk.green('success')} 🚀`); + console.log(`${colors.blue(target.name)} ${colors.green('success')} 🚀`); await fs.rm(`${path.resolve('./node_modules/' + target.name)}`, { force: true, @@ -49,7 +49,7 @@ async function buildTarget(target) { ); } else { console.log( - `${chalk.blue(target.name)} ${chalk.cyan('skip')} for private module` + `${colors.blue(target.name)} ${colors.cyan('skip')} for private module` ); } } diff --git a/scripts/publish.js b/scripts/publish.js index b1d6ea64..0c5f6d46 100644 --- a/scripts/publish.js +++ b/scripts/publish.js @@ -6,7 +6,7 @@ // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -const chalk = require('chalk'); +const colors = require('colors/safe'); const shelljs = require('shelljs'); const path = require('path'); @@ -16,33 +16,33 @@ function publishNpm(target) { try { if (target.private === true) { console.log( - `${chalk.red(target.name)} is ${chalk.cyan('private')}, ${chalk.green( - 'skip' - )}` + `${colors.red(target.name)} is ${colors.cyan( + 'private' + )}, ${colors.green('skip')}` ); } else { doPublishNpm(target); } } catch (err) { console.log( - `failed to puslish ${chalk.red(target.name)}@${chalk.yellowBright( + `failed to puslish ${colors.red(target.name)}@${colors.brightYellow( target.version - )}, error: ${chalk.blue(err.message)}` + )}, error: ${colors.blue(err.message)}` ); } } function doPublishNpm(target) { console.log( - `build ${chalk.red(target.name)}@${chalk.yellow(target.version)}` + `build ${colors.red(target.name)}@${colors.yellow(target.version)}` ); const packagePath = path.join(__dirname, '..', 'dist', target.folderName); console.log(packagePath); shelljs.cd(packagePath).exec('npm publish'); console.log( - `puslish ${chalk.red(target.name)}@${chalk.yellowBright( + `puslish ${colors.red(target.name)}@${colors.brightYellow( target.version - )} ${chalk.green('successfully')}` + )} ${colors.green('successfully')}` ); } diff --git a/scripts/release.js b/scripts/release.js index e71976bb..38205476 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -7,9 +7,9 @@ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. const args = require('minimist')(process.argv.slice(2)); -const chalk = require('chalk'); +const colors = require('colors/safe'); const semver = require('semver'); -const { exec, set } = require('shelljs'); +const { exec } = require('shelljs'); const currentVersion = require('../package.json').version; const { prompt } = require('enquirer'); const path = require('path'); @@ -34,11 +34,11 @@ const versionIncrements = [ const inc = i => semver.inc(currentVersion, i, preId); const realRun = command => exec(command); -const dryRun = command => console.log(chalk.blue(`[dry run]: ${command}`)); +const dryRun = command => console.log(colors.blue(`[dry run]: ${command}`)); const run = isDryRun ? dryRun : realRun; -const step = msg => console.log(chalk.cyan(msg)); +const step = msg => console.log(colors.cyan(msg)); const fetchTargetVersion = async () => { let targetVersion = args._[0]; @@ -74,9 +74,9 @@ const fetchTargetVersion = async () => { const confirmUpdateTargetVersion = async (targetVersion, targets) => { targets.forEach(target => { console.log( - `${chalk.blue(target.name)}@${chalk.cyan(target.version)} => ${chalk.red( - 'v' + targetVersion - )}` + `${colors.blue(target.name)}@${colors.cyan( + target.version + )} => ${colors.red('v' + targetVersion)}` ); }); const { yes } = await prompt({ @@ -92,7 +92,7 @@ const updatePackageVersion = (pkgPath, version) => { const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8')); pkg.version = version; if (isDryRun) { - console.log(`${chalk.bgCyan(pkg.name + '@' + pkg.version)}`); + console.log(`${colors.bgCyan(pkg.name + '@' + pkg.version)}`); } else { fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n'); } @@ -107,7 +107,7 @@ const updatePackageDeps = (pkgPath, version) => { dependencies[dependency] = version; }); if (isDryRun) { - console.log(`${chalk.bgCyan(pkg.name + '@' + pkg.version)}`); + console.log(`${colors.bgCyan(pkg.name + '@' + pkg.version)}`); console.log(pkg); } else { fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n'); diff --git a/yarn.lock b/yarn.lock index 8bda5161..a44d837b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2071,7 +2071,7 @@ chalk@2.4.2, chalk@^2.0.0, chalk@^2.3.0: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.2: +chalk@^4.0.0, chalk@^4.1.0: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -2243,7 +2243,7 @@ colorette@^2.0.16: resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.16.tgz#713b9af84fdb000139f04546bd4a93f62a5085da" integrity sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g== -colors@^1.2.1: +colors@1.4.0, colors@^1.2.1: version "1.4.0" resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==