Update @actions/github to 5.0.1 (#707)

* Update github package

* Update dist

* Use @actions/github@5.0.1

* Cleanup

* More cleanup
This commit is contained in:
Luke Tomlinson 2022-03-31 15:38:16 -04:00 committed by GitHub
parent 74dfff0835
commit a88f7b30b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 3214 additions and 926 deletions

View File

@ -1103,7 +1103,7 @@ class IssuesProcessorBuilder {
issue.updated_at ?? new Date().toDateString(), issue.updated_at ?? new Date().toDateString(),
issue.created_at ?? new Date().toDateString(), issue.created_at ?? new Date().toDateString(),
!!issue.pull_request, !!issue.pull_request,
issue.labels ? issue.labels.map(label => label.name) : [] issue.labels ? issue.labels.map(label => label.name || '') : []
) )
); );

View File

@ -85,7 +85,7 @@ class IssuesProcessorBuilder {
issue.updated_at ?? new Date().toDateString(), issue.updated_at ?? new Date().toDateString(),
issue.created_at ?? new Date().toDateString(), issue.created_at ?? new Date().toDateString(),
!!issue.pull_request, !!issue.pull_request,
issue.labels ? issue.labels.map(label => label.name) : [] issue.labels ? issue.labels.map(label => label.name || '') : []
) )
); );

View File

@ -1103,7 +1103,7 @@ class IssuesProcessorBuilder {
issue.updated_at ?? new Date().toDateString(), issue.updated_at ?? new Date().toDateString(),
issue.created_at ?? new Date().toDateString(), issue.created_at ?? new Date().toDateString(),
!!issue.pull_request, !!issue.pull_request,
issue.labels ? issue.labels.map(label => label.name) : [] issue.labels ? issue.labels.map(label => label.name || '') : []
) )
); );

View File

@ -455,7 +455,7 @@ class IssuesProcessorBuilder {
issue.updated_at ?? new Date().toDateString(), issue.updated_at ?? new Date().toDateString(),
issue.created_at ?? new Date().toDateString(), issue.created_at ?? new Date().toDateString(),
!!issue.pull_request, !!issue.pull_request,
issue.labels ? issue.labels.map(label => label.name) : [] issue.labels ? issue.labels.map(label => label.name || '') : []
) )
); );

3848
dist/index.js vendored

File diff suppressed because one or more lines are too long

163
package-lock.json generated
View File

