🎨 Add message grouping (#483)

* 🎨 add message grouping

* ⚗️ try output

* 🔥 remove unnecessary code

* ⬆️ bump deps

* 🎨 build project

* ⬆️ bump deps

* 🎨 formatting code

* ⬇️ revert bumps

* 🎨 using logger service

* 🎨 using package lock version 1

* 🎨 add engines keyword

* ♻️ create processIssue method

*  add grouping method

* 🎨 build project

* 🎨 update engine declaration

* 💚 fix merge conflicts
This commit is contained in:
Falk Puschner 2021-06-07 23:22:55 +02:00 committed by GitHub
parent 5f6f311ca6
commit 52f5648db3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 580 additions and 549 deletions

View File

@ -1112,14 +1112,12 @@ class IssuesProcessorBuilder {
issues(issues: Partial<IIssue>[]): IssuesProcessorBuilder { issues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
this.issuesOrPrs( this.issuesOrPrs(
issues.map( issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
return { return {
...issue, ...issue,
pull_request: null pull_request: null
}; };
} })
)
); );
return this; return this;
@ -1127,14 +1125,12 @@ class IssuesProcessorBuilder {
prs(issues: Partial<IIssue>[]): IssuesProcessorBuilder { prs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
this.issuesOrPrs( this.issuesOrPrs(
issues.map( issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
return { return {
...issue, ...issue,
pull_request: {key: 'value'} pull_request: {key: 'value'}
}; };
} })
)
); );
return this; return this;

View File

@ -32,12 +32,10 @@ export function generateIssue(
title: milestone title: milestone
} }
: undefined, : undefined,
assignees: assignees.map( assignees: assignees.map((assignee: Readonly<string>): IAssignee => {
(assignee: Readonly<string>): IAssignee => {
return { return {
login: assignee login: assignee
}; };
} })
)
}); });
} }

View File

@ -1112,14 +1112,12 @@ class IssuesProcessorBuilder {
issues(issues: Partial<IIssue>[]): IssuesProcessorBuilder { issues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
this.issuesOrPrs( this.issuesOrPrs(
issues.map( issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
return { return {
...issue, ...issue,
pull_request: null pull_request: null
}; };
} })
)
); );
return this; return this;
@ -1127,14 +1125,12 @@ class IssuesProcessorBuilder {
prs(issues: Partial<IIssue>[]): IssuesProcessorBuilder { prs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
this.issuesOrPrs( this.issuesOrPrs(
issues.map( issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
return { return {
...issue, ...issue,
pull_request: {key: 'value'} pull_request: {key: 'value'}
}; };
} })
)
); );
return this; return this;

View File

