npm-pkgbuild 22.1.18 → 22.1.19

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
@@ -97,49 +97,49 @@ See [mf-hosting](https://www.npmjs.com/package/mf-hosting) or [mf-hosting-fronte
97
97
  * [Properties](#properties)
98
98
  * [extractFromPackage](#extractfrompackage)
99
99
  * [Parameters](#parameters-1)
100
- * [NPMPackContentProvider](#npmpackcontentprovider)
100
+ * [BUILDAH](#buildah)
101
+ * [ContentProvider](#contentprovider)
101
102
  * [Parameters](#parameters-2)
102
103
  * [Properties](#properties-1)
103
- * [name](#name)
104
- * [NodeModulesContentProvider](#nodemodulescontentprovider)
105
- * [Parameters](#parameters-3)
106
- * [Properties](#properties-2)
104
+ * [propertiesFor](#propertiesfor)
105
+ * [Parameters](#parameters-3)
107
106
  * [asyncIterator](#asynciterator)
108
- * [name](#name-1)
109
107
  * [FileContentProvider](#filecontentprovider)
110
108
  * [Parameters](#parameters-4)
111
109
  * [asyncIterator](#asynciterator-1)
112
- * [name](#name-2)
113
- * [NFTContentProvider](#nftcontentprovider)
110
+ * [name](#name)
111
+ * [NodeModulesContentProvider](#nodemodulescontentprovider)
114
112
  * [Parameters](#parameters-5)
113
+ * [Properties](#properties-2)
115
114
  * [asyncIterator](#asynciterator-2)
116
- * [name](#name-3)
117
- * [ContentProvider](#contentprovider)
115
+ * [name](#name-1)
116
+ * [NPMPackContentProvider](#npmpackcontentprovider)
118
117
  * [Parameters](#parameters-6)
119
118
  * [Properties](#properties-3)
120
- * [propertiesFor](#propertiesfor)
121
- * [Parameters](#parameters-7)
119
+ * [name](#name-2)
120
+ * [NFTContentProvider](#nftcontentprovider)
121
+ * [Parameters](#parameters-7)
122
122
  * [asyncIterator](#asynciterator-3)
123
+ * [name](#name-3)
123
124
  * [DEBIAN](#debian)
124
125
  * [hookMapping](#hookmapping)
125
126
  * [attributes](#attributes)
126
127
  * [prepare](#prepare)
127
128
  * [Parameters](#parameters-8)
128
- * [pkgKeyValuePairOptions](#pkgkeyvaluepairoptions)
129
- * [attributes](#attributes-1)
130
129
  * [quoteFile](#quotefile)
131
130
  * [Parameters](#parameters-9)
132
131
  * [RPM](#rpm)
133
132
  * [hookMapping](#hookmapping-1)
134
- * [attributes](#attributes-2)
133
+ * [attributes](#attributes-1)
135
134
  * [prepare](#prepare-1)
136
135
  * [Parameters](#parameters-10)
136
+ * [pkgKeyValuePairOptions](#pkgkeyvaluepairoptions)
137
+ * [attributes](#attributes-2)
137
138
  * [OCI](#oci)
138
139
  * [DOCKER](#docker)
139
140
  * [attributes](#attributes-3)
140
141
  * [prepare](#prepare-2)
141
142
  * [Parameters](#parameters-11)
142
- * [BUILDAH](#buildah)
143
143
  * [Packager](#packager)
144
144
  * [Parameters](#parameters-12)
145
145
  * [packageName](#packagename)
@@ -257,39 +257,35 @@ Extract package definition from package.json.
257
257
 
258
258
  Returns **AsyncIterable<[PackageDefinition](#packagedefinition)>**&#x20;
259
259
 
260
- ## NPMPackContentProvider
260
+ ## BUILDAH
261
261
 
262
- **Extends ContentProvider**
262
+ **Extends DOCKER**
263
263
 
264
- Content from npm pack.
264
+ Use buildah @see <https://buildah.io>
265
+
266
+ ## ContentProvider
267
+
268
+ Source of package content.
265
269
 
266
270
  ### Parameters
267
271
 
268
272
  * `definitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
269
- * `entryProperties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** to be set for each entry
270
273
 
271
274
  ### Properties
272
275
 
273
276
  * `dir` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
277
+ * `destination` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
278
+ * `defaultProperties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
279
+ * `permissions` **([Map](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object), [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)> | [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))**&#x20;
274
280
 
275
- ### name
276
-
277
- Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
278
-
279
- ## NodeModulesContentProvider
280
-
281
- **Extends ContentProvider**
282
-
283
- Content from node\_modules.
284
- Requires .npmrc or NPM\_TOKEN environment
285
-
286
- ### Parameters
281
+ ### propertiesFor
287
282
 
288
- * `definitions` &#x20;
283
+ #### Parameters
289
284
 
290
- ### Properties
285
+ * `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
286
+ * `isCollection` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**&#x20;
291
287
 
292
- * `withoutDevelpmentDependencies` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**&#x20;
288
+ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
293
289
 
294
290
  ### asyncIterator
295
291
 
@@ -297,10 +293,6 @@ List all entries.
297
293
 
298
294
  Returns **AsyncIterable<(ContentEntry | CollectionEntry)>** all entries
299
295
 
300
- ### name
301
-
302
- Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
303
-
304
296
  ## FileContentProvider
305
297
 
306
298
  **Extends ContentProvider**
@@ -319,53 +311,67 @@ Returns **AsyncIterable<(ContentEntry | CollectionEntry)>** all entries
319
311
 
320
312
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
321
313
 
322
- ## NFTContentProvider
314
+ ## NodeModulesContentProvider
323
315
 
324
316
  **Extends ContentProvider**
325
317
 
326
- Content provided form the file system.
318
+ Content from node\_modules.
319
+ Requires .npmrc or NPM\_TOKEN environment
327
320
 
328
321
  ### Parameters
329
322
 
330
- * `definitions` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))**&#x20;
323
+ * `definitions` &#x20;
324
+
325
+ ### Properties
326
+
327
+ * `withoutDevelpmentDependencies` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**&#x20;
331
328
 
332
329
  ### asyncIterator
333
330
 
334
- Returns **AsyncIterable\<ContentEntry>** all entries
331
+ List all entries.
332
+
333
+ Returns **AsyncIterable<(ContentEntry | CollectionEntry)>** all entries
335
334
 
336
335
  ### name
337
336
 
338
337
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
339
338
 
340
- ## ContentProvider
339
+ ## NPMPackContentProvider
341
340
 
342
- Source of package content.
341
+ **Extends ContentProvider**
342
+
343
+ Content from npm pack.
343
344
 
344
345
  ### Parameters
345
346
 
346
347
  * `definitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
348
+ * `entryProperties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** to be set for each entry
347
349
 
348
350
  ### Properties
349
351
 
350
352
  * `dir` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
351
- * `destination` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
352
- * `defaultProperties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
353
- * `permissions` **([Map](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object), [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)> | [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))**&#x20;
354
353
 
355
- ### propertiesFor
354
+ ### name
356
355
 
357
- #### Parameters
356
+ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
358
357
 
359
- * `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
360
- * `isCollection` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**&#x20;
358
+ ## NFTContentProvider
361
359
 
362
- Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
360
+ **Extends ContentProvider**
361
+
362
+ Content provided form the file system.
363
+
364
+ ### Parameters
365
+
366
+ * `definitions` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))**&#x20;
363
367
 
364
368
  ### asyncIterator
365
369
 
366
- List all entries.
370
+ Returns **AsyncIterable\<ContentEntry>** all entries
367
371
 
368
- Returns **AsyncIterable<(ContentEntry | CollectionEntry)>** all entries
372
+ ### name
373
+
374
+ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
369
375
 
370
376
  ## DEBIAN
371
377
 
@@ -393,15 +399,6 @@ Map install hook named from default (arch) to deb.
393
399
 
394
400
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>**&#x20;
395
401
 
396
- ## pkgKeyValuePairOptions
397
-
398
- Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
399
-
400
- ## attributes
401
-
402
- well known package properties
403
- <https://www.archlinux.org/pacman/PKGBUILD.5.html>
404
-
405
402
  ## quoteFile
406
403
 
407
404
  ### Parameters
@@ -435,6 +432,15 @@ Check for rpmbuild presence.
435
432
 
436
433
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>** true when rpmbuild executable is present
437
434
 
435
+ ## pkgKeyValuePairOptions
436
+
437
+ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
438
+
439
+ ## attributes
440
+
441
+ well known package properties
442
+ <https://www.archlinux.org/pacman/PKGBUILD.5.html>
443
+
438
444
  ## OCI
439
445
 
440
446
  **Extends Packager**
@@ -464,12 +470,6 @@ Check for docker presence.
464
470
 
465
471
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>** true when docker executable is present
466
472
 
467
- ## BUILDAH
468
-
469
- **Extends DOCKER**
470
-
471
- Use buildah @see <https://buildah.io>
472
-
473
473
  ## Packager
474
474
 
475
475
  ### Parameters
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-pkgbuild",
3
- "version": "22.1.18",
3
+ "version": "22.1.19",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": false
@@ -52,16 +52,15 @@
52
52
  "aggregate-async-iterator": "^1.2.5",
53
53
  "commander": "^15.0.0",
54
54
  "compare-versions": "^6.1.1",
55
- "content-entry": "^15.0.2",
56
- "content-entry-filesystem": "^9.1.2",
57
- "content-entry-transform": "^1.7.6",
55
+ "content-entry": "^15.0.3",
56
+ "content-entry-filesystem": "^9.1.3",
57
+ "content-entry-transform": "^1.7.8",
58
58
  "execa": "^10.0.1",
59
59
  "ini": "^7.0.0",
60
- "iterable-string-interceptor": "^3.0.8",
61
60
  "key-value-transformer": "^3.3.2",
62
61
  "npm-package-walker": "^8.0.11",
63
62
  "npm-packlist": "^11.3.0",
64
- "pacc": "^11.13.0",
63
+ "pacc": "^11.15.0",
65
64
  "package-directory": "^8.2.0",
66
65
  "pacote": "^22.0.0",
67
66
  "picomatch": "^4.0.7",
@@ -69,7 +68,7 @@
69
68
  "uti": "^8.11.3"
70
69
  },
71
70
  "devDependencies": {
72
- "@types/node": "^26.6.1",
71
+ "@types/node": "^26.6.2",
73
72
  "ava": "^8.0.1",
74
73
  "c8": "^12.0.0",
75
74
  "documentation": "^14.0.3",
@@ -15,13 +15,14 @@ import {
15
15
  equalSeparatedKeyValuePairOptions,
16
16
  Uint8ArraysToLines
17
17
  } from "key-value-transformer";
18
+ import { Packager } from "./packager.mjs";
18
19
  import {
19
- Packager,
20
20
  pkgbuild_version_attribute,
21
21
  pkgbuild_description_attribute,
22
22
  pkgbuild_name_attribute,
23
- dependency_attribute_collection_writable
24
- } from "./packager.mjs";
23
+ dependency_attribute_collection_writable,
24
+ arch_attribute_writable
25
+ } from "../types.mjs";
25
26
  import {
26
27
  copyEntries,
27
28
  fieldProvider,
@@ -88,88 +89,154 @@ export class ALPM extends Packager {
88
89
  * https://www.archlinux.org/pacman/PKGBUILD.5.html
89
90
  */
90
91
  static attributes = {
91
- Maintainer: {
92
+ name: {
93
+ ...pkgbuild_name_attribute,
94
+ collection: true,
95
+ externalName: "pkgname"
96
+ },
97
+ description: { ...pkgbuild_description_attribute, externalName: "pkgdesc" },
98
+ version: { ...pkgbuild_version_attribute, externalName: "pkgver" },
99
+ maintainer: {
92
100
  ...string_collection_attribute_writable,
93
- name: "Maintainer",
94
- alias: "maintainer",
95
- prefix: "# "
101
+ externalName: "Maintainer",
102
+ name: "maintainer",
103
+ prefix: "# ",
104
+ skipEmpty: true
96
105
  },
97
106
  packager: {
98
107
  ...string_collection_attribute_writable,
99
108
  name: "packager",
100
- alias: "maintainer"
109
+ alias: "maintainer",
110
+ skipEmpty: true
101
111
  },
102
- pkgname: { ...pkgbuild_name_attribute, name: "pkgname", collection: true },
103
- pkgver: { ...pkgbuild_version_attribute, name: "pkgver" },
104
- pkgrel: {
112
+ release: {
105
113
  ...integer_attribute,
106
- name: "pkgrel",
107
- alias: "release",
114
+ name: "release",
115
+ externalName: "pkgrel",
108
116
  default: 1,
109
117
  mandatory: true
110
118
  },
111
119
  epoch: { ...integer_attribute, name: "epoch", default: 0 },
112
- pkgdesc: { ...pkgbuild_description_attribute, name: "pkgdesc" },
113
- url: { ...string_attribute, name: "url", alias: "homepage" },
120
+ url: {
121
+ ...string_attribute,
122
+ name: "url",
123
+ alias: "homepage",
124
+ skipEmpty: true
125
+ },
114
126
  license: {
115
127
  ...string_collection_attribute_writable,
128
+ separator: undefined,
116
129
  name: "license",
117
- mandatory: true
130
+ skipEmpty: true
131
+ },
132
+ install: { ...string_attribute, name: "install", skipEmpty: true },
133
+ changelog: { ...string_attribute, name: "changelog", skipEmpty: true },
134
+ source: {
135
+ ...string_collection_attribute_writable,
136
+ name: "source",
137
+ separator: undefined,
138
+ skipEmpty: true
118
139
  },
119
- install: { ...string_attribute, name: "install" },
120
- changelog: { ...string_attribute, name: "changelog" },
121
- source: { ...string_collection_attribute_writable, name: "source" },
122
140
  validpgpkeys: {
123
141
  ...string_collection_attribute_writable,
124
- name: "validpgpkeys"
142
+ name: "validpgpkeys",
143
+ separator: undefined,
144
+ skipEmpty: true
125
145
  },
126
- noextract: { ...default_attribute, name: "noextract" },
127
- cksums: { ...string_collection_attribute_writable, name: "cksums" },
128
- md5sums: { ...string_collection_attribute_writable, name: "md5sums" },
129
- sha1sums: { ...string_collection_attribute_writable, name: "sha1sums" },
130
- sha256sums: { ...string_collection_attribute_writable, name: "sha256sums" },
131
- sha384sums: { ...string_collection_attribute_writable, name: "sha384sums" },
132
- sha512sums: { ...string_collection_attribute_writable, name: "sha512sums" },
133
- groups: { ...string_collection_attribute_writable, name: "groups" },
134
- arch: {
146
+ noextract: { ...default_attribute, name: "noextract", skipEmpty: true },
147
+ cksums: {
135
148
  ...string_collection_attribute_writable,
136
- name: "arch",
137
- default: ["any"],
138
- mandatory: true
149
+ name: "cksums",
150
+ skipEmpty: true
151
+ },
152
+ md5sums: {
153
+ ...string_collection_attribute_writable,
154
+ name: "md5sums",
155
+ separator: undefined,
156
+ default: ["SKIP"]
157
+ },
158
+ sha1sums: {
159
+ ...string_collection_attribute_writable,
160
+ name: "sha1sums",
161
+ separator: undefined,
162
+ skipEmpty: true
163
+ },
164
+ sha256sums: {
165
+ ...string_collection_attribute_writable,
166
+ name: "sha256sums",
167
+ separator: undefined,
168
+ skipEmpty: true
169
+ },
170
+ sha384sums: {
171
+ ...string_collection_attribute_writable,
172
+ name: "sha384sums",
173
+ separator: undefined,
174
+ skipEmpty: true
175
+ },
176
+ sha512sums: {
177
+ ...string_collection_attribute_writable,
178
+ name: "sha512sums",
179
+ separator: undefined,
180
+ skipEmpty: true
181
+ },
182
+ groups: {
183
+ ...string_collection_attribute_writable,
184
+ name: "groups",
185
+ separator: undefined,
186
+ skipEmpty: true
187
+ },
188
+ arch: {
189
+ ...arch_attribute_writable,
190
+ default: ["any"]
139
191
  },
140
192
  backup: {
141
193
  ...string_collection_attribute_writable,
142
194
  name: "backup",
195
+ separator: undefined,
143
196
  skipEmpty: true
144
197
  },
145
- depends: {
146
- ...dependency_attribute_collection_writable /*, alias: "dependencies" */,
147
- name: "depends"
198
+ dependencies: {
199
+ ...dependency_attribute_collection_writable,
200
+ name: "dependencies",
201
+ externalName: "depends",
202
+ skipEmpty: true
148
203
  },
149
204
  makedepends: {
150
205
  ...dependency_attribute_collection_writable,
151
- name: "makedepends"
206
+ name: "makedepends",
207
+ skipEmpty: true
152
208
  },
153
209
  checkdepends: {
154
210
  ...dependency_attribute_collection_writable,
155
- name: "checkdepends"
211
+ name: "checkdepends",
212
+ skipEmpty: true
156
213
  },
157
214
  optdepends: {
158
215
  ...dependency_attribute_collection_writable,
159
- name: "optdepends"
216
+ name: "optdepends",
217
+ skipEmpty: true
160
218
  },
161
219
  conflicts: {
162
220
  ...dependency_attribute_collection_writable,
163
221
  name: "conflicts",
164
222
  skipEmpty: true
165
223
  },
166
- provides: { ...dependency_attribute_collection_writable, name: "provides" },
224
+ provides: {
225
+ ...dependency_attribute_collection_writable,
226
+ name: "provides",
227
+ skipEmpty: true
228
+ },
167
229
  replaces: {
168
230
  ...dependency_attribute_collection_writable,
169
231
  name: "replaces",
170
232
  skipEmpty: true
171
233
  },
172
- options: { ...default_attribute, name: "options" }
234
+ options: {
235
+ ...default_attribute,
236
+ name: "options",
237
+ separator: undefined,
238
+ skipEmpty: true
239
+ }
173
240
  };
174
241
 
175
242
  static async prepare(options = {}, variant = {}) {
@@ -209,8 +276,8 @@ export class ALPM extends Packager {
209
276
  }
210
277
 
211
278
  get packageFileName() {
212
- const p = this.properties;
213
- return `${p.name}-${p.version}-${p.release}-${p.arch}${this.fileNameExtension}`;
279
+ const p = this.externalProperties;
280
+ return `${p.pkgname}-${p.pkgver}-${p.pkgrel}-${p.arch}${this.fileNameExtension}`;
214
281
  }
215
282
 
216
283
  dependencyExpression(name, expression) {
@@ -220,9 +287,6 @@ export class ALPM extends Packager {
220
287
  async create(sources, transformer, publishingDetails, options, expander) {
221
288
  const { properties, staging, destination } = await this.prepare(options);
222
289
 
223
- if (properties.source) {
224
- properties.md5sums = ["SKIP"];
225
- }
226
290
  if (properties.hooks) {
227
291
  properties.install = `${properties.name}.install`;
228
292
 
@@ -239,7 +303,15 @@ export class ALPM extends Packager {
239
303
  out.end();
240
304
  }
241
305
 
242
- const depends = this.makeDepends(properties.dependencies).join(" ");
306
+ if (properties.backup?.[0] === "/") {
307
+ properties.backup = properties.backup.replace(/\//, "");
308
+ }
309
+
310
+ const dependencies = properties.dependencies;
311
+ delete properties.dependencies;
312
+ const fp = fieldProvider(properties, this.attributes);
313
+
314
+ const depends = this.makeDepends(dependencies).join(" ");
243
315
  const dependsStatement = depends.length ? `depends=(${depends})` : "";
244
316
  const verbose = options.verbose ? 'ls -laR "$pkgdir"' : "";
245
317
 
@@ -259,12 +331,6 @@ package() {
259
331
  `;
260
332
  }
261
333
 
262
- if (properties.backup?.[0] === "/") {
263
- properties.backup = properties.backup.replace(/\//, "");
264
- }
265
-
266
- const fp = fieldProvider(properties, this.attributes);
267
-
268
334
  transformer.push({
269
335
  name: PKGBUILD,
270
336
  match: entry => entry.name === PKGBUILD,
@@ -287,18 +353,18 @@ package() {
287
353
  join(staging, "src"),
288
354
  expander
289
355
  )) {
290
- if(file.destination !== '../PKGBUILD') {
291
- if (file.owner || file.group) {
292
- permission.push(
293
- ` chown ${[file.owner ?? "", file.group ?? ""].join(":")} \"$pkgdir/${file.destination}\"`
294
- );
295
- }
296
- const mode = (await file.mode) & 0o7777;
297
- if (mode) {
298
- permission.push(
299
- ` chmod ${Number(mode).toString(8)} \"$pkgdir/${file.destination}\"`
300
- );
301
- }
356
+ if (file.destination !== "../PKGBUILD") {
357
+ if (file.owner || file.group) {
358
+ permission.push(
359
+ ` chown ${[file.owner ?? "", file.group ?? ""].join(":")} \"$pkgdir/${file.destination}\"`
360
+ );
361
+ }
362
+ const mode = (await file.mode) & 0o7777;
363
+ if (mode) {
364
+ permission.push(
365
+ ` chmod ${Number(mode).toString(8)} \"$pkgdir/${file.destination}\"`
366
+ );
367
+ }
302
368
  }
303
369
 
304
370
  if (options.verbose) {
@@ -6,7 +6,7 @@ import {
6
6
  yesno_attribute_writable,
7
7
  string_attribute_writable,
8
8
  string_collection_attribute_writable,
9
- toExternal
9
+ types
10
10
  } from "pacc";
11
11
  import { ContentEntry, IteratorContentEntry } from "content-entry";
12
12
  import {
@@ -14,15 +14,15 @@ import {
14
14
  createPropertiesTransformer
15
15
  } from "content-entry-transform";
16
16
  import { keyValueTransformer, Uint8ArraysToLines } from "key-value-transformer";
17
+ import { Packager } from "./packager.mjs";
18
+ import { copyEntries, fieldProvider, aggregate } from "../util.mjs";
17
19
  import {
18
- Packager,
19
20
  pkgbuild_version_attribute,
20
21
  pkgbuild_description_attribute,
21
22
  pkgbuild_name_attribute,
22
23
  dependency_attribute_collection_writable,
23
- architectureType
24
- } from "./packager.mjs";
25
- import { copyEntries, fieldProvider, aggregate } from "../util.mjs";
24
+ arch_attribute_writable
25
+ } from "../types.mjs";
26
26
 
27
27
  const debian_dependency_attribute_collection_writable = {
28
28
  ...dependency_attribute_collection_writable,
@@ -52,85 +52,126 @@ export class DEBIAN extends Packager {
52
52
  * @see https://linux.die.net/man/5/deb-control
53
53
  */
54
54
  static attributes = {
55
- Package: {
55
+ name: {
56
56
  ...pkgbuild_name_attribute,
57
- name: "Package",
58
- set: v => v.toLowerCase()
57
+ externalName: "Package",
58
+ type: types["lowercase-string"]
59
+ },
60
+ description: {
61
+ ...pkgbuild_description_attribute,
62
+ externalName: "Description",
63
+ skipEmpty: true
59
64
  },
60
- Version: { ...pkgbuild_version_attribute, name: "Version" },
61
- Maintainer: {
65
+ version: { ...pkgbuild_version_attribute, externalName: "Version" },
66
+ maintainer: {
62
67
  ...string_attribute_writable,
63
- name: "Maintainer",
64
- alias: "maintainer",
68
+ name: "maintainer",
69
+ externalName: "Maintainer",
65
70
  mandatory: true
66
71
  },
67
- Description: { ...pkgbuild_description_attribute, name: "Description" },
68
- Section: { ...string_attribute_writable, name: "Section", alias: "groups" },
69
- Priority: { ...string_attribute_writable, name: "Priority" },
70
- Essential: { ...yesno_attribute_writable, name: "Essential" },
71
- Origin: { ...string_attribute_writable, name: "Origin" },
72
- Architecture: {
73
- ...string_attribute_writable,
74
- name: "Architecture",
75
- alias: "arch",
72
+ arch: {
73
+ ...arch_attribute_writable,
74
+ externalName: "Architecture",
76
75
  default: "all",
77
- mandatory: true,
78
- type: architectureType,
79
- mapping: { aarch64: "arm64" }
76
+ mapping: { aarch64: "arm64", any: "all" }
77
+ },
78
+ groups: {
79
+ ...string_attribute_writable,
80
+ name: "groups",
81
+ externalName: "Section",
82
+ skipEmpty: true
83
+ },
84
+ Priority: {
85
+ ...string_attribute_writable,
86
+ name: "Priority",
87
+ skipEmpty: true
88
+ },
89
+ Essential: {
90
+ ...yesno_attribute_writable,
91
+ name: "Essential",
92
+ skipEmpty: true
80
93
  },
81
- Homepage: {
94
+ Origin: { ...string_attribute_writable, name: "Origin", skipEmpty: true },
95
+ homepage: {
82
96
  ...string_attribute_writable,
83
- name: "Homepage",
84
- alias: "homepage"
97
+ name: "homepage",
98
+ externalName: "Homepage",
99
+ skipEmpty: true
85
100
  },
86
- Bugs: { ...string_attribute_writable, name: "Bugs", alias: "bugs" },
87
- Depends: {
101
+ Bugs: {
102
+ ...string_attribute_writable,
103
+ name: "bugs",
104
+ externalName: "Bugs",
105
+ skipEmpty: true
106
+ },
107
+ dependencies: {
88
108
  ...debian_dependency_attribute_collection_writable,
89
- name: "Depends"
109
+ name: "dependencies",
110
+ externalName: "Depends",
111
+ skipEmpty: true
90
112
  },
91
113
  "Pre-Depends": {
92
114
  ...debian_dependency_attribute_collection_writable,
93
- name: "Pre-Depends"
115
+ name: "Pre-Depends",
116
+ skipEmpty: true
94
117
  },
95
118
  "Build-Depends": {
96
119
  ...debian_dependency_attribute_collection_writable,
97
- name: "Build-Depends"
120
+ name: "Build-Depends",
121
+ skipEmpty: true
98
122
  },
99
123
  "Build-Depends-Indep": {
100
124
  ...debian_dependency_attribute_collection_writable,
101
- name: "Build-Depends-Indep"
125
+ name: "Build-Depends-Indep",
126
+ skipEmpty: true
102
127
  },
103
128
  "Build-Depends-Arch": {
104
129
  ...debian_dependency_attribute_collection_writable,
105
- name: "Build-Depends-Arch"
130
+ name: "Build-Depends-Arch",
131
+ skipEmpty: true
106
132
  },
107
133
  Recommends: {
108
134
  ...debian_dependency_attribute_collection_writable,
109
- name: "Recommends"
135
+ name: "Recommends",
136
+ skipEmpty: true
110
137
  },
111
138
  Suggests: {
112
139
  ...debian_dependency_attribute_collection_writable,
113
- name: "Suggests"
140
+ name: "Suggests",
141
+ skipEmpty: true
114
142
  },
115
143
  Provides: {
116
144
  ...debian_dependency_attribute_collection_writable,
117
- name: "Provides"
145
+ name: "Provides",
146
+ skipEmpty: true
118
147
  },
119
148
  Breaks: {
120
149
  ...debian_dependency_attribute_collection_writable,
121
- name: "Breaks"
150
+ name: "Breaks",
151
+ skipEmpty: true
122
152
  },
123
153
  Replaces: {
124
154
  ...debian_dependency_attribute_collection_writable,
125
- name: "Replaces"
155
+ name: "Replaces",
156
+ skipEmpty: true
157
+ },
158
+ source: {
159
+ ...string_attribute_writable,
160
+ name: "source",
161
+ externalName: "Source",
162
+ skipEmpty: true
126
163
  },
127
- Source: { ...string_attribute_writable, name: "Source", alias: "source" },
128
164
  Uploaders: {
129
165
  ...string_collection_attribute_writable,
130
166
  name: "Uploaders",
131
- mandatory: false
167
+ mandatory: false,
168
+ skipEmpty: true
132
169
  },
133
- "Installed-Size": { ...integer_attribute_writable, name: "Installed-Size" }
170
+ "Installed-Size": {
171
+ ...integer_attribute_writable,
172
+ name: "Installed-Size",
173
+ skipEmpty: true
174
+ }
134
175
  };
135
176
 
136
177
  /**
@@ -153,13 +194,8 @@ export class DEBIAN extends Packager {
153
194
  }
154
195
 
155
196
  get packageFileName() {
156
- const p = this.properties;
157
-
158
- // TODO utility to provide final values
159
- const arch = toExternal(p.arch, this.attributes.Architecture);
160
-
161
- // @ts-ignore
162
- return `${p.name}_${p.version}_${arch}${this.constructor.fileNameExtension}`;
197
+ const p = this.externalProperties;
198
+ return `${p.Package}_${p.Version}_${p.Architecture}${this.constructor.fileNameExtension}`;
163
199
  }
164
200
 
165
201
  /**
@@ -192,10 +228,7 @@ export class DEBIAN extends Packager {
192
228
  )
193
229
  );
194
230
 
195
- const depends = this.makeDepends(properties.dependencies);
196
- if (depends.length) {
197
- properties.Depends = depends;
198
- }
231
+ properties.dependencies = this.makeDepends(properties.dependencies);
199
232
 
200
233
  const fp = fieldProvider(properties, this.attributes);
201
234
 
@@ -1,7 +1,7 @@
1
1
  import { join } from "node:path";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import { execa } from "execa";
4
- import { string_attribute } from "pacc";
4
+ import { string_attribute_writable, types } from "pacc";
5
5
  import { ContentEntry, IteratorContentEntry } from "content-entry";
6
6
  import { transform } from "content-entry-transform";
7
7
  import { aggregateFifo } from "aggregate-async-iterator";
@@ -12,10 +12,12 @@ import {
12
12
  } from "key-value-transformer";
13
13
  import {
14
14
  Packager,
15
+ } from "./packager.mjs";
16
+ import {
15
17
  pkgbuild_version_attribute,
16
18
  pkgbuild_description_attribute,
17
19
  pkgbuild_name_attribute
18
- } from "./packager.mjs";
20
+ } from "../types.mjs";
19
21
  import {
20
22
  fieldProvider,
21
23
  copyEntries,
@@ -62,12 +64,12 @@ export class DOCKER extends Packager {
62
64
  static attributes = {
63
65
  name: {
64
66
  ...pkgbuild_name_attribute,
65
- set: value => value.toLowerCase()
67
+ type: types["lowercase-string"]
66
68
  },
67
69
  version: pkgbuild_version_attribute,
68
70
  description: pkgbuild_description_attribute,
69
- author: { ...string_attribute, alias: "maintainer" },
70
- workdir: { ...string_attribute, default: "/", mandatory: true }
71
+ maintainer: { ...string_attribute_writable, name: "maintainer", externalName: "author" },
72
+ workdir: { ...string_attribute_writable, default: "/", mandatory: true }
71
73
  };
72
74
 
73
75
  /**
@@ -3,12 +3,11 @@ import { tmpdir } from "node:os";
3
3
  import { mkdtemp, mkdir } from "node:fs/promises";
4
4
  import { createReadStream } from "node:fs";
5
5
  import {
6
+ asArray,
6
7
  expand,
7
8
  expandContextDoubbleCurly,
8
- string_collection_attribute_writable,
9
- name_attribute,
10
- description_attribute,
11
- version_attribute_writable
9
+ attributeIterator,
10
+ iterateToExternal
12
11
  } from "pacc";
13
12
  import { StringContentEntry } from "content-entry";
14
13
  import { publish } from "../publish.mjs";
@@ -58,7 +57,7 @@ export class Packager {
58
57
  return false;
59
58
  }
60
59
 
61
- #properties;
60
+ properties;
62
61
  #prepared;
63
62
 
64
63
  /**
@@ -66,7 +65,21 @@ export class Packager {
66
65
  * @param {Object} properties
67
66
  */
68
67
  constructor(properties) {
69
- this.#properties = { ...properties, type: this.constructor.name };
68
+ this.properties = { ...properties, type: this.constructor.name };
69
+
70
+ for (const [path, attribute] of attributeIterator(
71
+ this.constructor.attributes,
72
+ attribute => attribute.default !== undefined
73
+ )) {
74
+ const name = path.join(".");
75
+ this.properties[name] ??= attribute.default;
76
+ }
77
+ }
78
+
79
+ get externalProperties() {
80
+ return Object.fromEntries([
81
+ ...iterateToExternal(this.properties, this.constructor.attributes)
82
+ ]);
70
83
  }
71
84
 
72
85
  /**
@@ -142,14 +155,15 @@ export class Packager {
142
155
  return [];
143
156
  }
144
157
 
145
- if (Array.isArray(dependencies)) {
158
+ if (Array.isArray(dependencies) || dependencies instanceof Set) {
146
159
  dependencies = Object.fromEntries(
147
- dependencies.map(d => {
160
+ asArray(dependencies).map(d => {
148
161
  const m = d.match(/^([^=<>]+)(.*)/);
149
162
  return [m[1], m[2]];
150
163
  })
151
164
  );
152
165
  }
166
+
153
167
  return Object.entries(dependencies)
154
168
  .filter(filterOutUnwantedDependencies())
155
169
  .map(([name, expression]) => this.dependencyExpression(name, expression));
@@ -165,41 +179,6 @@ export class Packager {
165
179
  return this.constructor.attributes;
166
180
  }
167
181
 
168
- get properties() {
169
- const properties = this.#properties;
170
-
171
- for (const [name, field] of Object.entries(this.attributes)) {
172
- if (field.set) {
173
- if (properties[name] !== undefined) {
174
- properties[name] = field.set(properties[name]);
175
- } else if (
176
- field.alias !== undefined &&
177
- properties[field.alias] !== undefined
178
- ) {
179
- properties[field.alias] = field.set(properties[field.alias]);
180
- }
181
- }
182
-
183
- const e = properties[field.alias || name];
184
-
185
- if (e !== undefined) {
186
- properties[name] = field.set ? field.set(e) : e;
187
- } else {
188
- if (field.default !== undefined) {
189
- const vak = field.alias || name;
190
- if (
191
- (Array.isArray(properties[vak]) && properties[vak].length === 0) ||
192
- properties[vak] === undefined
193
- ) {
194
- properties[vak] = field.default;
195
- }
196
- }
197
- }
198
- }
199
-
200
- return properties;
201
- }
202
-
203
182
  /**
204
183
  * Create tmp directory.
205
184
  * @return {Promise<string>} directory path
@@ -225,9 +204,9 @@ export class Packager {
225
204
 
226
205
  const out = {
227
206
  properties: this.properties,
228
- destination: options.destination || tmpdir,
207
+ destination: options.destination ?? tmpdir,
229
208
  tmpdir,
230
- staging: options.staging || tmpdir
209
+ staging: options.staging ?? tmpdir
231
210
  };
232
211
 
233
212
  // @ts-ignore
@@ -273,65 +252,3 @@ export class Packager {
273
252
  return publish(artifact, publishingDetails, this.properties, logger);
274
253
  }
275
254
  }
276
-
277
- export const pkgbuild_name_attribute = {
278
- ...name_attribute,
279
- alias: "name",
280
- mandatory: true,
281
- pattern: /^[a-z_][a-z0-9_\-]*$/i
282
- };
283
-
284
- export const dependency_type = {
285
- name: "dependency",
286
- primitive: false,
287
- toExternal: (value, attribute) => {
288
- switch (typeof value) {
289
- case "string":
290
- case "undefined":
291
- return value;
292
- }
293
-
294
- if (Array.isArray(value)) {
295
- return value;
296
- }
297
-
298
- return Object.entries(value).map(([name, expression]) =>
299
- typeof expression === "string" ? `${name}${expression}` : name
300
- );
301
- }
302
- };
303
-
304
- export const architectureType = {
305
- name: "dependency",
306
- primitive: true,
307
-
308
- toInternal: (value, attribute) => {
309
- // console.log("architectureType toInternal", value);
310
- return value;
311
- },
312
-
313
- toExternal: (value, attribute) => {
314
- // console.log("architectureType toExternal", value);
315
- return attribute.mapping[value] ?? value;
316
- }
317
- };
318
-
319
- export const dependency_attribute_collection_writable = {
320
- ...string_collection_attribute_writable,
321
- type: dependency_type,
322
- separator: " ",
323
- pattern: /^[a-z_][a-z0-9_\-]*$/i
324
- };
325
-
326
- export const pkgbuild_version_attribute = {
327
- ...version_attribute_writable,
328
- alias: "version",
329
- mandatory: true,
330
- set: v => v.replace("-semantic-release", "")
331
- };
332
-
333
- export const pkgbuild_description_attribute = {
334
- ...description_attribute,
335
- alias: "description",
336
- mandatory: true
337
- };
@@ -3,10 +3,9 @@ import { readFile } from "node:fs/promises";
3
3
  import { cp } from "node:fs/promises";
4
4
  import { execa } from "execa";
5
5
  import {
6
- integer_attribute,
7
- url_attribute,
8
- string_attribute,
9
- string_collection_attribute_writable
6
+ integer_attribute_writable,
7
+ url_attribute_writable,
8
+ string_attribute_writable
10
9
  } from "pacc";
11
10
  import { ContentEntry, IteratorContentEntry } from "content-entry";
12
11
  import { transform } from "content-entry-transform";
@@ -15,12 +14,14 @@ import {
15
14
  colonSeparatedKeyValuePairOptionsDoublingKeys,
16
15
  Uint8ArraysToLines
17
16
  } from "key-value-transformer";
17
+ import { Packager } from "./packager.mjs";
18
18
  import {
19
- Packager,
20
19
  pkgbuild_version_attribute,
21
20
  pkgbuild_description_attribute,
22
- pkgbuild_name_attribute
23
- } from "./packager.mjs";
21
+ pkgbuild_name_attribute,
22
+ arch_attribute_writable,
23
+ dependency_attribute_collection_writable
24
+ } from "../types.mjs";
24
25
  import {
25
26
  copyEntries,
26
27
  fieldProvider,
@@ -61,37 +62,72 @@ export class RPM extends Packager {
61
62
  * @see https://rpm-packaging-guide.github.io
62
63
  */
63
64
  static attributes = {
64
- Name: { ...pkgbuild_name_attribute, name: "Name" },
65
- Summary: { ...pkgbuild_description_attribute, name: "Summary" },
66
- License: {
67
- ...string_attribute,
68
- name: "License",
69
- alias: "license",
65
+ name: { ...pkgbuild_name_attribute, externalName: "Name" },
66
+ description: { ...pkgbuild_description_attribute, externalName: "Summary" },
67
+ license: {
68
+ ...string_attribute_writable,
69
+ name: "license",
70
+ externalName: "License",
70
71
  mandatory: true
71
72
  },
72
- Version: { ...pkgbuild_version_attribute, name: "Version" },
73
- Release: {
74
- ...integer_attribute,
75
- name: "Release",
76
- alias: "release",
73
+ version: { ...pkgbuild_version_attribute, externalName: "Version" },
74
+ release: {
75
+ ...integer_attribute_writable,
76
+ externalName: "Release",
77
+ name: "release",
77
78
  default: 1,
78
79
  mandatory: true
79
80
  },
80
- Source0: { ...string_attribute, name: "Source0", alias: "source" },
81
- Group: { ...string_attribute, name: "Group", alias: "groups" },
82
- Packager: { ...string_attribute, name: "Packager", alias: "maintainer" },
83
- Vendor: { ...string_attribute, name: "Vendor", alias: "vendor" },
84
- BuildArch: {
85
- ...string_attribute,
86
- name: "BuildArch",
87
- alias: "arch",
81
+ source: {
82
+ ...string_attribute_writable,
83
+ externalName: "Source0",
84
+ name: "source",
85
+ skipEmpty: true
86
+ },
87
+ groups: {
88
+ ...string_attribute_writable,
89
+ externalName: "Group",
90
+ name: "groups",
91
+ skipEmpty: true
92
+ },
93
+ maintainer: {
94
+ ...string_attribute_writable,
95
+ name: "maintainer",
96
+ externalName: "Packager"
97
+ },
98
+ vendor: {
99
+ ...string_attribute_writable,
100
+ externalName: "Vendor",
101
+ name: "vendor",
102
+ skipEmpty: true
103
+ },
104
+ arch: {
105
+ ...arch_attribute_writable,
106
+ externalName: "BuildArch",
88
107
  default: "noarch",
89
- mandatory: true
108
+ mapping: { any: "noarch" }
90
109
  },
91
- URL: { ...url_attribute, name: "URL", alias: "homepage" },
92
- Requires: { ...string_collection_attribute_writable, name: "Requires" },
93
- Obsoletes: { ...string_collection_attribute_writable, name: "Obsoletes" },
94
- Conflicts: { ...string_collection_attribute_writable, name: "Conflicts" }
110
+ URL: {
111
+ ...url_attribute_writable,
112
+ name: "URL",
113
+ alias: "homepage",
114
+ skipEmpty: true
115
+ },
116
+ dependencies: {
117
+ ...dependency_attribute_collection_writable,
118
+ externalName: "Requires",
119
+ skipEmpty: true
120
+ },
121
+ Obsoletes: {
122
+ ...dependency_attribute_collection_writable,
123
+ name: "Obsoletes",
124
+ skipEmpty: true
125
+ },
126
+ Conflicts: {
127
+ ...dependency_attribute_collection_writable,
128
+ name: "Conflicts",
129
+ skipEmpty: true
130
+ }
95
131
  };
96
132
 
97
133
  static get workspaceLayout() {
@@ -152,7 +188,7 @@ export class RPM extends Packager {
152
188
  const { properties, tmpdir, staging, destination } =
153
189
  await this.prepare(options);
154
190
 
155
- properties.Requires = this.makeDepends(properties.dependencies);
191
+ properties.dependencies = this.makeDepends(properties.dependencies);
156
192
 
157
193
  if (properties.Packager?.length > 1) {
158
194
  // TODO how to write several Packages ?
package/src/types.mjs ADDED
@@ -0,0 +1,92 @@
1
+ import {
2
+ asArray,
3
+ types,
4
+ string_type,
5
+ string_collection_attribute_writable,
6
+ name_attribute,
7
+ description_attribute,
8
+ version_attribute_writable,
9
+ string_attribute_writable
10
+ } from "pacc";
11
+
12
+ export const dependency_type = {
13
+ ...string_type,
14
+ name: "dependency",
15
+ toExternal: (value, attribute) => {
16
+ switch (typeof value) {
17
+ case "string":
18
+ case "undefined":
19
+ return value;
20
+ }
21
+
22
+ if (Array.isArray(value)) {
23
+ if (value.length === 0 && attribute.skipEmpty) {
24
+ return undefined;
25
+ }
26
+
27
+ return value;
28
+ }
29
+
30
+ if (value instanceof Set) {
31
+ if (value.size === 0 && attribute.skipEmpty) {
32
+ return undefined;
33
+ }
34
+
35
+ return asArray(value);
36
+ }
37
+
38
+ return Object.entries(value).map(([name, expression]) =>
39
+ typeof expression === "string" ? `${name}${expression}` : name
40
+ );
41
+ }
42
+ };
43
+
44
+ export const architecture_type = {
45
+ ...string_type,
46
+ name: "architecture",
47
+
48
+ toInternal: (value, attribute) => {
49
+ return value;
50
+ },
51
+
52
+ toExternal: (value, attribute) => {
53
+ return attribute.mapping?.[value] ?? value;
54
+ }
55
+ };
56
+
57
+ export const arch_attribute_writable = {
58
+ ...string_attribute_writable,
59
+ name: "arch",
60
+ default: "all",
61
+ mandatory: true,
62
+ type: architecture_type
63
+ };
64
+
65
+ export const pkgbuild_name_attribute = {
66
+ ...name_attribute,
67
+ mandatory: true,
68
+ pattern: /^[a-z_][a-z0-9_\-]*$/i
69
+ };
70
+
71
+ export const dependency_attribute_collection_writable = {
72
+ ...string_collection_attribute_writable,
73
+ type: dependency_type,
74
+ separator: undefined,
75
+ pattern: /^[a-z_][a-z0-9_\-]*$/i
76
+ };
77
+
78
+ export const pkgbuild_version_attribute = {
79
+ ...version_attribute_writable,
80
+ mandatory: true,
81
+ type: {
82
+ ...types.string,
83
+ toExternal: (value, attribute) => {
84
+ return value.replace("-semantic-release", "");
85
+ }
86
+ }
87
+ };
88
+
89
+ export const pkgbuild_description_attribute = {
90
+ ...description_attribute,
91
+ mandatory: true
92
+ };
package/src/util.mjs CHANGED
@@ -3,7 +3,7 @@ import { mkdir } from "node:fs/promises";
3
3
  import { pipeline } from "node:stream/promises";
4
4
  import { Readable } from "node:stream";
5
5
  import { createWriteStream } from "node:fs";
6
- import { toExternal, asArray } from "pacc";
6
+ import { asArray, iterateToExternal } from "pacc";
7
7
  import { ContentEntry } from "content-entry";
8
8
  import { aggregateFifo } from "aggregate-async-iterator";
9
9
 
@@ -145,44 +145,21 @@ export function quote(v, qc = "'") {
145
145
  * @returns {Function}
146
146
  */
147
147
  export function fieldProvider(properties, attributes) {
148
- function av(attribute, value) {
149
- return attribute.collection ? asArray(value) : value;
150
- }
148
+ return function* controlProperties(key, value, presentKeys) {
149
+ let filter;
151
150
 
152
- return function* controlProperties(k, v, presentKeys) {
153
- if (k === undefined) {
154
- for (const [name, attribute] of Object.entries(attributes)) {
155
- if (!presentKeys.has(name)) {
156
- let value = properties[attribute.alias || name];
157
- if (
158
- value === undefined ||
159
- (attribute.collection && value.size === 0)
160
- ) {
161
- if (attribute.default === undefined) {
162
- if (attribute.mandatory) {
163
- console.error(`Missing value for mandatory attribute ${name}`);
164
- }
165
- if (attribute.skipEmpty) {
166
- continue;
167
- }
168
- } else {
169
- yield [name, toExternal(attribute.default, attribute)];
170
- }
171
- } else {
172
- if (attribute.mapping) {
173
- const mappedValue = attribute.mapping[value];
174
- if (mappedValue !== undefined) {
175
- value = mappedValue;
176
- }
177
- }
178
-
179
- yield [name, av(attribute, toExternal(value, attribute))];
180
- }
181
- }
182
- }
183
- } else {
184
- const attribute = attributes[k];
185
- yield [k, av(attribute, toExternal(properties[k] ?? v, attribute))];
151
+ if (key) {
152
+ filter = attribute => attribute.name === key;
153
+ }
154
+
155
+ for (const [name, value] of iterateToExternal(
156
+ properties,
157
+ attributes,
158
+ filter
159
+ )) {
160
+ //if (!presentKeys.has(name)) { }
161
+
162
+ yield [name, value];
186
163
  }
187
164
  };
188
165
  }