@ -10,20 +10,20 @@
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==" "integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
}, },
"@actions/github": { "@actions/github": {
"version": "4.0.0", "version": "5.0.1",
"resolved": "https://registry.npmjs.org/@actions/github/-/github-4.0.0.tgz", "resolved": "https://registry.npmjs.org/@actions/github/-/github-5.0.1.tgz",
"integrity": "sha512-Ej/Y2E+VV6sR9X7pWL5F3VgEWrABaT292DRqRU6R4hnQjPtC/zD3nagxVdXWiRQvYDh8kHXo7IDmG42eJ/dOMA==", "integrity": "sha512-JZGyPM9ektb8NVTTI/2gfJ9DL7Rk98tQ7OVyTlgTuaQroariRBsOnzjy0I2EarX4xUZpK88YyO503fhmjFdyAg==",
"requires": { "requires": {
"@actions/http-client": "^1.0.8", "@actions/http-client": "^1.0.11",
"@octokit/core": "^3.0.0", "@octokit/core": "^3.6.0",
"@octokit/plugin-paginate-rest": "^2.2.3", "@octokit/plugin-paginate-rest": "^2.17.0",
"@octokit/plugin-rest-endpoint-methods": "^4.0.0" "@octokit/plugin-rest-endpoint-methods": "^5.13.0"
} }
}, },
"@actions/http-client": { "@actions/http-client": {
"version": "1.0.8", "version": "1.0.11",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.8.tgz", "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
"integrity": "sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA==", "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
"requires": { "requires": {
"tunnel": "0.0.6" "tunnel": "0.0.6"
} }
@ -1382,94 +1382,98 @@
} }
}, },
"@octokit/auth-token": { "@octokit/auth-token": {
"version": "2.4.2", "version": "2.5.0",
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.4.2.tgz", "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz",
"integrity": "sha512-jE/lE/IKIz2v1+/P0u4fJqv0kYwXOTujKemJMFr6FeopsxlIK3+wKDCJGnysg81XID5TgZQbIfuJ5J0lnTiuyQ==", "integrity": "sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==",
"requires": { "requires": {
"@octokit/types": "^5.0.0" "@octokit/types": "^6.0.3"
} }
}, },
"@octokit/core": { "@octokit/core": {
"version": "3.1.1", "version": "3.6.0",
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.1.1.tgz", "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.6.0.tgz",
"integrity": "sha512-cQ2HGrtyNJ1IBxpTP1U5m/FkMAJvgw7d2j1q3c9P0XUuYilEgF6e4naTpsgm4iVcQeOnccZlw7XHRIUBy0ymcg==", "integrity": "sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q==",
"requires": { "requires": {
"@octokit/auth-token": "^2.4.0", "@octokit/auth-token": "^2.4.4",
"@octokit/graphql": "^4.3.1", "@octokit/graphql": "^4.5.8",
"@octokit/request": "^5.4.0", "@octokit/request": "^5.6.3",
"@octokit/types": "^5.0.0", "@octokit/request-error": "^2.0.5",
"before-after-hook": "^2.1.0", "@octokit/types": "^6.0.3",
"before-after-hook": "^2.2.0",
"universal-user-agent": "^6.0.0" "universal-user-agent": "^6.0.0"
} }
}, },
"@octokit/endpoint": { "@octokit/endpoint": {
"version": "6.0.5", "version": "6.0.12",
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.5.tgz", "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz",
"integrity": "sha512-70K5u6zd45ItOny6aHQAsea8HHQjlQq85yqOMe+Aj8dkhN2qSJ9T+Q3YjUjEYfPRBcuUWNgMn62DQnP/4LAIiQ==", "integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==",
"requires": { "requires": {
"@octokit/types": "^5.0.0", "@octokit/types": "^6.0.3",
"is-plain-object": "^4.0.0", "is-plain-object": "^5.0.0",
"universal-user-agent": "^6.0.0" "universal-user-agent": "^6.0.0"
} }
}, },
"@octokit/graphql": { "@octokit/graphql": {
"version": "4.5.2", "version": "4.8.0",
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.5.2.tgz", "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.8.0.tgz",
"integrity": "sha512-SpB/JGdB7bxRj8qowwfAXjMpICUYSJqRDj26MKJAryRQBqp/ZzARsaO2LEFWzDaps0FLQoPYVGppS0HQXkBhdg==", "integrity": "sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==",
"requires": { "requires": {
"@octokit/request": "^5.3.0", "@octokit/request": "^5.6.0",
"@octokit/types": "^5.0.0", "@octokit/types": "^6.0.3",
"universal-user-agent": "^6.0.0" "universal-user-agent": "^6.0.0"
} }
}, },
"@octokit/openapi-types": {
"version": "11.2.0",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-11.2.0.tgz",
"integrity": "sha512-PBsVO+15KSlGmiI8QAzaqvsNlZlrDlyAJYcrXBCvVUxCp7VnXjkwPoFHgjEJXx3WF9BAwkA6nfCUA7i9sODzKA=="
},
"@octokit/plugin-paginate-rest": { "@octokit/plugin-paginate-rest": {
"version": "2.2.4", "version": "2.17.0",
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.2.4.tgz", "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.17.0.tgz",
"integrity": "sha512-oT/lohKytvstJ4oL7yueNRhqbjYJ7BExYDAHxyYyZtiSZj5y2F1SRINvZwQ+E4esH30YovE2jDysUltty4OYEA==", "integrity": "sha512-tzMbrbnam2Mt4AhuyCHvpRkS0oZ5MvwwcQPYGtMv4tUa5kkzG58SVB0fcsLulOZQeRnOgdkZWkRUiyBlh0Bkyw==",
"requires": { "requires": {
"@octokit/types": "^5.0.0" "@octokit/types": "^6.34.0"
} }
}, },
"@octokit/plugin-rest-endpoint-methods": { "@octokit/plugin-rest-endpoint-methods": {
"version": "4.1.2", "version": "5.13.0",
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.1.2.tgz", "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.13.0.tgz",
"integrity": "sha512-PTI7wpbGEZ2IR87TVh+TNWaLcgX/RsZQalFbQCq8XxYUrQ36RHyERrHSNXFy5gkWpspUAOYRSV707JJv6BhqJA==", "integrity": "sha512-uJjMTkN1KaOIgNtUPMtIXDOjx6dGYysdIFhgA52x4xSadQCz3b/zJexvITDVpANnfKPW/+E0xkOvLntqMYpviA==",
"requires": { "requires": {
"@octokit/types": "^5.1.1", "@octokit/types": "^6.34.0",
"deprecation": "^2.3.1" "deprecation": "^2.3.1"
} }
}, },
"@octokit/request": { "@octokit/request": {
"version": "5.4.7", "version": "5.6.3",
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.7.tgz", "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.3.tgz",
"integrity": "sha512-FN22xUDP0i0uF38YMbOfx6TotpcENP5W8yJM1e/LieGXn6IoRxDMnBf7tx5RKSW4xuUZ/1P04NFZy5iY3Rax1A==", "integrity": "sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==",
"requires": { "requires": {
"@octokit/endpoint": "^6.0.1", "@octokit/endpoint": "^6.0.1",
"@octokit/request-error": "^2.0.0", "@octokit/request-error": "^2.1.0",
"@octokit/types": "^5.0.0", "@octokit/types": "^6.16.1",
"deprecation": "^2.0.0", "is-plain-object": "^5.0.0",
"is-plain-object": "^4.0.0", "node-fetch": "^2.6.7",
"node-fetch": "^2.3.0",
"once": "^1.4.0",
"universal-user-agent": "^6.0.0" "universal-user-agent": "^6.0.0"
} }
}, },
"@octokit/request-error": { "@octokit/request-error": {
"version": "2.0.2", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.0.2.tgz", "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz",
"integrity": "sha512-2BrmnvVSV1MXQvEkrb9zwzP0wXFNbPJij922kYBTLIlIafukrGOb+ABBT2+c6wZiuyWDH1K1zmjGQ0toN/wMWw==", "integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==",
"requires": { "requires": {
"@octokit/types": "^5.0.1", "@octokit/types": "^6.0.3",
"deprecation": "^2.0.0", "deprecation": "^2.0.0",
"once": "^1.4.0" "once": "^1.4.0"
} }
}, },
"@octokit/types": { "@octokit/types": {
"version": "5.1.2", "version": "6.34.0",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-5.1.2.tgz", "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.34.0.tgz",
"integrity": "sha512-+zuMnja97vuZmWa+HdUY+0KB9MLwcEHueSSyKu0G/HqZaFYCVdLpBkavb0xyDlH7eoBdvAvSX/+Y8+4FOEZkrQ==", "integrity": "sha512-s1zLBjWhdEI2zwaoSgyOFoKSl109CUcVBCc7biPJ3aAf6LGLU6szDvi31JPU7bxfla2lqfhjbbg/5DdFNxOwHw==",
"requires": { "requires": {
"@types/node": ">= 8" "@octokit/openapi-types": "^11.2.0"
} }
}, },
"@sinonjs/commons": { "@sinonjs/commons": {
@ -1616,7 +1620,8 @@
"@types/node": { "@types/node": {
"version": "15.0.2", "version": "15.0.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.0.2.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-15.0.2.tgz",
"integrity": "sha512-p68+a+KoxpoB47015IeYZYRrdqMUcpbK8re/zpFB8Ld46LHC1lPEbp3EXgkEhAYEcPvjJF6ZO+869SQ0aH1dcA==" "integrity": "sha512-p68+a+KoxpoB47015IeYZYRrdqMUcpbK8re/zpFB8Ld46LHC1lPEbp3EXgkEhAYEcPvjJF6ZO+869SQ0aH1dcA==",
"dev": true
}, },
"@types/normalize-package-data": { "@types/normalize-package-data": {
"version": "2.4.1", "version": "2.4.1",
@ -2273,9 +2278,9 @@
"dev": true "dev": true
}, },
"before-after-hook": { "before-after-hook": {
"version": "2.1.0", "version": "2.2.2",
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.1.0.tgz", "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.2.tgz",
"integrity": "sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A==" "integrity": "sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ=="
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
@ -4593,9 +4598,9 @@
"dev": true "dev": true
}, },
"is-plain-object": { "is-plain-object": {
"version": "4.1.1", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-4.1.1.tgz", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
"integrity": "sha512-5Aw8LLVsDlZsETVMhoMXzqsXwQqr/0vlnBYzIXJbYo2F4yYlhLHs+Ez7Bod7IIQKWkJbJfxrWD7pA1Dw1TKrwA==" "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q=="
}, },
"is-potential-custom-element-name": { "is-potential-custom-element-name": {
"version": "1.0.1", "version": "1.0.1",
@ -7508,9 +7513,33 @@
"dev": true "dev": true
}, },
"node-fetch": { "node-fetch": {
"version": "2.6.1", "version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"requires": {
"whatwg-url": "^5.0.0"
},
"dependencies": {
"tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
},
"webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
},
"whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
"requires": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
}
}
}, },
"node-int64": { "node-int64": {
"version": "0.4.0", "version": "0.4.0",

View File

@ -39,7 +39,7 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/github": "^4.0.0", "@actions/github": "^5.0.1",
"lodash.deburr": "^4.1.0", "lodash.deburr": "^4.1.0",
"semver": "^7.3.5" "semver": "^7.3.5"
}, },

