Skip to content
This repository was archived by the owner on Apr 3, 2023. It is now read-only.

Commit 8478f88

Browse files
build(deps): bump probot from 10.9.5 to 10.18.0 (#151)
* build(deps): bump probot from 10.9.5 to 10.18.0 Bumps [probot](https://github.com/probot/probot) from 10.9.5 to 10.18.0. - [Release notes](https://github.com/probot/probot/releases) - [Commits](probot/probot@v10.9.5...v10.18.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * test: fix broken cases * test: refine deprecation Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: hi-rustin <rustin.liu@gmail.com>
1 parent 18b0f8b commit 8478f88

File tree

6 files changed

+2812
-4861
lines changed

6 files changed

+2812
-4861
lines changed

package-lock.json

Lines changed: 2782 additions & 4837 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
@@ -31,7 +31,7 @@
3131
"http-status-codes": "^2.1.4",
3232
"lodash": "^4.17.20",
3333
"mysql": "^2.18.1",
34-
"probot": "^10.9.5",
34+
"probot": "^10.18.0",
3535
"probot-commands-pro": "^1.0.1",
3636
"reflect-metadata": "^0.1.13",
3737
"typedi": "^0.8.0",

src/events/pull/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async function constructPullFormatQuery(
3232
): Promise<PullFormatQuery> {
3333
const { number } = context.payload.pull_request;
3434

35-
const { data: filesData } = await context.github.pulls.listFiles({
35+
const { data: filesData } = await context.octokit.pulls.listFiles({
3636
...context.issue(),
3737
pull_number: number,
3838
});
@@ -82,7 +82,7 @@ async function checkPullFormat(context: Context, pullService: PullService) {
8282
reply.message
8383
);
8484
// @ts-ignore
85-
await context.github.repos.createStatus({
85+
await context.octokit.repos.createStatus({
8686
...context.repo(),
8787
...status,
8888
});
@@ -96,7 +96,7 @@ async function checkPullFormat(context: Context, pullService: PullService) {
9696
reply.message
9797
);
9898
// @ts-ignore
99-
await context.github.repos.createStatus({
99+
await context.octokit.repos.createStatus({
100100
...context.repo(),
101101
...status,
102102
});
@@ -111,7 +111,7 @@ async function checkPullFormat(context: Context, pullService: PullService) {
111111
combineReplay(reply)
112112
);
113113
// @ts-ignore
114-
await context.github.repos.createStatus({
114+
await context.octokit.repos.createStatus({
115115
...context.repo(),
116116
...status,
117117
});
@@ -132,7 +132,7 @@ async function createOrUpdateComment(
132132
body: string
133133
) {
134134
// List all comment.
135-
const { data: comments } = await context.github.issues.listComments({
135+
const { data: comments } = await context.octokit.issues.listComments({
136136
...context.issue(),
137137
});
138138

@@ -141,7 +141,7 @@ async function createOrUpdateComment(
141141
});
142142

143143
if (botComment === undefined) {
144-
await context.github.issues.createComment(context.issue({ body }));
144+
await context.octokit.issues.createComment(context.issue({ body }));
145145
} else {
146146
// Update.
147147
botComment.body = body;
@@ -150,7 +150,7 @@ async function createOrUpdateComment(
150150
...botComment,
151151
comment_id: botComment.id,
152152
};
153-
await context.github.issues.updateComment(comment);
153+
await context.octokit.issues.updateComment(comment);
154154
}
155155
}
156156

@@ -167,21 +167,21 @@ async function updateSigInfo(context: Context, sigService: SigService) {
167167
switch (reply.status) {
168168
case Status.Failed: {
169169
context.log.error("Update sig info.", files);
170-
await context.github.issues.createComment(
170+
await context.octokit.issues.createComment(
171171
context.issue({ body: reply.message })
172172
);
173173
break;
174174
}
175175
case Status.Success: {
176176
context.log.info("Update sig info.", files);
177-
await context.github.issues.createComment(
177+
await context.octokit.issues.createComment(
178178
context.issue({ body: reply.message })
179179
);
180180
break;
181181
}
182182
case Status.Problematic: {
183183
context.log.warn("Update sig info has some problems.", files);
184-
await context.github.issues.createComment(
184+
await context.octokit.issues.createComment(
185185
context.issue({ body: combineReplay(reply) })
186186
);
187187
}

src/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,24 @@ import { PullMessage } from "./services/messages/PullMessage";
1010
import { getSig } from "./api/sig";
1111
import { listOwners } from "./api/pull";
1212
import { handlePullRequestEvents } from "./events/pull";
13+
import { Router } from "express";
1314

1415
const commands = require("probot-commands-pro");
1516
const bodyParser = require("body-parser");
1617
const cors = require("cors");
1718

18-
export = (app: Application) => {
19+
export = (
20+
app: Application,
21+
{
22+
getRouter,
23+
}: {
24+
getRouter: (path?: string) => Router;
25+
}
26+
) => {
1927
useContainer(Container);
2028

2129
// Get an express router to expose new HTTP endpoints.
22-
const router = app.route("/ti-community-bot");
30+
const router = getRouter("/ti-community-bot");
2331
router.use(bodyParser.json());
2432
router.use(cors());
2533

@@ -41,7 +49,7 @@ export = (app: Application) => {
4149

4250
// Ping command.
4351
commands(app, "ping", async (context: Context) => {
44-
await context.github.issues.createComment(
52+
await context.octokit.issues.createComment(
4553
context.issue({ body: "pong! I am community bot." })
4654
);
4755
});

test/api/pull/index.test.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ describe("Pull API", () => {
5656
const team_slug = "bots-test";
5757
const installationId = 2;
5858

59-
beforeEach(() => {
59+
beforeEach(async () => {
6060
// Mock the db connection.
6161
typeorm.createConnection = jest.fn().mockResolvedValue(null);
6262
nock.disableNetConnect();
6363
// Create probot.
6464
const probot = new Probot({
65-
id: 123,
65+
appId: 123,
6666
privateKey,
6767
// disable request throttling and retries for testing
6868
Octokit: ProbotOctokit.defaults({
@@ -72,13 +72,11 @@ describe("Pull API", () => {
7272
});
7373

7474
// Get github client.
75-
probot.load(async (app) => {
76-
github = await app.auth(installationId);
77-
github.config.get = jest.fn().mockReturnValue({
78-
config: {
79-
maintainerTeamSlug: team_slug,
80-
},
81-
});
75+
github = await probot.auth(installationId);
76+
github.config.get = jest.fn().mockReturnValue({
77+
config: {
78+
maintainerTeamSlug: team_slug,
79+
},
8280
});
8381
});
8482

test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("My Probot app", () => {
2525
typeorm.createConnection = jest.fn().mockResolvedValue(null);
2626
nock.disableNetConnect();
2727
probot = new Probot({
28-
id: 123,
28+
appId: 123,
2929
privateKey,
3030
// disable request throttling and retries for testing
3131
Octokit: ProbotOctokit.defaults({

0 commit comments

Comments
 (0)