Skip to content

Update scripts for octokit 17 #36915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"mocha-fivemat-progress-reporter": "latest",
"ms": "latest",
"node-fetch": "^2.6.0",
"playwright": "latest",
"plugin-error": "latest",
"pretty-hrtime": "^1.0.3",
"prex": "^0.4.3",
Expand All @@ -96,7 +97,6 @@
"through2": "latest",
"travis-fold": "latest",
"typescript": "next",
"playwright": "latest",
"vinyl": "latest",
"vinyl-sourcemaps-apply": "latest",
"xml2js": "^0.4.19"
Expand Down
16 changes: 6 additions & 10 deletions scripts/open-cherry-pick-pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ async function main() {
["git", ["log", "-1", `--pretty="%aN <%aE>"`]]
]);

const gh = new Octokit();
gh.authenticate({
type: "token",
token: process.argv[2]
const gh = new Octokit({
auth: process.argv[2]
});

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

await gh.issues.createComment({
number: +process.env.SOURCE_ISSUE,
issue_number: +process.env.SOURCE_ISSUE,
owner: "Microsoft",
repo: "TypeScript",
body: `Hey @${process.env.REQUESTING_USER}, I've opened #${num} for you.`
Expand All @@ -112,13 +110,11 @@ main().catch(async e => {
console.error(e);
process.exitCode = 1;
if (process.env.SOURCE_ISSUE) {
const gh = new Octokit();
gh.authenticate({
type: "token",
token: process.argv[2]
const gh = new Octokit({
auth: process.argv[2]
});
await gh.issues.createComment({
number: +process.env.SOURCE_ISSUE,
issue_number: +process.env.SOURCE_ISSUE,
owner: "Microsoft",
repo: "TypeScript",
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.`
Expand Down
10 changes: 4 additions & 6 deletions scripts/open-user-pr.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference lib="esnext.asynciterable" />
/// <reference lib="es2015.promise" />
// Must reference esnext.asynciterable lib, since octokit uses AsyncIterable internally
import Octokit = require("@octokit/rest");
import { Octokit } from "@octokit/rest";
import {runSequence} from "./run-sequence";

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

const gh = new Octokit();
gh.authenticate({
type: "token",
token: process.argv[2]
const gh = new Octokit({
auth: process.argv[2]
});
gh.pulls.create({
owner: process.env.TARGET_FORK!,
Expand All @@ -54,7 +52,7 @@ cc ${reviewers.map(r => "@" + r).join(" ")}`,
}
else {
await gh.issues.createComment({
number: +process.env.SOURCE_ISSUE,
issue_number: +process.env.SOURCE_ISSUE,
owner: "Microsoft",
repo: "TypeScript",
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}).`
Expand Down
10 changes: 4 additions & 6 deletions scripts/perf-result-post.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
/// <reference lib="esnext.asynciterable" />
// Must reference esnext.asynciterable lib, since octokit uses AsyncIterable internally
const Octokit = require("@octokit/rest");
const { Octokit } = require("@octokit/rest");
const fs = require("fs");

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

const gh = new Octokit();
gh.authenticate({
type: "token",
token: process.argv[2]
const gh = new Octokit({
auth: process.argv[2]
});
gh.issues.createComment({
number: +source,
issue_number: +source,
owner: "Microsoft",
repo: "TypeScript",
body: `@${requester}
Expand Down
16 changes: 6 additions & 10 deletions scripts/post-vsts-artifact-comment.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
/// <reference lib="esnext.asynciterable" />
// Must reference esnext.asynciterable lib, since octokit uses AsyncIterable internally
const Octokit = require("@octokit/rest");
const { Octokit } = require("@octokit/rest");
const ado = require("azure-devops-node-api");
const { default: fetch } = require("node-fetch");

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

// Please keep the strings "an installable tgz" and "packed" in this message, as well as the devDependencies section,
Expand Down Expand Up @@ -57,13 +55,11 @@ main().catch(async e => {
console.error(e);
process.exitCode = 1;
if (process.env.SOURCE_ISSUE) {
const gh = new Octokit();
gh.authenticate({
type: "token",
token: process.argv[2]
const gh = new Octokit({
auth: process.argv[2]
});
await gh.issues.createComment({
number: +process.env.SOURCE_ISSUE,
issue_number: +process.env.SOURCE_ISSUE,
owner: "Microsoft",
repo: "TypeScript",
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)).`
Expand Down
5 changes: 3 additions & 2 deletions scripts/update-experimental-branches.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
/// <reference lib="esnext.asynciterable" />
const Octokit = require("@octokit/rest");
const { Octokit } = require("@octokit/rest");
const { runSequence } = require("./run-sequence");

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

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