repository-provider 26.4.3 → 26.6.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/README.md CHANGED
@@ -146,33 +146,31 @@ console.log(await readme.getString());
146
146
  * [priority](#priority)
147
147
  * [name](#name-1)
148
148
  * [messageDestination](#messagedestination-1)
149
- * [Commit](#commit)
150
- * [Properties](#properties-2)
151
- * [Commit](#commit-1)
152
- * [Parameters](#parameters-32)
153
- * [Properties](#properties-3)
154
- * [CommitResult](#commitresult)
155
- * [Properties](#properties-4)
156
149
  * [Branch](#branch)
157
- * [Parameters](#parameters-33)
158
- * [Properties](#properties-5)
150
+ * [Parameters](#parameters-32)
151
+ * [Properties](#properties-2)
159
152
  * [url](#url-1)
160
153
  * [refType](#reftype)
161
154
  * [isDefault](#isdefault)
162
155
  * [delete](#delete)
163
- * [commit](#commit-2)
164
- * [Parameters](#parameters-34)
156
+ * [commit](#commit)
157
+ * [Parameters](#parameters-33)
165
158
  * [commitIntoPullRequest](#commitintopullrequest)
166
- * [Parameters](#parameters-35)
159
+ * [Parameters](#parameters-34)
167
160
  * [removeEntries](#removeentries)
168
- * [Parameters](#parameters-36)
161
+ * [Parameters](#parameters-35)
169
162
  * [createPullRequest](#createpullrequest)
170
- * [Parameters](#parameters-37)
163
+ * [Parameters](#parameters-36)
171
164
  * [createBranch](#createbranch)
172
- * [Parameters](#parameters-38)
165
+ * [Parameters](#parameters-37)
166
+ * [CommitResult](#commitresult)
167
+ * [Properties](#properties-3)
168
+ * [Commit](#commit-1)
169
+ * [Parameters](#parameters-38)
170
+ * [Properties](#properties-4)
173
171
  * [Hook](#hook)
174
172
  * [Parameters](#parameters-39)
175
- * [Properties](#properties-6)
173
+ * [Properties](#properties-5)
176
174
  * [equals](#equals-2)
177
175
  * [Parameters](#parameters-40)
178
176
  * [toJSON](#tojson-1)
@@ -196,7 +194,7 @@ console.log(await readme.getString());
196
194
  * [Parameters](#parameters-49)
197
195
  * [NamedObject](#namedobject)
198
196
  * [Parameters](#parameters-50)
199
- * [Properties](#properties-7)
197
+ * [Properties](#properties-6)
200
198
  * [equals](#equals-3)
201
199
  * [Parameters](#parameters-51)
202
200
  * [displayName](#displayname)
@@ -205,7 +203,7 @@ console.log(await readme.getString());
205
203
  * [Parameters](#parameters-52)
206
204
  * [PullRequest](#pullrequest)
207
205
  * [Parameters](#parameters-53)
208
- * [Properties](#properties-8)
206
+ * [Properties](#properties-7)
209
207
  * [fullName](#fullname)
210
208
  * [url](#url-2)
211
209
  * [repository](#repository-1)
@@ -232,7 +230,7 @@ console.log(await readme.getString());
232
230
  * [merged](#merged)
233
231
  * [draft](#draft)
234
232
  * [ContentEntry](#contententry)
235
- * [Properties](#properties-9)
233
+ * [Properties](#properties-8)
236
234
  * [Ref](#ref)
237
235
  * [Parameters](#parameters-58)
238
236
  * [equals](#equals-5)
@@ -262,7 +260,7 @@ console.log(await readme.getString());
262
260
  * [isProtected](#isprotected-1)
263
261
  * [RepositoryGroup](#repositorygroup-1)
264
262
  * [Parameters](#parameters-64)
265
- * [Properties](#properties-10)
263
+ * [Properties](#properties-9)
266
264
  * [attributeMapping](#attributemapping-1)
267
265
  * [type](#type)
268
266
  * [url](#url-3)
@@ -270,7 +268,7 @@ console.log(await readme.getString());
270
268
  * [Parameters](#parameters-65)
271
269
  * [Repository](#repository-2)
272
270
  * [Parameters](#parameters-66)
273
- * [Properties](#properties-11)
271
+ * [Properties](#properties-10)
274
272
  * [fullName](#fullname-2)
275
273
  * [slug](#slug)
276
274
  * [provider](#provider-3)
@@ -374,8 +372,9 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
374
372
 
375
373
  * `type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
376
374
  * `writable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**
377
- * `private` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**
375
+ * `private` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** should the value be shown
378
376
  * `description` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
377
+ * `default` **any?** the default value
379
378
 
380
379
  ## definePropertiesFromOptions
381
380
 
@@ -404,7 +403,7 @@ Object.definedProperties(new aClass(),{ with_default: { value: 77 }})
404
403
  * `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** target object
405
404
  * `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** as passed to object constructor (optional, default `{}`)
406
405
  * `properties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object properties (optional, default `{}`)
407
- * `attributes` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `object.constructor.attributes`)
406
+ * `attributes` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `object.constructor.attributes||[]`)
408
407
 
409
408
  ## defaultValues
410
409
 
@@ -905,35 +904,6 @@ Name of the provider
905
904
 
906
905
  to forward info/warn and error messages to
907
906
 
908
- ## Commit
909
-
910
- Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
911
-
912
- ### Properties
913
-
914
- * `message` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
915
- * `updates` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[ContentEntry](#contententry)>**
916
-
917
- ## Commit
918
-
919
- ### Parameters
920
-
921
- * `repository`
922
-
923
- ### Properties
924
-
925
- * `repository` **[Repository](#repository)**
926
- * `message` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
927
- * `sha` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
928
-
929
- ## CommitResult
930
-
931
- Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
932
-
933
- ### Properties
934
-
935
- * `ref` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
936
-
937
907
  ## Branch
938
908
 
939
909
  **Extends Ref**
@@ -1038,6 +1008,26 @@ Simply calls Repository.createBranch() with the receiver as source branch
1038
1008
 
1039
1009
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Branch](#branch)>** newly created branch (or already present old one with the same name)
1040
1010
 
1011
+ ## CommitResult
1012
+
1013
+ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
1014
+
1015
+ ### Properties
1016
+
1017
+ * `ref` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
1018
+
1019
+ ## Commit
1020
+
1021
+ ### Parameters
1022
+
1023
+ * `repository`
1024
+
1025
+ ### Properties
1026
+
1027
+ * `repository` **[Repository](#repository)**
1028
+ * `message` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
1029
+ * `sha` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
1030
+
1041
1031
  ## Hook
1042
1032
 
1043
1033
  **Extends BaseObject**
@@ -1436,7 +1426,7 @@ List entries of the branch.
1436
1426
 
1437
1427
  #### Parameters
1438
1428
 
1439
- * `matchingPatterns` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**
1429
+ * `matchingPatterns` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?**
1440
1430
 
1441
1431
  Returns **AsyncIterator<[ContentEntry](#contententry)>** all matching entries in the branch
1442
1432
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repository-provider",
3
- "version": "26.4.3",
3
+ "version": "26.6.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -30,15 +30,15 @@
30
30
  "lint:tsc": "tsc --allowJs --checkJs --noEmit -module nodenext -t es2022 ./src/*.mjs"
31
31
  },
32
32
  "dependencies": {
33
- "matching-iterator": "^2.0.1"
33
+ "matching-iterator": "^2.0.2"
34
34
  },
35
35
  "devDependencies": {
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.9",
39
+ "repository-provider-test-support": "^1.12.0",
40
40
  "semantic-release": "^19.0.2",
41
- "typescript": "^4.6.0-dev.20220126"
41
+ "typescript": "^4.6.0-dev.20220204"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=14.18.3"
package/src/attribute.mjs CHANGED
@@ -3,8 +3,10 @@
3
3
  *
4
4
  * @property {string} type
5
5
  * @property {boolean} writable
6
- * @property {boolean} private
6
+ * @property {boolean} [private] should the value be shown
7
7
  * @property {string} description
8
+ * @property {any} [default] the default value
9
+ * @property {string|string[]} [env] environment variable use to provide the value
8
10
  */
9
11
 
10
12
  /**
@@ -34,69 +36,68 @@ export function definePropertiesFromOptions(
34
36
  object,
35
37
  options = {},
36
38
  properties = {},
37
- attributes = object.constructor.attributes
39
+ attributes = object.constructor.attributes || []
38
40
  ) {
39
41
  const applyLater = {};
40
42
 
41
- if (attributes !== undefined) {
42
- Object.entries(attributes).forEach(([name, attribute]) => {
43
- const path = name.split(/\./);
44
- const first = path.shift();
45
- const property = properties[first];
46
-
47
- let value = options[name];
48
- if (value === undefined) {
49
- if (attribute.getDefault) {
50
- value = attribute.getDefault(attribute, object);
51
- } else if (
52
- attribute.default !== undefined &&
53
- attribute.default !== getAttribute(object, name)
54
- ) {
55
- value = attribute.default;
56
- }
43
+ Object.entries(attributes).forEach(([name, attribute]) => {
44
+ const path = name.split(/\./);
45
+ const first = path.shift();
46
+ const property = properties[first];
47
+
48
+ let value = getAttribute(options, name);
49
+
50
+ if (value === undefined) {
51
+ if (attribute.getDefault) {
52
+ value = attribute.getDefault(attribute, object);
53
+ } else if (
54
+ attribute.default !== undefined &&
55
+ attribute.default !== getAttribute(object, name)
56
+ ) {
57
+ value = attribute.default;
57
58
  }
59
+ }
58
60
 
59
- if (attribute.set) {
60
- value = attribute.set(value);
61
- } else {
62
- switch (attribute.type) {
63
- case "boolean":
64
- if (value !== undefined) {
65
- value =
66
- value === 0 || value === "0" || value === false ? false : true;
67
- }
68
- break;
69
- }
61
+ if (attribute.set) {
62
+ value = attribute.set(value);
63
+ } else {
64
+ switch (attribute.type) {
65
+ case "boolean":
66
+ if (value !== undefined) {
67
+ value =
68
+ value === 0 || value === "0" || value === false ? false : true;
69
+ }
70
+ break;
70
71
  }
72
+ }
71
73
 
72
- if (path.length) {
73
- const remaining = path.join(".");
74
- if (property) {
75
- setAttribute(property.value, remaining, value);
76
- } else {
77
- const slice = {};
78
- setAttribute(slice, remaining, value);
79
- properties[first] = { configurable: true, value: slice };
80
- }
74
+ if (path.length) {
75
+ const remaining = path.join(".");
76
+ if (property) {
77
+ setAttribute(property.value, remaining, value);
81
78
  } else {
82
- if (value !== undefined) {
83
- const op = Object.getOwnPropertyDescriptor(
84
- object.constructor.prototype,
85
- first
79
+ const slice = {};
80
+ setAttribute(slice, remaining, value);
81
+ properties[first] = { configurable: true, value: slice };
82
+ }
83
+ } else {
84
+ if (value !== undefined) {
85
+ const op = Object.getOwnPropertyDescriptor(
86
+ object.constructor.prototype,
87
+ first
88
+ );
89
+
90
+ if ((op && op.set) || (property && property.set)) {
91
+ applyLater[first] = value;
92
+ } else {
93
+ properties[first] = Object.assign(
94
+ { value, writable: attribute.writable },
95
+ property
86
96
  );
87
-
88
- if ((op && op.set) || (property && property.set)) {
89
- applyLater[first] = value;
90
- } else {
91
- properties[first] = Object.assign(
92
- { value, writable: attribute.writable },
93
- property
94
- );
95
- }
96
97
  }
97
98
  }
98
- });
99
- }
99
+ }
100
+ });
100
101
 
101
102
  Object.defineProperties(object, properties);
102
103
  Object.assign(object, applyLater);
@@ -114,8 +115,7 @@ export function defaultValues(attributes, object) {
114
115
 
115
116
  if (attribute.default !== undefined) {
116
117
  a.push([name, attribute.default]);
117
- }
118
- else if (attribute.getDefault !== undefined) {
118
+ } else if (attribute.getDefault !== undefined) {
119
119
  a.push([name, attribute.getDefault(attribute, object)]);
120
120
  }
121
121
 
@@ -155,6 +155,10 @@ export function setAttribute(object, name, value) {
155
155
  export function getAttribute(object, name) {
156
156
  let value = object;
157
157
 
158
+ if(value && value[name] !== undefined) {
159
+ return value[name];
160
+ }
161
+
158
162
  for (const p of name.split(/\./)) {
159
163
  if (value === undefined) {
160
164
  break;
@@ -65,8 +65,8 @@ export class BaseObject {
65
65
 
66
66
  /**
67
67
  * Creates an instance of BaseObject.
68
- * @param {*} options
69
- * @param {*} additionalProperties
68
+ * @param {object} options
69
+ * @param {object} additionalProperties
70
70
  */
71
71
  constructor(options, additionalProperties) {
72
72
  definePropertiesFromOptions(
@@ -1,5 +1,4 @@
1
1
  import { asArray, stripBaseName } from "./util.mjs";
2
- import { definePropertiesFromOptions } from "./attribute.mjs";
3
2
  import { PullRequest } from "./pull-request.mjs";
4
3
  import { RepositoryGroup } from "./repository-group.mjs";
5
4
  import { Repository } from "./repository.mjs";
@@ -8,6 +7,7 @@ import { Tag } from "./tag.mjs";
8
7
  import { Hook } from "./hook.mjs";
9
8
  import { Project } from "./project.mjs";
10
9
  import { Milestone } from "./milestone.mjs";
10
+ import { BaseObject } from "./base-object.mjs";
11
11
 
12
12
  /**
13
13
  * @typedef {Object} MessageDestination
@@ -20,7 +20,7 @@ import { Milestone } from "./milestone.mjs";
20
20
  /**
21
21
  * @property {MessageDestination} messageDestination
22
22
  */
23
- export class BaseProvider {
23
+ export class BaseProvider extends BaseObject {
24
24
  /**
25
25
  * @return {string} identifier for environment options
26
26
  */
@@ -87,6 +87,7 @@ export class BaseProvider {
87
87
 
88
88
  static get attributes() {
89
89
  return {
90
+ ...super.attributes,
90
91
  /**
91
92
  * In case there are several provider able to support a given source which one sould be used ?
92
93
  * this defines the order
@@ -100,7 +101,8 @@ export class BaseProvider {
100
101
  * Name of the provider
101
102
  */
102
103
  name: {
103
- type: "string"
104
+ type: "string",
105
+ env: ["{{instanceIdentifier}}NAME"]
104
106
  },
105
107
 
106
108
  url: {
@@ -141,10 +143,6 @@ export class BaseProvider {
141
143
  }
142
144
  }
143
145
 
144
- constructor(options, properties) {
145
- definePropertiesFromOptions(this, options, properties);
146
- }
147
-
148
146
  /**
149
147
  * @return {boolean} true if other provider is the same as the receiver
150
148
  */
@@ -401,6 +399,11 @@ export class BaseProvider {
401
399
  return this.constructor.name;
402
400
  }
403
401
 
402
+ get fullName()
403
+ {
404
+ return this.name;
405
+ }
406
+
404
407
  /**
405
408
  * We are our own provider.
406
409
  * @return {BaseProvider} this
package/src/branch.mjs CHANGED
@@ -1,17 +1,8 @@
1
1
  import { Ref } from "./ref.mjs";
2
2
  import { PullRequest } from "./pull-request.mjs";
3
3
  import { Repository } from "./repository.mjs";
4
+ import { Commit } from "./commit.mjs";
4
5
 
5
- /**
6
- * @typedef {Object} Commit
7
- * @property {string} message
8
- * @property {ContentEntry[]} updates
9
- */
10
-
11
- /**
12
- * @typedef {Object} CommitResult
13
- * @property {string} ref
14
- */
15
6
 
16
7
  /**
17
8
  * Abstract branch.
package/src/commit.mjs CHANGED
@@ -1,3 +1,10 @@
1
+
2
+
3
+ /**
4
+ * @typedef {Object} CommitResult
5
+ * @property {string} ref
6
+ */
7
+
1
8
  /**
2
9
  * @property {Repository} repository
3
10
  * @property {string} message
@@ -50,9 +50,7 @@ export class MultiGroupProvider extends BaseProvider {
50
50
  if (rg !== undefined) {
51
51
  const r = await rg.repository(repository);
52
52
  if (r !== undefined) {
53
- return r.branch(
54
- branch === undefined ? r.defaultBranchName : branch
55
- );
53
+ return r.branch( r.defaultBranchName || branch);
56
54
  }
57
55
  }
58
56
  }
package/src/ref.mjs CHANGED
@@ -1,9 +1,11 @@
1
1
  import { NamedObject } from "./named-object.mjs";
2
+
2
3
  /**
3
4
  * @typedef {Object} ContentEntry
4
5
  * @property {string} name
5
6
  *
6
7
  */
8
+
7
9
  /**
8
10
  * Base for Branch and Tag
9
11
  */
@@ -59,7 +61,7 @@ export class Ref extends NamedObject {
59
61
 
60
62
  /**
61
63
  * List entries of the branch.
62
- * @param {string[]} matchingPatterns
64
+ * @param {string[]} [matchingPatterns]
63
65
  * @return {AsyncIterator<ContentEntry>} all matching entries in the branch
64
66
  */
65
67
  async *entries(matchingPatterns) {}