app-builder-lib 26.6.0 → 26.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/codeSign/windowsSignToolManager.d.ts +4 -5
- package/out/codeSign/windowsSignToolManager.js +76 -86
- package/out/codeSign/windowsSignToolManager.js.map +1 -1
- package/out/configuration.d.ts +34 -0
- package/out/configuration.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js.map +1 -1
- package/out/linuxPackager.js +1 -1
- package/out/linuxPackager.js.map +1 -1
- package/out/macPackager.js +0 -1
- package/out/macPackager.js.map +1 -1
- package/out/node-module-collector/index.d.ts +1 -2
- package/out/node-module-collector/nodeModulesCollector.d.ts +2 -18
- package/out/node-module-collector/nodeModulesCollector.js +38 -73
- package/out/node-module-collector/nodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/npmNodeModulesCollector.js +11 -7
- package/out/node-module-collector/npmNodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/pnpmNodeModulesCollector.js +1 -1
- package/out/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/types.d.ts +0 -4
- package/out/node-module-collector/types.js.map +1 -1
- package/out/node-module-collector/yarnNodeModulesCollector.d.ts +4 -10
- package/out/node-module-collector/yarnNodeModulesCollector.js +7 -197
- package/out/node-module-collector/yarnNodeModulesCollector.js.map +1 -1
- package/out/options/AppXOptions.d.ts +8 -0
- package/out/options/AppXOptions.js.map +1 -1
- package/out/options/macOptions.d.ts +12 -0
- package/out/options/macOptions.js.map +1 -1
- package/out/targets/AppxCapabilities.d.ts +8 -0
- package/out/targets/AppxCapabilities.js +258 -0
- package/out/targets/AppxCapabilities.js.map +1 -0
- package/out/targets/AppxTarget.d.ts +1 -0
- package/out/targets/AppxTarget.js +32 -14
- package/out/targets/AppxTarget.js.map +1 -1
- package/out/targets/FpmTarget.js +3 -3
- package/out/targets/FpmTarget.js.map +1 -1
- package/out/targets/MsiWrappedTarget.js +4 -3
- package/out/targets/MsiWrappedTarget.js.map +1 -1
- package/out/targets/appimage/AppImageTarget.d.ts +16 -0
- package/out/targets/{AppImageTarget.js → appimage/AppImageTarget.js} +65 -28
- package/out/targets/appimage/AppImageTarget.js.map +1 -0
- package/out/targets/appimage/appImageUtil.d.ts +23 -0
- package/out/targets/appimage/appImageUtil.js +266 -0
- package/out/targets/appimage/appImageUtil.js.map +1 -0
- package/out/targets/appimage/appLauncher.d.ts +3 -0
- package/out/targets/appimage/appLauncher.js +91 -0
- package/out/targets/appimage/appLauncher.js.map +1 -0
- package/out/targets/archive.js +2 -2
- package/out/targets/archive.js.map +1 -1
- package/out/toolsets/linux.d.ts +9 -0
- package/out/toolsets/linux.js +68 -0
- package/out/toolsets/linux.js.map +1 -0
- package/out/toolsets/windows.d.ts +42 -0
- package/out/toolsets/windows.js +143 -0
- package/out/toolsets/windows.js.map +1 -0
- package/out/util/packageMetadata.js +9 -5
- package/out/util/packageMetadata.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/out/winPackager.js +4 -3
- package/out/winPackager.js.map +1 -1
- package/package.json +9 -9
- package/scheme.json +78 -1
- package/templates/appx/appxmanifest.xml +1 -3
- package/templates/linux/after-install.tpl +1 -1
- package/out/targets/AppImageTarget.d.ts +0 -14
- package/out/targets/AppImageTarget.js.map +0 -1
- package/out/targets/tools.d.ts +0 -2
- package/out/targets/tools.js +0 -46
- 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,8CAA6C;AAC7C,+BAA8B;AAC9B,uCAA4C;AAC5C,uCAA+B;AAC/B,6BAA4B;AAC5B,mCAAqE;AACrE,mDAA+C;AAC/C,qDAA+D;AAG/D,MAAsB,oBAAoB;IAsBxC,YACqB,OAAe,EACjB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F;AAraD,oDAqaC","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 = await 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 logFields = { error: error.message, tempOutputFile, cwd: this.rootDir }\n\n if (!(await 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 /**\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 *\n * This method attempts to extract and parse JSON data from shell output that may contain\n * additional non-JSON content (like warnings or informational messages). It first tries\n * to parse the entire output as JSON, and if that fails, it intelligently searches for\n * JSON content within the output by:\n * 1. Finding the first line that starts with `{` or `[`\n * 2. Tracking bracket depth to find the matching closing bracket\n * 3. Extracting only the valid JSON portion\n *\n * @param shellOutput - The raw output from a shell command, potentially containing JSON\n * @returns The parsed dependencies tree object\n * @throws {Error} If no JSON content is found in the output\n * @throws {Error} If no matching closing bracket is found in the output\n * @throws {SyntaxError} If the extracted content is not valid JSON\n */\n protected extractJsonFromPollutedOutput<T>(shellOutput: string): T {\n const consoleOutput = shellOutput.trim()\n try {\n return JSON.parse(consoleOutput)\n } catch {\n // Continue\n }\n\n const lines = consoleOutput.split(\"\\n\")\n\n // Find the first line that starts with { or [\n const jsonStartIdx = lines.findIndex(line => {\n const trimmed = line.trim()\n return trimmed.startsWith(\"{\") || trimmed.startsWith(\"[\")\n })\n\n if (jsonStartIdx === -1) {\n throw new Error(\"No JSON content found in output\")\n }\n\n // Find matching closing bracket using bracket counting\n let depth = 0\n let jsonEndIdx = -1\n\n for (let i = jsonStartIdx; i < lines.length; i++) {\n const line = lines[i]\n for (const char of line) {\n if (char === \"{\" || char === \"[\") {\n depth++\n } else if (char === \"}\" || char === \"]\") {\n depth--\n if (depth === 0) {\n jsonEndIdx = i\n break\n }\n }\n }\n if (jsonEndIdx !== -1) {\n break\n }\n }\n\n if (jsonEndIdx === -1) {\n throw new Error(\"No matching closing bracket found in output\")\n }\n\n // Parse the matched JSON section\n const candidate = lines\n .slice(jsonStartIdx, jsonEndIdx + 1)\n .join(\"\\n\")\n .trim()\n\n return JSON.parse(candidate)\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 Promise resolving to the pruned dependency tree\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 /**\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,mDAA+C;AAC/C,qDAA+D;AAG/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,GA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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 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 }\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"]}
|
|
@@ -12,7 +12,7 @@ class NpmNodeModulesCollector extends nodeModulesCollector_js_1.NodeModulesColle
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
getArgs() {
|
|
15
|
-
return ["list", "-a", "--include", "prod", "--include", "optional", "--omit", "dev", "--json", "--long", "--silent"];
|
|
15
|
+
return ["list", "-a", "--include", "prod", "--include", "optional", "--omit", "dev", "--json", "--long", "--silent", "--loglevel=error"];
|
|
16
16
|
}
|
|
17
17
|
async collectAllDependencies(tree) {
|
|
18
18
|
for (const [key, value] of Object.entries(tree.dependencies || {})) {
|
|
@@ -28,23 +28,27 @@ class NpmNodeModulesCollector extends nodeModulesCollector_js_1.NodeModulesColle
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
async extractProductionDependencyGraph(tree, dependencyId) {
|
|
31
|
-
var _a;
|
|
32
31
|
if (this.productionGraph[dependencyId]) {
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
35
34
|
const isDuplicateDep = this.isDuplicatedNpmDependency(tree);
|
|
36
|
-
const
|
|
35
|
+
const targetTree = isDuplicateDep ? this.allDependencies.get(dependencyId) : tree;
|
|
37
36
|
// Initialize with empty dependencies array first to mark this dependency as "in progress"
|
|
38
37
|
// After initialization, if there are libraries with the same name+version later, they will not be searched recursively again
|
|
39
38
|
// This will prevents infinite loops when circular dependencies are encountered.
|
|
40
39
|
this.productionGraph[dependencyId] = { dependencies: [] };
|
|
41
40
|
const collectedDependencies = [];
|
|
42
|
-
if (
|
|
43
|
-
for (const packageName in
|
|
44
|
-
|
|
41
|
+
if (targetTree === null || targetTree === void 0 ? void 0 : targetTree.dependencies) {
|
|
42
|
+
for (const packageName in targetTree.dependencies) {
|
|
43
|
+
// Check against matching _dependencies
|
|
44
|
+
if (!this.isProdDependency(packageName, targetTree)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const dependency = targetTree.dependencies[packageName];
|
|
48
|
+
// Match first version's empty check
|
|
49
|
+
if (Object.keys(dependency).length === 0) {
|
|
45
50
|
continue;
|
|
46
51
|
}
|
|
47
|
-
const dependency = resolvedDeps[packageName];
|
|
48
52
|
const childDependencyId = this.packageVersionString({ name: packageName, version: dependency.version });
|
|
49
53
|
await this.extractProductionDependencyGraph(dependency, childDependencyId);
|
|
50
54
|
collectedDependencies.push(childDependencyId);
|
|
@@ -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;S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C;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"]}
|
|
@@ -13,7 +13,7 @@ class PnpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollect
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
getArgs() {
|
|
16
|
-
return ["list", "--prod", "--json", "--depth", "Infinity"];
|
|
16
|
+
return ["list", "--prod", "--json", "--depth", "Infinity", "--silent", "--loglevel=error"];
|
|
17
17
|
}
|
|
18
18
|
async extractProductionDependencyGraph(tree, dependencyId) {
|
|
19
19
|
if (this.productionGraph[dependencyId]) {
|
|
@@ -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,CAAC,CAAA;
|
|
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,UAAU,EAAE,kBAAkB,CAAC,CAAA;IAC5F,CAAC;IAES,KAAK,CAAC,gCAAgC,CAAC,IAAoB,EAAE,YAAoB;QACzF,IAAI,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;YACvC,OAAM;QACR,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,EAAE,EAAE,EAAE,CAAA;QAEzD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAA;QAC1C,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,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GAAG,uBAAH,GAAG,CAAE,UAAU,mCAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;YACtG,MAAM,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAA;QAC1C,CAAC;QAED,8CAA8C;QAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,IAAI,EAAE,CAAC,EAAE,CAAC;YAC3E,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC1H,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,MAAA,GAAG,aAAH,GAAG,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,oBAAoB,CAAC,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"]}
|
|
@@ -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
|
|
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 {
|
|
2
|
-
import { NodeModulesCollector } from "./nodeModulesCollector";
|
|
1
|
+
import { NpmNodeModulesCollector } from "./npmNodeModulesCollector";
|
|
3
2
|
import { PM } from "./packageManager";
|
|
4
|
-
import {
|
|
5
|
-
export declare class YarnNodeModulesCollector extends
|
|
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
|
|
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
|
}
|
|
@@ -1,211 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.YarnNodeModulesCollector = void 0;
|
|
4
|
-
const
|
|
5
|
-
const lazy_val_1 = require("lazy-val");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
const nodeModulesCollector_1 = require("./nodeModulesCollector");
|
|
4
|
+
const npmNodeModulesCollector_1 = require("./npmNodeModulesCollector");
|
|
8
5
|
const packageManager_1 = require("./packageManager");
|
|
9
|
-
|
|
6
|
+
// Yarn Classic (v1) produces a hoisted node_modules structure similar to npm.
|
|
7
|
+
// Instead of parsing Yarn's custom NDJSON output, we leverage npm's list command
|
|
8
|
+
// which NpmNodeModulesCollector already handles.
|
|
9
|
+
class YarnNodeModulesCollector extends npmNodeModulesCollector_1.NpmNodeModulesCollector {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
12
12
|
this.installOptions = {
|
|
13
13
|
manager: packageManager_1.PM.YARN,
|
|
14
14
|
lockfile: "yarn.lock",
|
|
15
15
|
};
|
|
16
|
-
this.isHoisted = new lazy_val_1.Lazy(async () => {
|
|
17
|
-
return Promise.resolve(true); // Yarn Classic always hoists
|
|
18
|
-
});
|
|
19
16
|
}
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
async extractProductionDependencyGraph(tree, dependencyId) {
|
|
24
|
-
if (this.productionGraph[dependencyId]) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const productionDeps = Object.entries(tree.dependencies || {}).map(async ([, dependency]) => {
|
|
28
|
-
const dep = {
|
|
29
|
-
...dependency,
|
|
30
|
-
path: await this.cache.realPath[dependency.path],
|
|
31
|
-
};
|
|
32
|
-
const childDependencyId = this.packageVersionString(dep);
|
|
33
|
-
await this.extractProductionDependencyGraph(dep, childDependencyId);
|
|
34
|
-
return childDependencyId;
|
|
35
|
-
});
|
|
36
|
-
const dependencies = [];
|
|
37
|
-
for (const dep of productionDeps) {
|
|
38
|
-
dependencies.push(await dep);
|
|
39
|
-
}
|
|
40
|
-
this.productionGraph[dependencyId] = { dependencies };
|
|
41
|
-
}
|
|
42
|
-
async parseDependenciesTree(jsonBlob) {
|
|
43
|
-
const lines = jsonBlob
|
|
44
|
-
.split("\n")
|
|
45
|
-
.map(l => l.trim())
|
|
46
|
-
.filter(Boolean)
|
|
47
|
-
.map(l => {
|
|
48
|
-
try {
|
|
49
|
-
return JSON.parse(l);
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
.filter(Boolean);
|
|
56
|
-
const parsedTree = lines
|
|
57
|
-
.filter(l => l.type === "tree")
|
|
58
|
-
.map(l => l.data.trees)
|
|
59
|
-
.shift();
|
|
60
|
-
if (!parsedTree) {
|
|
61
|
-
throw new Error('Failed to extract Yarn tree: no "type":"tree" line found in console output');
|
|
62
|
-
}
|
|
63
|
-
const rootPkgJson = (await this.cache.json[path.join(this.rootDir, "package.json")]);
|
|
64
|
-
const normalizedTree = await this.normalizeTree({ tree: parsedTree, seen: new Set(), appName: rootPkgJson.name, parentPath: this.rootDir });
|
|
65
|
-
const dependencies = {};
|
|
66
|
-
for (const [name, dep] of Object.entries(normalizedTree)) {
|
|
67
|
-
dependencies[name] = dep;
|
|
68
|
-
}
|
|
69
|
-
return Promise.resolve({
|
|
70
|
-
name: rootPkgJson.name,
|
|
71
|
-
version: rootPkgJson.version,
|
|
72
|
-
path: this.rootDir,
|
|
73
|
-
dependencies,
|
|
74
|
-
workspaces: rootPkgJson === null || rootPkgJson === void 0 ? void 0 : rootPkgJson.workspaces,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
async normalizeTree(options) {
|
|
78
|
-
const { tree, seen, appName, parentPath = this.rootDir } = options;
|
|
79
|
-
const normalized = {};
|
|
80
|
-
for (const node of tree) {
|
|
81
|
-
const match = node.name.match(/^(.*)@([^@]+)$/);
|
|
82
|
-
if (!match) {
|
|
83
|
-
builder_util_1.log.debug({ name: node.name }, "invalid node name format");
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
const [, pkgName, version] = match;
|
|
87
|
-
const id = `${pkgName}@${version}`;
|
|
88
|
-
const isShadow = node.shadow && node.color === "dim";
|
|
89
|
-
if (isShadow) {
|
|
90
|
-
builder_util_1.log.debug({ pkgName, version }, "registering shadow node (hoisted elsewhere), will resolve");
|
|
91
|
-
}
|
|
92
|
-
if (seen.has(id)) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
// Find the correct package path that matches the required version
|
|
96
|
-
const pkg = await this.locatePackageWithVersion({ name: pkgName, version, path: parentPath });
|
|
97
|
-
const pkgPath = pkg === null || pkg === void 0 ? void 0 : pkg.packageDir;
|
|
98
|
-
if (!pkgPath) {
|
|
99
|
-
builder_util_1.log.warn({ pkgName, version, parentPath }, "could not find package matching version");
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
seen.add(id);
|
|
103
|
-
const normalizedDep = {
|
|
104
|
-
name: pkgName,
|
|
105
|
-
version,
|
|
106
|
-
path: pkgPath,
|
|
107
|
-
dependencies: {},
|
|
108
|
-
optionalDependencies: {},
|
|
109
|
-
};
|
|
110
|
-
// Recursively process children, passing this package's info
|
|
111
|
-
if (node.children && node.children.length > 0) {
|
|
112
|
-
const childDeps = await this.normalizeTree({
|
|
113
|
-
tree: node.children,
|
|
114
|
-
seen,
|
|
115
|
-
appName,
|
|
116
|
-
parentPath: pkgPath,
|
|
117
|
-
});
|
|
118
|
-
for (const [childDepName, childDep] of Object.entries(childDeps)) {
|
|
119
|
-
normalizedDep.dependencies[childDepName] = childDep;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
normalized[pkgName] = normalizedDep;
|
|
123
|
-
}
|
|
124
|
-
return normalized;
|
|
125
|
-
}
|
|
126
|
-
async collectAllDependencies(tree, packageToExclude) {
|
|
127
|
-
const rootPkgJson = (await this.cache.json[path.join(this.rootDir, "package.json")]);
|
|
128
|
-
const failedPackages = new Set();
|
|
129
|
-
const collect = async (deps = {}, isOptionalDependency, parentIsOptional = false) => {
|
|
130
|
-
var _a, _b, _c, _d;
|
|
131
|
-
for (const [, value] of Object.entries(deps)) {
|
|
132
|
-
const isRootOptional = !!((_a = rootPkgJson.optionalDependencies) === null || _a === void 0 ? void 0 : _a[value.name]);
|
|
133
|
-
const isDirectRootDep = ((_b = rootPkgJson.dependencies) === null || _b === void 0 ? void 0 : _b[value.name]) || ((_c = rootPkgJson.optionalDependencies) === null || _c === void 0 ? void 0 : _c[value.name]) || ((_d = rootPkgJson.devDependencies) === null || _d === void 0 ? void 0 : _d[value.name]);
|
|
134
|
-
const treatAsOptional = isOptionalDependency || parentIsOptional || isRootOptional;
|
|
135
|
-
const logFields = { name: value.name, version: value.version, path: value.path };
|
|
136
|
-
const p = await this.cache.realPath[value.path];
|
|
137
|
-
if (!(await this.cache.exists[p])) {
|
|
138
|
-
if (treatAsOptional) {
|
|
139
|
-
builder_util_1.log.debug(logFields, "failed to find optional dependency, skipping");
|
|
140
|
-
failedPackages.add(value.name);
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
if (!isDirectRootDep) {
|
|
144
|
-
builder_util_1.log.debug(logFields, "failed to find transitive dependency, treating as optional");
|
|
145
|
-
failedPackages.add(value.name);
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
const message = "unable to find module directory; is the path correct?";
|
|
149
|
-
builder_util_1.log.error(logFields, message);
|
|
150
|
-
throw new Error(`Failed to resolve module directory for ${value.name}@${value.version} at path: ${value.path}`);
|
|
151
|
-
}
|
|
152
|
-
let resolvedVersion = value.version;
|
|
153
|
-
const versionMatch = p.match(/[/\\]node_modules[/\\][^@]+@([^/\\]+)[/\\]/);
|
|
154
|
-
if (versionMatch) {
|
|
155
|
-
resolvedVersion = versionMatch[1];
|
|
156
|
-
if (resolvedVersion !== value.version) {
|
|
157
|
-
builder_util_1.log.debug({ name: value.name, declared: value.version, resolved: resolvedVersion }, "resolved actual version from path");
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
const m = {
|
|
161
|
-
...value,
|
|
162
|
-
version: resolvedVersion,
|
|
163
|
-
path: p,
|
|
164
|
-
};
|
|
165
|
-
const moduleKey = this.packageVersionString(m);
|
|
166
|
-
if (this.allDependencies.has(moduleKey)) {
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
this.allDependencies.set(moduleKey, m);
|
|
170
|
-
const childIsOptional = treatAsOptional;
|
|
171
|
-
await collect(m.dependencies, false, childIsOptional);
|
|
172
|
-
await collect(m.optionalDependencies, true, true);
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
await collect(tree.dependencies, false, false);
|
|
176
|
-
await collect(tree.optionalDependencies, true, true);
|
|
177
|
-
// Final cleanup: remove the app package from allDependencies
|
|
178
|
-
if (packageToExclude) {
|
|
179
|
-
for (const [key, dep] of this.allDependencies.entries()) {
|
|
180
|
-
if (dep.name === packageToExclude) {
|
|
181
|
-
builder_util_1.log.debug({ key, name: dep.name }, "removing app package from allDependencies");
|
|
182
|
-
for (const [, d] of Object.entries(dep.dependencies || {})) {
|
|
183
|
-
this.allDependencies.set(this.packageVersionString(d), d);
|
|
184
|
-
}
|
|
185
|
-
this.allDependencies.delete(key);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (failedPackages.size > 0) {
|
|
190
|
-
const cleanDependencies = (deps = {}) => {
|
|
191
|
-
for (const [key, dep] of Object.entries(deps)) {
|
|
192
|
-
if (failedPackages.has(dep.name)) {
|
|
193
|
-
builder_util_1.log.debug({ name: dep.name }, "removing failed package from tree");
|
|
194
|
-
delete deps[key];
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
if (dep.dependencies) {
|
|
198
|
-
cleanDependencies(dep.dependencies);
|
|
199
|
-
}
|
|
200
|
-
if (dep.optionalDependencies) {
|
|
201
|
-
cleanDependencies(dep.optionalDependencies);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
cleanDependencies(tree.dependencies);
|
|
207
|
-
cleanDependencies(tree.optionalDependencies);
|
|
208
|
-
}
|
|
17
|
+
async getDependenciesTree(_pm) {
|
|
18
|
+
return super.getDependenciesTree(packageManager_1.PM.NPM);
|
|
209
19
|
}
|
|
210
20
|
}
|
|
211
21
|
exports.YarnNodeModulesCollector = YarnNodeModulesCollector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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CAAC,GAAG,CAAC,CAAA;gBAClC,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,cAAc,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,iBAAiB,GAAG,CAAC,OAAuC,EAAE,EAAE,EAAE;gBACtE,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC9C,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;wBACjC,kBAAG,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,mCAAmC,CAAC,CAAA;wBAClE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;oBAClB,CAAC;yBAAM,CAAC;wBACN,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC;4BACrB,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;wBACrC,CAAC;wBACD,IAAI,GAAG,CAAC,oBAAoB,EAAE,CAAC;4BAC7B,iBAAiB,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;wBAC7C,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC,CAAA;YAED,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YACpC,iBAAiB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;CACF;AA7OD,4DA6OC","sourcesContent":["import { log } from \"builder-util\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { PM } from \"./packageManager\"\nimport { YarnDependency } from \"./types\"\n\ntype YarnListJsonLine =\n | {\n type: \"tree\"\n data: {\n type: \"list\"\n trees: YarnListTree[]\n }\n }\n | {\n type: \"info\" | \"warning\" | \"error\"\n data: string\n }\n\ninterface YarnListTree {\n name: string // e.g. \"lodash@4.17.21\"\n children: YarnListTree[]\n shadow?: boolean\n color?: string\n hint?: any\n depth?: number\n}\n\nexport class YarnNodeModulesCollector extends NodeModulesCollector<YarnDependency, YarnDependency> {\n public readonly installOptions = {\n manager: PM.YARN,\n lockfile: \"yarn.lock\",\n }\n\n protected isHoisted: Lazy<boolean> = new Lazy<boolean>(async () => {\n return Promise.resolve(true) // Yarn Classic always hoists\n })\n\n protected getArgs(): string[] {\n return [\"list\", \"--production\", \"--json\", \"--depth=Infinity\", \"--no-progress\"]\n }\n\n protected async extractProductionDependencyGraph(tree: YarnDependency, dependencyId: string): Promise<void> {\n if (this.productionGraph[dependencyId]) {\n return\n }\n\n const productionDeps = Object.entries(tree.dependencies || {}).map(async ([, dependency]) => {\n const dep = {\n ...dependency,\n path: await this.cache.realPath[dependency.path],\n }\n\n const childDependencyId = this.packageVersionString(dep)\n await this.extractProductionDependencyGraph(dep, childDependencyId)\n return childDependencyId\n })\n\n const dependencies: string[] = []\n for (const dep of productionDeps) {\n dependencies.push(await dep)\n }\n this.productionGraph[dependencyId] = { dependencies }\n }\n\n protected async parseDependenciesTree(jsonBlob: string): Promise<YarnDependency> {\n const lines = jsonBlob\n .split(\"\\n\")\n .map(l => l.trim())\n .filter(Boolean)\n .map(l => {\n try {\n return JSON.parse(l)\n } catch {\n return undefined\n }\n })\n .filter(Boolean) as YarnListJsonLine[]\n\n const parsedTree: YarnListTree[] | undefined = lines\n .filter(l => l.type === \"tree\")\n .map(l => (l.data as any).trees)\n .shift()\n\n if (!parsedTree) {\n throw new Error('Failed to extract Yarn tree: no \"type\":\"tree\" line found in console output')\n }\n const rootPkgJson = (await this.cache.json[path.join(this.rootDir, \"package.json\")])!\n\n const normalizedTree = await this.normalizeTree({ tree: parsedTree, seen: new Set<string>(), appName: rootPkgJson.name, parentPath: this.rootDir })\n\n const dependencies: Record<string, YarnDependency> = {}\n for (const [name, dep] of Object.entries(normalizedTree)) {\n dependencies[name] = dep\n }\n\n return Promise.resolve({\n name: rootPkgJson.name,\n version: rootPkgJson.version,\n path: this.rootDir,\n dependencies,\n workspaces: rootPkgJson?.workspaces,\n })\n }\n\n private async normalizeTree(options: { tree: YarnListTree[]; seen: Set<string>; appName?: string; parentPath: string }): Promise<Record<string, YarnDependency>> {\n const { tree, seen, appName, parentPath = this.rootDir } = options\n const normalized: Record<string, YarnDependency> = {}\n\n for (const node of tree) {\n const match = node.name.match(/^(.*)@([^@]+)$/)\n if (!match) {\n log.debug({ name: node.name }, \"invalid node name format\")\n continue\n }\n\n const [, pkgName, version] = match\n const id = `${pkgName}@${version}`\n\n const isShadow = node.shadow && node.color === \"dim\"\n if (isShadow) {\n log.debug({ pkgName, version }, \"registering shadow node (hoisted elsewhere), will resolve\")\n }\n\n if (seen.has(id)) {\n continue\n }\n\n // Find the correct package path that matches the required version\n const pkg = await this.locatePackageWithVersion({ name: pkgName, version, path: parentPath })\n const pkgPath = pkg?.packageDir\n\n if (!pkgPath) {\n log.warn({ pkgName, version, parentPath }, \"could not find package matching version\")\n continue\n }\n\n seen.add(id)\n\n const normalizedDep: YarnDependency = {\n name: pkgName,\n version,\n path: pkgPath,\n dependencies: {},\n optionalDependencies: {},\n }\n\n // Recursively process children, passing this package's info\n if (node.children && node.children.length > 0) {\n const childDeps = await this.normalizeTree({\n tree: node.children,\n seen,\n appName,\n parentPath: pkgPath,\n })\n\n for (const [childDepName, childDep] of Object.entries(childDeps)) {\n normalizedDep.dependencies![childDepName] = childDep\n }\n }\n\n normalized[pkgName] = normalizedDep\n }\n\n return normalized\n }\n\n protected async collectAllDependencies(tree: YarnDependency, packageToExclude: string) {\n const rootPkgJson = (await this.cache.json[path.join(this.rootDir, \"package.json\")])!\n const failedPackages = new Set<string>()\n\n const collect = async (\n deps: YarnDependency[\"dependencies\"] | YarnDependency[\"optionalDependencies\"] = {},\n isOptionalDependency: boolean,\n parentIsOptional: boolean = false\n ) => {\n for (const [, value] of Object.entries(deps)) {\n const isRootOptional = !!rootPkgJson.optionalDependencies?.[value.name]\n const isDirectRootDep = rootPkgJson.dependencies?.[value.name] || rootPkgJson.optionalDependencies?.[value.name] || rootPkgJson.devDependencies?.[value.name]\n const treatAsOptional = isOptionalDependency || parentIsOptional || isRootOptional\n\n const logFields = { name: value.name, version: value.version, path: value.path }\n const p = await this.cache.realPath[value.path]\n if (!(await this.cache.exists[p])) {\n if (treatAsOptional) {\n log.debug(logFields, \"failed to find optional dependency, skipping\")\n failedPackages.add(value.name)\n continue\n }\n\n if (!isDirectRootDep) {\n log.debug(logFields, \"failed to find transitive dependency, treating as optional\")\n failedPackages.add(value.name)\n continue\n }\n\n const message = \"unable to find module directory; is the path correct?\"\n log.error(logFields, message)\n throw new Error(`Failed to resolve module directory for ${value.name}@${value.version} at path: ${value.path}`)\n }\n\n let resolvedVersion = value.version\n const versionMatch = p.match(/[/\\\\]node_modules[/\\\\][^@]+@([^/\\\\]+)[/\\\\]/)\n if (versionMatch) {\n resolvedVersion = versionMatch[1]\n if (resolvedVersion !== value.version) {\n log.debug({ name: value.name, declared: value.version, resolved: resolvedVersion }, \"resolved actual version from path\")\n }\n }\n\n const m: YarnDependency = {\n ...value,\n version: resolvedVersion,\n path: p,\n }\n\n const moduleKey = this.packageVersionString(m)\n if (this.allDependencies.has(moduleKey)) {\n continue\n }\n this.allDependencies.set(moduleKey, m)\n\n const childIsOptional = treatAsOptional\n await collect(m.dependencies, false, childIsOptional)\n await collect(m.optionalDependencies, true, true)\n }\n }\n\n await collect(tree.dependencies, false, false)\n await collect(tree.optionalDependencies, true, true)\n\n // Final cleanup: remove the app package from allDependencies\n if (packageToExclude) {\n for (const [key, dep] of this.allDependencies.entries()) {\n if (dep.name === packageToExclude) {\n log.debug({ key, name: dep.name }, \"removing app package from allDependencies\")\n for (const [, d] of Object.entries(dep.dependencies || {})) {\n this.allDependencies.set(this.packageVersionString(d), d)\n }\n this.allDependencies.delete(key)\n }\n }\n }\n\n if (failedPackages.size > 0) {\n const cleanDependencies = (deps: Record<string, YarnDependency> = {}) => {\n for (const [key, dep] of Object.entries(deps)) {\n if (failedPackages.has(dep.name)) {\n log.debug({ name: dep.name }, \"removing failed package from tree\")\n delete deps[key]\n } else {\n if (dep.dependencies) {\n cleanDependencies(dep.dependencies)\n }\n if (dep.optionalDependencies) {\n cleanDependencies(dep.optionalDependencies)\n }\n }\n }\n }\n\n cleanDependencies(tree.dependencies)\n cleanDependencies(tree.optionalDependencies)\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"yarnNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/yarnNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,uEAAmE;AACnE,qDAAqC;AAGrC,8EAA8E;AAC9E,iFAAiF;AACjF,iDAAiD;AACjD,MAAa,wBAAyB,SAAQ,iDAAuB;IAArE;;QACkB,mBAAc,GAAG;YAC/B,OAAO,EAAE,mBAAE,CAAC,IAAI;YAChB,QAAQ,EAAE,WAAW;SACtB,CAAA;IAKH,CAAC;IAHW,KAAK,CAAC,mBAAmB,CAAC,GAAO;QACzC,OAAO,KAAK,CAAC,mBAAmB,CAAC,mBAAE,CAAC,GAAG,CAAC,CAAA;IAC1C,CAAC;CACF;AATD,4DASC","sourcesContent":["import { NpmNodeModulesCollector } from \"./npmNodeModulesCollector\"\nimport { PM } from \"./packageManager\"\nimport { NpmDependency } from \"./types\"\n\n// Yarn Classic (v1) produces a hoisted node_modules structure similar to npm.\n// Instead of parsing Yarn's custom NDJSON output, we leverage npm's list command\n// which NpmNodeModulesCollector already handles.\nexport class YarnNodeModulesCollector extends NpmNodeModulesCollector {\n public readonly installOptions = {\n manager: PM.YARN,\n lockfile: \"yarn.lock\",\n }\n\n protected async getDependenciesTree(_pm: PM): Promise<NpmDependency> {\n return super.getDependenciesTree(PM.NPM)\n }\n}\n"]}
|
|
@@ -41,6 +41,13 @@ export interface AppXOptions extends TargetSpecificOptions {
|
|
|
41
41
|
* Relative path to custom extensions xml to be included in an `appmanifest.xml`.
|
|
42
42
|
*/
|
|
43
43
|
readonly customExtensionsPath?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The list of [capabilities](https://learn.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations) to be added to an `appmanifest.xml`.
|
|
46
|
+
* The `runFullTrust` capability is obligatory for electron apps and will be auto added if not specified here.
|
|
47
|
+
* Defaults to `['runFullTrust']` if omitted
|
|
48
|
+
* Example: `['runFullTrust', 'privateNetworkClientServer', 'webcam']`
|
|
49
|
+
*/
|
|
50
|
+
readonly capabilities?: Array<string> | null;
|
|
44
51
|
/**
|
|
45
52
|
* (Advanced Option) Relative path to custom `appmanifest.xml` (file name doesn't matter, it'll be renamed) located in build resources directory.
|
|
46
53
|
* Supports the following template macros:
|
|
@@ -62,6 +69,7 @@ export interface AppXOptions extends TargetSpecificOptions {
|
|
|
62
69
|
* - ${splashScreen}
|
|
63
70
|
* - ${arch}
|
|
64
71
|
* - ${resourceLanguages}
|
|
72
|
+
* - ${capabilities}
|
|
65
73
|
* - ${extensions}
|
|
66
74
|
* - ${minVersion}
|
|
67
75
|
* - ${maxVersionTested}
|