feat(logs): enhance the logs for assignees and milestones (#382)

* docs(only-labels): enhance the docs and fix duplicate (#341)

* docs(only-labels): remove duplicated option and improve descriptions

a bad rebase happend

* docs(readme): use a multi-line array and remove the optional column

the option column was not helpful since each value is optional
the multi-line array will allow to have a better UI in small devices and basically in GitHub too due to the max-width

* style(readme): break line for the statistics

* docs(readme): add a better description for the ascending option

* docs(action): add missing punctuation

* build(deps-dev): bump @typescript-eslint/eslint-plugin (#342)

Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.15.2 to 4.16.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.16.1/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump @octokit/rest from 18.3.0 to 18.3.2 (#350)

Bumps [@octokit/rest](https://github.com/octokit/rest.js) from 18.3.0 to 18.3.2.
- [Release notes](https://github.com/octokit/rest.js/releases)
- [Commits](https://github.com/octokit/rest.js/compare/v18.3.0...v18.3.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* test: add more coverage for the stale label behaviour (#352) (#15)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* test: add more coverage for the stale label behaviour (#352) (#17)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* test: add more coverage for the stale label behaviour (#352) (#18)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat(logs): enhance the logs for assignees and milestones

closes #381

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Geoffrey Testelin
2021-04-28 22:39:28 +02:00
committed by GitHub
parent c70e174d4a
commit 043fbbdea3
5 changed files with 707 additions and 136 deletions

88
dist/index.js vendored
View File

@@ -12,7 +12,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Assignees = void 0;
const chalk_1 = __importDefault(__nccwpck_require__(8818));
const lodash_deburr_1 = __importDefault(__nccwpck_require__(1601));
const option_1 = __nccwpck_require__(5931);
const words_to_list_1 = __nccwpck_require__(1883);
const issue_logger_1 = __nccwpck_require__(2984);
class Assignees {
@@ -31,23 +33,23 @@ class Assignees {
return false;
}
if (this._shouldExemptAllAssignees()) {
this._issueLogger.info('Skipping $$type because it has an exempt assignee');
this._issueLogger.info(chalk_1.default.white('└──'), 'Skipping $$type because it has an exempt assignee');
return true;
}
const exemptAssignees = this._getExemptAssignees();
if (exemptAssignees.length === 0) {
this._issueLogger.info(`No assignee option was specified to skip the stale process for this $$type`);
this._issueLogger.info(chalk_1.default.white('├──'), `No assignee option was specified to skip the stale process for this $$type`);
this._logSkip();
return false;
}
this._issueLogger.info(`Found ${exemptAssignees.length} assignee${exemptAssignees.length > 1 ? 's' : ''} that can exempt stale on this $$type`);
this._issueLogger.info(chalk_1.default.white('├──'), `Found ${chalk_1.default.cyan(exemptAssignees.length)} assignee${exemptAssignees.length > 1 ? 's' : ''} that can exempt stale on this $$type`);
const hasExemptAssignee = exemptAssignees.some((exemptAssignee) => this._hasAssignee(exemptAssignee));
if (!hasExemptAssignee) {
this._issueLogger.info('No assignee on this $$type can exempt the stale process');
this._issueLogger.info(chalk_1.default.white('├──'), 'No assignee on this $$type can exempt the stale process');
this._logSkip();
}
else {
this._issueLogger.info('Skipping this $$type because it has an exempt assignee');
this._issueLogger.info(chalk_1.default.white('└──'), 'Skipping this $$type because it has an exempt assignee');
}
return hasExemptAssignee;
}
@@ -58,32 +60,32 @@ class Assignees {
}
_getExemptIssueAssignees() {
if (this._options.exemptIssueAssignees === '') {
this._issueLogger.info('The option "exemptIssueAssignees" is disabled. No specific assignee can skip the stale process for this $$type');
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptIssueAssignees)} is disabled. No specific assignee can skip the stale process for this $$type`);
if (this._options.exemptAssignees === '') {
this._issueLogger.info('The option "exemptAssignees" is disabled. No specific assignee can skip the stale process for this $$type');
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAssignees)} is disabled. No specific assignee can skip the stale process for this $$type`);
return [];
}
const exemptAssignees = words_to_list_1.wordsToList(this._options.exemptAssignees);
this._issueLogger.info(`The option "exemptAssignees" is set. ${exemptAssignees.length} assignee${exemptAssignees.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAssignees)} is set. ${chalk_1.default.cyan(exemptAssignees.length)} assignee${exemptAssignees.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
return exemptAssignees;
}
const exemptAssignees = words_to_list_1.wordsToList(this._options.exemptIssueAssignees);
this._issueLogger.info(`The option "exemptIssueAssignees" is set. ${exemptAssignees.length} assignee${exemptAssignees.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptIssueAssignees)} is set. ${chalk_1.default.cyan(exemptAssignees.length)} assignee${exemptAssignees.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
return exemptAssignees;
}
_getExemptPullRequestAssignees() {
if (this._options.exemptPrAssignees === '') {
this._issueLogger.info('The option "exemptPrAssignees" is disabled. No specific assignee can skip the stale process for this $$type');
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptPrAssignees)} is disabled. No specific assignee can skip the stale process for this $$type`);
if (this._options.exemptAssignees === '') {
this._issueLogger.info('The option "exemptAssignees" is disabled. No specific assignee can skip the stale process for this $$type');
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAssignees)} is disabled. No specific assignee can skip the stale process for this $$type`);
return [];
}
const exemptAssignees = words_to_list_1.wordsToList(this._options.exemptAssignees);
this._issueLogger.info(`The option "exemptAssignees" is set. ${exemptAssignees.length} assignee${exemptAssignees.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAssignees)} is set. ${chalk_1.default.cyan(exemptAssignees.length)} assignee${exemptAssignees.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
return exemptAssignees;
}
const exemptAssignees = words_to_list_1.wordsToList(this._options.exemptPrAssignees);
this._issueLogger.info(`The option "exemptPrAssignees" is set. ${exemptAssignees.length} assignee${exemptAssignees.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptPrAssignees)} is set. ${chalk_1.default.cyan(exemptAssignees.length)} assignee${exemptAssignees.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
return exemptAssignees;
}
_hasAssignee(assignee) {
@@ -91,7 +93,7 @@ class Assignees {
return this._issue.assignees.some((issueAssignee) => {
const isSameAssignee = cleanAssignee === Assignees._cleanAssignee(issueAssignee.login);
if (isSameAssignee) {
this._issueLogger.info(`@${issueAssignee.login} is assigned on this $$type and is an exempt assignee`);
this._issueLogger.info(chalk_1.default.white('├──'), `@${issueAssignee.login} is assigned on this $$type and is an exempt assignee`);
}
return isSameAssignee;
});
@@ -103,11 +105,11 @@ class Assignees {
}
_shouldExemptAllIssueAssignees() {
if (this._options.exemptAllIssueAssignees === true) {
this._issueLogger.info('The option "exemptAllIssueAssignees" is enabled. Any assignee on this $$type will skip the stale process');
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllIssueAssignees)} is enabled. Any assignee on this $$type will skip the stale process`);
return true;
}
else if (this._options.exemptAllIssueAssignees === false) {
this._issueLogger.info('The option "exemptAllIssueAssignees" is disabled. Only some specific assignees on this $$type will skip the stale process');
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllIssueAssignees)} is disabled. Only some specific assignees on this $$type will skip the stale process`);
return false;
}
this._logExemptAllAssigneesOption();
@@ -115,11 +117,11 @@ class Assignees {
}
_shouldExemptAllPullRequestAssignees() {
if (this._options.exemptAllPrAssignees === true) {
this._issueLogger.info('The option "exemptAllPrAssignees" is enabled. Any assignee on this $$type will skip the stale process');
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllPrAssignees)} is enabled. Any assignee on this $$type will skip the stale process`);
return true;
}
else if (this._options.exemptAllPrAssignees === false) {
this._issueLogger.info('The option "exemptAllPrAssignees" is disabled. Only some specific assignees on this $$type will skip the stale process');
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllPrAssignees)} is disabled. Only some specific assignees on this $$type will skip the stale process`);
return false;
}
this._logExemptAllAssigneesOption();
@@ -127,14 +129,14 @@ class Assignees {
}
_logExemptAllAssigneesOption() {
if (this._options.exemptAllAssignees) {
this._issueLogger.info('The option "exemptAllAssignees" is enabled. Any assignee on this $$type will skip the stale process');
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllAssignees)} is enabled. Any assignee on this $$type will skip the stale process`);
}
else {
this._issueLogger.info('The option "exemptAllAssignees" is disabled. Only some specific assignees on this $$type will skip the stale process');
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllAssignees)} is disabled. Only some specific assignees on this $$type will skip the stale process`);
}
}
_logSkip() {
this._issueLogger.info('Skip the assignees checks');
this._issueLogger.info(chalk_1.default.white('└──'), 'Skip the assignees checks');
}
}
exports.Assignees = Assignees;
@@ -955,7 +957,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Milestones = void 0;
const chalk_1 = __importDefault(__nccwpck_require__(8818));
const lodash_deburr_1 = __importDefault(__nccwpck_require__(1601));
const option_1 = __nccwpck_require__(5931);
const words_to_list_1 = __nccwpck_require__(1883);
const issue_logger_1 = __nccwpck_require__(2984);
class Milestones {
@@ -974,23 +978,23 @@ class Milestones {
return false;
}
if (this._shouldExemptAllMilestones()) {
this._issueLogger.info('Skipping $$type because it has an exempt milestone');
this._issueLogger.info(chalk_1.default.white('└──'), 'Skipping $$type because it has a milestone');
return true;
}
const exemptMilestones = this._getExemptMilestones();
if (exemptMilestones.length === 0) {
this._issueLogger.info(`No milestone option was specified to skip the stale process for this $$type`);
this._issueLogger.info(chalk_1.default.white('├──'), `No milestone option was specified to skip the stale process for this $$type`);
this._logSkip();
return false;
}
this._issueLogger.info(`Found ${exemptMilestones.length} milestone${exemptMilestones.length > 1 ? 's' : ''} that can exempt stale on this $$type`);
this._issueLogger.info(chalk_1.default.white('├──'), `Found ${chalk_1.default.cyan(exemptMilestones.length)} milestone${exemptMilestones.length > 1 ? 's' : ''} that can exempt stale on this $$type`);
const hasExemptMilestone = exemptMilestones.some((exemptMilestone) => this._hasMilestone(exemptMilestone));
if (!hasExemptMilestone) {
this._issueLogger.info('No milestone on this $$type can exempt the stale process');
this._issueLogger.info(chalk_1.default.white('├──'), 'No milestone on this $$type can exempt the stale process');
this._logSkip();
}
else {
this._issueLogger.info('Skipping this $$type because it has an exempt milestone');
this._issueLogger.info(chalk_1.default.white('└──'), 'Skipping this $$type because it has an exempt milestone');
}
return hasExemptMilestone;
}
@@ -1001,32 +1005,32 @@ class Milestones {
}
_getExemptIssueMilestones() {
if (this._options.exemptIssueMilestones === '') {
this._issueLogger.info('The option "exemptIssueMilestones" is disabled. No specific milestone can skip the stale process for this $$type');
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptIssueMilestones)} is disabled. No specific milestone can skip the stale process for this $$type`);
if (this._options.exemptMilestones === '') {
this._issueLogger.info('The option "exemptMilestones" is disabled. No specific milestone can skip the stale process for this $$type');
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptMilestones)} is disabled. No specific milestone can skip the stale process for this $$type`);
return [];
}
const exemptMilestones = words_to_list_1.wordsToList(this._options.exemptMilestones);
this._issueLogger.info(`The option "exemptMilestones" is set. ${exemptMilestones.length} milestone${exemptMilestones.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptMilestones)} is set. ${chalk_1.default.cyan(exemptMilestones.length)} milestone${exemptMilestones.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
return exemptMilestones;
}
const exemptMilestones = words_to_list_1.wordsToList(this._options.exemptIssueMilestones);
this._issueLogger.info(`The option "exemptIssueMilestones" is set. ${exemptMilestones.length} milestone${exemptMilestones.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptIssueMilestones)} is set. ${chalk_1.default.cyan(exemptMilestones.length)} milestone${exemptMilestones.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
return exemptMilestones;
}
_getExemptPullRequestMilestones() {
if (this._options.exemptPrMilestones === '') {
this._issueLogger.info('The option "exemptPrMilestones" is disabled. No specific milestone can skip the stale process for this $$type');
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptPrMilestones)} is disabled. No specific milestone can skip the stale process for this $$type`);
if (this._options.exemptMilestones === '') {
this._issueLogger.info('The option "exemptMilestones" is disabled. No specific milestone can skip the stale process for this $$type');
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptMilestones)} is disabled. No specific milestone can skip the stale process for this $$type`);
return [];
}
const exemptMilestones = words_to_list_1.wordsToList(this._options.exemptMilestones);
this._issueLogger.info(`The option "exemptMilestones" is set. ${exemptMilestones.length} milestone${exemptMilestones.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptMilestones)} is set. ${chalk_1.default.cyan(exemptMilestones.length)} milestone${exemptMilestones.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
return exemptMilestones;
}
const exemptMilestones = words_to_list_1.wordsToList(this._options.exemptPrMilestones);
this._issueLogger.info(`The option "exemptPrMilestones" is set. ${exemptMilestones.length} milestone${exemptMilestones.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
this._issueLogger.info(chalk_1.default.white('├──'), `The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptPrMilestones)} is set. ${chalk_1.default.cyan(exemptMilestones.length)} milestone${exemptMilestones.length === 1 ? '' : 's'} can skip the stale process for this $$type`);
return exemptMilestones;
}
_hasMilestone(milestone) {
@@ -1037,7 +1041,7 @@ class Milestones {
const isSameMilestone = cleanMilestone ===
Milestones._cleanMilestone(this._issue.milestone.title);
if (isSameMilestone) {
this._issueLogger.info(`The milestone "${milestone}" is set on this $$type and is an exempt milestone`);
this._issueLogger.info(chalk_1.default.white('├──'), `The milestone "${milestone}" is set on this $$type and is an exempt milestone`);
}
return isSameMilestone;
}
@@ -1051,11 +1055,11 @@ class Milestones {
}
_shouldExemptAllIssueMilestones() {
if (this._options.exemptAllIssueMilestones === true) {
this._issueLogger.info('The option "exemptAllIssueMilestones" is enabled. Any milestone on this $$type will skip the stale process');
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllIssueMilestones)} is enabled. Any milestone on this $$type will skip the stale process`);
return true;
}
else if (this._options.exemptAllIssueMilestones === false) {
this._issueLogger.info('The option "exemptAllIssueMilestones" is disabled. Only some specific milestones on this $$type will skip the stale process');
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllIssueMilestones)} is disabled. Only some specific milestones on this $$type will skip the stale process`);
return false;
}
this._logExemptAllMilestonesOption();
@@ -1063,11 +1067,11 @@ class Milestones {
}
_shouldExemptAllPullRequestMilestones() {
if (this._options.exemptAllPrMilestones === true) {
this._issueLogger.info('The option "exemptAllPrMilestones" is enabled. Any milestone on this $$type will skip the stale process');
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllPrMilestones)} is enabled. Any milestone on this $$type will skip the stale process`);
return true;
}
else if (this._options.exemptAllPrMilestones === false) {
this._issueLogger.info('The option "exemptAllPrMilestones" is disabled. Only some specific milestones on this $$type will skip the stale process');
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllPrMilestones)} is disabled. Only some specific milestones on this $$type will skip the stale process`);
return false;
}
this._logExemptAllMilestonesOption();
@@ -1075,14 +1079,14 @@ class Milestones {
}
_logExemptAllMilestonesOption() {
if (this._options.exemptAllMilestones) {
this._issueLogger.info('The option "exemptAllMilestones" is enabled. Any milestone on this $$type will skip the stale process');
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllMilestones)} is enabled. Any milestone on this $$type will skip the stale process`);
}
else {
this._issueLogger.info('The option "exemptAllMilestones" is disabled. Only some specific milestones on this $$type will skip the stale process');
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptAllMilestones)} is disabled. Only some specific milestones on this $$type will skip the stale process`);
}
}
_logSkip() {
this._issueLogger.info('Skip the milestones checks');
this._issueLogger.info(chalk_1.default.white('└──'), 'Skip the milestones checks');
}
}
exports.Milestones = Milestones;