chore: change color dep, add banner

Signed-off-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
Jef LeCompte
2020-09-23 19:20:17 -04:00
parent 76b28a6dbd
commit bcbd2b6007
6 changed files with 86 additions and 33 deletions
+7 -7
View File
@@ -1,7 +1,7 @@
import {Link, Store} from './store/model';
import winston, {format} from 'winston';
import {Config} from './config';
import colors from 'colors'; // eslint-disable-line no-restricted-imports
import chalk from 'chalk';
const prettyJson = format.printf(info => {
const timestamp = new Date().toLocaleTimeString();
@@ -10,7 +10,7 @@ const prettyJson = format.printf(info => {
info.message = JSON.stringify(info.message, null, 4);
}
return colors.grey(`[${timestamp}]`) + ` ${info.level} ` + colors.grey('::') + ` ${info.message}`;
return chalk.grey(`[${timestamp}]`) + ` ${info.level} ` + chalk.grey('::') + ` ${info.message}`;
});
export const Logger = winston.createLogger({
@@ -28,28 +28,28 @@ export const Logger = winston.createLogger({
export const Print = {
captcha(link: Link, store: Store, color?: boolean): string {
if (color) {
return '✖ ' + buildProductString(link, store, true) + ' :: ' + colors.yellow('CAPTCHA');
return '✖ ' + buildProductString(link, store, true) + ' :: ' + chalk.yellow('CAPTCHA');
}
return `${buildProductString(link, store)} :: CAPTCHA`;
},
inStock(link: Link, store: Store, color?: boolean): string {
if (color) {
return colors.rainbow(`🚀🚨 ${buildProductString(link, store, true)} :: IN STOCK 🚨🚀`);
return chalk.green.bold(`🚀🚨 ${buildProductString(link, store, true)} :: IN STOCK 🚨🚀`);
}
return `🚀🚨 ${buildProductString(link, store)} :: IN STOCK 🚨🚀`;
},
outOfStock(link: Link, store: Store, color?: boolean): string {
if (color) {
return '✖ ' + buildProductString(link, store, true) + ' :: ' + colors.red('OUT OF STOCK');
return '✖ ' + buildProductString(link, store, true) + ' :: ' + chalk.red('OUT OF STOCK');
}
return `${buildProductString(link, store)} :: OUT OF STOCK`;
},
rateLimit(link: Link, store: Store, color?: boolean): string {
if (color) {
return '✖ ' + buildProductString(link, store, true) + ' :: ' + colors.yellow('RATE LIMIT EXCEEDED');
return '✖ ' + buildProductString(link, store, true) + ' :: ' + chalk.yellow('RATE LIMIT EXCEEDED');
}
return `${buildProductString(link, store)} :: RATE LIMIT EXCEEDED`;
@@ -58,7 +58,7 @@ export const Print = {
function buildProductString(link: Link, store: Store, color?: boolean): string {
if (color) {
return colors.cyan(`[${store.name}]`) + colors.grey(` [${link.brand} (${link.series})] ${link.model}`);
return chalk.cyan(`[${store.name}]`) + chalk.grey(` [${link.brand} (${link.series})] ${link.model}`);
}
return `[${store.name}] [${link.brand} (${link.series})] ${link.model}`;