Compare commits

..

1 Commits

Author SHA1 Message Date
Luke Tomlinson
42fc933372 Update dist/index.json after dependabot updates 2021-05-07 16:59:31 -04:00
7 changed files with 726 additions and 1970 deletions

View File

@@ -1,7 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [4.0.1](https://github.com/actions/stale/compare/v3.0.19...v4.0.1) (2021-05-19)
### [2.0.1](https://github.com/actions/stale/compare/v3.0.19...v2.0.1) (2021-05-19)

955
dist/index.js vendored

File diff suppressed because it is too large Load Diff

1549
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "stale-action",
"version": "4.0.1",
"version": "2.0.0",
"private": true,
"description": "Marks old issues and PRs as stale",
"main": "lib/main.js",
@@ -30,17 +30,17 @@
"author": "GitHub",
"license": "MIT",
"dependencies": {
"@actions/core": "file:../toolkit/packages/core",
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"@octokit/rest": "^18.3.3",
"lodash.deburr": "^4.1.0",
"semver": "^7.3.5",
"standard-version": "^9.3.0"
"semver": "^7.3.4"
},
"devDependencies": {
"@types/jest": "^26.0.20",
"@types/lodash.deburr": "^4.1.6",
"@types/node": "^15.0.2",
"@types/semver": "^7.3.5",
"@types/semver": "^7.3.4",
"@typescript-eslint/eslint-plugin": "^4.16.1",
"@typescript-eslint/parser": "^4.22.1",
"@vercel/ncc": "^0.27.0",
@@ -55,6 +55,6 @@
"prettier": "^2.2.1",
"terminal-link": "^2.1.1",
"ts-jest": "^26.5.3",
"typescript": "^4.2.4"
"typescript": "^4.2.3"
}
}

View File

