npm-pkgbuild 8.3.3 → 8.3.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 +4 -4
- package/src/content/npm-pack-content-provider.mjs +16 -8
- package/src/output/rpm.mjs +5 -5
- package/src/util.mjs +13 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
"commander": "^9.1.0",
|
|
46
46
|
"content-entry": "^4.1.9",
|
|
47
47
|
"content-entry-filesystem": "^4.0.9",
|
|
48
|
-
"content-entry-transform": "^1.3.
|
|
48
|
+
"content-entry-transform": "^1.3.16",
|
|
49
49
|
"execa": "^6.1.0",
|
|
50
50
|
"expression-expander": "^7.0.16",
|
|
51
51
|
"globby": "^13.1.0",
|
|
52
|
-
"ini": "^
|
|
52
|
+
"ini": "^3.0.0",
|
|
53
53
|
"iterable-string-interceptor": "^1.0.15",
|
|
54
54
|
"key-value-transformer": "^2.1.1",
|
|
55
55
|
"node-fetch": "^3.2.3",
|
|
56
56
|
"npm-package-walker": "^5.0.6",
|
|
57
57
|
"npm-packlist": "^4.0.0",
|
|
58
|
-
"pacote": "^13.0
|
|
58
|
+
"pacote": "^13.1.0",
|
|
59
59
|
"pkg-dir": "^6.0.1",
|
|
60
60
|
"tar-stream": "^2.2.0"
|
|
61
61
|
},
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { pipeline } from "stream/promises";
|
|
2
2
|
import { createGunzip } from "zlib";
|
|
3
3
|
import pacote from "pacote";
|
|
4
|
-
import
|
|
5
|
-
import { ContentProvider } from "./content-provider.mjs";
|
|
4
|
+
import { extract as tarExtract } from "tar-stream";
|
|
6
5
|
import { BufferContentEntry } from "content-entry";
|
|
6
|
+
import { ContentProvider } from "./content-provider.mjs";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Content from npm pack.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} definitions
|
|
12
|
+
* @param {Object} entryProperties to be set for each entry
|
|
10
13
|
*/
|
|
11
14
|
export class NPMPackContentProvider extends ContentProvider {
|
|
12
15
|
/**
|
|
@@ -23,11 +26,13 @@ export class NPMPackContentProvider extends ContentProvider {
|
|
|
23
26
|
constructor(definitions, entryProperties) {
|
|
24
27
|
super();
|
|
25
28
|
Object.assign(this, definitions);
|
|
26
|
-
|
|
29
|
+
|
|
30
|
+
this.entryProperties = Object.fromEntries(
|
|
31
|
+
Object.entries(entryProperties).map(([key, value]) => [key, { value }])
|
|
32
|
+
);
|
|
27
33
|
}
|
|
28
34
|
|
|
29
|
-
toString()
|
|
30
|
-
{
|
|
35
|
+
toString() {
|
|
31
36
|
return `${this.constructor.name}: ${this.dir} -> ${this.entryProperties.destination}`;
|
|
32
37
|
}
|
|
33
38
|
|
|
@@ -35,7 +40,7 @@ export class NPMPackContentProvider extends ContentProvider {
|
|
|
35
40
|
const entries = [];
|
|
36
41
|
|
|
37
42
|
await pacote.tarball.stream(this.dir, async stream => {
|
|
38
|
-
const extract =
|
|
43
|
+
const extract = tarExtract();
|
|
39
44
|
|
|
40
45
|
extract.on("entry", async (header, stream, next) => {
|
|
41
46
|
stream.on("end", () => next());
|
|
@@ -46,12 +51,15 @@ export class NPMPackContentProvider extends ContentProvider {
|
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
entries.push(
|
|
49
|
-
Object.
|
|
54
|
+
Object.create(
|
|
50
55
|
new BufferContentEntry(
|
|
51
56
|
header.name.substring(8),
|
|
52
57
|
Buffer.concat(chunks)
|
|
53
58
|
),
|
|
54
|
-
|
|
59
|
+
{
|
|
60
|
+
mode: { value: header.mode },
|
|
61
|
+
...this.entryProperties
|
|
62
|
+
}
|
|
55
63
|
)
|
|
56
64
|
);
|
|
57
65
|
|
package/src/output/rpm.mjs
CHANGED
|
@@ -31,13 +31,13 @@ const hookMapping = {
|
|
|
31
31
|
post_upgrade:*/
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
export function requiresFromDependencies(dependencies)
|
|
35
|
-
{
|
|
34
|
+
export function requiresFromDependencies(dependencies) {
|
|
36
35
|
return Object.entries(dependencies).map(
|
|
37
36
|
([name, e]) =>
|
|
38
|
-
`${
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
`${packageNameMapping[name] ? packageNameMapping[name] : name}${e
|
|
38
|
+
.replace(/^\s*(\w+)/, (match, p1) => ` = ${p1}`)
|
|
39
|
+
.replace(/^\s*$/, "")
|
|
40
|
+
.replace(/^\s*(<|<=|>|>=|=)\s*(\w+)/, (match, p1, p2) => ` ${p1} ${p2}`)}`
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
43
|
|
package/src/util.mjs
CHANGED
|
@@ -39,18 +39,28 @@ export function decodePassword(password)
|
|
|
39
39
|
*/
|
|
40
40
|
export async function* extractFunctions(source) {
|
|
41
41
|
let name;
|
|
42
|
+
let insideBody;
|
|
42
43
|
const body = [];
|
|
43
44
|
|
|
44
45
|
for await (const line of asLines(source)) {
|
|
45
46
|
let m;
|
|
46
47
|
|
|
47
|
-
if ((m = line.match(/^\s*(function\s*)?([\w_]+)\s*\(\s*\)
|
|
48
|
+
if ((m = line.match(/^\s*(function\s*)?([\w_]+)\s*\(\s*\)\s*(\{)?/))) {
|
|
48
49
|
name = m[2];
|
|
50
|
+
insideBody = m[3] ? true : false;
|
|
49
51
|
continue;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
if (name) {
|
|
53
|
-
if (line.match(
|
|
55
|
+
if (line.match(/^\s*{\s*$/)) {
|
|
56
|
+
if(insideBody) {
|
|
57
|
+
body.push(line);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
insideBody = true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else if (line.match(/^}$/)) {
|
|
54
64
|
yield { name, body: body.join("\n")};
|
|
55
65
|
name = undefined;
|
|
56
66
|
body.length = 0;
|
|
@@ -114,7 +124,7 @@ export function fieldProvider(properties, fields) {
|
|
|
114
124
|
if (value === undefined) {
|
|
115
125
|
if (field.default === undefined) {
|
|
116
126
|
if (field.mandatory) {
|
|
117
|
-
console.
|
|
127
|
+
console.error(`Missing value for mandatory field ${name}`);
|
|
118
128
|
}
|
|
119
129
|
} else {
|
|
120
130
|
yield [name, field.default];
|