Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(logs): coloured logs #465

Merged
merged 5 commits into from Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Expand Up @@ -28,7 +28,7 @@
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-extraneous-class": "off",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
Expand Down
2,489 changes: 410 additions & 2,079 deletions dist/index.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions jest.config.js
Expand Up @@ -7,6 +7,5 @@ module.exports = {
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true,
setupFilesAfterEnv: [`./jest/test.ts`]
verbose: true
};
11 changes: 0 additions & 11 deletions jest/test.ts

This file was deleted.

99 changes: 41 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -43,7 +43,7 @@
"@typescript-eslint/eslint-plugin": "^4.16.1",
"@typescript-eslint/parser": "^4.22.1",
"@vercel/ncc": "^0.27.0",
"chalk": "^4.1.0",
"ansi-styles": "5.2.0",
"eslint": "^7.21.0",
"eslint-plugin-github": "^4.1.2",
"eslint-plugin-jest": "^24.3.6",
Expand Down
45 changes: 24 additions & 21 deletions src/classes/assignees.ts
@@ -1,11 +1,11 @@
import chalk from 'chalk';
import deburr from 'lodash.deburr';
import {Option} from '../enums/option';
import {wordsToList} from '../functions/words-to-list';
import {IAssignee} from '../interfaces/assignee';
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
import {Issue} from './issue';
import {IssueLogger} from './loggers/issue-logger';
import {LoggerService} from '../services/logger.service';

type CleanAssignee = string;

Expand Down Expand Up @@ -34,7 +34,7 @@ export class Assignees {

if (this._shouldExemptAllAssignees()) {
this._issueLogger.info(
chalk.white('└──'),
LoggerService.white('└──'),
'Skipping this $$type because it has an exempt assignee'
);

Expand All @@ -45,7 +45,7 @@ export class Assignees {

if (exemptAssignees.length === 0) {
this._issueLogger.info(
chalk.white('├──'),
LoggerService.white('├──'),
`No assignee option was specified to skip the stale process for this $$type`
);
this._logSkip();
Expand All @@ -54,8 +54,8 @@ export class Assignees {
}

this._issueLogger.info(
chalk.white('├──'),
`Found ${chalk.cyan(exemptAssignees.length)} assignee${
LoggerService.white('├──'),
`Found ${LoggerService.cyan(exemptAssignees.length)} assignee${
exemptAssignees.length > 1 ? 's' : ''
} that can exempt stale on this $$type`
);
Expand All @@ -67,13 +67,13 @@ export class Assignees {

if (!hasExemptAssignee) {
this._issueLogger.info(
chalk.white('├──'),
LoggerService.white('├──'),
'No assignee on this $$type can exempt the stale process'
);
this._logSkip();
} else {
this._issueLogger.info(
chalk.white('└──'),
LoggerService.white('└──'),
'Skipping this $$type because it has an exempt assignee'
);
}
Expand All @@ -90,15 +90,15 @@ export class Assignees {
private _getExemptIssueAssignees(): string[] {
if (this._options.exemptIssueAssignees === '') {
this._issueLogger.info(
chalk.white('├──'),
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptIssueAssignees
)} is disabled. No specific assignee can skip the stale process for this $$type`
);

if (this._options.exemptAssignees === '') {
this._issueLogger.info(
chalk.white('├──'),
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAssignees
)} is disabled. No specific assignee can skip the stale process for this $$type`
Expand All @@ -112,10 +112,10 @@ export class Assignees {
);

this._issueLogger.info(
chalk.white('├──'),
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAssignees
)} is set. ${chalk.cyan(exemptAssignees.length)} assignee${
)} is set. ${LoggerService.cyan(exemptAssignees.length)} assignee${
exemptAssignees.length === 1 ? '' : 's'
} can skip the stale process for this $$type`
);
Expand All @@ -128,10 +128,10 @@ export class Assignees {
);

this._issueLogger.info(
chalk.white('├──'),
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptIssueAssignees
)} is set. ${chalk.cyan(exemptAssignees.length)} assignee${
)} is set. ${LoggerService.cyan(exemptAssignees.length)} assignee${
exemptAssignees.length === 1 ? '' : 's'
} can skip the stale process for this $$type`
);
Expand All @@ -142,15 +142,15 @@ export class Assignees {
private _getExemptPullRequestAssignees(): string[] {
if (this._options.exemptPrAssignees === '') {
this._issueLogger.info(
chalk.white('├──'),
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptPrAssignees
)} is disabled. No specific assignee can skip the stale process for this $$type`
);

if (this._options.exemptAssignees === '') {
this._issueLogger.info(
chalk.white('├──'),
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAssignees
)} is disabled. No specific assignee can skip the stale process for this $$type`
Expand All @@ -164,10 +164,10 @@ export class Assignees {
);

this._issueLogger.info(
chalk.white('├──'),
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptAssignees
)} is set. ${chalk.cyan(exemptAssignees.length)} assignee${
)} is set. ${LoggerService.cyan(exemptAssignees.length)} assignee${
exemptAssignees.length === 1 ? '' : 's'
} can skip the stale process for this $$type`
);
Expand All @@ -180,10 +180,10 @@ export class Assignees {
);

this._issueLogger.info(
chalk.white('├──'),
LoggerService.white('├──'),
`The option ${this._issueLogger.createOptionLink(
Option.ExemptPrAssignees
)} is set. ${chalk.cyan(exemptAssignees.length)} assignee${
)} is set. ${LoggerService.cyan(exemptAssignees.length)} assignee${
exemptAssignees.length === 1 ? '' : 's'
} can skip the stale process for this $$type`
);
Expand All @@ -201,7 +201,7 @@ export class Assignees {

if (isSameAssignee) {
this._issueLogger.info(
chalk.white('├──'),
LoggerService.white('├──'),
`@${issueAssignee.login} is assigned on this $$type and is an exempt assignee`
);
}
Expand Down Expand Up @@ -282,6 +282,9 @@ export class Assignees {
}

private _logSkip(): void {
this._issueLogger.info(chalk.white('└──'), 'Skip the assignees checks');
this._issueLogger.info(
LoggerService.white('└──'),
'Skip the assignees checks'
);
}
}