Skip to content

Commit a5061ef

Browse files
authored
Update scripts for octokit 17 (microsoft#36915)
* Update scripts for octokit 17 Also put playwright in alphabetical order, npm seems to like that. * back to passing auth in the ctor I GUESS
1 parent 24dd93f commit a5061ef

6 files changed

+24
-35
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"mocha-fivemat-progress-reporter": "latest",
8888
"ms": "latest",
8989
"node-fetch": "^2.6.0",
90+
"playwright": "latest",
9091
"plugin-error": "latest",
9192
"pretty-hrtime": "^1.0.3",
9293
"prex": "^0.4.3",
@@ -96,7 +97,6 @@
9697
"through2": "latest",
9798
"travis-fold": "latest",
9899
"typescript": "next",
99-
"playwright": "latest",
100100
"vinyl": "latest",
101101
"vinyl-sourcemaps-apply": "latest",
102102
"xml2js": "^0.4.19"

Diff for: scripts/open-cherry-pick-pr.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ async function main() {
2727
["git", ["log", "-1", `--pretty="%aN <%aE>"`]]
2828
]);
2929

30-
const gh = new Octokit();
31-
gh.authenticate({
32-
type: "token",
33-
token: process.argv[2]
30+
const gh = new Octokit({
31+
auth: process.argv[2]
3432
});
3533

3634
const inputPR = (await gh.pulls.get({ pull_number: +process.env.SOURCE_ISSUE, owner: "microsoft", repo: "TypeScript" })).data;
@@ -101,7 +99,7 @@ cc ${reviewers.map(r => "@" + r).join(" ")}`,
10199
console.log(`Pull request ${num} created.`);
102100

103101
await gh.issues.createComment({
104-
number: +process.env.SOURCE_ISSUE,
102+
issue_number: +process.env.SOURCE_ISSUE,
105103
owner: "Microsoft",
106104
repo: "TypeScript",
107105
body: `Hey @${process.env.REQUESTING_USER}, I've opened #${num} for you.`
@@ -112,13 +110,11 @@ main().catch(async e => {
112110
console.error(e);
113111
process.exitCode = 1;
114112
if (process.env.SOURCE_ISSUE) {
115-
const gh = new Octokit();
116-
gh.authenticate({
117-
type: "token",
118-
token: process.argv[2]
113+
const gh = new Octokit({
114+
auth: process.argv[2]
119115
});
120116
await gh.issues.createComment({
121-
number: +process.env.SOURCE_ISSUE,
117+
issue_number: +process.env.SOURCE_ISSUE,
122118
owner: "Microsoft",
123119
repo: "TypeScript",
124120
body: `Hey @${process.env.REQUESTING_USER}, I couldn't open a PR with the cherry-pick. ([You can check the log here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${process.env.BUILD_BUILDID}&_a=summary)). You may need to squash and pick this PR into ${process.env.TARGET_BRANCH} manually.`

Diff for: scripts/open-user-pr.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference lib="esnext.asynciterable" />
22
/// <reference lib="es2015.promise" />
33
// Must reference esnext.asynciterable lib, since octokit uses AsyncIterable internally
4-
import Octokit = require("@octokit/rest");
4+
import { Octokit } from "@octokit/rest";
55
import {runSequence} from "./run-sequence";
66

77
function padNum(num: number) {
@@ -24,10 +24,8 @@ runSequence([
2424
["git", ["push", "--set-upstream", "fork", branchName, "-f"]] // push the branch
2525
]);
2626

27-
const gh = new Octokit();
28-
gh.authenticate({
29-
type: "token",
30-
token: process.argv[2]
27+
const gh = new Octokit({
28+
auth: process.argv[2]
3129
});
3230
gh.pulls.create({
3331
owner: process.env.TARGET_FORK!,
@@ -54,7 +52,7 @@ cc ${reviewers.map(r => "@" + r).join(" ")}`,
5452
}
5553
else {
5654
await gh.issues.createComment({
57-
number: +process.env.SOURCE_ISSUE,
55+
issue_number: +process.env.SOURCE_ISSUE,
5856
owner: "Microsoft",
5957
repo: "TypeScript",
6058
body: `The user suite test run you requested has finished and _failed_. I've opened a [PR with the baseline diff from master](${r.data.html_url}).`

Diff for: scripts/perf-result-post.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22
/// <reference lib="esnext.asynciterable" />
33
// Must reference esnext.asynciterable lib, since octokit uses AsyncIterable internally
4-
const Octokit = require("@octokit/rest");
4+
const { Octokit } = require("@octokit/rest");
55
const fs = require("fs");
66

77
const requester = process.env.requesting_user;
@@ -12,13 +12,11 @@ const outputTableText = fs.readFileSync(process.argv[3], { encoding: "utf8" });
1212
console.log(`Fragment contents:
1313
${outputTableText}`);
1414

15-
const gh = new Octokit();
16-
gh.authenticate({
17-
type: "token",
18-
token: process.argv[2]
15+
const gh = new Octokit({
16+
auth: process.argv[2]
1917
});
2018
gh.issues.createComment({
21-
number: +source,
19+
issue_number: +source,
2220
owner: "Microsoft",
2321
repo: "TypeScript",
2422
body: `@${requester}

Diff for: scripts/post-vsts-artifact-comment.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22
/// <reference lib="esnext.asynciterable" />
33
// Must reference esnext.asynciterable lib, since octokit uses AsyncIterable internally
4-
const Octokit = require("@octokit/rest");
4+
const { Octokit } = require("@octokit/rest");
55
const ado = require("azure-devops-node-api");
66
const { default: fetch } = require("node-fetch");
77

@@ -23,10 +23,8 @@ async function main() {
2323
const tgzUrl = new URL(artifact.resource.url);
2424
tgzUrl.search = `artifactName=tgz&fileId=${file.blob.id}&fileName=${file.path}`;
2525
const link = "" + tgzUrl;
26-
const gh = new Octokit();
27-
gh.authenticate({
28-
type: "token",
29-
token: process.argv[2]
26+
const gh = new Octokit({
27+
auth: process.argv[2]
3028
});
3129

3230
// Please keep the strings "an installable tgz" and "packed" in this message, as well as the devDependencies section,
@@ -57,13 +55,11 @@ main().catch(async e => {
5755
console.error(e);
5856
process.exitCode = 1;
5957
if (process.env.SOURCE_ISSUE) {
60-
const gh = new Octokit();
61-
gh.authenticate({
62-
type: "token",
63-
token: process.argv[2]
58+
const gh = new Octokit({
59+
auth: process.argv[2]
6460
});
6561
await gh.issues.createComment({
66-
number: +process.env.SOURCE_ISSUE,
62+
issue_number: +process.env.SOURCE_ISSUE,
6763
owner: "Microsoft",
6864
repo: "TypeScript",
6965
body: `Hey @${process.env.REQUESTING_USER}, something went wrong when looking for the build artifact. ([You can check the log here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${process.env.BUILD_BUILDID}&_a=summary)).`

Diff for: scripts/update-experimental-branches.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22
/// <reference lib="esnext.asynciterable" />
3-
const Octokit = require("@octokit/rest");
3+
const { Octokit } = require("@octokit/rest");
44
const { runSequence } = require("./run-sequence");
55

66
// The first is used by bot-based kickoffs, the second by automatic triggers
@@ -76,7 +76,8 @@ async function main() {
7676
]);
7777

7878
// Merge each branch into `experimental` (which, if there is a conflict, we now know is from inter-experiment conflict)
79-
for (const branch of prnums) {
79+
for (const branchnum of prnums) {
80+
const branch = "" + branchnum;
8081
// Find the merge base
8182
const mergeBase = runSequence([
8283
["git", ["merge-base", branch, "experimental"]],

0 commit comments

Comments
 (0)