@ffflorian/gh-open 3.10.0 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/GitHubClient.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ export interface PullRequest {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
export declare class GitHubClient {
|
|
12
|
-
private readonly
|
|
12
|
+
private readonly baseURL;
|
|
13
|
+
private readonly timeout;
|
|
13
14
|
constructor(timeout?: number);
|
|
14
15
|
getPullRequestByBranch(user: string, repository: string, branch: string): Promise<PullRequest | undefined>;
|
|
15
16
|
/**
|
package/dist/GitHubClient.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
1
|
const TWO_SECONDS_IN_MILLIS = 2000;
|
|
3
2
|
export class GitHubClient {
|
|
4
3
|
constructor(timeout = TWO_SECONDS_IN_MILLIS) {
|
|
5
|
-
this.
|
|
4
|
+
this.baseURL = 'https://api.github.com';
|
|
5
|
+
this.timeout = timeout;
|
|
6
6
|
}
|
|
7
7
|
async getPullRequestByBranch(user, repository, branch) {
|
|
8
8
|
const pullRequests = await this.getPullRequests(user, repository);
|
|
@@ -12,12 +12,12 @@ export class GitHubClient {
|
|
|
12
12
|
* @see https://developer.github.com/v3/pulls/#list-pull-requests
|
|
13
13
|
*/
|
|
14
14
|
async getPullRequests(user, repository) {
|
|
15
|
-
const resourceUrl = `repos/${user}/${repository}/pulls
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return response.
|
|
15
|
+
const resourceUrl = new URL(`repos/${user}/${repository}/pulls`, this.baseURL);
|
|
16
|
+
resourceUrl.search = new URLSearchParams({ per_page: '100', state: 'open' }).toString();
|
|
17
|
+
const response = await fetch(resourceUrl, { signal: AbortSignal.timeout(this.timeout) });
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new Error(`Error while fetching pull requests: ${response.statusText}`);
|
|
20
|
+
}
|
|
21
|
+
return response.json();
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -18,7 +18,7 @@ describe('GitHubClient', () => {
|
|
|
18
18
|
assert.fail('Should not have resolved');
|
|
19
19
|
}
|
|
20
20
|
catch (error) {
|
|
21
|
-
expect(error.message).toBe('
|
|
21
|
+
expect(error.message).toBe('The operation was aborted due to timeout');
|
|
22
22
|
}
|
|
23
23
|
finally {
|
|
24
24
|
nock.cleanAll();
|
package/package.json
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
"author": "Florian Imdahl <git@ffflorian.de>",
|
|
3
3
|
"bin": "dist/cli.js",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"axios": "1.13.2",
|
|
6
5
|
"commander": "14.0.2",
|
|
7
6
|
"find-up": "8.0.0",
|
|
8
7
|
"logdown": "3.3.1",
|
|
@@ -43,6 +42,6 @@
|
|
|
43
42
|
"test": "vitest run"
|
|
44
43
|
},
|
|
45
44
|
"type": "module",
|
|
46
|
-
"version": "3.
|
|
47
|
-
"gitHead": "
|
|
45
|
+
"version": "3.11.0",
|
|
46
|
+
"gitHead": "558b5c962cd6ad6e42e7c4917294cfddd2e60599"
|
|
48
47
|
}
|