npm-pkgbuild 8.0.2 → 8.1.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/README.md +23 -4
- package/package.json +9 -6
- package/src/content/node-modules-content-provider.mjs +5 -2
- package/src/output/arch.mjs +10 -7
- package/src/output/rpm.mjs +13 -7
package/README.md
CHANGED
|
@@ -11,18 +11,37 @@
|
|
|
11
11
|
|
|
12
12
|
## npm-pkgbuild
|
|
13
13
|
|
|
14
|
-
|
|
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 --rpm --debian --arch --content build
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
This will create a
|
|
25
|
-
|
|
24
|
+
This will create a arch, rpm and a debian package of the build dir.
|
|
25
|
+
|
|
26
|
+
You can specify the package content in package.json.
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"pkg": {
|
|
31
|
+
"content": {
|
|
32
|
+
"/some/location" : { "base": "build" },
|
|
33
|
+
"/etc/myconfig.json" : "sample-config.json"
|
|
34
|
+
},
|
|
35
|
+
"hooks" : "pkg/hooks",
|
|
36
|
+
"output": {
|
|
37
|
+
"debian" : {},
|
|
38
|
+
"rpm" : {},
|
|
39
|
+
"arch" : {}
|
|
40
|
+
},
|
|
41
|
+
"dependencies": { "nginx" : ">=1.12" }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
26
45
|
|
|
27
46
|
# API
|
|
28
47
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
"ArchLinux",
|
|
14
14
|
"arch-linux",
|
|
15
15
|
"aur",
|
|
16
|
+
"deb",
|
|
16
17
|
"debian",
|
|
18
|
+
"package",
|
|
17
19
|
"pacman",
|
|
18
20
|
"pkgbuild",
|
|
19
21
|
"rpm",
|
|
@@ -41,14 +43,15 @@
|
|
|
41
43
|
"@npmcli/arborist": "^5.0.3",
|
|
42
44
|
"aggregate-async-iterator": "^1.1.9",
|
|
43
45
|
"commander": "^9.1.0",
|
|
44
|
-
"content-entry": "^4.1.
|
|
45
|
-
"content-entry-filesystem": "^4.0.
|
|
46
|
-
"content-entry-transform": "^1.3.
|
|
46
|
+
"content-entry": "^4.1.9",
|
|
47
|
+
"content-entry-filesystem": "^4.0.9",
|
|
48
|
+
"content-entry-transform": "^1.3.15",
|
|
47
49
|
"execa": "^6.1.0",
|
|
48
50
|
"expression-expander": "^7.0.15",
|
|
49
51
|
"globby": "^13.1.0",
|
|
52
|
+
"ini": "^2.0.0",
|
|
50
53
|
"iterable-string-interceptor": "^1.0.14",
|
|
51
|
-
"key-value-transformer": "^2.
|
|
54
|
+
"key-value-transformer": "^2.1.1",
|
|
52
55
|
"node-fetch": "^3.2.3",
|
|
53
56
|
"npm-package-walker": "^5.0.5",
|
|
54
57
|
"npm-packlist": "^4.0.0",
|
|
@@ -64,7 +67,7 @@
|
|
|
64
67
|
"stream-buffers": "^3.0.2"
|
|
65
68
|
},
|
|
66
69
|
"engines": {
|
|
67
|
-
"node": ">=16.
|
|
70
|
+
"node": ">=16.14.2"
|
|
68
71
|
},
|
|
69
72
|
"repository": {
|
|
70
73
|
"type": "git",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { tmpdir } from "os";
|
|
1
|
+
import { tmpdir, homedir } from "os";
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { mkdtemp, readFile, writeFile } from "fs/promises";
|
|
4
4
|
import { globby } from "globby";
|
|
5
5
|
import Arborist from "@npmcli/arborist";
|
|
6
|
+
import { parse } from "ini";
|
|
6
7
|
import { StringContentEntry } from "content-entry";
|
|
7
8
|
import { FileSystemEntry } from "content-entry-filesystem";
|
|
8
9
|
import { ContentProvider } from "./content-provider.mjs";
|
|
@@ -47,7 +48,9 @@ export class NodeModulesContentProvider extends ContentProvider {
|
|
|
47
48
|
utf8StreamOptions
|
|
48
49
|
);
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
// TODO find .npmrc
|
|
52
|
+
const npmrc = parse(await readFile(join(homedir(), ".npmrc"), utf8StreamOptions));
|
|
53
|
+
const arb = new Arborist({ path: tmp, ...npmrc });
|
|
51
54
|
await arb.buildIdealTree({
|
|
52
55
|
update: true,
|
|
53
56
|
prune: true,
|
package/src/output/arch.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
|
-
import { createReadStream, createWriteStream
|
|
2
|
+
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";
|
|
@@ -34,14 +34,17 @@ export const pkgKeyValuePairOptions = {
|
|
|
34
34
|
return [m[2], m[3] ? m[3].split(/\s*,\s*/) : m[4]];
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
|
|
38
|
-
`${keyPrefix(key)}=${
|
|
39
|
-
Array.isArray(value)
|
|
40
|
-
? "(" + value.map(v => quote(v)).join(" ") + ")"
|
|
41
|
-
: quote(value)
|
|
42
|
-
}${lineEnding}`
|
|
37
|
+
keyValueLines: keyValueLines3
|
|
43
38
|
};
|
|
44
39
|
|
|
40
|
+
function* keyValueLines3(key, value, lineEnding) {
|
|
41
|
+
yield `${keyPrefix(key)}=${
|
|
42
|
+
Array.isArray(value)
|
|
43
|
+
? "(" + value.map(v => quote(v)).join(" ") + ")"
|
|
44
|
+
: quote(value)
|
|
45
|
+
}${lineEnding}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
45
48
|
function keyPrefix(key) {
|
|
46
49
|
const f = fields[key];
|
|
47
50
|
return f && f.prefix ? f.prefix + key : key;
|
package/src/output/rpm.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
|
|
|
6
6
|
import { transform } from "content-entry-transform";
|
|
7
7
|
import {
|
|
8
8
|
keyValueTransformer,
|
|
9
|
-
|
|
9
|
+
colonSeparatedKeyValuePairOptionsDoublingKeys
|
|
10
10
|
} from "key-value-transformer";
|
|
11
11
|
import { aggregateFifo } from "aggregate-async-iterator";
|
|
12
12
|
import { Packager } from "./packager.mjs";
|
|
@@ -25,7 +25,7 @@ const hookMapping = {
|
|
|
25
25
|
post_install: "post",
|
|
26
26
|
pre_remove: "preun",
|
|
27
27
|
post_remove: "postun"
|
|
28
|
-
/* TODO with logic check $1
|
|
28
|
+
/* TODO with logic check $1
|
|
29
29
|
pre_upgrade:
|
|
30
30
|
post_upgrade:*/
|
|
31
31
|
};
|
|
@@ -74,9 +74,10 @@ export class RPM extends Packager {
|
|
|
74
74
|
const { properties, tmpdir, staging, destination } =
|
|
75
75
|
await this.prepareExecute(options);
|
|
76
76
|
|
|
77
|
-
properties.Requires = Object.entries(dependencies)
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
properties.Requires = Object.entries(dependencies).map(
|
|
78
|
+
([name, e]) =>
|
|
79
|
+
`${name} ${e.replace(/([<=>])\d/, (match, p1) => `${p1} `)}`
|
|
80
|
+
);
|
|
80
81
|
|
|
81
82
|
const specFileName = `${properties.name}.spec`;
|
|
82
83
|
|
|
@@ -130,7 +131,7 @@ export class RPM extends Packager {
|
|
|
130
131
|
new ReadableStreamContentEntry(
|
|
131
132
|
entry.name,
|
|
132
133
|
keyValueTransformer(await entry.readStream, fp, {
|
|
133
|
-
...
|
|
134
|
+
...colonSeparatedKeyValuePairOptionsDoublingKeys,
|
|
134
135
|
trailingLines
|
|
135
136
|
})
|
|
136
137
|
),
|
|
@@ -168,6 +169,8 @@ export class RPM extends Packager {
|
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
|
|
172
|
+
|
|
173
|
+
const pkglist = { type: "string[]" };
|
|
171
174
|
/**
|
|
172
175
|
* @see https://rpm-packaging-guide.github.io
|
|
173
176
|
*/
|
|
@@ -188,5 +191,8 @@ const fields = {
|
|
|
188
191
|
mandatory: true
|
|
189
192
|
},
|
|
190
193
|
URL: { alias: "homepage", type: "string" },
|
|
191
|
-
Requires:
|
|
194
|
+
Requires: pkglist,
|
|
195
|
+
Obsoletes: pkglist,
|
|
196
|
+
Conflicts: pkglist
|
|
192
197
|
};
|
|
198
|
+
|