@@ -35,7 +35,7 @@ export class Assignees {
if (this._shouldExemptAllAssignees()) {
this._issueLogger.info(
chalk.white('└──'),
'Skipping this $$type because it has an exempt assignee'
'Skipping $$type because it has an exempt assignee'
);
return true;

View File

@@ -51,14 +51,6 @@ export class IssuesProcessor {
}
}
private static _getStaleMessageUsedOptionName(
issue: Readonly<Issue>
): Option.StalePrMessage | Option.StaleIssueMessage {
return issue.isPullRequest
? Option.StalePrMessage
: Option.StaleIssueMessage;
}
private readonly _logger: Logger = new Logger();
private readonly _operations: StaleOperations;
private readonly _statistics: Statistics | undefined;
@@ -120,9 +112,7 @@ export class IssuesProcessor {
const issueLogger: IssueLogger = new IssueLogger(issue);
this._statistics?.incrementProcessedItemsCount(issue);
issueLogger.info(
`Found this $$type last updated at: ${chalk.cyan(issue.updated_at)}`
);
issueLogger.info(`Found this $$type last updated ${issue.updated_at}`);
// calculate string based messages for this issue
const staleMessage: string = issue.isPullRequest
@@ -147,11 +137,7 @@ export class IssuesProcessor {
if (onlyLabels.length > 0) {
issueLogger.info(
`The option ${issueLogger.createOptionLink(
Option.OnlyLabels
)} was specified to only process issues and pull requests with all those labels (${chalk.cyan(
onlyLabels.length
)})`
`The option "onlyLabels" was specified to only processed the issues and pull requests with all those labels (${onlyLabels.length})`
);
const hasAllWhitelistedLabels: boolean = onlyLabels.every(
@@ -179,45 +165,31 @@ export class IssuesProcessor {
);
}
} else {
issueLogger.info(
`The option ${issueLogger.createOptionLink(
Option.OnlyLabels
)} was not specified`
);
issueLogger.info(`The option "onlyLabels" was not specified`);
issueLogger.info(
chalk.white('└──'),
`Continuing the process for this $$type`
);
}
issueLogger.info(
`Days before $$type stale: ${chalk.cyan(daysBeforeStale)}`
);
issueLogger.info(`Days before $$type stale: ${daysBeforeStale}`);
const shouldMarkAsStale: boolean = shouldMarkWhenStale(daysBeforeStale);
if (!staleMessage && shouldMarkAsStale) {
issueLogger.info(
`Skipping this $$type because it should be marked as stale based on the option ${issueLogger.createOptionLink(
this._getDaysBeforeStaleUsedOptionName(issue)
)} (${chalk.cyan(
daysBeforeStale
)}) but the option ${issueLogger.createOptionLink(
IssuesProcessor._getStaleMessageUsedOptionName(issue)
)} is not set`
);
issueLogger.info(`Skipping $$type due to empty stale message`);
IssuesProcessor._endIssueProcessing(issue);
continue;
}
if (issue.state === 'closed') {
issueLogger.info(`Skipping this $$type because it is closed`);
issueLogger.info(`Skipping $$type because it is closed`);
IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process closed issues
}
if (issue.locked) {
issueLogger.info(`Skipping this $$type because it is locked`);
issueLogger.info(`Skipping $$type because it is locked`);
IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process locked issues
}
@@ -230,9 +202,9 @@ export class IssuesProcessor {
const createdAt: Date = new Date(issue.created_at);
issueLogger.info(
`A start date was specified for the ${getHumanizedDate(
startDate
)} (${chalk.cyan(this.options.startDate)})`
`A start date was specified for the ${getHumanizedDate(startDate)} (${
this.options.startDate
})`
);
// Expecting that GitHub will always set a creation date on the issues and PRs
@@ -247,14 +219,14 @@ export class IssuesProcessor {
}
issueLogger.info(
`$$type created the ${getHumanizedDate(createdAt)} (${chalk.cyan(
`$$type created the ${getHumanizedDate(createdAt)} (${
issue.created_at
)})`
})`
);
if (!isDateMoreRecentThan(createdAt, startDate)) {
issueLogger.info(
`Skipping this $$type because it was created before the specified start date`
`Skipping $$type because it was created before the specified start date`
);
IssuesProcessor._endIssueProcessing(issue);
@@ -284,7 +256,7 @@ export class IssuesProcessor {
await this._removeStaleLabel(issue, staleLabel);
}
issueLogger.info(`Skipping this $$type because it has an exempt label`);
issueLogger.info(`Skipping $$type because it has an exempt label`);
IssuesProcessor._endIssueProcessing(issue);
continue; // Don't process exempt issues
}
@@ -293,11 +265,7 @@ export class IssuesProcessor {
if (anyOfLabels.length > 0) {
issueLogger.info(
`The option ${issueLogger.createOptionLink(
Option.AnyOfLabels
)} was specified to only process the issues and pull requests with one of those labels (${chalk.cyan(
anyOfLabels.length
)})`
`The option "anyOfLabels" was specified to only processed the issues and pull requests with one of those labels (${anyOfLabels.length})`
);
const hasOneOfWhitelistedLabels: boolean = anyOfLabels.some(
@@ -324,11 +292,7 @@ export class IssuesProcessor {
);
}
} else {
issueLogger.info(
`The option ${issueLogger.createOptionLink(
Option.AnyOfLabels
)} was not specified`
);
issueLogger.info(`The option "anyOfLabels" was not specified`);
issueLogger.info(
chalk.white('└──'),
`Continuing the process for this $$type`
@@ -356,45 +320,21 @@ export class IssuesProcessor {
);
// Determine if this issue needs to be marked stale first
if (!issue.isStale) {
issueLogger.info(`This $$type is not stale`);
const updatedAtDate: Date = new Date(issue.updated_at);
if (shouldBeStale) {
issueLogger.info(
`This $$type should be stale based on the last update date the ${getHumanizedDate(
updatedAtDate
)} (${chalk.cyan(issue.updated_at)})`
);
if (shouldMarkAsStale) {
issueLogger.info(
`This $$type should be marked as stale based on the option ${issueLogger.createOptionLink(
this._getDaysBeforeStaleUsedOptionName(issue)
)} (${chalk.cyan(daysBeforeStale)})`
);
await this._markStale(issue, staleMessage, staleLabel, skipMessage);
issue.isStale = true; // This issue is now considered stale
issueLogger.info(`This $$type is now stale`);
} else {
issueLogger.info(
`This $$type should not be marked as stale based on the option ${issueLogger.createOptionLink(
this._getDaysBeforeStaleUsedOptionName(issue)
)} (${chalk.cyan(daysBeforeStale)})`
);
}
} else {
issueLogger.info(
`This $$type should not be stale based on the last update date the ${getHumanizedDate(
updatedAtDate
)} (${chalk.cyan(issue.updated_at)})`
);
}
if (!issue.isStale && shouldBeStale && shouldMarkAsStale) {
issueLogger.info(
`Marking $$type stale because it was last updated on ${issue.updated_at} and it does not have a stale label`
);
await this._markStale(issue, staleMessage, staleLabel, skipMessage);
issue.isStale = true; // This issue is now considered stale
} else if (!issue.isStale) {
issueLogger.info(
`Not marking as stale: shouldBeStale=${shouldBeStale}, shouldMarkAsStale=${shouldMarkAsStale}`
);
}
// Process the issue if it was marked stale
if (issue.isStale) {
issueLogger.info(`This $$type is already stale`);
issueLogger.info(`Found a stale $$type`);
await this._processStaleIssue(
issue,
staleLabel,
@@ -505,7 +445,7 @@ export class IssuesProcessor {
): Promise<string | undefined> {
const issueLogger: IssueLogger = new IssueLogger(issue);
issueLogger.info(`Checking for label on this $$type`);
issueLogger.info(`Checking for label on $$type`);
this._consumeIssueOperation(issue);
this._statistics?.incrementFetchedItemsEventsCount();
@@ -557,9 +497,7 @@ export class IssuesProcessor {
? this._getDaysBeforePrClose()
: this._getDaysBeforeIssueClose();
issueLogger.info(
`Days before $$type close: ${chalk.cyan(daysBeforeClose)}`
);
issueLogger.info(`Days before $$type close: ${daysBeforeClose}`);
const issueHasUpdate: boolean = IssuesProcessor._updatedSince(
issue.updated_at,
@@ -583,17 +521,13 @@ export class IssuesProcessor {
if (!issueHasComments && !issueHasUpdate) {
issueLogger.info(
`Closing $$type because it was last updated on! ${chalk.cyan(
issue.updated_at
)}`
`Closing $$type because it was last updated on ${issue.updated_at}`
);
await this._closeIssue(issue, closeMessage, closeLabel);
if (this.options.deleteBranch && issue.pull_request) {
issueLogger.info(
`Deleting the branch the option ${issueLogger.createOptionLink(
Option.DeleteBranch
)} was specified`
`Deleting branch for as delete-branch option was specified`
);
await this._deleteBranch(issue);
this.deletedBranchIssues.push(issue);
@@ -613,9 +547,7 @@ export class IssuesProcessor {
): Promise<boolean> {
const issueLogger: IssueLogger = new IssueLogger(issue);
issueLogger.info(
`Checking for comments on $$type since: ${chalk.cyan(sinceDate)}`
);
issueLogger.info(`Checking for comments on $$type since ${sinceDate}`);
if (!sinceDate) {
return true;
@@ -629,9 +561,7 @@ export class IssuesProcessor {
);
issueLogger.info(
`Comments not made by actor or another bot: ${chalk.cyan(
filteredComments.length
)}`
`Comments not made by actor or another bot: ${filteredComments.length}`
);
// if there are any user comments returned
@@ -647,7 +577,7 @@ export class IssuesProcessor {
): Promise<void> {
const issueLogger: IssueLogger = new IssueLogger(issue);
issueLogger.info(`Marking this $$type as stale`);
issueLogger.info(`Marking $$type as stale`);
this.staleIssues.push(issue);
// if the issue is being marked stale, the updated date should be changed to right now
@@ -782,7 +712,7 @@ export class IssuesProcessor {
if (!pullRequest) {
issueLogger.info(
`Not deleting this branch as no pull request was found for this $$type`
`Not deleting branch as pull request not found for this $$type`
);
return;
}
@@ -818,7 +748,7 @@ export class IssuesProcessor {
const issueLogger: IssueLogger = new IssueLogger(issue);
issueLogger.info(
`Removing the label "${chalk.cyan(label)}" from this $$type...`
`Removing the label "${chalk.cyan(label)}" from the $$type...`
);
this.removedLabelIssues.push(issue);
@@ -957,31 +887,4 @@ export class IssuesProcessor {
this._operations.consumeOperation();
issue.operations.consumeOperation();
}
private _getDaysBeforeStaleUsedOptionName(
issue: Readonly<Issue>
):
| Option.DaysBeforeStale
| Option.DaysBeforeIssueStale
| Option.DaysBeforePrStale {
return issue.isPullRequest
? this._getDaysBeforePrStaleUsedOptionName()
: this._getDaysBeforeIssueStaleUsedOptionName();
}
private _getDaysBeforeIssueStaleUsedOptionName():
| Option.DaysBeforeStale
| Option.DaysBeforeIssueStale {
return isNaN(this.options.daysBeforeIssueStale)
? Option.DaysBeforeStale
: Option.DaysBeforeIssueStale;
}
private _getDaysBeforePrStaleUsedOptionName():
| Option.DaysBeforeStale
| Option.DaysBeforePrStale {
return isNaN(this.options.daysBeforePrStale)
? Option.DaysBeforeStale
: Option.DaysBeforePrStale;
}
}

View File

@@ -34,7 +34,7 @@ export class Milestones {
if (this._shouldExemptAllMilestones()) {
this._issueLogger.info(
chalk.white('└──'),
'Skipping this $$type because it has a milestone'
'Skipping $$type because it has a milestone'
);
return true;