repository-provider 26.1.3 → 26.4.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": "repository-provider",
3
- "version": "26.1.3",
3
+ "version": "26.4.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,9 +36,9 @@
36
36
  "ava": "^4.0.1",
37
37
  "c8": "^7.11.0",
38
38
  "documentation": "^13.2.5",
39
- "repository-provider-test-support": "^1.9.6",
40
- "semantic-release": "^18.0.1",
41
- "typescript": "^4.6.0-dev.20220115"
39
+ "repository-provider-test-support": "^1.9.8",
40
+ "semantic-release": "^19.0.2",
41
+ "typescript": "^4.6.0-dev.20220124"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=14.18.3"
@@ -71,6 +71,11 @@ export class BaseObject {
71
71
  );
72
72
  }
73
73
 
74
+ /**
75
+ * Save object attributes in the backing store.
76
+ */
77
+ async update() {}
78
+
74
79
  /**
75
80
  * Check for equality
76
81
  * @param {BaseObject} other
@@ -79,4 +84,84 @@ export class BaseObject {
79
84
  equals(other) {
80
85
  return other !== undefined;
81
86
  }
87
+
88
+ /**
89
+ * The provider we live in.
90
+ * @return {BaseProvider}
91
+ */
92
+ get provider() {
93
+ return this.owner.provider;
94
+ }
95
+
96
+ /**
97
+ * Forwarded to the owner.
98
+ * @param {...any} args
99
+ */
100
+ info(...args) {
101
+ return this.owner.info(...args);
102
+ }
103
+
104
+ /**
105
+ * Forwarded to the owner.
106
+ * @param {...any} args
107
+ */
108
+ warn(...args) {
109
+ return this.owner.warn(...args);
110
+ }
111
+
112
+ /**
113
+ * Forwarded to the owner.
114
+ * @param {...any} args
115
+ */
116
+ error(...args) {
117
+ return this.owner.error(...args);
118
+ }
119
+
120
+ /**
121
+ * By default we use the owners implementation.
122
+ * @return {Class} as defined in the owner
123
+ */
124
+ get repositoryClass() {
125
+ return this.owner.repositoryClass;
126
+ }
127
+
128
+ /**
129
+ * By default we use the owners implementation.
130
+ * @return {Class} as defined in the owner
131
+ */
132
+ get pullRequestClass() {
133
+ return this.owner.pullRequestClass;
134
+ }
135
+
136
+ /**
137
+ * By default we use the owners implementation.
138
+ * @return {Class} as defined in the owner
139
+ */
140
+ get branchClass() {
141
+ return this.owner.branchClass;
142
+ }
143
+
144
+ /**
145
+ * By default we use the owners implementation.
146
+ * @return {Class} as defined in the owner
147
+ */
148
+ get tagClass() {
149
+ return this.owner.tagClass;
150
+ }
151
+
152
+ /**
153
+ * By default we use the owners implementation.
154
+ * @return {Class} as defined in the owner
155
+ */
156
+ get entryClass() {
157
+ return this.owner.entryClass;
158
+ }
159
+
160
+ /**
161
+ * By default we use the owners implementation.
162
+ * @return {Class} as defined in the owner
163
+ */
164
+ get hookClass() {
165
+ return this.owner.hookClass;
166
+ }
82
167
  }
@@ -482,6 +482,13 @@ export class BaseProvider {
482
482
  return Branch;
483
483
  }
484
484
 
485
+ /**
486
+ * @return {Class} branch class used by the Provider
487
+ */
488
+ get tagClass() {
489
+ return Tag;
490
+ }
491
+
485
492
  /**
486
493
  * @return {Class} entry class used by the Provider
487
494
  */
