github-repository-provider 7.23.45 → 7.24.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-repository-provider",
3
- "version": "7.23.45",
3
+ "version": "7.24.2",
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.0",
33
+ "content-entry": "^3.0.2",
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.11",
45
+ "repository-provider-test-support": "^1.8.13",
46
46
  "semantic-release": "^18.0.1"
47
47
  },
48
48
  "engines": {
@@ -154,7 +154,7 @@ 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 (const i = 0; i < 3; i++) {
157
+ for (let i = 0; i < 3; i++) {
158
158
  try {
159
159
  res = await this.provider.fetch(url);
160
160
  if (res.ok) {
@@ -163,9 +163,8 @@ export class GithubBranch extends Branch {
163
163
  }
164
164
  } catch (e) {
165
165
  // errno: 'ERR_STREAM_PREMATURE_CLOSE',
166
- // code: 'ERR_STREAM_PREMATURE_CLOSE',
167
-
168
- console.error(e);
166
+ // code: 'ERR_STREAM_PREMATURE_CLOSE',
167
+
169
168
  this.error(e);
170
169
  }
171
170
  }
@@ -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
- const response = await this.fetch(`user/repos?page=${page}`, {
125
- headers: {
126
- accept: "application/vnd.github.baptiste-preview+json"
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
- if (!response.ok) {
131
- this.error(
132
- `Unable to fetch repositories ${response.status} ${response.url}`
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