app-builder-lib 26.7.0 → 26.8.1

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.
Files changed (69) hide show
  1. package/out/codeSign/windowsSignToolManager.d.ts +4 -5
  2. package/out/codeSign/windowsSignToolManager.js +76 -86
  3. package/out/codeSign/windowsSignToolManager.js.map +1 -1
  4. package/out/configuration.d.ts +34 -0
  5. package/out/configuration.js.map +1 -1
  6. package/out/index.d.ts +1 -1
  7. package/out/index.js.map +1 -1
  8. package/out/linuxPackager.js +1 -1
  9. package/out/linuxPackager.js.map +1 -1
  10. package/out/node-module-collector/index.d.ts +1 -8
  11. package/out/node-module-collector/index.js +0 -5
  12. package/out/node-module-collector/index.js.map +1 -1
  13. package/out/node-module-collector/moduleManager.d.ts +15 -0
  14. package/out/node-module-collector/moduleManager.js +50 -1
  15. package/out/node-module-collector/moduleManager.js.map +1 -1
  16. package/out/node-module-collector/nodeModulesCollector.d.ts +10 -10
  17. package/out/node-module-collector/nodeModulesCollector.js +12 -16
  18. package/out/node-module-collector/nodeModulesCollector.js.map +1 -1
  19. package/out/node-module-collector/npmNodeModulesCollector.js +15 -8
  20. package/out/node-module-collector/npmNodeModulesCollector.js.map +1 -1
  21. package/out/node-module-collector/pnpmNodeModulesCollector.d.ts +0 -1
  22. package/out/node-module-collector/pnpmNodeModulesCollector.js +2 -6
  23. package/out/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
  24. package/out/node-module-collector/traversalNodeModulesCollector.js +10 -7
  25. package/out/node-module-collector/traversalNodeModulesCollector.js.map +1 -1
  26. package/out/node-module-collector/types.d.ts +0 -4
  27. package/out/node-module-collector/types.js.map +1 -1
  28. package/out/node-module-collector/yarnNodeModulesCollector.d.ts +4 -10
  29. package/out/node-module-collector/yarnNodeModulesCollector.js +7 -197
  30. package/out/node-module-collector/yarnNodeModulesCollector.js.map +1 -1
  31. package/out/targets/AppxTarget.js +8 -7
  32. package/out/targets/AppxTarget.js.map +1 -1
  33. package/out/targets/FpmTarget.js +3 -3
  34. package/out/targets/FpmTarget.js.map +1 -1
  35. package/out/targets/MsiWrappedTarget.js +4 -3
  36. package/out/targets/MsiWrappedTarget.js.map +1 -1
  37. package/out/targets/appimage/AppImageTarget.d.ts +16 -0
  38. package/out/targets/{AppImageTarget.js → appimage/AppImageTarget.js} +65 -28
  39. package/out/targets/appimage/AppImageTarget.js.map +1 -0
  40. package/out/targets/appimage/appImageUtil.d.ts +23 -0
  41. package/out/targets/appimage/appImageUtil.js +266 -0
  42. package/out/targets/appimage/appImageUtil.js.map +1 -0
  43. package/out/targets/appimage/appLauncher.d.ts +3 -0
  44. package/out/targets/appimage/appLauncher.js +91 -0
  45. package/out/targets/appimage/appLauncher.js.map +1 -0
  46. package/out/targets/archive.js +2 -2
  47. package/out/targets/archive.js.map +1 -1
  48. package/out/toolsets/linux.d.ts +9 -0
  49. package/out/toolsets/linux.js +68 -0
  50. package/out/toolsets/linux.js.map +1 -0
  51. package/out/toolsets/windows.d.ts +42 -0
  52. package/out/toolsets/windows.js +143 -0
  53. package/out/toolsets/windows.js.map +1 -0
  54. package/out/util/appFileCopier.js +39 -28
  55. package/out/util/appFileCopier.js.map +1 -1
  56. package/out/util/packageMetadata.js +9 -5
  57. package/out/util/packageMetadata.js.map +1 -1
  58. package/out/version.d.ts +1 -1
  59. package/out/version.js +1 -1
  60. package/out/version.js.map +1 -1
  61. package/out/winPackager.js +4 -3
  62. package/out/winPackager.js.map +1 -1
  63. package/package.json +8 -8
  64. package/scheme.json +51 -0
  65. package/out/targets/AppImageTarget.d.ts +0 -14
  66. package/out/targets/AppImageTarget.js.map +0 -1
  67. package/out/targets/tools.d.ts +0 -2
  68. package/out/targets/tools.js +0 -46
  69. package/out/targets/tools.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,+CAAyD;AACzD,8CA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C1C,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;AA/XD,oDA+XC","sourcesContent":["import { exists, log, retry, TmpDir } from \"builder-util\"\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 { hoist, type HoisterResult, type HoisterTree } from \"./hoist\"\nimport { ModuleManager } from \"./moduleManager\"\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 protected readonly cache: ModuleManager = new ModuleManager()\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 /**\n * Retrieves and collects all Node.js modules for a given package.\n *\n * This method orchestrates the entire module collection process by:\n * 1. Fetching the dependency tree from the package manager\n * 2. Collecting all dependencies recursively\n * 3. Extracting workspace references if applicable\n * 4. Building a production dependency graph\n * 5. Hoisting the dependencies to their final locations\n * 6. Resolving and returning module information\n *\n * @param options - Configuration object\n * @param options.packageName - The name of the package to collect modules for\n * @returns Promise resolving to an array of NodeModuleInfo objects representing all collected modules\n */\n public async getNodeModules({ packageName }: { packageName: string }): Promise<NodeModuleInfo[]> {\n const tree: ProdDepType = await this.getDependenciesTree(this.installOptions.manager)\n\n await this.collectAllDependencies(tree, packageName)\n const realTree: ProdDepType = this.getTreeFromWorkspaces(tree, packageName)\n await this.extractProductionDependencyGraph(realTree, packageName)\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 extractProductionDependencyGraph(tree: Dependency<ProdDepType, OptionalDepType>, dependencyId: string): Promise<void>\n protected abstract collectAllDependencies(tree: Dependency<ProdDepType, OptionalDepType>, appPackageName: string): Promise<void>\n\n /**\n * Retrieves the dependency tree from the package manager.\n *\n * Executes the appropriate package manager command to fetch the dependency tree and writes\n * the output to a temporary file. Includes retry logic to handle transient failures such as\n * incomplete JSON output or missing files. Will retry up to 1 time with exponential backoff.\n *\n * @param pm - The package manager to use (npm, yarn, pnpm, etc.)\n * @returns Promise resolving to the parsed dependency tree\n * @throws {Error} If the dependency tree cannot be retrieved after retries\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 const result = await Promise.resolve(this.parseDependenciesTree(shellOutput))\n return result\n },\n {\n retries: 1,\n interval: 2000,\n backoff: 2000,\n shouldRetry: async (error: any) => {\n const fields: Record<string, string> = { error: error.message, tempOutputFile, cwd: this.rootDir, packageManager: pm }\n\n if (!(await exists(tempOutputFile))) {\n log.debug(fields, \"dependency tree output file missing, retrying\")\n return true\n }\n\n const fileContent = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n fields.fileContentLength = fileContent.length.toString()\n\n if (fileContent.trim().length === 0) {\n log.debug(fields, \"dependency tree output file empty, retrying\")\n return true\n }\n\n // extract small start/end sample for debugging purposes (e.g. polluted console output)\n const lines = fileContent.split(\"\\n\")\n const lineSampleSize = Math.min(5, lines.length / 2)\n if (2 * lineSampleSize > 5) {\n fields.sampleStart = lines.slice(0, lineSampleSize).join(\"\\n\")\n fields.sampleEnd = lines.slice(-lineSampleSize).join(\"\\n\")\n } else {\n fields.content = fileContent\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 /**\n * Parses the dependencies tree from shell command output.\n *\n **/\n protected parseDependenciesTree(shellOutput: string): ProdDepType | Promise<ProdDepType> {\n return this.extractJsonFromPollutedOutput<ProdDepType>(shellOutput)\n }\n\n protected extractJsonFromPollutedOutput<T>(shellOutput: string): T {\n const consoleOutput = shellOutput.trim()\n try {\n // Please for the love of all that is holy, this should cover 99% of cases where npm/pnpm/yarn output is clean JSON\n return JSON.parse(consoleOutput)\n } catch {\n // ignore\n }\n\n // DEDICATED FALLBACK FOR POLLUTED OUTPUT, non-trivial to implement correctly, not needed in most cases, and highly inefficient\n\n // Find the first index that starts with { or [\n const bracketOpen = Math.max(consoleOutput.indexOf(\"{\"), 0)\n const bracketOpenSquare = Math.max(consoleOutput.indexOf(\"[\"), 0)\n const start = Math.min(bracketOpen, bracketOpenSquare) // always non-negative due to Math.max above\n\n for (let i = start; i < consoleOutput.length; i++) {\n const slice = consoleOutput.slice(start, i + 1)\n try {\n return JSON.parse(slice)\n } catch {\n // ignore, try next\n }\n }\n throw new Error(\"No JSON content found in output\")\n }\n\n protected cacheKey(pkg: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): string {\n const rel = path.relative(this.rootDir, pkg.path)\n return `${pkg.name}::${pkg.version}::${rel ?? \".\"}`\n }\n\n protected packageVersionString(pkg: Pick<ProdDepType, \"name\" | \"version\">): string {\n return `${pkg.name}@${pkg.version}`\n }\n\n /**\n * Determines if a given dependency is a production dependency of a package.\n *\n * Checks both the dependencies and optionalDependencies of a package to see if\n * the specified dependency name is listed.\n *\n * @param depName - The name of the dependency to check\n * @param pkg - The package to search for the dependency in\n * @returns True if the dependency is found in either dependencies or optionalDependencies, false otherwise\n */\n protected isProdDependency(depName: string, pkg: ProdDepType): boolean {\n const prodDeps = { ...pkg.dependencies, ...pkg.optionalDependencies }\n return prodDeps[depName] != null\n }\n\n protected async locatePackageWithVersion(depTree: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): Promise<{ packageDir: string; packageJson: PackageJson } | null> {\n const result = await this.cache.locatePackageVersion({\n parentDir: depTree.path,\n pkgName: depTree.name,\n requiredRange: depTree.version,\n })\n return result\n }\n /**\n * Parses a dependency identifier string into name and version components.\n *\n * Handles both scoped packages (e.g., \"@scope/pkg@1.2.3\") and regular packages (e.g., \"pkg@1.2.3\").\n * If the identifier is malformed or cannot be parsed, defaults to treating the entire string as\n * the package name with an \"unknown\" version.\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 /**\n * Retrieves the dependency tree and handles workspace package self-references.\n *\n * If the project is a workspace project, this method removes the root package's self-reference\n * from the dependency tree to avoid circular dependencies. It promotes the root package's\n * direct dependencies to the top level of the tree.\n *\n * @param tree - The original dependency tree\n * @param packageName - The name of the package to check for and remove from the tree\n * @returns The extracted dependency subtree\n */\n protected getTreeFromWorkspaces(tree: ProdDepType, packageName: string): ProdDepType {\n if (tree.workspaces && tree.dependencies) {\n for (const [key, value] of Object.entries(tree.dependencies)) {\n if (key === packageName) {\n return value\n }\n }\n }\n\n return 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 /**\n * Executes a command and streams its output to a file.\n *\n * Spawns a child process to execute the specified command with arguments, capturing stdout\n * to a file. Handles Windows-specific quirks by wrapping .cmd files in a temporary .bat file\n * when necessary. Enables corepack strict mode by default but allows process.env overrides.\n *\n * Special handling for `npm list` exit code 1, which is expected in certain scenarios.\n *\n * @param command - The command to execute\n * @param args - Array of command-line arguments\n * @param cwd - The working directory to execute the command in\n * @param tempOutputFile - The path to the temporary file where stdout will be written\n * @returns Promise that resolves when the command completes successfully or rejects if it fails\n * @throws {Error} If the child process spawn fails or exits with a non-zero code\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 env: { COREPACK_ENABLE_STRICT: \"0\", ...process.env }, // allow `process.env` overrides\n shell: true, // `true`` is now required: https://github.com/electron-userland/electron-builder/issues/9488\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,+CAAyD;AACzD,8CAA6C;AAC7C,+BAA8B;AAC9B,uCAA4C;AAC5C,uCAA+B;AAC/B,6BAA4B;AAC5B,mCAAqE;AACrE,mDAAgE;AAChE,qDAA+D;AAG/D,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AC,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;oBAC/E,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,+BAAe,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;gBAC1E,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;AA/XD,oDA+XC","sourcesContent":["import { exists, log, retry, TmpDir } from \"builder-util\"\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 { hoist, type HoisterResult, type HoisterTree } from \"./hoist\"\nimport { LogMessageByKey, ModuleManager } from \"./moduleManager\"\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 protected readonly cache: ModuleManager = new ModuleManager()\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 /**\n * Retrieves and collects all Node.js modules for a given package.\n *\n * This method orchestrates the entire module collection process by:\n * 1. Fetching the dependency tree from the package manager\n * 2. Collecting all dependencies recursively\n * 3. Extracting workspace references if applicable\n * 4. Building a production dependency graph\n * 5. Hoisting the dependencies to their final locations\n * 6. Resolving and returning module information\n */\n public async getNodeModules({ packageName }: { packageName: string }): Promise<{\n nodeModules: NodeModuleInfo[]\n logSummary: ModuleManager[\"logSummary\"]\n }> {\n const tree: ProdDepType = await this.getDependenciesTree(this.installOptions.manager)\n\n await this.collectAllDependencies(tree, packageName)\n const realTree: ProdDepType = this.getTreeFromWorkspaces(tree, packageName)\n await this.extractProductionDependencyGraph(realTree, packageName)\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\n log.debug({ packageName, depCount: this.nodeModules.length }, \"node modules collection complete\")\n\n return { nodeModules: this.nodeModules, logSummary: this.cache.logSummary }\n }\n\n public abstract readonly installOptions: {\n manager: PM\n lockfile: string\n }\n\n protected abstract getArgs(): string[]\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 /**\n * Retrieves the dependency tree from the package manager.\n *\n * Executes the appropriate package manager command to fetch the dependency tree and writes\n * the output to a temporary file. Includes retry logic to handle transient failures such as\n * incomplete JSON output or missing files. Will retry up to 1 time with exponential backoff.\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 const result = await Promise.resolve(this.parseDependenciesTree(shellOutput))\n return result\n },\n {\n retries: 1,\n interval: 2000,\n backoff: 2000,\n shouldRetry: async (error: any) => {\n const fields: Record<string, string> = { error: error.message, tempOutputFile, cwd: this.rootDir, packageManager: pm }\n\n if (!(await exists(tempOutputFile))) {\n log.debug(fields, \"dependency tree output file missing, retrying\")\n return true\n }\n\n const fileContent = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n fields.fileContentLength = fileContent.length.toString()\n\n if (fileContent.trim().length === 0) {\n log.debug(fields, \"dependency tree output file empty, retrying\")\n return true\n }\n\n // extract small start/end sample for debugging purposes (e.g. polluted console output)\n const lines = fileContent.split(\"\\n\")\n const lineSampleSize = Math.min(5, lines.length / 2)\n if (2 * lineSampleSize > 5) {\n fields.sampleStart = lines.slice(0, lineSampleSize).join(\"\\n\")\n fields.sampleEnd = lines.slice(-lineSampleSize).join(\"\\n\")\n } else {\n fields.content = fileContent\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 /**\n * Parses the dependencies tree from shell command output.\n *\n **/\n protected parseDependenciesTree(shellOutput: string): ProdDepType | Promise<ProdDepType> {\n return this.extractJsonFromPollutedOutput<ProdDepType>(shellOutput)\n }\n\n protected extractJsonFromPollutedOutput<T>(shellOutput: string): T {\n const consoleOutput = shellOutput.trim()\n try {\n // Please for the love of all that is holy, this should cover 99% of cases where npm/pnpm/yarn output is clean JSON\n return JSON.parse(consoleOutput)\n } catch {\n // ignore\n }\n\n // DEDICATED FALLBACK FOR POLLUTED OUTPUT, non-trivial to implement correctly, not needed in most cases, and highly inefficient\n\n // Find the first index that starts with { or [\n const bracketOpen = Math.max(consoleOutput.indexOf(\"{\"), 0)\n const bracketOpenSquare = Math.max(consoleOutput.indexOf(\"[\"), 0)\n const start = Math.min(bracketOpen, bracketOpenSquare) // always non-negative due to Math.max above\n\n for (let i = start; i < consoleOutput.length; i++) {\n const slice = consoleOutput.slice(start, i + 1)\n try {\n return JSON.parse(slice)\n } catch {\n // ignore, try next\n }\n }\n throw new Error(\"No JSON content found in output\")\n }\n\n protected cacheKey(pkg: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): string {\n const rel = path.relative(this.rootDir, pkg.path)\n return `${pkg.name}::${pkg.version}::${rel ?? \".\"}`\n }\n\n // We use the key (alias name) instead of value.name for npm aliased packages\n // e.g., { \"foo\": { name: \"@scope/bar\", ... } } should be stored as \"foo@version\"\n protected normalizePackageVersion(key: string, pkg: ProdDepType) {\n return { id: `${key}@${pkg.version}`, pkgOverride: { ...pkg, name: key } }\n }\n\n /**\n * Determines if a given dependency is a production dependency of a package.\n *\n * Checks both the dependencies and optionalDependencies of a package to see if\n * the specified dependency name is listed.\n *\n * @param depName - The name of the dependency to check\n * @param pkg - The package to search for the dependency in\n * @returns True if the dependency is found in either dependencies or optionalDependencies, false otherwise\n */\n protected isProdDependency(depName: string, pkg: ProdDepType): boolean {\n const prodDeps = { ...pkg.dependencies, ...pkg.optionalDependencies }\n return prodDeps[depName] != null\n }\n\n protected async locatePackageWithVersion(depTree: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): Promise<{ packageDir: string; packageJson: PackageJson } | null> {\n const result = await this.cache.locatePackageVersion({\n parentDir: depTree.path,\n pkgName: depTree.name,\n requiredRange: depTree.version,\n })\n return result\n }\n /**\n * Parses a dependency identifier string into name and version components.\n *\n * Handles both scoped packages (e.g., \"@scope/pkg@1.2.3\") and regular packages (e.g., \"pkg@1.2.3\").\n * If the identifier is malformed or cannot be parsed, defaults to treating the entire string as\n * the package name with an \"unknown\" version.\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 /**\n * Retrieves the dependency tree and handles workspace package self-references.\n *\n * If the project is a workspace project, this method removes the root package's self-reference\n * from the dependency tree to avoid circular dependencies. It promotes the root package's\n * direct dependencies to the top level of the tree.\n *\n * @param tree - The original dependency tree\n * @param packageName - The name of the package to check for and remove from the tree\n * @returns The extracted dependency subtree\n */\n protected getTreeFromWorkspaces(tree: ProdDepType, packageName: string): ProdDepType {\n if (tree.workspaces && tree.dependencies) {\n for (const [key, value] of Object.entries(tree.dependencies)) {\n if (key === packageName) {\n return value\n }\n }\n }\n\n return 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 key = `${d.name}@${reference}`\n const p = this.allDependencies.get(key)?.path\n if (p === undefined) {\n this.cache.logSummary[LogMessageByKey.PKG_NOT_FOUND].push(key)\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 this.cache.logSummary[LogMessageByKey.PKG_NOT_ON_DISK].push(key)\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 /**\n * Executes a command and streams its output to a file.\n *\n * Spawns a child process to execute the specified command with arguments, capturing stdout\n * to a file. Handles Windows-specific quirks by wrapping .cmd files in a temporary .bat file\n * when necessary. Enables corepack strict mode by default but allows process.env overrides.\n *\n * Special handling for `npm list` exit code 1, which is expected in certain scenarios.\n *\n * @param command - The command to execute\n * @param args - Array of command-line arguments\n * @param cwd - The working directory to execute the command in\n * @param tempOutputFile - The path to the temporary file where stdout will be written\n * @returns Promise that resolves when the command completes successfully or rejects if it fails\n * @throws {Error} If the child process spawn fails or exits with a non-zero code\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 when using `shell: true`\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 env: { COREPACK_ENABLE_STRICT: \"0\", ...process.env }, // allow `process.env` overrides\n shell: true, // `true`` is now required: https://github.com/electron-userland/electron-builder/issues/9488\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 this.cache.logSummary[LogMessageByKey.PKG_COLLECTOR_OUTPUT].push(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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NpmNodeModulesCollector = void 0;
4
+ const moduleManager_js_1 = require("./moduleManager.js");
4
5
  const nodeModulesCollector_js_1 = require("./nodeModulesCollector.js");
5
6
  const packageManager_js_1 = require("./packageManager.js");
6
7
  class NpmNodeModulesCollector extends nodeModulesCollector_js_1.NodeModulesCollector {
@@ -16,15 +17,21 @@ class NpmNodeModulesCollector extends nodeModulesCollector_js_1.NodeModulesColle
16
17
  }
17
18
  async collectAllDependencies(tree) {
18
19
  for (const [key, value] of Object.entries(tree.dependencies || {})) {
20
+ const { id: childDependencyId, pkgOverride } = this.normalizePackageVersion(key, value);
21
+ // Only skip if this exact version is already collected AND it's a duplicate reference
22
+ // We need to collect nested versions even if a different version exists at top level
19
23
  if (this.isDuplicatedNpmDependency(value)) {
24
+ // This is a reference to a package already defined elsewhere in the tree
25
+ // Still add it to allDependencies if we haven't seen this exact version yet
26
+ if (!this.allDependencies.has(childDependencyId)) {
27
+ this.allDependencies.set(childDependencyId, pkgOverride);
28
+ }
29
+ this.cache.logSummary[moduleManager_js_1.LogMessageByKey.PKG_DUPLICATE_REF].push(childDependencyId);
20
30
  continue;
21
31
  }
22
- // Use the key (alias name) instead of value.name for npm aliased packages
23
- // e.g., { "foo": { name: "@scope/bar", ... } } should be stored as "foo@version"
24
- // This ensures aliased packages are copied to the correct location in node_modules
25
- const normalizedDep = key !== value.name ? { ...value, name: key } : value;
26
- this.allDependencies.set(this.packageVersionString(normalizedDep), normalizedDep);
27
- await this.collectAllDependencies(value);
32
+ // Always store this dependency and recurse into its children
33
+ this.allDependencies.set(childDependencyId, pkgOverride);
34
+ await this.collectAllDependencies(pkgOverride);
28
35
  }
29
36
  }
30
37
  async extractProductionDependencyGraph(tree, dependencyId) {
@@ -49,8 +56,8 @@ class NpmNodeModulesCollector extends nodeModulesCollector_js_1.NodeModulesColle
49
56
  if (Object.keys(dependency).length === 0) {
50
57
  continue;
51
58
  }
52
- const childDependencyId = this.packageVersionString({ name: packageName, version: dependency.version });
53
- await this.extractProductionDependencyGraph(dependency, childDependencyId);
59
+ const { id: childDependencyId, pkgOverride } = this.normalizePackageVersion(packageName, dependency);
60
+ await this.extractProductionDependencyGraph(pkgOverride, childDependencyId);
54
61
  collectedDependencies.push(childDependencyId);
55
62
  }
56
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"npmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/npmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,uEAAgE;AAChE,2DAAwC;AAGxC,MAAa,uBAAwB,SAAQ,8CAA2C;IAAxF;;QACkB,mBAAc,GAAG;YAC/B,OAAO,EAAE,sBAAE,CAAC,GAAG;YACf,QAAQ,EAAE,mBAAmB;SAC9B,CAAA;IAiEH,CAAC;IA/DW,OAAO;QACf,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,CAAC,CAAA;IAC1I,CAAC;IAES,KAAK,CAAC,sBAAsB,CAAC,IAAmB;QACxD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,EAAE,CAAC;YACnE,IAAI,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC1C,SAAQ;YACV,CAAC;YACD,0EAA0E;YAC1E,iFAAiF;YACjF,mFAAmF;YACnF,MAAM,aAAa,GAAkB,GAAG,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;YACzF,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C,OAAO,EAAE,CAAC,CAAA;gBACvG,MAAM,IAAI,CAAC,gCAAgC,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAA;gBAC1E,qBAAqB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;YAC/C,CAAC;QACH,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,EAAE,qBAAqB,EAAE,CAAA;IAC9E,CAAC;IAED,kFAAkF;IAClF,qFAAqF;IAC7E,yBAAyB,CAAC,IAAmB;QACnD,MAAM,EAAE,aAAa,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,IAAI,CAAA;QACtD,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;QACtG,OAAO,cAAc,CAAA;IACvB,CAAC;IAED,6DAA6D;IACnD,gBAAgB,CAAC,WAAmB,EAAE,IAAmB;;QACjE,OAAO,CAAA,MAAA,IAAI,CAAC,aAAa,0CAAG,WAAW,CAAC,KAAI,IAAI,CAAA;IAClD,CAAC;CACF;AArED,0DAqEC","sourcesContent":["import { NodeModulesCollector } from \"./nodeModulesCollector.js\"\nimport { PM } from \"./packageManager.js\"\nimport { NpmDependency } from \"./types.js\"\n\nexport class NpmNodeModulesCollector extends NodeModulesCollector<NpmDependency, string> {\n public readonly installOptions = {\n manager: PM.NPM,\n lockfile: \"package-lock.json\",\n }\n\n protected getArgs(): string[] {\n return [\"list\", \"-a\", \"--include\", \"prod\", \"--include\", \"optional\", \"--omit\", \"dev\", \"--json\", \"--long\", \"--silent\", \"--loglevel=error\"]\n }\n\n protected async collectAllDependencies(tree: NpmDependency) {\n for (const [key, value] of Object.entries(tree.dependencies || {})) {\n if (this.isDuplicatedNpmDependency(value)) {\n continue\n }\n // Use the key (alias name) instead of value.name for npm aliased packages\n // e.g., { \"foo\": { name: \"@scope/bar\", ... } } should be stored as \"foo@version\"\n // This ensures aliased packages are copied to the correct location in node_modules\n const normalizedDep: NpmDependency = key !== value.name ? { ...value, name: key } : value\n this.allDependencies.set(this.packageVersionString(normalizedDep), normalizedDep)\n await this.collectAllDependencies(value)\n }\n }\n\n protected async extractProductionDependencyGraph(tree: NpmDependency, dependencyId: string): Promise<void> {\n if (this.productionGraph[dependencyId]) {\n return\n }\n\n const isDuplicateDep = this.isDuplicatedNpmDependency(tree)\n const targetTree = isDuplicateDep ? this.allDependencies.get(dependencyId) : tree\n\n // Initialize with empty dependencies array first to mark this dependency as \"in progress\"\n // After initialization, if there are libraries with the same name+version later, they will not be searched recursively again\n // This will prevents infinite loops when circular dependencies are encountered.\n this.productionGraph[dependencyId] = { dependencies: [] }\n\n const collectedDependencies: string[] = []\n if (targetTree?.dependencies) {\n for (const packageName in targetTree.dependencies) {\n // Check against matching _dependencies\n if (!this.isProdDependency(packageName, targetTree)) {\n continue\n }\n const dependency = targetTree.dependencies[packageName]\n // Match first version's empty check\n if (Object.keys(dependency).length === 0) {\n continue\n }\n const childDependencyId = this.packageVersionString({ name: packageName, version: dependency.version })\n await this.extractProductionDependencyGraph(dependency, childDependencyId)\n collectedDependencies.push(childDependencyId)\n }\n }\n this.productionGraph[dependencyId] = { dependencies: collectedDependencies }\n }\n\n // Check: is package already included as a prod dependency due to another package?\n // We need to check this to prevent infinite loops in case of duplicated dependencies\n private isDuplicatedNpmDependency(tree: NpmDependency): boolean {\n const { _dependencies = {}, dependencies = {} } = tree\n const isDuplicateDep = Object.keys(_dependencies).length > 0 && Object.keys(dependencies).length === 0\n return isDuplicateDep\n }\n\n // `npm list` provides explicit list of deps in _dependencies\n protected isProdDependency(packageName: string, tree: NpmDependency) {\n return tree._dependencies?.[packageName] != null\n }\n}\n"]}
1
+ {"version":3,"file":"npmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/npmNodeModulesCollector.ts"],"names":[],"mappings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BAAiB,CAAC,CAAA;YAC/C,CAAC;QACH,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,EAAE,qBAAqB,EAAE,CAAA;IAC9E,CAAC;IAED,kFAAkF;IAClF,qFAAqF;IAC7E,yBAAyB,CAAC,IAAmB;QACnD,MAAM,EAAE,aAAa,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,IAAI,CAAA;QACtD,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;QACtG,OAAO,cAAc,CAAA;IACvB,CAAC;IAED,6DAA6D;IACnD,gBAAgB,CAAC,WAAmB,EAAE,IAAmB;;QACjE,OAAO,CAAA,MAAA,IAAI,CAAC,aAAa,0CAAG,WAAW,CAAC,KAAI,IAAI,CAAA;IAClD,CAAC;CACF;AA7ED,0DA6EC","sourcesContent":["import { LogMessageByKey } from \"./moduleManager.js\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector.js\"\nimport { PM } from \"./packageManager.js\"\nimport { NpmDependency } from \"./types.js\"\n\nexport class NpmNodeModulesCollector extends NodeModulesCollector<NpmDependency, string> {\n public readonly installOptions = {\n manager: PM.NPM,\n lockfile: \"package-lock.json\",\n }\n\n protected getArgs(): string[] {\n return [\"list\", \"-a\", \"--include\", \"prod\", \"--include\", \"optional\", \"--omit\", \"dev\", \"--json\", \"--long\", \"--silent\", \"--loglevel=error\"]\n }\n\n protected async collectAllDependencies(tree: NpmDependency) {\n for (const [key, value] of Object.entries(tree.dependencies || {})) {\n const { id: childDependencyId, pkgOverride } = this.normalizePackageVersion(key, value)\n\n // Only skip if this exact version is already collected AND it's a duplicate reference\n // We need to collect nested versions even if a different version exists at top level\n if (this.isDuplicatedNpmDependency(value)) {\n // This is a reference to a package already defined elsewhere in the tree\n // Still add it to allDependencies if we haven't seen this exact version yet\n if (!this.allDependencies.has(childDependencyId)) {\n this.allDependencies.set(childDependencyId, pkgOverride)\n }\n this.cache.logSummary[LogMessageByKey.PKG_DUPLICATE_REF].push(childDependencyId)\n continue\n }\n\n // Always store this dependency and recurse into its children\n this.allDependencies.set(childDependencyId, pkgOverride)\n await this.collectAllDependencies(pkgOverride)\n }\n }\n\n protected async extractProductionDependencyGraph(tree: NpmDependency, dependencyId: string): Promise<void> {\n if (this.productionGraph[dependencyId]) {\n return\n }\n\n const isDuplicateDep = this.isDuplicatedNpmDependency(tree)\n const targetTree = isDuplicateDep ? this.allDependencies.get(dependencyId) : tree\n\n // Initialize with empty dependencies array first to mark this dependency as \"in progress\"\n // After initialization, if there are libraries with the same name+version later, they will not be searched recursively again\n // This will prevents infinite loops when circular dependencies are encountered.\n this.productionGraph[dependencyId] = { dependencies: [] }\n\n const collectedDependencies: string[] = []\n if (targetTree?.dependencies) {\n for (const packageName in targetTree.dependencies) {\n // Check against matching _dependencies\n if (!this.isProdDependency(packageName, targetTree)) {\n continue\n }\n const dependency = targetTree.dependencies[packageName]\n // Match first version's empty check\n if (Object.keys(dependency).length === 0) {\n continue\n }\n const { id: childDependencyId, pkgOverride } = this.normalizePackageVersion(packageName, dependency)\n await this.extractProductionDependencyGraph(pkgOverride, childDependencyId)\n collectedDependencies.push(childDependencyId)\n }\n }\n this.productionGraph[dependencyId] = { dependencies: collectedDependencies }\n }\n\n // Check: is package already included as a prod dependency due to another package?\n // We need to check this to prevent infinite loops in case of duplicated dependencies\n private isDuplicatedNpmDependency(tree: NpmDependency): boolean {\n const { _dependencies = {}, dependencies = {} } = tree\n const isDuplicateDep = Object.keys(_dependencies).length > 0 && Object.keys(dependencies).length === 0\n return isDuplicateDep\n }\n\n // `npm list` provides explicit list of deps in _dependencies\n protected isProdDependency(packageName: string, tree: NpmDependency) {\n return tree._dependencies?.[packageName] != null\n }\n}\n"]}
@@ -9,6 +9,5 @@ export declare class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmD
9
9
  protected getArgs(): string[];
