npm-pkgbuild 7.11.4 → 7.11.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/LICENSE +1 -1
- package/README.md +2 -2
- package/package.json +2 -2
- package/src/module.mjs +1 -1
- package/src/npm-pkgbuild-cli.mjs +28 -13
- package/src/output/{pkg.mjs → arch.mjs} +46 -43
- package/src/output/deb.mjs +1 -1
- package/src/output/packager.mjs +1 -1
- package/src/output/rpm.mjs +1 -1
- package/src/util.mjs +2 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
|
|
12
12
|
## npm-pkgbuild
|
|
13
13
|
|
|
14
|
-
create ArchLinux, RPM and
|
|
14
|
+
create ArchLinux, RPM and Debian packages from npm packages.
|
|
15
15
|
|
|
16
16
|
# usage
|
|
17
17
|
|
|
18
18
|
In a package directory execute
|
|
19
19
|
|
|
20
20
|
```shell
|
|
21
|
-
npm-pkgbuild --
|
|
21
|
+
npm-pkgbuild --pkg
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
This will create a PKGBUILD file and execute it
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "7.11.
|
|
3
|
+
"version": "7.11.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./src/module.mjs"
|
|
10
10
|
},
|
|
11
|
-
"description": "create ArchLinux, RPM and
|
|
11
|
+
"description": "create ArchLinux, RPM and Debian packages from npm packages",
|
|
12
12
|
"keywords": [
|
|
13
13
|
"ArchLinux",
|
|
14
14
|
"arch-linux",
|
package/src/module.mjs
CHANGED
|
@@ -6,5 +6,5 @@ export * from "./content/node-modules-content-provider.mjs";
|
|
|
6
6
|
export * from "./content/npm-pack-content-provider.mjs";
|
|
7
7
|
export * from "./output/deb.mjs";
|
|
8
8
|
export * from "./output/rpm.mjs";
|
|
9
|
-
export * from "./output/
|
|
9
|
+
export * from "./output/arch.mjs";
|
|
10
10
|
export * from "./output/packager.mjs";
|
package/src/npm-pkgbuild-cli.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { aggregateFifo } from "aggregate-async-iterator";
|
|
|
8
8
|
import { createContext } from "expression-expander";
|
|
9
9
|
import { packageDirectory } from "pkg-dir";
|
|
10
10
|
import { utf8StreamOptions, extractFromPackage } from "./util.mjs";
|
|
11
|
-
import { FileContentProvider, DEB,
|
|
11
|
+
import { FileContentProvider, DEB, ARCH, RPM } from "npm-pkgbuild";
|
|
12
12
|
import { createExpressionTransformer } from "./util.mjs";
|
|
13
13
|
|
|
14
14
|
const { version, description } = JSON.parse(
|
|
@@ -18,7 +18,7 @@ const { version, description } = JSON.parse(
|
|
|
18
18
|
|
|
19
19
|
const cwd = process.cwd();
|
|
20
20
|
|
|
21
|
-
const allOutputs = [DEB,
|
|
21
|
+
const allOutputs = [DEB, ARCH, RPM];
|
|
22
22
|
|
|
23
23
|
program.description(description).version(version);
|
|
24
24
|
|
|
@@ -27,12 +27,16 @@ allOutputs.forEach(o =>
|
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
program
|
|
30
|
+
.option("--verbose", "be more verbose", false)
|
|
30
31
|
.option("-D --define <a=b>", "define property", str => {
|
|
31
32
|
const kv = str.split(/=/);
|
|
32
33
|
return Object.fromEntries([kv]);
|
|
33
34
|
})
|
|
34
|
-
.option(
|
|
35
|
-
|
|
35
|
+
.option(
|
|
36
|
+
"-d --destination <dir>",
|
|
37
|
+
"where to put the package(s)",
|
|
38
|
+
join(cwd, "dist")
|
|
39
|
+
)
|
|
36
40
|
.option("-p --pkgdir <dir>", "which package to use", process.cwd())
|
|
37
41
|
.option(
|
|
38
42
|
"-c --content <dir>",
|
|
@@ -48,18 +52,19 @@ program
|
|
|
48
52
|
)
|
|
49
53
|
.action(async options => {
|
|
50
54
|
try {
|
|
51
|
-
const pkgDir = await packageDirectory({ cwd: options.pkgdir});
|
|
55
|
+
const pkgDir = await packageDirectory({ cwd: options.pkgdir });
|
|
52
56
|
|
|
53
57
|
if (options.verbose) {
|
|
54
58
|
console.log(`pkgdir: ${pkgDir}`);
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
const { properties, sources, output } =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
const { properties, sources, output, dependencies } =
|
|
62
|
+
await extractFromPackage(
|
|
63
|
+
JSON.parse(
|
|
64
|
+
await readFile(join(pkgDir, "package.json"), utf8StreamOptions)
|
|
65
|
+
),
|
|
66
|
+
pkgDir
|
|
67
|
+
);
|
|
63
68
|
|
|
64
69
|
for (const outputFactory of allOutputs.filter(
|
|
65
70
|
o => options[o.name] === true || output[o.name] !== undefined
|
|
@@ -80,7 +85,7 @@ program
|
|
|
80
85
|
const context = createContext({ properties });
|
|
81
86
|
const output = new outputFactory(properties);
|
|
82
87
|
const transformer = [createExpressionTransformer(properties)];
|
|
83
|
-
|
|
88
|
+
|
|
84
89
|
if (options.verbose) {
|
|
85
90
|
console.log(output.properties);
|
|
86
91
|
}
|
|
@@ -88,11 +93,21 @@ program
|
|
|
88
93
|
const fileName = await output.execute(
|
|
89
94
|
aggregateFifo(sources.map(c => c[Symbol.asyncIterator]())),
|
|
90
95
|
transformer,
|
|
96
|
+
dependencies,
|
|
91
97
|
options,
|
|
92
98
|
path => context.expand(path)
|
|
93
99
|
);
|
|
94
100
|
|
|
95
|
-
|
|
101
|
+
/*
|
|
102
|
+
console.log(`#<CI>publish ${fileName}`);
|
|
103
|
+
|
|
104
|
+
if (publish !== undefined) {
|
|
105
|
+
context.properties.arch = arch;
|
|
106
|
+
|
|
107
|
+
publish = publish.replace(/\{\{(\w+)\}\}/m, (match, key, offset, string) =>
|
|
108
|
+
context.evaluate(key)
|
|
109
|
+
);
|
|
110
|
+
*/
|
|
96
111
|
}
|
|
97
112
|
} catch (e) {
|
|
98
113
|
console.log(e);
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { join } from "path";
|
|
2
|
-
import {
|
|
1
|
+
import { join, dirname } from "path";
|
|
2
|
+
import { createReadStream, createWriteStream } from "fs";
|
|
3
|
+
import { mkdir } from "fs/promises";
|
|
4
|
+
import { pipeline } from "stream/promises";
|
|
3
5
|
import { execa } from "execa";
|
|
4
6
|
import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
|
|
7
|
+
import { iterableStringInterceptor } from "iterable-string-interceptor";
|
|
5
8
|
import {
|
|
6
9
|
keyValueTransformer,
|
|
7
10
|
equalSeparatedKeyValuePairOptions
|
|
8
11
|
} from "key-value-transformer";
|
|
9
12
|
import { Packager } from "./packager.mjs";
|
|
10
13
|
import { copyEntries, transform, fieldProvider } from "../util.mjs";
|
|
11
|
-
import { quote } from "../util.mjs";
|
|
14
|
+
import { quote, utf8StreamOptions } from "../util.mjs";
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
17
|
* @type KeyValueTransformOptions
|
|
@@ -31,9 +34,9 @@ export const pkgKeyValuePairOptions = {
|
|
|
31
34
|
}${lineEnding}`
|
|
32
35
|
};
|
|
33
36
|
|
|
34
|
-
export class
|
|
37
|
+
export class ARCH extends Packager {
|
|
35
38
|
static get name() {
|
|
36
|
-
return "
|
|
39
|
+
return "arch";
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
static get fileNameExtension() {
|
|
@@ -49,20 +52,21 @@ export class PKG extends Packager {
|
|
|
49
52
|
return `${p.name}-${p.version}-${p.release}-${p.arch}${this.constructor.fileNameExtension}`;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
|
-
async execute(sources, transformer, options, expander) {
|
|
55
|
+
async execute(sources, transformer, dependencies, options, expander) {
|
|
53
56
|
const properties = this.properties;
|
|
54
57
|
|
|
55
|
-
if(properties.source) {
|
|
58
|
+
if (properties.source) {
|
|
56
59
|
properties.md5sums = ["SKIP"];
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
//properties.depends = makeDepends(
|
|
62
|
+
//properties.depends = makeDepends(dependencies);
|
|
60
63
|
|
|
61
64
|
const staging = await this.tmpdir;
|
|
62
65
|
|
|
63
66
|
async function* trailingLines() {
|
|
64
67
|
yield `
|
|
65
68
|
package() {
|
|
69
|
+
depends=(${makeDepends(dependencies).map(v=>quote(v)).join(',')})
|
|
66
70
|
cp -r $srcdir/* "$pkgdir"
|
|
67
71
|
}
|
|
68
72
|
`;
|
|
@@ -90,12 +94,24 @@ package() {
|
|
|
90
94
|
});
|
|
91
95
|
|
|
92
96
|
if (properties.hooks) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
async function* transformer(expression, remainder, source, cb) {
|
|
98
|
+
const value = properties[expression];
|
|
99
|
+
yield value === undefined ? "" : value;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const destination = join(staging, properties.hooks);
|
|
103
|
+
|
|
104
|
+
await mkdir(dirname(destination), { recursive: true });
|
|
105
|
+
|
|
106
|
+
await pipeline(
|
|
107
|
+
iterableStringInterceptor(
|
|
108
|
+
createReadStream(
|
|
109
|
+
join(options.pkgdir, properties.hooks),
|
|
110
|
+
utf8StreamOptions
|
|
111
|
+
),
|
|
112
|
+
transformer
|
|
113
|
+
),
|
|
114
|
+
createWriteStream(destination, utf8StreamOptions)
|
|
99
115
|
);
|
|
100
116
|
}
|
|
101
117
|
|
|
@@ -105,7 +121,7 @@ package() {
|
|
|
105
121
|
console.log(`stagingDir: ${staging}`);
|
|
106
122
|
}
|
|
107
123
|
|
|
108
|
-
const makepkg = await execa("makepkg", ["-f"], {
|
|
124
|
+
const makepkg = await execa("makepkg", ["-f", "-e"], {
|
|
109
125
|
cwd: staging,
|
|
110
126
|
env: { PKGDEST: options.destination }
|
|
111
127
|
});
|
|
@@ -125,7 +141,7 @@ package() {
|
|
|
125
141
|
const fields = {
|
|
126
142
|
pkgname: { alias: "name", type: "string[]", mandatory: true },
|
|
127
143
|
pkgver: { alias: "version", type: "string", mandatory: true },
|
|
128
|
-
pkgrel: { alias: "release", type: "integer", default:
|
|
144
|
+
pkgrel: { alias: "release", type: "integer", default: 1, mandatory: true },
|
|
129
145
|
epoch: { type: "integer", default: 0 },
|
|
130
146
|
pkgdesc: { alias: "description", type: "string", mandatory: true },
|
|
131
147
|
url: { alias: "homepage", type: "string" },
|
|
@@ -154,34 +170,21 @@ const fields = {
|
|
|
154
170
|
options: { type: "string[]" }
|
|
155
171
|
};
|
|
156
172
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
.map(
|
|
161
|
-
(c, i) => `${i ? "Contributor" : "Maintainer"}: ${c.name} <${c.email}>`
|
|
162
|
-
)
|
|
163
|
-
.join("\n# ")}
|
|
164
|
-
|
|
165
|
-
build() {
|
|
166
|
-
cd \${pkgname}${directory}
|
|
167
|
-
sed -i 's/"version": ".* /"version": "${
|
|
168
|
-
context.properties.pkgver
|
|
169
|
-
}",/' package.json
|
|
170
|
-
npm install
|
|
171
|
-
npm pack
|
|
172
|
-
npm prune --production
|
|
173
|
-
}
|
|
173
|
+
const mapping = {
|
|
174
|
+
node: "nodejs"
|
|
175
|
+
};
|
|
174
176
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
function normalizeExpression(e) {
|
|
178
|
+
e = e.replace(/\-([\w\d]+)$/, "");
|
|
179
|
+
if (e.match(/^\d+/)) {
|
|
180
|
+
return `>=${e}`;
|
|
181
|
+
}
|
|
179
182
|
|
|
180
|
-
|
|
181
|
-
npx npm-pkgbuild --package \${srcdir}/\${pkgname}${directory} --staging \${pkgdir} content
|
|
183
|
+
return e;
|
|
182
184
|
}
|
|
183
|
-
*/
|
|
184
185
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
186
|
+
function makeDepends(dependencies) {
|
|
187
|
+
return Object.entries(dependencies).map(
|
|
188
|
+
([name, version]) => `${name}${normalizeExpression(version)}`
|
|
189
|
+
);
|
|
190
|
+
}
|
package/src/output/deb.mjs
CHANGED
|
@@ -23,7 +23,7 @@ export class DEB extends Packager {
|
|
|
23
23
|
return `${p.name}_${p.version}_${p.arch}${this.constructor.fileNameExtension}`;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
async execute(sources, transformer, options, expander) {
|
|
26
|
+
async execute(sources, transformer, dependencies, options, expander) {
|
|
27
27
|
const properties = this.properties;
|
|
28
28
|
const staging = await this.tmpdir;
|
|
29
29
|
|
package/src/output/packager.mjs
CHANGED
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, transformer, options, expander) {
|
|
30
|
+
async execute(sources, transformer, dependencies, options, expander) {
|
|
31
31
|
const properties = this.properties;
|
|
32
32
|
const tmp = await this.tmpdir;
|
|
33
33
|
|
package/src/util.mjs
CHANGED
|
@@ -99,8 +99,8 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
99
99
|
let output = {};
|
|
100
100
|
|
|
101
101
|
const processPkg = pkg => {
|
|
102
|
-
if (pkg.
|
|
103
|
-
const pkgbuild = pkg.
|
|
102
|
+
if (pkg.pkg) {
|
|
103
|
+
const pkgbuild = pkg.pkg;
|
|
104
104
|
|
|
105
105
|
Object.assign(output, pkgbuild.output);
|
|
106
106
|
|