github-repository-provider 7.26.40 → 7.27.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 +15 -15
- package/src/github-pull-request.mjs +4 -4
- package/src/github-repository.mjs +20 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-repository-provider",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.27.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"matching-iterator": "^2.0.4",
|
|
37
37
|
"node-fetch": "^3.2.4",
|
|
38
38
|
"one-time-execution-method": "^3.0.1",
|
|
39
|
-
"repository-provider": "^29.2.
|
|
39
|
+
"repository-provider": "^29.2.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"ava": "^4.2.0",
|
|
43
43
|
"c8": "^7.11.3",
|
|
44
44
|
"documentation": "^13.2.5",
|
|
45
|
-
"repository-provider-test-support": "^2.1.
|
|
45
|
+
"repository-provider-test-support": "^2.1.19",
|
|
46
46
|
"semantic-release": "^19.0.2"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
package/src/github-branch.mjs
CHANGED
|
@@ -10,6 +10,12 @@ import {
|
|
|
10
10
|
* Branch on GitHub.
|
|
11
11
|
*/
|
|
12
12
|
export class GithubBranch extends Branch {
|
|
13
|
+
|
|
14
|
+
get api()
|
|
15
|
+
{
|
|
16
|
+
return this.repository.api;
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
/**
|
|
14
20
|
* Writes content into the branch
|
|
15
21
|
* {@link https://developer.github.com/v3/git/blobs/#get-a-blob}
|
|
@@ -18,7 +24,7 @@ export class GithubBranch extends Branch {
|
|
|
18
24
|
*/
|
|
19
25
|
async writeEntry(entry) {
|
|
20
26
|
const { json } = await this.provider.fetchJSON(
|
|
21
|
-
|
|
27
|
+
`${this.api}/git/blobs`,
|
|
22
28
|
{
|
|
23
29
|
method: "POST",
|
|
24
30
|
body: JSON.stringify({
|
|
@@ -58,7 +64,7 @@ export class GithubBranch extends Branch {
|
|
|
58
64
|
const commit = await this.commitForSha(shaLatestCommit);
|
|
59
65
|
|
|
60
66
|
let { json } = await this.provider.fetchJSON(
|
|
61
|
-
|
|
67
|
+
`${this.api}/git/trees`,
|
|
62
68
|
{
|
|
63
69
|
method: "POST",
|
|
64
70
|
body: JSON.stringify({
|
|
@@ -75,7 +81,7 @@ export class GithubBranch extends Branch {
|
|
|
75
81
|
}
|
|
76
82
|
);
|
|
77
83
|
|
|
78
|
-
let r = await this.provider.fetchJSON(
|
|
84
|
+
let r = await this.provider.fetchJSON(`${this.api}/git/commits`, {
|
|
79
85
|
method: "POST",
|
|
80
86
|
body: JSON.stringify({
|
|
81
87
|
message,
|
|
@@ -84,7 +90,7 @@ export class GithubBranch extends Branch {
|
|
|
84
90
|
})
|
|
85
91
|
});
|
|
86
92
|
|
|
87
|
-
r = await this.provider.fetchJSON(
|
|
93
|
+
r = await this.provider.fetchJSON(`${this.api}/git/${this.ref}`, {
|
|
88
94
|
method: "PATCH",
|
|
89
95
|
body: JSON.stringify({
|
|
90
96
|
...options,
|
|
@@ -114,9 +120,7 @@ export class GithubBranch extends Branch {
|
|
|
114
120
|
}
|
|
115
121
|
|
|
116
122
|
const f = async () => {
|
|
117
|
-
const { json } = await this.provider.fetchJSON(
|
|
118
|
-
`repos/${this.slug}/contents/${name}?ref=${this.ref}`
|
|
119
|
-
);
|
|
123
|
+
const { json } = await this.provider.fetchJSON(`${this.api}/contents/${name}?ref=${this.ref}`);
|
|
120
124
|
|
|
121
125
|
const entry = new this.entryClass(
|
|
122
126
|
name,
|
|
@@ -149,9 +153,7 @@ export class GithubBranch extends Branch {
|
|
|
149
153
|
this.#commitForSha = new Map();
|
|
150
154
|
}
|
|
151
155
|
|
|
152
|
-
const { json } = await this.provider.fetchJSON(
|
|
153
|
-
`repos/${this.slug}/git/commits/${sha}`
|
|
154
|
-
);
|
|
156
|
+
const { json } = await this.provider.fetchJSON(`${this.api}/git/commits/${sha}`);
|
|
155
157
|
|
|
156
158
|
this.#commitForSha.set(sha, json);
|
|
157
159
|
|
|
@@ -173,9 +175,7 @@ export class GithubBranch extends Branch {
|
|
|
173
175
|
this.#tree = new Map();
|
|
174
176
|
}
|
|
175
177
|
|
|
176
|
-
const { json } = await this.provider.fetchJSON(
|
|
177
|
-
`repos/${this.slug}/git/trees/${sha}?recursive=1`
|
|
178
|
-
);
|
|
178
|
+
const { json } = await this.provider.fetchJSON(`${this.api}/git/trees/${sha}?recursive=1`);
|
|
179
179
|
|
|
180
180
|
const tree = json.tree;
|
|
181
181
|
|
|
@@ -219,7 +219,7 @@ export class GithubBranch extends Branch {
|
|
|
219
219
|
*/
|
|
220
220
|
async removeEntries(entries) {
|
|
221
221
|
for await (const entry of entries) {
|
|
222
|
-
await this.provider.fetch(
|
|
222
|
+
await this.provider.fetch(`${this.api}/contents/${entry.name}`, {
|
|
223
223
|
method: "DELETE",
|
|
224
224
|
body: JSON.stringify({ branch: this.name, message: "", sha: "" })
|
|
225
225
|
});
|
|
@@ -249,7 +249,7 @@ class LazyBufferContentEntry extends BufferContentEntryMixin(ContentEntry) {
|
|
|
249
249
|
|
|
250
250
|
const f = async () => {
|
|
251
251
|
const { json } = await branch.provider.fetchJSON(
|
|
252
|
-
|
|
252
|
+
`${branch.api}/contents/${this.name}?ref=${branch.ref}`
|
|
253
253
|
);
|
|
254
254
|
|
|
255
255
|
this.#buffer = Buffer.from(json.content, "base64");
|
|
@@ -39,7 +39,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
39
39
|
for (const state of [
|
|
40
40
|
...(filter.states ? filter.states : this.defaultListStates)
|
|
41
41
|
]) {
|
|
42
|
-
let next =
|
|
42
|
+
let next = `${repository.api}/pulls?state=${state}${head}${base}`;
|
|
43
43
|
|
|
44
44
|
do {
|
|
45
45
|
const provider = repository.provider;
|
|
@@ -73,7 +73,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
const { json } = await destination.provider.fetchJSON(
|
|
76
|
-
|
|
76
|
+
`${destination.repository.api}/pulls`,
|
|
77
77
|
{
|
|
78
78
|
method: "POST",
|
|
79
79
|
body: JSON.stringify({
|
|
@@ -92,7 +92,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
92
92
|
*/
|
|
93
93
|
async _merge(method = "MERGE") {
|
|
94
94
|
const res = await this.provider.fetch(
|
|
95
|
-
|
|
95
|
+
`${this.source.repository.api}/pulls/${this.number}/merge`,
|
|
96
96
|
{
|
|
97
97
|
method: "PUT",
|
|
98
98
|
body: JSON.stringify({ merge_method: method, sha: "???" })
|
|
@@ -105,7 +105,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
105
105
|
*/
|
|
106
106
|
async update() {
|
|
107
107
|
const res = await this.provider.fetch(
|
|
108
|
-
|
|
108
|
+
`${this.source.repository.api}/pulls/${this.number}`,
|
|
109
109
|
{
|
|
110
110
|
method: "PATCH",
|
|
111
111
|
body: JSON.stringify({
|
|
@@ -49,7 +49,7 @@ export class GithubRepository extends Repository {
|
|
|
49
49
|
* @returns {AsyncIterator<Commit>}
|
|
50
50
|
*/
|
|
51
51
|
async *commits(options) {
|
|
52
|
-
let next =
|
|
52
|
+
let next = `${this.api}/commits`;
|
|
53
53
|
|
|
54
54
|
do {
|
|
55
55
|
const { response, json } = await this.provider.fetchJSON(next);
|
|
@@ -66,8 +66,8 @@ export class GithubRepository extends Repository {
|
|
|
66
66
|
} while (next);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
async
|
|
70
|
-
let next =
|
|
69
|
+
async #initializeSlot(typeName, addMethodName) {
|
|
70
|
+
let next = `${this.api}/${typeName}`;
|
|
71
71
|
|
|
72
72
|
do {
|
|
73
73
|
const { response, json } = await this.provider.fetchJSON(next);
|
|
@@ -80,14 +80,14 @@ export class GithubRepository extends Repository {
|
|
|
80
80
|
* {@link https://developer.github.com/v3/repos/branches/#list-branches}
|
|
81
81
|
*/
|
|
82
82
|
async initializeBranches() {
|
|
83
|
-
return this
|
|
83
|
+
return this.#initializeSlot("branches", "addBranch");
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* {@link https://docs.github.com/en/rest/reference/repos#list-repository-tags}
|
|
88
88
|
*/
|
|
89
89
|
async initializeTags() {
|
|
90
|
-
return this
|
|
90
|
+
return this.#initializeSlot("tags", "addTag");
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
@@ -113,11 +113,20 @@ export class GithubRepository extends Repository {
|
|
|
113
113
|
return `${this.provider.url}${this.fullName}#readme`;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
* API endpoint for ourselfs.
|
|
118
|
+
* @return {string}
|
|
119
|
+
*/
|
|
120
|
+
get api()
|
|
121
|
+
{
|
|
122
|
+
return `repos/${this.slug}`;
|
|
123
|
+
}
|
|
124
|
+
|
|
116
125
|
/**
|
|
117
126
|
* {@link https://developer.github.com/v3/repos/#update-a-repository}
|
|
118
127
|
*/
|
|
119
128
|
async update() {
|
|
120
|
-
return this.provider.fetch(
|
|
129
|
+
return this.provider.fetch(this.api, {
|
|
121
130
|
method: "PATCH",
|
|
122
131
|
body: JSON.stringify(
|
|
123
132
|
mapAttributesInverse(
|
|
@@ -150,7 +159,7 @@ export class GithubRepository extends Repository {
|
|
|
150
159
|
}
|
|
151
160
|
|
|
152
161
|
const { response, json } = await this.provider.fetchJSON(
|
|
153
|
-
|
|
162
|
+
`${this.api}/git/ref/${ref}`,
|
|
154
163
|
undefined,
|
|
155
164
|
conflictErrorActions
|
|
156
165
|
);
|
|
@@ -199,7 +208,7 @@ export class GithubRepository extends Repository {
|
|
|
199
208
|
*/
|
|
200
209
|
}
|
|
201
210
|
|
|
202
|
-
const res = await this.provider.fetch(
|
|
211
|
+
const res = await this.provider.fetch(`${this.api}/git/refs`, {
|
|
203
212
|
method: "POST",
|
|
204
213
|
body: JSON.stringify({
|
|
205
214
|
ref: `refs/heads/${name}`,
|
|
@@ -216,7 +225,7 @@ export class GithubRepository extends Repository {
|
|
|
216
225
|
|
|
217
226
|
async deleteBranch(name) {
|
|
218
227
|
const res = await this.provider.fetch(
|
|
219
|
-
|
|
228
|
+
`${this.api}/git/refs/heads/${name}`,
|
|
220
229
|
{
|
|
221
230
|
method: "DELETE"
|
|
222
231
|
}
|
|
@@ -233,7 +242,7 @@ export class GithubRepository extends Repository {
|
|
|
233
242
|
* @param {string} name
|
|
234
243
|
*/
|
|
235
244
|
async deletePullRequest(name) {
|
|
236
|
-
const res = await this.provider.fetch(
|
|
245
|
+
const res = await this.provider.fetch(`${this.api}/pulls/${name}`, {
|
|
237
246
|
method: "PATCH",
|
|
238
247
|
body: JSON.stringify({ state: "closed" })
|
|
239
248
|
});
|
|
@@ -247,7 +256,7 @@ export class GithubRepository extends Repository {
|
|
|
247
256
|
* {@link https://developer.github.com/v3/repos/hooks/}
|
|
248
257
|
*/
|
|
249
258
|
async initializeHooks() {
|
|
250
|
-
let next =
|
|
259
|
+
let next = `${this.api}/hooks`;
|
|
251
260
|
|
|
252
261
|
do {
|
|
253
262
|
const { response, json } = await this.provider.fetchJSON(next);
|