github-repository-provider 7.26.41 → 7.27.0

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.26.41",
3
+ "version": "7.27.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -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 = `/repos/${repository.slug}/pulls?state=${state}${head}${base}`;
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
- `repos/${destination.repository.slug}/pulls`,
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
- `repos/${this.source.repository.slug}/pulls/${this.number}/merge`,
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
- `repos/${this.source.repository.slug}/pulls/${this.number}`,
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 = `repos/${this.slug}/commits`;
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 _initializeSlot(typeName, addMethodName) {
70
- let next = `repos/${this.slug}/${typeName}`;
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._initializeSlot("branches", "addBranch");
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._initializeSlot("tags", "addTag");
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(`repos/${this.slug}`, {
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
- `repos/${this.slug}/git/ref/${ref}`,
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(`repos/${this.slug}/git/refs`, {
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
- `repos/${this.slug}/git/refs/heads/${name}`,
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(`repos/${this.slug}/pulls/${name}`, {
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 = `repos/${this.slug}/hooks`;
259
+ let next = `${this.api}/hooks`;
251
260
 
252
261
  do {
253
262
  const { response, json } = await this.provider.fetchJSON(next);