10
10
  protected extractProductionDependencyGraph(tree: PnpmDependency, dependencyId: string): Promise<void>;
11
11
  protected collectAllDependencies(tree: PnpmDependency): Promise<void>;
12
- protected packageVersionString(pkg: PnpmDependency): string;
13
12
  protected parseDependenciesTree(jsonBlob: string): PnpmDependency;
14
13
  }
@@ -39,8 +39,8 @@ class PnpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollect
39
39
  return undefined;
40
40
  }
41
41
  }
42
- const childDependencyId = this.packageVersionString(dependency);
43
- await this.extractProductionDependencyGraph(dependency, childDependencyId);
42
+ const { id: childDependencyId, pkgOverride } = this.normalizePackageVersion(packageName, dependency);
43
+ await this.extractProductionDependencyGraph(pkgOverride, childDependencyId);
44
44
  return childDependencyId;
45
45
  });
46
46
  const collectedDependencies = [];
@@ -67,10 +67,6 @@ class PnpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollect
67
67
  await this.collectAllDependencies(value);
68
68
  }
69
69
  }
70
- packageVersionString(pkg) {
71
- // we use 'from' field because 'name' may be different in case of aliases
72
- return `${pkg.from}@${pkg.version}`;
73
- }
74
70
  parseDependenciesTree(jsonBlob) {
75
71
  // pnpm returns an array of dependency trees
76
72
  const dependencyTree = this.extractJsonFromPollutedOutput(jsonBlob);
@@ -1 +1 @@
1
- {"version":3,"file":"pnpmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,+CAAkC;AAClC,iEAA6D;AAC7D,qDAAqC;AAGrC,MAAa,wBAAyB,SAAQ,2CAAoD;IAAlG;;QACkB,mBAAc,GAAG;YAC/B,OAAO,EAAE,mBAAE,CAAC,IAAI;YAChB,QAAQ,EAAE,gBAAgB;SAC3B,CAAA;IA2EH,CAAC;IAzEW,OAAO;QACf,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,UA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GAAmB;QAChD,yEAAyE;QACzE,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAA;IACrC,CAAC;IAES,qBAAqB,CAAC,QAAgB;QAC9C,4CAA4C;QAC5C,MAAM,cAAc,GAAqB,IAAI,CAAC,6BAA6B,CAAmB,QAAQ,CAAC,CAAA;QACvG,OAAO,cAAc,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;CACF;AA/ED,4DA+EC","sourcesContent":["import { log } from \"builder-util\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { PM } from \"./packageManager\"\nimport { PnpmDependency } from \"./types\"\n\nexport class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmDependency, PnpmDependency> {\n public readonly installOptions = {\n manager: PM.PNPM,\n lockfile: \"pnpm-lock.yaml\",\n }\n\n protected getArgs(): string[] {\n return [\"list\", \"--prod\", \"--json\", \"--depth\", \"Infinity\", \"--silent\", \"--loglevel=error\"]\n }\n\n protected async extractProductionDependencyGraph(tree: PnpmDependency, dependencyId: string) {\n if (this.productionGraph[dependencyId]) {\n return\n }\n this.productionGraph[dependencyId] = { dependencies: [] }\n\n const packageName = tree.name || tree.from\n const { packageJson } = (await this.cache.locatePackageVersion({ pkgName: packageName, parentDir: this.rootDir, requiredRange: tree.version })) || {}\n\n const all = packageJson ? { ...packageJson.dependencies, ...packageJson.optionalDependencies } : { ...tree.dependencies, ...tree.optionalDependencies }\n const optional = packageJson ? { ...packageJson.optionalDependencies } : {}\n\n const deps = { ...(tree.dependencies || {}), ...(tree.optionalDependencies || {}) }\n this.productionGraph[dependencyId] = { dependencies: [] }\n const depPromises = Object.entries(deps).map(async ([packageName, dependency]) => {\n // First check if it's in production dependencies\n if (!all[packageName]) {\n return undefined\n }\n\n // Then check if optional dependency path exists (using actual resolved path)\n if (optional[packageName]) {\n const pkg = await this.cache.locatePackageVersion({ pkgName: packageName, parentDir: this.rootDir, requiredRange: dependency.version })\n if (!pkg) {\n log.debug({ name: packageName, version: dependency.version, path: dependency.path }, `optional dependency doesn't exist, skipping - likely not installed`)\n return undefined\n }\n }\n const childDependencyId = this.packageVersionString(dependency)\n await this.extractProductionDependencyGraph(dependency, childDependencyId)\n return childDependencyId\n })\n\n const collectedDependencies: string[] = []\n for (const dep of depPromises) {\n const result = await dep\n if (result !== undefined) {\n collectedDependencies.push(result)\n }\n }\n this.productionGraph[dependencyId] = { dependencies: collectedDependencies }\n }\n\n protected async collectAllDependencies(tree: PnpmDependency) {\n // Collect regular dependencies\n for (const [key, value] of Object.entries(tree.dependencies || {})) {\n const pkg = await this.cache.locatePackageVersion({ pkgName: key, parentDir: this.rootDir, requiredRange: value.version })\n this.allDependencies.set(`${key}@${value.version}`, { ...value, path: pkg?.packageDir ?? value.path })\n await this.collectAllDependencies(value)\n }\n\n // Collect optional dependencies if they exist\n for (const [key, value] of Object.entries(tree.optionalDependencies || {})) {\n const pkg = await this.cache.locatePackageVersion({ pkgName: key, parentDir: this.rootDir, requiredRange: value.version })\n this.allDependencies.set(`${key}@${value.version}`, { ...value, path: pkg?.packageDir ?? value.path })\n await this.collectAllDependencies(value)\n }\n }\n\n protected packageVersionString(pkg: PnpmDependency): string {\n // we use 'from' field because 'name' may be different in case of aliases\n return `${pkg.from}@${pkg.version}`\n }\n\n protected parseDependenciesTree(jsonBlob: string): PnpmDependency {\n // pnpm returns an array of dependency trees\n const dependencyTree: PnpmDependency[] = this.extractJsonFromPollutedOutput<PnpmDependency[]>(jsonBlob)\n return dependencyTree[0]\n }\n}\n"]}
1
+ {"version":3,"file":"pnpmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,+CAAkC;AAClC,iEAA6D;AAC7D,qDAAqC;AAGrC,MAAa,wBAAyB,SAAQ,2CAAoD;IAAlG;;QACkB,mBAAc,GAAG;YAC/B,OAAO,EAAE,mBAAE,CAAC,IAAI;YAChB,QAAQ,EAAE,gBAAg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,uBAAH,GAAG,CAAE,UAAU,mCAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;YACtG,MAAM,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAA;QAC1C,CAAC;IACH,CAAC;IAES,qBAAqB,CAAC,QAAgB;QAC9C,4CAA4C;QAC5C,MAAM,cAAc,GAAqB,IAAI,CAAC,6BAA6B,CAAmB,QAAQ,CAAC,CAAA;QACvG,OAAO,cAAc,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;CACF;AA1ED,4DA0EC","sourcesContent":["import { log } from \"builder-util\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { PM } from \"./packageManager\"\nimport { PnpmDependency } from \"./types\"\n\nexport class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmDependency, PnpmDependency> {\n public readonly installOptions = {\n manager: PM.PNPM,\n lockfile: \"pnpm-lock.yaml\",\n }\n\n protected getArgs(): string[] {\n return [\"list\", \"--prod\", \"--json\", \"--depth\", \"Infinity\", \"--silent\", \"--loglevel=error\"]\n }\n\n protected async extractProductionDependencyGraph(tree: PnpmDependency, dependencyId: string) {\n if (this.productionGraph[dependencyId]) {\n return\n }\n this.productionGraph[dependencyId] = { dependencies: [] }\n\n const packageName = tree.name || tree.from\n const { packageJson } = (await this.cache.locatePackageVersion({ pkgName: packageName, parentDir: this.rootDir, requiredRange: tree.version })) || {}\n\n const all = packageJson ? { ...packageJson.dependencies, ...packageJson.optionalDependencies } : { ...tree.dependencies, ...tree.optionalDependencies }\n const optional = packageJson ? { ...packageJson.optionalDependencies } : {}\n\n const deps = { ...(tree.dependencies || {}), ...(tree.optionalDependencies || {}) }\n this.productionGraph[dependencyId] = { dependencies: [] }\n const depPromises = Object.entries(deps).map(async ([packageName, dependency]) => {\n // First check if it's in production dependencies\n if (!all[packageName]) {\n return undefined\n }\n\n // Then check if optional dependency path exists (using actual resolved path)\n if (optional[packageName]) {\n const pkg = await this.cache.locatePackageVersion({ pkgName: packageName, parentDir: this.rootDir, requiredRange: dependency.version })\n if (!pkg) {\n log.debug({ name: packageName, version: dependency.version, path: dependency.path }, `optional dependency doesn't exist, skipping - likely not installed`)\n return undefined\n }\n }\n const { id: childDependencyId, pkgOverride } = this.normalizePackageVersion(packageName, dependency)\n await this.extractProductionDependencyGraph(pkgOverride, childDependencyId)\n return childDependencyId\n })\n\n const collectedDependencies: string[] = []\n for (const dep of depPromises) {\n const result = await dep\n if (result !== undefined) {\n collectedDependencies.push(result)\n }\n }\n this.productionGraph[dependencyId] = { dependencies: collectedDependencies }\n }\n\n protected async collectAllDependencies(tree: PnpmDependency) {\n // Collect regular dependencies\n for (const [key, value] of Object.entries(tree.dependencies || {})) {\n const pkg = await this.cache.locatePackageVersion({ pkgName: key, parentDir: this.rootDir, requiredRange: value.version })\n this.allDependencies.set(`${key}@${value.version}`, { ...value, path: pkg?.packageDir ?? value.path })\n await this.collectAllDependencies(value)\n }\n\n // Collect optional dependencies if they exist\n for (const [key, value] of Object.entries(tree.optionalDependencies || {})) {\n const pkg = await this.cache.locatePackageVersion({ pkgName: key, parentDir: this.rootDir, requiredRange: value.version })\n this.allDependencies.set(`${key}@${value.version}`, { ...value, path: pkg?.packageDir ?? value.path })\n await this.collectAllDependencies(value)\n }\n }\n\n protected parseDependenciesTree(jsonBlob: string): PnpmDependency {\n // pnpm returns an array of dependency trees\n const dependencyTree: PnpmDependency[] = this.extractJsonFromPollutedOutput<PnpmDependency[]>(jsonBlob)\n return dependencyTree[0]\n }\n}\n"]}
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TraversalNodeModulesCollector = void 0;
4
4
  const builder_util_1 = require("builder-util");
5
+ const path = require("path");
6
+ const moduleManager_1 = require("./moduleManager");
5
7
  const nodeModulesCollector_1 = require("./nodeModulesCollector");
6
8
  const packageManager_js_1 = require("./packageManager.js");
7
- const path = require("path");
8
9
  // manual traversal of node_modules for package managers without CLI support for dependency tree extraction (e.g., bun) OR as a fallback (e.g. corepack enabled w/ strict mode)
9
10
  class TraversalNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollector {
10
11
  constructor() {
@@ -22,8 +23,9 @@ class TraversalNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCo
22
23
  return this.buildNodeModulesTreeManually(this.rootDir, undefined);
23
24
  }
24
25
  async collectAllDependencies(tree, appPackageName) {
25
- for (const [, value] of Object.entries({ ...tree.dependencies, ...tree.optionalDependencies })) {
26
- this.allDependencies.set(this.packageVersionString(value), value);
26
+ for (const [packageKey, value] of Object.entries({ ...tree.dependencies, ...tree.optionalDependencies })) {
27
+ const normalizedDep = this.normalizePackageVersion(packageKey, value);
28
+ this.allDependencies.set(normalizedDep.id, normalizedDep.pkgOverride);
27
29
  await this.collectAllDependencies(value, appPackageName);
28
30
  }
29
31
  }
@@ -37,8 +39,8 @@ class TraversalNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCo
37
39
  const collectedDependencies = [];
38
40
  for (const packageName in prodDependencies) {
39
41
  const dependency = prodDependencies[packageName];
40
- const childDependencyId = this.packageVersionString(dependency);
41
- await this.extractProductionDependencyGraph(dependency, childDependencyId);
42
+ const { id: childDependencyId, pkgOverride } = this.normalizePackageVersion(packageName, dependency);
43
+ await this.extractProductionDependencyGraph(pkgOverride, childDependencyId);
42
44
  collectedDependencies.push(childDependencyId);
43
45
  }
44
46
  this.productionGraph[dependencyId] = { dependencies: collectedDependencies };
@@ -89,7 +91,7 @@ class TraversalNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCo
89
91
  }
90
92
  // Skip if this dependency resolves to the base directory or any parent we're already processing
91
93
  if (pkg.packageDir === resolvedPackageDir || pkg.packageDir === resolvedBaseDir) {
92
- builder_util_1.log.debug({ ...logFields, resolvedPath: pkg.packageDir }, "skipping self-referential dependency");
94
+ this.cache.logSummary[moduleManager_1.LogMessageByKey.PKG_SELF_REF].push(`${depName}@${depVersion}`);
93
95
  continue;
94
96
  }
95
97
  builder_util_1.log.debug(logFields, "processing production dependency");
@@ -101,8 +103,9 @@ class TraversalNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCo
101
103
  builder_util_1.log.error({ parent: moduleName, dependency: depName, version }, "production dependency not found");
102
104
  throw new Error(`Production dependency ${depName} not found for package ${moduleName}`);
103
105
  });
