npm-pkgbuild 7.20.2 → 7.21.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 +1 -1
- package/src/content/node-modules-content-provider.mjs +114 -65
- package/src/npm-shrink.mjs +124 -0
- package/src/output/rpm.mjs +7 -4
- package/src/npm-cleanup.mjs +0 -164
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { tmpdir } from "os";
|
|
2
2
|
import { join } from "path";
|
|
3
|
-
import {
|
|
3
|
+
import { mkdtemp, readFile, writeFile } from "fs/promises";
|
|
4
4
|
import { globby } from "globby";
|
|
5
5
|
import Arborist from "@npmcli/arborist";
|
|
6
|
+
import { StringContentEntry } from "content-entry";
|
|
6
7
|
import { FileSystemEntry } from "content-entry-filesystem";
|
|
7
8
|
import { ContentProvider } from "./content-provider.mjs";
|
|
8
9
|
import { utf8StreamOptions } from "../util.mjs";
|
|
9
|
-
|
|
10
|
+
import { shrinkNPM } from "../npm-shrink.mjs";
|
|
10
11
|
/**
|
|
11
12
|
* Content from node_modules
|
|
12
13
|
*/
|
|
@@ -46,77 +47,125 @@ export class NodeModulesContentProvider extends ContentProvider {
|
|
|
46
47
|
);
|
|
47
48
|
|
|
48
49
|
const arb = new Arborist({ path: tmp });
|
|
49
|
-
await arb.buildIdealTree({
|
|
50
|
+
await arb.buildIdealTree({
|
|
51
|
+
rm: ["@types/node"],
|
|
52
|
+
update: true,
|
|
53
|
+
prune: true,
|
|
54
|
+
saveType: "prod"
|
|
55
|
+
});
|
|
50
56
|
await arb.prune({ saveType: "prod" });
|
|
51
57
|
await arb.reify({ save: true });
|
|
52
58
|
|
|
53
59
|
for (const name of await globby("node_modules/**/*", {
|
|
54
60
|
cwd: tmp
|
|
55
61
|
})) {
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
if (!toBeSkipped.test(name)) {
|
|
63
|
+
if (name.endsWith("package.json")) {
|
|
64
|
+
const json = shrinkNPM(
|
|
65
|
+
JSON.parse(await readFile(join(tmp, name), utf8StreamOptions))
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
if (json) {
|
|
69
|
+
yield Object.assign(
|
|
70
|
+
new StringContentEntry(name, JSON.stringify(json)),
|
|
71
|
+
this.entryProperties
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
yield Object.assign(
|
|
76
|
+
new FileSystemEntry(name, tmp),
|
|
77
|
+
this.entryProperties
|
|
78
|
+
);
|
|
79
|
+
}
|
|
65
80
|
}
|
|
66
81
|
}
|
|
67
82
|
}
|
|
68
83
|
}
|
|
69
84
|
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"appveyor
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
85
|
+
const toBeSkipped = new RegExp(
|
|
86
|
+
"(" +
|
|
87
|
+
[
|
|
88
|
+
"~",
|
|
89
|
+
"\\.map",
|
|
90
|
+
"\\.ts",
|
|
91
|
+
"\\.orig",
|
|
92
|
+
"\\.log",
|
|
93
|
+
"\\.tmp",
|
|
94
|
+
"\\.bak",
|
|
95
|
+
"\\.bat",
|
|
96
|
+
"\\.gypi",
|
|
97
|
+
"\\.gyp",
|
|
98
|
+
"appveyor\\.yml",
|
|
99
|
+
"yarn\\.lock",
|
|
100
|
+
"\\.DS_Store",
|
|
101
|
+
"jenkinsfile",
|
|
102
|
+
"\\.travis\\.yml",
|
|
103
|
+
"\\.jshint(rc)?",
|
|
104
|
+
"\\.npm.*",
|
|
105
|
+
"\\.git.*",
|
|
106
|
+
"rollup\\.config\\.(js|mjs|cjs)",
|
|
107
|
+
"CODE_OF_CONDUCT(\\.md)?",
|
|
108
|
+
"GOVERNANCE(\\.md)?",
|
|
109
|
+
"CODEOWNERS(\\.md)?",
|
|
110
|
+
"UPGRAD(E|ING)(\\.md)?",
|
|
111
|
+
"AUTHORS(\\.md)?",
|
|
112
|
+
"CONTRIBUT(ORS|ING)(\\.md)?",
|
|
113
|
+
"CHANGELOG(\\.md)?",
|
|
114
|
+
"HISTORY(\\.md)?",
|
|
115
|
+
"LICENSE(-w+|\\.md|\\.txt)?",
|
|
116
|
+
"README(.*\\.md)?",
|
|
117
|
+
"\\.o",
|
|
118
|
+
"\\.a",
|
|
119
|
+
"\\.c",
|
|
120
|
+
"\\.cc",
|
|
121
|
+
"\\.h",
|
|
122
|
+
"\\.in",
|
|
123
|
+
"Makefile",
|
|
124
|
+
"\\.cmake",
|
|
125
|
+
"\\.mk",
|
|
126
|
+
"\\.d",
|
|
127
|
+
|
|
128
|
+
"\\.patch",
|
|
129
|
+
"\\.esl*",
|
|
130
|
+
"\\.zuul\\.yml",
|
|
131
|
+
"\\.doclets\\.yml",
|
|
132
|
+
"\\.editorconfig",
|
|
133
|
+
"\\.tern-project",
|
|
134
|
+
"\\.dockerignore",
|
|
135
|
+
"\\.dir-locals\\.el",
|
|
136
|
+
"gulpfile\\.js",
|
|
137
|
+
"jsdoc\\.json",
|
|
138
|
+
"Gruntfile\\.js",
|
|
139
|
+
"karma\\.conf\\.js",
|
|
140
|
+
"verb\\.md",
|
|
141
|
+
"\\.nvmrc",
|
|
142
|
+
"bower\\.json",
|
|
143
|
+
"\\.bash_completion.*",
|
|
144
|
+
"\\.coveralls\\.yml",
|
|
145
|
+
"\\.istanbul\\.yml",
|
|
146
|
+
"\\.babelrc.*",
|
|
147
|
+
"\\.nycrc",
|
|
148
|
+
"\\.env",
|
|
149
|
+
"x-package\\.json5",
|
|
150
|
+
"component\\.json",
|
|
151
|
+
"tsconfig\\.json",
|
|
152
|
+
"cypress\\.json",
|
|
153
|
+
"\\.airtap\\.yml",
|
|
154
|
+
"\\.jscs\\.json",
|
|
155
|
+
"sauce-labs\\.svg",
|
|
156
|
+
"PATENTS(\\.md)?",
|
|
157
|
+
"NOTICE(\\.md)?",
|
|
158
|
+
"SUMMARY\\.md",
|
|
159
|
+
"MIGRAT.*\\.md",
|
|
160
|
+
"PULL_REQUEST_TEMPLATE\\.md",
|
|
161
|
+
"PATTERNS\\.md",
|
|
162
|
+
"REFERENCE\\.md",
|
|
163
|
+
"SECURITY\\.md",
|
|
164
|
+
"SFTPStream\\.md",
|
|
165
|
+
"LIMITS\\.md",
|
|
166
|
+
"Porting-Buffer\\.md",
|
|
167
|
+
"chains and topics\\.md"
|
|
168
|
+
].join("|") +
|
|
169
|
+
")$",
|
|
170
|
+
"i"
|
|
171
|
+
);
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export function shrinkNPM(pkg) {
|
|
2
|
+
[
|
|
3
|
+
"version",
|
|
4
|
+
"name",
|
|
5
|
+
"dependencies",
|
|
6
|
+
"sideEffects",
|
|
7
|
+
"jspm",
|
|
8
|
+
"jsnext:main",
|
|
9
|
+
"man",
|
|
10
|
+
"files",
|
|
11
|
+
"directories",
|
|
12
|
+
"devDependencies",
|
|
13
|
+
"bundleDependencies",
|
|
14
|
+
"peerDependencies",
|
|
15
|
+
"peerDependenciesMeta",
|
|
16
|
+
"optionalDependencies",
|
|
17
|
+
"optionalDevDependencies",
|
|
18
|
+
"sideEffects",
|
|
19
|
+
"pika",
|
|
20
|
+
"private",
|
|
21
|
+
"publishConfig",
|
|
22
|
+
"repository",
|
|
23
|
+
"license",
|
|
24
|
+
"licenses",
|
|
25
|
+
"changelog",
|
|
26
|
+
"keywords",
|
|
27
|
+
"homepage",
|
|
28
|
+
"bugs",
|
|
29
|
+
"scripts",
|
|
30
|
+
"types",
|
|
31
|
+
"deprecated",
|
|
32
|
+
"description",
|
|
33
|
+
"decription",
|
|
34
|
+
"engine",
|
|
35
|
+
"engines",
|
|
36
|
+
"author",
|
|
37
|
+
"authors",
|
|
38
|
+
"contributors",
|
|
39
|
+
"maintainers",
|
|
40
|
+
"verb",
|
|
41
|
+
"xo",
|
|
42
|
+
"prettier",
|
|
43
|
+
"jest",
|
|
44
|
+
"remarkConfig",
|
|
45
|
+
"nyc",
|
|
46
|
+
"ava",
|
|
47
|
+
"publishConfig",
|
|
48
|
+
"typeScriptVersion",
|
|
49
|
+
"typesPublisherContentHash",
|
|
50
|
+
"typings",
|
|
51
|
+
"systemd",
|
|
52
|
+
"pacman",
|
|
53
|
+
"pkg",
|
|
54
|
+
"lintDeps",
|
|
55
|
+
"icon",
|
|
56
|
+
"config",
|
|
57
|
+
"release",
|
|
58
|
+
"template",
|
|
59
|
+
"spm",
|
|
60
|
+
"precommit.silent",
|
|
61
|
+
"greenkeeper",
|
|
62
|
+
"bundlesize",
|
|
63
|
+
"standard",
|
|
64
|
+
"ignore",
|
|
65
|
+
"ender",
|
|
66
|
+
"dojoBuild",
|
|
67
|
+
"component",
|
|
68
|
+
"eslintConfig",
|
|
69
|
+
"env",
|
|
70
|
+
"commitlint",
|
|
71
|
+
"standard-version",
|
|
72
|
+
"lint-staged",
|
|
73
|
+
"lintStaged",
|
|
74
|
+
"ci",
|
|
75
|
+
"husky",
|
|
76
|
+
"verbiage",
|
|
77
|
+
"os",
|
|
78
|
+
"gypfile",
|
|
79
|
+
"coordinates",
|
|
80
|
+
"tap",
|
|
81
|
+
"typesVersions",
|
|
82
|
+
"node-gyp-build-optional",
|
|
83
|
+
"node-gyp-build-test",
|
|
84
|
+
"gitHead",
|
|
85
|
+
"hallmark",
|
|
86
|
+
"funding",
|
|
87
|
+
"eslintIgnore",
|
|
88
|
+
"react-native",
|
|
89
|
+
"sharec",
|
|
90
|
+
"source",
|
|
91
|
+
"support",
|
|
92
|
+
"auto-changelog",
|
|
93
|
+
"readmeFilename",
|
|
94
|
+
"readme",
|
|
95
|
+
"node-gyp-build-optional",
|
|
96
|
+
"node-gyp-build-test"
|
|
97
|
+
].map(key => {
|
|
98
|
+
delete pkg[key];
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
switch (pkg.main) {
|
|
102
|
+
case "index":
|
|
103
|
+
case "./index":
|
|
104
|
+
case "index.js":
|
|
105
|
+
case "./index.js":
|
|
106
|
+
case "":
|
|
107
|
+
delete pkg.main;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
for (const key of Object.keys(pkg)) {
|
|
111
|
+
if (key[0] === "_") {
|
|
112
|
+
delete pkg[key];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
for (const toBeRemoved of ["types", "unpkg", "shim", "browser", "testling"]) {
|
|
117
|
+
// TODO mark files as to be skipped
|
|
118
|
+
|
|
119
|
+
delete pkg[toBeRemoved];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return Object.keys(pkg).length === 0 ? undefined : pkg
|
|
123
|
+
}
|
|
124
|
+
|
package/src/output/rpm.mjs
CHANGED
|
@@ -37,7 +37,7 @@ export class RPM extends Packager {
|
|
|
37
37
|
named: {
|
|
38
38
|
staging: "BUILDROOT"
|
|
39
39
|
},
|
|
40
|
-
others: ["RPMS", "SRPMS", "SOURCES", "SPECS"]
|
|
40
|
+
others: ["RPMS", "SRPMS", "SOURCES", "SPECS"]
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -51,7 +51,8 @@ export class RPM extends Packager {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
async execute(sources, transformer, dependencies, options, expander) {
|
|
54
|
-
const { properties, tmpdir, staging, destination } =
|
|
54
|
+
const { properties, tmpdir, staging, destination } =
|
|
55
|
+
await this.prepareExecute(options);
|
|
55
56
|
|
|
56
57
|
properties.Requires = Object.entries(dependencies)
|
|
57
58
|
.map(([n, e]) => `${n}${e}`)
|
|
@@ -125,12 +126,14 @@ export class RPM extends Packager {
|
|
|
125
126
|
console.log(rpmbuild.stdout);
|
|
126
127
|
}
|
|
127
128
|
|
|
129
|
+
const packageFile = join(destination, this.packageFileName);
|
|
130
|
+
|
|
128
131
|
await cp(
|
|
129
132
|
join(tmpdir, "RPMS", properties.arch, this.packageFileName),
|
|
130
|
-
|
|
133
|
+
packageFile,
|
|
131
134
|
{ preserveTimestamps: true }
|
|
132
135
|
);
|
|
133
|
-
return
|
|
136
|
+
return packageFile;
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
139
|
|
package/src/npm-cleanup.mjs
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { unlink, readFile, writeFile } from "fs/promises";
|
|
2
|
-
import { globby} from "globby";
|
|
3
|
-
import { join, dirname } from "path";
|
|
4
|
-
import { utf8StreamOptions } from "./util.mjs";
|
|
5
|
-
|
|
6
|
-
async function rm(file) {
|
|
7
|
-
try {
|
|
8
|
-
console.log("rm", file);
|
|
9
|
-
return await unlink(file);
|
|
10
|
-
} catch (error) {
|
|
11
|
-
console.log(error);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async function iterate(o, cb) {
|
|
16
|
-
switch (typeof o) {
|
|
17
|
-
case "string":
|
|
18
|
-
return cb(o);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (Array.isArray(o)) {
|
|
22
|
-
for (const x of o) {
|
|
23
|
-
await iterate(x, cb);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
for (const k in o) {
|
|
27
|
-
await iterate(o[k], cb);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const blacklist = new Set(["parse-client-options", "@octokit/rest"]);
|
|
32
|
-
|
|
33
|
-
export async function cleanup(context, stagingDir) {
|
|
34
|
-
for (const name of await globby(["**/package.json"], {
|
|
35
|
-
cwd: stagingDir
|
|
36
|
-
})) {
|
|
37
|
-
const pkgFile = join(stagingDir, name);
|
|
38
|
-
const pkg = JSON.parse(await readFile(pkgFile, utf8StreamOptions));
|
|
39
|
-
|
|
40
|
-
if (!blacklist.has(pkg.name)) {
|
|
41
|
-
console.log(`cleanup ${pkgFile}`);
|
|
42
|
-
|
|
43
|
-
// unused files may also be deleted
|
|
44
|
-
await Promise.all(
|
|
45
|
-
["types", "unpkg", "shim", "browser", "testling", "source"].map(
|
|
46
|
-
async key => {
|
|
47
|
-
await iterate(pkg[key], async o => rm(join(dirname(pkgFile), o)));
|
|
48
|
-
delete pkg[key];
|
|
49
|
-
}
|
|
50
|
-
)
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
[
|
|
54
|
-
"version",
|
|
55
|
-
"name",
|
|
56
|
-
"dependencies",
|
|
57
|
-
"sideEffects",
|
|
58
|
-
"jspm",
|
|
59
|
-
"jsnext:main",
|
|
60
|
-
"man",
|
|
61
|
-
"files",
|
|
62
|
-
"directories",
|
|
63
|
-
"devDependencies",
|
|
64
|
-
"bundleDependencies",
|
|
65
|
-
"peerDependencies",
|
|
66
|
-
"optionalDependencies",
|
|
67
|
-
"sideEffects",
|
|
68
|
-
"pika",
|
|
69
|
-
"private",
|
|
70
|
-
"publishConfig",
|
|
71
|
-
"repository",
|
|
72
|
-
"license",
|
|
73
|
-
"licenses",
|
|
74
|
-
"changelog",
|
|
75
|
-
"keywords",
|
|
76
|
-
"homepage",
|
|
77
|
-
"bugs",
|
|
78
|
-
"scripts",
|
|
79
|
-
"types",
|
|
80
|
-
"deprecated",
|
|
81
|
-
"description",
|
|
82
|
-
"decription",
|
|
83
|
-
"engine",
|
|
84
|
-
"engines",
|
|
85
|
-
"author",
|
|
86
|
-
"authors",
|
|
87
|
-
"contributors",
|
|
88
|
-
"maintainers",
|
|
89
|
-
"verb",
|
|
90
|
-
"xo",
|
|
91
|
-
"prettier",
|
|
92
|
-
"jest",
|
|
93
|
-
"remarkConfig",
|
|
94
|
-
"nyc",
|
|
95
|
-
"ava",
|
|
96
|
-
"publishConfig",
|
|
97
|
-
"typeScriptVersion",
|
|
98
|
-
"typesPublisherContentHash",
|
|
99
|
-
"typings",
|
|
100
|
-
"systemd",
|
|
101
|
-
"pacman",
|
|
102
|
-
"lintDeps",
|
|
103
|
-
"icon",
|
|
104
|
-
"config",
|
|
105
|
-
"release",
|
|
106
|
-
"template",
|
|
107
|
-
"spm",
|
|
108
|
-
"precommit.silent",
|
|
109
|
-
"greenkeeper",
|
|
110
|
-
"bundlesize",
|
|
111
|
-
"standard",
|
|
112
|
-
"ignore",
|
|
113
|
-
"ender",
|
|
114
|
-
"dojoBuild",
|
|
115
|
-
"component",
|
|
116
|
-
"eslintConfig",
|
|
117
|
-
"env",
|
|
118
|
-
"commitlint",
|
|
119
|
-
"standard-version",
|
|
120
|
-
"lint-staged",
|
|
121
|
-
"lintStaged",
|
|
122
|
-
"ci",
|
|
123
|
-
"husky",
|
|
124
|
-
"verbiage",
|
|
125
|
-
"os",
|
|
126
|
-
"gypfile",
|
|
127
|
-
"coordinates",
|
|
128
|
-
"tap",
|
|
129
|
-
"typesVersions",
|
|
130
|
-
"node-gyp-build-optional",
|
|
131
|
-
"node-gyp-build-test",
|
|
132
|
-
"gitHead",
|
|
133
|
-
"hallmark",
|
|
134
|
-
"funding",
|
|
135
|
-
"eslintIgnore",
|
|
136
|
-
"react-native",
|
|
137
|
-
"sharec"
|
|
138
|
-
].map(key => {
|
|
139
|
-
delete pkg[key];
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
for (const key of Object.keys(pkg)) {
|
|
143
|
-
if (key[0] === "_") {
|
|
144
|
-
delete pkg[key];
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
switch (pkg.main) {
|
|
149
|
-
case "index":
|
|
150
|
-
case "./index":
|
|
151
|
-
case "index.js":
|
|
152
|
-
case "./index.js":
|
|
153
|
-
case "":
|
|
154
|
-
delete pkg.main;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (Object.keys(pkg).length === 0 || pkg.type === "module") {
|
|
158
|
-
await unlink(pkgFile);
|
|
159
|
-
} else {
|
|
160
|
-
await writeFile(pkgFile, JSON.stringify(pkg), utf8StreamOptions);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|