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* 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 node-linker setting; assuming non-hoisted (virtual store) layout\")\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          // Both indicate truncated/polluted PM output (a transient that re-running the command clears).\n          if (error.message?.includes(\"Unexpected end of JSON input\") || error.message?.includes(\"No JSON content found in output\")) {\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    let at: number\n    if (identifier.startsWith(\"@\")) {\n      // Scoped package: find the version separator after the scope (e.g. \"@scope/pkg@1.2.3\")\n      const slashIndex = identifier.indexOf(\"/\")\n      if (slashIndex === -1) {\n        return { name: identifier, version: \"unknown\" }\n      }\n      at = identifier.indexOf(\"@\", slashIndex + 1)\n    } else {\n      at = identifier.indexOf(\"@\")\n    }\n    if (at <= 0) {\n      return { name: identifier, version: \"unknown\" }\n    }\n    return { name: identifier.slice(0, at), version: identifier.slice(at + 1) }\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      // Normalize the path to handle mixed separators from pnpm JSON output on Windows\n      const rawPath = this.allDependencies.get(key)?.path\n      const p = rawPath != null ? path.normalize(rawPath) : undefined\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.logMissingDependency(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  protected logMissingDependency(pkgName: string) {\n    const PLATFORM_PACKAGE_RE = /(linux|win32|darwin|freebsd|android)[-_](x64|arm64|ia32|arm|ppc64|s390x|loong64|riscv64|universal)/\n    const diskLogKey = PLATFORM_PACKAGE_RE.test(pkgName) ? LogMessageByKey.PKG_OPTIONAL_PLATFORM_NOT_INSTALLED : LogMessageByKey.PKG_NOT_ON_DISK\n    this.cache.logSummary[diskLogKey].push(pkgName)\n  }\n\n  protected 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. On Windows, wraps the invocation in `powershell.exe -EncodedCommand` (UTF-16LE\n   * base64) to avoid spawning `.cmd` shims directly and to eliminate shell-injection surface area.\n   * 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  protected async streamCollectorCommandToFile(command: string, args: string[], cwd: string, tempOutputFile: string) {\n    // Derive execName from the original command so the npm-list shouldIgnore check below keys off the\n    // real invocation (e.g. \"npm\"), not the \"powershell\" wrapper we spawn on Windows.\n    const execName = path.basename(command, path.extname(command))\n\n    // On Windows the package-manager command is typically a `.cmd` shim (npm.cmd/pnpm.cmd/yarn.cmd),\n    // which Node can no longer spawn directly (CVE-2024-27980). Rather than spawn with `shell: true` —\n    // which emits the DEP0190 \"args with shell\" deprecation warning and forces manual metacharacter\n    // escaping — wrap the invocation in a single PowerShell `-EncodedCommand`. The base64 (UTF-16LE)\n    // payload sidesteps every shell-quoting layer, and `powershell.exe` is a real executable we spawn\n    // directly with no shell. See buildPowerShellEncodedArgs for the UTF-8 / exit-code handling.\n    const [spawnCommand, spawnArgs] = process.platform === \"win32\" ? ([\"powershell.exe\", buildPowerShellEncodedArgs(command, args)] as const) : ([command, args] as const)\n\n    await new Promise<void>((resolve, reject) => {\n      const outStream = createWriteStream(tempOutputFile)\n\n      const child = childProcess.spawn(spawnCommand, spawnArgs, {\n        cwd,\n        // Package manager invocations do not need signing/publishing credentials.\n        env: { COREPACK_ENABLE_STRICT: \"0\", ...stripSensitiveEnvVars(process.env) },\n      })\n\n      let stderr = \"\"\n      // The process can close before all piped stdout has been flushed to disk. Resolving on the\n      // child's \"close\" alone races the write stream and lets the caller read a TRUNCATED file\n      // (manifesting as \"No JSON content found in output\"). Gate the settle on BOTH the child exit\n      // (for the code/stderr) and the write stream's \"finish\" (all bytes flushed).\n      let exitCode: number | null = null\n      let childClosed = false\n      let streamFinished = false\n      let settled = false\n\n      // `pipe` ends `outStream` when stdout EOFs, which triggers its \"finish\" once flushed.\n      child.stdout.pipe(outStream)\n      child.stderr.on(\"data\", chunk => {\n        stderr += chunk.toString()\n      })\n\n      const fail = (err: Error) => {\n        if (settled) {\n          return\n        }\n        settled = true\n        // Best-effort cleanup: stop the child and close the stream so we don't\n        // waste CPU writing to a broken fd after rejection.\n        try {\n          child.kill()\n        } catch {\n          // ignore\n        }\n        try {\n          outStream.destroy()\n        } catch {\n          // ignore\n        }\n        reject(err)\n      }\n\n      const settle = () => {\n        if (settled || !childClosed || !streamFinished) {\n          return\n        }\n        const code = exitCode\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          // Only surface stderr as a user-visible warning when the exit code itself is unexpected.\n          // When shouldIgnore is true (npm list exit code 1) the stderr is an anticipated side\n          // effect of package-manager features like yarn resolutions or npm overrides that cause\n          // npm to report ELSPROBLEMS for aliased packages it considers \"invalid\".\n          if (!shouldIgnore) {\n            this.cache.logSummary[LogMessageByKey.PKG_COLLECTOR_OUTPUT].push(stderr)\n          }\n        }\n        settled = true\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      outStream.on(\"error\", err => fail(new Error(`Node module collector failed writing output (${command}): ${err.message}`)))\n      outStream.on(\"finish\", () => {\n        streamFinished = true\n        settle()\n      })\n      child.on(\"error\", err => {\n        fail(new Error(`Node module collector spawn (${command} ${JSON.stringify(args)}) failed: ${err.message}`))\n      })\n      child.on(\"close\", code => {\n        exitCode = code\n        childClosed = true\n        settle()\n      })\n    })\n  }\n}\n\n/**\n * Build the argv for invoking a Windows command through `powershell.exe -EncodedCommand`.\n *\n * Each token is wrapped in a PowerShell single-quoted string (with embedded single quotes doubled),\n * so no character is interpreted by a shell. The script:\n *   - pins `[Console]::OutputEncoding` to UTF-8 *without* a BOM so the JSON dependency tree is not\n *     corrupted by the console's OEM code page (and no BOM is prepended to break `JSON.parse`),\n *   - invokes the command via the call operator `&`,\n *   - re-emits the command's own exit code via `exit $LASTEXITCODE` (e.g. `npm list` returns 1 in\n *     expected scenarios, which the caller's shouldIgnore logic relies on).\n *\n * The whole script is base64-encoded as UTF-16LE per PowerShell's `-EncodedCommand` contract.\n */\nexport function buildPowerShellEncodedArgs(command: string, args: string[]): string[] {\n  const psQuote = (value: string) => `'${value.replace(/'/g, \"''\")}'`\n  const invocation = [\"&\", psQuote(command), ...args.map(psQuote)].join(\" \")\n  const script = `[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new($false); ${invocation}; exit $LASTEXITCODE`\n  const encoded = Buffer.from(script, \"utf16le\").toString(\"base64\")\n  return [\"-NoProfile\", \"-NonInteractive\", \"-EncodedCommand\", encoded]\n}\n"]}