npm-pkgbuild 7.15.3 → 7.15.7
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 +5 -5
- package/src/extract-from-package.mjs +18 -15
- package/src/npm-pkgbuild-cli.mjs +7 -1
- package/src/util.mjs +47 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "7.15.
|
|
3
|
+
"version": "7.15.7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"aggregate-async-iterator": "^1.1.7",
|
|
42
42
|
"commander": "^8.3.0",
|
|
43
|
-
"content-entry": "^4.
|
|
44
|
-
"content-entry-filesystem": "^4.0.
|
|
45
|
-
"content-entry-transform": "^1.3.
|
|
43
|
+
"content-entry": "^4.1.1",
|
|
44
|
+
"content-entry-filesystem": "^4.0.2",
|
|
45
|
+
"content-entry-transform": "^1.3.3",
|
|
46
46
|
"execa": "^6.0.0",
|
|
47
47
|
"expression-expander": "^7.0.9",
|
|
48
|
-
"globby": "^12.0
|
|
48
|
+
"globby": "^12.1.0",
|
|
49
49
|
"iterable-string-interceptor": "^1.0.8",
|
|
50
50
|
"key-value-transformer": "^2.0.0",
|
|
51
51
|
"npm-package-walker": "^5.0.3",
|
|
@@ -11,9 +11,9 @@ export const allInputs = [NPMPackContentProvider, NodeModulesContentProvider];
|
|
|
11
11
|
export const allOutputs = [DEB, ARCH, RPM];
|
|
12
12
|
|
|
13
13
|
const npmArchMapping = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
arm64: "aarch64",
|
|
15
|
+
arm: "armv7h",
|
|
16
|
+
x86: "x86_64"
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -48,8 +48,12 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (pkg.repository) {
|
|
51
|
-
if (pkg.repository
|
|
52
|
-
properties.source = pkg.repository
|
|
51
|
+
if (typeof pkg.repository === "string") {
|
|
52
|
+
properties.source = pkg.repository;
|
|
53
|
+
} else {
|
|
54
|
+
if (pkg.repository.url) {
|
|
55
|
+
properties.source = pkg.repository.url;
|
|
56
|
+
}
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
59
|
|
|
@@ -57,24 +61,23 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
57
61
|
let sources = [];
|
|
58
62
|
let output = {};
|
|
59
63
|
let arch = new Set();
|
|
60
|
-
|
|
61
|
-
const processPkg = (pkg, dir) => {
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
const processPkg = (pkg, dir) => {
|
|
66
|
+
if (pkg.cpu) {
|
|
67
|
+
for (const a of asArray(pkg.cpu)) {
|
|
65
68
|
arch.add(npmArchMapping[a]);
|
|
66
69
|
}
|
|
67
|
-
}
|
|
70
|
+
}
|
|
68
71
|
|
|
69
72
|
if (pkg.pkg) {
|
|
70
73
|
const pkgbuild = pkg.pkg;
|
|
71
74
|
|
|
72
|
-
if(pkgbuild.arch) {
|
|
73
|
-
for(const a of asArray(pkgbuild.arch)) {
|
|
75
|
+
if (pkgbuild.arch) {
|
|
76
|
+
for (const a of asArray(pkgbuild.arch)) {
|
|
74
77
|
arch.add(a);
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
|
-
|
|
80
|
+
|
|
78
81
|
Object.assign(output, pkgbuild.output);
|
|
79
82
|
|
|
80
83
|
Object.entries(pkgbuild)
|
|
@@ -118,9 +121,9 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
118
121
|
|
|
119
122
|
processPkg(pkg, dir);
|
|
120
123
|
|
|
121
|
-
if(arch.size > 0) {
|
|
124
|
+
if (arch.size > 0) {
|
|
122
125
|
properties.arch = [...arch];
|
|
123
126
|
}
|
|
124
|
-
|
|
127
|
+
|
|
125
128
|
return { properties, sources, dependencies, output };
|
|
126
129
|
}
|
package/src/npm-pkgbuild-cli.mjs
CHANGED
|
@@ -82,7 +82,13 @@ program
|
|
|
82
82
|
o => options[o.name] === true || output[o.name] !== undefined
|
|
83
83
|
)) {
|
|
84
84
|
Object.assign(properties, options.define);
|
|
85
|
-
|
|
85
|
+
|
|
86
|
+
for(const [k,v] of Object.entries(properties)) {
|
|
87
|
+
if(typeof(v) === 'string') {
|
|
88
|
+
properties[k] = v.replace(/\$\{([^\}]+)\}/m,(m,k) => properties[k]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
86
92
|
sources.push(
|
|
87
93
|
...[...options.content, ...options.meta]
|
|
88
94
|
.filter(x => x)
|
package/src/util.mjs
CHANGED
|
@@ -2,11 +2,56 @@ import { join, dirname } from "path";
|
|
|
2
2
|
import { mkdir } from "fs/promises";
|
|
3
3
|
import { pipeline } from "stream/promises";
|
|
4
4
|
import { createWriteStream } from "fs";
|
|
5
|
-
import { iterableStringInterceptor } from "iterable-string-interceptor";
|
|
6
|
-
import { ReadableStreamContentEntry } from "content-entry";
|
|
7
5
|
|
|
8
6
|
export const utf8StreamOptions = { encoding: "utf8" };
|
|
9
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Extract shell functions from a given text
|
|
10
|
+
* @param {AsyncIterator<string>} source
|
|
11
|
+
* @return {AsyncIterator<FunctionDecl>}
|
|
12
|
+
*/
|
|
13
|
+
export async function* extractFunctions(source) {
|
|
14
|
+
let name;
|
|
15
|
+
let body = [];
|
|
16
|
+
|
|
17
|
+
for await (const line of asLines(source)) {
|
|
18
|
+
let m;
|
|
19
|
+
|
|
20
|
+
if ((m = line.match(/^\s*(function\s*)?([\w_]+)\s*\(\s*\)/))) {
|
|
21
|
+
name = m[2];
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (name) {
|
|
26
|
+
if (line.match(/^}$/)) {
|
|
27
|
+
yield { name, body: body.join("\n")};
|
|
28
|
+
name = undefined;
|
|
29
|
+
body.length = 0;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
body.push(line);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function* asLines(source) {
|
|
39
|
+
let buffer = "";
|
|
40
|
+
|
|
41
|
+
for await (let chunk of source) {
|
|
42
|
+
buffer += chunk.toString();
|
|
43
|
+
const lines = buffer.split(/\n\r?/);
|
|
44
|
+
buffer = lines.pop();
|
|
45
|
+
for (const line of lines) {
|
|
46
|
+
yield line;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (buffer.length > 0) {
|
|
51
|
+
yield buffer;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
10
55
|
export function quote(v) {
|
|
11
56
|
if (v === undefined) return "";
|
|
12
57
|
|