package/src/branch.mjs CHANGED
@@ -82,6 +82,7 @@ export class Branch extends Ref {
82
82
  * @param {boolean} options.dry do not create a branch and do not commit only create dummy PR
83
83
  * @param {boolean} options.skipWithoutCommits do not create a PR if no commits are given
84
84
  * @param {boolean} options.bodyFromCommitMessages generate body from commit messages
85
+ * @param {string} [options.body] body of the PR
85
86
  * @return {Promise<PullRequest>}
86
87
  */
87
88
  async commitIntoPullRequest(commits, options) {
@@ -182,14 +183,6 @@ export class Branch extends Ref {
182
183
  return this.repository.deletePullRequest(name);
183
184
  }
184
185
 
185
- /**
186
- * By default we use the repository implementation.
187
- * @return {Class} as defined in the repository
188
- */
189
- get pullRequestClass() {
190
- return this.repository.pullRequestClass;
191
- }
192
-
193
186
  /**
194
187
  * Create a new {@link Branch} by cloning a given source branch.
195
188
  * Simply calls Repository.createBranch() with the receiver as source branch
package/src/hook.mjs CHANGED
@@ -36,6 +36,11 @@ export class Hook extends BaseObject {
36
36
  repository._addHook(this);
37
37
  }
38
38
 
39
+ get owner()
40
+ {
41
+ return this.repository;
42
+ }
43
+
39
44
  get fullName() {
40
45
  return `${this.repository.fullName}/${this.id}`;
41
46
  }
@@ -59,16 +64,4 @@ export class Hook extends BaseObject {
59
64
  toJSON() {
60
65
  return optionJSON(this, { id: this.id, events: [...this.events] });
61
66
  }
62
-
63
- info(...args) {
64
- return this.repository.info(...args);
65
- }
66
-
67
- warn(...args) {
68
- return this.repository.warn(...args);
69
- }
70
-
71
- error(...args) {
72
- return this.repository.error(...args);
73
- }
74
67
  }
@@ -34,13 +34,6 @@ export class NamedObject extends BaseObject {
34
34
  return this.name;
35
35
  }
36
36
 
37
- /**
38
- * Save object attributes in the backing store.
39
- */
40
- async update()
41
- {
42
- }
43
-
44
37
  toString() {
45
38
  return this.name;
46
39
  }
package/src/ref.mjs CHANGED
@@ -96,14 +96,6 @@ export class Ref extends NamedObject {
96
96
  return e;
97
97
  }
98
98
 
99
- /**
100
- * The provider we live in.
101
- * @return {BaseProvider}
102
- */
103
- get provider() {
104
- return this.repository.provider;
105
- }
106
-
107
99
  /**
108
100
  * Branch owner.
109
101
  * By default we provide the repository owner
@@ -208,16 +200,4 @@ export class Ref extends NamedObject {
208
200
  !this.isProtected
209
201
  );
210
202
  }
211
-
212
- info(...args) {
213
- return this.repository.info(...args);
214
- }
215
-
216
- warn(...args) {
217
- return this.repository.warn(...args);
218
- }
219
-
220
- error(...args) {
221
- return this.repository.error(...args);
222
- }
223
203
  }
@@ -49,6 +49,11 @@ export class RepositoryGroup extends RepositoryOwner(NamedObject) {
49
49
  });
50
50
  }
51
51
 
52
+ get owner()
53
+ {
54
+ return this.provider;
55
+ }
56
+
52
57
  get isAdmin() {
53
58
  return false;
54
59
  }
@@ -60,56 +65,4 @@ export class RepositoryGroup extends RepositoryOwner(NamedObject) {
60
65
  get areRepositoryGroupNamesCaseSensitive() {
61
66
  return this.provider.areRepositoryGroupNamesCaseSensitive;
62
67
  }
63
-
64
- /**
65
- * By default we use the providers implementation.
66
- * @return {Class} as defined in the provider
67
- */
68
- get repositoryClass() {
69
- return this.provider.repositoryClass;
70
- }
71
-
72
- /**
73
- * By default we use the providers implementation.
74
- * @return {Class} as defined in the provider
75
- */
76
- get branchClass() {
77
- return this.provider.branchClass;
78
- }
79
-
80
- /**
81
- * By default we use the providers implementation.
82
- * @return {Class} as defined in the provider
83
- */
84
- get contentClass() {
85
- return this.provider.contentClass;
86
- }
87
-
88
- /**
89
- * By default we use the providers implementation.
90
- * @return {Class} as defined in the provider
91
- */
92
- get pullRequestClass() {
93
- return this.provider.pullRequestClass;
94
- }
95
-
96
- /**
97
- * By default we use the providers implementation.
98
- * @return {Class} as defined in the provider
99
- */
100
- get hookClass() {
101
- return this.provider.hookClass;
102
- }
103
-
104
- info(...args) {
105
- return this.provider.info(...args);
106
- }
107
-
108
- warn(...args) {
109
- return this.provider.warn(...args);
110
- }
111
-
112
- error(...args) {
113
- return this.provider.error(...args);
114
- }
115
68
  }
@@ -42,7 +42,7 @@ export class Repository extends NamedObject {
42
42
  * URLs of the repository
43
43
  * @return {string[]}
44
44
  */
45
- urls: { },
45
+ urls: {},
46
46
 
47
47
  cloneURL: { type: "url" },
48
48
 
@@ -229,6 +229,14 @@ export class Repository extends NamedObject {
229
229
  return false;
230
230
  }
231
231
 
232
+ /**
233
+ * Lookup the default branch.
234
+ * @return {Promise<Branch>} branch named after defaultBranchName
235
+ */
236
+ get defaultBranch() {
237
+ return this.branch(this.defaultBranchName);
238
+ }
239
+
232
240
  /**
233
241
  * Lookup branch by name.
234
242
  * @param {string} name
@@ -239,14 +247,6 @@ export class Repository extends NamedObject {
239
247
  return this._branches.get(name);
240
248
  }
241
249
 
242
- /**
243
- * Lookup the default branch.
244
- * @return {Promise<Branch>} branch named after defaultBranchName
245
- */
246
- get defaultBranch() {
247
- return this.branch(this.defaultBranchName);
248
- }
249
-
250
250
  /**
251
251
  * @return {AsyncIterator<Branch>} of all branches
252
252
  */
@@ -274,7 +274,7 @@ export class Repository extends NamedObject {
274
274
  * Internal branch creation does not call repository.initialize()
275
275
  * @param {string} name of the new branch
276
276
  * @param {Object} options
277
- * @return {Promise<Branch>} newly created branch
277
+ * @return {Branch} newly created branch
278
278
  */
279
279
  addBranch(name, options) {
280
280
  let branch = this._branches.get(name);
@@ -298,8 +298,14 @@ export class Repository extends NamedObject {
298
298
  this._branches.delete(name);
299
299
  }
300
300
 
301
- _addTag(tag) {
302
- this._tags.set(tag.name, tag);
301
+ /**
302
+ * Get a Tag.
303
+ * @param {string} name
304
+ * @return {Promise<Tag>}
305
+ */
306
+ async tag(name) {
307
+ await this.initializeTags();
308
+ return this._tags.get(name);
303
309
  }
304
310
 
305
311
  /**
@@ -315,13 +321,23 @@ export class Repository extends NamedObject {
315
321
  }
316
322
 
317
323
  /**
318
- * Get a Tag.
319
- * @param {string} name
320
- * @return {Promise<Tag>}
324
+ * Add a new {@link Tag}.
325
+ * Internal tag creation does not call repository.initialize()
326
+ * @param {string} name of the new tag
327
+ * @param {Object} options
328
+ * @return {Tag} newly created tag
321
329
  */
322
- async tag(name) {
323
- await this.initializeTags();
324
- return this._tags.get(name);
330
+ addTag(name, options) {
331
+ let tag = this._tags.get(name);
332
+ if (tag === undefined) {
333
+ tag = new this.tagClass(this, name, options);
334
+ }
335
+
336
+ return tag;
337
+ }
338
+
339
+ _addTag(tag) {
340
+ this._tags.set(tag.name, tag);
325
341
  }
326
342
 
327
343
  /**
@@ -474,46 +490,6 @@ export class Repository extends NamedObject {
474
490
  return undefined;
475
491
  }
476
492
 
477
- /**
478
- * By default we use the owners implementation.
479
- * @return {Class} as defined in the owner
480
- */
481
- get repositoryClass() {
482
- return this.owner.repositoryClass;
483
- }
484
-
485
- /**
486
- * By default we use the owners implementation.
487
- * @return {Class} as defined in the owner
488
- */
489
- get pullRequestClass() {
490
- return this.owner.pullRequestClass;
491
- }
492
-
493
- /**
494
- * By default we use the owners implementation.
495
- * @return {Class} as defined in the owner
496
- */
497
- get branchClass() {
498
- return this.owner.branchClass;
499
- }
500
-
501
- /**
502
- * By default we use the owners implementation.
503
- * @return {Class} as defined in the owner
504
- */
505
- get entryClass() {
506
- return this.owner.entryClass;
507
- }
508
-
509
- /**
510
- * By default we use the owners implementation.
511
- * @return {Class} as defined in the owner
512
- */
513
- get hookClass() {
514
- return this.owner.hookClass;
515
- }
516
-
517
493
  toString() {
518
494
  return this.fullName;
519
495
  }
@@ -529,18 +505,6 @@ export class Repository extends NamedObject {
529
505
  });
530
506
  }
531
507
 
532
- info(...args) {
533
- return this.owner.info(...args);
534
- }
535
-
536
- warn(...args) {
537
- return this.owner.warn(...args);
538
- }
539
-
540
- error(...args) {
541
- return this.owner.error(...args);
542
- }
543
-
544
508
  initialize() {}
545
509
 
546
510
  initializeHooks() {