Skip to content

Commit

Permalink
chore(color): update to ansi-colors
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Sep 26, 2018
1 parent e210af8 commit 9f546fa
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@types/pngjs": "^3.3.2",
"@types/puppeteer": "^1.6.0",
"@types/ws": "^5.1.2",
"ansi-colors": "~3.0.6",
"autoprefixer": "^8.2.0",
"clean-css": "4.1.11",
"conventional-changelog-cli": "^1.3.5",
Expand Down Expand Up @@ -102,7 +103,6 @@
"tslib": "^1.9.3",
"tslint": "^5.9.1",
"tslint-ionic-rules": "0.0.13",
"turbocolor": "^2.4.1",
"webpack": "^4.9.1 ",
"ws": "5.2.1"
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const DIST_LICENSES = path.join(DIST, 'sys', 'node', 'LICENSES');
fs.emptyDirSync(DIST_LICENSES);

[
'ansi-colors',
'autoprefixer',
'clean-css',
'glob',
Expand All @@ -41,7 +42,6 @@ fs.emptyDirSync(DIST_LICENSES);
'postcss',
'semver',
'terser',
'turbocolor',
'ws',

].forEach(copyLicense);
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ if (success) {
rollup.rollup({
input: ENTRY_FILE,
external: [
'ansi-colors',
'fs',
'path',
'turbocolor',
'child_process'
],
plugins: [
Expand Down
24 changes: 12 additions & 12 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Deploy script adopted from https://github.com/sindresorhus/np
* MIT License (c) Sindre Sorhus (sindresorhus.com)
*/
const tc = require('turbocolor');
const color = require('ansi-colors');
const execa = require('execa');
const inquirer = require('inquirer');
const Listr = require('listr');
Expand Down Expand Up @@ -215,7 +215,7 @@ function runTasks(opts) {
}
})
.catch(err => {
console.log('\n', tc.red(err), '\n');
console.log('\n', color.red(err), '\n');
process.exit(0);
});
}
Expand All @@ -225,7 +225,7 @@ function prepareUI() {
const pkg = readPkg();
const oldVersion = pkg.version;

console.log(`\nPrepare to publish a new version of ${tc.bold.magenta(pkg.name)} ${tc.dim(`(${oldVersion})`)}\n`);
console.log(`\nPrepare to publish a new version of ${color.bold.magenta(pkg.name)} ${color.dim(`(${oldVersion})`)}\n`);

const prompts = [
{
Expand Down Expand Up @@ -267,7 +267,7 @@ function prepareUI() {
type: 'confirm',
name: 'confirm',
message: answers => {
return `Will bump from ${tc.cyan(oldVersion)} to ${tc.cyan(answers.version)}. Continue?`;
return `Will bump from ${color.cyan(oldVersion)} to ${color.cyan(answers.version)}. Continue?`;
}
}
];
Expand All @@ -282,7 +282,7 @@ function prepareUI() {
}
})
.catch(err => {
console.log('\n', tc.red(err), '\n');
console.log('\n', color.red(err), '\n');
process.exit(0);
});
}
Expand All @@ -291,7 +291,7 @@ function publishUI() {
const pkg = readPkg();
const version = pkg.version;

console.log(`\nPublish a new version of ${tc.bold.magenta(pkg.name)} ${tc.dim(`(${version})`)}\n`);
console.log(`\nPublish a new version of ${color.bold.magenta(pkg.name)} ${color.dim(`(${version})`)}\n`);

const prompts = [
{
Expand Down Expand Up @@ -345,7 +345,7 @@ function publishUI() {
const tag = answers.tag;
const tagPart = tag ? ` and tag this release in npm as ${tag}` : '';

return `Will publish ${tc.cyan(version + tagPart)}. Continue?`;
return `Will publish ${color.cyan(version + tagPart)}. Continue?`;
}
}
];
Expand All @@ -361,7 +361,7 @@ function publishUI() {
}
})
.catch(err => {
console.log('\n', tc.red(err), '\n');
console.log('\n', color.red(err), '\n');
process.exit(0);
});
}
Expand Down Expand Up @@ -414,17 +414,17 @@ function prettyVersionDiff(oldVersion, inc) {

for (let i = 0; i < newVersion.length; i++) {
if ((newVersion[i] !== oldVersion[i] && !firstVersionChange)) {
output.push(`${tc.dim.cyan(newVersion[i])}`);
output.push(`${color.dim.cyan(newVersion[i])}`);
firstVersionChange = true;
} else if (newVersion[i].indexOf('-') >= 1) {
let preVersion = [];
preVersion = newVersion[i].split('-');
output.push(`${tc.dim.cyan(`${preVersion[0]}-${preVersion[1]}`)}`);
output.push(`${color.dim.cyan(`${preVersion[0]}-${preVersion[1]}`)}`);
} else {
output.push(tc.reset.dim(newVersion[i]));
output.push(color.reset.dim(newVersion[i]));
}
}
return output.join(tc.reset.dim('.'));
return output.join(color.reset.dim('.'));
}

const prepare = process.argv.slice(2).indexOf('--prepare') > -1;
Expand Down
2 changes: 1 addition & 1 deletion src/sys/node/bundles/sys-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ exports.opn = require('opn');

exports.semver = require('semver');

exports.turbocolor = require('turbocolor');
exports.color = require('ansi-colors');
48 changes: 24 additions & 24 deletions src/sys/node/node-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as path from 'path';

