node-modules-tools 1.4.2 → 2.0.0-beta.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/dist/chunks/index.mjs +1 -2
- package/dist/chunks/json-parse-stream.mjs +1203 -409
- package/dist/index.mjs +26 -26
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -106,7 +106,7 @@ function populateRawResult(input) {
|
|
|
106
106
|
return result;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
function analyzeExports(exports
|
|
109
|
+
function analyzeExports(exports, depth = 0) {
|
|
110
110
|
const result = {
|
|
111
111
|
hasImport: false,
|
|
112
112
|
hasRequire: false,
|
|
@@ -114,22 +114,22 @@ function analyzeExports(exports$1, depth = 0) {
|
|
|
114
114
|
};
|
|
115
115
|
if (depth > 10)
|
|
116
116
|
return result;
|
|
117
|
-
if (exports
|
|
117
|
+
if (exports == null)
|
|
118
118
|
return result;
|
|
119
|
-
if (typeof exports
|
|
120
|
-
if (exports
|
|
119
|
+
if (typeof exports === "string") {
|
|
120
|
+
if (exports.endsWith(".mjs") || exports.endsWith(".mts"))
|
|
121
121
|
result.hasImport = true;
|
|
122
|
-
else if (exports
|
|
122
|
+
else if (exports.endsWith(".cjs") || exports.endsWith(".cts"))
|
|
123
123
|
result.hasRequire = true;
|
|
124
124
|
return result;
|
|
125
125
|
}
|
|
126
|
-
if (Array.isArray(exports
|
|
127
|
-
for (const item of exports
|
|
126
|
+
if (Array.isArray(exports)) {
|
|
127
|
+
for (const item of exports)
|
|
128
128
|
mergeAnalysis(result, analyzeExports(item, depth + 1));
|
|
129
129
|
return result;
|
|
130
130
|
}
|
|
131
|
-
if (typeof exports
|
|
132
|
-
for (const [key, value] of Object.entries(exports
|
|
131
|
+
if (typeof exports === "object") {
|
|
132
|
+
for (const [key, value] of Object.entries(exports)) {
|
|
133
133
|
if (key === "import")
|
|
134
134
|
result.hasImport = true;
|
|
135
135
|
else if (key === "require")
|
|
@@ -188,7 +188,7 @@ async function getPackageInstallSize(pkg) {
|
|
|
188
188
|
return;
|
|
189
189
|
if (pkg.name.startsWith("#"))
|
|
190
190
|
return;
|
|
191
|
-
if (
|
|
191
|
+
if (/^(?:file|link|workspace):/.test(pkg.version))
|
|
192
192
|
return;
|
|
193
193
|
if (!pkg.filepath)
|
|
194
194
|
return;
|
|
@@ -199,7 +199,7 @@ async function getPackageInstallSize(pkg) {
|
|
|
199
199
|
if (n.isFile()) {
|
|
200
200
|
files.push(join(dir, n.name));
|
|
201
201
|
} else if (n.isDirectory()) {
|
|
202
|
-
if (n.name
|
|
202
|
+
if (/^\.|^node_modules$/.test(n.name))
|
|
203
203
|
continue;
|
|
204
204
|
await traverse(join(dir, n.name));
|
|
205
205
|
}
|
|
@@ -241,35 +241,35 @@ function guessFileCategory(file) {
|
|
|
241
241
|
return "other";
|
|
242
242
|
if (dirs.some((d) => d.match(/^(?:bin|binary)$/)))
|
|
243
243
|
return "bin";
|
|
244
|
-
if (
|
|
244
|
+
if (/\.(?:test|tests|spec|specs)\.\w+$/i.test(base))
|
|
245
245
|
return "test";
|
|
246
|
-
if (
|
|
246
|
+
if (/\.map$/i.test(base))
|
|
247
247
|
return "map";
|
|
248
|
-
if (
|
|
248
|
+
if (/\.d(?:\.\w+)?\.[cm]?tsx?$/i.test(base))
|
|
249
249
|
return "dts";
|
|
250
|
-
if (
|
|
250
|
+
if (/\.exe$/i.test(base))
|
|
251
251
|
return "bin";
|
|
252
|
-
if (
|
|
252
|
+
if (/\.(?:css|scss|sass|less)$/i.test(base))
|
|
253
253
|
return "css";
|
|
254
|
-
if (
|
|
254
|
+
if (/\.(?:json[c5]?|ya?ml)$/i.test(base))
|
|
255
255
|
return "json";
|
|
256
|
-
if (
|
|
256
|
+
if (/\.html?$/i.test(base))
|
|
257
257
|
return "html";
|
|
258
|
-
if (
|
|
258
|
+
if (/\.[cm]?jsx?$/i.test(base))
|
|
259
259
|
return "js";
|
|
260
|
-
if (
|
|
260
|
+
if (/\.[cm]?tsx?$/i.test(base))
|
|
261
261
|
return "ts";
|
|
262
|
-
if (
|
|
262
|
+
if (/\.(?:vue|svelte|astro)$/i.test(base))
|
|
263
263
|
return "comp";
|
|
264
|
-
if (
|
|
264
|
+
if (/\.(?:png|jpe?g|gif|svg)$/i.test(base))
|
|
265
265
|
return "image";
|
|
266
|
-
if (
|
|
266
|
+
if (/\.(?:md|txt|mdx|markdown|rst)$/i.test(base))
|
|
267
267
|
return "doc";
|
|
268
|
-
if (
|
|
268
|
+
if (/\.(?:wasm|wat)$/i.test(base))
|
|
269
269
|
return "wasm";
|
|
270
|
-
if (
|
|
270
|
+
if (/\.flow$/i.test(base))
|
|
271
271
|
return "flow";
|
|
272
|
-
if (
|
|
272
|
+
if (/\.(?:ttf|otf|woff2?)$/i.test(base))
|
|
273
273
|
return "font";
|
|
274
274
|
return "other";
|
|
275
275
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-modules-tools",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0-beta.2",
|
|
5
5
|
"description": "Tools for inspecting node_modules",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
"p-limit": "^7.3.0",
|
|
32
32
|
"package-manager-detector": "^1.6.0",
|
|
33
33
|
"pathe": "^2.0.3",
|
|
34
|
-
"pkg-types": "^2.3.
|
|
35
|
-
"publint": "^0.3.
|
|
34
|
+
"pkg-types": "^2.3.1",
|
|
35
|
+
"publint": "^0.3.19",
|
|
36
36
|
"semver": "^7.7.4",
|
|
37
|
-
"tinyexec": "^1.
|
|
37
|
+
"tinyexec": "^1.1.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@pnpm/list": "^1000.3.
|
|
40
|
+
"@pnpm/list": "^1000.3.4",
|
|
41
41
|
"@pnpm/types": "^1001.3.0",
|
|
42
42
|
"@types/js-yaml": "^4.0.9",
|
|
43
43
|
"@types/stream-json": "^1.7.8",
|
|
44
|
-
"stream-json": "^1.
|
|
44
|
+
"stream-json": "^2.1.0",
|
|
45
45
|
"unbuild": "^3.6.1"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|