app-builder-lib 26.15.7 → 26.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/codeSign/macCodeSign.js +5 -3
- package/out/codeSign/macCodeSign.js.map +1 -1
- package/out/codeSign/windowsCodeSign.js +0 -3
- package/out/codeSign/windowsCodeSign.js.map +1 -1
- package/out/codeSign/windowsSignToolManager.js +4 -1
- package/out/codeSign/windowsSignToolManager.js.map +1 -1
- package/out/configuration.d.ts +32 -0
- package/out/configuration.js.map +1 -1
- package/out/electron/ElectronFramework.d.ts +2 -1
- package/out/electron/ElectronFramework.js +13 -5
- package/out/electron/ElectronFramework.js.map +1 -1
- package/out/electron/electronMac.js +1 -5
- package/out/electron/electronMac.js.map +1 -1
- package/out/macPackager.d.ts +7 -2
- package/out/macPackager.js +40 -11
- package/out/macPackager.js.map +1 -1
- package/out/node-module-collector/nodeModulesCollector.d.ts +11 -1
- package/out/node-module-collector/nodeModulesCollector.js +28 -5
- package/out/node-module-collector/nodeModulesCollector.js.map +1 -1
- package/out/node-module-collector/pnpmNodeModulesCollector.js +3 -1
- package/out/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
- package/out/packager.d.ts +2 -0
- package/out/packager.js +15 -0
- package/out/packager.js.map +1 -1
- package/out/platformPackager.d.ts +1 -0
- package/out/platformPackager.js +3 -0
- package/out/platformPackager.js.map +1 -1
- package/out/targets/AppxTarget.js +5 -5
- package/out/targets/AppxTarget.js.map +1 -1
- package/out/targets/MsiTarget.js +8 -11
- package/out/targets/MsiTarget.js.map +1 -1
- package/out/targets/appimage/appImageUtil.d.ts +1 -1
- package/out/targets/appimage/appImageUtil.js +3 -3
- package/out/targets/appimage/appImageUtil.js.map +1 -1
- package/out/targets/appimage/appLauncher.js +3 -9
- package/out/targets/appimage/appLauncher.js.map +1 -1
- package/out/targets/blockmap/blockmap.js +2 -2
- package/out/targets/blockmap/blockmap.js.map +1 -1
- package/out/targets/nsis/NsisTarget.d.ts +2 -2
- package/out/targets/nsis/NsisTarget.js +9 -1
- package/out/targets/nsis/NsisTarget.js.map +1 -1
- package/out/targets/nsis/nsisOptions.d.ts +2 -0
- package/out/targets/nsis/nsisOptions.js.map +1 -1
- package/out/targets/nsis/nsisUtil.d.ts +5 -2
- package/out/targets/nsis/nsisUtil.js +48 -24
- package/out/targets/nsis/nsisUtil.js.map +1 -1
- package/out/toolsets/icons.js +2 -2
- package/out/toolsets/icons.js.map +1 -1
- package/out/toolsets/linux.js +3 -3
- package/out/toolsets/linux.js.map +1 -1
- package/out/util/appFileCopier.d.ts +21 -0
- package/out/util/appFileCopier.js +58 -0
- package/out/util/appFileCopier.js.map +1 -1
- package/out/util/electronGet.d.ts +46 -0
- package/out/util/electronGet.js +174 -24
- package/out/util/electronGet.js.map +1 -1
- package/out/version.d.ts +1 -1
- package/out/version.js +1 -1
- package/out/version.js.map +1 -1
- package/package.json +8 -8
- package/scheme.json +20 -1
- package/templates/appx/appxmanifest.xml +1 -2
- package/templates/nsis/include/allowOnlyOneInstallerInstance.nsh +4 -4
|
@@ -238,17 +238,24 @@ class NodeModulesCollector {
|
|
|
238
238
|
const deps = (obj[key] || {}).dependencies || [];
|
|
239
239
|
for (const dep of deps) {
|
|
240
240
|
const child = this.transformToHoisterTree(obj, dep, nodes);
|
|
241
|
-
|
|
241
|
+
// a package that declares itself as a dependency (e.g. libsql) must not produce a self-edge
|
|
242
|
+
if (child !== node) {
|
|
243
|
+
node.dependencies.add(child);
|
|
244
|
+
}
|
|
242
245
|
}
|
|
243
246
|
}
|
|
244
247
|
return node;
|
|
245
248
|
}
|
|
246
|
-
async _getNodeModules(dependencies, result) {
|
|
249
|
+
async _getNodeModules(dependencies, result, ancestors = new Set()) {
|
|
247
250
|
var _a;
|
|
248
251
|
if (dependencies.size === 0) {
|
|
249
252
|
return;
|
|
250
253
|
}
|
|
251
254
|
for (const d of dependencies.values()) {
|
|
255
|
+
// dependency cycles (including self-references) must not recurse
|
|
256
|
+
if (ancestors.has(d)) {
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
252
259
|
const reference = [...d.references][0];
|
|
253
260
|
const key = `${d.name}@${reference}`;
|
|
254
261
|
// Normalize the path to handle mixed separators from pnpm JSON output on Windows
|
|
@@ -272,14 +279,30 @@ class NodeModulesCollector {
|
|
|
272
279
|
result.push(node);
|
|
273
280
|
if (d.dependencies.size > 0) {
|
|
274
281
|
node.dependencies = [];
|
|
275
|
-
|
|
282
|
+
ancestors.add(d);
|
|
283
|
+
await this._getNodeModules(d.dependencies, node.dependencies, ancestors);
|
|
284
|
+
ancestors.delete(d);
|
|
276
285
|
}
|
|
277
286
|
}
|
|
278
287
|
result.sort((a, b) => a.name.localeCompare(b.name));
|
|
279
288
|
}
|
|
280
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Records a dependency that could not be resolved on disk in the log summary.
|
|
291
|
+
*
|
|
292
|
+
* A platform-specific package name (e.g. `sass-embedded-linux-x64`) is always classified as a
|
|
293
|
+
* platform-specific optional dependency. Otherwise, `isDeclaredOptional` decides the bucket: a
|
|
294
|
+
* caller that *knows* the dependency was declared in `optionalDependencies` (e.g. the pnpm
|
|
295
|
+
* collector's optional-dependency check) reports a missing *optional* dependency — an expected
|
|
296
|
+
* condition — rather than the `PKG_NOT_ON_DISK` warning reserved for genuinely missing
|
|
297
|
+
* production dependencies.
|
|
298
|
+
*/
|
|
299
|
+
logMissingDependency(pkgName, isDeclaredOptional = false) {
|
|
281
300
|
const PLATFORM_PACKAGE_RE = /(linux|win32|darwin|freebsd|android)[-_](x64|arm64|ia32|arm|ppc64|s390x|loong64|riscv64|universal)/;
|
|
282
|
-
const diskLogKey = PLATFORM_PACKAGE_RE.test(pkgName)
|
|
301
|
+
const diskLogKey = PLATFORM_PACKAGE_RE.test(pkgName)
|
|
302
|
+
? moduleManager_1.LogMessageByKey.PKG_OPTIONAL_PLATFORM_NOT_INSTALLED
|
|
303
|
+
: isDeclaredOptional
|
|
304
|
+
? moduleManager_1.LogMessageByKey.PKG_OPTIONAL_NOT_INSTALLED
|
|
305
|
+
: moduleManager_1.LogMessageByKey.PKG_NOT_ON_DISK;
|
|
283
306
|
this.cache.logSummary[diskLogKey].push(pkgName);
|
|
284
307
|
}
|
|
285
308
|
async asyncExec(command, args, cwd = this.rootDir) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":";;;AAwdA,gEAMC;AA9dD,+CAAgF;AAChF,8CAA6C;AAC7C,+BAA8B;AAC9B,uCAA4C;AAC5C,uCAA+B;AAC/B,6BAA4B;AAC5B,mCAAqE;AACrE,mDAAgE;AAChE,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,GAA6B,IAAI,GAAG,EAAE,CAAA;QACrD,oBAAe,GAAoB,EAAE,CAAA;QACrC,UAAK,GAAkB,IAAI,6BAAa,EAAE,CAAA;QAEnD,cAAS,GAAG,IAAI,eAAI,CAAU,KAAK,IAAI,EAAE;YACjD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,cAAc,CAAA;YACvC,MAAM,OAAO,GAAG,IAAA,yCAAwB,EAAC,OAAO,CAAC,CAAA;YACjD,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;YACzE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;gBACnB,kBAAG,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,sFAAsF,CAAC,CAAA;gBAC9G,OAAO,KAAK,CAAA;YACd,CAAC;YACD,MAAM,KAAK,GAAG,M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IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACjE,OAAO,CAAC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAA;AACtE,CAAC","sourcesContent":["import { exists, log, retry, stripSensitiveEnvVars, 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 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"]}
|
|
1
|
+
{"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":";;;AA+eA,gEAMC;AArfD,+CAAgF;AAChF,8CAA6C;AAC7C,+BAA8B;AAC9B,uCAA4C;AAC5C,uCAA+B;AAC/B,6BAA4B;AAC5B,mCAAqE;AACrE,mDAAgE;AAChE,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,GAA6B,IAAI,GAAG,EAAE,CAAA;QACrD,oBAAe,GAAoB,EAAE,CAAA;QACrC,UAAK,GAAkB,IAAI,6BAAa,EAAE,CAAA;QAEnD,cAAS,GAAG,IAAI,eAAI,CAAU,KAAK,IAAI,EAAE;YACjD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,cAAc,CAAA;YACvC,MAAM,OAAO,GAAG,IAAA,yCAAwB,EAAC,OAAO,CAAC,CAAA;YACjD,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;YACzE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;gBACnB,kBAAG,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,sFAAsF,CAAC,CAAA;gBAC9G,OAAO,KAAK,CAAA;YACd,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,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Ae,EAAE,IAAc;IACxE,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAA;IACnE,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC1E,MAAM,MAAM,GAAG,sEAAsE,UAAU,sBAAsB,CAAA;IACrH,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACjE,OAAO,CAAC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAA;AACtE,CAAC","sourcesContent":["import { exists, log, retry, stripSensitiveEnvVars, 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 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 // a package that declares itself as a dependency (e.g. libsql) must not produce a self-edge\n if (child !== node) {\n node.dependencies.add(child)\n }\n }\n }\n\n return node\n }\n\n private async _getNodeModules(dependencies: Set<HoisterResult>, result: NodeModuleInfo[], ancestors: Set<HoisterResult> = new Set()) {\n if (dependencies.size === 0) {\n return\n }\n\n for (const d of dependencies.values()) {\n // dependency cycles (including self-references) must not recurse\n if (ancestors.has(d)) {\n continue\n }\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 ancestors.add(d)\n await this._getNodeModules(d.dependencies, node.dependencies, ancestors)\n ancestors.delete(d)\n }\n }\n result.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n /**\n * Records a dependency that could not be resolved on disk in the log summary.\n *\n * A platform-specific package name (e.g. `sass-embedded-linux-x64`) is always classified as a\n * platform-specific optional dependency. Otherwise, `isDeclaredOptional` decides the bucket: a\n * caller that *knows* the dependency was declared in `optionalDependencies` (e.g. the pnpm\n * collector's optional-dependency check) reports a missing *optional* dependency — an expected\n * condition — rather than the `PKG_NOT_ON_DISK` warning reserved for genuinely missing\n * production dependencies.\n */\n protected logMissingDependency(pkgName: string, isDeclaredOptional = false) {\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)\n ? LogMessageByKey.PKG_OPTIONAL_PLATFORM_NOT_INSTALLED\n : isDeclaredOptional\n ? LogMessageByKey.PKG_OPTIONAL_NOT_INSTALLED\n : 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"]}
|
|
@@ -123,7 +123,9 @@ class PnpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollect
|
|
|
123
123
|
if (optional[packageName]) {
|
|
124
124
|
const pkg = await this.locateFromDepOrRoot(packageName, tree.path, dependency.version);
|
|
125
125
|
if (!pkg) {
|
|
126
|
-
|
|
126
|
+
// Declared in `optionalDependencies`, so a miss is an expected condition (e.g. fsevents
|
|
127
|
+
// on Linux/Windows) — classify it as a missing optional dependency, not PKG_NOT_ON_DISK.
|
|
128
|
+
this.logMissingDependency(`${packageName}@${dependency.version}`, true);
|
|
127
129
|
return undefined;
|
|
128
130
|
}
|
|
129
131
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pnpmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,uCAA+B;AAC/B,mDAA+D;AAC/D,iEAA6D;AAC7D,qDAA+D;AAG/D,MAAa,wBAAyB,SAAQ,2CAAoD;IAAlG;;QACkB,mBAAc,GAAG;YAC/B,OAAO,EAAE,mBAAE,CAAC,IAAI;YAChB,QAAQ,EAAE,gBAAgB;SAC3B,CAAA;QAED,0DAA0D;QAClD,0BAAqB,GAAqB,EAAE,CAAA;QACpD,4FAA4F;QACpF,sBAAiB,GAAG,CAAC,CAAA;QAC7B,iEAAiE;QAChD,gBAAW,GAAG,IAAI,eAAI,CAAS,KAAK,IAAI,EAAE;;YACzD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAA,yCAAwB,EAAC,mBAAE,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;YACrF,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,MAAA,MAAM,CAAC,MAAM,mCAAI,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;YAChE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;QACjC,CAAC,CAAC,CAAA;QAEF;;;;;;WAMG;QACc,eAAU,GAAyC,IAAI,GAAG,EAAE,CAAA;QAE7E;;;WAGG;QACc,kBAAa,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AAO,MAAM,CAAA;QACf,CAAC;QACD,kFAAkF;QAClF,4FAA4F;QAC5F,MAAM,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,WAAW,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,CAAC,CAAA;QACzG,OAAO,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,CAAA;IACtB,CAAC;IAES,KAAK,CAAC,qBAAqB,CAAC,QAAgB;QACpD,MAAM,cAAc,GAAG,IAAI,CAAC,6BAA6B,CAAmB,QAAQ,CAAC,CAAA;QACrF,IAAI,CAAC,qBAAqB,GAAG,cAAc,CAAA;QAC3C,IAAI,CAAC,iBAAiB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAA;QACrD,OAAO,cAAc,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;CACF;AAlMD,4DAkMC","sourcesContent":["import { Lazy } from \"lazy-val\"\nimport { LogMessageByKey, type Package } from \"./moduleManager\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { getPackageManagerCommand, 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 // Raw backing field — all entries from `pnpm list --json`\n private _allWorkspacePackages: PnpmDependency[] = []\n // Cached after parseDependenciesTree resolves the Lazy; 0 = safe default (treated as < v11)\n private _pnpmMajorVersion = 0\n // Runs `pnpm --version` once and caches the major version number\n private readonly pnpmVersion = new Lazy<number>(async () => {\n const result = await this.asyncExec(getPackageManagerCommand(PM.PNPM), [\"--version\"])\n const major = parseInt((result.stdout ?? \"0\").split(\".\")[0], 10)\n return isNaN(major) ? 0 : major\n })\n\n /**\n * Memo for `locateFromDepOrRoot`, keyed by `name@version`. pnpm's content-addressed virtual\n * store guarantees that any given `name@version` resolves to a single location on disk, so\n * once we've resolved a package we can short-circuit every subsequent lookup. This is the\n * dominant speedup for large workspaces where the `pnpm list --json` tree contains the same\n * `name@version` thousands of times (one entry per dependent).\n */\n private readonly locateMemo: Map<string, Promise<Package | null>> = new Map()\n\n /**\n * Visited set for `collectDepsRecursively`, keyed by `name@version`. Without this we re-walk\n * every shared subtree of the pnpm list output, exploding work in deep workspaces.\n */\n private readonly collectedDeps: Set<string> = new Set()\n\n /**\n * Returns the workspace packages to iterate over, gated by detected pnpm version:\n * - pnpm v11+: multi-entry workspace output → return the full parsed array\n * - pnpm < v11 / non-workspace / detection failure: single-tree behavior → return only [0]\n */\n private get allWorkspacePackages(): PnpmDependency[] {\n if (this._pnpmMajorVersion >= 11) {\n return this._allWorkspacePackages\n }\n return this._allWorkspacePackages.slice(0, 1)\n }\n\n protected getArgs(): string[] {\n return [\"list\", \"--prod\", \"--json\", \"--depth\", \"Infinity\", \"--silent\", \"--loglevel=error\"]\n }\n\n /**\n * Locate a package version, preferring the dep's own reported path before falling back to rootDir.\n * This is critical for pnpm non-hoisted (virtual store) setups where each package has its own\n * nested node_modules. Searching only from rootDir can resolve the wrong version when multiple\n * versions of a dep exist in the workspace.\n */\n private async locateFromDepOrRoot(pkgName: string, parentPath: string | undefined, requiredRange?: string) {\n // pnpm's virtual store is content-addressed: every `name@version` lookup is deterministic,\n // so memoize on the exact version. `requiredRange` is normally an exact version coming from\n // the pnpm list output (e.g. `value.version`), which makes this cache hit on duplicates.\n // Only memoize when we have a concrete version — semver ranges could resolve differently\n // depending on what's installed at `parentPath` vs root, so skip the cache for those.\n const memoKey = requiredRange && /^\\d/.test(requiredRange) ? `${pkgName}@${requiredRange}` : null\n if (memoKey != null) {\n const cached = this.locateMemo.get(memoKey)\n if (cached != null) {\n return cached\n }\n }\n\n // pnpm's default `.pnpm` virtual store is flat, so `downwardSearch` would burn thousands\n // of `readdir`/`lstat` calls finding nothing. With `nodeLinker: hoisted`, however, the\n // layout is a traditional nested `node_modules` tree where version-conflicted packages\n // land at `<root>/node_modules/A/node_modules/B` — downward BFS is needed to find them.\n const skipDownwardSearch = !(await this.isHoisted.value)\n const promise = (async (): Promise<Package | null> => {\n const fromDep = parentPath ? await this.cache.locatePackageVersion({ pkgName, parentDir: parentPath, requiredRange, skipDownwardSearch }) : null\n if (fromDep) {\n return fromDep\n }\n return this.cache.locatePackageVersion({ pkgName, parentDir: this.rootDir, requiredRange, skipDownwardSearch })\n })()\n\n if (memoKey != null) {\n this.locateMemo.set(memoKey, promise)\n }\n return promise\n }\n\n // pnpm 10+ does not automatically preserve transitive optional platform-specific\n // packages (e.g. sass-embedded-linux-x64) across lock file regeneration. Users\n // must list them as direct optionalDependencies. Missing ones are emitted as\n // PKG_OPTIONAL_PLATFORM_NOT_INSTALLED warnings in the log summary.\n protected async extractProductionDependencyGraph(tree: PnpmDependency, dependencyId: string) {\n if (this.productionGraph[dependencyId]) {\n return\n }\n this.productionGraph[dependencyId] = { dependencies: [] }\n\n if ((tree.dedupedDependenciesCount ?? 0) > 0) {\n const realDep = this.allDependencies.get(dependencyId)\n if (realDep) {\n this.cache.logSummary[LogMessageByKey.PKG_DUPLICATE_REF].push(dependencyId)\n tree = realDep\n } else {\n this.cache.logSummary[LogMessageByKey.PKG_DUPLICATE_REF_UNRESOLVED].push(dependencyId)\n return\n }\n }\n\n const packageName = tree.name || tree.from\n const { packageJson } = (await this.locateFromDepOrRoot(packageName, tree.path, 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.locateFromDepOrRoot(packageName, tree.path, dependency.version)\n if (!pkg) {\n this.logMissingDependency(`${packageName}@${dependency.version}`)\n return undefined\n }\n }\n const { id: childDependencyId, pkgOverride } = this.normalizePackageVersion(packageName, dependency)\n await this.extractProductionDependencyGraph(pkgOverride, childDependencyId)\n return childDependencyId\n })\n\n const collectedDependencies: string[] = []\n for (const dep of depPromises) {\n const result = await dep\n if (result !== undefined) {\n collectedDependencies.push(result)\n }\n }\n this.productionGraph[dependencyId] = { dependencies: collectedDependencies }\n }\n\n protected async collectAllDependencies(_tree: PnpmDependency, _appPackageName: string): Promise<void> {\n for (const root of this.allWorkspacePackages) {\n await this.collectDepsRecursively(root)\n }\n }\n\n private async collectDepsRecursively(tree: PnpmDependency): Promise<void> {\n const visit = async (key: string, value: PnpmDependency) => {\n if ((value?.dedupedDependenciesCount ?? 0) > 0) {\n return\n }\n const id = `${key}@${value.version}`\n // The pnpm list output can include the same `name@version` thousands of times across a\n // deep workspace; without this guard we re-resolve and re-recurse each occurrence.\n if (this.collectedDeps.has(id)) {\n return\n }\n this.collectedDeps.add(id)\n const pkg = await this.locateFromDepOrRoot(key, value.path, value.version)\n this.allDependencies.set(id, { ...value, path: pkg?.packageDir ?? value.path })\n await this.collectDepsRecursively(value)\n }\n\n for (const [key, value] of Object.entries(tree.dependencies || {})) {\n await visit(key, value)\n }\n for (const [key, value] of Object.entries(tree.optionalDependencies || {})) {\n await visit(key, value)\n }\n }\n\n protected override getTreeFromWorkspaces(tree: PnpmDependency, packageName: string): PnpmDependency {\n // pnpm v10 workspace: app is nested as a dependency of root — handled by base class\n const result = super.getTreeFromWorkspaces(tree, packageName)\n if (result !== tree) {\n return result\n }\n // pnpm v11 workspace: each workspace package is a separate top-level array entry;\n // non-workspace (single-tree): find returns the one entry or undefined → falls back to tree\n const match = this.allWorkspacePackages.find(pkg => pkg.name === packageName || pkg.from === packageName)\n return match ?? tree\n }\n\n protected async parseDependenciesTree(jsonBlob: string): Promise<PnpmDependency> {\n const dependencyTree = this.extractJsonFromPollutedOutput<PnpmDependency[]>(jsonBlob)\n this._allWorkspacePackages = dependencyTree\n this._pnpmMajorVersion = await this.pnpmVersion.value\n return dependencyTree[0]\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pnpmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,uCAA+B;AAC/B,mDAA+D;AAC/D,iEAA6D;AAC7D,qDAA+D;AAG/D,MAAa,wBAAyB,SAAQ,2CAAoD;IAAlG;;QACkB,mBAAc,GAAG;YAC/B,OAAO,EAAE,mBAAE,CAAC,IAAI;YAChB,QAAQ,EAAE,gBAAgB;SAC3B,CAAA;QAED,0DAA0D;QAClD,0BAAqB,GAAqB,EAAE,CAAA;QACpD,4FAA4F;QACpF,sBAAiB,GAAG,CAAC,CAAA;QAC7B,iEAAiE;QAChD,gBAAW,GAAG,IAAI,eAAI,CAAS,KAAK,IAAI,EAAE;;YACzD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAA,yCAAwB,EAAC,mBAAE,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;YACrF,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,MAAA,MAAM,CAAC,MAAM,mCAAI,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;YAChE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;QACjC,CAAC,CAAC,CAAA;QAEF;;;;;;WAMG;QACc,eAAU,GAAyC,IAAI,GAAG,EAAE,CAAA;QAE7E;;;WAGG;QACc,kBAAa,GAAgB,IAAI,GAAG,EAAE,CAAA;IAsKzD,CAAC;IApKC;;;;OAIG;IACH,IAAY,oBAAoB;QA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QAClF,4FAA4F;QAC5F,MAAM,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,WAAW,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,CAAC,CAAA;QACzG,OAAO,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,CAAA;IACtB,CAAC;IAES,KAAK,CAAC,qBAAqB,CAAC,QAAgB;QACpD,MAAM,cAAc,GAAG,IAAI,CAAC,6BAA6B,CAAmB,QAAQ,CAAC,CAAA;QACrF,IAAI,CAAC,qBAAqB,GAAG,cAAc,CAAA;QAC3C,IAAI,CAAC,iBAAiB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAA;QACrD,OAAO,cAAc,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;CACF;AApMD,4DAoMC","sourcesContent":["import { Lazy } from \"lazy-val\"\nimport { LogMessageByKey, type Package } from \"./moduleManager\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { getPackageManagerCommand, 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 // Raw backing field — all entries from `pnpm list --json`\n private _allWorkspacePackages: PnpmDependency[] = []\n // Cached after parseDependenciesTree resolves the Lazy; 0 = safe default (treated as < v11)\n private _pnpmMajorVersion = 0\n // Runs `pnpm --version` once and caches the major version number\n private readonly pnpmVersion = new Lazy<number>(async () => {\n const result = await this.asyncExec(getPackageManagerCommand(PM.PNPM), [\"--version\"])\n const major = parseInt((result.stdout ?? \"0\").split(\".\")[0], 10)\n return isNaN(major) ? 0 : major\n })\n\n /**\n * Memo for `locateFromDepOrRoot`, keyed by `name@version`. pnpm's content-addressed virtual\n * store guarantees that any given `name@version` resolves to a single location on disk, so\n * once we've resolved a package we can short-circuit every subsequent lookup. This is the\n * dominant speedup for large workspaces where the `pnpm list --json` tree contains the same\n * `name@version` thousands of times (one entry per dependent).\n */\n private readonly locateMemo: Map<string, Promise<Package | null>> = new Map()\n\n /**\n * Visited set for `collectDepsRecursively`, keyed by `name@version`. Without this we re-walk\n * every shared subtree of the pnpm list output, exploding work in deep workspaces.\n */\n private readonly collectedDeps: Set<string> = new Set()\n\n /**\n * Returns the workspace packages to iterate over, gated by detected pnpm version:\n * - pnpm v11+: multi-entry workspace output → return the full parsed array\n * - pnpm < v11 / non-workspace / detection failure: single-tree behavior → return only [0]\n */\n private get allWorkspacePackages(): PnpmDependency[] {\n if (this._pnpmMajorVersion >= 11) {\n return this._allWorkspacePackages\n }\n return this._allWorkspacePackages.slice(0, 1)\n }\n\n protected getArgs(): string[] {\n return [\"list\", \"--prod\", \"--json\", \"--depth\", \"Infinity\", \"--silent\", \"--loglevel=error\"]\n }\n\n /**\n * Locate a package version, preferring the dep's own reported path before falling back to rootDir.\n * This is critical for pnpm non-hoisted (virtual store) setups where each package has its own\n * nested node_modules. Searching only from rootDir can resolve the wrong version when multiple\n * versions of a dep exist in the workspace.\n */\n private async locateFromDepOrRoot(pkgName: string, parentPath: string | undefined, requiredRange?: string) {\n // pnpm's virtual store is content-addressed: every `name@version` lookup is deterministic,\n // so memoize on the exact version. `requiredRange` is normally an exact version coming from\n // the pnpm list output (e.g. `value.version`), which makes this cache hit on duplicates.\n // Only memoize when we have a concrete version — semver ranges could resolve differently\n // depending on what's installed at `parentPath` vs root, so skip the cache for those.\n const memoKey = requiredRange && /^\\d/.test(requiredRange) ? `${pkgName}@${requiredRange}` : null\n if (memoKey != null) {\n const cached = this.locateMemo.get(memoKey)\n if (cached != null) {\n return cached\n }\n }\n\n // pnpm's default `.pnpm` virtual store is flat, so `downwardSearch` would burn thousands\n // of `readdir`/`lstat` calls finding nothing. With `nodeLinker: hoisted`, however, the\n // layout is a traditional nested `node_modules` tree where version-conflicted packages\n // land at `<root>/node_modules/A/node_modules/B` — downward BFS is needed to find them.\n const skipDownwardSearch = !(await this.isHoisted.value)\n const promise = (async (): Promise<Package | null> => {\n const fromDep = parentPath ? await this.cache.locatePackageVersion({ pkgName, parentDir: parentPath, requiredRange, skipDownwardSearch }) : null\n if (fromDep) {\n return fromDep\n }\n return this.cache.locatePackageVersion({ pkgName, parentDir: this.rootDir, requiredRange, skipDownwardSearch })\n })()\n\n if (memoKey != null) {\n this.locateMemo.set(memoKey, promise)\n }\n return promise\n }\n\n // pnpm 10+ does not automatically preserve transitive optional platform-specific\n // packages (e.g. sass-embedded-linux-x64) across lock file regeneration. Users\n // must list them as direct optionalDependencies. Missing ones are emitted as\n // PKG_OPTIONAL_PLATFORM_NOT_INSTALLED warnings in the log summary.\n protected async extractProductionDependencyGraph(tree: PnpmDependency, dependencyId: string) {\n if (this.productionGraph[dependencyId]) {\n return\n }\n this.productionGraph[dependencyId] = { dependencies: [] }\n\n if ((tree.dedupedDependenciesCount ?? 0) > 0) {\n const realDep = this.allDependencies.get(dependencyId)\n if (realDep) {\n this.cache.logSummary[LogMessageByKey.PKG_DUPLICATE_REF].push(dependencyId)\n tree = realDep\n } else {\n this.cache.logSummary[LogMessageByKey.PKG_DUPLICATE_REF_UNRESOLVED].push(dependencyId)\n return\n }\n }\n\n const packageName = tree.name || tree.from\n const { packageJson } = (await this.locateFromDepOrRoot(packageName, tree.path, 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.locateFromDepOrRoot(packageName, tree.path, dependency.version)\n if (!pkg) {\n // Declared in `optionalDependencies`, so a miss is an expected condition (e.g. fsevents\n // on Linux/Windows) — classify it as a missing optional dependency, not PKG_NOT_ON_DISK.\n this.logMissingDependency(`${packageName}@${dependency.version}`, true)\n return undefined\n }\n }\n const { id: childDependencyId, pkgOverride } = this.normalizePackageVersion(packageName, dependency)\n await this.extractProductionDependencyGraph(pkgOverride, childDependencyId)\n return childDependencyId\n })\n\n const collectedDependencies: string[] = []\n for (const dep of depPromises) {\n const result = await dep\n if (result !== undefined) {\n collectedDependencies.push(result)\n }\n }\n this.productionGraph[dependencyId] = { dependencies: collectedDependencies }\n }\n\n protected async collectAllDependencies(_tree: PnpmDependency, _appPackageName: string): Promise<void> {\n for (const root of this.allWorkspacePackages) {\n await this.collectDepsRecursively(root)\n }\n }\n\n private async collectDepsRecursively(tree: PnpmDependency): Promise<void> {\n const visit = async (key: string, value: PnpmDependency) => {\n if ((value?.dedupedDependenciesCount ?? 0) > 0) {\n return\n }\n const id = `${key}@${value.version}`\n // The pnpm list output can include the same `name@version` thousands of times across a\n // deep workspace; without this guard we re-resolve and re-recurse each occurrence.\n if (this.collectedDeps.has(id)) {\n return\n }\n this.collectedDeps.add(id)\n const pkg = await this.locateFromDepOrRoot(key, value.path, value.version)\n this.allDependencies.set(id, { ...value, path: pkg?.packageDir ?? value.path })\n await this.collectDepsRecursively(value)\n }\n\n for (const [key, value] of Object.entries(tree.dependencies || {})) {\n await visit(key, value)\n }\n for (const [key, value] of Object.entries(tree.optionalDependencies || {})) {\n await visit(key, value)\n }\n }\n\n protected override getTreeFromWorkspaces(tree: PnpmDependency, packageName: string): PnpmDependency {\n // pnpm v10 workspace: app is nested as a dependency of root — handled by base class\n const result = super.getTreeFromWorkspaces(tree, packageName)\n if (result !== tree) {\n return result\n }\n // pnpm v11 workspace: each workspace package is a separate top-level array entry;\n // non-workspace (single-tree): find returns the one entry or undefined → falls back to tree\n const match = this.allWorkspacePackages.find(pkg => pkg.name === packageName || pkg.from === packageName)\n return match ?? tree\n }\n\n protected async parseDependenciesTree(jsonBlob: string): Promise<PnpmDependency> {\n const dependencyTree = this.extractJsonFromPollutedOutput<PnpmDependency[]>(jsonBlob)\n this._allWorkspacePackages = dependencyTree\n this._pnpmMajorVersion = await this.pnpmVersion.value\n return dependencyTree[0]\n }\n}\n"]}
|
package/out/packager.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ export declare class Packager {
|
|
|
49
49
|
_appInfo: AppInfo | null;
|
|
50
50
|
get appInfo(): AppInfo;
|
|
51
51
|
readonly tempDirManager: TmpDir;
|
|
52
|
+
private readonly buildFinalizeTasks;
|
|
53
|
+
addBuildFinalizeTask(task: () => Promise<void>): void;
|
|
52
54
|
private _repositoryInfo;
|
|
53
55
|
readonly options: PackagerOptions;
|
|
54
56
|
readonly debugLogger: DebugLogger;
|
package/out/packager.js
CHANGED
|
@@ -83,6 +83,9 @@ class Packager {
|
|
|
83
83
|
get appInfo() {
|
|
84
84
|
return this._appInfo;
|
|
85
85
|
}
|
|
86
|
+
addBuildFinalizeTask(task) {
|
|
87
|
+
this.buildFinalizeTasks.push(task);
|
|
88
|
+
}
|
|
86
89
|
get repositoryInfo() {
|
|
87
90
|
return this._repositoryInfo.value;
|
|
88
91
|
}
|
|
@@ -118,6 +121,10 @@ class Packager {
|
|
|
118
121
|
this.eventEmitter = new asyncEventEmitter_1.AsyncEventEmitter();
|
|
119
122
|
this._appInfo = null;
|
|
120
123
|
this.tempDirManager = new builder_util_1.TmpDir("packager");
|
|
124
|
+
// Tasks that must run after EVERY target has finished building — the only point at which the
|
|
125
|
+
// shared appOutDir can be mutated without racing a concurrent target that reads it. Used by NSIS
|
|
126
|
+
// to write elevate.exe into win-unpacked without it leaking into Squirrel/zip/etc. (see #9852).
|
|
127
|
+
this.buildFinalizeTasks = [];
|
|
121
128
|
this._repositoryInfo = new lazy_val_1.Lazy(() => (0, repositoryInfo_1.getRepositoryInfo)(this.projectDir, this.metadata, this.devMetadata));
|
|
122
129
|
this.debugLogger = new builder_util_1.DebugLogger(builder_util_1.log.isDebugEnabled);
|
|
123
130
|
this.runtimeEnvironmentVariables = {};
|
|
@@ -421,6 +428,14 @@ class Packager {
|
|
|
421
428
|
}
|
|
422
429
|
await target.finishBuild();
|
|
423
430
|
}
|
|
431
|
+
// Every target has now finished reading the shared appOutDir(s), so finalize tasks may safely
|
|
432
|
+
// mutate them (e.g. NSIS copying elevate.exe into win-unpacked — see #9852).
|
|
433
|
+
for (const task of this.buildFinalizeTasks) {
|
|
434
|
+
if (this.cancellationToken.cancelled) {
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
await task();
|
|
438
|
+
}
|
|
424
439
|
return platformToTarget;
|
|
425
440
|
}
|
|
426
441
|
async createHelper(platform) {
|
package/out/packager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packager.js","sourceRoot":"","sources":["../src/packager.ts"],"names":[],"mappings":";;;AAAA,+CAgBqB;AACrB,+DAA2E;AAC3E,uCAAoD;AACpD,qCAA8B;AAC9B,uCAA+B;AAC/B,2BAA4C;AAC5C,6BAA4B;AAC5B,uCAAmC;AACnC,sCAA0C;AAE1C,iCAA+D;AAC/D,oEAA6E;AAE7E,gEAA4D;AAI5D,uDAAmD;AACnD,2DAAgG;AAChG,iDAAmG;AACnG,wDAAkD;AAClD,4DAAuE;AACvE,0DAAyD;AACzD,4CAAgD;AAChD,sCAA8D;AAC9D,uCAA2C;AAC3C,gEAAyE;AACzE,qDAAuC;AACvC,mEAAwE;AAExE,KAAK,UAAU,mBAAmB,CAAC,aAA4B,EAAE,QAAkB;IACjF,IAAI,SAAS,GAAG,aAAa,CAAC,SAAS,CAAA;IACvC,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACtB,SAAS,GAAG,SAAS,CAAC,WAAW,EAAE,CAAA;IACrC,CAAC;IAED,IAAI,WAAW,GAAG,aAAa,CAAC,WAAW,CAAA;IAC3C,IAAI,S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C,GAAG,CAAC,EAAE;QACT,OAAO,IAAA,iBAAM,EAAC,GAAG,CAAC;aACf,IAAI,CAAC,GAAG,EAAE,CAAC,IAAA,gBAAK,EAAC,GAAG,EAAE,KAAK,CAAC,CAAC,oBAAoB,CAAC;aAClD,IAAI,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IACxC,CAAC,CAAC,CACL,CAAA;AACH,CAAC;AASD,SAAS,sBAAsB,CAAC,aAA4B;IAC1D,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,gCAAiB,EAAC,aAAa,CAAC,CAAC,CAAA;IACtD,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;QACtB,CAAC,CAAC,OAAO,GAAG,qBAAqB,CAAA;IACnC,CAAC;IACD,OAAO,IAAA,8BAAe,EAAC,CAAC,EAAE,IAAI,CAAC,CAAA;AACjC,CAAC","sourcesContent":["import {\n addValue,\n Arch,\n archFromString,\n AsyncTaskManager,\n DebugLogger,\n executeFinally,\n getArtifactArchName,\n InvalidConfigurationError,\n log,\n MAX_FILE_REQUESTS,\n orNullIfFileNotExist,\n sanitizeDirPath,\n safeStringifyJson,\n serializeToYaml,\n TmpDir,\n} from \"builder-util\"\nimport { CancellationToken, deepAssign, retry } from \"builder-util-runtime\"\nimport { chmod, mkdirs, outputFile } from \"fs-extra\"\nimport { isCI } from \"ci-info\"\nimport { Lazy } from \"lazy-val\"\nimport { release as getOsRelease } from \"os\"\nimport * as path from \"path\"\nimport { AppInfo } from \"./appInfo\"\nimport { readAsarJson } from \"./asar/asar\"\nimport { AfterExtractContext, AfterPackContext, BeforePackContext, Configuration, Hook } from \"./configuration\"\nimport { Platform, SourceRepositoryInfo, Target } from \"./core\"\nimport { createElectronFrameworkSupport } from \"./electron/ElectronFramework\"\nimport { Framework } from \"./Framework\"\nimport { LibUiFramework } from \"./frameworks/LibUiFramework\"\nimport { Metadata } from \"./options/metadata\"\nimport { ArtifactBuildStarted, ArtifactCreated, PackagerOptions } from \"./packagerApi\"\nimport { PlatformPackager } from \"./platformPackager\"\nimport { ProtonFramework } from \"./ProtonFramework\"\nimport { computeArchToTargetNamesMap, createTargets, NoOpTarget } from \"./targets/targetFactory\"\nimport { computeDefaultAppDirectory, getConfig, validateConfiguration } from \"./util/config/config\"\nimport { expandMacro } from \"./util/macroExpander\"\nimport { checkMetadata, readPackageJson } from \"./util/packageMetadata\"\nimport { getRepositoryInfo } from \"./util/repositoryInfo\"\nimport { resolveFunction } from \"./util/resolve\"\nimport { installOrRebuild, nodeGypRebuild } from \"./util/yarn\"\nimport { PACKAGE_VERSION } from \"./version\"\nimport { AsyncEventEmitter, HandlerType } from \"./util/asyncEventEmitter\"\nimport asyncPool from \"tiny-async-pool\"\nimport { determinePackageManagerEnv, PM } from \"./node-module-collector\"\n\nasync function createFrameworkInfo(configuration: Configuration, packager: Packager): Promise<Framework> {\n let framework = configuration.framework\n if (framework != null) {\n framework = framework.toLowerCase()\n }\n\n let nodeVersion = configuration.nodeVersion\n if (framework === \"electron\" || framework == null) {\n return await createElectronFrameworkSupport(configuration, packager)\n }\n\n if (nodeVersion == null || nodeVersion === \"current\") {\n nodeVersion = process.versions.node\n }\n\n const isUseLaunchUi = configuration.launchUiVersion !== false\n if (framework === \"proton\" || framework === \"proton-native\") {\n return new ProtonFramework(nodeVersion, packager.appInfo.productFilename, isUseLaunchUi)\n } else if (framework === \"libui\") {\n return new LibUiFramework(nodeVersion, packager.appInfo.productFilename, isUseLaunchUi)\n } else {\n throw new InvalidConfigurationError(`Unknown framework: ${framework}`)\n }\n}\n\ntype PackagerEvents = {\n artifactBuildStarted: Hook<ArtifactBuildStarted, void>\n\n beforePack: Hook<BeforePackContext, void>\n afterExtract: Hook<AfterExtractContext, void>\n afterPack: Hook<AfterPackContext, void>\n afterSign: Hook<AfterPackContext, void>\n\n artifactBuildCompleted: Hook<ArtifactCreated, void>\n\n msiProjectCreated: Hook<string, void>\n appxManifestCreated: Hook<string, void>\n\n // internal-use only, prefer usage of `artifactBuildCompleted`\n artifactCreated: Hook<ArtifactCreated, void>\n}\n\nexport class Packager {\n readonly projectDir: string\n\n private _appDir: string\n get appDir(): string {\n return this._appDir\n }\n\n private readonly _packageManager: Lazy<{ pm: PM; workspaceRoot: Promise<string | undefined> }>\n async getPackageManager(): Promise<PM> {\n return (await this._packageManager.value).pm\n }\n async getWorkspaceRoot(): Promise<string> {\n return (await (await this._packageManager.value).workspaceRoot) || this.projectDir\n }\n\n /** Stores original metadata merged with extraMetadata from configuration. */\n private _metadata: Metadata | null = null\n get metadata(): Metadata {\n return this._metadata!\n }\n\n /** Stores original metadata from package.json before merging with extraMetadata. */\n private _originalMetadata: Metadata | null = null\n get originalMetadata(): Metadata {\n return this._originalMetadata!\n }\n\n /** The \"name\" field from package.json. */\n get nodePackageName() {\n return this.originalMetadata.name!\n }\n\n private _nodeModulesHandledExternally = false\n\n get areNodeModulesHandledExternally(): boolean {\n return this._nodeModulesHandledExternally\n }\n\n private _isPrepackedAppAsar = false\n\n get isPrepackedAppAsar(): boolean {\n return this._isPrepackedAppAsar\n }\n\n private _devMetadata: Metadata | null = null\n get devMetadata(): Metadata | null {\n return this._devMetadata\n }\n\n private _configuration: Configuration | null = null\n\n get config(): Configuration {\n return this._configuration!\n }\n\n isTwoPackageJsonProjectLayoutUsed = false\n\n private readonly eventEmitter = new AsyncEventEmitter<PackagerEvents>()\n\n _appInfo: AppInfo | null = null\n get appInfo(): AppInfo {\n return this._appInfo!\n }\n\n readonly tempDirManager = new TmpDir(\"packager\")\n\n private _repositoryInfo = new Lazy<SourceRepositoryInfo | null>(() => getRepositoryInfo(this.projectDir, this.metadata, this.devMetadata))\n\n readonly options: PackagerOptions\n\n readonly debugLogger = new DebugLogger(log.isDebugEnabled)\n\n get repositoryInfo(): Promise<SourceRepositoryInfo | null> {\n return this._repositoryInfo.value\n }\n\n private runtimeEnvironmentVariables: NodeJS.ProcessEnv = {}\n\n stageDirPathCustomizer: (target: Target, packager: PlatformPackager<any>, arch: Arch) => string = (target, packager, arch) => {\n return path.join(target.outDir, `__${target.name}-${getArtifactArchName(arch, target.name)}`)\n }\n\n private _buildResourcesDir: string | null = null\n\n get buildResourcesDir(): string {\n let result = this._buildResourcesDir\n if (result == null) {\n result = path.resolve(this.projectDir, this.relativeBuildResourcesDirname)\n this._buildResourcesDir = result\n }\n return result\n }\n\n get relativeBuildResourcesDirname(): string {\n return this.config.directories!.buildResources!\n }\n\n private _framework: Framework | null = null\n get framework(): Framework {\n return this._framework!\n }\n\n private readonly toDispose: Array<() => Promise<void>> = []\n\n disposeOnBuildFinish(disposer: () => Promise<void>) {\n this.toDispose.push(disposer)\n }\n\n //noinspection JSUnusedGlobalSymbols\n constructor(\n options: PackagerOptions,\n readonly cancellationToken = new CancellationToken()\n ) {\n if (\"devMetadata\" in options) {\n throw new InvalidConfigurationError(\"devMetadata in the options is deprecated, please use config instead\")\n }\n if (\"extraMetadata\" in options) {\n throw new InvalidConfigurationError(\"extraMetadata in the options is deprecated, please use config.extraMetadata instead\")\n }\n\n const targets = options.targets || new Map<Platform, Map<Arch, Array<string>>>()\n if (options.targets == null) {\n options.targets = targets\n }\n\n function processTargets(platform: Platform, types: Array<string>) {\n function commonArch(currentIfNotSpecified: boolean): Array<Arch> {\n const result = Array<Arch>()\n return result.length === 0 && currentIfNotSpecified ? [archFromString(process.arch)] : result\n }\n\n let archToType = targets.get(platform)\n if (archToType == null) {\n archToType = new Map<Arch, Array<string>>()\n targets.set(platform, archToType)\n }\n\n if (types.length === 0) {\n for (const arch of commonArch(false)) {\n archToType.set(arch, [])\n }\n return\n }\n\n for (const type of types) {\n const suffixPos = type.lastIndexOf(\":\")\n if (suffixPos > 0) {\n addValue(archToType, archFromString(type.substring(suffixPos + 1)), type.substring(0, suffixPos))\n } else {\n for (const arch of commonArch(true)) {\n addValue(archToType, arch, type)\n }\n }\n }\n }\n\n if (options.mac != null) {\n processTargets(Platform.MAC, options.mac)\n }\n if (options.linux != null) {\n processTargets(Platform.LINUX, options.linux)\n }\n if (options.win != null) {\n processTargets(Platform.WINDOWS, options.win)\n }\n\n this.projectDir = sanitizeDirPath(options.projectDir == null ? process.cwd() : options.projectDir)\n this._appDir = this.projectDir\n this._packageManager = determinePackageManagerEnv({ projectDir: this.projectDir, appDir: this.appDir, workspaceRoot: undefined })\n\n this.options = {\n ...options,\n prepackaged: options.prepackaged == null ? null : sanitizeDirPath(path.resolve(this.projectDir, options.prepackaged)),\n }\n\n log.info({ version: PACKAGE_VERSION, os: getOsRelease() }, \"electron-builder\")\n }\n\n private async addPackagerEventHandlers() {\n const { type } = this.appInfo\n const root = await this.getWorkspaceRoot()\n this.eventEmitter.on(\"artifactBuildStarted\", await resolveFunction(type, this.config.artifactBuildStarted, \"artifactBuildStarted\", root), \"user\")\n this.eventEmitter.on(\"artifactBuildCompleted\", await resolveFunction(type, this.config.artifactBuildCompleted, \"artifactBuildCompleted\", root), \"user\")\n\n this.eventEmitter.on(\"appxManifestCreated\", await resolveFunction(type, this.config.appxManifestCreated, \"appxManifestCreated\", root), \"user\")\n this.eventEmitter.on(\"msiProjectCreated\", await resolveFunction(type, this.config.msiProjectCreated, \"msiProjectCreated\", root), \"user\")\n\n this.eventEmitter.on(\"beforePack\", await resolveFunction(type, this.config.beforePack, \"beforePack\", root), \"user\")\n this.eventEmitter.on(\"afterExtract\", await resolveFunction(type, this.config.afterExtract, \"afterExtract\", root), \"user\")\n this.eventEmitter.on(\"afterPack\", await resolveFunction(type, this.config.afterPack, \"afterPack\", root), \"user\")\n this.eventEmitter.on(\"afterSign\", await resolveFunction(type, this.config.afterSign, \"afterSign\", root), \"user\")\n }\n\n onAfterPack(handler: PackagerEvents[\"afterPack\"]): Packager {\n this.eventEmitter.on(\"afterPack\", handler)\n return this\n }\n\n onArtifactCreated(handler: PackagerEvents[\"artifactCreated\"]): Packager {\n this.eventEmitter.on(\"artifactCreated\", handler)\n return this\n }\n\n filterPackagerEventListeners(event: keyof PackagerEvents, type: HandlerType | undefined) {\n return this.eventEmitter.filterListeners(event, type)\n }\n\n clearPackagerEventListeners() {\n this.eventEmitter.clear()\n }\n\n async emitArtifactBuildStarted(event: ArtifactBuildStarted, logFields?: any) {\n log.info(\n logFields || {\n target: event.targetPresentableName,\n arch: event.arch == null ? null : Arch[event.arch],\n file: log.filePath(event.file),\n },\n \"building\"\n )\n await this.eventEmitter.emit(\"artifactBuildStarted\", event)\n }\n\n /**\n * Only for sub artifacts (update info), for main artifacts use `callArtifactBuildCompleted`.\n */\n async emitArtifactCreated(event: ArtifactCreated) {\n await this.eventEmitter.emit(\"artifactCreated\", event)\n }\n\n async emitArtifactBuildCompleted(event: ArtifactCreated) {\n await this.eventEmitter.emit(\"artifactBuildCompleted\", event)\n await this.emitArtifactCreated(event)\n }\n\n async emitAppxManifestCreated(path: string) {\n await this.eventEmitter.emit(\"appxManifestCreated\", path)\n }\n\n async emitMsiProjectCreated(path: string) {\n await this.eventEmitter.emit(\"msiProjectCreated\", path)\n }\n\n async emitBeforePack(context: BeforePackContext) {\n await this.eventEmitter.emit(\"beforePack\", context)\n }\n\n async emitAfterPack(context: AfterPackContext) {\n await this.eventEmitter.emit(\"afterPack\", context)\n }\n\n async emitAfterSign(context: AfterPackContext) {\n await this.eventEmitter.emit(\"afterSign\", context)\n }\n\n async emitAfterExtract(context: AfterPackContext) {\n await this.eventEmitter.emit(\"afterExtract\", context)\n }\n\n async validateConfig(): Promise<void> {\n let configPath: string | null = null\n let configFromOptions = this.options.config\n if (typeof configFromOptions === \"string\") {\n // it is a path to config file\n configPath = configFromOptions\n configFromOptions = null\n } else if (configFromOptions != null && typeof configFromOptions.extends === \"string\" && configFromOptions.extends.includes(\".\")) {\n configPath = configFromOptions.extends\n delete configFromOptions.extends\n }\n\n const projectDir = this.projectDir\n\n const devPackageFile = path.join(projectDir, \"package.json\")\n this._devMetadata = await orNullIfFileNotExist(readPackageJson(devPackageFile))\n\n const devMetadata = this.devMetadata\n const configuration = await getConfig(projectDir, configPath, configFromOptions, new Lazy(() => Promise.resolve(devMetadata)))\n\n log.debug({ config: getSafeEffectiveConfig(configuration) }, \"effective config\")\n\n this._appDir = await computeDefaultAppDirectory(projectDir, configuration.directories!.app)\n this.isTwoPackageJsonProjectLayoutUsed = this._appDir !== projectDir\n\n const appPackageFile = this.isTwoPackageJsonProjectLayoutUsed ? path.join(this.appDir, \"package.json\") : devPackageFile\n\n // tslint:disable:prefer-conditional-expression\n if (this.devMetadata != null && !this.isTwoPackageJsonProjectLayoutUsed) {\n this._metadata = this.devMetadata\n } else {\n this._metadata = await this.readProjectMetadataIfTwoPackageStructureOrPrepacked(appPackageFile)\n }\n this._originalMetadata = deepAssign({}, this._metadata)\n deepAssign(this._metadata, configuration.extraMetadata)\n\n if (this.isTwoPackageJsonProjectLayoutUsed) {\n log.debug({ devPackageFile, appPackageFile }, \"two package.json structure is used\")\n }\n checkMetadata(this.metadata, this.devMetadata, appPackageFile, devPackageFile)\n\n await validateConfiguration(configuration, this.debugLogger)\n\n this._configuration = configuration\n this._devMetadata = devMetadata\n }\n\n // external caller of this method always uses isTwoPackageJsonProjectLayoutUsed=false and appDir=projectDir, no way (and need) to use another values\n async build(repositoryInfo?: SourceRepositoryInfo): Promise<BuildResult> {\n await this.validateConfig()\n\n if (repositoryInfo != null) {\n this._repositoryInfo.value = Promise.resolve(repositoryInfo)\n }\n\n this._appInfo = new AppInfo(this, null)\n await this.addPackagerEventHandlers()\n\n this._framework = await createFrameworkInfo(this.config, this)\n\n const commonOutDirWithoutPossibleOsMacro = path.resolve(\n this.projectDir,\n expandMacro(this.config.directories!.output!, null, this._appInfo, {\n os: \"\",\n })\n )\n\n if (!isCI && (process.stdout as any).isTTY) {\n const effectiveConfigFile = path.join(commonOutDirWithoutPossibleOsMacro, \"builder-effective-config.yaml\")\n log.info({ file: log.filePath(effectiveConfigFile) }, \"writing effective config\")\n await outputFile(effectiveConfigFile, getSafeEffectiveConfig(this.config))\n }\n\n // because artifact event maybe dispatched several times for different publish providers\n const artifactPaths = new Set<string>()\n this.onArtifactCreated(event => {\n if (event.file != null) {\n artifactPaths.add(event.file)\n }\n })\n\n this.disposeOnBuildFinish(() =>\n retry(() => this.tempDirManager.cleanup(), {\n retries: 2,\n interval: 2000,\n backoff: 2000,\n cancellationToken: this.cancellationToken,\n shouldRetry: e => {\n const message: string = e?.message || \"\"\n const code = e?.code\n // windows file locks\n const resourceIsBusy = message.includes(\"EBUSY\") || code === \"EBUSY\"\n if (resourceIsBusy) {\n log.debug({ error: message || code }, \"retrying temporary directory cleanup\")\n return true\n }\n return false\n },\n })\n )\n\n const platformToTargets = await executeFinally(this.doBuild(), async () => {\n if (this.debugLogger.isEnabled) {\n await this.debugLogger.save(path.join(commonOutDirWithoutPossibleOsMacro, \"builder-debug.yml\"))\n }\n\n const toDispose = this.toDispose.slice()\n this.toDispose.length = 0\n for (const disposer of toDispose) {\n await disposer().catch((e: any) => {\n log.warn({ error: e }, \"cannot dispose\")\n })\n }\n })\n\n return {\n outDir: commonOutDirWithoutPossibleOsMacro,\n artifactPaths: Array.from(artifactPaths),\n platformToTargets,\n configuration: this.config,\n }\n }\n\n private async readProjectMetadataIfTwoPackageStructureOrPrepacked(appPackageFile: string): Promise<Metadata> {\n let data = await orNullIfFileNotExist(readPackageJson(appPackageFile))\n if (data != null) {\n return data\n }\n\n data = await orNullIfFileNotExist(readAsarJson(path.join(this.projectDir, \"app.asar\"), \"package.json\"))\n if (data != null) {\n this._isPrepackedAppAsar = true\n return data\n }\n\n throw new Error(`Cannot find package.json in the ${path.dirname(appPackageFile)}`)\n }\n\n private async doBuild(): Promise<Map<Platform, Map<string, Target>>> {\n const taskManager = new AsyncTaskManager(this.cancellationToken)\n const syncTargetsIfAny = [] as Target[]\n\n const platformToTarget = new Map<Platform, Map<string, Target>>()\n const createdOutDirs = new Set<string>()\n\n for (const [platform, archToType] of this.options.targets!) {\n if (this.cancellationToken.cancelled) {\n break\n }\n\n if (platform === Platform.MAC && process.platform === Platform.WINDOWS.nodeName) {\n throw new InvalidConfigurationError(\"Build for macOS is supported only on macOS, please see https://electron.build/multi-platform-build\")\n }\n\n const packager = await this.createHelper(platform)\n const nameToTarget: Map<string, Target> = new Map()\n platformToTarget.set(platform, nameToTarget)\n\n let poolCount = Math.floor(packager.config.concurrency?.jobs || 1)\n if (poolCount < 1) {\n log.warn({ concurrency: poolCount }, \"concurrency is invalid, overriding with job count: 1\")\n poolCount = 1\n } else if (poolCount > MAX_FILE_REQUESTS) {\n log.warn(\n { concurrency: poolCount, MAX_FILE_REQUESTS },\n `job concurrency is greater than recommended MAX_FILE_REQUESTS, this may lead to File Descriptor errors (too many files open). Proceed with caution (e.g. this is an experimental feature)`\n )\n }\n const packPromises: Promise<any>[] = []\n\n for (const [arch, targetNames] of computeArchToTargetNamesMap(archToType, packager, platform)) {\n if (this.cancellationToken.cancelled) {\n break\n }\n\n // support os and arch macro in output value\n const outDir = path.resolve(this.projectDir, packager.expandMacro(this.config.directories!.output!, Arch[arch]))\n const targetList = createTargets(nameToTarget, targetNames.length === 0 ? packager.defaultTarget : targetNames, outDir, packager)\n await createOutDirIfNeed(targetList, createdOutDirs)\n const promise = packager.pack(outDir, arch, targetList, taskManager)\n if (poolCount < 2) {\n await promise\n } else {\n packPromises.push(promise)\n }\n }\n\n await asyncPool(poolCount, packPromises, async it => {\n if (this.cancellationToken.cancelled) {\n return\n }\n await it\n })\n\n if (this.cancellationToken.cancelled) {\n break\n }\n\n for (const target of nameToTarget.values()) {\n if (target.isAsyncSupported) {\n taskManager.addTask(target.finishBuild())\n } else {\n syncTargetsIfAny.push(target)\n }\n }\n }\n\n await taskManager.awaitTasks()\n\n for (const target of syncTargetsIfAny) {\n if (this.cancellationToken.cancelled) {\n break\n }\n await target.finishBuild()\n }\n return platformToTarget\n }\n\n private async createHelper(platform: Platform): Promise<PlatformPackager<any>> {\n if (this.options.platformPackagerFactory != null) {\n return this.options.platformPackagerFactory(this, platform)\n }\n\n switch (platform) {\n case Platform.MAC: {\n const helperClass = (await import(\"./macPackager\")).MacPackager\n return new helperClass(this)\n }\n\n case Platform.WINDOWS: {\n const helperClass = (await import(\"./winPackager\")).WinPackager\n return new helperClass(this)\n }\n\n case Platform.LINUX:\n return new (await import(\"./linuxPackager\")).LinuxPackager(this)\n\n default:\n throw new Error(`Unknown platform: ${platform}`)\n }\n }\n\n public async installAppDependencies(platform: Platform, arch: Arch): Promise<any> {\n if (this.options.prepackaged != null || !this.framework.isNpmRebuildRequired) {\n return\n }\n\n const frameworkInfo = { version: this.framework.version, useCustomDist: true }\n const config = this.config\n if (config.nodeGypRebuild === true) {\n await nodeGypRebuild(platform.nodeName, Arch[arch], frameworkInfo)\n }\n\n if (config.npmRebuild === false) {\n log.info({ reason: \"npmRebuild is set to false\" }, \"skipped dependencies rebuild\")\n return\n }\n\n const beforeBuild = await resolveFunction(this.appInfo.type, config.beforeBuild, \"beforeBuild\", await this.getWorkspaceRoot())\n if (beforeBuild != null) {\n const performDependenciesInstallOrRebuild = await beforeBuild({\n appDir: this.appDir,\n electronVersion: this.config.electronVersion!,\n platform,\n arch: Arch[arch],\n })\n\n // If beforeBuild resolves to false, it means that handling node_modules is done outside of electron-builder.\n this._nodeModulesHandledExternally = !performDependenciesInstallOrRebuild\n if (!performDependenciesInstallOrRebuild) {\n return\n }\n }\n\n if (config.buildDependenciesFromSource === true && platform.nodeName !== process.platform) {\n log.info({ reason: \"platform is different and buildDependenciesFromSource is set to true\" }, \"skipped dependencies rebuild\")\n } else {\n await installOrRebuild(\n config,\n { appDir: this.appDir, projectDir: this.projectDir, workspaceRoot: await this.getWorkspaceRoot() },\n {\n frameworkInfo,\n platform: platform.nodeName,\n arch: Arch[arch],\n },\n false,\n this.runtimeEnvironmentVariables\n )\n }\n }\n}\n\nfunction createOutDirIfNeed(targetList: Array<Target>, createdOutDirs: Set<string>): Promise<any> {\n const ourDirs = new Set<string>()\n for (const target of targetList) {\n // noinspection SuspiciousInstanceOfGuard\n if (target instanceof NoOpTarget) {\n continue\n }\n\n const outDir = target.outDir\n if (!createdOutDirs.has(outDir)) {\n ourDirs.add(outDir)\n }\n }\n\n if (ourDirs.size === 0) {\n return Promise.resolve()\n }\n\n return Promise.all(\n Array.from(ourDirs)\n .sort()\n .map(dir => {\n return mkdirs(dir)\n .then(() => chmod(dir, 0o755) /* set explicitly */)\n .then(() => createdOutDirs.add(dir))\n })\n )\n}\n\nexport interface BuildResult {\n readonly outDir: string\n readonly artifactPaths: Array<string>\n readonly platformToTargets: Map<Platform, Map<string, Target>>\n readonly configuration: Configuration\n}\n\nfunction getSafeEffectiveConfig(configuration: Configuration): string {\n const o = JSON.parse(safeStringifyJson(configuration))\n if (o.cscLink != null) {\n o.cscLink = \"<hidden by builder>\"\n }\n return serializeToYaml(o, true)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"packager.js","sourceRoot":"","sources":["../src/packager.ts"],"names":[],"mappings":";;;AAAA,+CAgBqB;AACrB,+DAA2E;AAC3E,uCAAoD;AACpD,qCAA8B;AAC9B,uCAA+B;AAC/B,2BAA4C;AAC5C,6BAA4B;AAC5B,uCAAmC;AACnC,sCAA0C;AAE1C,iCAA+D;AAC/D,oEAA6E;AAE7E,gEAA4D;AAI5D,uDAAmD;AACnD,2DAAgG;AAChG,iDAAmG;AACnG,wDAAkD;AAClD,4DAAuE;AACvE,0DAAyD;AACzD,4CAAgD;AAChD,sCAA8D;AAC9D,uCAA2C;AAC3C,gEAAyE;AACzE,qDAAuC;AACvC,mEAAwE;AAExE,KAAK,UAAU,mBAAmB,CAAC,aAA4B,EAAE,QAAkB;IACjF,IAAI,SAAS,GAAG,aAAa,CAAC,SAAS,CAAA;IACvC,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACtB,SAAS,GAAG,SAAS,CAAC,WAAW,EAAE,CAAA;IACrC,CAAC;IAED,IAAI,WAAW,GAAG,aAAa,CAAC,WAAW,CAAA;IAC3C,IAAI,SAAS,KAAK,UAAU,IAAI,SAAS,IAAI,IAAI,EA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AAA;QAC5B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACrB,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IAC1B,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAChB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;SAChB,IAAI,EAAE;SACN,GAAG,CAAC,GAAG,CAAC,EAAE;QACT,OAAO,IAAA,iBAAM,EAAC,GAAG,CAAC;aACf,IAAI,CAAC,GAAG,EAAE,CAAC,IAAA,gBAAK,EAAC,GAAG,EAAE,KAAK,CAAC,CAAC,oBAAoB,CAAC;aAClD,IAAI,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IACxC,CAAC,CAAC,CACL,CAAA;AACH,CAAC;AASD,SAAS,sBAAsB,CAAC,aAA4B;IAC1D,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,gCAAiB,EAAC,aAAa,CAAC,CAAC,CAAA;IACtD,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;QACtB,CAAC,CAAC,OAAO,GAAG,qBAAqB,CAAA;IACnC,CAAC;IACD,OAAO,IAAA,8BAAe,EAAC,CAAC,EAAE,IAAI,CAAC,CAAA;AACjC,CAAC","sourcesContent":["import {\n addValue,\n Arch,\n archFromString,\n AsyncTaskManager,\n DebugLogger,\n executeFinally,\n getArtifactArchName,\n InvalidConfigurationError,\n log,\n MAX_FILE_REQUESTS,\n orNullIfFileNotExist,\n sanitizeDirPath,\n safeStringifyJson,\n serializeToYaml,\n TmpDir,\n} from \"builder-util\"\nimport { CancellationToken, deepAssign, retry } from \"builder-util-runtime\"\nimport { chmod, mkdirs, outputFile } from \"fs-extra\"\nimport { isCI } from \"ci-info\"\nimport { Lazy } from \"lazy-val\"\nimport { release as getOsRelease } from \"os\"\nimport * as path from \"path\"\nimport { AppInfo } from \"./appInfo\"\nimport { readAsarJson } from \"./asar/asar\"\nimport { AfterExtractContext, AfterPackContext, BeforePackContext, Configuration, Hook } from \"./configuration\"\nimport { Platform, SourceRepositoryInfo, Target } from \"./core\"\nimport { createElectronFrameworkSupport } from \"./electron/ElectronFramework\"\nimport { Framework } from \"./Framework\"\nimport { LibUiFramework } from \"./frameworks/LibUiFramework\"\nimport { Metadata } from \"./options/metadata\"\nimport { ArtifactBuildStarted, ArtifactCreated, PackagerOptions } from \"./packagerApi\"\nimport { PlatformPackager } from \"./platformPackager\"\nimport { ProtonFramework } from \"./ProtonFramework\"\nimport { computeArchToTargetNamesMap, createTargets, NoOpTarget } from \"./targets/targetFactory\"\nimport { computeDefaultAppDirectory, getConfig, validateConfiguration } from \"./util/config/config\"\nimport { expandMacro } from \"./util/macroExpander\"\nimport { checkMetadata, readPackageJson } from \"./util/packageMetadata\"\nimport { getRepositoryInfo } from \"./util/repositoryInfo\"\nimport { resolveFunction } from \"./util/resolve\"\nimport { installOrRebuild, nodeGypRebuild } from \"./util/yarn\"\nimport { PACKAGE_VERSION } from \"./version\"\nimport { AsyncEventEmitter, HandlerType } from \"./util/asyncEventEmitter\"\nimport asyncPool from \"tiny-async-pool\"\nimport { determinePackageManagerEnv, PM } from \"./node-module-collector\"\n\nasync function createFrameworkInfo(configuration: Configuration, packager: Packager): Promise<Framework> {\n let framework = configuration.framework\n if (framework != null) {\n framework = framework.toLowerCase()\n }\n\n let nodeVersion = configuration.nodeVersion\n if (framework === \"electron\" || framework == null) {\n return await createElectronFrameworkSupport(configuration, packager)\n }\n\n if (nodeVersion == null || nodeVersion === \"current\") {\n nodeVersion = process.versions.node\n }\n\n const isUseLaunchUi = configuration.launchUiVersion !== false\n if (framework === \"proton\" || framework === \"proton-native\") {\n return new ProtonFramework(nodeVersion, packager.appInfo.productFilename, isUseLaunchUi)\n } else if (framework === \"libui\") {\n return new LibUiFramework(nodeVersion, packager.appInfo.productFilename, isUseLaunchUi)\n } else {\n throw new InvalidConfigurationError(`Unknown framework: ${framework}`)\n }\n}\n\ntype PackagerEvents = {\n artifactBuildStarted: Hook<ArtifactBuildStarted, void>\n\n beforePack: Hook<BeforePackContext, void>\n afterExtract: Hook<AfterExtractContext, void>\n afterPack: Hook<AfterPackContext, void>\n afterSign: Hook<AfterPackContext, void>\n\n artifactBuildCompleted: Hook<ArtifactCreated, void>\n\n msiProjectCreated: Hook<string, void>\n appxManifestCreated: Hook<string, void>\n\n // internal-use only, prefer usage of `artifactBuildCompleted`\n artifactCreated: Hook<ArtifactCreated, void>\n}\n\nexport class Packager {\n readonly projectDir: string\n\n private _appDir: string\n get appDir(): string {\n return this._appDir\n }\n\n private readonly _packageManager: Lazy<{ pm: PM; workspaceRoot: Promise<string | undefined> }>\n async getPackageManager(): Promise<PM> {\n return (await this._packageManager.value).pm\n }\n async getWorkspaceRoot(): Promise<string> {\n return (await (await this._packageManager.value).workspaceRoot) || this.projectDir\n }\n\n /** Stores original metadata merged with extraMetadata from configuration. */\n private _metadata: Metadata | null = null\n get metadata(): Metadata {\n return this._metadata!\n }\n\n /** Stores original metadata from package.json before merging with extraMetadata. */\n private _originalMetadata: Metadata | null = null\n get originalMetadata(): Metadata {\n return this._originalMetadata!\n }\n\n /** The \"name\" field from package.json. */\n get nodePackageName() {\n return this.originalMetadata.name!\n }\n\n private _nodeModulesHandledExternally = false\n\n get areNodeModulesHandledExternally(): boolean {\n return this._nodeModulesHandledExternally\n }\n\n private _isPrepackedAppAsar = false\n\n get isPrepackedAppAsar(): boolean {\n return this._isPrepackedAppAsar\n }\n\n private _devMetadata: Metadata | null = null\n get devMetadata(): Metadata | null {\n return this._devMetadata\n }\n\n private _configuration: Configuration | null = null\n\n get config(): Configuration {\n return this._configuration!\n }\n\n isTwoPackageJsonProjectLayoutUsed = false\n\n private readonly eventEmitter = new AsyncEventEmitter<PackagerEvents>()\n\n _appInfo: AppInfo | null = null\n get appInfo(): AppInfo {\n return this._appInfo!\n }\n\n readonly tempDirManager = new TmpDir(\"packager\")\n\n // Tasks that must run after EVERY target has finished building — the only point at which the\n // shared appOutDir can be mutated without racing a concurrent target that reads it. Used by NSIS\n // to write elevate.exe into win-unpacked without it leaking into Squirrel/zip/etc. (see #9852).\n private readonly buildFinalizeTasks: Array<() => Promise<void>> = []\n\n addBuildFinalizeTask(task: () => Promise<void>): void {\n this.buildFinalizeTasks.push(task)\n }\n\n private _repositoryInfo = new Lazy<SourceRepositoryInfo | null>(() => getRepositoryInfo(this.projectDir, this.metadata, this.devMetadata))\n\n readonly options: PackagerOptions\n\n readonly debugLogger = new DebugLogger(log.isDebugEnabled)\n\n get repositoryInfo(): Promise<SourceRepositoryInfo | null> {\n return this._repositoryInfo.value\n }\n\n private runtimeEnvironmentVariables: NodeJS.ProcessEnv = {}\n\n stageDirPathCustomizer: (target: Target, packager: PlatformPackager<any>, arch: Arch) => string = (target, packager, arch) => {\n return path.join(target.outDir, `__${target.name}-${getArtifactArchName(arch, target.name)}`)\n }\n\n private _buildResourcesDir: string | null = null\n\n get buildResourcesDir(): string {\n let result = this._buildResourcesDir\n if (result == null) {\n result = path.resolve(this.projectDir, this.relativeBuildResourcesDirname)\n this._buildResourcesDir = result\n }\n return result\n }\n\n get relativeBuildResourcesDirname(): string {\n return this.config.directories!.buildResources!\n }\n\n private _framework: Framework | null = null\n get framework(): Framework {\n return this._framework!\n }\n\n private readonly toDispose: Array<() => Promise<void>> = []\n\n disposeOnBuildFinish(disposer: () => Promise<void>) {\n this.toDispose.push(disposer)\n }\n\n //noinspection JSUnusedGlobalSymbols\n constructor(\n options: PackagerOptions,\n readonly cancellationToken = new CancellationToken()\n ) {\n if (\"devMetadata\" in options) {\n throw new InvalidConfigurationError(\"devMetadata in the options is deprecated, please use config instead\")\n }\n if (\"extraMetadata\" in options) {\n throw new InvalidConfigurationError(\"extraMetadata in the options is deprecated, please use config.extraMetadata instead\")\n }\n\n const targets = options.targets || new Map<Platform, Map<Arch, Array<string>>>()\n if (options.targets == null) {\n options.targets = targets\n }\n\n function processTargets(platform: Platform, types: Array<string>) {\n function commonArch(currentIfNotSpecified: boolean): Array<Arch> {\n const result = Array<Arch>()\n return result.length === 0 && currentIfNotSpecified ? [archFromString(process.arch)] : result\n }\n\n let archToType = targets.get(platform)\n if (archToType == null) {\n archToType = new Map<Arch, Array<string>>()\n targets.set(platform, archToType)\n }\n\n if (types.length === 0) {\n for (const arch of commonArch(false)) {\n archToType.set(arch, [])\n }\n return\n }\n\n for (const type of types) {\n const suffixPos = type.lastIndexOf(\":\")\n if (suffixPos > 0) {\n addValue(archToType, archFromString(type.substring(suffixPos + 1)), type.substring(0, suffixPos))\n } else {\n for (const arch of commonArch(true)) {\n addValue(archToType, arch, type)\n }\n }\n }\n }\n\n if (options.mac != null) {\n processTargets(Platform.MAC, options.mac)\n }\n if (options.linux != null) {\n processTargets(Platform.LINUX, options.linux)\n }\n if (options.win != null) {\n processTargets(Platform.WINDOWS, options.win)\n }\n\n this.projectDir = sanitizeDirPath(options.projectDir == null ? process.cwd() : options.projectDir)\n this._appDir = this.projectDir\n this._packageManager = determinePackageManagerEnv({ projectDir: this.projectDir, appDir: this.appDir, workspaceRoot: undefined })\n\n this.options = {\n ...options,\n prepackaged: options.prepackaged == null ? null : sanitizeDirPath(path.resolve(this.projectDir, options.prepackaged)),\n }\n\n log.info({ version: PACKAGE_VERSION, os: getOsRelease() }, \"electron-builder\")\n }\n\n private async addPackagerEventHandlers() {\n const { type } = this.appInfo\n const root = await this.getWorkspaceRoot()\n this.eventEmitter.on(\"artifactBuildStarted\", await resolveFunction(type, this.config.artifactBuildStarted, \"artifactBuildStarted\", root), \"user\")\n this.eventEmitter.on(\"artifactBuildCompleted\", await resolveFunction(type, this.config.artifactBuildCompleted, \"artifactBuildCompleted\", root), \"user\")\n\n this.eventEmitter.on(\"appxManifestCreated\", await resolveFunction(type, this.config.appxManifestCreated, \"appxManifestCreated\", root), \"user\")\n this.eventEmitter.on(\"msiProjectCreated\", await resolveFunction(type, this.config.msiProjectCreated, \"msiProjectCreated\", root), \"user\")\n\n this.eventEmitter.on(\"beforePack\", await resolveFunction(type, this.config.beforePack, \"beforePack\", root), \"user\")\n this.eventEmitter.on(\"afterExtract\", await resolveFunction(type, this.config.afterExtract, \"afterExtract\", root), \"user\")\n this.eventEmitter.on(\"afterPack\", await resolveFunction(type, this.config.afterPack, \"afterPack\", root), \"user\")\n this.eventEmitter.on(\"afterSign\", await resolveFunction(type, this.config.afterSign, \"afterSign\", root), \"user\")\n }\n\n onAfterPack(handler: PackagerEvents[\"afterPack\"]): Packager {\n this.eventEmitter.on(\"afterPack\", handler)\n return this\n }\n\n onArtifactCreated(handler: PackagerEvents[\"artifactCreated\"]): Packager {\n this.eventEmitter.on(\"artifactCreated\", handler)\n return this\n }\n\n filterPackagerEventListeners(event: keyof PackagerEvents, type: HandlerType | undefined) {\n return this.eventEmitter.filterListeners(event, type)\n }\n\n clearPackagerEventListeners() {\n this.eventEmitter.clear()\n }\n\n async emitArtifactBuildStarted(event: ArtifactBuildStarted, logFields?: any) {\n log.info(\n logFields || {\n target: event.targetPresentableName,\n arch: event.arch == null ? null : Arch[event.arch],\n file: log.filePath(event.file),\n },\n \"building\"\n )\n await this.eventEmitter.emit(\"artifactBuildStarted\", event)\n }\n\n /**\n * Only for sub artifacts (update info), for main artifacts use `callArtifactBuildCompleted`.\n */\n async emitArtifactCreated(event: ArtifactCreated) {\n await this.eventEmitter.emit(\"artifactCreated\", event)\n }\n\n async emitArtifactBuildCompleted(event: ArtifactCreated) {\n await this.eventEmitter.emit(\"artifactBuildCompleted\", event)\n await this.emitArtifactCreated(event)\n }\n\n async emitAppxManifestCreated(path: string) {\n await this.eventEmitter.emit(\"appxManifestCreated\", path)\n }\n\n async emitMsiProjectCreated(path: string) {\n await this.eventEmitter.emit(\"msiProjectCreated\", path)\n }\n\n async emitBeforePack(context: BeforePackContext) {\n await this.eventEmitter.emit(\"beforePack\", context)\n }\n\n async emitAfterPack(context: AfterPackContext) {\n await this.eventEmitter.emit(\"afterPack\", context)\n }\n\n async emitAfterSign(context: AfterPackContext) {\n await this.eventEmitter.emit(\"afterSign\", context)\n }\n\n async emitAfterExtract(context: AfterPackContext) {\n await this.eventEmitter.emit(\"afterExtract\", context)\n }\n\n async validateConfig(): Promise<void> {\n let configPath: string | null = null\n let configFromOptions = this.options.config\n if (typeof configFromOptions === \"string\") {\n // it is a path to config file\n configPath = configFromOptions\n configFromOptions = null\n } else if (configFromOptions != null && typeof configFromOptions.extends === \"string\" && configFromOptions.extends.includes(\".\")) {\n configPath = configFromOptions.extends\n delete configFromOptions.extends\n }\n\n const projectDir = this.projectDir\n\n const devPackageFile = path.join(projectDir, \"package.json\")\n this._devMetadata = await orNullIfFileNotExist(readPackageJson(devPackageFile))\n\n const devMetadata = this.devMetadata\n const configuration = await getConfig(projectDir, configPath, configFromOptions, new Lazy(() => Promise.resolve(devMetadata)))\n\n log.debug({ config: getSafeEffectiveConfig(configuration) }, \"effective config\")\n\n this._appDir = await computeDefaultAppDirectory(projectDir, configuration.directories!.app)\n this.isTwoPackageJsonProjectLayoutUsed = this._appDir !== projectDir\n\n const appPackageFile = this.isTwoPackageJsonProjectLayoutUsed ? path.join(this.appDir, \"package.json\") : devPackageFile\n\n // tslint:disable:prefer-conditional-expression\n if (this.devMetadata != null && !this.isTwoPackageJsonProjectLayoutUsed) {\n this._metadata = this.devMetadata\n } else {\n this._metadata = await this.readProjectMetadataIfTwoPackageStructureOrPrepacked(appPackageFile)\n }\n this._originalMetadata = deepAssign({}, this._metadata)\n deepAssign(this._metadata, configuration.extraMetadata)\n\n if (this.isTwoPackageJsonProjectLayoutUsed) {\n log.debug({ devPackageFile, appPackageFile }, \"two package.json structure is used\")\n }\n checkMetadata(this.metadata, this.devMetadata, appPackageFile, devPackageFile)\n\n await validateConfiguration(configuration, this.debugLogger)\n\n this._configuration = configuration\n this._devMetadata = devMetadata\n }\n\n // external caller of this method always uses isTwoPackageJsonProjectLayoutUsed=false and appDir=projectDir, no way (and need) to use another values\n async build(repositoryInfo?: SourceRepositoryInfo): Promise<BuildResult> {\n await this.validateConfig()\n\n if (repositoryInfo != null) {\n this._repositoryInfo.value = Promise.resolve(repositoryInfo)\n }\n\n this._appInfo = new AppInfo(this, null)\n await this.addPackagerEventHandlers()\n\n this._framework = await createFrameworkInfo(this.config, this)\n\n const commonOutDirWithoutPossibleOsMacro = path.resolve(\n this.projectDir,\n expandMacro(this.config.directories!.output!, null, this._appInfo, {\n os: \"\",\n })\n )\n\n if (!isCI && (process.stdout as any).isTTY) {\n const effectiveConfigFile = path.join(commonOutDirWithoutPossibleOsMacro, \"builder-effective-config.yaml\")\n log.info({ file: log.filePath(effectiveConfigFile) }, \"writing effective config\")\n await outputFile(effectiveConfigFile, getSafeEffectiveConfig(this.config))\n }\n\n // because artifact event maybe dispatched several times for different publish providers\n const artifactPaths = new Set<string>()\n this.onArtifactCreated(event => {\n if (event.file != null) {\n artifactPaths.add(event.file)\n }\n })\n\n this.disposeOnBuildFinish(() =>\n retry(() => this.tempDirManager.cleanup(), {\n retries: 2,\n interval: 2000,\n backoff: 2000,\n cancellationToken: this.cancellationToken,\n shouldRetry: e => {\n const message: string = e?.message || \"\"\n const code = e?.code\n // windows file locks\n const resourceIsBusy = message.includes(\"EBUSY\") || code === \"EBUSY\"\n if (resourceIsBusy) {\n log.debug({ error: message || code }, \"retrying temporary directory cleanup\")\n return true\n }\n return false\n },\n })\n )\n\n const platformToTargets = await executeFinally(this.doBuild(), async () => {\n if (this.debugLogger.isEnabled) {\n await this.debugLogger.save(path.join(commonOutDirWithoutPossibleOsMacro, \"builder-debug.yml\"))\n }\n\n const toDispose = this.toDispose.slice()\n this.toDispose.length = 0\n for (const disposer of toDispose) {\n await disposer().catch((e: any) => {\n log.warn({ error: e }, \"cannot dispose\")\n })\n }\n })\n\n return {\n outDir: commonOutDirWithoutPossibleOsMacro,\n artifactPaths: Array.from(artifactPaths),\n platformToTargets,\n configuration: this.config,\n }\n }\n\n private async readProjectMetadataIfTwoPackageStructureOrPrepacked(appPackageFile: string): Promise<Metadata> {\n let data = await orNullIfFileNotExist(readPackageJson(appPackageFile))\n if (data != null) {\n return data\n }\n\n data = await orNullIfFileNotExist(readAsarJson(path.join(this.projectDir, \"app.asar\"), \"package.json\"))\n if (data != null) {\n this._isPrepackedAppAsar = true\n return data\n }\n\n throw new Error(`Cannot find package.json in the ${path.dirname(appPackageFile)}`)\n }\n\n private async doBuild(): Promise<Map<Platform, Map<string, Target>>> {\n const taskManager = new AsyncTaskManager(this.cancellationToken)\n const syncTargetsIfAny = [] as Target[]\n\n const platformToTarget = new Map<Platform, Map<string, Target>>()\n const createdOutDirs = new Set<string>()\n\n for (const [platform, archToType] of this.options.targets!) {\n if (this.cancellationToken.cancelled) {\n break\n }\n\n if (platform === Platform.MAC && process.platform === Platform.WINDOWS.nodeName) {\n throw new InvalidConfigurationError(\"Build for macOS is supported only on macOS, please see https://electron.build/multi-platform-build\")\n }\n\n const packager = await this.createHelper(platform)\n const nameToTarget: Map<string, Target> = new Map()\n platformToTarget.set(platform, nameToTarget)\n\n let poolCount = Math.floor(packager.config.concurrency?.jobs || 1)\n if (poolCount < 1) {\n log.warn({ concurrency: poolCount }, \"concurrency is invalid, overriding with job count: 1\")\n poolCount = 1\n } else if (poolCount > MAX_FILE_REQUESTS) {\n log.warn(\n { concurrency: poolCount, MAX_FILE_REQUESTS },\n `job concurrency is greater than recommended MAX_FILE_REQUESTS, this may lead to File Descriptor errors (too many files open). Proceed with caution (e.g. this is an experimental feature)`\n )\n }\n const packPromises: Promise<any>[] = []\n\n for (const [arch, targetNames] of computeArchToTargetNamesMap(archToType, packager, platform)) {\n if (this.cancellationToken.cancelled) {\n break\n }\n\n // support os and arch macro in output value\n const outDir = path.resolve(this.projectDir, packager.expandMacro(this.config.directories!.output!, Arch[arch]))\n const targetList = createTargets(nameToTarget, targetNames.length === 0 ? packager.defaultTarget : targetNames, outDir, packager)\n await createOutDirIfNeed(targetList, createdOutDirs)\n const promise = packager.pack(outDir, arch, targetList, taskManager)\n if (poolCount < 2) {\n await promise\n } else {\n packPromises.push(promise)\n }\n }\n\n await asyncPool(poolCount, packPromises, async it => {\n if (this.cancellationToken.cancelled) {\n return\n }\n await it\n })\n\n if (this.cancellationToken.cancelled) {\n break\n }\n\n for (const target of nameToTarget.values()) {\n if (target.isAsyncSupported) {\n taskManager.addTask(target.finishBuild())\n } else {\n syncTargetsIfAny.push(target)\n }\n }\n }\n\n await taskManager.awaitTasks()\n\n for (const target of syncTargetsIfAny) {\n if (this.cancellationToken.cancelled) {\n break\n }\n await target.finishBuild()\n }\n\n // Every target has now finished reading the shared appOutDir(s), so finalize tasks may safely\n // mutate them (e.g. NSIS copying elevate.exe into win-unpacked — see #9852).\n for (const task of this.buildFinalizeTasks) {\n if (this.cancellationToken.cancelled) {\n break\n }\n await task()\n }\n return platformToTarget\n }\n\n private async createHelper(platform: Platform): Promise<PlatformPackager<any>> {\n if (this.options.platformPackagerFactory != null) {\n return this.options.platformPackagerFactory(this, platform)\n }\n\n switch (platform) {\n case Platform.MAC: {\n const helperClass = (await import(\"./macPackager\")).MacPackager\n return new helperClass(this)\n }\n\n case Platform.WINDOWS: {\n const helperClass = (await import(\"./winPackager\")).WinPackager\n return new helperClass(this)\n }\n\n case Platform.LINUX:\n return new (await import(\"./linuxPackager\")).LinuxPackager(this)\n\n default:\n throw new Error(`Unknown platform: ${platform}`)\n }\n }\n\n public async installAppDependencies(platform: Platform, arch: Arch): Promise<any> {\n if (this.options.prepackaged != null || !this.framework.isNpmRebuildRequired) {\n return\n }\n\n const frameworkInfo = { version: this.framework.version, useCustomDist: true }\n const config = this.config\n if (config.nodeGypRebuild === true) {\n await nodeGypRebuild(platform.nodeName, Arch[arch], frameworkInfo)\n }\n\n if (config.npmRebuild === false) {\n log.info({ reason: \"npmRebuild is set to false\" }, \"skipped dependencies rebuild\")\n return\n }\n\n const beforeBuild = await resolveFunction(this.appInfo.type, config.beforeBuild, \"beforeBuild\", await this.getWorkspaceRoot())\n if (beforeBuild != null) {\n const performDependenciesInstallOrRebuild = await beforeBuild({\n appDir: this.appDir,\n electronVersion: this.config.electronVersion!,\n platform,\n arch: Arch[arch],\n })\n\n // If beforeBuild resolves to false, it means that handling node_modules is done outside of electron-builder.\n this._nodeModulesHandledExternally = !performDependenciesInstallOrRebuild\n if (!performDependenciesInstallOrRebuild) {\n return\n }\n }\n\n if (config.buildDependenciesFromSource === true && platform.nodeName !== process.platform) {\n log.info({ reason: \"platform is different and buildDependenciesFromSource is set to true\" }, \"skipped dependencies rebuild\")\n } else {\n await installOrRebuild(\n config,\n { appDir: this.appDir, projectDir: this.projectDir, workspaceRoot: await this.getWorkspaceRoot() },\n {\n frameworkInfo,\n platform: platform.nodeName,\n arch: Arch[arch],\n },\n false,\n this.runtimeEnvironmentVariables\n )\n }\n }\n}\n\nfunction createOutDirIfNeed(targetList: Array<Target>, createdOutDirs: Set<string>): Promise<any> {\n const ourDirs = new Set<string>()\n for (const target of targetList) {\n // noinspection SuspiciousInstanceOfGuard\n if (target instanceof NoOpTarget) {\n continue\n }\n\n const outDir = target.outDir\n if (!createdOutDirs.has(outDir)) {\n ourDirs.add(outDir)\n }\n }\n\n if (ourDirs.size === 0) {\n return Promise.resolve()\n }\n\n return Promise.all(\n Array.from(ourDirs)\n .sort()\n .map(dir => {\n return mkdirs(dir)\n .then(() => chmod(dir, 0o755) /* set explicitly */)\n .then(() => createdOutDirs.add(dir))\n })\n )\n}\n\nexport interface BuildResult {\n readonly outDir: string\n readonly artifactPaths: Array<string>\n readonly platformToTargets: Map<Platform, Map<string, Target>>\n readonly configuration: Configuration\n}\n\nfunction getSafeEffectiveConfig(configuration: Configuration): string {\n const o = JSON.parse(safeStringifyJson(configuration))\n if (o.cscLink != null) {\n o.cscLink = \"<hidden by builder>\"\n }\n return serializeToYaml(o, true)\n}\n"]}
|
|
@@ -33,6 +33,7 @@ export declare abstract class PlatformPackager<DC extends PlatformSpecificBuildO
|
|
|
33
33
|
protected constructor(info: Packager, platform: Platform);
|
|
34
34
|
get compression(): CompressionLevel;
|
|
35
35
|
get debugLogger(): DebugLogger;
|
|
36
|
+
addBuildFinalizeTask(task: () => Promise<void>): void;
|
|
36
37
|
abstract get defaultTarget(): Array<string>;
|
|
37
38
|
protected prepareAppInfo(appInfo: AppInfo): AppInfo;
|
|
38
39
|
private static normalizePlatformSpecificBuildOptions;
|