npm-pkgbuild 7.7.0 → 7.8.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 +1 -1
- package/package.json +2 -2
- package/src/output/deb.mjs +3 -2
- package/src/output/pkg.mjs +7 -5
- package/src/output/rpm.mjs +7 -2
- package/src/util.mjs +17 -9
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.1",
|
|
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 packages from npm packages",
|
|
11
|
+
"description": "create ArchLinux, RPM and debian packages from npm packages",
|
|
12
12
|
"keywords": [
|
|
13
13
|
"ArchLinux",
|
|
14
14
|
"arch-linux",
|
package/src/output/deb.mjs
CHANGED
|
@@ -58,7 +58,8 @@ export class DEB extends Packager {
|
|
|
58
58
|
|
|
59
59
|
await copyEntries(transform(sources, transformers), staging, expander, attributes);
|
|
60
60
|
|
|
61
|
-
await execa("dpkg", ["-b", staging, options.destination]);
|
|
61
|
+
const dpkg = await execa("dpkg", ["-b", staging, options.destination]);
|
|
62
|
+
//console.log(dpkg.stdout);
|
|
62
63
|
|
|
63
64
|
return join(options.destination, this.packageFileName);
|
|
64
65
|
}
|
|
@@ -81,7 +82,7 @@ const fields = {
|
|
|
81
82
|
Architecture: {
|
|
82
83
|
alias: "arch",
|
|
83
84
|
type: "string",
|
|
84
|
-
default: "
|
|
85
|
+
default: "all",
|
|
85
86
|
mandatory: true
|
|
86
87
|
},
|
|
87
88
|
Homepage: { alias: "homepage", type: "string" },
|
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 } from "../util.mjs";
|
|
10
|
-
import { quote,
|
|
10
|
+
import { quote, createExpressionTransformer } from "../util.mjs";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @type KeyValueTransformOptions
|
|
@@ -45,7 +45,7 @@ export class PKG extends Packager {
|
|
|
45
45
|
|
|
46
46
|
get packageFileName() {
|
|
47
47
|
const p = this.properties;
|
|
48
|
-
return `${p.name}-${p.version}-${p.release}
|
|
48
|
+
return `${p.name}-${p.version}-${p.release}-${p.arch}${this.constructor.fileNameExtension}`;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
async execute(sources, options, expander) {
|
|
@@ -77,10 +77,9 @@ package() {
|
|
|
77
77
|
`;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
await copyEntries(transform(sources, []), join(staging, "src"), expander);
|
|
80
|
+
await copyEntries(transform(sources, [createExpressionTransformer(properties)]), join(staging, "src"), expander);
|
|
81
81
|
|
|
82
82
|
const metaTransformers = [
|
|
83
|
-
createPropertyTransformer(properties),
|
|
84
83
|
{
|
|
85
84
|
match: entry => entry.name === "PKGBUILD",
|
|
86
85
|
transform: async entry =>
|
|
@@ -101,7 +100,10 @@ package() {
|
|
|
101
100
|
expander
|
|
102
101
|
);
|
|
103
102
|
|
|
104
|
-
await execa("makepkg", ["-f"], {
|
|
103
|
+
await execa("makepkg", ["-f"], {
|
|
104
|
+
cwd: staging,
|
|
105
|
+
env: { PKGDEST: options.destination }
|
|
106
|
+
});
|
|
105
107
|
|
|
106
108
|
return join(options.destination, this.packageFileName);
|
|
107
109
|
}
|
package/src/output/rpm.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
|
-
import { mkdir } from "fs/promises";
|
|
2
|
+
import { mkdir, cp } from "fs/promises";
|
|
3
3
|
import { execa } from "execa";
|
|
4
4
|
import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
|
|
5
5
|
import {
|
|
@@ -78,7 +78,7 @@ export class RPM extends Packager {
|
|
|
78
78
|
|
|
79
79
|
await copyEntries(transform(sources, transformers), staging, expander);
|
|
80
80
|
|
|
81
|
-
await execa("rpmbuild", [
|
|
81
|
+
const rpmbuild = await execa("rpmbuild", [
|
|
82
82
|
"--define",
|
|
83
83
|
`_topdir ${tmp}`,
|
|
84
84
|
"-vv",
|
|
@@ -86,6 +86,11 @@ export class RPM extends Packager {
|
|
|
86
86
|
join(staging, specFileName)
|
|
87
87
|
]);
|
|
88
88
|
|
|
89
|
+
await cp(
|
|
90
|
+
join(tmp, "RPMS", properties.arch, this.packageFileName),
|
|
91
|
+
join(options.destination, this.packageFileName),
|
|
92
|
+
{preserveTimestamps :true }
|
|
93
|
+
);
|
|
89
94
|
return join(options.destination, this.packageFileName);
|
|
90
95
|
}
|
|
91
96
|
}
|
package/src/util.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { mkdir } from "fs/promises";
|
|
|
3
3
|
import { pipeline } from "stream/promises";
|
|
4
4
|
import { createWriteStream } from "fs";
|
|
5
5
|
import { iterableStringInterceptor } from "iterable-string-interceptor";
|
|
6
|
+
import { ReadableStreamContentEntry } from "content-entry";
|
|
6
7
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
7
8
|
import { packageWalker } from "npm-package-walker";
|
|
8
9
|
|
|
@@ -32,7 +33,7 @@ export function asArray(o) {
|
|
|
32
33
|
*/
|
|
33
34
|
export async function extractFromPackage(pkg, dir) {
|
|
34
35
|
const properties = Object.fromEntries(
|
|
35
|
-
["name", "version", "description", "homepage"]
|
|
36
|
+
["name", "version", "description", "homepage", "license"]
|
|
36
37
|
.map(key => [key, pkg[key]])
|
|
37
38
|
.filter(([k, v]) => v !== undefined)
|
|
38
39
|
);
|
|
@@ -58,13 +59,13 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
58
59
|
let dependencies = { ...pkg.engines };
|
|
59
60
|
let sources = [];
|
|
60
61
|
let output = {};
|
|
61
|
-
|
|
62
|
+
|
|
62
63
|
const processPkg = pkg => {
|
|
63
64
|
if (pkg.pkgbuild) {
|
|
64
65
|
const pkgbuild = pkg.pkgbuild;
|
|
65
66
|
|
|
66
67
|
Object.assign(output, pkgbuild.output);
|
|
67
|
-
|
|
68
|
+
|
|
68
69
|
Object.entries(pkgbuild)
|
|
69
70
|
.filter(([k, v]) => typeof v === "string")
|
|
70
71
|
.forEach(([k, v]) => (properties[k] = v));
|
|
@@ -81,7 +82,7 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
81
82
|
};
|
|
82
83
|
|
|
83
84
|
await packageWalker(async (pkg, base, modulePath) => {
|
|
84
|
-
processPkg(pkg)
|
|
85
|
+
processPkg(pkg);
|
|
85
86
|
return true;
|
|
86
87
|
}, dir);
|
|
87
88
|
|
|
@@ -90,18 +91,25 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
90
91
|
return { properties, sources, dependencies, output };
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
export function
|
|
94
|
+
export function createExpressionTransformer(
|
|
95
|
+
properties,
|
|
96
|
+
match = entry => entry.name.match(/\.(conf|json)$/)
|
|
97
|
+
) {
|
|
94
98
|
async function* transformer(expression, remainder, source, cb) {
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
const value = properties[expression];
|
|
100
|
+
console.log("EXPRESSION", expression, value);
|
|
101
|
+
yield value === undefined ? "" : value;
|
|
97
102
|
}
|
|
98
103
|
|
|
99
104
|
return {
|
|
100
|
-
match
|
|
105
|
+
match,
|
|
101
106
|
transform: async entry =>
|
|
102
107
|
new ReadableStreamContentEntry(
|
|
103
108
|
entry.name,
|
|
104
|
-
iterableStringInterceptor(
|
|
109
|
+
iterableStringInterceptor(
|
|
110
|
+
await entry.getReadStream(utf8StreamOptions),
|
|
111
|
+
transformer
|
|
112
|
+
)
|
|
105
113
|
)
|
|
106
114
|
};
|
|
107
115
|
}
|