npm-pkgbuild 7.14.14 → 7.15.2
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/npm-pkgbuild-cli.mjs +17 -4
- package/src/output/arch.mjs +1 -2
- package/src/output/deb.mjs +34 -26
- package/src/output/rpm.mjs +2 -1
- package/src/util.mjs +0 -71
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.15.2",
|
|
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.3.1",
|
|
45
46
|
"execa": "^6.0.0",
|
|
46
47
|
"expression-expander": "^7.0.9",
|
|
47
48
|
"globby": "^12.0.2",
|
package/src/npm-pkgbuild-cli.mjs
CHANGED
|
@@ -8,9 +8,10 @@ import { aggregateFifo } from "aggregate-async-iterator";
|
|
|
8
8
|
import { createContext } from "expression-expander";
|
|
9
9
|
import { packageDirectory } from "pkg-dir";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "
|
|
11
|
+
createExpressionTransformer,
|
|
12
|
+
nameExtensionMatcher
|
|
13
|
+
} from "content-entry-transform";
|
|
14
|
+
import { utf8StreamOptions } from "./util.mjs";
|
|
14
15
|
import {
|
|
15
16
|
FileContentProvider,
|
|
16
17
|
allInputs,
|
|
@@ -95,7 +96,19 @@ program
|
|
|
95
96
|
|
|
96
97
|
const context = createContext({ properties });
|
|
97
98
|
const output = new outputFactory(context.expand(properties));
|
|
98
|
-
const transformer = [
|
|
99
|
+
const transformer = [
|
|
100
|
+
createExpressionTransformer(
|
|
101
|
+
nameExtensionMatcher([
|
|
102
|
+
".conf",
|
|
103
|
+
".json",
|
|
104
|
+
".html",
|
|
105
|
+
".txt",
|
|
106
|
+
".service",
|
|
107
|
+
".socket"
|
|
108
|
+
]),
|
|
109
|
+
properties
|
|
110
|
+
)
|
|
111
|
+
];
|
|
99
112
|
|
|
100
113
|
if (options.verbose) {
|
|
101
114
|
console.log(output.properties);
|
package/src/output/arch.mjs
CHANGED
|
@@ -3,6 +3,7 @@ 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, createPropertiesInterceptor } from "content-entry-transform";
|
|
6
7
|
import { iterableStringInterceptor } from "iterable-string-interceptor";
|
|
7
8
|
import {
|
|
8
9
|
keyValueTransformer,
|
|
@@ -11,9 +12,7 @@ import {
|
|
|
11
12
|
import { Packager } from "./packager.mjs";
|
|
12
13
|
import {
|
|
13
14
|
copyEntries,
|
|
14
|
-
transform,
|
|
15
15
|
fieldProvider,
|
|
16
|
-
createPropertiesInterceptor,
|
|
17
16
|
quote,
|
|
18
17
|
utf8StreamOptions
|
|
19
18
|
} from "../util.mjs";
|
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,77 +58,6 @@ export function fieldProvider(properties, fields) {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
export function createModeTransformer(mode, match) {
|
|
62
|
-
return {
|
|
63
|
-
name: "mode",
|
|
64
|
-
match,
|
|
65
|
-
transform: async entry => Object.create(entry, { mode: { value: mode } })
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function createPropertiesInterceptor(properties) {
|
|
70
|
-
return async function* transformer(expression, remainder, source, cb) {
|
|
71
|
-
const value = properties[expression];
|
|
72
|
-
yield value === undefined ? "" : value;
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function createExpressionTransformer(
|
|
77
|
-
properties,
|
|
78
|
-
match = entry =>
|
|
79
|
-
entry.name.match(/\.(conf|json|html|txt|service|socket)$/) ? true : false
|
|
80
|
-
) {
|
|
81
|
-
return {
|
|
82
|
-
name: "expression",
|
|
83
|
-
match,
|
|
84
|
-
transform: async entry => {
|
|
85
|
-
//console.log("TRANSFORM",entry.name);
|
|
86
|
-
const ne = new ReadableStreamContentEntry(
|
|
87
|
-
entry.name,
|
|
88
|
-
iterableStringInterceptor(
|
|
89
|
-
await entry.getReadStream(utf8StreamOptions),
|
|
90
|
-
createPropertiesInterceptor(properties)
|
|
91
|
-
)
|
|
92
|
-
);
|
|
93
|
-
ne.destination = entry.destination; // TODO all the other attributes ?
|
|
94
|
-
return ne;
|
|
95
|
-
//return Object.assign(entry,ne);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Apply transformers.
|
|
102
|
-
* @param {AsyncIterator<ContentEntry>} source
|
|
103
|
-
* @param {Transformer[]} transformers
|
|
104
|
-
* @param {Boolean]} onlyMatching filter out all none matching entries
|
|
105
|
-
*/
|
|
106
|
-
export async function* transform(source, transformers = [], onlyMatching) {
|
|
107
|
-
const usedTransformers = new Set();
|
|
108
|
-
|
|
109
|
-
for await (let entry of source) {
|
|
110
|
-
let didMatch = false;
|
|
111
|
-
for (const t of transformers) {
|
|
112
|
-
//console.log(t.name,entry.name,t.match(entry));
|
|
113
|
-
if (t.match(entry)) {
|
|
114
|
-
didMatch = true;
|
|
115
|
-
entry = await t.transform(entry);
|
|
116
|
-
usedTransformers.add(t);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if ((onlyMatching && didMatch) || !onlyMatching) {
|
|
121
|
-
yield entry;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
for (const t of transformers) {
|
|
126
|
-
if (!usedTransformers.has(t) && t.createEntryWhenMissing !== undefined) {
|
|
127
|
-
yield t.transform(await t.createEntryWhenMissing());
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
61
|
/**
|
|
133
62
|
* @typedef {Function} Expander
|
|
134
63
|
* @param {string} path
|