View File

@ -1,7 +1,7 @@
import {isLabeled} from '../functions/is-labeled'; import {isLabeled} from '../functions/is-labeled';
import {isPullRequest} from '../functions/is-pull-request'; import {isPullRequest} from '../functions/is-pull-request';
import {Assignee} from '../interfaces/assignee'; import {Assignee} from '../interfaces/assignee';
import {IIssue} from '../interfaces/issue'; import {IIssue, OctokitIssue} from '../interfaces/issue';
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options'; import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
import {ILabel} from '../interfaces/label'; import {ILabel} from '../interfaces/label';
import {IMilestone} from '../interfaces/milestone'; import {IMilestone} from '../interfaces/milestone';
@ -17,7 +17,7 @@ export class Issue implements IIssue {
readonly pull_request: Object | null | undefined; readonly pull_request: Object | null | undefined;
readonly state: string | 'closed' | 'open'; readonly state: string | 'closed' | 'open';
readonly locked: boolean; readonly locked: boolean;
readonly milestone: IMilestone | undefined; readonly milestone?: IMilestone | null;
readonly assignees: Assignee[]; readonly assignees: Assignee[];
isStale: boolean; isStale: boolean;
operations = new Operations(); operations = new Operations();
@ -25,19 +25,19 @@ export class Issue implements IIssue {
constructor( constructor(
options: Readonly<IIssuesProcessorOptions>, options: Readonly<IIssuesProcessorOptions>,
issue: Readonly<IIssue> issue: Readonly<OctokitIssue> | Readonly<IIssue>
) { ) {
this._options = options; this._options = options;
this.title = issue.title; this.title = issue.title;
this.number = issue.number; this.number = issue.number;
this.created_at = issue.created_at; this.created_at = issue.created_at;
this.updated_at = issue.updated_at; this.updated_at = issue.updated_at;
this.labels = issue.labels; this.labels = mapLabels(issue.labels);
this.pull_request = issue.pull_request; this.pull_request = issue.pull_request;
this.state = issue.state; this.state = issue.state;
this.locked = issue.locked; this.locked = issue.locked;
this.milestone = issue.milestone; this.milestone = issue.milestone;
this.assignees = issue.assignees; this.assignees = issue.assignees || [];
this.isStale = isLabeled(this, this.staleLabel); this.isStale = isLabeled(this, this.staleLabel);
} }
@ -59,3 +59,14 @@ export class Issue implements IIssue {
: this._options.staleIssueLabel; : this._options.staleIssueLabel;
} }
} }
function mapLabels(labels: (string | ILabel)[] | ILabel[]): ILabel[] {
return labels.map(label => {
if (typeof label == 'string') {
return {
name: label
};
}
return label;
});
}

