npm-pkgbuild 7.9.2 → 7.10.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 +1 -1
- package/src/npm-pkgbuild-cli.mjs +4 -1
- package/src/output/deb.mjs +8 -10
- package/src/output/pkg.mjs +6 -7
- package/src/output/rpm.mjs +4 -5
- package/src/util.mjs +13 -13
package/package.json
CHANGED
package/src/npm-pkgbuild-cli.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { createContext } from "expression-expander";
|
|
|
9
9
|
import { packageDirectory } from "pkg-dir";
|
|
10
10
|
import { utf8StreamOptions, extractFromPackage } from "./util.mjs";
|
|
11
11
|
import { FileContentProvider, DEB, PKG, RPM } from "npm-pkgbuild";
|
|
12
|
+
import { createExpressionTransformer } from "./util.mjs";
|
|
12
13
|
|
|
13
14
|
const { version, description } = JSON.parse(
|
|
14
15
|
readFileSync(new URL("../package.json", import.meta.url).pathname),
|
|
@@ -74,13 +75,15 @@ program
|
|
|
74
75
|
|
|
75
76
|
const context = createContext({ properties });
|
|
76
77
|
const output = new outputFactory(properties);
|
|
77
|
-
|
|
78
|
+
const transformer = [createExpressionTransformer(properties)];
|
|
79
|
+
|
|
78
80
|
if (options.verbose) {
|
|
79
81
|
console.log(output.properties);
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
const fileName = await output.execute(
|
|
83
85
|
aggregateFifo(sources.map(c => c[Symbol.asyncIterator]())),
|
|
86
|
+
transformer,
|
|
84
87
|
options,
|
|
85
88
|
path => context.expand(path)
|
|
86
89
|
);
|
package/src/output/deb.mjs
CHANGED
|
@@ -3,9 +3,7 @@ import { execa } from "execa";
|
|
|
3
3
|
import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
|
|
4
4
|
import { keyValueTransformer } from "key-value-transformer";
|
|
5
5
|
import { Packager } from "./packager.mjs";
|
|
6
|
-
import { copyEntries, transform, fieldProvider } from "../util.mjs";
|
|
7
|
-
|
|
8
|
-
const attributes = [{ pattern: /DEBIAN\/.*(inst|rm)/, mode: 0o775 }];
|
|
6
|
+
import { copyEntries, transform, fieldProvider, createModeTransformer } from "../util.mjs";
|
|
9
7
|
|
|
10
8
|
export class DEB extends Packager {
|
|
11
9
|
static get name() {
|
|
@@ -25,15 +23,16 @@ export class DEB extends Packager {
|
|
|
25
23
|
return `${p.name}_${p.version}_${p.arch}${this.constructor.fileNameExtension}`;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
async execute(sources, options, expander) {
|
|
26
|
+
async execute(sources, transformer, options, expander) {
|
|
29
27
|
const properties = this.properties;
|
|
30
28
|
const mandatoryFields = this.mandatoryFields;
|
|
31
29
|
const staging = await this.tmpdir;
|
|
32
30
|
|
|
33
31
|
const fp = fieldProvider(properties, fields, mandatoryFields);
|
|
34
|
-
|
|
35
32
|
const debianControlName = "DEBIAN/control";
|
|
36
|
-
|
|
33
|
+
|
|
34
|
+
transformer.push(createModeTransformer(0o775, entry => entry.name.match(/DEBIAN\/.*(inst|rm)/)));
|
|
35
|
+
transformer.push(
|
|
37
36
|
{
|
|
38
37
|
match: entry => entry.name === debianControlName,
|
|
39
38
|
transform: async entry =>
|
|
@@ -42,10 +41,9 @@ export class DEB extends Packager {
|
|
|
42
41
|
keyValueTransformer(await entry.readStream, fp)
|
|
43
42
|
),
|
|
44
43
|
createEntryWhenMissing: () => new EmptyContentEntry(debianControlName)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
await copyEntries(transform(sources, transformers), staging, expander, attributes);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
await copyEntries(transform(sources, transformer), staging, expander);
|
|
49
47
|
|
|
50
48
|
const dpkg = await execa("dpkg", ["-b", staging, options.destination]);
|
|
51
49
|
|
package/src/output/pkg.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "key-value-transformer";
|
|
8
8
|
import { Packager } from "./packager.mjs";
|
|
9
9
|
import { copyEntries, transform, fieldProvider } from "../util.mjs";
|
|
10
|
-
import { quote
|
|
10
|
+
import { quote } from "../util.mjs";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @type KeyValueTransformOptions
|
|
@@ -48,7 +48,7 @@ export class PKG extends Packager {
|
|
|
48
48
|
return `${p.name}-${p.version}-${p.release}-${p.arch}${this.constructor.fileNameExtension}`;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
async execute(sources, options, expander) {
|
|
51
|
+
async execute(sources, transformer, options, expander) {
|
|
52
52
|
const properties = this.properties;
|
|
53
53
|
|
|
54
54
|
//properties.depends = makeDepends({ ...pkg.engines });
|
|
@@ -64,11 +64,11 @@ package() {
|
|
|
64
64
|
`;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
await copyEntries(transform(sources,
|
|
67
|
+
await copyEntries(transform(sources, transformer), join(staging, "src"), expander);
|
|
68
68
|
|
|
69
69
|
const fp = fieldProvider(properties, fields, mandatoryFields);
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
transformer.push(
|
|
72
72
|
{
|
|
73
73
|
match: entry => entry.name === "PKGBUILD",
|
|
74
74
|
transform: async entry =>
|
|
@@ -80,11 +80,10 @@ package() {
|
|
|
80
80
|
})
|
|
81
81
|
),
|
|
82
82
|
createEntryWhenMissing: () => new EmptyContentEntry("PKGBUILD")
|
|
83
|
-
}
|
|
84
|
-
];
|
|
83
|
+
});
|
|
85
84
|
|
|
86
85
|
await copyEntries(
|
|
87
|
-
transform(sources,
|
|
86
|
+
transform(sources, transformer, true),
|
|
88
87
|
staging,
|
|
89
88
|
expander
|
|
90
89
|
);
|
package/src/output/rpm.mjs
CHANGED
|
@@ -27,7 +27,7 @@ export class RPM extends Packager {
|
|
|
27
27
|
return fields;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
async execute(sources, options, expander) {
|
|
30
|
+
async execute(sources, transformer, options, expander) {
|
|
31
31
|
const properties = this.properties;
|
|
32
32
|
const mandatoryFields = this.mandatoryFields;
|
|
33
33
|
const tmp = await this.tmpdir;
|
|
@@ -50,7 +50,7 @@ export class RPM extends Packager {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
transformer.push(
|
|
54
54
|
{
|
|
55
55
|
match: entry => entry.name === specFileName,
|
|
56
56
|
transform: async entry =>
|
|
@@ -62,10 +62,9 @@ export class RPM extends Packager {
|
|
|
62
62
|
})
|
|
63
63
|
),
|
|
64
64
|
createEntryWhenMissing: () => new EmptyContentEntry(specFileName)
|
|
65
|
-
}
|
|
66
|
-
];
|
|
65
|
+
});
|
|
67
66
|
|
|
68
|
-
await copyEntries(transform(sources,
|
|
67
|
+
await copyEntries(transform(sources, transformer), staging, expander);
|
|
69
68
|
|
|
70
69
|
const rpmbuild = await execa("rpmbuild", [
|
|
71
70
|
"--define",
|
package/src/util.mjs
CHANGED
|
@@ -111,13 +111,20 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
111
111
|
return { properties, sources, dependencies, output };
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
export function createModeTransformer(mode, match)
|
|
115
|
+
{
|
|
116
|
+
return {
|
|
117
|
+
match,
|
|
118
|
+
transform: async entry => Object.create(entry,{ mode: { value: mode }})
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
114
122
|
export function createExpressionTransformer(
|
|
115
123
|
properties,
|
|
116
|
-
match = entry => entry.name.match(/\.(conf|json)$/)
|
|
124
|
+
match = entry => entry.name.match(/\.(conf|json|html|txt)$/)
|
|
117
125
|
) {
|
|
118
126
|
async function* transformer(expression, remainder, source, cb) {
|
|
119
127
|
const value = properties[expression];
|
|
120
|
-
console.log("EXPRESSION", expression, value);
|
|
121
128
|
yield value === undefined ? "" : value;
|
|
122
129
|
}
|
|
123
130
|
|
|
@@ -183,30 +190,23 @@ export async function* transform(source, transformers = [], onlyMatching) {
|
|
|
183
190
|
export async function copyEntries(
|
|
184
191
|
source,
|
|
185
192
|
destinationDirectory,
|
|
186
|
-
expander = v => v
|
|
187
|
-
attributes = []
|
|
193
|
+
expander = v => v
|
|
188
194
|
) {
|
|
189
195
|
for await (let entry of source) {
|
|
190
|
-
const
|
|
196
|
+
const destination = expander(
|
|
191
197
|
entry.destination === undefined
|
|
192
198
|
? join(destinationDirectory, entry.name)
|
|
193
199
|
: entry.destination.endsWith("/")
|
|
194
200
|
? join(destinationDirectory, entry.destination, entry.name)
|
|
195
201
|
: join(destinationDirectory, entry.destination)
|
|
196
202
|
);
|
|
197
|
-
await mkdir(dirname(
|
|
203
|
+
await mkdir(dirname(destination), { recursive: true });
|
|
198
204
|
|
|
199
205
|
const options = { mode: entry.mode };
|
|
200
206
|
|
|
201
|
-
for (const a of attributes) {
|
|
202
|
-
if (entry.name.match(a.pattern)) {
|
|
203
|
-
options.mode = a.mode;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
207
|
await pipeline(
|
|
208
208
|
await entry.readStream,
|
|
209
|
-
createWriteStream(
|
|
209
|
+
createWriteStream(destination, options)
|
|
210
210
|
);
|
|
211
211
|
}
|
|
212
212
|
}
|