stale/__tests__/remove-stale-when-updated.s...

556 lines
17 KiB
TypeScript
Raw Normal View History

feat(remove-stale-when-updated): add 2 options for issues and prs (#383) * 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(remove-stale-when-updated): add 2 options for issues and prs closes #377 also I closed the stale process once the stale label is removed since the following process is regarding the closing and it should simply not occur if no longer stale * chore(logs): add more logs to understand the process * chore(logs): highlights more logs and humanize a bit more * chore(index): update it * refactor(checks): simplify if complexity Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-30 21:14:51 +08:00
import {Issue} from '../src/classes/issue';
import {IIssue} from '../src/interfaces/issue';
import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options';
import {ILabel} from '../src/interfaces/label';
import {IssuesProcessorMock} from './classes/issues-processor-mock';
import {DefaultProcessorOptions} from './constants/default-processor-options';
import {generateIssue} from './functions/generate-issue';
let issuesProcessorBuilder: IssuesProcessorBuilder;
let issuesProcessor: IssuesProcessorMock;
/**
* @description
* Assuming there is a comment on the issue
feat(remove-stale-when-updated): add 2 options for issues and prs (#383) * 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(remove-stale-when-updated): add 2 options for issues and prs closes #377 also I closed the stale process once the stale label is removed since the following process is regarding the closing and it should simply not occur if no longer stale * chore(logs): add more logs to understand the process * chore(logs): highlights more logs and humanize a bit more * chore(index): update it * refactor(checks): simplify if complexity Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-30 21:14:51 +08:00
*/
describe('remove-stale-when-updated option', (): void => {
beforeEach((): void => {
issuesProcessorBuilder = new IssuesProcessorBuilder();
});
describe('when the option "remove-stale-when-updated" is disabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.keepStaleWhenUpdated();
});
test('should not remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
test('should not remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
});
describe('when the option "remove-stale-when-updated" is enabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.removeStaleWhenUpdated();
});
test('should remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
test('should remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
});
});
describe('remove-issue-stale-when-updated option', (): void => {
beforeEach((): void => {
issuesProcessorBuilder = new IssuesProcessorBuilder();
});
describe('when the option "remove-stale-when-updated" is disabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.keepStaleWhenUpdated();
});
describe('when the option "remove-issue-stale-when-updated" is unset', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.unsetIssueStaleWhenUpdated();
});
test('should not remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
test('should not remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
});
describe('when the option "remove-issue-stale-when-updated" is disabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.keepIssueStaleWhenUpdated();
});
test('should not remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
test('should not remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
});
describe('when the option "remove-issue-stale-when-updated" is enabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.removeIssueStaleWhenUpdated();
});
test('should remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
test('should not remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
});
});
describe('when the option "remove-stale-when-updated" is enabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.removeStaleWhenUpdated();
});
describe('when the option "remove-issue-stale-when-updated" is unset', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.unsetIssueStaleWhenUpdated();
});
test('should remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
test('should remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
});
describe('when the option "remove-issue-stale-when-updated" is disabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.keepIssueStaleWhenUpdated();
});
test('should not remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
test('should remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
});
describe('when the option "remove-issue-stale-when-updated" is enabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.removeIssueStaleWhenUpdated();
});
test('should remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
test('should remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
});
});
});
describe('remove-pr-stale-when-updated option', (): void => {
beforeEach((): void => {
issuesProcessorBuilder = new IssuesProcessorBuilder();
});
describe('when the option "remove-stale-when-updated" is disabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.keepStaleWhenUpdated();
});
describe('when the option "remove-pr-stale-when-updated" is unset', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.unsetPrStaleWhenUpdated();
});
test('should not remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
test('should not remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
});
describe('when the option "remove-pr-stale-when-updated" is disabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.keepPrStaleWhenUpdated();
});
test('should not remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
test('should not remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
});
describe('when the option "remove-pr-stale-when-updated" is enabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.removePrStaleWhenUpdated();
});
test('should not remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
test('should remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
});
});
describe('when the option "remove-stale-when-updated" is enabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.removeStaleWhenUpdated();
});
describe('when the option "remove-pr-stale-when-updated" is unset', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.unsetPrStaleWhenUpdated();
});
test('should remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
test('should remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
});
describe('when the option "remove-pr-stale-when-updated" is disabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.keepPrStaleWhenUpdated();
});
test('should remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
test('should not remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(0);
});
});
describe('when the option "remove-pr-stale-when-updated" is enabled', (): void => {
beforeEach((): void => {
issuesProcessorBuilder.removePrStaleWhenUpdated();
});
test('should remove the stale label on the issue', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.staleIssues([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
test('should remove the stale label on the pull request', async (): Promise<void> => {
expect.assertions(1);
issuesProcessor = issuesProcessorBuilder.stalePrs([{}]).build();
await issuesProcessor.processIssues();
expect(issuesProcessor.removedLabelIssues).toHaveLength(1);
});
});
});
});
class IssuesProcessorBuilder {
private _options: IIssuesProcessorOptions = {
...DefaultProcessorOptions
};
private _issues: Issue[] = [];
keepStaleWhenUpdated(): IssuesProcessorBuilder {
this._options.removeStaleWhenUpdated = false;
return this;
}
removeStaleWhenUpdated(): IssuesProcessorBuilder {
this._options.removeStaleWhenUpdated = true;
return this;
}
unsetIssueStaleWhenUpdated(): IssuesProcessorBuilder {
delete this._options.removeIssueStaleWhenUpdated;
return this;
}
keepIssueStaleWhenUpdated(): IssuesProcessorBuilder {
this._options.removeIssueStaleWhenUpdated = false;
return this;
}
removeIssueStaleWhenUpdated(): IssuesProcessorBuilder {
this._options.removeIssueStaleWhenUpdated = true;
return this;
}
unsetPrStaleWhenUpdated(): IssuesProcessorBuilder {
delete this._options.removePrStaleWhenUpdated;
return this;
}
keepPrStaleWhenUpdated(): IssuesProcessorBuilder {
this._options.removePrStaleWhenUpdated = false;
return this;
}
removePrStaleWhenUpdated(): IssuesProcessorBuilder {
this._options.removePrStaleWhenUpdated = true;
return this;
}
issuesOrPrs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
this._issues = issues.map(
(issue: Readonly<Partial<IIssue>>, index: Readonly<number>): Issue =>
generateIssue(
this._options,
index,
issue.title ?? 'dummy-title',
issue.updated_at ?? new Date().toDateString(),
issue.created_at ?? new Date().toDateString(),
!!issue.pull_request,
issue.labels ? issue.labels.map(label => label.name) : []
)
);
return this;
}
issues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
this.issuesOrPrs(
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
return {
...issue,
pull_request: null
};
})
feat(remove-stale-when-updated): add 2 options for issues and prs (#383) * 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(remove-stale-when-updated): add 2 options for issues and prs closes #377 also I closed the stale process once the stale label is removed since the following process is regarding the closing and it should simply not occur if no longer stale * chore(logs): add more logs to understand the process * chore(logs): highlights more logs and humanize a bit more * chore(index): update it * refactor(checks): simplify if complexity Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-30 21:14:51 +08:00
);
return this;
}
staleIssues(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
this.issues(
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
return {
...issue,
updated_at: '2020-01-01T17:00:00Z',
created_at: '2020-01-01T17:00:00Z',
labels: issue.labels?.map((label: Readonly<ILabel>): ILabel => {
return {
...label,
name: 'Stale'
};
}) ?? [
{
name: 'Stale'
}
]
};
})
feat(remove-stale-when-updated): add 2 options for issues and prs (#383) * 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(remove-stale-when-updated): add 2 options for issues and prs closes #377 also I closed the stale process once the stale label is removed since the following process is regarding the closing and it should simply not occur if no longer stale * chore(logs): add more logs to understand the process * chore(logs): highlights more logs and humanize a bit more * chore(index): update it * refactor(checks): simplify if complexity Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-30 21:14:51 +08:00
);
return this;
}
prs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
this.issuesOrPrs(
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
return {
...issue,
pull_request: {key: 'value'}
};
})
feat(remove-stale-when-updated): add 2 options for issues and prs (#383) * 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(remove-stale-when-updated): add 2 options for issues and prs closes #377 also I closed the stale process once the stale label is removed since the following process is regarding the closing and it should simply not occur if no longer stale * chore(logs): add more logs to understand the process * chore(logs): highlights more logs and humanize a bit more * chore(index): update it * refactor(checks): simplify if complexity Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-30 21:14:51 +08:00
);
return this;
}
stalePrs(issues: Partial<IIssue>[]): IssuesProcessorBuilder {
this.prs(
issues.map((issue: Readonly<Partial<IIssue>>): Partial<IIssue> => {
return {
...issue,
updated_at: '2020-01-01T17:00:00Z',
created_at: '2020-01-01T17:00:00Z',
labels: issue.labels?.map((label: Readonly<ILabel>): ILabel => {
return {
...label,
name: 'Stale'
};
}) ?? [
{
name: 'Stale'
}
]
};
})
feat(remove-stale-when-updated): add 2 options for issues and prs (#383) * 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(remove-stale-when-updated): add 2 options for issues and prs closes #377 also I closed the stale process once the stale label is removed since the following process is regarding the closing and it should simply not occur if no longer stale * chore(logs): add more logs to understand the process * chore(logs): highlights more logs and humanize a bit more * chore(index): update it * refactor(checks): simplify if complexity Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-30 21:14:51 +08:00
);
return this;
}
build(): IssuesProcessorMock {
return new IssuesProcessorMock(
this._options,
async p => (p === 1 ? this._issues : []),
async () => [
{
user: {
login: 'notme',
type: 'User'
},
body: 'body'
}
],
feat(remove-stale-when-updated): add 2 options for issues and prs (#383) * 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(remove-stale-when-updated): add 2 options for issues and prs closes #377 also I closed the stale process once the stale label is removed since the following process is regarding the closing and it should simply not occur if no longer stale * chore(logs): add more logs to understand the process * chore(logs): highlights more logs and humanize a bit more * chore(index): update it * refactor(checks): simplify if complexity Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-30 21:14:51 +08:00
async () => new Date().toDateString()
);
}
}