fix(logs): coloured logs (#465)

* refactor(logs): replace chalk by ansi-styles

* test(logs): fix the failing tests due to ansi styles

I was not able to disable or mock ansi-styles so instead I found a way to make the tests pass
it's not perfect but it's still nice because the logs will keep their trustful colour when running through the tests

* refactor(logs): simplify the syntax to colour the logs

* chore(rebase): update files due to rebase

* refactor(logger): reduce code duplication
This commit is contained in:
Geoffrey Testelin
2021-06-02 23:04:34 +02:00
committed by GitHub
parent e884599072
commit 5fbbfba142
15 changed files with 671 additions and 2262 deletions

View File

@@ -1,6 +1,6 @@
import chalk from 'chalk';
import {Issue} from './issue';
import {Logger} from './loggers/logger';
import {LoggerService} from '../services/logger.service';
interface IGroupValue {
name: string;
@@ -163,7 +163,7 @@ export class Statistics {
}
logStats(): Statistics {
this._logger.info(chalk.yellow.bold('Statistics:'));
this._logger.info(LoggerService.yellow(LoggerService.bold(`Statistics:`)));
this._logProcessedIssuesAndPullRequestsCount();
this._logStaleIssuesAndPullRequestsCount();
this._logUndoStaleIssuesAndPullRequestsCount();
@@ -440,7 +440,7 @@ export class Statistics {
private _logCount(name: Readonly<string>, count: Readonly<number>): void {
if (count > 0) {
this._logger.info(`${name}:`, chalk.cyan(count));
this._logger.info(`${name}:`, LoggerService.cyan(count));
}
}
@@ -498,7 +498,10 @@ export class Statistics {
const prefix = index === onlyValuesSet.length - 1 ? '└──' : '├──';
this._logCount(
`${chalk.white(prefix)} ${value.name.padEnd(longestValue, ' ')}`,
`${LoggerService.white(prefix)} ${value.name.padEnd(
longestValue,
' '
)}`,
value.count
);
}