github-repository-provider 7.23.44 → 7.24.1
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/package.json +3 -3
- package/src/github-branch.mjs +12 -7
- package/src/github-provider.mjs +37 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-repository-provider",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.24.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"lint:docs": "documentation lint ./src/**/*.mjs"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"content-entry": "^3.0.
|
|
33
|
+
"content-entry": "^3.0.1",
|
|
34
34
|
"fetch-link-util": "^1.0.4",
|
|
35
35
|
"fetch-rate-limit-util": "^1.1.6",
|
|
36
36
|
"matching-iterator": "^2.0.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"ava": "^3.15.0",
|
|
43
43
|
"c8": "^7.10.0",
|
|
44
44
|
"documentation": "^13.2.5",
|
|
45
|
-
"repository-provider-test-support": "^1.8.
|
|
45
|
+
"repository-provider-test-support": "^1.8.12",
|
|
46
46
|
"semantic-release": "^18.0.1"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
package/src/github-branch.mjs
CHANGED
|
@@ -154,17 +154,22 @@ export class GithubBranch extends Branch {
|
|
|
154
154
|
const url = `repos/${this.slug}/git/trees/${treeSha}?recursive=1`;
|
|
155
155
|
|
|
156
156
|
let res;
|
|
157
|
-
for (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
for (let i = 0; i < 3; i++) {
|
|
158
|
+
try {
|
|
159
|
+
res = await this.provider.fetch(url);
|
|
160
|
+
if (res.ok) {
|
|
161
|
+
const json = await res.json();
|
|
162
|
+
return json.tree;
|
|
163
|
+
}
|
|
164
|
+
} catch (e) {
|
|
165
|
+
// errno: 'ERR_STREAM_PREMATURE_CLOSE',
|
|
166
|
+
// code: 'ERR_STREAM_PREMATURE_CLOSE',
|
|
167
|
+
|
|
168
|
+
this.error(e);
|
|
162
169
|
}
|
|
163
170
|
}
|
|
164
171
|
|
|
165
172
|
console.log(res.errno, res.code);
|
|
166
|
-
// errno: 'ERR_STREAM_PREMATURE_CLOSE',
|
|
167
|
-
// code: 'ERR_STREAM_PREMATURE_CLOSE',
|
|
168
173
|
|
|
169
174
|
throw new Error(res.status);
|
|
170
175
|
}
|
package/src/github-provider.mjs
CHANGED
|
@@ -42,7 +42,7 @@ export class GithubProvider extends MultiGroupProvider {
|
|
|
42
42
|
* @return {string} default instance environment name prefix
|
|
43
43
|
*/
|
|
44
44
|
static get instanceIdentifier() {
|
|
45
|
-
return "GITHUB_"
|
|
45
|
+
return "GITHUB_";
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
static get attributes() {
|
|
@@ -116,34 +116,51 @@ export class GithubProvider extends MultiGroupProvider {
|
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
async fetchJSON(url, options) {
|
|
120
|
+
for (let i = 0; i < 3; i++) {
|
|
121
|
+
try {
|
|
122
|
+
const response = await this.fetch(url, options);
|
|
123
|
+
if (!response.ok) {
|
|
124
|
+
this.error(`Unable to fetch ${response.status} ${response.url}`);
|
|
125
|
+
throw new Error(`Unable to fetch ${response.status} ${response.url}`);
|
|
126
|
+
}
|
|
127
|
+
return await response.json();
|
|
128
|
+
} catch (e) {
|
|
129
|
+
this.error(e);
|
|
130
|
+
throw e;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
119
135
|
/**
|
|
120
136
|
* {@link https://developer.github.com/v3/repos/#list-repositories-for-the-authenticated-user}
|
|
121
137
|
*/
|
|
122
138
|
async initializeRepositories() {
|
|
123
139
|
for (let page = 1; ; page++) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
140
|
+
try {
|
|
141
|
+
const json = await this.fetchJSON(
|
|
142
|
+
`user/repos?page=${page}&per_page=100`,
|
|
143
|
+
{
|
|
144
|
+
headers: {
|
|
145
|
+
accept: "application/vnd.github.baptiste-preview+json"
|
|
146
|
+
// accept: "application/vnd.github.v3+json"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
if (json.length === 0 || !Array.isArray(json)) {
|
|
151
|
+
break;
|
|
127
152
|
}
|
|
128
|
-
});
|
|
129
153
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
154
|
+
json.forEach(r => {
|
|
155
|
+
const [groupName, repoName] = r.full_name.split(/\//);
|
|
156
|
+
this.addRepositoryGroup(groupName, r.owner).addRepository(
|
|
157
|
+
repoName,
|
|
158
|
+
r
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
} catch (e) {
|
|
134
162
|
return;
|
|
135
163
|
}
|
|
136
|
-
|
|
137
|
-
const json = await response.json();
|
|
138
|
-
|
|
139
|
-
if (json.length === 0 || !Array.isArray(json)) {
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
json.forEach(r => {
|
|
144
|
-
const [groupName, repoName] = r.full_name.split(/\//);
|
|
145
|
-
this.addRepositoryGroup(groupName, r.owner).addRepository(repoName, r);
|
|
146
|
-
});
|
|
147
164
|
}
|
|
148
165
|
}
|
|
149
166
|
|