npm-pkgbuild 22.1.16 → 22.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-pkgbuild",
3
- "version": "22.1.16",
3
+ "version": "22.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": false
@@ -61,7 +61,7 @@
61
61
  "key-value-transformer": "^3.3.2",
62
62
  "npm-package-walker": "^8.0.11",
63
63
  "npm-packlist": "^11.3.0",
64
- "pacc": "^11.12.2",
64
+ "pacc": "^11.12.6",
65
65
  "package-directory": "^8.2.0",
66
66
  "pacote": "^22.0.0",
67
67
  "picomatch": "^4.0.7",
@@ -69,7 +69,7 @@
69
69
  "uti": "^8.11.3"
70
70
  },
71
71
  "devDependencies": {
72
- "@types/node": "^26.5.1",
72
+ "@types/node": "^26.6.1",
73
73
  "ava": "^8.0.1",
74
74
  "c8": "^12.0.0",
75
75
  "documentation": "^14.0.3",
@@ -15,13 +15,13 @@ 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
23
  dependency_attribute_collection_writable
24
- } from "./packager.mjs";
24
+ } from "../types.mjs";
25
25
  import {
26
26
  copyEntries,
27
27
  fieldProvider,
@@ -88,49 +88,94 @@ export class ALPM extends Packager {
88
88
  * https://www.archlinux.org/pacman/PKGBUILD.5.html
89
89
  */
90
90
  static attributes = {
91
- Maintainer: {
91
+ name: {
92
+ ...pkgbuild_name_attribute,
93
+ collection: true,
94
+ externalName: "pkgname"
95
+ },
96
+ description: { ...pkgbuild_description_attribute, externalName: "pkgdesc" },
97
+ version: { ...pkgbuild_version_attribute, externalName: "pkgver" },
98
+ maintainer: {
92
99
  ...string_collection_attribute_writable,
93
- name: "Maintainer",
94
- alias: "maintainer",
95
- prefix: "# "
100
+ externalName: "Maintainer",
101
+ name: "maintainer",
102
+ prefix: "# ",
103
+ skipEmpty: true
96
104
  },
97
105
  packager: {
98
106
  ...string_collection_attribute_writable,
99
107
  name: "packager",
100
- alias: "maintainer"
108
+ alias: "maintainer",
109
+ skipEmpty: true
101
110
  },
102
- pkgname: { ...pkgbuild_name_attribute, name: "pkgname", collection: true },
103
- pkgver: { ...pkgbuild_version_attribute, name: "pkgver" },
104
- pkgrel: {
111
+ release: {
105
112
  ...integer_attribute,
106
- name: "pkgrel",
107
- alias: "release",
113
+ name: "release",
114
+ externalName: "pkgrel",
108
115
  default: 1,
109
116
  mandatory: true
110
117
  },
111
118
  epoch: { ...integer_attribute, name: "epoch", default: 0 },
112
- pkgdesc: { ...pkgbuild_description_attribute, name: "pkgdesc" },
113
- url: { ...string_attribute, name: "url", alias: "homepage" },
119
+ url: {
120
+ ...string_attribute,
121
+ name: "url",
122
+ alias: "homepage",
123
+ skipEmpty: true
124
+ },
114
125
  license: {
115
126
  ...string_collection_attribute_writable,
116
127
  name: "license",
117
- mandatory: true
128
+ skipEmpty: true
129
+ },
130
+ install: { ...string_attribute, name: "install", skipEmpty: true },
131
+ changelog: { ...string_attribute, name: "changelog", skipEmpty: true },
132
+ source: {
133
+ ...string_collection_attribute_writable,
134
+ name: "source",
135
+ skipEmpty: true
118
136
  },
119
- install: { ...string_attribute, name: "install" },
120
- changelog: { ...string_attribute, name: "changelog" },
121
- source: { ...string_collection_attribute_writable, name: "source" },
122
137
  validpgpkeys: {
123
138
  ...string_collection_attribute_writable,
124
- name: "validpgpkeys"
139
+ name: "validpgpkeys",
140
+ skipEmpty: true
141
+ },
142
+ noextract: { ...default_attribute, name: "noextract", skipEmpty: true },
143
+ cksums: {
144
+ ...string_collection_attribute_writable,
145
+ name: "cksums",
146
+ skipEmpty: true
147
+ },
148
+ md5sums: {
149
+ ...string_collection_attribute_writable,
150
+ name: "md5sums",
151
+ default: ["SKIP"]
152
+ // skipEmpty: true
153
+ },
154
+ sha1sums: {
155
+ ...string_collection_attribute_writable,
156
+ name: "sha1sums",
157
+ skipEmpty: true
158
+ },
159
+ sha256sums: {
160
+ ...string_collection_attribute_writable,
161
+ name: "sha256sums",
162
+ skipEmpty: true
163
+ },
164
+ sha384sums: {
165
+ ...string_collection_attribute_writable,
166
+ name: "sha384sums",
167
+ skipEmpty: true
168
+ },
169
+ sha512sums: {
170
+ ...string_collection_attribute_writable,
171
+ name: "sha512sums",
172
+ skipEmpty: true
173
+ },
174
+ groups: {
175
+ ...string_collection_attribute_writable,
176
+ name: "groups",
177
+ skipEmpty: true
125
178
  },
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
179
  arch: {
135
180
  ...string_collection_attribute_writable,
136
181
  name: "arch",
@@ -142,34 +187,43 @@ export class ALPM extends Packager {
142
187
  name: "backup",
143
188
  skipEmpty: true
144
189
  },
145
- depends: {
146
- ...dependency_attribute_collection_writable /*, alias: "dependencies" */,
147
- name: "depends"
190
+ dependencies: {
191
+ ...dependency_attribute_collection_writable,
192
+ name: "dependencies",
193
+ externalName: "depends",
194
+ skipEmpty: true
148
195
  },
149
196
  makedepends: {
150
197
  ...dependency_attribute_collection_writable,
151
- name: "makedepends"
198
+ name: "makedepends",
199
+ skipEmpty: true
152
200
  },
153
201
  checkdepends: {
154
202
  ...dependency_attribute_collection_writable,
155
- name: "checkdepends"
203
+ name: "checkdepends",
204
+ skipEmpty: true
156
205
  },
157
206
  optdepends: {
158
207
  ...dependency_attribute_collection_writable,
159
- name: "optdepends"
208
+ name: "optdepends",
209
+ skipEmpty: true
160
210
  },
161
211
  conflicts: {
162
212
  ...dependency_attribute_collection_writable,
163
213
  name: "conflicts",
164
214
  skipEmpty: true
165
215
  },
166
- provides: { ...dependency_attribute_collection_writable, name: "provides" },
216
+ provides: {
217
+ ...dependency_attribute_collection_writable,
218
+ name: "provides",
219
+ skipEmpty: true
220
+ },
167
221
  replaces: {
168
222
  ...dependency_attribute_collection_writable,
169
223
  name: "replaces",
170
224
  skipEmpty: true
171
225
  },
172
- options: { ...default_attribute, name: "options" }
226
+ options: { ...default_attribute, name: "options", skipEmpty: true }
173
227
  };
174
228
 
175
229
  static async prepare(options = {}, variant = {}) {
@@ -209,8 +263,8 @@ export class ALPM extends Packager {
209
263
  }
210
264
 
211
265
  get packageFileName() {
212
- const p = this.properties;
213
- return `${p.name}-${p.version}-${p.release}-${p.arch}${this.fileNameExtension}`;
266
+ const p = this.externalProperties;
267
+ return `${p.pkgname}-${p.pkgver}-${p.pkgrel}-${p.arch}${this.fileNameExtension}`;
214
268
  }
215
269
 
216
270
  dependencyExpression(name, expression) {
@@ -220,9 +274,9 @@ export class ALPM extends Packager {
220
274
  async create(sources, transformer, publishingDetails, options, expander) {
221
275
  const { properties, staging, destination } = await this.prepare(options);
222
276
 
223
- if (properties.source) {
277
+ /*if (properties.source) {
224
278
  properties.md5sums = ["SKIP"];
225
- }
279
+ }*/
226
280
  if (properties.hooks) {
227
281
  properties.install = `${properties.name}.install`;
228
282
 
@@ -287,18 +341,18 @@ package() {
287
341
  join(staging, "src"),
288
342
  expander
289
343
  )) {
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
- }
344
+ if (file.destination !== "../PKGBUILD") {
345
+ if (file.owner || file.group) {
346
+ permission.push(
347
+ ` chown ${[file.owner ?? "", file.group ?? ""].join(":")} \"$pkgdir/${file.destination}\"`
348
+ );
349
+ }
350
+ const mode = (await file.mode) & 0o7777;
351
+ if (mode) {
352
+ permission.push(
353
+ ` chmod ${Number(mode).toString(8)} \"$pkgdir/${file.destination}\"`
354
+ );
355
+ }
302
356
  }
303
357
 
304
358
  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
24
  architectureType
24
- } from "./packager.mjs";
25
- import { copyEntries, fieldProvider, aggregate } from "../util.mjs";
25
+ } from "../types.mjs";
26
26
 
27
27
  const debian_dependency_attribute_collection_writable = {
28
28
  ...dependency_attribute_collection_writable,
@@ -52,85 +52,129 @@ 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
59
  },
60
- Version: { ...pkgbuild_version_attribute, name: "Version" },
61
- Maintainer: {
60
+ description: {
61
+ ...pkgbuild_description_attribute,
62
+ externalName: "Description",
63
+ skipEmpty: true
64
+ },
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: {
72
+ arch: {
73
73
  ...string_attribute_writable,
74
- name: "Architecture",
75
- alias: "arch",
74
+ name: "arch",
75
+ externalName: "Architecture",
76
76
  default: "all",
77
77
  mandatory: true,
78
78
  type: architectureType,
79
79
  mapping: { aarch64: "arm64" }
80
80
  },
81
- Homepage: {
81
+ groups: {
82
+ ...string_attribute_writable,
83
+ name: "groups",
84
+ externalName: "Section",
85
+ skipEmpty: true
86
+ },
87
+ Priority: {
88
+ ...string_attribute_writable,
89
+ name: "Priority",
90
+ skipEmpty: true
91
+ },
92
+ Essential: {
93
+ ...yesno_attribute_writable,
94
+ name: "Essential",
95
+ skipEmpty: true
96
+ },
97
+ Origin: { ...string_attribute_writable, name: "Origin", skipEmpty: true },
98
+ homepage: {
82
99
  ...string_attribute_writable,
83
- name: "Homepage",
84
- alias: "homepage"
100
+ name: "homepage",
101
+ externalName: "Homepage",
102
+ skipEmpty: true
85
103
  },
86
- Bugs: { ...string_attribute_writable, name: "Bugs", alias: "bugs" },
87
- Depends: {
104
+ Bugs: {
105
+ ...string_attribute_writable,
106
+ name: "bugs",
107
+ externalName: "Bugs",
108
+ skipEmpty: true
109
+ },
110
+ dependencies: {
88
111
  ...debian_dependency_attribute_collection_writable,
89
- name: "Depends"
112
+ name: "dependencies",
113
+ externalName: "Depends",
114
+ skipEmpty: true
90
115
  },
91
116
  "Pre-Depends": {
92
117
  ...debian_dependency_attribute_collection_writable,
93
- name: "Pre-Depends"
118
+ name: "Pre-Depends",
119
+ skipEmpty: true
94
120
  },
95
121
  "Build-Depends": {
96
122
  ...debian_dependency_attribute_collection_writable,
97
- name: "Build-Depends"
123
+ name: "Build-Depends",
124
+ skipEmpty: true
98
125
  },
99
126
  "Build-Depends-Indep": {
100
127
  ...debian_dependency_attribute_collection_writable,
101
- name: "Build-Depends-Indep"
128
+ name: "Build-Depends-Indep",
129
+ skipEmpty: true
102
130
  },
103
131
  "Build-Depends-Arch": {
104
132
  ...debian_dependency_attribute_collection_writable,
105
- name: "Build-Depends-Arch"
133
+ name: "Build-Depends-Arch",
134
+ skipEmpty: true
106
135
  },
107
136
  Recommends: {
108
137
  ...debian_dependency_attribute_collection_writable,
109
- name: "Recommends"
138
+ name: "Recommends",
139
+ skipEmpty: true
110
140
  },
111
141
  Suggests: {
112
142
  ...debian_dependency_attribute_collection_writable,
113
- name: "Suggests"
143
+ name: "Suggests",
144
+ skipEmpty: true
114
145
  },
115
146
  Provides: {
116
147
  ...debian_dependency_attribute_collection_writable,
117
- name: "Provides"
148
+ name: "Provides",
149
+ skipEmpty: true
118
150
  },
119
151
  Breaks: {
120
152
  ...debian_dependency_attribute_collection_writable,
121
- name: "Breaks"
153
+ name: "Breaks",
154
+ skipEmpty: true
122
155
  },
123
156
  Replaces: {
124
157
  ...debian_dependency_attribute_collection_writable,
125
- name: "Replaces"
158
+ name: "Replaces",
159
+ skipEmpty: true
160
+ },
161
+ source: {
162
+ ...string_attribute_writable,
163
+ name: "source",
164
+ externalName: "Source",
165
+ skipEmpty: true
126
166
  },
127
- Source: { ...string_attribute_writable, name: "Source", alias: "source" },
128
167
  Uploaders: {
129
168
  ...string_collection_attribute_writable,
130
169
  name: "Uploaders",
131
- mandatory: false
170
+ mandatory: false,
171
+ skipEmpty: true
132
172
  },
133
- "Installed-Size": { ...integer_attribute_writable, name: "Installed-Size" }
173
+ "Installed-Size": {
174
+ ...integer_attribute_writable,
175
+ name: "Installed-Size",
176
+ skipEmpty: true
177
+ }
134
178
  };
135
179
 
136
180
  /**
@@ -153,13 +197,8 @@ export class DEBIAN extends Packager {
153
197
  }
154
198
 
155
199
  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}`;
200
+ const p = this.externalProperties;
201
+ return `${p.Package}_${p.Version}_${p.Architecture}${this.constructor.fileNameExtension}`;
163
202
  }
164
203
 
165
204
  /**
@@ -192,10 +231,7 @@ export class DEBIAN extends Packager {
192
231
  )
193
232
  );
194
233
 
195
- const depends = this.makeDepends(properties.dependencies);
196
- if (depends.length) {
197
- properties.Depends = depends;
198
- }
234
+ properties.dependencies = this.makeDepends(properties.dependencies);
199
235
 
200
236
  const fp = fieldProvider(properties, this.attributes);
201
237
 
@@ -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,
@@ -2,14 +2,7 @@ import { join } from "node:path";
2
2
  import { tmpdir } from "node:os";
3
3
  import { mkdtemp, mkdir } from "node:fs/promises";
4
4
  import { createReadStream } from "node:fs";
5
- import {
6
- expand,
7
- expandContextDoubbleCurly,
8
- string_collection_attribute_writable,
9
- name_attribute,
10
- description_attribute,
11
- version_attribute_writable
12
- } from "pacc";
5
+ import { expand, expandContextDoubbleCurly, iterateToExternal } from "pacc";
13
6
  import { StringContentEntry } from "content-entry";
14
7
  import { publish } from "../publish.mjs";
15
8
  import {
@@ -58,7 +51,7 @@ export class Packager {
58
51
  return false;
59
52
  }
60
53
 
61
- #properties;
54
+ properties;
62
55
  #prepared;
63
56
 
64
57
  /**
@@ -66,7 +59,13 @@ export class Packager {
66
59
  * @param {Object} properties
67
60
  */
68
61
  constructor(properties) {
69
- this.#properties = { ...properties, type: this.constructor.name };
62
+ this.properties = { ...properties, type: this.constructor.name };
63
+ }
64
+
65
+ get externalProperties() {
66
+ return Object.fromEntries([
67
+ ...iterateToExternal(this.properties, this.constructor.attributes)
68
+ ]);
70
69
  }
71
70
 
72
71
  /**
@@ -165,41 +164,6 @@ export class Packager {
165
164
  return this.constructor.attributes;
166
165
  }
167
166
 
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
167
  /**
204
168
  * Create tmp directory.
205
169
  * @return {Promise<string>} directory path
@@ -225,9 +189,9 @@ export class Packager {
225
189
 
226
190
  const out = {
227
191
  properties: this.properties,
228
- destination: options.destination || tmpdir,
192
+ destination: options.destination ?? tmpdir,
229
193
  tmpdir,
230
- staging: options.staging || tmpdir
194
+ staging: options.staging ?? tmpdir
231
195
  };
232
196
 
233
197
  // @ts-ignore
@@ -273,65 +237,3 @@ export class Packager {
273
237
  return publish(artifact, publishingDetails, this.properties, logger);
274
238
  }
275
239
  }
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
- };
@@ -15,12 +15,12 @@ import {
15
15
  colonSeparatedKeyValuePairOptionsDoublingKeys,
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
- } from "./packager.mjs";
23
+ } from "../types.mjs";
24
24
  import {
25
25
  copyEntries,
26
26
  fieldProvider,
@@ -61,30 +61,30 @@ export class RPM extends Packager {
61
61
  * @see https://rpm-packaging-guide.github.io
62
62
  */
63
63
  static attributes = {
64
- Name: { ...pkgbuild_name_attribute, name: "Name" },
65
- Summary: { ...pkgbuild_description_attribute, name: "Summary" },
66
- License: {
64
+ name: { ...pkgbuild_name_attribute, externalName: "Name" },
65
+ description: { ...pkgbuild_description_attribute, externalName: "Summary" },
66
+ license: {
67
67
  ...string_attribute,
68
- name: "License",
69
- alias: "license",
68
+ name: "license",
69
+ externalName: "License",
70
70
  mandatory: true
71
71
  },
72
- Version: { ...pkgbuild_version_attribute, name: "Version" },
73
- Release: {
72
+ version: { ...pkgbuild_version_attribute, externalName: "Version" },
73
+ release: {
74
74
  ...integer_attribute,
75
- name: "Release",
76
- alias: "release",
75
+ externalName: "Release",
76
+ name: "release",
77
77
  default: 1,
78
78
  mandatory: true
79
79
  },
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: {
80
+ source: { ...string_attribute, externalName: "Source0", name: "source" },
81
+ groups: { ...string_attribute, externalName: "Group", name: "groups" },
82
+ maintainer: { ...string_attribute, name: "maintainer", externalName: "Packager" },
83
+ vendor: { ...string_attribute, externalName: "Vendor", name: "vendor" },
84
+ arch: {
85
85
  ...string_attribute,
86
- name: "BuildArch",
87
- alias: "arch",
86
+ externalName: "BuildArch",
87
+ name: "arch",
88
88
  default: "noarch",
89
89
  mandatory: true
90
90
  },
package/src/types.mjs ADDED
@@ -0,0 +1,75 @@
1
+ import {
2
+ types,
3
+ string_collection_attribute_writable,
4
+ name_attribute,
5
+ description_attribute,
6
+ version_attribute_writable
7
+ } from "pacc";
8
+
9
+ export const pkgbuild_name_attribute = {
10
+ ...name_attribute,
11
+ mandatory: true,
12
+ pattern: /^[a-z_][a-z0-9_\-]*$/i
13
+ };
14
+
15
+ export const dependency_type = {
16
+ name: "dependency",
17
+ primitive: false,
18
+ toExternal: (value, attribute) => {
19
+ switch (typeof value) {
20
+ case "string":
21
+ case "undefined":
22
+ return value;
23
+ }
24
+
25
+ if (Array.isArray(value)) {
26
+ if (value.length === 0 && attribute.skipEmpty) {
27
+ return undefined;
28
+ }
29
+
30
+ return value;
31
+ }
32
+
33
+ return Object.entries(value).map(([name, expression]) =>
34
+ typeof expression === "string" ? `${name}${expression}` : name
35
+ );
36
+ }
37
+ };
38
+
39
+ export const architectureType = {
40
+ name: "architecture",
41
+ primitive: true,
42
+
43
+ toInternal: (value, attribute) => {
44
+ // console.log("architectureType toInternal", value);
45
+ return value;
46
+ },
47
+
48
+ toExternal: (value, attribute) => {
49
+ // console.log("architectureType toExternal", value);
50
+ return attribute.mapping[value] ?? value;
51
+ }
52
+ };
53
+
54
+ export const dependency_attribute_collection_writable = {
55
+ ...string_collection_attribute_writable,
56
+ type: dependency_type,
57
+ separator: " ",
58
+ pattern: /^[a-z_][a-z0-9_\-]*$/i
59
+ };
60
+
61
+ export const pkgbuild_version_attribute = {
62
+ ...version_attribute_writable,
63
+ mandatory: true,
64
+ type: {
65
+ ...types.string,
66
+ toExternal: (value, attribute) => {
67
+ return value.replace("-semantic-release", "");
68
+ }
69
+ }
70
+ };
71
+
72
+ export const pkgbuild_description_attribute = {
73
+ ...description_attribute,
74
+ mandatory: true
75
+ };
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
 
@@ -150,39 +150,20 @@ export function fieldProvider(properties, attributes) {
150
150
  }
151
151
 
152
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))];
153
+ let filter;
154
+
155
+ if (k) {
156
+ filter = attribute => attribute.name === k;
157
+ }
158
+
159
+ for (const [name, value] of iterateToExternal(
160
+ properties,
161
+ attributes,
162
+ filter
163
+ )) {
164
+ //if (!presentKeys.has(name)) { }
165
+
166
+ yield [name, value];
186
167
  }
187
168
  };
188
169
  }