npm-pkgbuild 7.15.5 → 7.15.6
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/extract-from-package.mjs +14 -16
- package/src/npm-pkgbuild-cli.mjs +7 -1
- package/src/util.mjs +47 -2
package/package.json
CHANGED
|
@@ -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,10 +48,9 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (pkg.repository) {
|
|
51
|
-
if(typeof
|
|
51
|
+
if (typeof pkg.repository === "string") {
|
|
52
52
|
properties.source = pkg.repository;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
53
|
+
} else {
|
|
55
54
|
if (pkg.repository.url) {
|
|
56
55
|
properties.source = pkg.repository.url;
|
|
57
56
|
}
|
|
@@ -62,24 +61,23 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
62
61
|
let sources = [];
|
|
63
62
|
let output = {};
|
|
64
63
|
let arch = new Set();
|
|
65
|
-
|
|
66
|
-
const processPkg = (pkg, dir) => {
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
const processPkg = (pkg, dir) => {
|
|
66
|
+
if (pkg.cpu) {
|
|
67
|
+
for (const a of asArray(pkg.cpu)) {
|
|
70
68
|
arch.add(npmArchMapping[a]);
|
|
71
69
|
}
|
|
72
|
-
}
|
|
70
|
+
}
|
|
73
71
|
|
|
74
72
|
if (pkg.pkg) {
|
|
75
73
|
const pkgbuild = pkg.pkg;
|
|
76
74
|
|
|
77
|
-
if(pkgbuild.arch) {
|
|
78
|
-
for(const a of asArray(pkgbuild.arch)) {
|
|
75
|
+
if (pkgbuild.arch) {
|
|
76
|
+
for (const a of asArray(pkgbuild.arch)) {
|
|
79
77
|
arch.add(a);
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
|
-
|
|
80
|
+
|
|
83
81
|
Object.assign(output, pkgbuild.output);
|
|
84
82
|
|
|
85
83
|
Object.entries(pkgbuild)
|
|
@@ -123,9 +121,9 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
123
121
|
|
|
124
122
|
processPkg(pkg, dir);
|
|
125
123
|
|
|
126
|
-
if(arch.size > 0) {
|
|
124
|
+
if (arch.size > 0) {
|
|
127
125
|
properties.arch = [...arch];
|
|
128
126
|
}
|
|
129
|
-
|
|
127
|
+
|
|
130
128
|
return { properties, sources, dependencies, output };
|
|
131
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
|
|