repository-provider 26.1.1 → 26.1.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": "26.1.1",
3
+ "version": "26.1.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,7 +38,7 @@
38
38
  "documentation": "^13.2.5",
39
39
  "repository-provider-test-support": "^1.9.1",
40
40
  "semantic-release": "^18.0.1",
41
- "typescript": "^4.6.0-dev.20211230"
41
+ "typescript": "^4.6.0-dev.20211231"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=14.18.1"
package/src/attribute.mjs CHANGED
@@ -103,23 +103,25 @@ export function definePropertiesFromOptions(
103
103
  }
104
104
 
105
105
  /**
106
- * get default values.
106
+ * Get default values.
107
107
  * @param {Object} attributes
108
108
  * @return {Object} filled with default values
109
109
  */
110
- export function defaultValues(attributes) {
111
- Object.entries(attributes).reduce((a, c) => {
112
- const [name, attribute] = c;
113
- if (attribute.default !== undefined) {
114
- a.push([
115
- name,
116
- typeof attribute.getDefault
117
- ? attribute.getDefault(attribute, object)
118
- : attribute.default
119
- ]);
120
- }
121
- return a;
122
- }, []);
110
+ export function defaultValues(attributes, object) {
111
+ return Object.fromEntries(
112
+ Object.entries(attributes).reduce((a, c) => {
113
+ const [name, attribute] = c;
114
+
115
+ if (attribute.default !== undefined) {
116
+ a.push([name, attribute.default]);
117
+ }
118
+ else if (attribute.getDefault !== undefined) {
119
+ a.push([name, attribute.getDefault(attribute, object)]);
120
+ }
121
+
122
+ return a;
123
+ }, [])
124
+ );
123
125
  }
124
126
 
125
127
  /**
@@ -126,7 +126,7 @@ export class BaseProvider {
126
126
  /**
127
127
  * Creates a new provider for a given set of options.
128
128
  * @param {Object} options additional options
129
- * @param {string} [options.instanceIdentifier]
129
+ * @param {string} [options.instanceIdentifier] name of the provider instance
130
130
  * @param {Object} env taken from process.env
131
131
  * @return {BaseProvider} newly created provider or undefined if options are not sufficient to construct a provider
132
132
  */
@@ -153,7 +153,7 @@ export class BaseProvider {
153
153
  }
154
154
 
155
155
  /**
156
- * All possible base urls.
156
+ * All supported base urls.
157
157
  * For github something like:
158
158
  * - git@github.com
159
159
  * - git://github.com
@@ -293,6 +293,12 @@ export class BaseProvider {
293
293
  return result;
294
294
  }
295
295
 
296
+ /**
297
+ * Create a repository.
298
+ * @param {string} name of group and repository
299
+ * @param {Object} options
300
+ * @returns {Promise<Repository>}
301
+ */
296
302
  async createRepository(name, options) {
297
303
  const { group, repository } = this.parseName(name);
298
304
  const rg = await this.repositoryGroup(group);
@@ -311,7 +317,7 @@ export class BaseProvider {
311
317
  yield* group[type]();
312
318
  }
313
319
  } else {
314
- for (let pattern of asArray(patterns)) {
320
+ for (const pattern of asArray(patterns)) {
315
321
  const [groupPattern, repoPattern] = stripBaseName(
316
322
  pattern,
317
323
  this.repositoryBases
@@ -387,20 +393,6 @@ export class BaseProvider {
387
393
  yield* this.list("pullRequests", patterns);
388
394
  }
389
395
 
390
- /**
391
- * @return {Class} repository group class used by the Provider
392
- */
393
- get repositoryGroupClass() {
394
- return RepositoryGroup;
395
- }
396
-
397
- /**
398
- * @return {Class} hook class used by the Provider
399
- */
400
- get hookClass() {
401
- return Hook;
402
- }
403
-
404
396
  /**
405
397
  * Deliver the provider name.
406
398
  * @return {string} class name by default
@@ -448,6 +440,34 @@ export class BaseProvider {
448
440
  return json;
449
441
  }
450
442
 
443
+ initializeRepositories() {}
444
+
445
+ info(...args) {
446
+ return this.messageDestination.info(...args);
447
+ }
448
+
449
+ warn(...args) {
450
+ return this.messageDestination.warn(...args);
451
+ }
452
+
453
+ error(...args) {
454
+ return this.messageDestination.error(...args);
455
+ }
456
+
457
+ /**
458
+ * @return {Class} repository group class used by the Provider
459
+ */
460
+ get repositoryGroupClass() {
461
+ return RepositoryGroup;
462
+ }
463
+
464
+ /**
465
+ * @return {Class} hook class used by the Provider
466
+ */
467
+ get hookClass() {
468
+ return Hook;
469
+ }
470
+
451
471
  /**
452
472
  * @return {Class} repository class used by the Provider
453
473
  */
@@ -475,18 +495,4 @@ export class BaseProvider {
475
495
  get pullRequestClass() {
476
496
  return PullRequest;
477
497
  }
478
-
479
- initializeRepositories() {}
480
-
481
- info(...args) {
482
- return this.messageDestination.info(...args);
483
- }
484
-
485
- warn(...args) {
486
- return this.messageDestination.warn(...args);
487
- }
488
-
489
- error(...args) {
490
- return this.messageDestination.error(...args);
491
- }
492
498
  }