github-repository-provider 7.24.10 → 7.25.3
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/LICENSE +1 -1
- package/README.md +12 -12
- package/package.json +4 -4
- package/src/github-branch.mjs +11 -11
- package/src/github-provider.mjs +34 -73
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -36,13 +36,13 @@ console.log(entry.name);
|
|
|
36
36
|
* [GithubBranch](#githubbranch)
|
|
37
37
|
* [writeEntry](#writeentry)
|
|
38
38
|
* [Parameters](#parameters)
|
|
39
|
-
* [baseTreeSha](#basetreesha)
|
|
40
|
-
* [Parameters](#parameters-1)
|
|
41
39
|
* [commit](#commit)
|
|
42
|
-
* [Parameters](#parameters-
|
|
40
|
+
* [Parameters](#parameters-1)
|
|
43
41
|
* [entry](#entry)
|
|
44
|
-
* [Parameters](#parameters-
|
|
42
|
+
* [Parameters](#parameters-2)
|
|
45
43
|
* [maybeEntry](#maybeentry)
|
|
44
|
+
* [Parameters](#parameters-3)
|
|
45
|
+
* [baseTreeSha](#basetreesha)
|
|
46
46
|
* [Parameters](#parameters-4)
|
|
47
47
|
* [tree](#tree)
|
|
48
48
|
* [Parameters](#parameters-5)
|
|
@@ -99,14 +99,6 @@ Writes content into the branch
|
|
|
99
99
|
|
|
100
100
|
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<ConentEntry>** written content with sha values set
|
|
101
101
|
|
|
102
|
-
### baseTreeSha
|
|
103
|
-
|
|
104
|
-
<https://developer.github.com/v3/git/commits/#get-a-commit>
|
|
105
|
-
|
|
106
|
-
#### Parameters
|
|
107
|
-
|
|
108
|
-
* `sha` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
109
|
-
|
|
110
102
|
### commit
|
|
111
103
|
|
|
112
104
|
<https://developer.github.com/v3/git/trees/#create-a-tree>
|
|
@@ -133,6 +125,14 @@ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
|
|
|
133
125
|
|
|
134
126
|
* `name`
|
|
135
127
|
|
|
128
|
+
### baseTreeSha
|
|
129
|
+
|
|
130
|
+
<https://developer.github.com/v3/git/commits/#get-a-commit>
|
|
131
|
+
|
|
132
|
+
#### Parameters
|
|
133
|
+
|
|
134
|
+
* `sha` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
135
|
+
|
|
136
136
|
### tree
|
|
137
137
|
|
|
138
138
|
* **See**: <https://developer.github.com/v3/git/trees/>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-repository-provider",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.25.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,17 +32,17 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"content-entry": "^3.0.2",
|
|
34
34
|
"fetch-link-util": "^1.0.4",
|
|
35
|
-
"fetch-rate-limit-util": "^
|
|
35
|
+
"fetch-rate-limit-util": "^2.2.0",
|
|
36
36
|
"matching-iterator": "^2.0.0",
|
|
37
37
|
"node-fetch": "3.1.0",
|
|
38
38
|
"one-time-execution-method": "^2.0.9",
|
|
39
|
-
"repository-provider": "^26.1.
|
|
39
|
+
"repository-provider": "^26.1.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"ava": "^3.15.0",
|
|
43
43
|
"c8": "^7.11.0",
|
|
44
44
|
"documentation": "^13.2.5",
|
|
45
|
-
"repository-provider-test-support": "^1.9.
|
|
45
|
+
"repository-provider-test-support": "^1.9.2",
|
|
46
46
|
"semantic-release": "^18.0.1"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
package/src/github-branch.mjs
CHANGED
|
@@ -34,17 +34,6 @@ export class GithubBranch extends Branch {
|
|
|
34
34
|
return entry;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/**
|
|
38
|
-
* {@link https://developer.github.com/v3/git/commits/#get-a-commit}
|
|
39
|
-
* @param {string} sha
|
|
40
|
-
*/
|
|
41
|
-
async baseTreeSha(sha) {
|
|
42
|
-
const { json } = await this.provider.fetchJSON(
|
|
43
|
-
`repos/${this.slug}/git/commits/${sha}`
|
|
44
|
-
);
|
|
45
|
-
return json.tree.sha;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
37
|
/**
|
|
49
38
|
* {@link https://developer.github.com/v3/git/trees/#create-a-tree}
|
|
50
39
|
* {@link https://developer.github.com/v3/git/commits/#create-a-commit}
|
|
@@ -135,6 +124,17 @@ export class GithubBranch extends Branch {
|
|
|
135
124
|
}
|
|
136
125
|
}
|
|
137
126
|
|
|
127
|
+
/**
|
|
128
|
+
* {@link https://developer.github.com/v3/git/commits/#get-a-commit}
|
|
129
|
+
* @param {string} sha
|
|
130
|
+
*/
|
|
131
|
+
async baseTreeSha(sha) {
|
|
132
|
+
const { json } = await this.provider.fetchJSON(
|
|
133
|
+
`repos/${this.slug}/git/commits/${sha}`
|
|
134
|
+
);
|
|
135
|
+
return json.tree.sha;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
138
|
/**
|
|
139
139
|
* @see https://developer.github.com/v3/git/trees/
|
|
140
140
|
* @param {string } treeSha
|
package/src/github-provider.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fetch from "node-fetch";
|
|
2
2
|
import { replaceWithOneTimeExecutionMethod } from "one-time-execution-method";
|
|
3
|
-
import {
|
|
3
|
+
import { stateActionHandler } from "fetch-rate-limit-util";
|
|
4
4
|
|
|
5
5
|
import { MultiGroupProvider } from "repository-provider";
|
|
6
6
|
import { GithubRepository } from "./github-repository.mjs";
|
|
@@ -9,7 +9,7 @@ import { GithubOwner } from "./github-owner.mjs";
|
|
|
9
9
|
import { GithubPullRequest } from "./github-pull-request.mjs";
|
|
10
10
|
export { GithubRepository, GithubBranch, GithubOwner, GithubPullRequest };
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const host = "github.com";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* <!-- skip-example -->
|
|
@@ -42,43 +42,39 @@ 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_"; // "GH_" "GH_ENTERPRISE_"
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
static get attributes() {
|
|
49
49
|
return {
|
|
50
50
|
...super.attributes,
|
|
51
|
+
host: {
|
|
52
|
+
type: "string",
|
|
53
|
+
env: ["{{instanceIdentifier}}HOST", "GH_HOST"],
|
|
54
|
+
default: "github.com"
|
|
55
|
+
},
|
|
51
56
|
ssh: {
|
|
52
57
|
type: "url",
|
|
53
|
-
default: `git@${
|
|
58
|
+
default: `git@${host}:`
|
|
54
59
|
},
|
|
55
60
|
url: {
|
|
56
61
|
type: "url",
|
|
57
62
|
env: ["{{instanceIdentifier}}SERVER_URL"],
|
|
58
63
|
set: value => (value.endsWith("/") ? value : value + "/"),
|
|
59
|
-
default: `https://${
|
|
64
|
+
default: `https://${host}/`
|
|
60
65
|
},
|
|
61
66
|
api: {
|
|
62
67
|
type: "url",
|
|
63
68
|
env: ["{{instanceIdentifier}}API_URL"],
|
|
64
69
|
set: value => value.replace(/\/$/, ""),
|
|
65
|
-
default: `https://api.${
|
|
66
|
-
},
|
|
67
|
-
/*
|
|
68
|
-
domain : {
|
|
69
|
-
type: "string",
|
|
70
|
-
env: ["GH_HOST"],
|
|
71
|
-
default: "github.com"
|
|
70
|
+
default: `https://api.${host}`
|
|
72
71
|
},
|
|
73
|
-
*/
|
|
74
72
|
"authentication.token": {
|
|
75
73
|
type: "string",
|
|
76
74
|
// @see https://cli.github.com/manual/gh_help_environment
|
|
77
75
|
env: [
|
|
78
76
|
"{{instanceIdentifier}}TOKEN",
|
|
79
|
-
"GH_TOKEN"
|
|
80
|
-
"GITHUB_ENTERPRISE_TOKEN",
|
|
81
|
-
"GH_ENTERPRISE_TOKEN"
|
|
77
|
+
"GH_TOKEN" // declare GH_ as identifier
|
|
82
78
|
],
|
|
83
79
|
additionalAttributes: { "authentication.type": "token" },
|
|
84
80
|
private: true,
|
|
@@ -102,57 +98,30 @@ export class GithubProvider extends MultiGroupProvider {
|
|
|
102
98
|
}
|
|
103
99
|
|
|
104
100
|
fetch(url, options = {}) {
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
authorization: `token ${this.authentication.token}`,
|
|
111
|
-
...options.headers
|
|
112
|
-
}
|
|
113
|
-
}),
|
|
114
|
-
(millisecondsToWait, rateLimitRemaining, nthTry, response) => {
|
|
115
|
-
this.rateLimitRemaining = rateLimitRemaining;
|
|
116
|
-
|
|
117
|
-
const msecs = defaultWaitDecide(
|
|
118
|
-
millisecondsToWait,
|
|
119
|
-
rateLimitRemaining,
|
|
120
|
-
nthTry,
|
|
121
|
-
response
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
if (msecs > 0) {
|
|
125
|
-
this.warn(`Rate limit reached: waiting for ${msecs / 1000}s`);
|
|
126
|
-
}
|
|
127
|
-
return msecs;
|
|
101
|
+
return stateActionHandler(fetch, new URL(url, this.api), {
|
|
102
|
+
...options,
|
|
103
|
+
headers: {
|
|
104
|
+
authorization: `token ${this.authentication.token}`,
|
|
105
|
+
...options.headers
|
|
128
106
|
}
|
|
129
|
-
);
|
|
107
|
+
});
|
|
130
108
|
}
|
|
131
109
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// none repeatable
|
|
142
|
-
throw new Error(
|
|
143
|
-
`Unable to fetch ${response.url} (${response.status})`
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
this.info(
|
|
147
|
-
`Unable to fetch ${response.url} (${response.status}) try #${i}`
|
|
148
|
-
);
|
|
149
|
-
} catch (e) {
|
|
150
|
-
if (i >= 3) {
|
|
151
|
-
throw e;
|
|
110
|
+
fetchJSON(url, options = {}) {
|
|
111
|
+
return stateActionHandler(
|
|
112
|
+
fetch,
|
|
113
|
+
new URL(url, this.api),
|
|
114
|
+
{
|
|
115
|
+
...options,
|
|
116
|
+
headers: {
|
|
117
|
+
authorization: `token ${this.authentication.token}`,
|
|
118
|
+
...options.headers
|
|
152
119
|
}
|
|
153
|
-
|
|
120
|
+
},
|
|
121
|
+
async response => {
|
|
122
|
+
return { response, json: await response.json() };
|
|
154
123
|
}
|
|
155
|
-
|
|
124
|
+
);
|
|
156
125
|
}
|
|
157
126
|
|
|
158
127
|
/**
|
|
@@ -199,9 +168,9 @@ export class GithubProvider extends MultiGroupProvider {
|
|
|
199
168
|
return super.repositoryBases.concat([
|
|
200
169
|
this.url,
|
|
201
170
|
"git+" + this.url,
|
|
202
|
-
`git+ssh://${
|
|
203
|
-
`git://${
|
|
204
|
-
`git@${
|
|
171
|
+
`git+ssh://${host}`,
|
|
172
|
+
`git://${host}/`,
|
|
173
|
+
`git@${host}:`
|
|
205
174
|
]);
|
|
206
175
|
}
|
|
207
176
|
|
|
@@ -224,11 +193,3 @@ replaceWithOneTimeExecutionMethod(
|
|
|
224
193
|
);
|
|
225
194
|
|
|
226
195
|
export default GithubProvider;
|
|
227
|
-
|
|
228
|
-
/*
|
|
229
|
-
{
|
|
230
|
-
"400" : { repeat: 3, timeout: 100 }
|
|
231
|
-
"401" : { repeat: 0 }
|
|
232
|
-
"500" : { repeat: 3, timeout: 100 }
|
|
233
|
-
}
|
|
234
|
-
*/
|