npm-pkgbuild 7.2.4 → 7.2.8
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 +4 -4
- package/src/key-value-transformer.mjs +25 -4
- package/src/npm-pkgbuild-cli.mjs +7 -4
- package/src/output/deb.mjs +24 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"aggregate-async-iterator": "^1.1.7",
|
|
42
|
-
"commander": "^8.
|
|
43
|
-
"content-entry": "^2.7.
|
|
44
|
-
"content-entry-filesystem": "^3.0.
|
|
42
|
+
"commander": "^8.3.0",
|
|
43
|
+
"content-entry": "^2.7.1",
|
|
44
|
+
"content-entry-filesystem": "^3.0.1",
|
|
45
45
|
"execa": "^5.1.1",
|
|
46
46
|
"expression-expander": "^7.0.9",
|
|
47
47
|
"globby": "^12.0.2",
|
|
@@ -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
13
|
yield `${k}: ${v}\n`;
|
|
13
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";
|
|
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
|
@@ -4,12 +4,15 @@ import { createWriteStream } from "fs";
|
|
|
4
4
|
import { mkdtemp, mkdir, chmod } from "fs/promises";
|
|
5
5
|
import { pipeline } from "stream/promises";
|
|
6
6
|
import execa from "execa";
|
|
7
|
+
import { EmptyContentEntry } from "content-entry";
|
|
7
8
|
import { Packager } from "./packager.mjs";
|
|
8
9
|
import { keyValueTransformer } from "../key-value-transformer.mjs";
|
|
9
10
|
|
|
10
11
|
const permissions = {
|
|
11
12
|
"DEBIAN/preinst": { chmod: "0775" },
|
|
12
|
-
"DEBIAN/postinst": { chmod: "0775" }
|
|
13
|
+
"DEBIAN/postinst": { chmod: "0775" },
|
|
14
|
+
"DEBIAN/prerm": { chmod: "0775" },
|
|
15
|
+
"DEBIAN/postrm": { chmod: "0775" }
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
export class Deb extends Packager {
|
|
@@ -50,16 +53,15 @@ export class Deb extends Packager {
|
|
|
50
53
|
|
|
51
54
|
const output = `${staging}${this.constructor.fileNameExtension}`;
|
|
52
55
|
|
|
56
|
+
let debianControlEntry;
|
|
57
|
+
|
|
53
58
|
for await (const entry of this.source) {
|
|
54
59
|
const destName = join(staging, entry.name);
|
|
55
60
|
|
|
56
61
|
await mkdir(dirname(destName), { recursive: true });
|
|
57
62
|
|
|
58
63
|
if (entry.name === "DEBIAN/control") {
|
|
59
|
-
|
|
60
|
-
keyValueTransformer(await entry.getReadStream(), controlProperties),
|
|
61
|
-
createWriteStream(destName)
|
|
62
|
-
);
|
|
64
|
+
debianControlEntry = entry;
|
|
63
65
|
} else {
|
|
64
66
|
await pipeline(
|
|
65
67
|
await entry.getReadStream(),
|
|
@@ -77,7 +79,22 @@ export class Deb extends Packager {
|
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
if (!debianControlEntry) {
|
|
83
|
+
debianControlEntry = new EmptyContentEntry("DEBIAN/control");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let destName = join(staging, debianControlEntry.name);
|
|
87
|
+
|
|
88
|
+
console.log("A", destName, dirname(destName));
|
|
89
|
+
await mkdir(dirname(destName), { recursive: true });
|
|
90
|
+
|
|
91
|
+
const x = await pipeline(
|
|
92
|
+
keyValueTransformer(
|
|
93
|
+
await debianControlEntry.getReadStream(),
|
|
94
|
+
controlProperties
|
|
95
|
+
),
|
|
96
|
+
createWriteStream(destName)
|
|
97
|
+
);
|
|
81
98
|
|
|
82
99
|
await execa("dpkg", ["-b", staging]);
|
|
83
100
|
|
|
@@ -96,7 +113,7 @@ const fields = {
|
|
|
96
113
|
Description: { alias: "description", mandatory: true },
|
|
97
114
|
Homepage: { alias: "homepage" },
|
|
98
115
|
Source: { mandatory: true },
|
|
99
|
-
Maintainer: { mandatory: true },
|
|
116
|
+
Maintainer: { alias: "maintainer", mandatory: true },
|
|
100
117
|
Uploaders: { mandatory: false },
|
|
101
118
|
Section: { recommended: true },
|
|
102
119
|
Priority: { recommended: true },
|