104
- const optionalDeps = await buildPackage(pkg.optionalDependencies, (depName) => {
106
+ const optionalDeps = await buildPackage(pkg.optionalDependencies, (depName, version) => {
105
107
  builder_util_1.log.debug({ parent: moduleName, dependency: depName }, "optional dependency not installed, skipping");
108
+ this.cache.logSummary[moduleManager_1.LogMessageByKey.PKG_OPTIONAL_NOT_INSTALLED].push(`${depName}@${version}`);
106
109
  });
107
110
  return {
108
111
  name: moduleName,
@@ -1 +1 @@
1
- {"version":3,"file":"traversalNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/traversalNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,+CAAkC;AAClC,iEAA6D;AAC7D,2DAAwC;AAExC,6BAA4B;AAE5B,+KAA+K;AAC/K,MAAa,6BAA8B,SAAQ,2CAA8D;IAAjH;;QACS,mBAAc,GAAG;YACtB,OAAO,EAAE,sBAAE,CAAC,SAAS;YACrB,QAAQ,EAAE,MAAM;SACjB,CAAA;IA2HH,CAAC;IAzHW,OAAO;QACf,OAAO,EAAE,CAAA;IACX,CAAC;IAES,mBAAmB,CAAC,GAAO;QACnC,kBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,iEAAiE,CAAC,CAAA;QACjF,OAAO,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IACnE,CAAC;IAES,KAAK,CAAC,sBAAsB,CAAC,IAAyB,EAAE,cAAsB;QACtF,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC,EAAE,CAAC;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C,CAAC,CAAA;YAEF,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,oBAAoB,EAAE,CAAC,OAAe,EAAE,EAAE;gBACpF,kBAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,6CAA6C,CAAC,CAAA;YACvG,CAAC,CAAC,CAAA;YAEF,OAAO;gBACL,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,IAAI,EAAE,kBAAkB;gBACxB,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;gBACrE,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;aACtF,CAAA;QACH,CAAC,CAAA;QAED,OAAO,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAC7C,CAAC;CACF;AA/HD,sEA+HC","sourcesContent":["import { log } from \"builder-util\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { PM } from \"./packageManager.js\"\nimport { TraversedDependency } from \"./types.js\"\nimport * as path from \"path\"\n\n// manual traversal of node_modules for package managers without CLI support for dependency tree extraction (e.g., bun) OR as a fallback (e.g. corepack enabled w/ strict mode)\nexport class TraversalNodeModulesCollector extends NodeModulesCollector<TraversedDependency, TraversedDependency> {\n public installOptions = {\n manager: PM.TRAVERSAL,\n lockfile: \"none\",\n }\n\n protected getArgs(): string[] {\n return []\n }\n\n protected getDependenciesTree(_pm: PM): Promise<TraversedDependency> {\n log.info(null, \"using manual traversal of node_modules to build dependency tree\")\n return this.buildNodeModulesTreeManually(this.rootDir, undefined)\n }\n\n protected async collectAllDependencies(tree: TraversedDependency, appPackageName: string) {\n for (const [, value] of Object.entries({ ...tree.dependencies, ...tree.optionalDependencies })) {\n this.allDependencies.set(this.packageVersionString(value), value)\n await this.collectAllDependencies(value, appPackageName)\n }\n }\n\n // we don't need to check optional dependencies here because they're pre-processed in `buildNodeModulesTreeManually`\n protected async extractProductionDependencyGraph(tree: TraversedDependency, dependencyId: string): Promise<void> {\n if (this.productionGraph[dependencyId]) {\n return\n }\n this.productionGraph[dependencyId] = { dependencies: [] }\n\n const prodDependencies = { ...(tree.dependencies || {}), ...(tree.optionalDependencies || {}) }\n\n const collectedDependencies: string[] = []\n for (const packageName in prodDependencies) {\n const dependency = prodDependencies[packageName]\n const childDependencyId = this.packageVersionString(dependency)\n await this.extractProductionDependencyGraph(dependency, childDependencyId)\n collectedDependencies.push(childDependencyId)\n }\n this.productionGraph[dependencyId] = { dependencies: collectedDependencies }\n }\n\n /**\n * Builds a dependency tree using only package.json dependencies and optionalDependencies.\n * This skips devDependencies and uses Node.js module resolution (require.resolve).\n */\n private async buildNodeModulesTreeManually(baseDir: string, aliasName: string | undefined): Promise<TraversedDependency> {\n // Track visited packages by their resolved path to prevent infinite loops\n const visited = new Set<string>()\n const resolvedBaseDir = await this.cache.realPath[baseDir]\n\n /**\n * Recursively builds dependency tree starting from a package directory.\n * @param packageDir - The directory of the package to process\n * @param aliasName - Optional alias name for npm aliased dependencies (e.g., \"foo\": \"npm:@scope/bar@1.0.0\")\n * When provided, this name is used instead of the package.json name for the module name,\n * ensuring the package is copied to the correct location in node_modules.\n */\n const buildFromPackage = async (packageDir: string, aliasName: string | undefined): Promise<TraversedDependency> => {\n const pkgPath = path.join(packageDir, \"package.json\")\n\n if (!(await this.cache.exists[pkgPath])) {\n throw new Error(`package.json not found at ${pkgPath}`)\n }\n\n const pkg = (await this.cache.json[pkgPath])!\n const resolvedPackageDir = await this.cache.realPath[packageDir]\n\n // Use the alias name if provided, otherwise fall back to the package.json name\n // This ensures npm aliased packages are copied to the correct location\n const moduleName = aliasName ?? pkg.name\n\n // Use resolved path as the unique identifier to prevent circular dependencies\n if (visited.has(resolvedPackageDir)) {\n log.debug({ name: moduleName, version: pkg.version, path: resolvedPackageDir }, \"skipping already visited package\")\n\n return {\n name: moduleName,\n version: pkg.version,\n path: resolvedPackageDir,\n }\n }\n\n visited.add(resolvedPackageDir)\n\n const buildPackage = async (dependencies: Record<string, string> | undefined, nullHandler: (depName: string, version: string) => void) => {\n const builtPackages: Record<string, TraversedDependency> = {}\n for (const [depName, depVersion] of Object.entries(dependencies || {})) {\n const pkg = await this.locatePackageWithVersion({ name: depName, version: depVersion, path: resolvedPackageDir })\n\n const logFields = { parent: moduleName, dependency: depName, version: depVersion }\n if (pkg == null) {\n nullHandler(depName, depVersion)\n continue\n }\n\n // Skip if this dependency resolves to the base directory or any parent we're already processing\n if (pkg.packageDir === resolvedPackageDir || pkg.packageDir === resolvedBaseDir) {\n log.debug({ ...logFields, resolvedPath: pkg.packageDir }, \"skipping self-referential dependency\")\n continue\n }\n\n log.debug(logFields, \"processing production dependency\")\n builtPackages[depName] = await buildFromPackage(pkg.packageDir, depName)\n }\n return builtPackages\n }\n\n const prodDeps = await buildPackage(pkg.dependencies, (depName: string, version: string) => {\n log.error({ parent: moduleName, dependency: depName, version }, \"production dependency not found\")\n throw new Error(`Production dependency ${depName} not found for package ${moduleName}`)\n })\n\n const optionalDeps = await buildPackage(pkg.optionalDependencies, (depName: string) => {\n log.debug({ parent: moduleName, dependency: depName }, \"optional dependency not installed, skipping\")\n })\n\n return {\n name: moduleName,\n version: pkg.version,\n path: resolvedPackageDir,\n dependencies: Object.keys(prodDeps).length > 0 ? prodDeps : undefined,\n optionalDependencies: Object.keys(optionalDeps).length > 0 ? optionalDeps : undefined,\n }\n }\n\n return buildFromPackage(baseDir, aliasName)\n }\n}\n"]}
1
+ {"version":3,"file":"traversalNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/traversalNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,+CAAkC;AAClC,6BAA4B;AAC5B,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,OAAO;gBACpB,IAAI,EAAE,kBAAkB;gBACxB,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;gBACrE,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;aACtF,CAAA;QACH,CAAC,CAAA;QAED,OAAO,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAC7C,CAAC;CACF;AAjID,sEAiIC","sourcesContent":["import { log } from \"builder-util\"\nimport * as path from \"path\"\nimport { LogMessageByKey } from \"./moduleManager\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { PM } from \"./packageManager.js\"\nimport { TraversedDependency } from \"./types.js\"\n\n// manual traversal of node_modules for package managers without CLI support for dependency tree extraction (e.g., bun) OR as a fallback (e.g. corepack enabled w/ strict mode)\nexport class TraversalNodeModulesCollector extends NodeModulesCollector<TraversedDependency, TraversedDependency> {\n public installOptions = {\n manager: PM.TRAVERSAL,\n lockfile: \"none\",\n }\n\n protected getArgs(): string[] {\n return []\n }\n\n protected getDependenciesTree(_pm: PM): Promise<TraversedDependency> {\n log.info(null, \"using manual traversal of node_modules to build dependency tree\")\n return this.buildNodeModulesTreeManually(this.rootDir, undefined)\n }\n\n protected async collectAllDependencies(tree: TraversedDependency, appPackageName: string) {\n for (const [packageKey, value] of Object.entries({ ...tree.dependencies, ...tree.optionalDependencies })) {\n const normalizedDep = this.normalizePackageVersion(packageKey, value)\n this.allDependencies.set(normalizedDep.id, normalizedDep.pkgOverride)\n await this.collectAllDependencies(value, appPackageName)\n }\n }\n\n // we don't need to check optional dependencies here because they're pre-processed in `buildNodeModulesTreeManually`\n protected async extractProductionDependencyGraph(tree: TraversedDependency, dependencyId: string): Promise<void> {\n if (this.productionGraph[dependencyId]) {\n return\n }\n this.productionGraph[dependencyId] = { dependencies: [] }\n\n const prodDependencies = { ...(tree.dependencies || {}), ...(tree.optionalDependencies || {}) }\n\n const collectedDependencies: string[] = []\n for (const packageName in prodDependencies) {\n const dependency = prodDependencies[packageName]\n const { id: childDependencyId, pkgOverride } = this.normalizePackageVersion(packageName, dependency)\n await this.extractProductionDependencyGraph(pkgOverride, childDependencyId)\n collectedDependencies.push(childDependencyId)\n }\n this.productionGraph[dependencyId] = { dependencies: collectedDependencies }\n }\n\n /**\n * Builds a dependency tree using only package.json dependencies and optionalDependencies.\n * This skips devDependencies and uses Node.js module resolution (require.resolve).\n */\n private async buildNodeModulesTreeManually(baseDir: string, aliasName: string | undefined): Promise<TraversedDependency> {\n // Track visited packages by their resolved path to prevent infinite loops\n const visited = new Set<string>()\n const resolvedBaseDir = await this.cache.realPath[baseDir]\n\n /**\n * Recursively builds dependency tree starting from a package directory.\n * @param packageDir - The directory of the package to process\n * @param aliasName - Optional alias name for npm aliased dependencies (e.g., \"foo\": \"npm:@scope/bar@1.0.0\")\n * When provided, this name is used instead of the package.json name for the module name,\n * ensuring the package is copied to the correct location in node_modules.\n */\n const buildFromPackage = async (packageDir: string, aliasName: string | undefined): Promise<TraversedDependency> => {\n const pkgPath = path.join(packageDir, \"package.json\")\n\n if (!(await this.cache.exists[pkgPath])) {\n throw new Error(`package.json not found at ${pkgPath}`)\n }\n\n const pkg = (await this.cache.json[pkgPath])!\n const resolvedPackageDir = await this.cache.realPath[packageDir]\n\n // Use the alias name if provided, otherwise fall back to the package.json name\n // This ensures npm aliased packages are copied to the correct location\n const moduleName = aliasName ?? pkg.name\n\n // Use resolved path as the unique identifier to prevent circular dependencies\n if (visited.has(resolvedPackageDir)) {\n log.debug({ name: moduleName, version: pkg.version, path: resolvedPackageDir }, \"skipping already visited package\")\n\n return {\n name: moduleName,\n version: pkg.version,\n path: resolvedPackageDir,\n }\n }\n\n visited.add(resolvedPackageDir)\n\n const buildPackage = async (dependencies: Record<string, string> | undefined, nullHandler: (depName: string, version: string) => void) => {\n const builtPackages: Record<string, TraversedDependency> = {}\n for (const [depName, depVersion] of Object.entries(dependencies || {})) {\n const pkg = await this.locatePackageWithVersion({ name: depName, version: depVersion, path: resolvedPackageDir })\n\n const logFields = { parent: moduleName, dependency: depName, version: depVersion }\n if (pkg == null) {\n nullHandler(depName, depVersion)\n continue\n }\n\n // Skip if this dependency resolves to the base directory or any parent we're already processing\n if (pkg.packageDir === resolvedPackageDir || pkg.packageDir === resolvedBaseDir) {\n this.cache.logSummary[LogMessageByKey.PKG_SELF_REF].push(`${depName}@${depVersion}`)\n continue\n }\n\n log.debug(logFields, \"processing production dependency\")\n builtPackages[depName] = await buildFromPackage(pkg.packageDir, depName)\n }\n return builtPackages\n }\n\n const prodDeps = await buildPackage(pkg.dependencies, (depName: string, version: string) => {\n log.error({ parent: moduleName, dependency: depName, version }, \"production dependency not found\")\n throw new Error(`Production dependency ${depName} not found for package ${moduleName}`)\n })\n\n const optionalDeps = await buildPackage(pkg.optionalDependencies, (depName: string, version: string) => {\n log.debug({ parent: moduleName, dependency: depName }, \"optional dependency not installed, skipping\")\n this.cache.logSummary[LogMessageByKey.PKG_OPTIONAL_NOT_INSTALLED].push(`${depName}@${version}`)\n })\n\n return {\n name: moduleName,\n version: pkg.version,\n path: resolvedPackageDir,\n dependencies: Object.keys(prodDeps).length > 0 ? prodDeps : undefined,\n optionalDependencies: Object.keys(optionalDeps).length > 0 ? optionalDeps : undefined,\n }\n }\n\n return buildFromPackage(baseDir, aliasName)\n }\n}\n"]}
@@ -33,10 +33,6 @@ export interface NpmDependency extends Dependency<NpmDependency, string> {
33
33
  [packageName: string]: string;
34
34
  };
35
35
  }
36
- export interface YarnBerryDependency extends Dependency<YarnBerryDependency, string> {
37
- }
38
- export interface YarnDependency extends Dependency<YarnDependency, YarnDependency> {
39
- }
40
36
  export interface TraversedDependency extends Dependency<TraversedDependency, TraversedDependency> {
41
37
  }
42
38
  export type Dependency<T, V> = Dependencies<T, V> & ParsedDependencyTree;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/node-module-collector/types.ts"],"names":[],"mappings":"","sourcesContent":["export type PackageJson = {\n name: string\n version: string\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n peerDependencies?: Record<string, string>\n optionalDependencies?: Record<string, string>\n workspaces?: string[] | { packages: string[] }\n}\n\nexport interface NodeModuleInfo {\n name: string\n version: string\n dir: string\n dependencies?: Array<NodeModuleInfo>\n}\n\nexport type ParsedDependencyTree = {\n readonly name: string\n readonly version: string\n readonly path: string\n readonly workspaces?: string[] | { packages: string[] } // we only use this at root level\n}\n\n// Note: `PnpmDependency` and `NpmDependency` include the output of `JSON.parse(...)` of `pnpm list` and `npm list` respectively\n// This object has a TON of info - a majority, if not all, of each dependency's package.json\n// We extract only what we need when constructing DependencyTree in `extractProductionDependencyTree`\nexport interface PnpmDependency extends Dependency<PnpmDependency, PnpmDependency> {\n readonly from: string\n readonly resolved: string\n}\n\nexport interface NpmDependency extends Dependency<NpmDependency, string> {\n readonly resolved?: string\n // implicit dependencies, returned only through `npm list`\n readonly _dependencies?: {\n [packageName: string]: string\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface YarnBerryDependency extends Dependency<YarnBerryDependency, string> {}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface YarnDependency extends Dependency<YarnDependency, YarnDependency> {}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface TraversedDependency extends Dependency<TraversedDependency, TraversedDependency> {}\n\nexport type Dependency<T, V> = Dependencies<T, V> & ParsedDependencyTree\n\nexport type Dependencies<T, V> = {\n readonly dependencies?: {\n [packageName: string]: T\n }\n readonly optionalDependencies?: {\n [packageName: string]: V\n }\n}\n\nexport interface DependencyGraph {\n [packageNameAndVersion: string]: {\n readonly dependencies: string[]\n }\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/node-module-collector/types.ts"],"names":[],"mappings":"","sourcesContent":["export type PackageJson = {\n name: string\n version: string\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n peerDependencies?: Record<string, string>\n optionalDependencies?: Record<string, string>\n workspaces?: string[] | { packages: string[] }\n}\n\nexport interface NodeModuleInfo {\n name: string\n version: string\n dir: string\n dependencies?: Array<NodeModuleInfo>\n}\n\nexport type ParsedDependencyTree = {\n readonly name: string\n readonly version: string\n readonly path: string\n readonly workspaces?: string[] | { packages: string[] } // we only use this at root level\n}\n\n// Note: `PnpmDependency` and `NpmDependency` include the output of `JSON.parse(...)` of `pnpm list` and `npm list` respectively\n// This object has a TON of info - a majority, if not all, of each dependency's package.json\n// We extract only what we need when constructing DependencyTree in `extractProductionDependencyTree`\nexport interface PnpmDependency extends Dependency<PnpmDependency, PnpmDependency> {\n readonly from: string\n readonly resolved: string\n}\n\nexport interface NpmDependency extends Dependency<NpmDependency, string> {\n readonly resolved?: string\n // implicit dependencies, returned only through `npm list`\n readonly _dependencies?: {\n [packageName: string]: string\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface TraversedDependency extends Dependency<TraversedDependency, TraversedDependency> {}\n\nexport type Dependency<T, V> = Dependencies<T, V> & ParsedDependencyTree\n\nexport type Dependencies<T, V> = {\n readonly dependencies?: {\n [packageName: string]: T\n }\n readonly optionalDependencies?: {\n [packageName: string]: V\n }\n}\n\nexport interface DependencyGraph {\n [packageNameAndVersion: string]: {\n readonly dependencies: string[]\n }\n}\n"]}
@@ -1,16 +1,10 @@
1
- import { Lazy } from "lazy-val";
2
- import { NodeModulesCollector } from "./nodeModulesCollector";
1
+ import { NpmNodeModulesCollector } from "./npmNodeModulesCollector";
3
2
  import { PM } from "./packageManager";
4
- import { YarnDependency } from "./types";
5
- export declare class YarnNodeModulesCollector extends NodeModulesCollector<YarnDependency, YarnDependency> {
3
+ import { NpmDependency } from "./types";
4
+ export declare class YarnNodeModulesCollector extends NpmNodeModulesCollector {
6
5
  readonly installOptions: {
7
6
  manager: PM;
8
7
  lockfile: string;
9
8
  };
10
- protected isHoisted: Lazy<boolean>;
11
- protected getArgs(): string[];
12
- protected extractProductionDependencyGraph(tree: YarnDependency, dependencyId: string): Promise<void>;
13
- protected parseDependenciesTree(jsonBlob: string): Promise<YarnDependency>;
14
- private normalizeTree;
15
- protected collectAllDependencies(tree: YarnDependency, packageToExclude: string): Promise<void>;
9
+ protected getDependenciesTree(_pm: PM): Promise<NpmDependency>;
16
10
  }