npm-pkgbuild 8.1.2 → 8.2.2
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 +6 -1
- package/package.json +1 -1
- package/src/content/node-modules-content-provider.mjs +50 -36
- package/src/output/arch.mjs +3 -5
- package/src/output/debian.mjs +3 -2
- package/src/output/rpm.mjs +5 -4
- package/src/util.mjs +7 -0
package/README.md
CHANGED
|
@@ -36,7 +36,8 @@ You can specify the package content in package.json.
|
|
|
36
36
|
"type": "npm-pack"
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
|
-
"type": "node-modules"
|
|
39
|
+
"type": "node-modules",
|
|
40
|
+
"withoutDevelpmentDependencies": true
|
|
40
41
|
}
|
|
41
42
|
]
|
|
42
43
|
},
|
|
@@ -65,6 +66,10 @@ content as provided by npm pack
|
|
|
65
66
|
|
|
66
67
|
content of all (production) dependencies
|
|
67
68
|
|
|
69
|
+
options:
|
|
70
|
+
- withoutDevelpmentDependencies when to stip away dev dependencies
|
|
71
|
+
|
|
72
|
+
|
|
68
73
|
# API
|
|
69
74
|
|
|
70
75
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ export class NodeModulesContentProvider extends ContentProvider {
|
|
|
27
27
|
|
|
28
28
|
constructor(definitions, entryProperties) {
|
|
29
29
|
super();
|
|
30
|
-
Object.assign(this, definitions);
|
|
30
|
+
Object.assign(this, { withoutDevelpmentDependencies: true }, definitions);
|
|
31
31
|
this.entryProperties = entryProperties;
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -36,51 +36,65 @@ export class NodeModulesContentProvider extends ContentProvider {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
async *[Symbol.asyncIterator]() {
|
|
39
|
-
|
|
39
|
+
let pkgSourceDir = this.dir;
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
await
|
|
43
|
-
);
|
|
44
|
-
delete json.devDependencies;
|
|
45
|
-
await writeFile(
|
|
46
|
-
join(tmp, "package.json"),
|
|
47
|
-
JSON.stringify(json),
|
|
48
|
-
utf8StreamOptions
|
|
49
|
-
);
|
|
41
|
+
if (this.withoutDevelpmentDependencies) {
|
|
42
|
+
pkgSourceDir = await mkdtemp(join(tmpdir(), "node-modules"));
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
44
|
+
const json = JSON.parse(
|
|
45
|
+
await readFile(join(this.dir, "package.json"), utf8StreamOptions)
|
|
46
|
+
);
|
|
47
|
+
delete json.devDependencies;
|
|
48
|
+
await writeFile(
|
|
49
|
+
join(pkgSourceDir, "package.json"),
|
|
50
|
+
JSON.stringify(json),
|
|
51
|
+
utf8StreamOptions
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
// TODO find .npmrc
|
|
55
|
+
const npmrc = parse(
|
|
56
|
+
await readFile(join(homedir(), ".npmrc"), utf8StreamOptions)
|
|
57
|
+
);
|
|
58
|
+
const arb = new Arborist({ path: pkgSourceDir, ...npmrc });
|
|
59
|
+
await arb.buildIdealTree({
|
|
60
|
+
update: true,
|
|
61
|
+
prune: true,
|
|
62
|
+
saveType: "prod"
|
|
63
|
+
});
|
|
64
|
+
await arb.prune({ saveType: "prod" });
|
|
65
|
+
await arb.reify({ save: true });
|
|
66
|
+
}
|
|
61
67
|
|
|
62
68
|
for (const name of await globby("node_modules/**/*", {
|
|
63
|
-
cwd:
|
|
69
|
+
cwd: pkgSourceDir
|
|
64
70
|
})) {
|
|
65
71
|
if (!toBeSkipped.test(name)) {
|
|
66
72
|
if (name.endsWith("package.json")) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
yield Object.assign(
|
|
74
|
-
new StringContentEntry(name, JSON.stringify(json)),
|
|
75
|
-
this.entryProperties
|
|
73
|
+
try {
|
|
74
|
+
const json = shrinkNPM(
|
|
75
|
+
JSON.parse(
|
|
76
|
+
await readFile(join(pkgSourceDir, name), utf8StreamOptions)
|
|
77
|
+
),
|
|
78
|
+
{}
|
|
76
79
|
);
|
|
80
|
+
|
|
81
|
+
if (json) {
|
|
82
|
+
yield Object.assign(
|
|
83
|
+
new StringContentEntry(name, JSON.stringify(json)),
|
|
84
|
+
this.entryProperties
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
continue;
|
|
89
|
+
} catch (e) {
|
|
90
|
+
console.error(e, name);
|
|
77
91
|
}
|
|
78
|
-
} else {
|
|
79
|
-
yield Object.assign(
|
|
80
|
-
new FileSystemEntry(name, tmp),
|
|
81
|
-
this.entryProperties
|
|
82
|
-
);
|
|
83
92
|
}
|
|
93
|
+
|
|
94
|
+
yield Object.assign(
|
|
95
|
+
new FileSystemEntry(name, pkgSourceDir),
|
|
96
|
+
this.entryProperties
|
|
97
|
+
);
|
|
84
98
|
}
|
|
85
99
|
}
|
|
86
100
|
}
|
package/src/output/arch.mjs
CHANGED
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
copyEntries,
|
|
19
19
|
fieldProvider,
|
|
20
20
|
quote,
|
|
21
|
-
utf8StreamOptions
|
|
21
|
+
utf8StreamOptions,
|
|
22
|
+
packageNameMapping
|
|
22
23
|
} from "../util.mjs";
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -200,9 +201,6 @@ const fields = {
|
|
|
200
201
|
options: { type: "string[]" }
|
|
201
202
|
};
|
|
202
203
|
|
|
203
|
-
const mapping = {
|
|
204
|
-
node: "nodejs"
|
|
205
|
-
};
|
|
206
204
|
|
|
207
205
|
function normalizeExpression(e) {
|
|
208
206
|
e = e.replace(/\-([\w\d]+)$/, "");
|
|
@@ -216,6 +214,6 @@ function normalizeExpression(e) {
|
|
|
216
214
|
function makeDepends(dependencies) {
|
|
217
215
|
return Object.entries(dependencies).map(
|
|
218
216
|
([name, version]) =>
|
|
219
|
-
`${
|
|
217
|
+
`${packageNameMapping[name] ? packageNameMapping[name] : name}${normalizeExpression(version)}`
|
|
220
218
|
);
|
|
221
219
|
}
|
package/src/output/debian.mjs
CHANGED
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
copyEntries,
|
|
18
18
|
fieldProvider,
|
|
19
19
|
extractFunctions,
|
|
20
|
-
utf8StreamOptions
|
|
20
|
+
utf8StreamOptions,
|
|
21
|
+
packageNameMapping
|
|
21
22
|
} from "../util.mjs";
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -93,7 +94,7 @@ export class DEBIAN extends Packager {
|
|
|
93
94
|
);
|
|
94
95
|
|
|
95
96
|
properties.Depends = Object.entries(dependencies).map(
|
|
96
|
-
([
|
|
97
|
+
([name, e]) => `${packageNameMapping[name] ? packageNameMapping[name] : name} (${e})`
|
|
97
98
|
);
|
|
98
99
|
|
|
99
100
|
const fp = fieldProvider(properties, fields);
|
package/src/output/rpm.mjs
CHANGED
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
copyEntries,
|
|
15
15
|
fieldProvider,
|
|
16
16
|
utf8StreamOptions,
|
|
17
|
-
extractFunctions
|
|
17
|
+
extractFunctions,
|
|
18
|
+
packageNameMapping
|
|
18
19
|
} from "../util.mjs";
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -76,7 +77,9 @@ export class RPM extends Packager {
|
|
|
76
77
|
|
|
77
78
|
properties.Requires = Object.entries(dependencies).map(
|
|
78
79
|
([name, e]) =>
|
|
79
|
-
`${
|
|
80
|
+
`${
|
|
81
|
+
packageNameMapping[name] ? packageNameMapping[name] : name
|
|
82
|
+
} ${e.replace(/([<=>])\d/, (match, p1) => `${p1} `)}`
|
|
80
83
|
);
|
|
81
84
|
|
|
82
85
|
const specFileName = `${properties.name}.spec`;
|
|
@@ -169,7 +172,6 @@ export class RPM extends Packager {
|
|
|
169
172
|
}
|
|
170
173
|
}
|
|
171
174
|
|
|
172
|
-
|
|
173
175
|
const pkglist = { type: "string[]" };
|
|
174
176
|
/**
|
|
175
177
|
* @see https://rpm-packaging-guide.github.io
|
|
@@ -195,4 +197,3 @@ const fields = {
|
|
|
195
197
|
Obsoletes: pkglist,
|
|
196
198
|
Conflicts: pkglist
|
|
197
199
|
};
|
|
198
|
-
|
package/src/util.mjs
CHANGED
|
@@ -5,6 +5,13 @@ import { createWriteStream } from "fs";
|
|
|
5
5
|
|
|
6
6
|
export const utf8StreamOptions = { encoding: "utf8" };
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* what is the node name in the package eco-system
|
|
10
|
+
*/
|
|
11
|
+
export const packageNameMapping = {
|
|
12
|
+
node: "nodejs"
|
|
13
|
+
};
|
|
14
|
+
|
|
8
15
|
/**
|
|
9
16
|
* Decode a password
|
|
10
17
|
* @param {string} password
|