View File

@ -1,7 +1,6 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import {context, getOctokit} from '@actions/github'; import {context, getOctokit} from '@actions/github';
import {GitHub} from '@actions/github/lib/utils'; import {GitHub} from '@actions/github/lib/utils';
import {GetResponseTypeFromEndpointMethod} from '@octokit/types';
import {Option} from '../enums/option'; import {Option} from '../enums/option';
import {getHumanizedDate} from '../functions/dates/get-humanized-date'; import {getHumanizedDate} from '../functions/dates/get-humanized-date';
import {isDateMoreRecentThan} from '../functions/dates/is-date-more-recent-than'; import {isDateMoreRecentThan} from '../functions/dates/is-date-more-recent-than';
@ -25,7 +24,7 @@ import {Milestones} from './milestones';
import {StaleOperations} from './stale-operations'; import {StaleOperations} from './stale-operations';
import {Statistics} from './statistics'; import {Statistics} from './statistics';
import {LoggerService} from '../services/logger.service'; import {LoggerService} from '../services/logger.service';
import {IIssue} from '../interfaces/issue'; import {OctokitIssue} from '../interfaces/issue';
/*** /***
* Handle processing of issues for staleness/closure. * Handle processing of issues for staleness/closure.
@ -517,7 +516,7 @@ export class IssuesProcessor {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this.statistics?.incrementFetchedItemsCommentsCount(); this.statistics?.incrementFetchedItemsCommentsCount();
const comments = await this.client.issues.listComments({ const comments = await this.client.rest.issues.listComments({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: issue.number, issue_number: issue.number,
@ -532,14 +531,9 @@ export class IssuesProcessor {
// grab issues from github in batches of 100 // grab issues from github in batches of 100
async getIssues(page: number): Promise<Issue[]> { async getIssues(page: number): Promise<Issue[]> {
// generate type for response
const endpoint = this.client.issues.listForRepo;
type OctoKitIssueList = GetResponseTypeFromEndpointMethod<typeof endpoint>;
try { try {
this.operations.consumeOperation(); this.operations.consumeOperation();
const issueResult: OctoKitIssueList = const issueResult = await this.client.rest.issues.listForRepo({
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',
@ -550,7 +544,7 @@ export class IssuesProcessor {
this.statistics?.incrementFetchedItemsCount(issueResult.data.length); this.statistics?.incrementFetchedItemsCount(issueResult.data.length);
return issueResult.data.map( return issueResult.data.map(
(issue: Readonly<IIssue>): Issue => new Issue(this.options, issue) (issue: Readonly<OctokitIssue>): Issue => new Issue(this.options, issue)
); );
} catch (error) { } catch (error) {
this._logger.error(`Get issues for repo error: ${error.message}`); this._logger.error(`Get issues for repo error: ${error.message}`);
@ -570,7 +564,7 @@ export class IssuesProcessor {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this.statistics?.incrementFetchedItemsEventsCount(); this.statistics?.incrementFetchedItemsEventsCount();
const options = this.client.issues.listEvents.endpoint.merge({ const options = this.client.rest.issues.listEvents.endpoint.merge({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
per_page: 100, per_page: 100,
@ -601,7 +595,7 @@ export class IssuesProcessor {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this.statistics?.incrementFetchedPullRequestsCount(); this.statistics?.incrementFetchedPullRequestsCount();
const pullRequest = await this.client.pulls.get({ const pullRequest = await this.client.rest.pulls.get({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
pull_number: issue.number pull_number: issue.number
@ -738,8 +732,8 @@ export class IssuesProcessor {
const filteredComments = comments.filter( const filteredComments = comments.filter(
comment => comment =>
comment.user.type === 'User' && comment.user?.type === 'User' &&
comment.body.toLowerCase() !== staleMessage.toLowerCase() comment.body?.toLowerCase() !== staleMessage.toLowerCase()
); );
issueLogger.info( issueLogger.info(
@ -775,7 +769,7 @@ export class IssuesProcessor {
this.statistics?.incrementAddedItemsComment(issue); this.statistics?.incrementAddedItemsComment(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.createComment({ await this.client.rest.issues.createComment({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: issue.number, issue_number: issue.number,
@ -793,7 +787,7 @@ export class IssuesProcessor {
this.statistics?.incrementStaleItemsCount(issue); this.statistics?.incrementStaleItemsCount(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.addLabels({ await this.client.rest.issues.addLabels({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: issue.number, issue_number: issue.number,
@ -823,7 +817,7 @@ export class IssuesProcessor {
this.addedCloseCommentIssues.push(issue); this.addedCloseCommentIssues.push(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.createComment({ await this.client.rest.issues.createComment({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: issue.number, issue_number: issue.number,
@ -841,7 +835,7 @@ export class IssuesProcessor {
this.statistics?.incrementAddedItemsLabel(issue); this.statistics?.incrementAddedItemsLabel(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.addLabels({ await this.client.rest.issues.addLabels({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: issue.number, issue_number: issue.number,
@ -858,7 +852,7 @@ export class IssuesProcessor {
this.statistics?.incrementClosedItemsCount(issue); this.statistics?.incrementClosedItemsCount(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.update({ await this.client.rest.issues.update({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: issue.number, issue_number: issue.number,
@ -900,7 +894,7 @@ export class IssuesProcessor {
this.statistics?.incrementDeletedBranchesCount(); this.statistics?.incrementDeletedBranchesCount();
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.git.deleteRef({ await this.client.rest.git.deleteRef({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
ref: `heads/${branch}` ref: `heads/${branch}`
@ -935,7 +929,7 @@ export class IssuesProcessor {
this.statistics?.incrementDeletedItemsLabelsCount(issue); this.statistics?.incrementDeletedItemsLabelsCount(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.removeLabel({ await this.client.rest.issues.removeLabel({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: issue.number, issue_number: issue.number,
@ -1068,7 +1062,7 @@ export class IssuesProcessor {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this.statistics?.incrementAddedItemsLabel(issue); this.statistics?.incrementAddedItemsLabel(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.addLabels({ await this.client.rest.issues.addLabels({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: issue.number, issue_number: issue.number,

View File

@ -9,6 +9,6 @@ import {CleanLabel} from '../types/clean-label';
* *
* @return {string} A lowercased, deburred version of the passed in label * @return {string} A lowercased, deburred version of the passed in label
*/ */
export function cleanLabel(label: Readonly<string>): CleanLabel { export function cleanLabel(label?: Readonly<string>): CleanLabel {
return deburr(label.toLowerCase()); return deburr(label?.toLowerCase());
} }

