npm-pkgbuild 7.14.13 → 7.15.1
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 -3
- package/src/output/arch.mjs +10 -10
- package/src/output/deb.mjs +34 -26
- package/src/output/rpm.mjs +2 -1
- package/src/util.mjs +7 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.15.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -40,8 +40,9 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"aggregate-async-iterator": "^1.1.7",
|
|
42
42
|
"commander": "^8.3.0",
|
|
43
|
-
"content-entry": "^
|
|
44
|
-
"content-entry-filesystem": "^
|
|
43
|
+
"content-entry": "^4.0.0",
|
|
44
|
+
"content-entry-filesystem": "^4.0.0",
|
|
45
|
+
"content-entry-transform": "^1.2.1",
|
|
45
46
|
"execa": "^6.0.0",
|
|
46
47
|
"expression-expander": "^7.0.9",
|
|
47
48
|
"globby": "^12.0.2",
|
package/src/output/arch.mjs
CHANGED
|
@@ -3,14 +3,20 @@ import { createReadStream, createWriteStream } from "fs";
|
|
|
3
3
|
import { pipeline } from "stream/promises";
|
|
4
4
|
import { execa } from "execa";
|
|
5
5
|
import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
|
|
6
|
+
import { transform } from "content-entry-transform";
|
|
6
7
|
import { iterableStringInterceptor } from "iterable-string-interceptor";
|
|
7
8
|
import {
|
|
8
9
|
keyValueTransformer,
|
|
9
10
|
equalSeparatedKeyValuePairOptions
|
|
10
11
|
} from "key-value-transformer";
|
|
11
12
|
import { Packager } from "./packager.mjs";
|
|
12
|
-
import {
|
|
13
|
-
|
|
13
|
+
import {
|
|
14
|
+
copyEntries,
|
|
15
|
+
fieldProvider,
|
|
16
|
+
createPropertiesInterceptor,
|
|
17
|
+
quote,
|
|
18
|
+
utf8StreamOptions
|
|
19
|
+
} from "../util.mjs";
|
|
14
20
|
|
|
15
21
|
/**
|
|
16
22
|
* @type KeyValueTransformOptions
|
|
@@ -43,8 +49,7 @@ export class ARCH extends Packager {
|
|
|
43
49
|
return "arch";
|
|
44
50
|
}
|
|
45
51
|
|
|
46
|
-
static get description()
|
|
47
|
-
{
|
|
52
|
+
static get description() {
|
|
48
53
|
return "generate Arch-Linux package";
|
|
49
54
|
}
|
|
50
55
|
|
|
@@ -89,18 +94,13 @@ package() {
|
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
if (properties.hooks) {
|
|
92
|
-
async function* transformer(expression, remainder, source, cb) {
|
|
93
|
-
const value = properties[expression];
|
|
94
|
-
yield value === undefined ? "" : value;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
97
|
await pipeline(
|
|
98
98
|
iterableStringInterceptor(
|
|
99
99
|
createReadStream(
|
|
100
100
|
join(options.pkgdir, properties.hooks),
|
|
101
101
|
utf8StreamOptions
|
|
102
102
|
),
|
|
103
|
-
|
|
103
|
+
createPropertiesInterceptor(properties)
|
|
104
104
|
),
|
|
105
105
|
createWriteStream(join(staging, properties.install), utf8StreamOptions)
|
|
106
106
|
);
|
package/src/output/deb.mjs
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
2
|
import { execa } from "execa";
|
|
3
3
|
import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
|
|
4
|
+
import {
|
|
5
|
+
transform,
|
|
6
|
+
createPropertiesTransformer
|
|
7
|
+
} from "content-entry-transform";
|
|
4
8
|
import { keyValueTransformer } from "key-value-transformer";
|
|
5
9
|
import { Packager } from "./packager.mjs";
|
|
6
|
-
import { copyEntries,
|
|
10
|
+
import { copyEntries, fieldProvider } from "../util.mjs";
|
|
7
11
|
|
|
8
12
|
export class DEB extends Packager {
|
|
9
13
|
static get name() {
|
|
10
14
|
return "deb";
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
static get description()
|
|
14
|
-
{
|
|
17
|
+
static get description() {
|
|
15
18
|
return "generate Debian package";
|
|
16
19
|
}
|
|
17
20
|
|
|
@@ -32,35 +35,40 @@ export class DEB extends Packager {
|
|
|
32
35
|
const properties = this.properties;
|
|
33
36
|
const staging = await this.tmpdir;
|
|
34
37
|
|
|
35
|
-
transformer.push(
|
|
38
|
+
transformer.push(
|
|
39
|
+
createPropertiesTransformer(
|
|
40
|
+
entry => (entry.name.match(/DEBIAN\/.*(inst|rm)/) ? true : false),
|
|
41
|
+
{ mode: { value: 0o775 } },
|
|
42
|
+
"mode"
|
|
43
|
+
)
|
|
44
|
+
);
|
|
36
45
|
|
|
37
46
|
const fp = fieldProvider(properties, fields);
|
|
38
47
|
const debianControlName = "DEBIAN/control";
|
|
39
|
-
|
|
40
|
-
transformer.push(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
console.log(file.destination);
|
|
58
|
-
}
|
|
48
|
+
|
|
49
|
+
transformer.push({
|
|
50
|
+
match: entry => entry.name === debianControlName,
|
|
51
|
+
transform: async entry =>
|
|
52
|
+
new ReadableStreamContentEntry(
|
|
53
|
+
entry.name,
|
|
54
|
+
keyValueTransformer(await entry.readStream, fp)
|
|
55
|
+
),
|
|
56
|
+
createEntryWhenMissing: () => new EmptyContentEntry(debianControlName)
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
for await (const file of copyEntries(
|
|
60
|
+
transform(sources, transformer),
|
|
61
|
+
staging,
|
|
62
|
+
expander
|
|
63
|
+
)) {
|
|
64
|
+
if (options.verbose) {
|
|
65
|
+
console.log(file.destination);
|
|
59
66
|
}
|
|
60
|
-
|
|
67
|
+
}
|
|
68
|
+
|
|
61
69
|
const dpkg = await execa("dpkg", ["-b", staging, options.destination]);
|
|
62
70
|
|
|
63
|
-
if(options.verbose) {
|
|
71
|
+
if (options.verbose) {
|
|
64
72
|
console.log(dpkg.stdout);
|
|
65
73
|
}
|
|
66
74
|
|
package/src/output/rpm.mjs
CHANGED
|
@@ -2,12 +2,13 @@ import { join } from "path";
|
|
|
2
2
|
import { mkdir, cp } from "fs/promises";
|
|
3
3
|
import { execa } from "execa";
|
|
4
4
|
import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
|
|
5
|
+
import { transform } from "content-entry-transform";
|
|
5
6
|
import {
|
|
6
7
|
keyValueTransformer,
|
|
7
8
|
colonSeparatedKeyValuePairOptions
|
|
8
9
|
} from "key-value-transformer";
|
|
9
10
|
import { Packager } from "./packager.mjs";
|
|
10
|
-
import { copyEntries,
|
|
11
|
+
import { copyEntries, fieldProvider } from "../util.mjs";
|
|
11
12
|
|
|
12
13
|
export class RPM extends Packager {
|
|
13
14
|
static get name() {
|
package/src/util.mjs
CHANGED
|
@@ -58,24 +58,18 @@ export function fieldProvider(properties, fields) {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
match,
|
|
66
|
-
transform: async entry => Object.create(entry, { mode: { value: mode } })
|
|
61
|
+
export function createPropertiesInterceptor(properties) {
|
|
62
|
+
return async function* transformer(expression, remainder, source, cb) {
|
|
63
|
+
const value = properties[expression];
|
|
64
|
+
yield value === undefined ? "" : value;
|
|
67
65
|
};
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
export function createExpressionTransformer(
|
|
71
69
|
properties,
|
|
72
|
-
match = entry =>
|
|
70
|
+
match = entry =>
|
|
71
|
+
entry.name.match(/\.(conf|json|html|txt|service|socket)$/) ? true : false
|
|
73
72
|
) {
|
|
74
|
-
async function* transformer(expression, remainder, source, cb) {
|
|
75
|
-
const value = properties[expression];
|
|
76
|
-
yield value === undefined ? "" : value;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
73
|
return {
|
|
80
74
|
name: "expression",
|
|
81
75
|
match,
|
|
@@ -85,7 +79,7 @@ export function createExpressionTransformer(
|
|
|
85
79
|
entry.name,
|
|
86
80
|
iterableStringInterceptor(
|
|
87
81
|
await entry.getReadStream(utf8StreamOptions),
|
|
88
|
-
|
|
82
|
+
createPropertiesInterceptor(properties)
|
|
89
83
|
)
|
|
90
84
|
);
|
|
91
85
|
ne.destination = entry.destination; // TODO all the other attributes ?
|
|
@@ -95,38 +89,6 @@ export function createExpressionTransformer(
|
|
|
95
89
|
};
|
|
96
90
|
}
|
|
97
91
|
|
|
98
|
-
/**
|
|
99
|
-
* Apply transformers.
|
|
100
|
-
* @param {AsyncIterator<ContentEntry>} source
|
|
101
|
-
* @param {Transformer[]} transformers
|
|
102
|
-
* @param {Boolean]} onlyMatching filter out all none matching entries
|
|
103
|
-
*/
|
|
104
|
-
export async function* transform(source, transformers = [], onlyMatching) {
|
|
105
|
-
const usedTransformers = new Set();
|
|
106
|
-
|
|
107
|
-
for await (let entry of source) {
|
|
108
|
-
let didMatch = false;
|
|
109
|
-
for (const t of transformers) {
|
|
110
|
-
//console.log(t.name,entry.name,t.match(entry));
|
|
111
|
-
if (t.match(entry)) {
|
|
112
|
-
didMatch = true;
|
|
113
|
-
entry = await t.transform(entry);
|
|
114
|
-
usedTransformers.add(t);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if ((onlyMatching && didMatch) || !onlyMatching) {
|
|
119
|
-
yield entry;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
for (const t of transformers) {
|
|
124
|
-
if (!usedTransformers.has(t) && t.createEntryWhenMissing !== undefined) {
|
|
125
|
-
yield t.transform(await t.createEntryWhenMissing());
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
92
|
/**
|
|
131
93
|
* @typedef {Function} Expander
|
|
132
94
|
* @param {string} path
|