feat: remove colors in favour of chalk (#10142)

* feat: remove colors in favour of chalk

* fix: bad conversion from colors to chalk in src/cli/index.js

* fix: padWidth calculation to account for control characters

* fix: termWidth calculation, but swapped one problem for another

* fix: formatItem, implement my own padRight to take control characters into account
This commit is contained in:
Julian Lam
2022-02-01 21:43:09 -05:00
committed by GitHub
parent c7a5643932
commit cf8f62aed9
15 changed files with 106 additions and 78 deletions

View File

@@ -1,6 +1,7 @@
'use strict';
const _ = require('lodash');
const chalk = require('chalk');
const aliases = {
'plugin static dirs': ['staticdirs'],
@@ -30,7 +31,7 @@ function buildTargets() {
}
return [name, arr.join(', ')];
}).map(tuple => ` ${_.padEnd(`"${tuple[0]}"`, length + 2).magenta} | ${tuple[1]}`).join('\n');
}).map(tuple => ` ${chalk.magenta(_.padEnd(`"${tuple[0]}"`, length + 2))} | ${tuple[1]}`).join('\n');
console.log(
`\n\n Build targets:\n${
(`\n ${_.padEnd('Target', length + 2)} | Aliases`).green

View File

@@ -6,6 +6,7 @@ const nconf = require('nconf');
const _ = require('lodash');
const path = require('path');
const mkdirp = require('mkdirp');
const chalk = require('chalk');
const cacheBuster = require('./cacheBuster');
const { aliases } = require('./aliases');
@@ -60,8 +61,7 @@ const aliasMap = Object.keys(aliases).reduce((prev, key) => {
async function beforeBuild(targets) {
const db = require('../database');
require('colors');
process.stdout.write(' started'.green + '\n'.reset);
process.stdout.write(`${chalk.green(' started')}\n`);
try {
await db.init();
meta = require('./index');

View File

@@ -5,7 +5,7 @@ const fs = require('fs');
const semver = require('semver');
const winston = require('winston');
require('colors');
const chalk = require('chalk');
const pkg = require('../../package.json');
const { paths, pluginNamePattern } = require('../constants');
@@ -49,7 +49,7 @@ Dependencies.parseModuleData = function (moduleName, pkgData) {
try {
pkgData = JSON.parse(pkgData);
} catch (e) {
winston.warn(`[${'missing'.red}] ${moduleName.bold} is a required dependency but could not be found\n`);
winston.warn(`[${chalk.red('missing')}] ${chalk.bold(moduleName)} is a required dependency but could not be found\n`);
depsMissing = true;
return null;
}
@@ -64,7 +64,7 @@ Dependencies.doesSatisfy = function (moduleData, packageJSONVersion) {
const githubRepo = moduleData._resolved && moduleData._resolved.includes('//github.com');
const satisfies = versionOk || githubRepo;
if (!satisfies) {
winston.warn(`[${'outdated'.yellow}] ${moduleData.name.bold} installed v${moduleData.version}, package.json requires ${packageJSONVersion}\n`);
winston.warn(`[${chalk.yellow('outdated')}] ${chalk.bold(moduleData.name)} installed v${moduleData.version}, package.json requires ${packageJSONVersion}\n`);
depsOutdated = true;
}
return satisfies;