repository-provider 28.3.15 → 28.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repository-provider",
3
- "version": "28.3.15",
3
+ "version": "28.4.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -63,9 +63,8 @@ export class MultiGroupProvider extends BaseProvider {
63
63
  const { base } = this.parseName(name);
64
64
 
65
65
  if (this.supportsBase(base)) {
66
- name = stripBaseNames(name, this.provider.repositoryBases);
67
66
  await this.initializeRepositories();
68
- return this.#repositoryGroups.get(this.normalizeGroupName(name, true));
67
+ return this.#repositoryGroups.get(this.normalizeGroupName(stripBaseNames(name, this.provider.repositoryBases), true));
69
68
  }
70
69
  }
71
70
 
@@ -105,13 +104,10 @@ export class MultiGroupProvider extends BaseProvider {
105
104
  * @return {RepositoryGroup}
106
105
  */
107
106
  addRepositoryGroup(name, options) {
108
- const normalizedName = this.normalizeGroupName(name, true);
107
+ return this.#repositoryGroups.get(this.normalizeGroupName(name, true)) || new this.repositoryGroupClass(this, name, options);
108
+ }
109
109
 
110
- let repositoryGroup = this.#repositoryGroups.get(normalizedName);
111
- if (repositoryGroup === undefined) {
112
- repositoryGroup = new this.repositoryGroupClass(this, name, options);
113
- this.#repositoryGroups.set(normalizedName, repositoryGroup);
114
- }
115
- return repositoryGroup;
110
+ _addRepositoryGroup(repositoryGroup) {
111
+ this.#repositoryGroups.set(this.normalizeGroupName(repositoryGroup.name, true), repositoryGroup);
116
112
  }
117
113
  }
@@ -1,5 +1,5 @@
1
1
  import { RepositoryOwner } from "./repository-owner.mjs";
2
- import { NamedObject } from "./named-object.mjs";
2
+ import { OwnedObject } from "./owned-object.mjs";
3
3
  import { BaseProvider } from "./base-provider.mjs";
4
4
 
5
5
  /**
@@ -16,7 +16,12 @@ import { BaseProvider } from "./base-provider.mjs";
16
16
  * @property {string} name
17
17
  */
18
18
 