View File

@ -1,6 +1,6 @@
import {IUser} from './user'; import {IUser} from './user';
export interface IComment { export interface IComment {
user: IUser; user: IUser | null;
body: string; body?: string;
} }

View File

@ -2,16 +2,18 @@ import {IsoDateString} from '../types/iso-date-string';
import {Assignee} from './assignee'; import {Assignee} from './assignee';
import {ILabel} from './label'; import {ILabel} from './label';
import {IMilestone} from './milestone'; import {IMilestone} from './milestone';
import {components} from '@octokit/openapi-types';
export interface IIssue { export interface IIssue {
title: string; title: string;
number: number; number: number;
created_at: IsoDateString; created_at: IsoDateString;
updated_at: IsoDateString; updated_at: IsoDateString;
labels: ILabel[]; labels: ILabel[];
pull_request: Object | null | undefined; pull_request?: Object | null;
state: string; state: string;
locked: boolean; locked: boolean;
milestone: IMilestone | undefined; milestone?: IMilestone | null;
assignees: Assignee[]; assignees?: Assignee[] | null;
} }
export type OctokitIssue = components['schemas']['issue'];

View File

@ -1,3 +1,3 @@
export interface ILabel { export interface ILabel {
name: string; name?: string;
} }

View File

@ -3,5 +3,5 @@ export interface IPullRequest {
head: { head: {
ref: string; ref: string;
}; };
draft: boolean; draft?: boolean;
} }