github-repository-provider 7.24.9 → 7.25.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 +4 -4
- package/src/github-branch.mjs +11 -11
- package/src/github-provider.mjs +25 -34
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-repository-provider",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.25.2",
|
|
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.1.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.
|
|
39
|
+
"repository-provider": "^26.1.1"
|
|
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,31 +42,40 @@ 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.${
|
|
70
|
+
default: `https://api.${host}`
|
|
66
71
|
},
|
|
67
72
|
"authentication.token": {
|
|
68
73
|
type: "string",
|
|
69
|
-
|
|
74
|
+
// @see https://cli.github.com/manual/gh_help_environment
|
|
75
|
+
env: [
|
|
76
|
+
"{{instanceIdentifier}}TOKEN",
|
|
77
|
+
"GH_TOKEN" // declare GH_ as identifier
|
|
78
|
+
],
|
|
70
79
|
additionalAttributes: { "authentication.type": "token" },
|
|
71
80
|
private: true,
|
|
72
81
|
mandatory: true
|
|
@@ -89,31 +98,13 @@ export class GithubProvider extends MultiGroupProvider {
|
|
|
89
98
|
}
|
|
90
99
|
|
|
91
100
|
fetch(url, options = {}) {
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
authorization: `token ${this.authentication.token}`,
|
|
98
|
-
...options.headers
|
|
99
|
-
}
|
|
100
|
-
}),
|
|
101
|
-
(millisecondsToWait, rateLimitRemaining, nthTry, response) => {
|
|
102
|
-
this.rateLimitRemaining = rateLimitRemaining;
|
|
103
|
-
|
|
104
|
-
const msecs = defaultWaitDecide(
|
|
105
|
-
millisecondsToWait,
|
|
106
|
-
rateLimitRemaining,
|
|
107
|
-
nthTry,
|
|
108
|
-
response
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
if (msecs > 0) {
|
|
112
|
-
this.warn(`Rate limit reached: waiting for ${msecs / 1000}s`);
|
|
113
|
-
}
|
|
114
|
-
return msecs;
|
|
101
|
+
return stateActionHandler(fetch, new URL(url, this.api), {
|
|
102
|
+
...options,
|
|
103
|
+
headers: {
|
|
104
|
+
authorization: `token ${this.authentication.token}`,
|
|
105
|
+
...options.headers
|
|
115
106
|
}
|
|
116
|
-
);
|
|
107
|
+
});
|
|
117
108
|
}
|
|
118
109
|
|
|
119
110
|
async fetchJSON(url, options) {
|
|
@@ -186,9 +177,9 @@ export class GithubProvider extends MultiGroupProvider {
|
|
|
186
177
|
return super.repositoryBases.concat([
|
|
187
178
|
this.url,
|
|
188
179
|
"git+" + this.url,
|
|
189
|
-
`git+ssh://${
|
|
190
|
-
`git://${
|
|
191
|
-
`git@${
|
|
180
|
+
`git+ssh://${host}`,
|
|
181
|
+
`git://${host}/`,
|
|
182
|
+
`git@${host}:`
|
|
192
183
|
]);
|
|
193
184
|
}
|
|
194
185
|
|