@ -188,8 +188,7 @@ class SUT {
} }
private _setTestIssueList(): SUT { private _setTestIssueList(): SUT {
this._testIssueList = this._sutIssues.map( this._testIssueList = this._sutIssues.map((sutIssue: SUTIssue): Issue => {
(sutIssue: SUTIssue): Issue => {
return generateIssue( return generateIssue(
this._opts, this._opts,
1, 1,
@ -198,8 +197,7 @@ class SUT {
sutIssue.updatedAt, sutIssue.updatedAt,
false false
); );
} });
);
return this; return this;
} }

View File

@ -464,14 +464,12 @@ class IssuesProcessorBuilder {
issues(issues: Partial<IIssue>[]): IssuesProcessorBuilder { issues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
this.issuesOrPrs( this.issuesOrPrs(
issues.map( issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
return { return {
...issue, ...issue,
pull_request: null pull_request: null
}; };
} })
)
); );
return this; return this;
@ -479,27 +477,23 @@ class IssuesProcessorBuilder {
staleIssues(issues: Partial<IIssue>[]): IssuesProcessorBuilder { staleIssues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
this.issues( this.issues(
issues.map( issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
return { return {
...issue, ...issue,
updated_at: '2020-01-01T17:00:00Z', updated_at: '2020-01-01T17:00:00Z',
created_at: '2020-01-01T17:00:00Z', created_at: '2020-01-01T17:00:00Z',
labels: issue.labels?.map( labels: issue.labels?.map((label: Readonly<ILabel>): ILabel => {
(label: Readonly<ILabel>): ILabel => {
return { return {
...label, ...label,
name: 'Stale' name: 'Stale'
}; };
} }) ?? [
) ?? [
{ {
name: 'Stale' name: 'Stale'
} }
] ]
}; };
} })
)
); );
return this; return this;
@ -507,14 +501,12 @@ class IssuesProcessorBuilder {
prs(issues: Partial<IIssue>[]): IssuesProcessorBuilder { prs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
this.issuesOrPrs( this.issuesOrPrs(
issues.map( issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
return { return {
...issue, ...issue,
pull_request: {key: 'value'} pull_request: {key: 'value'}
}; };
} })
)
); );
return this; return this;
@ -522,27 +514,23 @@ class IssuesProcessorBuilder {
stalePrs(issues: Partial<IIssue>[]): IssuesProcessorBuilder { stalePrs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
this.prs( this.prs(
issues.map( issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
(issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
return { return {
...issue, ...issue,
updated_at: '2020-01-01T17:00:00Z', updated_at: '2020-01-01T17:00:00Z',
created_at: '2020-01-01T17:00:00Z', created_at: '2020-01-01T17:00:00Z',
labels: issue.labels?.map( labels: issue.labels?.map((label: Readonly<ILabel>): ILabel => {
(label: Readonly<ILabel>): ILabel => {
return { return {
...label, ...label,
name: 'Stale' name: 'Stale'
}; };
} }) ?? [
) ?? [
{ {
name: 'Stale' name: 'Stale'
} }
] ]
}; };
} })
)
); );
return this; return this;

82
dist/index.js vendored
View File

