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E,CAAA;YAC5B,CAAC,CAAC,CAAA;YACF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE;gBACtB,MAAM,CAAC,IAAI,KAAK,CAAC,uCAAuC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;YACzE,CAAC,CAAC,CAAA;YAEF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;gBACvB,SAAS,CAAC,KAAK,EAAE,CAAA;gBACjB,0CAA0C;gBAC1C,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;gBAC5F,IAAI,YAAY,EAAE,CAAC;oBACjB,kBAAG,CAAC,KAAK,CAAC,IAAI,EAAE,uIAAuI,CAAC,CAAA;gBAC1J,CAAC;gBACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACtB,kBAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,wDAAwD,CAAC,CAAA;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"]}