Skip to content

Commit a97c57b

Browse files
authored
chore: use colors instead of chalk (#342)
1 parent e9270b4 commit a97c57b

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
"release:alpha": "node scripts/release.js --preId alpha",
3333
"release:beta": "node scripts/release.js --preId beta",
3434
"prepare": "npx husky install",
35-
"publish-npm": "node scripts/publish.js "
35+
"publish-npm": "node scripts/publish.js"
36+
},
37+
"dependencies": {
38+
"tslib": "^2.3.1"
3639
},
3740
"devDependencies": {
3841
"@commitlint/cli": "^16.0.1",
@@ -43,7 +46,7 @@
4346
"@typescript-eslint/eslint-plugin": "^5.6.0",
4447
"@typescript-eslint/eslint-plugin-tslint": "^5.6.0",
4548
"@typescript-eslint/parser": "^5.6.0",
46-
"chalk": "^4.1.2",
49+
"colors": "1.4.0",
4750
"conventional-changelog-cli": "^2.2.2",
4851
"enquirer": "^2.3.6",
4952
"eslint": "^8.6.0",
@@ -67,8 +70,5 @@
6770
},
6871
"resolutions": {
6972
"**/**/axios": ">=0.21.1"
70-
},
71-
"dependencies": {
72-
"tslib": "^2.3.1"
7373
}
7474
}

scripts/build.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// 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.
88

9-
const chalk = require('chalk');
9+
const colors = require('colors/safe');
1010
const fs = require('fs/promises');
1111
const fsEx = require('fs-extra');
1212
const path = require('path');
@@ -37,7 +37,7 @@ async function buildTarget(target) {
3737
})
3838
.map(f => fs.copyFile(f.src, f.dest));
3939
await Promise.all(copyTasks);
40-
console.log(`${chalk.blue(target.name)} ${chalk.green('success')} 🚀`);
40+
console.log(`${colors.blue(target.name)} ${colors.green('success')} 🚀`);
4141

4242
await fs.rm(`${path.resolve('./node_modules/' + target.name)}`, {
4343
force: true,
@@ -49,7 +49,7 @@ async function buildTarget(target) {
4949
);
5050
} else {
5151
console.log(
52-
`${chalk.blue(target.name)} ${chalk.cyan('skip')} for private module`
52+
`${colors.blue(target.name)} ${colors.cyan('skip')} for private module`
5353
);
5454
}
5555
}

scripts/publish.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// 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.
88

9-
const chalk = require('chalk');
9+
const colors = require('colors/safe');
1010
const shelljs = require('shelljs');
1111
const path = require('path');
1212

@@ -16,33 +16,33 @@ function publishNpm(target) {
1616
try {
1717
if (target.private === true) {
1818
console.log(
19-
`${chalk.red(target.name)} is ${chalk.cyan('private')}, ${chalk.green(
20-
'skip'
21-
)}`
19+
`${colors.red(target.name)} is ${colors.cyan(
20+
'private'
21+
)}, ${colors.green('skip')}`
2222
);
2323
} else {
2424
doPublishNpm(target);
2525
}
2626
} catch (err) {
2727
console.log(
28-
`failed to puslish ${chalk.red(target.name)}@${chalk.yellowBright(
28+
`failed to puslish ${colors.red(target.name)}@${colors.brightYellow(
2929
target.version
30-
)}, error: ${chalk.blue(err.message)}`
30+
)}, error: ${colors.blue(err.message)}`
3131
);
3232
}
3333
}
3434

3535
function doPublishNpm(target) {
3636
console.log(
37-
`build ${chalk.red(target.name)}@${chalk.yellow(target.version)}`
37+
`build ${colors.red(target.name)}@${colors.yellow(target.version)}`
3838
);
3939
const packagePath = path.join(__dirname, '..', 'dist', target.folderName);
4040
console.log(packagePath);
4141
shelljs.cd(packagePath).exec('npm publish');
4242
console.log(
43-
`puslish ${chalk.red(target.name)}@${chalk.yellowBright(
43+
`puslish ${colors.red(target.name)}@${colors.brightYellow(
4444
target.version
45-
)} ${chalk.green('successfully')}`
45+
)} ${colors.green('successfully')}`
4646
);
4747
}
4848

scripts/release.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
// 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.
88

99
const args = require('minimist')(process.argv.slice(2));
10-
const chalk = require('chalk');
10+
const colors = require('colors/safe');
1111
const semver = require('semver');
12-
const { exec, set } = require('shelljs');
12+
const { exec } = require('shelljs');
1313
const currentVersion = require('../package.json').version;
1414
const { prompt } = require('enquirer');
1515
const path = require('path');
@@ -34,11 +34,11 @@ const versionIncrements = [
3434
const inc = i => semver.inc(currentVersion, i, preId);
3535

3636
const realRun = command => exec(command);
37-
const dryRun = command => console.log(chalk.blue(`[dry run]: ${command}`));
37+
const dryRun = command => console.log(colors.blue(`[dry run]: ${command}`));
3838

3939
const run = isDryRun ? dryRun : realRun;
4040

41-
const step = msg => console.log(chalk.cyan(msg));
41+
const step = msg => console.log(colors.cyan(msg));
4242

4343
const fetchTargetVersion = async () => {
4444
let targetVersion = args._[0];
@@ -74,9 +74,9 @@ const fetchTargetVersion = async () => {
7474
const confirmUpdateTargetVersion = async (targetVersion, targets) => {
7575
targets.forEach(target => {
7676
console.log(
77-
`${chalk.blue(target.name)}@${chalk.cyan(target.version)} => ${chalk.red(
78-
'v' + targetVersion
79-
)}`
77+
`${colors.blue(target.name)}@${colors.cyan(
78+
target.version
79+
)} => ${colors.red('v' + targetVersion)}`
8080
);
8181
});
8282
const { yes } = await prompt({
@@ -92,7 +92,7 @@ const updatePackageVersion = (pkgPath, version) => {
9292
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
9393
pkg.version = version;
9494
if (isDryRun) {
95-
console.log(`${chalk.bgCyan(pkg.name + '@' + pkg.version)}`);
95+
console.log(`${colors.bgCyan(pkg.name + '@' + pkg.version)}`);
9696
} else {
9797
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
9898
}
@@ -107,7 +107,7 @@ const updatePackageDeps = (pkgPath, version) => {
107107
dependencies[dependency] = version;
108108
});
109109
if (isDryRun) {
110-
console.log(`${chalk.bgCyan(pkg.name + '@' + pkg.version)}`);
110+
console.log(`${colors.bgCyan(pkg.name + '@' + pkg.version)}`);
111111
console.log(pkg);
112112
} else {
113113
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,7 @@ chalk@2.4.2, chalk@^2.0.0, chalk@^2.3.0:
20712071
escape-string-regexp "^1.0.5"
20722072
supports-color "^5.3.0"
20732073

2074-
chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.2:
2074+
chalk@^4.0.0, chalk@^4.1.0:
20752075
version "4.1.2"
20762076
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
20772077
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
@@ -2243,7 +2243,7 @@ colorette@^2.0.16:
22432243
resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.16.tgz#713b9af84fdb000139f04546bd4a93f62a5085da"
22442244
integrity sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g==
22452245

2246-
colors@^1.2.1:
2246+
colors@1.4.0, colors@^1.2.1:
22472247
version "1.4.0"
22482248
resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78"
22492249
integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==

0 commit comments

Comments
 (0)