Skip to content

Commit 73f3f94

Browse files
devversionjelbourn
authored andcommitted
build: remove deprecated node-github api (#12420)
Switches to the newer version of `node-github` that has been renamed to `@octokit/rest`.
1 parent f5f7f1c commit 73f3f94

File tree

3 files changed

+64
-59
lines changed

3 files changed

+64
-59
lines changed

package-lock.json

Lines changed: 51 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"@angular/upgrade": "6.0.0",
5454
"@bazel/ibazel": "0.3.1",
5555
"@google-cloud/storage": "^1.1.1",
56+
"@octokit/rest": "^15.9.4",
5657
"@schematics/angular": "^0.7.1",
5758
"@types/chalk": "^0.4.31",
5859
"@types/fs-extra": "^4.0.3",
@@ -75,7 +76,6 @@
7576
"firebase-tools": "^3.11.0",
7677
"fs-extra": "^3.0.1",
7778
"git-semver-tags": "^2.0.0",
78-
"github": "^12.0.3",
7979
"glob": "^7.1.2",
8080
"google-closure-compiler": "20170409.0.0",
8181
"gulp": "^3.9.1",

scripts/caretaking/write-presumbit-scheduler.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const path = require('path');
44
const fs = require('fs');
5-
const GitHubApi = require('github');
5+
const GitHubApi = require('@octokit/rest');
66
const github = new GitHubApi();
77

88

@@ -30,6 +30,14 @@ const intervalMinutes = 10;
3030
/** Instead of querying github for PR numbers, manually provide the PR numbers to be presubmit */
3131
const explicitPullRequests = [];
3232

33+
/** Options that will be passed to the octokit Github API when querying Github for PR numbers. */
34+
const githubSearchOptions = {
35+
// Use the maximum of allowed items per Github API query. 100 pull requests should be
36+
// enough to continuously run presubmits through night.
37+
per_page: 100,
38+
q: 'repo:angular/material2 is:open type:pr label:"pr: merge ready" -label:"pr: merge safe"',
39+
};
40+
3341
/** END OF CONFIGURATION. */
3442

3543

@@ -41,17 +49,9 @@ if (explicitPullRequests.length) {
4149
writeScheduleScript(explicitPullRequests.map(n => ({number: n})));
4250
} else {
4351
// Fetch PRs that are merge-ready but not merge-safe
44-
github.search.issues({
45-
per_page: 100,
46-
q: 'repo:angular/material2 is:open type:pr label:"pr: merge ready" -label:"pr: merge safe"',
47-
}, (error, response) => {
48-
if (response) {
49-
writeScheduleScript(response.data.items);
50-
} else {
51-
console.error('Fetching merge-ready PRs failed.');
52-
console.error(error);
53-
}
54-
});
52+
github.search.issues(githubSearchOptions)
53+
.then(response => writeScheduleScript(response.data.items))
54+
.catch(error => console.error('Fetching merge-ready PRs failed.', error));
5555
}
5656

5757

0 commit comments

Comments
 (0)