app-builder-lib 26.3.3 → 26.3.5
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/out/macPackager.js +5 -5
- package/out/macPackager.js.map +1 -1
- package/out/node-module-collector/index.js +25 -8
- package/out/node-module-collector/index.js.map +1 -1
- package/out/node-module-collector/moduleCache.d.ts +21 -18
- package/out/node-module-collector/moduleCache.js +53 -12
- package/out/node-module-collector/moduleCache.js.map +1 -1
- package/out/node-module-collector/nodeModulesCollector.d.ts +21 -22
- package/out/node-module-collector/nodeModulesCollector.js +178 -118
- package/out/node-module-collector/nodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/npmNodeModulesCollector.d.ts +1 -0
- package/out/node-module-collector/npmNodeModulesCollector.js +29 -22
- package/out/node-module-collector/npmNodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/packageManager.d.ts +5 -2
- package/out/node-module-collector/packageManager.js +3 -5
- package/out/node-module-collector/packageManager.js.map +1 -1
- package/out/node-module-collector/pnpmNodeModulesCollector.js +18 -17
- package/out/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/yarnNodeModulesCollector.js +47 -55
- package/out/node-module-collector/yarnNodeModulesCollector.js.map +1 -1
- package/out/targets/nsis/nsisUtil.js +10 -8
- package/out/targets/nsis/nsisUtil.js.map +1 -1
- package/out/targets/pkg.js +32 -3
- package/out/targets/pkg.js.map +1 -1
- package/out/util/appFileCopier.js +4 -0
- package/out/util/appFileCopier.js.map +1 -1
- package/out/version.d.ts +1 -1
- package/out/version.js +1 -1
- package/out/version.js.map +1 -1
- package/package.json +9 -9
|
@@ -7,6 +7,7 @@ const fs = require("fs-extra");
|
|
|
7
7
|
const fs_extra_1 = require("fs-extra");
|
|
8
8
|
const lazy_val_1 = require("lazy-val");
|
|
9
9
|
const path = require("path");
|
|
10
|
+
const semver = require("semver");
|
|
10
11
|
const hoist_1 = require("./hoist");
|
|
11
12
|
const moduleCache_1 = require("./moduleCache");
|
|
12
13
|
const packageManager_1 = require("./packageManager");
|
|
@@ -17,14 +18,12 @@ class NodeModulesCollector {
|
|
|
17
18
|
this.nodeModules = [];
|
|
18
19
|
this.allDependencies = new Map();
|
|
19
20
|
this.productionGraph = {};
|
|
20
|
-
|
|
21
|
-
this.cache = (0, moduleCache_1.createModuleCache)();
|
|
21
|
+
this.cache = new moduleCache_1.ModuleCache();
|
|
22
22
|
this.isHoisted = new lazy_val_1.Lazy(async () => {
|
|
23
|
-
var _a;
|
|
24
23
|
const { manager } = this.installOptions;
|
|
25
24
|
const command = (0, packageManager_1.getPackageManagerCommand)(manager);
|
|
26
|
-
const config = (
|
|
27
|
-
if (
|
|
25
|
+
const config = (await this.asyncExec(command, ["config", "list"])).stdout;
|
|
26
|
+
if (config == null) {
|
|
28
27
|
builder_util_1.log.debug({ manager }, "unable to determine if node_modules are hoisted: no config output. falling back to hoisted mode");
|
|
29
28
|
return false;
|
|
30
29
|
}
|
|
@@ -35,10 +34,6 @@ class NodeModulesCollector {
|
|
|
35
34
|
}
|
|
36
35
|
return false;
|
|
37
36
|
});
|
|
38
|
-
this.appPkgJson = new lazy_val_1.Lazy(async () => {
|
|
39
|
-
const appPkgPath = path.join(this.rootDir, "package.json");
|
|
40
|
-
return this.readJsonMemoized(appPkgPath);
|
|
41
|
-
});
|
|
42
37
|
}
|
|
43
38
|
async getNodeModules({ cancellationToken, packageName }) {
|
|
44
39
|
const tree = await this.getDependenciesTree(this.installOptions.manager);
|
|
@@ -76,7 +71,7 @@ class NodeModulesCollector {
|
|
|
76
71
|
shouldRetry: async (error) => {
|
|
77
72
|
var _a;
|
|
78
73
|
const logFields = { error: error.message, tempOutputFile, cwd: this.rootDir };
|
|
79
|
-
if (!(await this.
|
|
74
|
+
if (!(await this.cache.exists[tempOutputFile])) {
|
|
80
75
|
builder_util_1.log.debug(logFields, "dependency tree output file missing, retrying");
|
|
81
76
|
return true;
|
|
82
77
|
}
|
|
@@ -95,109 +90,6 @@ class NodeModulesCollector {
|
|
|
95
90
|
},
|
|
96
91
|
});
|
|
97
92
|
}
|
|
98
|
-
async existsMemoized(filePath) {
|
|
99
|
-
if (!this.cache.exists.has(filePath)) {
|
|
100
|
-
this.cache.exists.set(filePath, await (0, builder_util_1.exists)(filePath));
|
|
101
|
-
}
|
|
102
|
-
return this.cache.exists.get(filePath);
|
|
103
|
-
}
|
|
104
|
-
async readJsonMemoized(filePath) {
|
|
105
|
-
if (!this.cache.packageJson.has(filePath)) {
|
|
106
|
-
this.cache.packageJson.set(filePath, await (0, fs_extra_1.readJson)(filePath));
|
|
107
|
-
}
|
|
108
|
-
return this.cache.packageJson.get(filePath);
|
|
109
|
-
}
|
|
110
|
-
async lstatMemoized(filePath) {
|
|
111
|
-
if (!this.cache.lstat.has(filePath)) {
|
|
112
|
-
this.cache.lstat.set(filePath, await fs.lstat(filePath));
|
|
113
|
-
}
|
|
114
|
-
return this.cache.lstat.get(filePath);
|
|
115
|
-
}
|
|
116
|
-
async realpathMemoized(filePath) {
|
|
117
|
-
if (!this.cache.realPath.has(filePath)) {
|
|
118
|
-
this.cache.realPath.set(filePath, await fs.realpath(filePath));
|
|
119
|
-
}
|
|
120
|
-
return this.cache.realPath.get(filePath);
|
|
121
|
-
}
|
|
122
|
-
requireMemoized(pkgPath) {
|
|
123
|
-
if (!this.cache.packageJson.has(pkgPath)) {
|
|
124
|
-
this.cache.packageJson.set(pkgPath, require(pkgPath));
|
|
125
|
-
}
|
|
126
|
-
return this.cache.packageJson.get(pkgPath);
|
|
127
|
-
}
|
|
128
|
-
existsSyncMemoized(filePath) {
|
|
129
|
-
if (!this.cache.exists.has(filePath)) {
|
|
130
|
-
this.cache.exists.set(filePath, fs.existsSync(filePath));
|
|
131
|
-
}
|
|
132
|
-
return this.cache.exists.get(filePath);
|
|
133
|
-
}
|
|
134
|
-
async resolvePath(filePath) {
|
|
135
|
-
// Check if we've already resolved this path
|
|
136
|
-
if (this.cache.realPath.has(filePath)) {
|
|
137
|
-
return this.cache.realPath.get(filePath);
|
|
138
|
-
}
|
|
139
|
-
try {
|
|
140
|
-
const stats = await this.lstatMemoized(filePath);
|
|
141
|
-
if (stats.isSymbolicLink()) {
|
|
142
|
-
const resolved = await this.realpathMemoized(filePath);
|
|
143
|
-
this.cache.realPath.set(filePath, resolved);
|
|
144
|
-
return resolved;
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
this.cache.realPath.set(filePath, filePath);
|
|
148
|
-
return filePath;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
builder_util_1.log.debug({ filePath, message: error.message || error.stack }, "error resolving path");
|
|
153
|
-
this.cache.realPath.set(filePath, filePath);
|
|
154
|
-
return filePath;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Resolve a package directory purely from the filesystem.
|
|
159
|
-
* Does NOT attempt to load the module or resolve an "exports" entrypoint.
|
|
160
|
-
* Good for Yarn 4 because a package may not be resolvable as a module,
|
|
161
|
-
* but still exists on disk.
|
|
162
|
-
*/
|
|
163
|
-
async resolvePackage(packageName, fromDir) {
|
|
164
|
-
const cacheKey = `${packageName}::${fromDir}`;
|
|
165
|
-
if (this.cache.requireResolve.has(cacheKey)) {
|
|
166
|
-
return this.cache.requireResolve.get(cacheKey);
|
|
167
|
-
}
|
|
168
|
-
// 1. NESTED under fromDir/node_modules/<name>
|
|
169
|
-
let candidate = path.join(fromDir, "node_modules", packageName);
|
|
170
|
-
let pkgJson = path.join(candidate, "package.json");
|
|
171
|
-
if (await this.existsMemoized(pkgJson)) {
|
|
172
|
-
this.cache.requireResolve.set(cacheKey, { entry: pkgJson, packageDir: candidate });
|
|
173
|
-
return { entry: pkgJson, packageDir: candidate };
|
|
174
|
-
}
|
|
175
|
-
// 2. HOISTED under rootDir/node_modules/<name>
|
|
176
|
-
candidate = path.join(this.rootDir, "node_modules", packageName);
|
|
177
|
-
pkgJson = path.join(candidate, "package.json");
|
|
178
|
-
if (await this.existsMemoized(pkgJson)) {
|
|
179
|
-
this.cache.requireResolve.set(cacheKey, { entry: pkgJson, packageDir: candidate });
|
|
180
|
-
return { entry: pkgJson, packageDir: candidate };
|
|
181
|
-
}
|
|
182
|
-
// 3. FALLBACK: try parent directories BFS (classic Node-style search)
|
|
183
|
-
let current = fromDir;
|
|
184
|
-
while (true) {
|
|
185
|
-
const nm = path.join(current, "node_modules", packageName);
|
|
186
|
-
const pkg = path.join(nm, "package.json");
|
|
187
|
-
if (await this.existsMemoized(pkg)) {
|
|
188
|
-
this.cache.requireResolve.set(cacheKey, { entry: pkg, packageDir: nm });
|
|
189
|
-
return { entry: pkg, packageDir: nm };
|
|
190
|
-
}
|
|
191
|
-
const parent = path.dirname(current);
|
|
192
|
-
if (parent === current) {
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
current = parent;
|
|
196
|
-
}
|
|
197
|
-
// 4. LAST RESORT: DO NOT throw — just return null
|
|
198
|
-
this.cache.requireResolve.set(cacheKey, null);
|
|
199
|
-
return null;
|
|
200
|
-
}
|
|
201
93
|
cacheKey(pkg) {
|
|
202
94
|
const rel = path.relative(this.rootDir, pkg.path);
|
|
203
95
|
return `${pkg.name}::${pkg.version}::${rel !== null && rel !== void 0 ? rel : "."}`;
|
|
@@ -225,7 +117,7 @@ class NodeModulesCollector {
|
|
|
225
117
|
}
|
|
226
118
|
if ((_a = tree.dependencies) === null || _a === void 0 ? void 0 : _a[packageName]) {
|
|
227
119
|
const { name, path, dependencies } = tree.dependencies[packageName];
|
|
228
|
-
builder_util_1.log.debug({ name, path, dependencies: JSON.stringify(dependencies) }, "pruning root app/self reference from workspace tree
|
|
120
|
+
builder_util_1.log.debug({ name, path, dependencies: JSON.stringify(dependencies) }, "pruning root app/self reference from workspace tree");
|
|
229
121
|
for (const [name, pkg] of Object.entries(dependencies !== null && dependencies !== void 0 ? dependencies : {})) {
|
|
230
122
|
tree.dependencies[name] = pkg;
|
|
231
123
|
this.allDependencies.set(this.packageVersionString(pkg), pkg);
|
|
@@ -263,19 +155,19 @@ class NodeModulesCollector {
|
|
|
263
155
|
const reference = [...d.references][0];
|
|
264
156
|
const p = (_a = this.allDependencies.get(`${d.name}@${reference}`)) === null || _a === void 0 ? void 0 : _a.path;
|
|
265
157
|
if (p === undefined) {
|
|
266
|
-
builder_util_1.log.
|
|
158
|
+
builder_util_1.log.warn({ name: d.name, reference }, "cannot find path for dependency");
|
|
267
159
|
continue;
|
|
268
160
|
}
|
|
269
161
|
// fix npm list issue
|
|
270
162
|
// https://github.com/npm/cli/issues/8535
|
|
271
|
-
if (!(await
|
|
163
|
+
if (!(await this.cache.exists[p])) {
|
|
272
164
|
builder_util_1.log.debug({ name: d.name, reference, p }, "dependency path does not exist");
|
|
273
165
|
continue;
|
|
274
166
|
}
|
|
275
167
|
const node = {
|
|
276
168
|
name: d.name,
|
|
277
169
|
version: reference,
|
|
278
|
-
dir: await this.
|
|
170
|
+
dir: await this.cache.realPath[p],
|
|
279
171
|
};
|
|
280
172
|
result.push(node);
|
|
281
173
|
if (d.dependencies.size > 0) {
|
|
@@ -314,7 +206,6 @@ class NodeModulesCollector {
|
|
|
314
206
|
command = "cmd.exe";
|
|
315
207
|
args = ["/c", tempBatFile, ...args];
|
|
316
208
|
}
|
|
317
|
-
builder_util_1.log.debug({ command, args, cwd, tempOutputFile }, "spawning node module collector process");
|
|
318
209
|
await new Promise((resolve, reject) => {
|
|
319
210
|
const outStream = (0, fs_extra_1.createWriteStream)(tempOutputFile);
|
|
320
211
|
const child = childProcess.spawn(command, args, {
|
|
@@ -344,6 +235,175 @@ class NodeModulesCollector {
|
|
|
344
235
|
});
|
|
345
236
|
});
|
|
346
237
|
}
|
|
238
|
+
async locatePackageVersion(parentDir, pkgName, requiredRange) {
|
|
239
|
+
// 1) check direct parent node_modules/pkgName first
|
|
240
|
+
const direct = path.join(path.resolve(parentDir), "node_modules", pkgName, "package.json");
|
|
241
|
+
if (await this.cache.exists[direct]) {
|
|
242
|
+
const ver = await this.readPackageVersion(direct);
|
|
243
|
+
if (ver && this.semverSatisfies(ver, requiredRange)) {
|
|
244
|
+
return { packageDir: path.dirname(direct), version: ver };
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// 2) upward hoisted search, then 3) downward non-hoisted search
|
|
248
|
+
return (await this.upwardSearch(parentDir, pkgName, requiredRange)) || (await this.downwardSearch(parentDir, pkgName, requiredRange)) || null;
|
|
249
|
+
}
|
|
250
|
+
async readPackageVersion(pkgJsonPath) {
|
|
251
|
+
return await this.cache.packageJson[pkgJsonPath].then(pkg => pkg.version).catch(() => null);
|
|
252
|
+
}
|
|
253
|
+
semverSatisfies(found, range) {
|
|
254
|
+
if (!range || range === "*" || range === "") {
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
if (range === found) {
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
if (semver.validRange(range) == null) {
|
|
261
|
+
// ignore, we can't verify non-semver ranges
|
|
262
|
+
// e.g. git urls, file:, patch:, etc. Example:
|
|
263
|
+
// "@ai-sdk/google": "patch:@ai-sdk/google@npm%3A2.0.43#~/.yarn/patches/@ai-sdk-google-npm-2.0.43-689ed559b3.patch"
|
|
264
|
+
builder_util_1.log.debug({ found, range }, "unable to validate semver version range, assuming match");
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
return semver.satisfies(found, range);
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
// fallback: simple equality or basic prefix handling (^, ~)
|
|
272
|
+
if (range.startsWith("^") || range.startsWith("~")) {
|
|
273
|
+
const r = range.slice(1);
|
|
274
|
+
return r === found;
|
|
275
|
+
}
|
|
276
|
+
// if range is like "8.x" or "8.*" match major
|
|
277
|
+
const m = range.match(/^(\d+)[.(*|x)]*/);
|
|
278
|
+
const fm = found.match(/^(\d+)\./);
|
|
279
|
+
if (m && fm) {
|
|
280
|
+
return m[1] === fm[1];
|
|
281
|
+
}
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Upward search (hoisted)
|
|
287
|
+
*/
|
|
288
|
+
async upwardSearch(parentDir, pkgName, requiredRange) {
|
|
289
|
+
let current = path.resolve(parentDir);
|
|
290
|
+
const root = path.parse(current).root;
|
|
291
|
+
while (true) {
|
|
292
|
+
const candidate = path.join(current, "node_modules", pkgName, "package.json");
|
|
293
|
+
if (await this.cache.exists[candidate]) {
|
|
294
|
+
const ver = await this.readPackageVersion(candidate);
|
|
295
|
+
if (ver && this.semverSatisfies(ver, requiredRange)) {
|
|
296
|
+
return { packageDir: path.dirname(candidate), version: ver };
|
|
297
|
+
}
|
|
298
|
+
// otherwise keep searching upward (we may find a different hoisted version)
|
|
299
|
+
}
|
|
300
|
+
if (current === root) {
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
const parent = path.dirname(current);
|
|
304
|
+
if (parent === current) {
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
current = parent;
|
|
308
|
+
}
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Breadth-first downward search from parentDir/node_modules
|
|
313
|
+
* Looks for node_modules/\*\/node_modules/pkgName (and deeper)
|
|
314
|
+
*/
|
|
315
|
+
async downwardSearch(parentDir, pkgName, requiredRange, maxExplored = 2000, maxDepth = 6) {
|
|
316
|
+
const start = path.join(path.resolve(parentDir), "node_modules");
|
|
317
|
+
if (!(await this.cache.exists[start]) || !(await this.cache.lstat[start]).isDirectory()) {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
const visited = new Set();
|
|
321
|
+
const queue = [{ dir: start, depth: 0 }];
|
|
322
|
+
let explored = 0;
|
|
323
|
+
while (queue.length > 0) {
|
|
324
|
+
const { dir, depth } = queue.shift();
|
|
325
|
+
if (explored++ > maxExplored) {
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
if (depth > maxDepth) {
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
let entries;
|
|
332
|
+
try {
|
|
333
|
+
entries = await fs.readdir(dir);
|
|
334
|
+
}
|
|
335
|
+
catch (e) {
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
for (const entry of entries) {
|
|
339
|
+
if (entry.startsWith(".")) {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
const entryPath = path.join(dir, entry);
|
|
343
|
+
// handle scoped packages @scope/name
|
|
344
|
+
if (entry.startsWith("@")) {
|
|
345
|
+
// queue the scope directory itself to explore its children
|
|
346
|
+
if ((await this.cache.exists[entryPath]) && (await this.cache.lstat[entryPath]).isDirectory()) {
|
|
347
|
+
const scopeEntries = await fs.readdir(entryPath);
|
|
348
|
+
for (const sc of scopeEntries) {
|
|
349
|
+
const scPath = path.join(entryPath, sc);
|
|
350
|
+
// check scPath/node_modules/pkgName
|
|
351
|
+
const candidatePkgJson = path.join(scPath, "node_modules", pkgName, "package.json");
|
|
352
|
+
if (await this.cache.exists[candidatePkgJson]) {
|
|
353
|
+
const ver = await this.readPackageVersion(candidatePkgJson);
|
|
354
|
+
if (ver && this.semverSatisfies(ver, requiredRange)) {
|
|
355
|
+
return { packageDir: path.dirname(candidatePkgJson), version: ver };
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
// enqueue scPath/node_modules to explore further
|
|
359
|
+
const scNodeModules = path.join(scPath, "node_modules");
|
|
360
|
+
if ((await this.cache.exists[scNodeModules]) && (await this.cache.lstat[scNodeModules]).isDirectory()) {
|
|
361
|
+
if (!visited.has(scNodeModules)) {
|
|
362
|
+
visited.add(scNodeModules);
|
|
363
|
+
queue.push({ dir: scNodeModules, depth: depth + 1 });
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
// check for direct candidate: entry/node_modules/pkgName
|
|
371
|
+
try {
|
|
372
|
+
const stat = await this.cache.lstat[entryPath];
|
|
373
|
+
if (!stat.isDirectory()) {
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
catch {
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
const candidatePkgJson = path.join(entryPath, "node_modules", pkgName, "package.json");
|
|
381
|
+
if (await this.cache.exists[candidatePkgJson]) {
|
|
382
|
+
const ver = await this.readPackageVersion(candidatePkgJson);
|
|
383
|
+
if (ver && this.semverSatisfies(ver, requiredRange)) {
|
|
384
|
+
return { packageDir: path.dirname(candidatePkgJson), version: ver };
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
// also check entry/node_modules directly for pkgName (some layouts)
|
|
388
|
+
const candidateDirect = path.join(entryPath, pkgName, "package.json");
|
|
389
|
+
if (await this.cache.exists[candidateDirect]) {
|
|
390
|
+
const ver = await this.readPackageVersion(candidateDirect);
|
|
391
|
+
if (ver && this.semverSatisfies(ver, requiredRange)) {
|
|
392
|
+
return { packageDir: path.dirname(candidateDirect), version: ver };
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
// enqueue entry/node_modules for deeper traversal
|
|
396
|
+
const nextNodeModules = path.join(entryPath, "node_modules");
|
|
397
|
+
if ((await this.cache.exists[nextNodeModules]) && (await this.cache.lstat[nextNodeModules]).isDirectory()) {
|
|
398
|
+
if (!visited.has(nextNodeModules)) {
|
|
399
|
+
visited.add(nextNodeModules);
|
|
400
|
+
queue.push({ dir: nextNodeModules, depth: depth + 1 });
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
347
407
|
}
|
|
348
408
|
exports.NodeModulesCollector = NodeModulesCollector;
|
|
349
409
|
//# sourceMappingURL=nodeModulesCollector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts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CAAA;YAC5B,CAAC,CAAC,CAAA;YACF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE;gBACtB,MAAM,CAAC,IAAI,KAAK,CAAC,uCAAuC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;YACzE,CAAC,CAAC,CAAA;YAEF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;gBACvB,SAAS,CAAC,KAAK,EAAE,CAAA;gBACjB,0CAA0C;gBAC1C,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;gBAC5F,IAAI,YAAY,EAAE,CAAC;oBACjB,kBAAG,CAAC,KAAK,CAAC,IAAI,EAAE,uIAAuI,CAAC,CAAA;gBAC1J,CAAC;gBACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACtB,kBAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,wDAAwD,CAAC,CAAA;gBACjF,CAAC;gBACD,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,IAAI,YAAY,CAAA;gBAChD,OAAO,aAAa,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,kDAAkD,IAAI,MAAM,MAAM,EAAE,CAAC,CAAC,CAAA;YAC5H,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AA5YD,oDA4YC","sourcesContent":["import { exists, isEmptyOrSpaces, log, retry, TmpDir } from \"builder-util\"\nimport * as childProcess from \"child_process\"\nimport { CancellationToken } from \"builder-util-runtime\"\nimport * as fs from \"fs-extra\"\nimport { createWriteStream, readJson } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { hoist, type HoisterResult, type HoisterTree } from \"./hoist\"\nimport { createModuleCache, type ModuleCache } from \"./moduleCache\"\nimport { getPackageManagerCommand, PM } from \"./packageManager\"\nimport type { Dependency, DependencyGraph, NodeModuleInfo, PackageJson } from \"./types\"\n\nexport abstract class NodeModulesCollector<ProdDepType extends Dependency<ProdDepType, OptionalDepType>, OptionalDepType> {\n private readonly nodeModules: NodeModuleInfo[] = []\n protected readonly allDependencies: Map<string, ProdDepType> = new Map()\n protected readonly productionGraph: DependencyGraph = {}\n\n // Unified cache for all file system and module operations\n private readonly cache: ModuleCache = createModuleCache()\n\n protected readonly isHoisted = new Lazy<boolean>(async () => {\n const { manager } = this.installOptions\n const command = getPackageManagerCommand(manager)\n\n const config = (await this.asyncExec(command, [\"config\", \"list\"])).stdout?.trim()\n if (isEmptyOrSpaces(config)) {\n log.debug({ manager }, \"unable to determine if node_modules are hoisted: no config output. falling back to hoisted mode\")\n return false\n }\n const lines = Object.fromEntries(config.split(\"\\n\").map(line => line.split(\"=\").map(s => s.trim())))\n\n if (lines[\"node-linker\"] === \"hoisted\") {\n log.debug({ manager }, \"node_modules are hoisted\")\n return true\n }\n\n return false\n })\n\n protected appPkgJson: Lazy<PackageJson> = new Lazy<PackageJson>(async () => {\n const appPkgPath = path.join(this.rootDir, \"package.json\")\n return this.readJsonMemoized(appPkgPath)\n })\n\n constructor(\n protected readonly rootDir: string,\n private readonly tempDirManager: TmpDir\n ) {}\n\n public async getNodeModules({ cancellationToken, packageName }: { cancellationToken: CancellationToken; packageName: string }): Promise<NodeModuleInfo[]> {\n const tree: ProdDepType = await this.getDependenciesTree(this.installOptions.manager)\n\n if (cancellationToken.cancelled) {\n throw new Error(\"getNodeModules cancelled after fetching dependency tree\")\n }\n\n await this.collectAllDependencies(tree, packageName)\n const realTree: ProdDepType = await this.getTreeFromWorkspaces(tree, packageName)\n await this.extractProductionDependencyGraph(realTree, packageName)\n\n if (cancellationToken.cancelled) {\n throw new Error(\"getNodeModules cancelled after building production graph\")\n }\n\n const hoisterResult: HoisterResult = hoist(this.transformToHoisterTree(this.productionGraph, packageName), {\n check: log.isDebugEnabled,\n })\n await this._getNodeModules(hoisterResult.dependencies, this.nodeModules)\n log.debug({ packageName, depCount: this.nodeModules.length }, \"node modules collection complete\")\n return this.nodeModules\n }\n\n public abstract readonly installOptions: {\n manager: PM\n lockfile: string\n }\n\n protected abstract getArgs(): string[]\n protected abstract parseDependenciesTree(jsonBlob: string): Promise<ProdDepType>\n protected abstract extractProductionDependencyGraph(tree: Dependency<ProdDepType, OptionalDepType>, dependencyId: string): Promise<void>\n protected abstract collectAllDependencies(tree: Dependency<ProdDepType, OptionalDepType>, appPackageName: string): Promise<void>\n\n protected async getDependenciesTree(pm: PM): Promise<ProdDepType> {\n const command = getPackageManagerCommand(pm)\n const args = this.getArgs()\n\n const tempOutputFile = await this.tempDirManager.getTempFile({\n prefix: path.basename(command, path.extname(command)),\n suffix: \"output.json\",\n })\n\n return retry(\n async () => {\n await this.streamCollectorCommandToFile(command, args, this.rootDir, tempOutputFile)\n const shellOutput = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n return await this.parseDependenciesTree(shellOutput)\n },\n {\n retries: 1,\n interval: 2000,\n backoff: 2000,\n shouldRetry: async (error: any) => {\n const logFields = { error: error.message, tempOutputFile, cwd: this.rootDir }\n\n if (!(await this.existsMemoized(tempOutputFile))) {\n log.debug(logFields, \"dependency tree output file missing, retrying\")\n return true\n }\n\n const fileContent = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n const fields = { ...logFields, fileContent }\n\n if (fileContent.trim().length === 0) {\n log.debug(fields, \"dependency tree output file empty, retrying\")\n return true\n }\n\n if (error.message?.includes(\"Unexpected end of JSON input\")) {\n log.debug(fields, \"JSON parse error in dependency tree, retrying\")\n return true\n }\n\n log.error(fields, \"error parsing dependencies tree\")\n return false\n },\n }\n )\n }\n\n protected async existsMemoized(filePath: string): Promise<boolean> {\n if (!this.cache.exists.has(filePath)) {\n this.cache.exists.set(filePath, await exists(filePath))\n }\n return this.cache.exists.get(filePath)!\n }\n\n protected async readJsonMemoized(filePath: string): Promise<PackageJson> {\n if (!this.cache.packageJson.has(filePath)) {\n this.cache.packageJson.set(filePath, await readJson(filePath))\n }\n return this.cache.packageJson.get(filePath)!\n }\n\n protected async lstatMemoized(filePath: string): Promise<fs.Stats> {\n if (!this.cache.lstat.has(filePath)) {\n this.cache.lstat.set(filePath, await fs.lstat(filePath))\n }\n return this.cache.lstat.get(filePath)!\n }\n\n protected async realpathMemoized(filePath: string): Promise<string> {\n if (!this.cache.realPath.has(filePath)) {\n this.cache.realPath.set(filePath, await fs.realpath(filePath))\n }\n return this.cache.realPath.get(filePath)!\n }\n\n protected requireMemoized(pkgPath: string): PackageJson {\n if (!this.cache.packageJson.has(pkgPath)) {\n this.cache.packageJson.set(pkgPath, require(pkgPath))\n }\n return this.cache.packageJson.get(pkgPath)!\n }\n\n protected existsSyncMemoized(filePath: string): boolean {\n if (!this.cache.exists.has(filePath)) {\n this.cache.exists.set(filePath, fs.existsSync(filePath))\n }\n return this.cache.exists.get(filePath)!\n }\n\n protected async resolvePath(filePath: string): Promise<string> {\n // Check if we've already resolved this path\n if (this.cache.realPath.has(filePath)) {\n return this.cache.realPath.get(filePath)!\n }\n\n try {\n const stats = await this.lstatMemoized(filePath)\n if (stats.isSymbolicLink()) {\n const resolved = await this.realpathMemoized(filePath)\n this.cache.realPath.set(filePath, resolved)\n return resolved\n } else {\n this.cache.realPath.set(filePath, filePath)\n return filePath\n }\n } catch (error: any) {\n log.debug({ filePath, message: error.message || error.stack }, \"error resolving path\")\n this.cache.realPath.set(filePath, filePath)\n return filePath\n }\n }\n\n /**\n * Resolve a package directory purely from the filesystem.\n * Does NOT attempt to load the module or resolve an \"exports\" entrypoint.\n * Good for Yarn 4 because a package may not be resolvable as a module,\n * but still exists on disk.\n */\n protected async resolvePackage(packageName: string, fromDir: string): Promise<{ entry: string; packageDir: string } | null> {\n const cacheKey = `${packageName}::${fromDir}`\n if (this.cache.requireResolve.has(cacheKey)) {\n return this.cache.requireResolve.get(cacheKey)!\n }\n\n // 1. NESTED under fromDir/node_modules/<name>\n let candidate = path.join(fromDir, \"node_modules\", packageName)\n let pkgJson = path.join(candidate, \"package.json\")\n if (await this.existsMemoized(pkgJson)) {\n this.cache.requireResolve.set(cacheKey, { entry: pkgJson, packageDir: candidate })\n return { entry: pkgJson, packageDir: candidate }\n }\n\n // 2. HOISTED under rootDir/node_modules/<name>\n candidate = path.join(this.rootDir, \"node_modules\", packageName)\n pkgJson = path.join(candidate, \"package.json\")\n if (await this.existsMemoized(pkgJson)) {\n this.cache.requireResolve.set(cacheKey, { entry: pkgJson, packageDir: candidate })\n return { entry: pkgJson, packageDir: candidate }\n }\n\n // 3. FALLBACK: try parent directories BFS (classic Node-style search)\n let current = fromDir\n while (true) {\n const nm = path.join(current, \"node_modules\", packageName)\n const pkg = path.join(nm, \"package.json\")\n\n if (await this.existsMemoized(pkg)) {\n this.cache.requireResolve.set(cacheKey, { entry: pkg, packageDir: nm })\n return { entry: pkg, packageDir: nm }\n }\n\n const parent = path.dirname(current)\n if (parent === current) {\n break\n }\n current = parent\n }\n\n // 4. LAST RESORT: DO NOT throw — just return null\n this.cache.requireResolve.set(cacheKey, null)\n return null\n }\n\n protected cacheKey(pkg: ProdDepType): string {\n const rel = path.relative(this.rootDir, pkg.path)\n return `${pkg.name}::${pkg.version}::${rel ?? \".\"}`\n }\n\n protected packageVersionString(pkg: ProdDepType): string {\n return `${pkg.name}@${pkg.version}`\n }\n\n /**\n * Parse a dependency identifier like \"@scope/pkg@1.2.3\" or \"pkg@1.2.3\"\n */\n protected parseNameVersion(identifier: string): { name: string; version: string } {\n const lastAt = identifier.lastIndexOf(\"@\")\n if (lastAt <= 0) {\n // fallback for scoped packages or malformed strings\n return { name: identifier, version: \"unknown\" }\n }\n const name = identifier.slice(0, lastAt)\n const version = identifier.slice(lastAt + 1)\n return { name, version }\n }\n\n protected async getTreeFromWorkspaces(tree: ProdDepType, packageName: string): Promise<ProdDepType> {\n if (!(tree.workspaces && tree.dependencies)) {\n return tree\n }\n\n if (tree.dependencies?.[packageName]) {\n const { name, path, dependencies } = tree.dependencies[packageName]\n log.debug({ name, path, dependencies: JSON.stringify(dependencies) }, \"pruning root app/self reference from workspace tree, merging dependencies uptree\")\n for (const [name, pkg] of Object.entries(dependencies ?? {})) {\n tree.dependencies[name] = pkg\n this.allDependencies.set(this.packageVersionString(pkg), pkg)\n }\n delete tree.dependencies[packageName]\n }\n return Promise.resolve(tree)\n }\n\n private transformToHoisterTree(obj: DependencyGraph, key: string, nodes: Map<string, HoisterTree> = new Map()): HoisterTree {\n let node = nodes.get(key)\n const { name, version } = this.parseNameVersion(key)\n\n if (!node) {\n node = {\n name,\n identName: name,\n reference: version,\n dependencies: new Set<HoisterTree>(),\n peerNames: new Set<string>(),\n }\n\n nodes.set(key, node)\n\n const deps = (obj[key] || {}).dependencies || []\n for (const dep of deps) {\n const child = this.transformToHoisterTree(obj, dep, nodes)\n node.dependencies.add(child)\n }\n }\n\n return node\n }\n\n private async _getNodeModules(dependencies: Set<HoisterResult>, result: NodeModuleInfo[]) {\n if (dependencies.size === 0) {\n return\n }\n\n for (const d of dependencies.values()) {\n const reference = [...d.references][0]\n const p = this.allDependencies.get(`${d.name}@${reference}`)?.path\n if (p === undefined) {\n log.debug({ name: d.name, reference }, \"cannot find path for dependency\")\n continue\n }\n\n // fix npm list issue\n // https://github.com/npm/cli/issues/8535\n if (!(await exists(p))) {\n log.debug({ name: d.name, reference, p }, \"dependency path does not exist\")\n continue\n }\n\n const node: NodeModuleInfo = {\n name: d.name,\n version: reference,\n dir: await this.resolvePath(p),\n }\n result.push(node)\n if (d.dependencies.size > 0) {\n node.dependencies = []\n await this._getNodeModules(d.dependencies, node.dependencies)\n }\n }\n result.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n async asyncExec(command: string, args: string[], cwd: string = this.rootDir): Promise<{ stdout: string | undefined; stderr: string | undefined }> {\n const file = await this.tempDirManager.getTempFile({ prefix: \"exec-\", suffix: \".txt\" })\n try {\n await this.streamCollectorCommandToFile(command, args, cwd, file)\n const result = await fs.readFile(file, { encoding: \"utf8\" })\n return { stdout: result?.trim(), stderr: undefined }\n } catch (error: any) {\n log.debug({ error: error.message }, \"failed to execute command\")\n return { stdout: undefined, stderr: error.message }\n }\n }\n\n async streamCollectorCommandToFile(command: string, args: string[], cwd: string, tempOutputFile: string) {\n const execName = path.basename(command, path.extname(command))\n const isWindowsScriptFile = process.platform === \"win32\" && path.extname(command).toLowerCase() === \".cmd\"\n if (isWindowsScriptFile) {\n // If the command is a Windows script file (.cmd), we need to wrap it in a .bat file to ensure it runs correctly with cmd.exe\n // This is necessary because .cmd files are not directly executable in the same way as .bat files.\n // We create a temporary .bat file that calls the .cmd file with the provided arguments. The .bat file will be executed by cmd.exe.\n // Note: This is a workaround for Windows command execution quirks for specifically when `shell: false`\n const tempBatFile = await this.tempDirManager.getTempFile({\n prefix: execName,\n suffix: \".bat\",\n })\n const batScript = `@echo off\\r\\n\"${command}\" %*\\r\\n` // <-- CRLF required for .bat\n await fs.writeFile(tempBatFile, batScript, { encoding: \"utf8\" })\n command = \"cmd.exe\"\n args = [\"/c\", tempBatFile, ...args]\n }\n\n log.debug({ command, args, cwd, tempOutputFile }, \"spawning node module collector process\")\n\n await new Promise<void>((resolve, reject) => {\n const outStream = createWriteStream(tempOutputFile)\n\n const child = childProcess.spawn(command, args, {\n cwd,\n shell: false, // required to prevent console logs polution from shell profile loading when `true`\n })\n\n let stderr = \"\"\n child.stdout.pipe(outStream)\n child.stderr.on(\"data\", chunk => {\n stderr += chunk.toString()\n })\n child.on(\"error\", err => {\n reject(new Error(`Node module collector spawn failed: ${err.message}`))\n })\n\n child.on(\"close\", code => {\n outStream.close()\n // https://github.com/npm/npm/issues/17624\n const shouldIgnore = code === 1 && \"npm\" === execName.toLowerCase() && args.includes(\"list\")\n if (shouldIgnore) {\n log.debug(null, \"`npm list` returned non-zero exit code, but it MIGHT be expected (https://github.com/npm/npm/issues/17624). Check stderr for details.\")\n }\n if (stderr.length > 0) {\n log.debug({ stderr }, \"note: there was node module collector output on stderr\")\n }\n const shouldResolve = code === 0 || shouldIgnore\n return shouldResolve ? resolve() : reject(new Error(`Node module collector process exited with code ${code}:\\n${stderr}`))\n })\n })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,+CAAiD;AAEjD,8CAA6C;AAC7C,+BAA8B;AAC9B,uCAA4C;AAC5C,uCAA+B;AAC/B,6BAA4B;AAC5B,iCAAgC;AAChC,mCAAqE;AACrE,+CAA2C;AAC3C,qDAA+D;AAI/D,MAAsB,oBAAoB;IAsBxC,YACqB,OAAe,EACjB,cAAsB;QADpB,YAAO,GAAP,OAAO,CAAQ;QACjB,mBAAc,GAAd,cAAc,CAAQ;QAvBxB,gBAAW,GAAqB,EAAE,CAAA;QAChC,oBAAe,GAA6B,IAAI,GAAG,EAAE,CAAA;QACrD,oBAAe,GAAoB,EAAE,CAAA;QACrC,UAAK,GAAgB,IAAI,yBAAW,EAAE,CAAA;QAE/C,cAAS,GAAG,IAAI,eAAI,CAAU,KAAK,IAAI,EAAE;YACjD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,cAAc,CAAA;YACvC,MAAM,OAAO,GAAG,IAAA,yCAAwB,EAAC,OAAO,CAAC,CAAA;YACjD,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;YACzE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;gBACnB,kBAAG,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,iGAAiG,CAAC,CAAA;gBACzH,OAAO,KAAK,CAAA;YACd,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,M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E,CAAA;oBACrE,CAAC;gBACH,CAAC;gBAED,oEAAoE;gBACpE,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,cAAc,CAAC,CAAA;gBACrE,IAAI,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC;oBAC7C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAA;oBAC1D,IAAI,GAAG,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC;wBACpD,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAA;oBACpE,CAAC;gBACH,CAAC;gBAED,kDAAkD;gBAClD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;gBAC5D,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;oBAC1G,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC;wBAClC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;wBAC5B,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAA;oBACxD,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AArcD,oDAqcC","sourcesContent":["import { log, retry, TmpDir } from \"builder-util\"\nimport { CancellationToken } from \"builder-util-runtime\"\nimport * as childProcess from \"child_process\"\nimport * as fs from \"fs-extra\"\nimport { createWriteStream } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport { hoist, type HoisterResult, type HoisterTree } from \"./hoist\"\nimport { ModuleCache } from \"./moduleCache\"\nimport { getPackageManagerCommand, PM } from \"./packageManager\"\nimport type { Dependency, DependencyGraph, NodeModuleInfo } from \"./types\"\ntype Result = { packageDir: string; version: string } | null\n\nexport abstract class NodeModulesCollector<ProdDepType extends Dependency<ProdDepType, OptionalDepType>, OptionalDepType> {\n private readonly nodeModules: NodeModuleInfo[] = []\n protected readonly allDependencies: Map<string, ProdDepType> = new Map()\n protected readonly productionGraph: DependencyGraph = {}\n protected readonly cache: ModuleCache = new ModuleCache()\n\n protected isHoisted = new Lazy<boolean>(async () => {\n const { manager } = this.installOptions\n const command = getPackageManagerCommand(manager)\n const config = (await this.asyncExec(command, [\"config\", \"list\"])).stdout\n if (config == null) {\n log.debug({ manager }, \"unable to determine if node_modules are hoisted: no config output. falling back to hoisted mode\")\n return false\n }\n const lines = Object.fromEntries(config.split(\"\\n\").map(line => line.split(\"=\").map(s => s.trim())))\n if (lines[\"node-linker\"] === \"hoisted\") {\n log.debug({ manager }, \"node_modules are hoisted\")\n return true\n }\n return false\n })\n\n constructor(\n protected readonly rootDir: string,\n private readonly tempDirManager: TmpDir\n ) {}\n\n public async getNodeModules({ cancellationToken, packageName }: { cancellationToken: CancellationToken; packageName: string }): Promise<NodeModuleInfo[]> {\n const tree: ProdDepType = await this.getDependenciesTree(this.installOptions.manager)\n\n if (cancellationToken.cancelled) {\n throw new Error(\"getNodeModules cancelled after fetching dependency tree\")\n }\n\n await this.collectAllDependencies(tree, packageName)\n\n const realTree: ProdDepType = await this.getTreeFromWorkspaces(tree, packageName)\n await this.extractProductionDependencyGraph(realTree, packageName)\n\n if (cancellationToken.cancelled) {\n throw new Error(\"getNodeModules cancelled after building production graph\")\n }\n\n const hoisterResult: HoisterResult = hoist(this.transformToHoisterTree(this.productionGraph, packageName), {\n check: log.isDebugEnabled,\n })\n\n await this._getNodeModules(hoisterResult.dependencies, this.nodeModules)\n log.debug({ packageName, depCount: this.nodeModules.length }, \"node modules collection complete\")\n\n return this.nodeModules\n }\n\n public abstract readonly installOptions: {\n manager: PM\n lockfile: string\n }\n\n protected abstract getArgs(): string[]\n protected abstract parseDependenciesTree(jsonBlob: string): Promise<ProdDepType>\n protected abstract extractProductionDependencyGraph(tree: Dependency<ProdDepType, OptionalDepType>, dependencyId: string): Promise<void>\n protected abstract collectAllDependencies(tree: Dependency<ProdDepType, OptionalDepType>, appPackageName: string): Promise<void>\n\n protected async getDependenciesTree(pm: PM): Promise<ProdDepType> {\n const command = getPackageManagerCommand(pm)\n const args = this.getArgs()\n\n const tempOutputFile = await this.tempDirManager.getTempFile({\n prefix: path.basename(command, path.extname(command)),\n suffix: \"output.json\",\n })\n\n return retry(\n async () => {\n await this.streamCollectorCommandToFile(command, args, this.rootDir, tempOutputFile)\n const shellOutput = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n return await this.parseDependenciesTree(shellOutput)\n },\n {\n retries: 1,\n interval: 2000,\n backoff: 2000,\n shouldRetry: async (error: any) => {\n const logFields = { error: error.message, tempOutputFile, cwd: this.rootDir }\n\n if (!(await this.cache.exists[tempOutputFile])) {\n log.debug(logFields, \"dependency tree output file missing, retrying\")\n return true\n }\n\n const fileContent = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n const fields = { ...logFields, fileContent }\n\n if (fileContent.trim().length === 0) {\n log.debug(fields, \"dependency tree output file empty, retrying\")\n return true\n }\n\n if (error.message?.includes(\"Unexpected end of JSON input\")) {\n log.debug(fields, \"JSON parse error in dependency tree, retrying\")\n return true\n }\n\n log.error(fields, \"error parsing dependencies tree\")\n return false\n },\n }\n )\n }\n\n protected cacheKey(pkg: ProdDepType): string {\n const rel = path.relative(this.rootDir, pkg.path)\n return `${pkg.name}::${pkg.version}::${rel ?? \".\"}`\n }\n\n protected packageVersionString(pkg: ProdDepType): string {\n return `${pkg.name}@${pkg.version}`\n }\n\n /**\n * Parse a dependency identifier like \"@scope/pkg@1.2.3\" or \"pkg@1.2.3\"\n */\n protected parseNameVersion(identifier: string): { name: string; version: string } {\n const lastAt = identifier.lastIndexOf(\"@\")\n if (lastAt <= 0) {\n // fallback for scoped packages or malformed strings\n return { name: identifier, version: \"unknown\" }\n }\n const name = identifier.slice(0, lastAt)\n const version = identifier.slice(lastAt + 1)\n return { name, version }\n }\n\n protected async getTreeFromWorkspaces(tree: ProdDepType, packageName: string): Promise<ProdDepType> {\n if (!(tree.workspaces && tree.dependencies)) {\n return tree\n }\n\n if (tree.dependencies?.[packageName]) {\n const { name, path, dependencies } = tree.dependencies[packageName]\n log.debug({ name, path, dependencies: JSON.stringify(dependencies) }, \"pruning root app/self reference from workspace tree\")\n for (const [name, pkg] of Object.entries(dependencies ?? {})) {\n tree.dependencies[name] = pkg\n this.allDependencies.set(this.packageVersionString(pkg), pkg)\n }\n delete tree.dependencies[packageName]\n }\n return Promise.resolve(tree)\n }\n\n private transformToHoisterTree(obj: DependencyGraph, key: string, nodes: Map<string, HoisterTree> = new Map()): HoisterTree {\n let node = nodes.get(key)\n const { name, version } = this.parseNameVersion(key)\n\n if (!node) {\n node = {\n name,\n identName: name,\n reference: version,\n dependencies: new Set<HoisterTree>(),\n peerNames: new Set<string>(),\n }\n\n nodes.set(key, node)\n\n const deps = (obj[key] || {}).dependencies || []\n for (const dep of deps) {\n const child = this.transformToHoisterTree(obj, dep, nodes)\n node.dependencies.add(child)\n }\n }\n\n return node\n }\n\n private async _getNodeModules(dependencies: Set<HoisterResult>, result: NodeModuleInfo[]) {\n if (dependencies.size === 0) {\n return\n }\n\n for (const d of dependencies.values()) {\n const reference = [...d.references][0]\n const p = this.allDependencies.get(`${d.name}@${reference}`)?.path\n if (p === undefined) {\n log.warn({ name: d.name, reference }, \"cannot find path for dependency\")\n continue\n }\n\n // fix npm list issue\n // https://github.com/npm/cli/issues/8535\n if (!(await this.cache.exists[p])) {\n log.debug({ name: d.name, reference, p }, \"dependency path does not exist\")\n continue\n }\n\n const node: NodeModuleInfo = {\n name: d.name,\n version: reference,\n dir: await this.cache.realPath[p],\n }\n result.push(node)\n if (d.dependencies.size > 0) {\n node.dependencies = []\n await this._getNodeModules(d.dependencies, node.dependencies)\n }\n }\n result.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n async asyncExec(command: string, args: string[], cwd: string = this.rootDir): Promise<{ stdout: string | undefined; stderr: string | undefined }> {\n const file = await this.tempDirManager.getTempFile({ prefix: \"exec-\", suffix: \".txt\" })\n try {\n await this.streamCollectorCommandToFile(command, args, cwd, file)\n const result = await fs.readFile(file, { encoding: \"utf8\" })\n return { stdout: result?.trim(), stderr: undefined }\n } catch (error: any) {\n log.debug({ error: error.message }, \"failed to execute command\")\n return { stdout: undefined, stderr: error.message }\n }\n }\n\n async streamCollectorCommandToFile(command: string, args: string[], cwd: string, tempOutputFile: string) {\n const execName = path.basename(command, path.extname(command))\n const isWindowsScriptFile = process.platform === \"win32\" && path.extname(command).toLowerCase() === \".cmd\"\n if (isWindowsScriptFile) {\n // If the command is a Windows script file (.cmd), we need to wrap it in a .bat file to ensure it runs correctly with cmd.exe\n // This is necessary because .cmd files are not directly executable in the same way as .bat files.\n // We create a temporary .bat file that calls the .cmd file with the provided arguments. The .bat file will be executed by cmd.exe.\n // Note: This is a workaround for Windows command execution quirks for specifically when `shell: false`\n const tempBatFile = await this.tempDirManager.getTempFile({\n prefix: execName,\n suffix: \".bat\",\n })\n const batScript = `@echo off\\r\\n\"${command}\" %*\\r\\n` // <-- CRLF required for .bat\n await fs.writeFile(tempBatFile, batScript, { encoding: \"utf8\" })\n command = \"cmd.exe\"\n args = [\"/c\", tempBatFile, ...args]\n }\n\n await new Promise<void>((resolve, reject) => {\n const outStream = createWriteStream(tempOutputFile)\n\n const child = childProcess.spawn(command, args, {\n cwd,\n shell: false, // required to prevent console logs polution from shell profile loading when `true`\n })\n\n let stderr = \"\"\n child.stdout.pipe(outStream)\n child.stderr.on(\"data\", chunk => {\n stderr += chunk.toString()\n })\n child.on(\"error\", err => {\n reject(new Error(`Node module collector spawn failed: ${err.message}`))\n })\n\n child.on(\"close\", code => {\n outStream.close()\n // https://github.com/npm/npm/issues/17624\n const shouldIgnore = code === 1 && \"npm\" === execName.toLowerCase() && args.includes(\"list\")\n if (shouldIgnore) {\n log.debug(null, \"`npm list` returned non-zero exit code, but it MIGHT be expected (https://github.com/npm/npm/issues/17624). Check stderr for details.\")\n }\n if (stderr.length > 0) {\n log.debug({ stderr }, \"note: there was node module collector output on stderr\")\n }\n const shouldResolve = code === 0 || shouldIgnore\n return shouldResolve ? resolve() : reject(new Error(`Node module collector process exited with code ${code}:\\n${stderr}`))\n })\n })\n }\n\n protected async locatePackageVersion(parentDir: string, pkgName: string, requiredRange?: string): Promise<Result | null> {\n // 1) check direct parent node_modules/pkgName first\n const direct = path.join(path.resolve(parentDir), \"node_modules\", pkgName, \"package.json\")\n if (await this.cache.exists[direct]) {\n const ver = await this.readPackageVersion(direct)\n if (ver && this.semverSatisfies(ver, requiredRange)) {\n return { packageDir: path.dirname(direct), version: ver }\n }\n }\n\n // 2) upward hoisted search, then 3) downward non-hoisted search\n return (await this.upwardSearch(parentDir, pkgName, requiredRange)) || (await this.downwardSearch(parentDir, pkgName, requiredRange)) || null\n }\n\n protected async readPackageVersion(pkgJsonPath: string): Promise<string | null> {\n return await this.cache.packageJson[pkgJsonPath].then(pkg => pkg.version).catch(() => null)\n }\n\n protected semverSatisfies(found: string, range?: string): boolean {\n if (!range || range === \"*\" || range === \"\") {\n return true\n }\n\n if (range === found) {\n return true\n }\n\n if (semver.validRange(range) == null) {\n // ignore, we can't verify non-semver ranges\n // e.g. git urls, file:, patch:, etc. Example:\n // \"@ai-sdk/google\": \"patch:@ai-sdk/google@npm%3A2.0.43#~/.yarn/patches/@ai-sdk-google-npm-2.0.43-689ed559b3.patch\"\n log.debug({ found, range }, \"unable to validate semver version range, assuming match\")\n return true\n }\n\n try {\n return semver.satisfies(found, range)\n } catch {\n // fallback: simple equality or basic prefix handling (^, ~)\n if (range.startsWith(\"^\") || range.startsWith(\"~\")) {\n const r = range.slice(1)\n return r === found\n }\n // if range is like \"8.x\" or \"8.*\" match major\n const m = range.match(/^(\\d+)[.(*|x)]*/)\n const fm = found.match(/^(\\d+)\\./)\n if (m && fm) {\n return m[1] === fm[1]\n }\n return false\n }\n }\n\n /**\n * Upward search (hoisted)\n */\n private async upwardSearch(parentDir: string, pkgName: string, requiredRange?: string): Promise<Result> {\n let current = path.resolve(parentDir)\n const root = path.parse(current).root\n while (true) {\n const candidate = path.join(current, \"node_modules\", pkgName, \"package.json\")\n if (await this.cache.exists[candidate]) {\n const ver = await this.readPackageVersion(candidate)\n if (ver && this.semverSatisfies(ver, requiredRange)) {\n return { packageDir: path.dirname(candidate), version: ver }\n }\n // otherwise keep searching upward (we may find a different hoisted version)\n }\n if (current === root) {\n break\n }\n const parent = path.dirname(current)\n if (parent === current) {\n break\n }\n current = parent\n }\n return null\n }\n\n /**\n * Breadth-first downward search from parentDir/node_modules\n * Looks for node_modules/\\*\\/node_modules/pkgName (and deeper)\n */\n private async downwardSearch(parentDir: string, pkgName: string, requiredRange?: string, maxExplored = 2000, maxDepth = 6): Promise<Result> {\n const start = path.join(path.resolve(parentDir), \"node_modules\")\n if (!(await this.cache.exists[start]) || !(await this.cache.lstat[start]).isDirectory()) {\n return null\n }\n\n const visited = new Set<string>()\n const queue: Array<{ dir: string; depth: number }> = [{ dir: start, depth: 0 }]\n let explored = 0\n\n while (queue.length > 0) {\n const { dir, depth } = queue.shift()!\n if (explored++ > maxExplored) {\n break\n }\n if (depth > maxDepth) {\n continue\n }\n let entries: string[]\n try {\n entries = await fs.readdir(dir)\n } catch (e) {\n continue\n }\n for (const entry of entries) {\n if (entry.startsWith(\".\")) {\n continue\n }\n const entryPath = path.join(dir, entry)\n // handle scoped packages @scope/name\n if (entry.startsWith(\"@\")) {\n // queue the scope directory itself to explore its children\n if ((await this.cache.exists[entryPath]) && (await this.cache.lstat[entryPath]).isDirectory()) {\n const scopeEntries = await fs.readdir(entryPath)\n for (const sc of scopeEntries) {\n const scPath = path.join(entryPath, sc)\n // check scPath/node_modules/pkgName\n const candidatePkgJson = path.join(scPath, \"node_modules\", pkgName, \"package.json\")\n if (await this.cache.exists[candidatePkgJson]) {\n const ver = await this.readPackageVersion(candidatePkgJson)\n if (ver && this.semverSatisfies(ver, requiredRange)) {\n return { packageDir: path.dirname(candidatePkgJson), version: ver }\n }\n }\n // enqueue scPath/node_modules to explore further\n const scNodeModules = path.join(scPath, \"node_modules\")\n if ((await this.cache.exists[scNodeModules]) && (await this.cache.lstat[scNodeModules]).isDirectory()) {\n if (!visited.has(scNodeModules)) {\n visited.add(scNodeModules)\n queue.push({ dir: scNodeModules, depth: depth + 1 })\n }\n }\n }\n }\n continue\n }\n\n // check for direct candidate: entry/node_modules/pkgName\n try {\n const stat = await this.cache.lstat[entryPath]\n if (!stat.isDirectory()) {\n continue\n }\n } catch {\n continue\n }\n\n const candidatePkgJson = path.join(entryPath, \"node_modules\", pkgName, \"package.json\")\n if (await this.cache.exists[candidatePkgJson]) {\n const ver = await this.readPackageVersion(candidatePkgJson)\n if (ver && this.semverSatisfies(ver, requiredRange)) {\n return { packageDir: path.dirname(candidatePkgJson), version: ver }\n }\n }\n\n // also check entry/node_modules directly for pkgName (some layouts)\n const candidateDirect = path.join(entryPath, pkgName, \"package.json\")\n if (await this.cache.exists[candidateDirect]) {\n const ver = await this.readPackageVersion(candidateDirect)\n if (ver && this.semverSatisfies(ver, requiredRange)) {\n return { packageDir: path.dirname(candidateDirect), version: ver }\n }\n }\n\n // enqueue entry/node_modules for deeper traversal\n const nextNodeModules = path.join(entryPath, \"node_modules\")\n if ((await this.cache.exists[nextNodeModules]) && (await this.cache.lstat[nextNodeModules]).isDirectory()) {\n if (!visited.has(nextNodeModules)) {\n visited.add(nextNodeModules)\n queue.push({ dir: nextNodeModules, depth: depth + 1 })\n }\n }\n }\n }\n\n return null\n }\n}\n"]}
|
|
@@ -10,6 +10,7 @@ export declare class NpmNodeModulesCollector extends NodeModulesCollector<NpmDep
|
|
|
10
10
|
protected getDependenciesTree(pm: PM): Promise<NpmDependency>;
|
|
11
11
|
protected collectAllDependencies(tree: NpmDependency): Promise<void>;
|
|
12
12
|
protected extractProductionDependencyGraph(tree: NpmDependency, dependencyId: string): Promise<void>;
|
|
13
|
+
private isDuplicatedNpmDependency;
|
|
13
14
|
protected isProdDependency(packageName: string, tree: NpmDependency): boolean;
|
|
14
15
|
/**
|
|
15
16
|
* Builds a dependency tree using only package.json dependencies and optionalDependencies.
|
|
@@ -23,14 +23,12 @@ class NpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollecto
|
|
|
23
23
|
catch (error) {
|
|
24
24
|
builder_util_1.log.info({ pm: this.installOptions.manager, parser: packageManager_1.PM.NPM, error: error.message }, "unable to process dependency tree, falling back to using manual node_modules traversal");
|
|
25
25
|
}
|
|
26
|
-
// node_modules linker fallback. (Slower due to system ops, so we only use it as a fallback) [
|
|
26
|
+
// node_modules linker fallback. (Slower due to system ops, so we only use it as a fallback) [such as when corepack env will not allow npm CLI to extract tree]
|
|
27
27
|
return this.buildNodeModulesTreeManually(this.rootDir);
|
|
28
28
|
}
|
|
29
29
|
async collectAllDependencies(tree) {
|
|
30
30
|
for (const [, value] of Object.entries(tree.dependencies || {})) {
|
|
31
|
-
|
|
32
|
-
const isDuplicateDep = Object.keys(_dependencies).length > 0 && Object.keys(dependencies).length === 0;
|
|
33
|
-
if (isDuplicateDep) {
|
|
31
|
+
if (this.isDuplicatedNpmDependency(value)) {
|
|
34
32
|
continue;
|
|
35
33
|
}
|
|
36
34
|
this.allDependencies.set(this.packageVersionString(value), value);
|
|
@@ -38,27 +36,36 @@ class NpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollecto
|
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
38
|
async extractProductionDependencyGraph(tree, dependencyId) {
|
|
41
|
-
var _a
|
|
39
|
+
var _a;
|
|
42
40
|
if (this.productionGraph[dependencyId]) {
|
|
43
41
|
return;
|
|
44
42
|
}
|
|
45
|
-
const
|
|
46
|
-
const isDuplicateDep =
|
|
47
|
-
const resolvedDeps = isDuplicateDep ? ((_b = (_a = this.allDependencies.get(dependencyId)) === null || _a === void 0 ? void 0 : _a.dependencies) !== null && _b !== void 0 ? _b : {}) : dependencies;
|
|
43
|
+
const isDuplicateDep = this.isDuplicatedNpmDependency(tree);
|
|
44
|
+
const resolvedDeps = isDuplicateDep ? (_a = this.allDependencies.get(dependencyId)) === null || _a === void 0 ? void 0 : _a.dependencies : tree.dependencies;
|
|
48
45
|
// Initialize with empty dependencies array first to mark this dependency as "in progress"
|
|
49
46
|
// After initialization, if there are libraries with the same name+version later, they will not be searched recursively again
|
|
50
47
|
// This will prevents infinite loops when circular dependencies are encountered.
|
|
51
48
|
this.productionGraph[dependencyId] = { dependencies: [] };
|
|
52
|
-
const productionDeps = Object.entries(resolvedDeps)
|
|
49
|
+
const productionDeps = Object.entries(resolvedDeps || {})
|
|
53
50
|
.filter(([packageName]) => this.isProdDependency(packageName, tree))
|
|
54
51
|
.map(async ([, dependency]) => {
|
|
55
52
|
const childDependencyId = this.packageVersionString(dependency);
|
|
56
53
|
await this.extractProductionDependencyGraph(dependency, childDependencyId);
|
|
57
54
|
return childDependencyId;
|
|
58
55
|
});
|
|
59
|
-
const collectedDependencies =
|
|
56
|
+
const collectedDependencies = [];
|
|
57
|
+
for (const dep of productionDeps) {
|
|
58
|
+
collectedDependencies.push(await dep);
|
|
59
|
+
}
|
|
60
60
|
this.productionGraph[dependencyId] = { dependencies: collectedDependencies };
|
|
61
61
|
}
|
|
62
|
+
// Check: is package already included as a prod dependency due to another package?
|
|
63
|
+
// We need to check this to prevent infinite loops in case of duplicated dependencies
|
|
64
|
+
isDuplicatedNpmDependency(tree) {
|
|
65
|
+
const { _dependencies = {}, dependencies = {} } = tree;
|
|
66
|
+
const isDuplicateDep = Object.keys(_dependencies).length > 0 && Object.keys(dependencies).length === 0;
|
|
67
|
+
return isDuplicateDep;
|
|
68
|
+
}
|
|
62
69
|
isProdDependency(packageName, tree) {
|
|
63
70
|
var _a;
|
|
64
71
|
return ((_a = tree._dependencies) === null || _a === void 0 ? void 0 : _a[packageName]) != null;
|
|
@@ -76,12 +83,11 @@ class NpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollecto
|
|
|
76
83
|
const buildFromPackage = async (packageDir) => {
|
|
77
84
|
const pkgPath = path.join(packageDir, "package.json");
|
|
78
85
|
builder_util_1.log.debug({ pkgPath }, "building dependency node from package.json");
|
|
79
|
-
if (!(await this.
|
|
86
|
+
if (!(await this.cache.exists[pkgPath])) {
|
|
80
87
|
throw new Error(`package.json not found at ${pkgPath}`);
|
|
81
88
|
}
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
const resolvedPackageDir = await this.resolvePath(packageDir);
|
|
89
|
+
const pkg = await this.cache.packageJson[pkgPath];
|
|
90
|
+
const resolvedPackageDir = await this.cache.realPath[packageDir];
|
|
85
91
|
// Use resolved path as the unique identifier to prevent circular dependencies
|
|
86
92
|
if (visited.has(resolvedPackageDir)) {
|
|
87
93
|
builder_util_1.log.debug({ name: pkg.name, version: pkg.version, path: resolvedPackageDir }, "skipping already visited package");
|
|
@@ -100,18 +106,19 @@ class NpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollecto
|
|
|
100
106
|
// Process all production and optional dependencies
|
|
101
107
|
for (const [depName, depVersion] of Object.entries(allProdDepNames)) {
|
|
102
108
|
try {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
const depPath = await this.locatePackageVersion(resolvedPackageDir, depName, depVersion);
|
|
110
|
+
if (!depPath || depPath.packageDir.length === 0) {
|
|
111
|
+
builder_util_1.log.warn({ package: pkg.name, dependency: depName, version: depVersion }, "dependency not found, skipping");
|
|
112
|
+
continue;
|
|
107
113
|
}
|
|
108
|
-
const resolvedDepPath = await this.
|
|
114
|
+
const resolvedDepPath = await this.cache.realPath[depPath.packageDir];
|
|
115
|
+
const logFields = { package: pkg.name, dependency: depName, resolvedPath: resolvedDepPath };
|
|
109
116
|
// Skip if this dependency resolves to the base directory or any parent we're already processing
|
|
110
|
-
if (resolvedDepPath === resolvedPackageDir || resolvedDepPath === (await this.
|
|
111
|
-
builder_util_1.log.debug(
|
|
117
|
+
if (resolvedDepPath === resolvedPackageDir || resolvedDepPath === (await this.cache.realPath[baseDir])) {
|
|
118
|
+
builder_util_1.log.debug(logFields, "skipping self-referential dependency");
|
|
112
119
|
continue;
|
|
113
120
|
}
|
|
114
|
-
builder_util_1.log.debug(
|
|
121
|
+
builder_util_1.log.debug(logFields, "processing production dependency");
|
|
115
122
|
// Recursively build the dependency tree for this dependency
|
|
116
123
|
prodDeps[depName] = await buildFromPackage(resolvedDepPath);
|
|
117
124
|
}
|