Skip to content

Commit 7024dc4

Browse files
devversionjelbourn
authored andcommitted
chore: update dashboard functions (#9504)
* Updates the package dependencies of the Dashboard dependencies. There seem to be errors with the old `node-github` API, but updating to the latest version (`@octokit/rest`) seems to work locally.
1 parent 5d77d90 commit 7024dc4

File tree

6 files changed

+23
-86
lines changed

6 files changed

+23
-86
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export {payloadGithubStatus} from './payload-github-status';
2-
export {pullRequestsWithConflicts} from './pull-requests-with-conflicts';
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
import {GraphQLClient} from 'graphql-request';
21
import {config} from 'firebase-functions';
3-
import * as GithubApi from 'github';
2+
import * as GithubApi from '@octokit/rest';
43

54
/** API token for the Github repository. Required to set the github status on commits and PRs. */
65
const githubAccessToken = config().secret.github;
76

8-
/** API Endpoint for the Github API v4 using GraphQL. */
9-
const githubApiV4Endpoint = 'https://api.github.com/graphql';
10-
117
/** Export the GitHub V3 API instance that is authenticated. */
128
export const githubApiV3 = new GithubApi();
139

14-
/** Export the GraphQL client that can be used to query the Github API v4. */
15-
export const githubApiV4 = new GraphQLClient(githubApiV4Endpoint, {
16-
headers: {
17-
Authorization: `Bearer ${githubAccessToken}`,
18-
}
19-
});
20-
2110
// Authenticate the Github API package with the user token.
2211
githubApiV3.authenticate({type: 'token', token: githubAccessToken});

tools/dashboard/functions/github/github-graphql-queries.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "material2-board-functions",
3-
"version": "0.0.1",
3+
"version": "0.0.0",
44
"main": "index.js",
55
"dependencies": {
6-
"@types/jsonwebtoken": "^7.2.1",
7-
"firebase-admin": "~4.2.1",
8-
"firebase-functions": "^0.5.7",
9-
"github": "^10.0.0",
10-
"graphql-request": "^1.3.4",
11-
"jsonwebtoken": "^7.4.1",
12-
"request": "^2.81.0",
13-
"ts-node": "^3.0.6",
14-
"typescript": "^2.3.4"
6+
"@firebase/app-types": "^0.1.1",
7+
"@octokit/rest": "^14.0.4",
8+
"@types/jsonwebtoken": "^7.2.5",
9+
"firebase-admin": "^5.8.1",
10+
"firebase-functions": "^0.8.1",
11+
"jsonwebtoken": "^8.1.0",
12+
"request": "^2.83.0",
13+
"ts-node": "^4.1.0",
14+
"typescript": "^2.6.2"
1515
}
1616
}

tools/dashboard/functions/payload-github-status.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,18 @@ export const payloadGithubStatus = https.onRequest(async (request, response) =>
3838
const diffFormatted = Math.abs(packageDiff).toFixed(2);
3939
const packageSizeFormatted = packageSize.toFixed(2);
4040

41-
await setGithubStatus(commitSha, {
42-
result: true,
43-
name: `${capitalizeFirstLetter(packageName)} Payload Size`,
44-
description: `${packageSizeFormatted}kb / ${diffFormatted}kb ${diffMessage} (ES2015 bundle)`
45-
});
46-
47-
response.json({message: 'Payload Github status successfully set.'});
41+
try {
42+
await setGithubStatus(commitSha, {
43+
result: true,
44+
name: `${capitalizeFirstLetter(packageName)} Payload Size`,
45+
description: `${packageSizeFormatted}kb / ${diffFormatted}kb ${diffMessage} (ES2015 bundle)`
46+
});
47+
48+
response.json({message: 'Payload Github status successfully set.'});
49+
} catch (e) {
50+
response.json({message: 'An error occurred while setting the GitHub status.'});
51+
console.error('An error occurred while setting Github status.', e);
52+
}
4853
});
4954

5055
/** Capitalizes the first letter of a string. */

tools/dashboard/functions/pull-requests-with-conflicts.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)