npm-pkgbuild 22.0.1 → 22.0.3

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
- * [BUILDAH](#buildah)
101
- * [ContentProvider](#contentprovider)
100
+ * [NPMPackContentProvider](#npmpackcontentprovider)
102
101
  * [Parameters](#parameters-2)
103
102
  * [Properties](#properties-1)
104
- * [propertiesFor](#propertiesfor)
105
- * [Parameters](#parameters-3)
103
+ * [name](#name)
104
+ * [NodeModulesContentProvider](#nodemodulescontentprovider)
105
+ * [Parameters](#parameters-3)
106
+ * [Properties](#properties-2)
106
107
  * [asyncIterator](#asynciterator)
108
+ * [name](#name-1)
107
109
  * [FileContentProvider](#filecontentprovider)
108
110
  * [Parameters](#parameters-4)
109
111
  * [asyncIterator](#asynciterator-1)
110
- * [name](#name)
111
- * [NodeModulesContentProvider](#nodemodulescontentprovider)
112
+ * [name](#name-2)
113
+ * [NFTContentProvider](#nftcontentprovider)
112
114
  * [Parameters](#parameters-5)
113
- * [Properties](#properties-2)
114
115
  * [asyncIterator](#asynciterator-2)
115
- * [name](#name-1)
116
- * [NPMPackContentProvider](#npmpackcontentprovider)
116
+ * [name](#name-3)
117
+ * [ContentProvider](#contentprovider)
117
118
  * [Parameters](#parameters-6)
118
119
  * [Properties](#properties-3)
119
- * [name](#name-2)
120
- * [NFTContentProvider](#nftcontentprovider)
121
- * [Parameters](#parameters-7)
120
+ * [propertiesFor](#propertiesfor)
121
+ * [Parameters](#parameters-7)
122
122
  * [asyncIterator](#asynciterator-3)
123
- * [name](#name-3)
124
123
  * [DEBIAN](#debian)
125
124
  * [hookMapping](#hookmapping)
126
125
  * [attributes](#attributes)
127
126
  * [prepare](#prepare)
128
127
  * [Parameters](#parameters-8)
128
+ * [pkgKeyValuePairOptions](#pkgkeyvaluepairoptions)
129
+ * [attributes](#attributes-1)
129
130
  * [quoteFile](#quotefile)
130
131
  * [Parameters](#parameters-9)
131
132
  * [RPM](#rpm)
132
133
  * [hookMapping](#hookmapping-1)
133
- * [attributes](#attributes-1)
134
+ * [attributes](#attributes-2)
134
135
  * [prepare](#prepare-1)
135
136
  * [Parameters](#parameters-10)
136
- * [pkgKeyValuePairOptions](#pkgkeyvaluepairoptions)
137
- * [attributes](#attributes-2)
138
137
  * [OCI](#oci)
139
138
  * [DOCKER](#docker)
140
139
  * [attributes](#attributes-3)
141
140
  * [prepare](#prepare-2)
142
141
  * [Parameters](#parameters-11)
142
+ * [BUILDAH](#buildah)
143
143
  * [Packager](#packager)
144
144
  * [Parameters](#parameters-12)
145
145
  * [packageName](#packagename)
@@ -257,57 +257,21 @@ Extract package definition from package.json.
257
257
 
258
258
  Returns **AsyncIterable<[PackageDefinition](#packagedefinition)>**&#x20;
259
259
 
260
- ## BUILDAH
261
-
262
- **Extends DOCKER**
263
-
264
- Use buildah @see <https://buildah.io>
260
+ ## NPMPackContentProvider
265
261
 
266
- ## ContentProvider
262
+ **Extends ContentProvider**
267
263
 
268
- Source of package content.
264
+ Content from npm pack.
269
265
 
270
266
  ### Parameters
271
267
 
272
268
  * `definitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
273
- * `entryProperties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**&#x20;
274
- * `directoryProperties` **[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
275
270
 
276
271
  ### Properties
277
272
 
278
273
  * `dir` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
279
274
 
280
- ### propertiesFor
281
-
282
- #### Parameters
283
-
284
- * `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
285
- * `isCollection` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**&#x20;
286
-
287
- Returns **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**&#x20;
288
-
289
- ### asyncIterator
290
-
291
- List all entries.
292
-
293
- Returns **AsyncIterable<(ContentEntry | CollectionEntry)>** all entries
294
-
295
- ## FileContentProvider
296
-
297
- **Extends ContentProvider**
298
-
299
- Content provided form the file system.
300
-
301
- ### Parameters
302
-
303
- * `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;
304
- * `entryProperties` &#x20;
305
- * `directoryProperties` &#x20;
306
-
307
- ### asyncIterator
308
-
309
- Returns **AsyncIterable<(ContentEntry | CollectionEntry)>** all entries
310
-
311
275
  ### name
312
276
 
313
277
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
@@ -322,8 +286,6 @@ Requires .npmrc or NPM\_TOKEN environment
322
286
  ### Parameters
323
287
 
324
288
  * `definitions` &#x20;
325
- * `entryProperties` &#x20;
326
- * `directoryProperties` &#x20;
327
289
 
328
290
  ### Properties
329
291
 
@@ -339,21 +301,19 @@ Returns **AsyncIterable<(ContentEntry | CollectionEntry)>** all entries
339
301
 
340
302
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
341
303
 
342
- ## NPMPackContentProvider
304
+ ## FileContentProvider
343
305
 
344
306
  **Extends ContentProvider**
345
307
 
346
- Content from npm pack.
308
+ Content provided form the file system.
347
309
 
348
310
  ### Parameters
349
311
 
350
- * `definitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
351
- * `entryProperties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** to be set for each entry
352
- * `directoryProperties` &#x20;
312
+ * `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;
353
313
 
354
- ### Properties
314
+ ### asyncIterator
355
315
 
356
- * `dir` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
316
+ Returns **AsyncIterable<(ContentEntry | CollectionEntry)>** all entries
357
317
 
358
318
  ### name
359
319
 
@@ -368,8 +328,6 @@ Content provided form the file system.
368
328
  ### Parameters
369
329
 
370
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;
371
- * `entryProperties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**&#x20;
372
- * `directoryProperties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**&#x20;
373
331
 
374
332
  ### asyncIterator
375
333
 
@@ -379,6 +337,33 @@ Returns **AsyncIterable\<ContentEntry>** all entries
379
337
 
380
338
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
381
339
 
340
+ ## ContentProvider
341
+
342
+ Source of package content.
343
+
344
+ ### Parameters
345
+
346
+ * `definitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
347
+
348
+ ### Properties
349
+
350
+ * `dir` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
351
+
352
+ ### propertiesFor
353
+
354
+ #### Parameters
355
+
356
+ * `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
357
+ * `isCollection` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**&#x20;
358
+
359
+ Returns **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**&#x20;
360
+
361
+ ### asyncIterator
362
+
363
+ List all entries.
364
+
365
+ Returns **AsyncIterable<(ContentEntry | CollectionEntry)>** all entries
366
+
382
367
  ## DEBIAN
383
368
 
384
369
  **Extends Packager**
@@ -405,6 +390,15 @@ Map install hook named from default (arch) to deb.
405
390
 
406
391
  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;
407
392
 
393
+ ## pkgKeyValuePairOptions
394
+
395
+ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
396
+
397
+ ## attributes
398
+
399
+ well known package properties
400
+ <https://www.archlinux.org/pacman/PKGBUILD.5.html>
401
+
408
402
  ## quoteFile
409
403
 
410
404
  ### Parameters
@@ -438,15 +432,6 @@ Check for rpmbuild presence.
438
432
 
439
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
440
434
 
441
- ## pkgKeyValuePairOptions
442
-
443
- Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
444
-
445
- ## attributes
446
-
447
- well known package properties
448
- <https://www.archlinux.org/pacman/PKGBUILD.5.html>
449
-
450
435
  ## OCI
451
436
 
452
437
  **Extends Packager**
@@ -476,6 +461,12 @@ Check for docker presence.
476
461
 
477
462
  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
478
463
 
464
+ ## BUILDAH
465
+
466
+ **Extends DOCKER**
467
+
468
+ Use buildah @see <https://buildah.io>
469
+
479
470
  ## Packager
480
471
 
481
472
  ### Parameters
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-pkgbuild",
3
- "version": "22.0.1",
3
+ "version": "22.0.3",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": false
@@ -4,9 +4,13 @@ import { ContentEntry, CollectionEntry } from "content-entry";
4
4
  /**
5
5
  * Source of package content.
6
6
  * @property {string} dir
7
+ * @property {string} destination
8
+ * @property {Object} defaultProperties
9
+ * @property {Map<Object,Object>} permissions
7
10
  */
8
11
  export class ContentProvider {
9
12
  dir;
13
+ defaultProperties;
10
14
 
11
15
  /**
12
16
  *
@@ -25,10 +29,15 @@ export class ContentProvider {
25
29
  ) {
26
30
  Object.assign(this.defaultProperties, definitions.permissions);
27
31
  } else {
32
+ const entries = definitions.permissions.entries
33
+ ? definitions.permissions.entries()
34
+ : Object.entries(definitions.permissions);
35
+
28
36
  this.permissions = new Map(
29
- Object.entries(definitions.permissions).map(
30
- ([pattern, properties]) => [picomatch(pattern), properties]
31
- )
37
+ entries.map(([pattern, properties]) => [
38
+ picomatch(pattern),
39
+ properties
40
+ ])
32
41
  );
33
42
  }
34
43
  }
@@ -46,12 +55,18 @@ export class ContentProvider {
46
55
  *
47
56
  * @param {string} name
48
57
  * @param {boolean} isCollection
49
- * @returns {Object|undefined}
58
+ * @returns {Object}
50
59
  */
51
60
  propertiesFor(name, isCollection) {
52
61
  if (this.permissions) {
53
62
  for (const [matcher, properties] of this.permissions) {
54
63
  if (matcher(name)) {
64
+ /*console.log("A",name, {
65
+ mode: properties.mode,
66
+ user: properties.user,
67
+ group: properties.group,
68
+ destination: this.destination
69
+ });*/
55
70
  return isCollection && properties.collection
56
71
  ? { ...properties.collection, destination: this.destination }
57
72
  : { ...properties, destination: this.destination };
@@ -241,7 +241,7 @@ package() {
241
241
 
242
242
  if [ "$(ls -A $srcdir)" ]
243
243
  then
244
- cp -rp $srcdir/* "$pkgdir"
244
+ #cp -rp $srcdir/* "$pkgdir"
245
245
  ### PERMISSION ###
246
246
 
247
247
  ${verbose}
@@ -271,48 +271,48 @@ package() {
271
271
  createEntryWhenMissing: () => new ContentEntry(PKGBUILD)
272
272
  });
273
273
 
274
- const permissions = [];
274
+ const install = [];
275
275
 
276
276
  for await (const file of copyEntries(
277
277
  transform(aggregate(sources), transformer),
278
278
  join(staging, "src"),
279
279
  expander
280
280
  )) {
281
- if (file.user || file.group || file.mode) {
282
- permissions.push(file);
281
+ const flags = {
282
+ user: ["-u", value => value],
283
+ group: ["-g", value => value],
284
+ mode: ["-m", value => Number(value & 0o7777).toString(8)]
285
+ };
286
+
287
+ const options = [];
288
+ for (const [name, config] of Object.entries(flags)) {
289
+ const value = await file[name];
290
+
291
+ if (value !== undefined) {
292
+ options.push(`${config[0]} ${config[1](value)}`);
293
+ }
283
294
  }
295
+ install.push(
296
+ ` install ${file.isBlob ? "-D" : "-d"} ${options.join(" ")} \"$srcdir/${file.name}\" \"$pkgdir/${file.destination}\"`
297
+ );
284
298
 
285
299
  if (options.verbose) {
286
300
  console.log(file.destination);
287
301
  }
288
302
  }
289
303
 
290
- if (permissions.length) {
304
+ if (install.length) {
291
305
  const pkgbuild = join(staging, PKGBUILD);
292
- let content = await readFile(pkgbuild, utf8StreamOptions);
306
+ const content = await readFile(pkgbuild, utf8StreamOptions);
293
307
  const markerPos = content.indexOf("### PERMISSION ###");
294
308
 
295
- const flags = {
296
- user: ["-u", f => f.user],
297
- group: ["-g", f => f.group],
298
- mode: ["-m", f => Number(f.mode & 0o7777).toString(8)] // TODO why only 12 bits
299
- };
300
-
301
- content =
309
+ await writeFile(
310
+ pkgbuild,
302
311
  content.substring(0, markerPos) +
303
- permissions
304
- .filter(f => f.isBlob)
305
- .map(f => {
306
- const options = Object.keys(flags)
307
- .filter(name => f[name])
308
- .map(name => `${flags[name][0]} ${flags[name][1](f)}`)
309
- .join(" ");
310
- return ` install -D ${options} \"$srcdir/${f.name}\" \"$pkgdir/${f.destination}\"`;
311
- })
312
- .join("\n") +
313
- content.substring(markerPos + 18);
314
-
315
- await writeFile(pkgbuild, content, utf8StreamOptions);
312
+ install.join("\n") +
313
+ content.substring(markerPos + 18),
314
+ utf8StreamOptions
315
+ );
316
316
  }
317
317
 
318
318
  if (options.verbose) {