19
- export class RepositoryGroup extends RepositoryOwner(NamedObject) {
19
+ export class RepositoryGroup extends RepositoryOwner(OwnedObject) {
20
+
21
+ static get registerInstanceMethodName() {
22
+ return "_addRepositoryGroup";
23
+ }
24
+
20
25
  static get attributes() {
21
26
  return {
22
27
  ...super.attributes,
@@ -43,15 +48,9 @@ export class RepositoryGroup extends RepositoryOwner(NamedObject) {
43
48
  return {};
44
49
  }
45
50
 
46
- constructor(provider, name, options) {
47
- super(name, options, {
48
- provider: { value: provider }
49
- });
50
- }
51
-
52
- get owner()
51
+ get provider()
53
52
  {
54
- return this.provider;
53
+ return this.owner;
55
54
  }
56
55
 
57
56
  get isAdmin() {
@@ -59,10 +58,10 @@ export class RepositoryGroup extends RepositoryOwner(NamedObject) {
59
58
  }
60
59
 
61
60
  get areRepositoryNamesCaseSensitive() {
62
- return this.provider.areRepositoryNamesCaseSensitive;
61
+ return this.owner.areRepositoryNamesCaseSensitive;
63
62
  }
64
63
 
65
64
  get areRepositoryGroupNamesCaseSensitive() {
66
- return this.provider.areRepositoryGroupNamesCaseSensitive;
65
+ return this.owner.areRepositoryGroupNamesCaseSensitive;
67
66
  }
68
67
  }
@@ -146,12 +146,7 @@ export function RepositoryOwner(base) {
146
146
  * @return {Promise<Repository>} newly created repository
147
147
  */
148
148
  addRepository(name, options) {
149
- const normalizedName = this.normalizeRepositoryName(name, true);
150
- let repository = this.#repositories.get(normalizedName);
151
- if (repository === undefined) {
152
- repository = new this.repositoryClass(this, name, options);
153
- }
154
- return repository;
149
+ return this.#repositories.get(this.normalizeRepositoryName(name, true)) || new this.repositoryClass(this, name, options);
155
150
  }
156
151
 
157
152
  _addRepository(repository)
@@ -66,15 +66,15 @@ export class Repository extends OwnedObject {
66
66
  };
67
67
  }
68
68
 
69
+ #branches = new Map();
70
+ #tags = new Map();
71
+ #projects = new Map();
72
+ #milestones = new Map();
73
+ #pullRequests = new Map();
74
+ #hooks = [];
75
+
69
76
  constructor(owner, name, options) {
70
- super(owner, owner.normalizeRepositoryName(name, false), options, {
71
- _branches: { value: new Map() },
72
- _tags: { value: new Map() },
73
- _pullRequests: { value: new Map() },
74
- _milestones: { value: new Map() },
75
- _projects: { value: new Map() },
76
- _hooks: { value: [] }
77
- });
77
+ super(owner, owner.normalizeRepositoryName(name, false), options);
78
78
  }
79
79
 
80
80
  /**
@@ -242,16 +242,11 @@ export class Repository extends OwnedObject {
242
242
  */
243
243
  async branch(name) {
244
244
  if(name === this.defaultBranchName) {
245
- const branch = this._branches.get(name);
246
- if(branch) {
247
- return branch;
248
- }
249
-
250
- return this.addBranch(name);
245
+ return this.#branches.get(name) || this.addBranch(name);
251
246
  }
252
247
 
253
248
  await this.initializeBranches();
254
- return this._branches.get(name);
249
+ return this.#branches.get(name);
255
250
  }
256
251
 
257
252
  /**
@@ -259,7 +254,7 @@ export class Repository extends OwnedObject {
259
254
  */
260
255
  async *branches(patterns) {
261
256
  await this.initializeBranches();
262
- yield* matcher(this._branches.values(), patterns, {
257
+ yield* matcher(this.#branches.values(), patterns, {
263
258
  name: "name"
264
259
  });
265
260
  }
@@ -284,16 +279,11 @@ export class Repository extends OwnedObject {
284
279
  * @return {Branch} newly created branch
285
280
  */
286
281
  addBranch(name, options) {
287
- let branch = this._branches.get(name);
288
- if (branch === undefined) {
289
- branch = new this.branchClass(this, name, options);
290
- }
291
-
292
- return branch;
282
+ return this.#branches.get(name) || new this.branchClass(this, name, options);
293
283
  }
294
284
 
295
285
  _addBranch(branch) {
296
- this._branches.set(branch.name, branch);
286
+ this.#branches.set(branch.name, branch);
297
287
  }
298
288
 
299
289
  /**
@@ -302,7 +292,7 @@ export class Repository extends OwnedObject {
302
292
  * @return {Promise<any>}
303
293
  */
304
294
  async deleteBranch(name) {
305
- this._branches.delete(name);
295
+ this.#branches.delete(name);
306
296
  }
307
297
 
308
298
  /**
@@ -312,7 +302,7 @@ export class Repository extends OwnedObject {
312
302
  */
313
303
  async tag(name) {
314
304
  await this.initializeTags();
315
- return this._tags.get(name);
305
+ return this.#tags.get(name);
316
306
  }
317
307
 
318
308
  /**
@@ -322,7 +312,7 @@ export class Repository extends OwnedObject {
322
312
  async *tags(patterns) {
323
313
  await this.initializeTags();
324
314
 
325
- yield* matcher(this._tags.values(), patterns, {
315
+ yield* matcher(this.#tags.values(), patterns, {
326
316
  name: "name"
327
317
  });
328
318
  }
@@ -335,16 +325,11 @@ export class Repository extends OwnedObject {
335
325
  * @return {Tag} newly created tag
336
326
  */
337
327
  addTag(name, options) {
338
- let tag = this._tags.get(name);
339
- if (tag === undefined) {
340
- tag = new this.tagClass(this, name, options);
341
- }
342
-
343
- return tag;
328
+ return this.#tags.get(name) || new this.tagClass(this, name, options);
344
329
  }
345
330
 
346
331
  _addTag(tag) {
347
- this._tags.set(tag.name, tag);
332
+ this.#tags.set(tag.name, tag);
348
333
  }
349
334
 
350
335
  /**
@@ -370,13 +355,13 @@ export class Repository extends OwnedObject {
370
355
  let pr = this._pullRequests.get(name);
371
356
  if (pr === undefined) {
372
357
  pr = new this.pullRequestClass(name, source, this, options);
373
- this._pullRequests.set(pr.name, pr);
358
+ this.#pullRequests.set(pr.name, pr);
374
359
  }
375
360
  return pr;
376
361
  }
377
362
 
378
363
  _addPullRequest(pr) {
379
- this._pullRequests.set(pr.name, pr);
364
+ this.#pullRequests.set(pr.name, pr);
380
365
  }
381
366
 
382
367
  /**
@@ -386,7 +371,7 @@ export class Repository extends OwnedObject {
386
371
  async *pullRequests() {
387
372
  await this.initializePullRequests();
388
373
 
389
- for (const pr of this._pullRequests.values()) {
374
+ for (const pr of this.#pullRequests.values()) {
390
375
  yield pr;
391
376
  }
392
377
  }
@@ -398,7 +383,7 @@ export class Repository extends OwnedObject {
398
383
  */
399
384
  async pullRequest(name) {
400
385
  await this.initializePullRequests();
401
- return this._pullRequests.get(name);
386
+ return this.#pullRequests.get(name);
402
387
  }
403
388
 
404
389
  /**
@@ -407,7 +392,7 @@ export class Repository extends OwnedObject {
407
392
  * @return {Promise<any>}
408
393
  */
409
394
  async deletePullRequest(name) {
410
- this._pullRequests.delete(name);
395
+ this.#pullRequests.delete(name);
411
396
  }
412
397
 
413
398
  /**
@@ -415,11 +400,11 @@ export class Repository extends OwnedObject {
415
400
  * @param {Hook} hook
416
401
  */
417
402
  addHook(hook) {
418
- this._hooks.push(hook);
403
+ this.#hooks.push(hook);
419
404
  }
420
405
 
421
406
  _addHook(hook) {
422
- this._hooks.push(hook);
407
+ this.#hooks.push(hook);
423
408
  }
424
409
 
425
410
  /**
@@ -436,7 +421,7 @@ export class Repository extends OwnedObject {
436
421
  */
437
422
  async *hooks() {
438
423
  await this.initializeHooks();
439
- for (const hook of this._hooks) {
424
+ for (const hook of this.#hooks) {
440
425
  yield hook;
441
426
  }
442
427
  }
@@ -456,19 +441,19 @@ export class Repository extends OwnedObject {
456
441
  }
457
442
 
458
443
  _addMilestone(milestone) {
459
- this._milestones.set(milestone.name, milestone);
444
+ this.#milestones.set(milestone.name, milestone);
460
445
  }
461
446
 
462
447
  async milestone(name) {
463
- return this._milestones.get(name);
448
+ return this.#milestones.get(name);
464
449
  }
465
450
 
466
451
  _addProject(project) {
467
- this._projects.set(project.name, project);
452
+ this.#projects.set(project.name, project);
468
453
  }
469
454
 
470
455
  async project(name) {
471
- return this._projects.get(name);
456
+ return this.#projects.get(name);
472
457
  }
473
458
 
474
459
  /**
@@ -522,7 +507,7 @@ export class Repository extends OwnedObject {
522
507
 
523
508
  async initializePullRequests() {
524
509
  for await (const pr of this.pullRequestClass.list(this)) {
525
- this._pullRequests.set(pr.name, pr);
510
+ this.#pullRequests.set(pr.name, pr);
526
511
  }
527
512
  }
528
513
  }