npm-pkgbuild 18.2.16 → 18.2.17

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
@@ -122,21 +122,21 @@ See [mf-hosting](https://www.npmjs.com/package/mf-hosting) or [mf-hosting-fronte
122
122
  * [asyncIterator](#asynciterator-3)
123
123
  * [DEBIAN](#debian)
124
124
  * [hookMapping](#hookmapping)
125
+ * [attributes](#attributes)
125
126
  * [prepare](#prepare)
126
127
  * [Parameters](#parameters-7)
127
- * [fields](#fields)
128
- * [fields](#fields-1)
129
- * [fields](#fields-2)
130
- * [fields](#fields-3)
131
128
  * [pkgKeyValuePairOptions](#pkgkeyvaluepairoptions)
129
+ * [attributes](#attributes-1)
132
130
  * [quoteFile](#quotefile)
133
131
  * [Parameters](#parameters-8)
134
132
  * [RPM](#rpm)
135
133
  * [hookMapping](#hookmapping-1)
134
+ * [attributes](#attributes-2)
136
135
  * [prepare](#prepare-1)
137
136
  * [Parameters](#parameters-9)
138
137
  * [OCI](#oci)
139
138
  * [DOCKER](#docker)
139
+ * [attributes](#attributes-3)
140
140
  * [prepare](#prepare-2)
141
141
  * [Parameters](#parameters-10)
142
142
  * [BUILDAH](#buildah)
@@ -371,6 +371,11 @@ Create .deb packages
371
371
 
372
372
  Map install hook named from default (arch) to deb.
373
373
 
374
+ ### attributes
375
+
376
+ * **See**: <https://www.debian.org/doc/debian-policy/ch-controlfields.html>
377
+ * **See**: <https://linux.die.net/man/5/deb-control>
378
+
374
379
  ### prepare
375
380
 
376
381
  #### Parameters
@@ -382,28 +387,15 @@ Map install hook named from default (arch) to deb.
382
387
 
383
388
  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;
384
389
 
385
- ## fields
390
+ ## pkgKeyValuePairOptions
386
391
 
387
- * **See**: <https://www.debian.org/doc/debian-policy/ch-controlfields.html>
388
- * **See**: <https://linux.die.net/man/5/deb-control>
392
+ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
389
393
 
390
- ## fields
394
+ ## attributes
391
395
 
392
396
  well known package properties
393
397
  <https://www.archlinux.org/pacman/PKGBUILD.5.html>
394
398
 
395
- ## fields
396
-
397
- * **See**: <https://rpm-packaging-guide.github.io>
398
-
399
- ## fields
400
-
401
- * **See**: <https://docs.docker.com/engine/reference/builder/>
402
-
403
- ## pkgKeyValuePairOptions
404
-
405
- Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
406
-
407
399
  ## quoteFile
408
400
 
409
401
  ### Parameters
@@ -420,6 +412,10 @@ Produce rpm packages.
420
412
 
421
413
  Map install hook named from default (arch) to rpm.
422
414
 
415
+ ### attributes
416
+
417
+ * **See**: <https://rpm-packaging-guide.github.io>
418
+
423
419
  ### prepare
424
420
 
425
421
  Check for rpmbuild presence.
@@ -445,6 +441,10 @@ Low level OCI compatible packager
445
441
 
446
442
  docker image build
447
443
 
444
+ ### attributes
445
+
446
+ * **See**: <https://docs.docker.com/engine/reference/builder/>
447
+
448
448
  ### prepare
449
449
 
450
450
  Check for docker presence.
@@ -679,7 +679,7 @@ Returns **AsyncIterable<[FunctionDecl](#functiondecl)>**&#x20;
679
679
  ### Parameters
680
680
 
681
681
  * `properties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
682
- * `fields` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
682
+ * `attributes` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
683
683
 
684
684
  Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**&#x20;
685
685
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-pkgbuild",
3
- "version": "18.2.16",
3
+ "version": "18.2.17",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": false
@@ -66,6 +66,7 @@
66
66
  "key-value-transformer": "^3.3.0",
67
67
  "npm-package-walker": "^8.0.9",
68
68
  "npm-packlist": "^10.0.1",
69
+ "pacc": "^4.5.3",
69
70
  "package-directory": "^8.1.0",
70
71
  "pacote": "^21.0.0",
71
72
  "tar-stream": "^3.1.7",
@@ -295,6 +295,6 @@ const toBeSkipped = new RegExp(
295
295
  "webpack.config.js",
296
296
  "tsconfig.build.tsbuildinfo"
297
297
  ].join("|") +
298
- ")$|(node_modules/(npm-pkgbuild|@types|node-addon-api|mf-hosting|node-gyp$)|(win32|android|darwin)-(ia32|x64|arm|arm64))",
298
+ ")$|(npm-pkgbuild|@types|node-addon-api|mf-hosting|node-gyp$)|(win32|android|darwin)-(ia32|x64|arm|arm64)",
299
299
  "i"
300
300
  );
@@ -2,6 +2,7 @@ import { join } from "node:path";
2
2
  import { createWriteStream } from "node:fs";
3
3
  import { readFile, writeFile } from "node:fs/promises";
4
4
  import { execa } from "execa";
5
+ import { default_attribute } from "pacc";
5
6
  import { ContentEntry, IteratorContentEntry } from "content-entry";
6
7
  import { transform } from "content-entry-transform";
7
8
  import {
@@ -21,7 +22,6 @@ import {
21
22
  fieldProvider,
22
23
  quote,
23
24
  utf8StreamOptions,
24
- compileFields,
25
25
  normalizeExpression
26
26
  } from "../util.mjs";
27
27
 
@@ -50,10 +50,12 @@ export const pkgKeyValuePairOptions = {
50
50
  };
51
51
 
52
52
  function keyPrefix(key) {
53
- const f = fields[key];
53
+ const f = ARCH.attributes[key];
54
54
  return f?.prefix ? f.prefix + key : key;
55
55
  }
56
56
 
57
+ const default_array_attribute = { type: "string[]" };
58
+
57
59
  const PKGBUILD = "PKGBUILD";
58
60
 
59
61
  let _ext = ".pkg.tar.xz";
@@ -73,9 +75,43 @@ export class ARCH extends Packager {
73
75
  return _ext;
74
76
  }
75
77
 
76
- static get fields() {
77
- return fields;
78
- }
78
+ /**
79
+ * well known package properties
80
+ * https://www.archlinux.org/pacman/PKGBUILD.5.html
81
+ */
82
+ static attributes = {
83
+ Maintainer: { alias: "maintainer", type: "string[]", prefix: "# " },
84
+ packager: { alias: "maintainer", type: "string[]" },
85
+ pkgname: { ...NAME_FIELD, type: "string[]" },
86
+ pkgver: { ...VERSION_FIELD },
87
+ pkgrel: { alias: "release", type: "integer", default: 1, mandatory: true },
88
+ epoch: { type: "integer", default: 0 },
89
+ pkgdesc: { ...DESCRIPTION_FIELD },
90
+ url: { alias: "homepage", type: "string" },
91
+ license: { type: "string[]", mandatory: true },
92
+ install: { type: "string" },
93
+ changelog: { type: "string" },
94
+ source: default_array_attribute,
95
+ validpgpkeys: default_array_attribute,
96
+ noextract: default_attribute,
97
+ cksums: default_array_attribute,
98
+ md5sums: default_array_attribute,
99
+ sha1sums: default_array_attribute,
100
+ sha256sums: default_array_attribute,
101
+ sha384sums: default_array_attribute,
102
+ sha512sums: default_array_attribute,
103
+ groups: default_array_attribute,
104
+ arch: { ...default_array_attribute, default: ["any"], mandatory: true },
105
+ backup: default_array_attribute,
106
+ depends: default_array_attribute,
107
+ makedepends: default_attribute,
108
+ checkdepends: default_attribute,
109
+ optdepends: default_attribute,
110
+ conflicts: default_attribute,
111
+ provides: default_attribute,
112
+ replaces: default_attribute,
113
+ options: default_attribute
114
+ };
79
115
 
80
116
  static async prepare(options = {}, variant = {}) {
81
117
  if (_prepared === undefined) {
@@ -164,7 +200,7 @@ package() {
164
200
  properties.backup = properties.backup.replace(/\//, "");
165
201
  }
166
202
 
167
- const fp = fieldProvider(properties, fields);
203
+ const fp = fieldProvider(properties, this.attributes);
168
204
 
169
205
  transformer.push({
170
206
  name: PKGBUILD,
@@ -207,9 +243,9 @@ package() {
207
243
  ownership
208
244
  .map(
209
245
  f =>
210
- ` chown ${[f.owner || "", f.group || ""].join(":")} \"$pkgdir/${
211
- f.destination
212
- }\"`
246
+ ` chown ${[f.owner || "", f.group || ""].join(
247
+ ":"
248
+ )} \"$pkgdir/${f.destination}\"`
213
249
  )
214
250
  .join("\n") +
215
251
  content.substring(markerPos + 14);
@@ -232,10 +268,14 @@ package() {
232
268
  PACKAGER = person(properties.contributors);
233
269
  }
234
270
 
235
- const makepkg = await execa("makepkg", ["--noprogressbar", "-c", "-f", "-e"], {
236
- cwd: staging,
237
- env: { PKGDEST: destination, PACKAGER }
238
- });
271
+ const makepkg = await execa(
272
+ "makepkg",
273
+ ["--noprogressbar", "-c", "-f", "-e"],
274
+ {
275
+ cwd: staging,
276
+ env: { PKGDEST: destination, PACKAGER }
277
+ }
278
+ );
239
279
 
240
280
  if (options.verbose) {
241
281
  console.log(makepkg.stdout);
@@ -249,44 +289,3 @@ package() {
249
289
  function person(contributors) {
250
290
  return contributors[0].name + " " + contributors[0].email;
251
291
  }
252
-
253
- const default_attribute = { type: "string" };
254
- const default_array_attribute = { type: "string[]" };
255
-
256
- /**
257
- * well known package properties
258
- * https://www.archlinux.org/pacman/PKGBUILD.5.html
259
- */
260
- const fields = compileFields({
261
- Maintainer: { alias: "maintainer", type: "string[]", prefix: "# " },
262
- packager: { alias: "maintainer", type: "string[]" },
263
- pkgname: { ...NAME_FIELD, type: "string[]" },
264
- pkgver: { ...VERSION_FIELD },
265
- pkgrel: { alias: "release", type: "integer", default: 1, mandatory: true },
266
- epoch: { type: "integer", default: 0 },
267
- pkgdesc: { ...DESCRIPTION_FIELD },
268
- url: { alias: "homepage", type: "string" },
269
- license: { type: "string[]", mandatory: true },
270
- install: { type: "string" },
271
- changelog: { type: "string" },
272
- source: default_array_attribute,
273
- validpgpkeys: default_array_attribute,
274
- noextract: default_attribute,
275
- cksums: default_array_attribute,
276
- md5sums: default_array_attribute,
277
- sha1sums: default_array_attribute,
278
- sha256sums: default_array_attribute,
279
- sha384sums: default_array_attribute,
280
- sha512sums: default_array_attribute,
281
- groups: default_array_attribute,
282
- arch: { ...default_array_attribute, default: ["any"], mandatory: true },
283
- backup: default_array_attribute,
284
- depends: default_array_attribute,
285
- makedepends: default_attribute,
286
- checkdepends: default_attribute,
287
- optdepends: default_attribute,
288
- conflicts: default_attribute,
289
- provides: default_attribute,
290
- replaces: default_attribute,
291
- options: default_attribute
292
- });
@@ -14,7 +14,7 @@ import {
14
14
  DESCRIPTION_FIELD,
15
15
  NAME_FIELD
16
16
  } from "./packager.mjs";
17
- import { copyEntries, fieldProvider, compileFields } from "../util.mjs";
17
+ import { copyEntries, fieldProvider } from "../util.mjs";
18
18
 
19
19
  /**
20
20
  * Create .deb packages
@@ -32,9 +32,45 @@ export class DEBIAN extends Packager {
32
32
  return ".deb";
33
33
  }
34
34
 
35
- static get fields() {
36
- return fields;
37
- }
35
+ /**
36
+ * @see https://www.debian.org/doc/debian-policy/ch-controlfields.html
37
+ * @see https://linux.die.net/man/5/deb-control
38
+ */
39
+ static attributes = {
40
+ Package: {
41
+ ...NAME_FIELD,
42
+ set: v => v.toLowerCase()
43
+ },
44
+ Version: { ...VERSION_FIELD },
45
+ Maintainer: { alias: "maintainer", type: "string", mandatory: true },
46
+ Description: { ...DESCRIPTION_FIELD },
47
+ Section: { alias: "groups", type: "string" },
48
+ Priority: { type: "string" },
49
+ Essential: { type: "boolean" },
50
+ Origin: { type: "string" },
51
+ Architecture: {
52
+ alias: "arch",
53
+ type: "string",
54
+ default: "all",
55
+ mandatory: true,
56
+ mapping: { aarch64: "arm64" }
57
+ },
58
+ Homepage: { alias: "homepage", type: "string" },
59
+ Bugs: { alias: "bugs", type: "string" },
60
+ Depends: { type: "string[]" },
61
+ "Pre-Depends": { type: "string[]" },
62
+ "Build-Depends": { type: "string[]" },
63
+ "Build-Depends-Indep": { type: "string[]" },
64
+ "Build-Depends-Arch": { type: "string[]" },
65
+ Recommends: { type: "string[]" },
66
+ Suggests: { type: "string[]" },
67
+ Provides: { type: "string[]" },
68
+ Breaks: { type: "string[]" },
69
+ Replaces: { type: "string[]" },
70
+ Source: { alias: "source", type: "string" },
71
+ Uploaders: { mandatory: false },
72
+ "Installed-Size": {}
73
+ };
38
74
 
39
75
  /**
40
76
  * @param {Object} options
@@ -59,7 +95,7 @@ export class DEBIAN extends Packager {
59
95
  const p = this.properties;
60
96
 
61
97
  // TODO utility to provide final values
62
- const arch = fields.Architecture.mapping[p.arch] || p.arch;
98
+ const arch = this.attributes.Architecture.mapping[p.arch] || p.arch;
63
99
 
64
100
  // @ts-ignore
65
101
  return `${p.name}_${p.version}_${arch}${this.constructor.fileNameExtension}`;
@@ -92,11 +128,11 @@ export class DEBIAN extends Packager {
92
128
  );
93
129
 
94
130
  const depends = this.makeDepends(properties.dependencies);
95
- if(depends.length) {
131
+ if (depends.length) {
96
132
  properties.Depends = depends;
97
133
  }
98
134
 
99
- const fp = fieldProvider(properties, fields);
135
+ const fp = fieldProvider(properties, this.attributes);
100
136
  const debianControlName = "DEBIAN/control";
101
137
 
102
138
  transformer.push({
@@ -137,47 +173,6 @@ export class DEBIAN extends Packager {
137
173
  }
138
174
  }
139
175
 
140
- /**
141
- * @see https://www.debian.org/doc/debian-policy/ch-controlfields.html
142
- * @see https://linux.die.net/man/5/deb-control
143
- */
144
-
145
- const fields = compileFields({
146
- Package: {
147
- ...NAME_FIELD,
148
- set: v => v.toLowerCase()
149
- },
150
- Version: { ...VERSION_FIELD },
151
- Maintainer: { alias: "maintainer", type: "string", mandatory: true },
152
- Description: { ...DESCRIPTION_FIELD },
153
- Section: { alias: "groups", type: "string" },
154
- Priority: { type: "string" },
155
- Essential: { type: "boolean" },
156
- Origin: { type: "string" },
157
- Architecture: {
158
- alias: "arch",
159
- type: "string",
160
- default: "all",
161
- mandatory: true,
162
- mapping: { aarch64: "arm64" }
163
- },
164
- Homepage: { alias: "homepage", type: "string" },
165
- Bugs: { alias: "bugs", type: "string" },
166
- Depends: { type: "string[]" },
167
- "Pre-Depends": { type: "string[]" },
168
- "Build-Depends": { type: "string[]" },
169
- "Build-Depends-Indep": { type: "string[]" },
170
- "Build-Depends-Arch": { type: "string[]" },
171
- Recommends: { type: "string[]" },
172
- Suggests: { type: "string[]" },
173
- Provides: { type: "string[]" },
174
- Breaks: { type: "string[]" },
175
- Replaces: { type: "string[]" },
176
- Source: { alias: "source", type: "string" },
177
- Uploaders: { mandatory: false },
178
- "Installed-Size": {}
179
- });
180
-
181
176
  /*
182
177
  @see https://www.debian.org/doc/debian-policy/ch-archive.html#sections
183
178
  sections:
@@ -20,8 +20,7 @@ import {
20
20
  copyEntries,
21
21
  utf8StreamOptions,
22
22
  quote,
23
- filterOutUnwantedDependencies,
24
- compileFields
23
+ filterOutUnwantedDependencies
25
24
  } from "../util.mjs";
26
25
 
27
26
  const DOCKERFILE = "Dockerfile";
@@ -56,9 +55,16 @@ export class DOCKER extends Packager {
56
55
  return `generate container image with ${this.name}`;
57
56
  }
58
57
 
59
- static get fields() {
60
- return fields;
61
- }
58
+ /**
59
+ * @see {@link https://docs.docker.com/engine/reference/builder/}
60
+ */
61
+ static attributes = {
62
+ name: { ...NAME_FIELD, set: value => value.toLowerCase() },
63
+ version: { ...VERSION_FIELD },
64
+ description: { ...DESCRIPTION_FIELD },
65
+ author: { alias: "maintainer", type: "string" },
66
+ workdir: { type: "string", default: "/", mandatory: true }
67
+ };
62
68
 
63
69
  /**
64
70
  * Check for docker presence.
@@ -112,7 +118,7 @@ export class DOCKER extends Packager {
112
118
  }
113
119
  }
114
120
 
115
- const fp = fieldProvider(properties, fields);
121
+ const fp = fieldProvider(properties, this.attributes);
116
122
 
117
123
  transformer.push({
118
124
  name: DOCKERFILE,
@@ -203,14 +209,3 @@ export class DOCKER extends Packager {
203
209
  }
204
210
  }
205
211
  }
206
-
207
- /**
208
- * @see {@link https://docs.docker.com/engine/reference/builder/}
209
- */
210
- const fields = compileFields({
211
- name: { ...NAME_FIELD, set: value => value.toLowerCase() },
212
- version: { ...VERSION_FIELD },
213
- description: { ...DESCRIPTION_FIELD },
214
- author: { alias: "maintainer", type: "string" },
215
- workdir: { type: "string", default: "/", mandatory: true }
216
- });
@@ -27,9 +27,7 @@ import {
27
27
  * @param {Object} properties
28
28
  */
29
29
  export class Packager {
30
- static get fields() {
31
- return {};
32
- }
30
+ static attributes = {};
33
31
 
34
32
  /**
35
33
  * @return {{named:object,others:string[]}}
@@ -118,7 +116,7 @@ export class Packager {
118
116
  }
119
117
 
120
118
  dependencyExpression(name, expression) {
121
- return expression ? `${name}${expression}`: name;
119
+ return expression ? `${name}${expression}` : name;
122
120
  }
123
121
 
124
122
  makeDepends(dependencies) {
@@ -144,18 +142,18 @@ export class Packager {
144
142
  return this.constructor.fileNameExtension;
145
143
  }
146
144
 
147
- get fields() {
145
+ get attributes() {
148
146
  // @ts-ignore
149
- return this.constructor.fields;
147
+ return this.constructor.attributes;
150
148
  }
151
149
 
152
150
  get properties() {
153
151
  const properties = this.#properties;
154
152
 
155
- for (const field of Object.values(this.fields)) {
153
+ for (const [name, field] of Object.entries(this.attributes)) {
156
154
  if (field.set) {
157
- if (properties[field.name] !== undefined) {
158
- properties[field.name] = field.set(properties[field.name]);
155
+ if (properties[name] !== undefined) {
156
+ properties[name] = field.set(properties[name]);
159
157
  } else if (properties[field.alias] !== undefined) {
160
158
  properties[field.alias] = field.set(properties[field.alias]);
161
159
  }
@@ -164,10 +162,10 @@ export class Packager {
164
162
  const e = properties[field.alias];
165
163
 
166
164
  if (e !== undefined) {
167
- properties[field.name] = field.set ? field.set(e) : e;
165
+ properties[name] = field.set ? field.set(e) : e;
168
166
  } else {
169
167
  if (field.default !== undefined) {
170
- const vak = field.alias || field.name;
168
+ const vak = field.alias || name;
171
169
  if (
172
170
  (Array.isArray(properties[vak]) && properties[vak].length === 0) ||
173
171
  properties[vak] === undefined
@@ -16,12 +16,7 @@ import {
16
16
  DESCRIPTION_FIELD,
17
17
  NAME_FIELD
18
18
  } from "./packager.mjs";
19
- import {
20
- copyEntries,
21
- fieldProvider,
22
- utf8StreamOptions,
23
- compileFields
24
- } from "../util.mjs";
19
+ import { copyEntries, fieldProvider, utf8StreamOptions } from "../util.mjs";
25
20
 
26
21
  /**
27
22
  * @typedef {import('../publish.mjs').PublishingDetail} PublishingDetail
@@ -31,6 +26,8 @@ function quoteFile(name) {
31
26
  return name.match(/\s/) ? '"' + name + '"' : name;
32
27
  }
33
28
 
29
+ const pkglist = { type: "string[]" };
30
+
34
31
  /**
35
32
  * Produce rpm packages.
36
33
  */
@@ -52,9 +49,30 @@ export class RPM extends Packager {
52
49
  return `${p.name}-${p.version}-${p.release}.${p.arch}${this.fileNameExtension}`;
53
50
  }
54
51
 
55
- static get fields() {
56
- return fields;
57
- }
52
+ /**
53
+ * @see https://rpm-packaging-guide.github.io
54
+ */
55
+ static attributes = {
56
+ Name: { ...NAME_FIELD },
57
+ Summary: { ...DESCRIPTION_FIELD },
58
+ License: { alias: "license", type: "string", mandatory: true },
59
+ Version: { ...VERSION_FIELD },
60
+ Release: { alias: "release", type: "integer", default: 1, mandatory: true },
61
+ Source0: { alias: "source", type: "string" },
62
+ Group: { alias: "groups", type: "string" },
63
+ Packager: { alias: "maintainer", type: "string" },
64
+ Vendor: { alias: "vendor", type: "string" },
65
+ BuildArch: {
66
+ alias: "arch",
67
+ default: "noarch",
68
+ type: "string",
69
+ mandatory: true
70
+ },
71
+ URL: { alias: "homepage", type: "string" },
72
+ Requires: pkglist,
73
+ Obsoletes: pkglist,
74
+ Conflicts: pkglist
75
+ };
58
76
 
59
77
  static get workspaceLayout() {
60
78
  return {
@@ -153,7 +171,7 @@ export class RPM extends Packager {
153
171
  }
154
172
  }
155
173
 
156
- const fp = fieldProvider(properties, fields);
174
+ const fp = fieldProvider(properties, this.attributes);
157
175
 
158
176
  for await (const file of copyEntries(
159
177
  transform(aggregateFifo(sources), [
@@ -215,29 +233,3 @@ export class RPM extends Packager {
215
233
  return packageFile;
216
234
  }
217
235
  }
218
-
219
- const pkglist = { type: "string[]" };
220
- /**
221
- * @see https://rpm-packaging-guide.github.io
222
- */
223
- const fields = compileFields({
224
- Name: { ...NAME_FIELD },
225
- Summary: { ...DESCRIPTION_FIELD },
226
- License: { alias: "license", type: "string", mandatory: true },
227
- Version: { ...VERSION_FIELD },
228
- Release: { alias: "release", type: "integer", default: 1, mandatory: true },
229
- Source0: { alias: "source", type: "string" },
230
- Group: { alias: "groups", type: "string" },
231
- Packager: { alias: "maintainer", type: "string" },
232
- Vendor: { alias: "vendor", type: "string" },
233
- BuildArch: {
234
- alias: "arch",
235
- default: "noarch",
236
- type: "string",
237
- mandatory: true
238
- },
239
- URL: { alias: "homepage", type: "string" },
240
- Requires: pkglist,
241
- Obsoletes: pkglist,
242
- Conflicts: pkglist
243
- });
package/src/util.mjs CHANGED
@@ -2,18 +2,9 @@ import { join, dirname } from "node:path";
2
2
  import { mkdir } from "node:fs/promises";
3
3
  import { pipeline } from "node:stream/promises";
4
4
  import { Readable } from "node:stream";
5
-
6
5
  import { createWriteStream } from "node:fs";
7
6
  import { ContentEntry } from "content-entry";
8
7
 
9
- export function compileFields(fields) {
10
- for (const [k, v] of Object.entries(fields)) {
11
- v.name = k;
12
- }
13
-
14
- return fields;
15
- }
16
-
17
8
  /**
18
9
  * @type {BufferEncoding}
19
10
  */
@@ -151,17 +142,17 @@ export function asArray(o) {
151
142
  /**
152
143
  *
153
144
  * @param {Object} properties
154
- * @param {Object} fields
145
+ * @param {Object} attributes
155
146
  * @returns {Function}
156
147
  */
157
- export function fieldProvider(properties, fields) {
148
+ export function fieldProvider(properties, attributes) {
158
149
  function av(field, value) {
159
150
  return field.type.endsWith("]") ? asArray(value) : value;
160
151
  }
161
152
 
162
153
  return function* controlProperties(k, v, presentKeys) {
163
154
  if (k === undefined) {
164
- for (const [name, field] of Object.entries(fields)) {
155
+ for (const [name, field] of Object.entries(attributes)) {
165
156
  if (!presentKeys.has(name)) {
166
157
  let value = properties[field.alias || name];
167
158
  if (value === undefined) {
@@ -185,7 +176,7 @@ export function fieldProvider(properties, fields) {
185
176
  }
186
177
  }
187
178
  } else {
188
- yield [k, av(fields[k], properties[k] || v)];
179
+ yield [k, av(attributes[k], properties[k] || v)];
189
180
  }
190
181
  };
191
182
  }
@@ -31,7 +31,7 @@ export const allInputs: (typeof NPMPackContentProvider | typeof NodeModulesConte
31
31
  /**
32
32
  * All output formats
33
33
  */
34
- export const allOutputs: (typeof ARCH | typeof DOCKER)[];
34
+ export const allOutputs: (typeof OCI | typeof DOCKER)[];
35
35
  export namespace npmArchMapping {
36
36
  let arm64: string;
37
37
  let arm: string;
@@ -71,6 +71,6 @@ import { NPMPackContentProvider } from "./content/npm-pack-content-provider.mjs"
71
71
  import { NodeModulesContentProvider } from "./content/node-modules-content-provider.mjs";
72
72
  import { FileContentProvider } from "./content/file-content-provider.mjs";
73
73
  import { NFTContentProvider } from "./content/nft-content-provider.mjs";
74
- import { ARCH } from "./output/arch.mjs";
74
+ import { OCI } from "./output/oci.mjs";
75
75
  import { DOCKER } from "./output/docker.mjs";
76
76
  import { ContentProvider } from "./content/content-provider.mjs";
@@ -6,7 +6,107 @@ export const pkgKeyValuePairOptions: any;
6
6
  export class ARCH extends Packager {
7
7
  static get description(): string;
8
8
  static get fileNameExtension(): string;
9
- static get fields(): any;
9
+ /**
10
+ * well known package properties
11
+ * https://www.archlinux.org/pacman/PKGBUILD.5.html
12
+ */
13
+ static attributes: {
14
+ Maintainer: {
15
+ alias: string;
16
+ type: string;
17
+ prefix: string;
18
+ };
19
+ packager: {
20
+ alias: string;
21
+ type: string;
22
+ };
23
+ pkgname: {
24
+ type: string;
25
+ alias: string;
26
+ mandatory: boolean;
27
+ };
28
+ pkgver: {
29
+ alias: string;
30
+ type: string;
31
+ mandatory: boolean;
32
+ set: (v: any) => any;
33
+ };
34
+ pkgrel: {
35
+ alias: string;
36
+ type: string;
37
+ default: number;
38
+ mandatory: boolean;
39
+ };
40
+ epoch: {
41
+ type: string;
42
+ default: number;
43
+ };
44
+ pkgdesc: {
45
+ alias: string;
46
+ type: string;
47
+ mandatory: boolean;
48
+ };
49
+ url: {
50
+ alias: string;
51
+ type: string;
52
+ };
53
+ license: {
54
+ type: string;
55
+ mandatory: boolean;
56
+ };
57
+ install: {
58
+ type: string;
59
+ };
60
+ changelog: {
61
+ type: string;
62
+ };
63
+ source: {
64
+ type: string;
65
+ };
66
+ validpgpkeys: {
67
+ type: string;
68
+ };
69
+ noextract: import("pacc").AttributeDefinition;
70
+ cksums: {
71
+ type: string;
72
+ };
73
+ md5sums: {
74
+ type: string;
75
+ };
76
+ sha1sums: {
77
+ type: string;
78
+ };
79
+ sha256sums: {
80
+ type: string;
81
+ };
82
+ sha384sums: {
83
+ type: string;
84
+ };
85
+ sha512sums: {
86
+ type: string;
87
+ };
88
+ groups: {
89
+ type: string;
90
+ };
91
+ arch: {
92
+ default: string[];
93
+ mandatory: boolean;
94
+ type: string;
95
+ };
96
+ backup: {
97
+ type: string;
98
+ };
99
+ depends: {
100
+ type: string;
101
+ };
102
+ makedepends: import("pacc").AttributeDefinition;
103
+ checkdepends: import("pacc").AttributeDefinition;
104
+ optdepends: import("pacc").AttributeDefinition;
105
+ conflicts: import("pacc").AttributeDefinition;
106
+ provides: import("pacc").AttributeDefinition;
107
+ replaces: import("pacc").AttributeDefinition;
108
+ options: import("pacc").AttributeDefinition;
109
+ };
10
110
  static prepare(options?: {}, variant?: {}): Promise<boolean>;
11
111
  get packageFileName(): string;
12
112
  create(sources: any, transformer: any, publishingDetails: any, options: any, expander: any): Promise<string>;
@@ -4,7 +4,102 @@
4
4
  export class DEBIAN extends Packager {
5
5
  static get description(): string;
6
6
  static get fileNameExtension(): string;
7
- static get fields(): any;
7
+ /**
8
+ * @see https://www.debian.org/doc/debian-policy/ch-controlfields.html
9
+ * @see https://linux.die.net/man/5/deb-control
10
+ */
11
+ static attributes: {
12
+ Package: {
13
+ set: (v: any) => any;
14
+ alias: string;
15
+ type: string;
16
+ mandatory: boolean;
17
+ };
18
+ Version: {
19
+ alias: string;
20
+ type: string;
21
+ mandatory: boolean;
22
+ set: (v: any) => any;
23
+ };
24
+ Maintainer: {
25
+ alias: string;
26
+ type: string;
27
+ mandatory: boolean;
28
+ };
29
+ Description: {
30
+ alias: string;
31
+ type: string;
32
+ mandatory: boolean;
33
+ };
34
+ Section: {
35
+ alias: string;
36
+ type: string;
37
+ };
38
+ Priority: {
39
+ type: string;
40
+ };
41
+ Essential: {
42
+ type: string;
43
+ };
44
+ Origin: {
45
+ type: string;
46
+ };
47
+ Architecture: {
48
+ alias: string;
49
+ type: string;
50
+ default: string;
51
+ mandatory: boolean;
52
+ mapping: {
53
+ aarch64: string;
54
+ };
55
+ };
56
+ Homepage: {
57
+ alias: string;
58
+ type: string;
59
+ };
60
+ Bugs: {
61
+ alias: string;
62
+ type: string;
63
+ };
64
+ Depends: {
65
+ type: string;
66
+ };
67
+ "Pre-Depends": {
68
+ type: string;
69
+ };
70
+ "Build-Depends": {
71
+ type: string;
72
+ };
73
+ "Build-Depends-Indep": {
74
+ type: string;
75
+ };
76
+ "Build-Depends-Arch": {
77
+ type: string;
78
+ };
79
+ Recommends: {
80
+ type: string;
81
+ };
82
+ Suggests: {
83
+ type: string;
84
+ };
85
+ Provides: {
86
+ type: string;
87
+ };
88
+ Breaks: {
89
+ type: string;
90
+ };
91
+ Replaces: {
92
+ type: string;
93
+ };
94
+ Source: {
95
+ alias: string;
96
+ type: string;
97
+ };
98
+ Uploaders: {
99
+ mandatory: boolean;
100
+ };
101
+ "Installed-Size": {};
102
+ };
8
103
  /**
9
104
  * @param {Object} options
10
105
  * @param {Object} variant
@@ -3,7 +3,37 @@
3
3
  */
4
4
  export class DOCKER extends Packager {
5
5
  static get description(): string;
6
- static get fields(): any;
6
+ /**
7
+ * @see {@link https://docs.docker.com/engine/reference/builder/}
8
+ */
9
+ static attributes: {
10
+ name: {
11
+ set: (value: any) => any;
12
+ alias: string;
13
+ type: string;
14
+ mandatory: boolean;
15
+ };
16
+ version: {
17
+ alias: string;
18
+ type: string;
19
+ mandatory: boolean;
20
+ set: (v: any) => any;
21
+ };
22
+ description: {
23
+ alias: string;
24
+ type: string;
25
+ mandatory: boolean;
26
+ };
27
+ author: {
28
+ alias: string;
29
+ type: string;
30
+ };
31
+ workdir: {
32
+ type: string;
33
+ default: string;
34
+ mandatory: boolean;
35
+ };
36
+ };
7
37
  /**
8
38
  * Check for docker presence.
9
39
  * @param {Object} options
@@ -13,7 +13,7 @@
13
13
  * @param {Object} properties
14
14
  */
15
15
  export class Packager {
16
- static get fields(): {};
16
+ static attributes: {};
17
17
  /**
18
18
  * @return {{named:object,others:string[]}}
19
19
  */
@@ -43,7 +43,7 @@ export class Packager {
43
43
  dependencyExpression(name: any, expression: any): any;
44
44
  makeDepends(dependencies: any): any[];
45
45
  get fileNameExtension(): any;
46
- get fields(): any;
46
+ get attributes(): any;
47
47
  get properties(): any;
48
48
  /**
49
49
  * Create tmp directory.
@@ -4,7 +4,73 @@
4
4
  export class RPM extends Packager {
5
5
  static get description(): string;
6
6
  static get fileNameExtension(): string;
7
- static get fields(): any;
7
+ /**
8
+ * @see https://rpm-packaging-guide.github.io
9
+ */
10
+ static attributes: {
11
+ Name: {
12
+ alias: string;
13
+ type: string;
14
+ mandatory: boolean;
15
+ };
16
+ Summary: {
17
+ alias: string;
18
+ type: string;
19
+ mandatory: boolean;
20
+ };
21
+ License: {
22
+ alias: string;
23
+ type: string;
24
+ mandatory: boolean;
25
+ };
26
+ Version: {
27
+ alias: string;
28
+ type: string;
29
+ mandatory: boolean;
30
+ set: (v: any) => any;
31
+ };
32
+ Release: {
33
+ alias: string;
34
+ type: string;
35
+ default: number;
36
+ mandatory: boolean;
37
+ };
38
+ Source0: {
39
+ alias: string;
40
+ type: string;
41
+ };
42
+ Group: {
43
+ alias: string;
44
+ type: string;
45
+ };
46
+ Packager: {
47
+ alias: string;
48
+ type: string;
49
+ };
50
+ Vendor: {
51
+ alias: string;
52
+ type: string;
53
+ };
54
+ BuildArch: {
55
+ alias: string;
56
+ default: string;
57
+ type: string;
58
+ mandatory: boolean;
59
+ };
60
+ URL: {
61
+ alias: string;
62
+ type: string;
63
+ };
64
+ Requires: {
65
+ type: string;
66
+ };
67
+ Obsoletes: {
68
+ type: string;
69
+ };
70
+ Conflicts: {
71
+ type: string;
72
+ };
73
+ };
8
74
  static get workspaceLayout(): {
9
75
  named: {
10
76
  staging: string;
package/types/util.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- export function compileFields(fields: any): any;
2
1
  export function filterOutUnwantedDependencies(): ([name, version]: [any, any]) => boolean;
3
2
  export function normalizeExpression(e: any): any;
4
3
  export function mergeDependencies(a: any, b: any): any;
@@ -24,10 +23,10 @@ export function asArray(o: any): any[];
24
23
  /**
25
24
  *
26
25
  * @param {Object} properties
27
- * @param {Object} fields
26
+ * @param {Object} attributes
28
27
  * @returns {Function}
29
28
  */
30
- export function fieldProvider(properties: any, fields: any): Function;
29
+ export function fieldProvider(properties: any, attributes: any): Function;
31
30
  /**
32
31
  * @typedef {Function} Expander
33
32
  * @param {string} path