@ -286,7 +286,7 @@ class IssuesProcessor {
return issue.isPullRequest ? option_1.Option.ClosePrLabel : option_1.Option.CloseIssueLabel; return issue.isPullRequest ? option_1.Option.ClosePrLabel : option_1.Option.CloseIssueLabel;
} }
processIssues(page = 1) { processIssues(page = 1) {
var _a, _b, _c; var _a, _b;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// get the next batch of issues // get the next batch of issues
const issues = yield this.getIssues(page); const issues = yield this.getIssues(page);
@ -305,7 +305,26 @@ class IssuesProcessor {
break; break;
} }
const issueLogger = new issue_logger_1.IssueLogger(issue); const issueLogger = new issue_logger_1.IssueLogger(issue);
(_b = this._statistics) === null || _b === void 0 ? void 0 : _b.incrementProcessedItemsCount(issue); yield issueLogger.grouping(`$$type #${issue.number}`, () => __awaiter(this, void 0, void 0, function* () {
yield this.processIssue(issue, actor);
}));
}
if (!this.operations.hasRemainingOperations()) {
this._logger.warning(logger_service_1.LoggerService.yellowBright(`No more operations left! Exiting...`));
this._logger.warning(`${logger_service_1.LoggerService.yellowBright('If you think that not enough issues were processed you could try to increase the quantity related to the')} ${this._logger.createOptionLink(option_1.Option.OperationsPerRun)} ${logger_service_1.LoggerService.yellowBright('option which is currently set to')} ${logger_service_1.LoggerService.cyan(this.options.operationsPerRun)}`);
(_b = this._statistics) === null || _b === void 0 ? void 0 : _b.setOperationsCount(this.operations.getConsumedOperationsCount()).logStats();
return 0;
}
this._logger.info(`${logger_service_1.LoggerService.green('Batch')} ${logger_service_1.LoggerService.cyan(`#${page}`)} ${logger_service_1.LoggerService.green('processed.')}`);
// Do the next batch
return this.processIssues(page + 1);
});
}
processIssue(issue, actor) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementProcessedItemsCount(issue);
const issueLogger = new issue_logger_1.IssueLogger(issue);
issueLogger.info(`Found this $$type last updated at: ${logger_service_1.LoggerService.cyan(issue.updated_at)}`); issueLogger.info(`Found this $$type last updated at: ${logger_service_1.LoggerService.cyan(issue.updated_at)}`);
// calculate string based messages for this issue // calculate string based messages for this issue
const staleMessage = issue.isPullRequest const staleMessage = issue.isPullRequest
@ -335,7 +354,7 @@ class IssuesProcessor {
if (!hasAllWhitelistedLabels) { if (!hasAllWhitelistedLabels) {
issueLogger.info(logger_service_1.LoggerService.white('└──'), `Skipping this $$type because it doesn't have all the required labels`); issueLogger.info(logger_service_1.LoggerService.white('└──'), `Skipping this $$type because it doesn't have all the required labels`);
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process issues without all of the required labels return; // Don't process issues without all of the required labels
} }
else { else {
issueLogger.info(logger_service_1.LoggerService.white('├──'), `All the required labels are present on this $$type`); issueLogger.info(logger_service_1.LoggerService.white('├──'), `All the required labels are present on this $$type`);
@ -351,12 +370,12 @@ class IssuesProcessor {
if (issue.state === 'closed') { if (issue.state === 'closed') {
issueLogger.info(`Skipping this $$type because it is closed`); issueLogger.info(`Skipping this $$type because it is closed`);
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process closed issues return; // Don't process closed issues
} }
if (issue.locked) { if (issue.locked) {
issueLogger.info(`Skipping this $$type because it is locked`); issueLogger.info(`Skipping this $$type because it is locked`);
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process locked issues return; // Don't process locked issues
} }
// Try to remove the close label when not close/locked issue or PR // Try to remove the close label when not close/locked issue or PR
yield this._removeCloseLabel(issue, closeLabel); yield this._removeCloseLabel(issue, closeLabel);
@ -374,7 +393,7 @@ class IssuesProcessor {
if (!is_date_more_recent_than_1.isDateMoreRecentThan(createdAt, startDate)) { if (!is_date_more_recent_than_1.isDateMoreRecentThan(createdAt, startDate)) {
issueLogger.info(`Skipping this $$type because it was created before the specified start date`); issueLogger.info(`Skipping this $$type because it was created before the specified start date`);
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process issues which were created before the start date return; // Don't process issues which were created before the start date
} }
} }
if (issue.isStale) { if (issue.isStale) {
@ -393,7 +412,7 @@ class IssuesProcessor {
} }
issueLogger.info(`Skipping this $$type because it has an exempt label`); issueLogger.info(`Skipping this $$type because it has an exempt label`);
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process exempt issues return; // Don't process exempt issues
} }
const anyOfLabels = words_to_list_1.wordsToList(this._getAnyOfLabels(issue)); const anyOfLabels = words_to_list_1.wordsToList(this._getAnyOfLabels(issue));
if (anyOfLabels.length > 0) { if (anyOfLabels.length > 0) {
@ -404,7 +423,7 @@ class IssuesProcessor {
if (!hasOneOfWhitelistedLabels) { if (!hasOneOfWhitelistedLabels) {
issueLogger.info(logger_service_1.LoggerService.white('└──'), `Skipping this $$type because it doesn't have one of the required labels`); issueLogger.info(logger_service_1.LoggerService.white('└──'), `Skipping this $$type because it doesn't have one of the required labels`);
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process issues without any of the required labels return; // Don't process issues without any of the required labels
} }
else { else {
issueLogger.info(logger_service_1.LoggerService.white('├──'), `One of the required labels is present on this $$type`); issueLogger.info(logger_service_1.LoggerService.white('├──'), `One of the required labels is present on this $$type`);
@ -418,12 +437,12 @@ class IssuesProcessor {
const milestones = new milestones_1.Milestones(this.options, issue); const milestones = new milestones_1.Milestones(this.options, issue);
if (milestones.shouldExemptMilestones()) { if (milestones.shouldExemptMilestones()) {
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process exempt milestones return; // Don't process exempt milestones
} }
const assignees = new assignees_1.Assignees(this.options, issue); const assignees = new assignees_1.Assignees(this.options, issue);
if (assignees.shouldExemptAssignees()) { if (assignees.shouldExemptAssignees()) {
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process exempt assignees return; // Don't process exempt assignees
} }
// Should this issue be marked stale? // Should this issue be marked stale?
const shouldBeStale = !IssuesProcessor._updatedSince(issue.updated_at, daysBeforeStale); const shouldBeStale = !IssuesProcessor._updatedSince(issue.updated_at, daysBeforeStale);
@ -453,16 +472,6 @@ class IssuesProcessor {
yield this._processStaleIssue(issue, staleLabel, actor, closeMessage, closeLabel); yield this._processStaleIssue(issue, staleLabel, actor, closeMessage, closeLabel);
} }
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
}
if (!this.operations.hasRemainingOperations()) {
this._logger.warning(logger_service_1.LoggerService.yellowBright(`No more operations left! Exiting...`));
this._logger.warning(`${logger_service_1.LoggerService.yellowBright('If you think that not enough issues were processed you could try to increase the quantity related to the')} ${this._logger.createOptionLink(option_1.Option.OperationsPerRun)} ${logger_service_1.LoggerService.yellowBright('option which is currently set to')} ${logger_service_1.LoggerService.cyan(this.options.operationsPerRun)}`);
(_c = this._statistics) === null || _c === void 0 ? void 0 : _c.setOperationsCount(this.operations.getConsumedOperationsCount()).logStats();
return 0;
}
this._logger.info(`${logger_service_1.LoggerService.green('Batch')} ${logger_service_1.LoggerService.cyan(`#${page}`)} ${logger_service_1.LoggerService.green('processed.')}`);
// Do the next batch
return this.processIssues(page + 1);
}); });
} }
// Grab comments for an issue since a given date // Grab comments for an issue since a given date
@ -913,10 +922,19 @@ exports.IssuesProcessor = IssuesProcessor;
/***/ }), /***/ }),
/***/ 2984: /***/ 2984:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.IssueLogger = void 0; exports.IssueLogger = void 0;
const logger_1 = __nccwpck_require__(6212); const logger_1 = __nccwpck_require__(6212);
@ -948,6 +966,14 @@ class IssueLogger extends logger_1.Logger {
error(...message) { error(...message) {
super.error(this._format(...message)); super.error(this._format(...message));
} }
grouping(message, fn) {
const _super = Object.create(null, {
grouping: { get: () => super.grouping }
});
return __awaiter(this, void 0, void 0, function* () {
return _super.grouping.call(this, this._format(message), fn);
});
}
_replaceTokens(message) { _replaceTokens(message) {
return this._replaceTypeToken(message); return this._replaceTypeToken(message);
} }
@ -1006,6 +1032,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
@ -1024,6 +1059,11 @@ class Logger {
error(...message) { error(...message) {
core.error(logger_service_1.LoggerService.whiteBright(message.join(' '))); core.error(logger_service_1.LoggerService.whiteBright(message.join(' ')));
} }
grouping(message, fn) {
return __awaiter(this, void 0, void 0, function* () {
return core.group(logger_service_1.LoggerService.whiteBright(message), fn);
});
}
createLink(name, link) { createLink(name, link) {
return terminal_link_1.default(name, link); return terminal_link_1.default(name, link);
} }

View File

@ -30,6 +30,10 @@
"node", "node",
"stale" "stale"
], ],
"engines": {
"node": "12",
"npm": "6"
},
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {

View File

@ -37,7 +37,8 @@ export class IssuesProcessor {
} }
private static _endIssueProcessing(issue: Issue): void { private static _endIssueProcessing(issue: Issue): void {
const consumedOperationsCount: number = issue.operations.getConsumedOperationsCount(); const consumedOperationsCount: number =
issue.operations.getConsumedOperationsCount();
if (consumedOperationsCount > 0) { if (consumedOperationsCount > 0) {
const issueLogger: IssueLogger = new IssueLogger(issue); const issueLogger: IssueLogger = new IssueLogger(issue);
@ -133,8 +134,45 @@ export class IssuesProcessor {
} }
const issueLogger: IssueLogger = new IssueLogger(issue); const issueLogger: IssueLogger = new IssueLogger(issue);
await issueLogger.grouping(`$$type #${issue.number}`, async () => {
await this.processIssue(issue, actor);
});
}
if (!this.operations.hasRemainingOperations()) {
this._logger.warning(
LoggerService.yellowBright(`No more operations left! Exiting...`)
);
this._logger.warning(
`${LoggerService.yellowBright(
'If you think that not enough issues were processed you could try to increase the quantity related to the'
)} ${this._logger.createOptionLink(
Option.OperationsPerRun
)} ${LoggerService.yellowBright(
'option which is currently set to'
)} ${LoggerService.cyan(this.options.operationsPerRun)}`
);
this._statistics
?.setOperationsCount(this.operations.getConsumedOperationsCount())
.logStats();
return 0;
}
this._logger.info(
`${LoggerService.green('Batch')} ${LoggerService.cyan(
`#${page}`
)} ${LoggerService.green('processed.')}`
);
// Do the next batch
return this.processIssues(page + 1);
}
async processIssue(issue: Issue, actor: string): Promise<void> {
this._statistics?.incrementProcessedItemsCount(issue); this._statistics?.incrementProcessedItemsCount(issue);
const issueLogger: IssueLogger = new IssueLogger(issue);
issueLogger.info( issueLogger.info(
`Found this $$type last updated at: ${LoggerService.cyan( `Found this $$type last updated at: ${LoggerService.cyan(
issue.updated_at issue.updated_at
@ -184,7 +222,7 @@ export class IssuesProcessor {
); );
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process issues without all of the required labels return; // Don't process issues without all of the required labels
} else { } else {
issueLogger.info( issueLogger.info(
LoggerService.white('├──'), LoggerService.white('├──'),
@ -216,13 +254,13 @@ export class IssuesProcessor {
if (issue.state === 'closed') { if (issue.state === 'closed') {
issueLogger.info(`Skipping this $$type because it is closed`); issueLogger.info(`Skipping this $$type because it is closed`);
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process closed issues return; // Don't process closed issues
} }
if (issue.locked) { if (issue.locked) {
issueLogger.info(`Skipping this $$type because it is locked`); issueLogger.info(`Skipping this $$type because it is locked`);
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process locked issues return; // Don't process locked issues
} }
// Try to remove the close label when not close/locked issue or PR // Try to remove the close label when not close/locked issue or PR
@ -243,9 +281,7 @@ export class IssuesProcessor {
if (!isValidDate(createdAt)) { if (!isValidDate(createdAt)) {
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
core.setFailed( core.setFailed(
new Error( new Error(`Invalid issue field: "created_at". Expected a valid date`)
`Invalid issue field: "created_at". Expected a valid date`
)
); );
} }
@ -261,7 +297,7 @@ export class IssuesProcessor {
); );
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process issues which were created before the start date return; // Don't process issues which were created before the start date
} }
} }
@ -289,7 +325,7 @@ export class IssuesProcessor {
issueLogger.info(`Skipping this $$type because it has an exempt label`); issueLogger.info(`Skipping this $$type because it has an exempt label`);
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process exempt issues return; // Don't process exempt issues
} }
const anyOfLabels: string[] = wordsToList(this._getAnyOfLabels(issue)); const anyOfLabels: string[] = wordsToList(this._getAnyOfLabels(issue));
@ -315,7 +351,7 @@ export class IssuesProcessor {
`Skipping this $$type because it doesn't have one of the required labels` `Skipping this $$type because it doesn't have one of the required labels`
); );
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process issues without any of the required labels return; // Don't process issues without any of the required labels
} else { } else {
issueLogger.info( issueLogger.info(
LoggerService.white('├──'), LoggerService.white('├──'),
@ -342,14 +378,14 @@ export class IssuesProcessor {
if (milestones.shouldExemptMilestones()) { if (milestones.shouldExemptMilestones()) {
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process exempt milestones return; // Don't process exempt milestones
} }
const assignees: Assignees = new Assignees(this.options, issue); const assignees: Assignees = new Assignees(this.options, issue);
if (assignees.shouldExemptAssignees()) { if (assignees.shouldExemptAssignees()) {
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process exempt assignees return; // Don't process exempt assignees
} }
// Should this issue be marked stale? // Should this issue be marked stale?
@ -410,36 +446,6 @@ export class IssuesProcessor {
IssuesProcessor._endIssueProcessing(issue); IssuesProcessor._endIssueProcessing(issue);
} }
if (!this.operations.hasRemainingOperations()) {
this._logger.warning(
LoggerService.yellowBright(`No more operations left! Exiting...`)
);
this._logger.warning(
`${LoggerService.yellowBright(
'If you think that not enough issues were processed you could try to increase the quantity related to the'
)} ${this._logger.createOptionLink(
Option.OperationsPerRun
)} ${LoggerService.yellowBright(
'option which is currently set to'
)} ${LoggerService.cyan(this.options.operationsPerRun)}`
);
this._statistics
?.setOperationsCount(this.operations.getConsumedOperationsCount())
.logStats();
return 0;
}
this._logger.info(
`${LoggerService.green('Batch')} ${LoggerService.cyan(
`#${page}`
)} ${LoggerService.green('processed.')}`
);
// Do the next batch
return this.processIssues(page + 1);
}
// Grab comments for an issue since a given date // Grab comments for an issue since a given date
async listIssueComments( async listIssueComments(
issueNumber: Readonly<number>, issueNumber: Readonly<number>,
@ -484,16 +490,15 @@ export class IssuesProcessor {
try { try {
this.operations.consumeOperation(); this.operations.consumeOperation();
const issueResult: OctoKitIssueList = await this.client.issues.listForRepo( const issueResult: OctoKitIssueList =
{ await this.client.issues.listForRepo({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
state: 'open', state: 'open',
per_page: 100, per_page: 100,
direction: this.options.ascending ? 'asc' : 'desc', direction: this.options.ascending ? 'asc' : 'desc',
page page
} });
);
this._statistics?.incrementFetchedItemsCount(issueResult.data.length); this._statistics?.incrementFetchedItemsCount(issueResult.data.length);
return issueResult.data.map( return issueResult.data.map(
@ -579,9 +584,8 @@ export class IssuesProcessor {
`$$type has been updated: ${LoggerService.cyan(issueHasUpdate)}` `$$type has been updated: ${LoggerService.cyan(issueHasUpdate)}`
); );
const shouldRemoveStaleWhenUpdated: boolean = this._shouldRemoveStaleWhenUpdated( const shouldRemoveStaleWhenUpdated: boolean =
issue this._shouldRemoveStaleWhenUpdated(issue);
);
issueLogger.info( issueLogger.info(
`The option ${issueLogger.createOptionLink( `The option ${issueLogger.createOptionLink(

View File

@ -35,6 +35,10 @@ export class IssueLogger extends Logger {
super.error(this._format(...message)); super.error(this._format(...message));
} }
async grouping(message: string, fn: () => Promise<void>): Promise<void> {
return super.grouping(this._format(message), fn);
}
private _replaceTokens(message: Readonly<string>): string { private _replaceTokens(message: Readonly<string>): string {
return this._replaceTypeToken(message); return this._replaceTypeToken(message);
} }

View File

@ -16,6 +16,10 @@ export class Logger {
core.error(LoggerService.whiteBright(message.join(' '))); core.error(LoggerService.whiteBright(message.join(' ')));
} }
async grouping(message: string, fn: () => Promise<void>): Promise<void> {
return core.group(LoggerService.whiteBright(message), fn);
}
createLink(name: Readonly<string>, link: Readonly<string>): string { createLink(name: Readonly<string>, link: Readonly<string>): string {
return terminalLink(name, link); return terminalLink(name, link);
} }

View File

@ -195,9 +195,8 @@ export class Milestones {
return false; return false;
} }
const cleanMilestone: CleanMilestone = Milestones._cleanMilestone( const cleanMilestone: CleanMilestone =
milestone Milestones._cleanMilestone(milestone);
);
const isSameMilestone: boolean = const isSameMilestone: boolean =
cleanMilestone === cleanMilestone ===

View File

@ -7,9 +7,9 @@ describe('isLabeled()', (): void => {
describe('when the given issue contains no label', (): void => { describe('when the given issue contains no label', (): void => {
beforeEach((): void => { beforeEach((): void => {
issue = ({ issue = {
labels: [] labels: []
} as unknown) as Issue; } as unknown as Issue;
}); });
describe('when the given label is a simple label', (): void => { describe('when the given label is a simple label', (): void => {