npm-pkgbuild 7.2.1 → 7.2.5
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 +1 -1
- package/src/key-value-transformer.mjs +26 -5
- package/src/npm-pkgbuild-cli.mjs +7 -4
- package/src/output/deb.mjs +23 -9
package/package.json
CHANGED
|
@@ -4,17 +4,38 @@
|
|
|
4
4
|
* @param updates
|
|
5
5
|
*/
|
|
6
6
|
export async function* keyValueTransformer(source, updates) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
let key, value;
|
|
8
|
+
|
|
9
|
+
function * eject() {
|
|
10
|
+
if (key !== undefined) {
|
|
11
|
+
const [k, v] = updates(key, value);
|
|
11
12
|
if (k !== undefined) {
|
|
12
|
-
yield
|
|
13
|
+
yield`${k}: ${v}\n`;
|
|
14
|
+
}
|
|
15
|
+
key = value = undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
for await (const line of asLines(source)) {
|
|
20
|
+
const m = line.match(/^(\w+):\s*(.*)/);
|
|
21
|
+
if (m) {
|
|
22
|
+
yield *eject();
|
|
23
|
+
key = m[1];
|
|
24
|
+
value = m[2];
|
|
25
|
+
} else if (key !== undefined) {
|
|
26
|
+
const m = line.match(/^\s+(.*)/);
|
|
27
|
+
if (m) {
|
|
28
|
+
value += m[1];
|
|
29
|
+
} else {
|
|
30
|
+
yield * eject();
|
|
31
|
+
yield line + "\n";
|
|
13
32
|
}
|
|
14
33
|
} else {
|
|
15
34
|
yield line + "\n";
|
|
16
35
|
}
|
|
17
36
|
}
|
|
37
|
+
|
|
38
|
+
yield *eject();
|
|
18
39
|
}
|
|
19
40
|
|
|
20
41
|
async function* asLines(source) {
|
package/src/npm-pkgbuild-cli.mjs
CHANGED
|
@@ -53,12 +53,15 @@ program
|
|
|
53
53
|
);
|
|
54
54
|
|
|
55
55
|
const properties = Object.fromEntries(
|
|
56
|
-
["name", "version", "description", "homepage"]
|
|
57
|
-
key,
|
|
58
|
-
|
|
59
|
-
]).filter(([k,v]) => v !== undefined )
|
|
56
|
+
["name", "version", "description", "homepage"]
|
|
57
|
+
.map(key => [key, pkg[key]])
|
|
58
|
+
.filter(([k, v]) => v !== undefined)
|
|
60
59
|
);
|
|
61
60
|
|
|
61
|
+
if(pkg.contributors) {
|
|
62
|
+
properties.maintainer = pkg.contributors.map(c => `${c.name} <${c.email}>`)[0];
|
|
63
|
+
}
|
|
64
|
+
|
|
62
65
|
const sources = [...options.content, ...options.meta]
|
|
63
66
|
.filter(x => x)
|
|
64
67
|
.map(source =>
|
package/src/output/deb.mjs
CHANGED
|
@@ -13,17 +13,18 @@ const permissions = {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export class Deb extends Packager {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
static get name() {
|
|
17
|
+
return "deb";
|
|
18
|
+
}
|
|
18
19
|
|
|
19
20
|
static get fileNameExtension() {
|
|
20
21
|
return ".deb";
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
async execute() {
|
|
24
|
-
Object.entries(fields).forEach(([k,v])=>{
|
|
25
|
+
Object.entries(fields).forEach(([k, v]) => {
|
|
25
26
|
const e = this.properties[v.alias];
|
|
26
|
-
if(e !== undefined) {
|
|
27
|
+
if (e !== undefined) {
|
|
27
28
|
this.properties[k] = e;
|
|
28
29
|
}
|
|
29
30
|
});
|
|
@@ -34,6 +35,19 @@ export class Deb extends Packager {
|
|
|
34
35
|
`${this.properties.name}-${this.properties.version}`
|
|
35
36
|
);
|
|
36
37
|
|
|
38
|
+
const presentProperties = new Set();
|
|
39
|
+
|
|
40
|
+
const controlProperties = (k, v) => {
|
|
41
|
+
presentProperties.add(k);
|
|
42
|
+
return [k, this.properties[k] || v];
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const mandatoryProperties = new Set(
|
|
46
|
+
Object.entries(fields)
|
|
47
|
+
.filter(([k, v]) => v.mandatory)
|
|
48
|
+
.map(([k, v]) => k)
|
|
49
|
+
);
|
|
50
|
+
|
|
37
51
|
const output = `${staging}${this.constructor.fileNameExtension}`;
|
|
38
52
|
|
|
39
53
|
for await (const entry of this.source) {
|
|
@@ -43,10 +57,7 @@ export class Deb extends Packager {
|
|
|
43
57
|
|
|
44
58
|
if (entry.name === "DEBIAN/control") {
|
|
45
59
|
await pipeline(
|
|
46
|
-
keyValueTransformer(await entry.getReadStream(),
|
|
47
|
-
k,
|
|
48
|
-
this.properties[k] === undefined ? v : this.properties[k]
|
|
49
|
-
]),
|
|
60
|
+
keyValueTransformer(await entry.getReadStream(), controlProperties),
|
|
50
61
|
createWriteStream(destName)
|
|
51
62
|
);
|
|
52
63
|
} else {
|
|
@@ -66,6 +77,8 @@ export class Deb extends Packager {
|
|
|
66
77
|
}
|
|
67
78
|
}
|
|
68
79
|
|
|
80
|
+
//console.log(presentProperties, mandatoryProperties);
|
|
81
|
+
|
|
69
82
|
await execa("dpkg", ["-b", staging]);
|
|
70
83
|
|
|
71
84
|
return output;
|
|
@@ -80,9 +93,10 @@ const fields = {
|
|
|
80
93
|
Package: { alias: "name", mandatory: true },
|
|
81
94
|
Version: { alias: "version", mandatory: true },
|
|
82
95
|
Architecture: { default: "any", mandatory: true },
|
|
96
|
+
Description: { alias: "description", mandatory: true },
|
|
83
97
|
Homepage: { alias: "homepage" },
|
|
84
98
|
Source: { mandatory: true },
|
|
85
|
-
Maintainer: { mandatory: true },
|
|
99
|
+
Maintainer: { alias: "maintainer", mandatory: true },
|
|
86
100
|
Uploaders: { mandatory: false },
|
|
87
101
|
Section: { recommended: true },
|
|
88
102
|
Priority: { recommended: true },
|