export class NodeLogger implements d.Logger {
private _level = 'info';
private tc: any;
private c: any;
private writeLogQueue: string[] = [];
buildLogFilePath: string = null;

Expand All @@ -14,7 +14,7 @@ export class NodeLogger implements d.Logger {
const distDir = path.join(rootDir, 'dist');
const sysUtil = require(path.join(distDir, 'sys', 'node', 'sys-util.js'));

this.tc = sysUtil.turbocolor;
this.c = sysUtil.color;
}

get level() {
Expand All @@ -26,7 +26,7 @@ export class NodeLogger implements d.Logger {
l = l.toLowerCase().trim();

if (LOG_LEVELS.indexOf(l) === -1) {
this.error(`Invalid log level '${this.tc.bold(l)}' (choose from: ${LOG_LEVELS.map(l => this.tc.bold(l)).join(', ')})`);
this.error(`Invalid log level '${this.c.bold(l)}' (choose from: ${LOG_LEVELS.map(l => this.c.bold(l)).join(', ')})`);
} else {
this._level = l;
}
Expand Down Expand Up @@ -67,7 +67,7 @@ export class NodeLogger implements d.Logger {
warnPrefix(lines: string[]) {
if (lines.length) {
const prefix = '[ WARN ]';
lines[0] = this.bold(this.tc.yellow(prefix)) + lines[0].substr(prefix.length);
lines[0] = this.bold(this.c.yellow(prefix)) + lines[0].substr(prefix.length);
}
}

Expand All @@ -93,7 +93,7 @@ export class NodeLogger implements d.Logger {
errorPrefix(lines: string[]) {
if (lines.length) {
const prefix = '[ ERROR ]';
lines[0] = this.bold(this.tc.red(prefix)) + lines[0].substr(prefix.length);
lines[0] = this.bold(this.c.red(prefix)) + lines[0].substr(prefix.length);
}
}

Expand All @@ -116,7 +116,7 @@ export class NodeLogger implements d.Logger {
('0' + d.getSeconds()).slice(-2) + '.' +
Math.floor((d.getMilliseconds() / 1000) * 10) + ']';

lines[0] = this.tc.cyan(prefix) + lines[0].substr(prefix.length);
lines[0] = this.c.cyan(prefix) + lines[0].substr(prefix.length);
}
}

Expand Down Expand Up @@ -224,43 +224,43 @@ export class NodeLogger implements d.Logger {
}

color(msg: string, color: 'red'|'green'|'yellow'|'blue'|'magenta'|'cyan'|'gray') {
return (this.tc as any)[color](msg);
return (this.c as any)[color](msg);
}

red(msg: string) {
return this.tc.red(msg);
return this.c.red(msg);
}

green(msg: string) {
return this.tc.green(msg);
return this.c.green(msg);
}

yellow(msg: string) {
return this.tc.yellow(msg);
return this.c.yellow(msg);
}

blue(msg: string) {
return this.tc.blue(msg);
return this.c.blue(msg);
}

magenta(msg: string) {
return this.tc.magenta(msg);
return this.c.magenta(msg);
}

cyan(msg: string) {
return this.tc.cyan(msg);
return this.c.cyan(msg);
}

gray(msg: string) {
return this.tc.gray(msg);
return this.c.gray(msg);
}

bold(msg: string) {
return this.tc.bold(msg);
return this.c.bold(msg);
}

dim(msg: string) {
return this.tc.dim(msg);
return this.c.dim(msg);
}

private shouldLog(level: string): boolean {
Expand Down Expand Up @@ -297,15 +297,15 @@ export class NodeLogger implements d.Logger {
header += ': ';
}

header += this.tc.cyan(d.relFilePath);
header += this.c.cyan(d.relFilePath);

if (typeof d.lineNumber === 'number' && d.lineNumber > -1) {
header += this.tc.dim(`:`);
header += this.tc.yellow(`${d.lineNumber}`);
header += this.c.dim(`:`);
header += this.c.yellow(`${d.lineNumber}`);

if (typeof d.columnNumber === 'number' && d.columnNumber > -1) {
header += this.tc.dim(`:`);
header += this.tc.yellow(`${d.columnNumber}`);
header += this.c.dim(`:`);
header += this.c.yellow(`${d.columnNumber}`);
}
}
}
Expand Down Expand Up @@ -389,7 +389,7 @@ export class NodeLogger implements d.Logger {
for (var i = 0; i < lineLength; i++) {
var chr = errorLine.charAt(i);
if (i >= errorCharStart && i < errorCharStart + errorLength) {
chr = this.tc.bgRed(chr === '' ? ' ' : chr);
chr = this.c.bgRed(chr === '' ? ' ' : chr);
}
lineChars.push(chr);
}
Expand All @@ -404,7 +404,7 @@ export class NodeLogger implements d.Logger {

const words = text.split(' ').map(word => {
if (JS_KEYWORDS.indexOf(word) > -1) {
return this.tc.cyan(word);
return this.c.cyan(word);
}
return word;
});
Expand All @@ -428,7 +428,7 @@ export class NodeLogger implements d.Logger {
cssProp = false;
}
if (cssProp && safeChars.indexOf(c.toLowerCase()) > -1) {
chars.push(this.tc.cyan(c));
chars.push(this.c.cyan(c));
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/sys/node/node-sys-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class NodeSystem implements d.StencilSystem {
}

get color() {
return this.sysUtil.turbocolor;
return this.sysUtil.color;
}

get semver() {
Expand Down
9 changes: 5 additions & 4 deletions test/example/src/components.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/**
* This is an autogenerated file created by the Stencil compiler.
* It contains typing information for all components that exist in this project.
*/
/* tslint:disable */
/**
* This is an autogenerated file created by the Stencil compiler.
* It contains typing information for all components that exist in this project.
*/


import '@stencil/core';

Expand Down

0 comments on commit 9f546fa

Please sign in to comment.