npm-pkgbuild 7.23.10 → 7.25.0
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
CHANGED
|
@@ -30,7 +30,7 @@ export class FileContentProvider extends ContentProvider {
|
|
|
30
30
|
} else {
|
|
31
31
|
this.definitions = { pattern: ["**/*"], ...definitions };
|
|
32
32
|
this.definitions.pattern = asArray(this.definitions.pattern);
|
|
33
|
-
/*
|
|
33
|
+
/*
|
|
34
34
|
if(entryProperties && entryProperties.destination && !entryProperties.destination.endsWith('/')) {
|
|
35
35
|
entryProperties.destination += '/';
|
|
36
36
|
}
|
|
@@ -41,7 +41,7 @@ export class FileContentProvider extends ContentProvider {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
toString() {
|
|
44
|
-
return `${this.constructor.name}: ${this.definitions.base}, ${this.definitions.pattern}`;
|
|
44
|
+
return `${this.constructor.name}: ${this.definitions.base}, ${this.definitions.pattern} -> ${this.entryProperties.destination}`;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
async *[Symbol.asyncIterator]() {
|
|
@@ -30,7 +30,7 @@ export class NodeModulesContentProvider extends ContentProvider {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
toString() {
|
|
33
|
-
return `${this.constructor.name}: ${this.dir}`;
|
|
33
|
+
return `${this.constructor.name}: ${this.dir} -> ${this.entryProperties.destination}`;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
async *[Symbol.asyncIterator]() {
|
|
@@ -61,7 +61,8 @@ export class NodeModulesContentProvider extends ContentProvider {
|
|
|
61
61
|
if (!toBeSkipped.test(name)) {
|
|
62
62
|
if (name.endsWith("package.json")) {
|
|
63
63
|
const json = shrinkNPM(
|
|
64
|
-
JSON.parse(await readFile(join(tmp, name), utf8StreamOptions))
|
|
64
|
+
JSON.parse(await readFile(join(tmp, name), utf8StreamOptions)),
|
|
65
|
+
{}
|
|
65
66
|
);
|
|
66
67
|
|
|
67
68
|
if (json) {
|
|
@@ -180,6 +181,6 @@ const toBeSkipped = new RegExp(
|
|
|
180
181
|
"chains and topics\\.md",
|
|
181
182
|
"build_detect_platform"
|
|
182
183
|
].join("|") +
|
|
183
|
-
")$|(node_modules
|
|
184
|
+
")$|(node_modules/(@types|node-addon-api)|(win32|android|darwin)-(ia32|x64|arm|arm64))",
|
|
184
185
|
"i"
|
|
185
186
|
);
|
|
@@ -28,7 +28,7 @@ export class NPMPackContentProvider extends ContentProvider {
|
|
|
28
28
|
|
|
29
29
|
toString()
|
|
30
30
|
{
|
|
31
|
-
return `${this.constructor.name}: ${this.dir}`;
|
|
31
|
+
return `${this.constructor.name}: ${this.dir} -> ${this.entryProperties.destination}`;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
async *[Symbol.asyncIterator]() {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { arch as hostArch } from "process";
|
|
2
2
|
import { packageWalker } from "npm-package-walker";
|
|
3
|
+
import { createContext } from "expression-expander";
|
|
3
4
|
import { asArray } from "./util.mjs";
|
|
4
5
|
import { NPMPackContentProvider } from "./content/npm-pack-content-provider.mjs";
|
|
5
6
|
import { NodeModulesContentProvider } from "./content/node-modules-content-provider.mjs";
|
|
@@ -46,6 +47,11 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
46
47
|
properties.name = properties.name.replace(/^\@\w+\//, "");
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
properties.access = "private";
|
|
51
|
+
if (pkg.publishConfig) {
|
|
52
|
+
properties.access = pkg.publishConfig.access;
|
|
53
|
+
}
|
|
54
|
+
|
|
49
55
|
if (pkg.contributors) {
|
|
50
56
|
properties.maintainer = pkg.contributors.map(
|
|
51
57
|
c => `${c.name} <${c.email}>`
|
|
@@ -62,6 +68,8 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
62
68
|
}
|
|
63
69
|
}
|
|
64
70
|
|
|
71
|
+
const context = createContext({ properties });
|
|
72
|
+
|
|
65
73
|
let dependencies = { ...pkg.engines };
|
|
66
74
|
let sources = [];
|
|
67
75
|
let output = {};
|
|
@@ -77,10 +85,10 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
77
85
|
arch.add(npmArchMapping[a]);
|
|
78
86
|
}
|
|
79
87
|
}
|
|
80
|
-
|
|
88
|
+
|
|
81
89
|
if (pkgbuild.arch) {
|
|
82
90
|
for (const a of asArray(pkgbuild.arch)) {
|
|
83
|
-
|
|
91
|
+
arch.add(a);
|
|
84
92
|
}
|
|
85
93
|
}
|
|
86
94
|
|
|
@@ -93,6 +101,8 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
93
101
|
if (pkgbuild.content && !modulePath) {
|
|
94
102
|
Object.entries(pkgbuild.content).forEach(
|
|
95
103
|
([destination, definitions]) => {
|
|
104
|
+
destination = context.expand(destination);
|
|
105
|
+
definitions = context.expand(definitions);
|
|
96
106
|
for (const definition of asArray(definitions)) {
|
|
97
107
|
const entryProperties = { destination };
|
|
98
108
|
|
|
@@ -130,7 +140,7 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
130
140
|
processPkg(pkg, dir);
|
|
131
141
|
|
|
132
142
|
if (arch.size > 0) {
|
|
133
|
-
properties.arch = [...arch].filter(a => a === npmArchMapping[hostArch])
|
|
143
|
+
properties.arch = [...arch].filter(a => a === npmArchMapping[hostArch]);
|
|
134
144
|
}
|
|
135
145
|
|
|
136
146
|
return { properties, sources, dependencies, output };
|
package/src/npm-shrink.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const nameAndVersion = ["name", "version"];
|
|
2
|
+
|
|
3
|
+
export function shrinkNPM(pkg, options = { removeKeys: nameAndVersion }) {
|
|
4
|
+
const toBeRemoved = [
|
|
5
5
|
"dependencies",
|
|
6
6
|
"sideEffects",
|
|
7
7
|
"jspm",
|
|
@@ -95,11 +95,24 @@ export function shrinkNPM(pkg) {
|
|
|
95
95
|
"readme",
|
|
96
96
|
"node-gyp-build-optional",
|
|
97
97
|
"node-gyp-build-test",
|
|
98
|
-
"jsdelivr"
|
|
99
|
-
|
|
98
|
+
"jsdelivr",
|
|
99
|
+
"types",
|
|
100
|
+
"unpkg",
|
|
101
|
+
"shim",
|
|
102
|
+
"browser",
|
|
103
|
+
"testling"
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
toBeRemoved.map(key => {
|
|
100
107
|
delete pkg[key];
|
|
101
108
|
});
|
|
102
109
|
|
|
110
|
+
if (options && options.removeKeys) {
|
|
111
|
+
options.removeKeys.map(key => {
|
|
112
|
+
delete pkg[key];
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
103
116
|
switch (pkg.main) {
|
|
104
117
|
case "index":
|
|
105
118
|
case "./index":
|
|
@@ -115,12 +128,5 @@ export function shrinkNPM(pkg) {
|
|
|
115
128
|
}
|
|
116
129
|
}
|
|
117
130
|
|
|
118
|
-
|
|
119
|
-
// TODO mark files as to be skipped
|
|
120
|
-
|
|
121
|
-
delete pkg[toBeRemoved];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return Object.keys(pkg).length === 0 ? undefined : pkg
|
|
131
|
+
return Object.keys(pkg).length === 0 ? undefined : pkg;
|
|
125
132
|
}
|
|
126
|
-
|