app-builder-lib 26.17.0 → 26.18.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/asar/asarUtil.js +7 -2
- package/out/asar/asarUtil.js.map +1 -1
- package/out/codeSign/windowsSignToolManager.d.ts +11 -0
- package/out/codeSign/windowsSignToolManager.js +26 -14
- package/out/codeSign/windowsSignToolManager.js.map +1 -1
- package/out/electron/ElectronFramework.d.ts +15 -0
- package/out/electron/ElectronFramework.js +36 -2
- package/out/electron/ElectronFramework.js.map +1 -1
- package/out/electron/electronMac.js +2 -28
- package/out/electron/electronMac.js.map +1 -1
- package/out/electron/electronMacUtils.d.ts +8 -0
- package/out/electron/electronMacUtils.js +40 -0
- package/out/electron/electronMacUtils.js.map +1 -0
- package/out/forge-maker.d.ts +64 -0
- package/out/forge-maker.js +108 -2
- package/out/forge-maker.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/node-module-collector/pnpmNodeModulesCollector.d.ts +37 -0
- package/out/node-module-collector/pnpmNodeModulesCollector.js +102 -24
- package/out/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
- package/out/options/winOptions.d.ts +2 -1
- package/out/options/winOptions.js.map +1 -1
- package/out/targets/archive.d.ts +6 -0
- package/out/targets/archive.js +12 -2
- package/out/targets/archive.js.map +1 -1
- package/out/targets/blockmap/blockmap.d.ts +43 -3
- package/out/targets/blockmap/blockmap.js +143 -16
- package/out/targets/blockmap/blockmap.js.map +1 -1
- package/out/targets/blockmap/verbatimRange.d.ts +43 -0
- package/out/targets/blockmap/verbatimRange.js +122 -0
- package/out/targets/blockmap/verbatimRange.js.map +1 -0
- package/out/targets/differentialUpdateInfoBuilder.d.ts +27 -2
- package/out/targets/differentialUpdateInfoBuilder.js +81 -5
- package/out/targets/differentialUpdateInfoBuilder.js.map +1 -1
- package/out/targets/nsis/NsisTarget.d.ts +35 -2
- package/out/targets/nsis/NsisTarget.js +121 -29
- package/out/targets/nsis/NsisTarget.js.map +1 -1
- package/out/targets/nsis/nsisOptions.d.ts +8 -3
- package/out/targets/nsis/nsisOptions.js.map +1 -1
- package/out/targets/nsis/nsisUtil.d.ts +7 -0
- package/out/targets/nsis/nsisUtil.js +14 -3
- package/out/targets/nsis/nsisUtil.js.map +1 -1
- package/out/targets/snap/core24.d.ts +2 -0
- package/out/targets/snap/core24.js +30 -7
- package/out/targets/snap/core24.js.map +1 -1
- package/out/targets/snap/coreLegacy.js +1 -2
- package/out/targets/snap/coreLegacy.js.map +1 -1
- package/out/util/appFileCopier.js +1 -1
- package/out/util/appFileCopier.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 +11 -9
- package/scheme.json +6 -6
|
@@ -94,6 +94,8 @@ class PnpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollect
|
|
|
94
94
|
/** Reverse index of `allDependencies` keyed by package name (without version). Built once on
|
|
95
95
|
* first access inside `extractProductionDependencyGraph`, after `allDependencies` is settled. */
|
|
96
96
|
this._allDepsByName = null;
|
|
97
|
+
/** The app's own node of the `pnpm list` output (the root of the production graph), set by `getTreeFromWorkspaces`. */
|
|
98
|
+
this.rootTree = null;
|
|
97
99
|
}
|
|
98
100
|
/** Returns true if `nmDir` is an isolated (`.pnpm`) store, false if hoisted, null if it holds no packages. */
|
|
99
101
|
async scanNodeModulesLayout(nmDir) {
|
|
@@ -196,12 +198,34 @@ class PnpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollect
|
|
|
196
198
|
return fromDep;
|
|
197
199
|
}
|
|
198
200
|
return this.cache.locatePackageVersion({ pkgName, parentDir: this.rootDir, requiredRange, skipDownwardSearch });
|
|
199
|
-
})();
|
|
201
|
+
})().then(pkg => this.toRealPackage(pkg));
|
|
200
202
|
if (memoKey != null) {
|
|
201
203
|
this.locateMemo.set(memoKey, promise);
|
|
202
204
|
}
|
|
203
205
|
return promise;
|
|
204
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Resolve a located package to its real directory (the symlink target), leaving a non-symlinked
|
|
209
|
+
* hit untouched.
|
|
210
|
+
*
|
|
211
|
+
* `locatePackageVersion` returns the path it *walked*, which in pnpm's isolated store is the
|
|
212
|
+
* `node_modules/<name>` symlink rather than `.pnpm/<name>@<ver>/node_modules/<name>`. That
|
|
213
|
+
* distinction matters because the store keeps a package's dependencies as SIBLINGS inside
|
|
214
|
+
* `.pnpm/<name>@<ver>/node_modules/`, reachable only from the real path: searching upward from
|
|
215
|
+
* the symlink walks the dependent's directory instead, and finds the dependency only by accident
|
|
216
|
+
* (through pnpm's hidden `.pnpm/node_modules` hoist, possibly at the wrong version). `visitDep`
|
|
217
|
+
* resolves the deps of every package pnpm printed without children (deduped stubs) from disk
|
|
218
|
+
* through here.
|
|
219
|
+
*
|
|
220
|
+
* Resolving the link is what Node itself does (`--preserve-symlinks` is off by default).
|
|
221
|
+
*/
|
|
222
|
+
async toRealPackage(pkg) {
|
|
223
|
+
if (pkg == null) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
const packageDir = await this.cache.realPath[pkg.packageDir];
|
|
227
|
+
return packageDir === pkg.packageDir ? pkg : { ...pkg, packageDir };
|
|
228
|
+
}
|
|
205
229
|
// pnpm 10+ does not automatically preserve transitive optional platform-specific
|
|
206
230
|
// packages (e.g. sass-embedded-linux-x64) across lock file regeneration. Users
|
|
207
231
|
// must list them as direct optionalDependencies. Missing ones are emitted as
|
|
@@ -224,7 +248,13 @@ class PnpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollect
|
|
|
224
248
|
}
|
|
225
249
|
}
|
|
226
250
|
const packageName = tree.name || tree.from;
|
|
227
|
-
|
|
251
|
+
// The app root is never installed inside a node_modules directory, so it is read from its own
|
|
252
|
+
// directory instead of being located by name. A by-name lookup finds a same-named dependency
|
|
253
|
+
// whenever the app shares its name with one (an app called `debug` depending on `debug`), and
|
|
254
|
+
// that dependency's package.json would then decide which of the app's dependencies are kept.
|
|
255
|
+
const isRoot = tree === this.rootTree;
|
|
256
|
+
const rootPackageJson = isRoot && tree.path ? await fs.readJson(path.join(tree.path, "package.json")).catch(() => null) : null;
|
|
257
|
+
const { packageJson } = (isRoot ? { packageJson: rootPackageJson } : await this.locateFromDepOrRoot(packageName, tree.path, tree.version)) || {};
|
|
228
258
|
const all = packageJson ? { ...packageJson.dependencies, ...packageJson.optionalDependencies } : { ...tree.dependencies, ...tree.optionalDependencies };
|
|
229
259
|
const optional = packageJson ? { ...packageJson.optionalDependencies } : {};
|
|
230
260
|
const deps = { ...(tree.dependencies || {}), ...(tree.optionalDependencies || {}) };
|
|
@@ -293,40 +323,88 @@ class PnpmNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollect
|
|
|
293
323
|
await this.collectDepsRecursively(root);
|
|
294
324
|
}
|
|
295
325
|
}
|
|
296
|
-
async
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
326
|
+
async readPackageJsonAt(dir) {
|
|
327
|
+
const packageJson = await fs.readJson(path.join(dir, "package.json")).catch(() => null);
|
|
328
|
+
return packageJson ? { packageDir: dir, packageJson } : null;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Visit a single dependency node, adding it and its transitive deps to allDependencies.
|
|
332
|
+
*
|
|
333
|
+
* pnpm 10.29.3+ prints a repeated subtree only once; every later occurrence is a childless
|
|
334
|
+
* `deduped` stub. Stubs must still be registered here: the one full print can sit under a node
|
|
335
|
+
* this walk skips, e.g. a second peer variant of a package with the same `name@version` (the
|
|
336
|
+
* guard below), so a package seen only as stubs was dropped from the asar together with its whole
|
|
337
|
+
* closure (#10253). For a stub (and every dependency discovered beneath one, `fromDisk`), we fall
|
|
338
|
+
* back to the on-disk package.json to discover transitive deps, resolving each one from the
|
|
339
|
+
* package's own store directory first (where pnpm placed them).
|
|
340
|
+
*
|
|
341
|
+
* Other childless entries keep the tree walk. A `link:` package is also printed without children,
|
|
342
|
+
* but its declared deps resolve from the link target's own `node_modules` (e.g. a linked
|
|
343
|
+
* electron-updater checkout's monorepo store), outside the app. Walking them would register those
|
|
344
|
+
* foreign copies under `name@version`, so the guard below then skips the app's own copy of the same
|
|
345
|
+
* `name@version` together with its subtree (`jsonfile` vanished from under `fs-extra`).
|
|
346
|
+
*/
|
|
347
|
+
async visitDep(key, value, fromDisk = false) {
|
|
348
|
+
var _a, _b, _c, _d;
|
|
349
|
+
const id = `${key}@${value.version}`;
|
|
350
|
+
// The pnpm list output can include the same `name@version` thousands of times across a
|
|
351
|
+
// deep workspace; without this guard we re-resolve and re-recurse each occurrence.
|
|
352
|
+
if (this.collectedDeps.has(id)) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
this.collectedDeps.add(id);
|
|
356
|
+
const located = await this.locateFromDepOrRoot(key, value.path, value.version);
|
|
357
|
+
const resolvedPath = (_a = located === null || located === void 0 ? void 0 : located.packageDir) !== null && _a !== void 0 ? _a : value.path;
|
|
358
|
+
this.allDependencies.set(id, { ...value, path: resolvedPath });
|
|
359
|
+
// Fall back to reading package.json straight from the resolved directory when the by-name lookup
|
|
360
|
+
// came up empty, e.g. a workspace package, which nothing above it exposes under `node_modules/`.
|
|
361
|
+
const pkg = located !== null && located !== void 0 ? located : (resolvedPath != null ? await this.readPackageJsonAt(resolvedPath) : null);
|
|
362
|
+
const hasTreeDeps = Object.keys((_b = value.dependencies) !== null && _b !== void 0 ? _b : {}).length > 0 || Object.keys((_c = value.optionalDependencies) !== null && _c !== void 0 ? _c : {}).length > 0;
|
|
363
|
+
const isDedupedStub = ((_d = value.dedupedDependenciesCount) !== null && _d !== void 0 ? _d : 0) > 0;
|
|
364
|
+
if ((isDedupedStub || fromDisk) && !hasTreeDeps && (pkg === null || pkg === void 0 ? void 0 : pkg.packageJson)) {
|
|
365
|
+
// Pass the declared version range so that resolution skips wrong-version hoisted packages and
|
|
366
|
+
// finds the correct nested copy.
|
|
367
|
+
const pkgOptionalDecl = pkg.packageJson.optionalDependencies || {};
|
|
368
|
+
const pkgDepsDecl = { ...(pkg.packageJson.dependencies || {}), ...pkgOptionalDecl };
|
|
369
|
+
for (const [depName, depRange] of Object.entries(pkgDepsDecl)) {
|
|
370
|
+
const resolved = await this.locateFromDepOrRoot(depName, pkg.packageDir, typeof depRange === "string" ? depRange : undefined);
|
|
371
|
+
if (!resolved) {
|
|
372
|
+
// A miss here silently ships a broken app (the dependency is simply absent from the
|
|
373
|
+
// asar and only fails at runtime with MODULE_NOT_FOUND), so surface it in the log
|
|
374
|
+
// summary. Optional deps are an expected miss and get the quieter bucket.
|
|
375
|
+
this.logMissingDependency(`${depName}@${depRange}`, pkgOptionalDecl[depName] != null);
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
await this.visitDep(depName, {
|
|
379
|
+
from: depName,
|
|
380
|
+
name: depName,
|
|
381
|
+
version: resolved.packageJson.version,
|
|
382
|
+
path: resolved.packageDir,
|
|
383
|
+
dependencies: {},
|
|
384
|
+
optionalDependencies: {},
|
|
385
|
+
}, true);
|
|
307
386
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
this.allDependencies.set(id, { ...value, path: (_b = pkg === null || pkg === void 0 ? void 0 : pkg.packageDir) !== null && _b !== void 0 ? _b : value.path });
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
311
389
|
await this.collectDepsRecursively(value);
|
|
312
|
-
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
async collectDepsRecursively(tree) {
|
|
313
393
|
for (const [key, value] of Object.entries(tree.dependencies || {})) {
|
|
314
|
-
await
|
|
394
|
+
await this.visitDep(key, value);
|
|
315
395
|
}
|
|
316
396
|
for (const [key, value] of Object.entries(tree.optionalDependencies || {})) {
|
|
317
|
-
await
|
|
397
|
+
await this.visitDep(key, value);
|
|
318
398
|
}
|
|
319
399
|
}
|
|
320
400
|
getTreeFromWorkspaces(tree, packageName) {
|
|
401
|
+
var _a;
|
|
321
402
|
// pnpm v10 workspace: app is nested as a dependency of root — handled by base class
|
|
322
403
|
const result = super.getTreeFromWorkspaces(tree, packageName);
|
|
323
|
-
if (result !== tree) {
|
|
324
|
-
return result;
|
|
325
|
-
}
|
|
326
404
|
// pnpm v11 workspace: each workspace package is a separate top-level array entry;
|
|
327
405
|
// non-workspace (single-tree): find returns the one entry or undefined → falls back to tree
|
|
328
|
-
|
|
329
|
-
return
|
|
406
|
+
this.rootTree = result !== tree ? result : ((_a = this.allWorkspacePackages.find(pkg => pkg.name === packageName || pkg.from === packageName)) !== null && _a !== void 0 ? _a : tree);
|
|
407
|
+
return this.rootTree;
|
|
330
408
|
}
|
|
331
409
|
async parseDependenciesTree(jsonBlob) {
|
|
332
410
|
const dependencyTree = this.extractJsonFromPollutedOutput(jsonBlob);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pnpmNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,+BAA8B;AAC9B,uCAA+B;AAC/B,6BAA4B;AAC5B,mDAA+D;AAC/D,iEAA6D;AAC7D,qDAA+D;AAE/D,+CAAiD;AAEjD,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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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;AA5VD,4DA4VC","sourcesContent":["import * as fs from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { LogMessageByKey, type Package } from \"./moduleManager\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { getPackageManagerCommand, PM } from \"./packageManager\"\nimport { PnpmDependency } from \"./types\"\nimport { exists, isValidKey } from \"builder-util\"\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 * Detect pnpm's installed layout from the on-disk structure rather than `pnpm config list`.\n * pnpm 11 no longer echoes `node-linker` (from `.npmrc`) in `config list`, so the base-class\n * config-parsing detection silently reports \"not hoisted\" for a hoisted install, which would\n * disable the downward search needed to find version-conflicted nested deps.\n *\n * In the default isolated store every regular top-level package resolves — through a symlink\n * on POSIX, a junction on Windows — into `node_modules/.pnpm/<name>@<ver>/node_modules/<name>`.\n * In a hoisted layout the same package is a real directory directly under `node_modules`.\n * `realpath` transparently follows both symlinks and junctions, so a layout is isolated iff\n * *any* top-level package's real path routes through `.pnpm`. We scan rather than sample the\n * first entry because `link:` packages resolve to their source (never under `.pnpm`) and could\n * otherwise mask an isolated store.\n */\n protected override isHoisted = new Lazy<boolean>(async () => {\n // A workspace package's own `node_modules` is often absent (or holds only its version\n // conflicts) in a hoisted workspace, so fall back to the workspace root's `node_modules`.\n let sawPackage = false\n for (const dir of await this.layoutRoots.value) {\n const isolated = await this.scanNodeModulesLayout(path.join(dir, \"node_modules\"))\n if (isolated != null) {\n if (isolated) {\n return false\n }\n sawPackage = true\n }\n }\n // Packages exist and none route through `.pnpm` → hoisted. No packages → flat default.\n return sawPackage\n })\n\n /**\n * The pnpm workspace root containing `rootDir` (nearest ancestor with `pnpm-workspace.yaml`, as pnpm\n * itself resolves it), or null outside a workspace or when `rootDir` is the workspace root.\n */\n private readonly workspaceRoot = new Lazy<string | null>(async () => {\n let current = path.resolve(this.rootDir)\n while (true) {\n if (await exists(path.join(current, \"pnpm-workspace.yaml\"))) {\n return current === path.resolve(this.rootDir) ? null : current\n }\n const parent = path.dirname(current)\n if (parent === current) {\n return null\n }\n current = parent\n }\n })\n\n /** `rootDir`, then the workspace root when `rootDir` is a workspace package. */\n private readonly layoutRoots = new Lazy<string[]>(async () => {\n const workspaceRoot = await this.workspaceRoot.value\n return workspaceRoot == null ? [this.rootDir] : [this.rootDir, workspaceRoot]\n })\n\n /** Returns true if `nmDir` is an isolated (`.pnpm`) store, false if hoisted, null if it holds no packages. */\n private async scanNodeModulesLayout(nmDir: string): Promise<boolean | null> {\n const entries = await fs.readdir(nmDir).catch(() => [] as string[])\n let sawPackage = false\n for (const name of entries) {\n if (name.startsWith(\".\")) {\n continue // .pnpm, .bin, .modules.yaml\n }\n const entryPath = path.join(nmDir, name)\n // A scoped dir (@scope) is not a package itself; descend to its packages.\n const candidates = name.startsWith(\"@\") ? (await fs.readdir(entryPath).catch(() => [] as string[])).map(s => path.join(entryPath, s)) : [entryPath]\n for (const candidate of candidates) {\n const real = await fs.realpath(candidate).catch(() => null)\n if (real == null) {\n continue\n }\n sawPackage = true\n if (real.split(path.sep).includes(\".pnpm\")) {\n return true // isolated store: a package routes through the virtual store\n }\n }\n }\n return sawPackage ? false : null\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 /** Reverse index of `allDependencies` keyed by package name (without version). Built once on\n * first access inside `extractProductionDependencyGraph`, after `allDependencies` is settled. */\n private _allDepsByName: Map<string, PnpmDependency> | null = null\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 private getAllDepsByName(): Map<string, PnpmDependency> {\n if (!this._allDepsByName) {\n this._allDepsByName = new Map()\n for (const [id, dep] of this.allDependencies.entries()) {\n const { name } = this.parseNameVersion(id)\n if (!this._allDepsByName.has(name)) {\n this._allDepsByName.set(name, dep)\n }\n }\n }\n return this._allDepsByName\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 // Phase 1: find a version that SATISFIES requiredRange, trying the dep's own location\n // first, then the workspace root. Crucially, neither pass accepts an out-of-range override\n // here — so a wrong-version copy reachable via upward search from `parentPath` (e.g. a\n // hoisted top-level dep) can't shadow the correct nested copy under root. With\n // `nodeLinker: hoisted`, pnpm still reports virtual-store `path`s that don't exist on disk;\n // an upward walk from one meets the root copy, which previously got accepted as an\n // \"override\" before the root search (whose downward BFS finds the nested copy) ever ran.\n //\n // When `rootDir` is a workspace package, a hoisted install keeps the tree — including the\n // nested `<workspaceRoot>/node_modules/A/node_modules/B` copies — under the workspace root,\n // which the downward BFS from `rootDir` never reaches (its `node_modules` is often absent),\n // so search the workspace root last.\n let satisfying = parentPath ? await this.cache.locatePackageVersion({ pkgName, parentDir: parentPath, requiredRange, skipDownwardSearch, skipOverrideFallback: true }) : null\n for (const dir of await this.layoutRoots.value) {\n satisfying ??= await this.cache.locatePackageVersion({ pkgName, parentDir: dir, requiredRange, skipDownwardSearch, skipOverrideFallback: true })\n }\n if (satisfying) {\n return satisfying\n }\n // Phase 2: no version satisfies requiredRange (package-manager override, or no range\n // given). Fall back to the original dep-then-root order, now allowing override versions.\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: Record<string, PnpmDependency> = { ...(tree.dependencies || {}), ...(tree.optionalDependencies || {}) }\n\n // pnpm --prod omits sub-deps for link: packages (and synthetic entries derived from them), and pnpm\n // 10.29.3+ prints a repeated subtree only once, so every later occurrence is a childless `deduped`\n // stub (which is what `tree` is when the stub was the first occurrence collected). For any dep\n // declared in the package.json (all) that pnpm left out of the tree, recover the resolved entry\n // from allDependencies so it lands in the production graph.\n for (const [depName, declaredRange] of Object.entries(all)) {\n if (!deps[depName]) {\n const dep = await this.resolveOmittedDependency(depName, declaredRange, tree.path)\n if (dep && isValidKey(depName)) {\n deps[depName] = dep\n }\n }\n }\n\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 /**\n * Resolve a dependency that `pnpm list` left out of a package's tree to its `allDependencies` entry.\n * The lookup goes through the copy node itself would load from `parentPath` (the package's real store\n * directory), filtered by the declared range, and falls back to a name-only match only when nothing on\n * disk resolves to a collected entry (a `link:` dep, whose entry is keyed by its `link:` version).\n *\n * A name-only lookup returns whichever version was collected first, which is wrong as soon as two\n * versions of the package are installed: with the app pinning es5-ext@0.10.53 while its transitive\n * d@1.0.2 needs es5-ext ^0.10.64, `d` was wired to 0.10.53 and the nested 0.10.64 copy (with its own\n * esniff / event-emitter / next-tick@1.1.0 closure) vanished from the asar (#8493). pnpm 10.29.3+\n * made this common, because its deduped output routes every repeated package through this recovery.\n */\n private async resolveOmittedDependency(depName: string, declaredRange: unknown, parentPath: string | undefined): Promise<PnpmDependency | undefined> {\n const range = typeof declaredRange === \"string\" ? declaredRange : undefined\n const located = await this.locateFromDepOrRoot(depName, parentPath, range)\n const exact = located ? this.allDependencies.get(`${depName}@${located.packageJson.version}`) : undefined\n return exact ?? this.getAllDepsByName().get(depName)\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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AibC","sourcesContent":["import * as fs from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { LogMessageByKey, type Package } from \"./moduleManager\"\nimport { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { getPackageManagerCommand, PM } from \"./packageManager\"\nimport { PackageJson, PnpmDependency } from \"./types\"\nimport { exists, isValidKey } from \"builder-util\"\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 * Detect pnpm's installed layout from the on-disk structure rather than `pnpm config list`.\n * pnpm 11 no longer echoes `node-linker` (from `.npmrc`) in `config list`, so the base-class\n * config-parsing detection silently reports \"not hoisted\" for a hoisted install, which would\n * disable the downward search needed to find version-conflicted nested deps.\n *\n * In the default isolated store every regular top-level package resolves — through a symlink\n * on POSIX, a junction on Windows — into `node_modules/.pnpm/<name>@<ver>/node_modules/<name>`.\n * In a hoisted layout the same package is a real directory directly under `node_modules`.\n * `realpath` transparently follows both symlinks and junctions, so a layout is isolated iff\n * *any* top-level package's real path routes through `.pnpm`. We scan rather than sample the\n * first entry because `link:` packages resolve to their source (never under `.pnpm`) and could\n * otherwise mask an isolated store.\n */\n protected override isHoisted = new Lazy<boolean>(async () => {\n // A workspace package's own `node_modules` is often absent (or holds only its version\n // conflicts) in a hoisted workspace, so fall back to the workspace root's `node_modules`.\n let sawPackage = false\n for (const dir of await this.layoutRoots.value) {\n const isolated = await this.scanNodeModulesLayout(path.join(dir, \"node_modules\"))\n if (isolated != null) {\n if (isolated) {\n return false\n }\n sawPackage = true\n }\n }\n // Packages exist and none route through `.pnpm` → hoisted. No packages → flat default.\n return sawPackage\n })\n\n /**\n * The pnpm workspace root containing `rootDir` (nearest ancestor with `pnpm-workspace.yaml`, as pnpm\n * itself resolves it), or null outside a workspace or when `rootDir` is the workspace root.\n */\n private readonly workspaceRoot = new Lazy<string | null>(async () => {\n let current = path.resolve(this.rootDir)\n while (true) {\n if (await exists(path.join(current, \"pnpm-workspace.yaml\"))) {\n return current === path.resolve(this.rootDir) ? null : current\n }\n const parent = path.dirname(current)\n if (parent === current) {\n return null\n }\n current = parent\n }\n })\n\n /** `rootDir`, then the workspace root when `rootDir` is a workspace package. */\n private readonly layoutRoots = new Lazy<string[]>(async () => {\n const workspaceRoot = await this.workspaceRoot.value\n return workspaceRoot == null ? [this.rootDir] : [this.rootDir, workspaceRoot]\n })\n\n /** Returns true if `nmDir` is an isolated (`.pnpm`) store, false if hoisted, null if it holds no packages. */\n private async scanNodeModulesLayout(nmDir: string): Promise<boolean | null> {\n const entries = await fs.readdir(nmDir).catch(() => [] as string[])\n let sawPackage = false\n for (const name of entries) {\n if (name.startsWith(\".\")) {\n continue // .pnpm, .bin, .modules.yaml\n }\n const entryPath = path.join(nmDir, name)\n // A scoped dir (@scope) is not a package itself; descend to its packages.\n const candidates = name.startsWith(\"@\") ? (await fs.readdir(entryPath).catch(() => [] as string[])).map(s => path.join(entryPath, s)) : [entryPath]\n for (const candidate of candidates) {\n const real = await fs.realpath(candidate).catch(() => null)\n if (real == null) {\n continue\n }\n sawPackage = true\n if (real.split(path.sep).includes(\".pnpm\")) {\n return true // isolated store: a package routes through the virtual store\n }\n }\n }\n return sawPackage ? false : null\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 /** Reverse index of `allDependencies` keyed by package name (without version). Built once on\n * first access inside `extractProductionDependencyGraph`, after `allDependencies` is settled. */\n private _allDepsByName: Map<string, PnpmDependency> | null = null\n\n /** The app's own node of the `pnpm list` output (the root of the production graph), set by `getTreeFromWorkspaces`. */\n private rootTree: PnpmDependency | null = null\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 private getAllDepsByName(): Map<string, PnpmDependency> {\n if (!this._allDepsByName) {\n this._allDepsByName = new Map()\n for (const [id, dep] of this.allDependencies.entries()) {\n const { name } = this.parseNameVersion(id)\n if (!this._allDepsByName.has(name)) {\n this._allDepsByName.set(name, dep)\n }\n }\n }\n return this._allDepsByName\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 // Phase 1: find a version that SATISFIES requiredRange, trying the dep's own location\n // first, then the workspace root. Crucially, neither pass accepts an out-of-range override\n // here — so a wrong-version copy reachable via upward search from `parentPath` (e.g. a\n // hoisted top-level dep) can't shadow the correct nested copy under root. With\n // `nodeLinker: hoisted`, pnpm still reports virtual-store `path`s that don't exist on disk;\n // an upward walk from one meets the root copy, which previously got accepted as an\n // \"override\" before the root search (whose downward BFS finds the nested copy) ever ran.\n //\n // When `rootDir` is a workspace package, a hoisted install keeps the tree — including the\n // nested `<workspaceRoot>/node_modules/A/node_modules/B` copies — under the workspace root,\n // which the downward BFS from `rootDir` never reaches (its `node_modules` is often absent),\n // so search the workspace root last.\n let satisfying = parentPath ? await this.cache.locatePackageVersion({ pkgName, parentDir: parentPath, requiredRange, skipDownwardSearch, skipOverrideFallback: true }) : null\n for (const dir of await this.layoutRoots.value) {\n satisfying ??= await this.cache.locatePackageVersion({ pkgName, parentDir: dir, requiredRange, skipDownwardSearch, skipOverrideFallback: true })\n }\n if (satisfying) {\n return satisfying\n }\n // Phase 2: no version satisfies requiredRange (package-manager override, or no range\n // given). Fall back to the original dep-then-root order, now allowing override versions.\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 })().then(pkg => this.toRealPackage(pkg))\n\n if (memoKey != null) {\n this.locateMemo.set(memoKey, promise)\n }\n return promise\n }\n\n /**\n * Resolve a located package to its real directory (the symlink target), leaving a non-symlinked\n * hit untouched.\n *\n * `locatePackageVersion` returns the path it *walked*, which in pnpm's isolated store is the\n * `node_modules/<name>` symlink rather than `.pnpm/<name>@<ver>/node_modules/<name>`. That\n * distinction matters because the store keeps a package's dependencies as SIBLINGS inside\n * `.pnpm/<name>@<ver>/node_modules/`, reachable only from the real path: searching upward from\n * the symlink walks the dependent's directory instead, and finds the dependency only by accident\n * (through pnpm's hidden `.pnpm/node_modules` hoist, possibly at the wrong version). `visitDep`\n * resolves the deps of every package pnpm printed without children (deduped stubs) from disk\n * through here.\n *\n * Resolving the link is what Node itself does (`--preserve-symlinks` is off by default).\n */\n private async toRealPackage(pkg: Package | null): Promise<Package | null> {\n if (pkg == null) {\n return null\n }\n const packageDir = await this.cache.realPath[pkg.packageDir]\n return packageDir === pkg.packageDir ? pkg : { ...pkg, packageDir }\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 // The app root is never installed inside a node_modules directory, so it is read from its own\n // directory instead of being located by name. A by-name lookup finds a same-named dependency\n // whenever the app shares its name with one (an app called `debug` depending on `debug`), and\n // that dependency's package.json would then decide which of the app's dependencies are kept.\n const isRoot = tree === this.rootTree\n const rootPackageJson: PackageJson | null = isRoot && tree.path ? await fs.readJson(path.join(tree.path, \"package.json\")).catch(() => null) : null\n const { packageJson } = (isRoot ? { packageJson: rootPackageJson } : 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: Record<string, PnpmDependency> = { ...(tree.dependencies || {}), ...(tree.optionalDependencies || {}) }\n\n // pnpm --prod omits sub-deps for link: packages (and synthetic entries derived from them), and pnpm\n // 10.29.3+ prints a repeated subtree only once, so every later occurrence is a childless `deduped`\n // stub (which is what `tree` is when the stub was the first occurrence collected). For any dep\n // declared in the package.json (all) that pnpm left out of the tree, recover the resolved entry\n // from allDependencies so it lands in the production graph.\n for (const [depName, declaredRange] of Object.entries(all)) {\n if (!deps[depName]) {\n const dep = await this.resolveOmittedDependency(depName, declaredRange, tree.path)\n if (dep && isValidKey(depName)) {\n deps[depName] = dep\n }\n }\n }\n\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 /**\n * Resolve a dependency that `pnpm list` left out of a package's tree to its `allDependencies` entry.\n * The lookup goes through the copy node itself would load from `parentPath` (the package's real store\n * directory), filtered by the declared range, and falls back to a name-only match only when nothing on\n * disk resolves to a collected entry (a `link:` dep, whose entry is keyed by its `link:` version).\n *\n * A name-only lookup returns whichever version was collected first, which is wrong as soon as two\n * versions of the package are installed: with the app pinning es5-ext@0.10.53 while its transitive\n * d@1.0.2 needs es5-ext ^0.10.64, `d` was wired to 0.10.53 and the nested 0.10.64 copy (with its own\n * esniff / event-emitter / next-tick@1.1.0 closure) vanished from the asar (#8493). pnpm 10.29.3+\n * made this common, because its deduped output routes every repeated package through this recovery.\n */\n private async resolveOmittedDependency(depName: string, declaredRange: unknown, parentPath: string | undefined): Promise<PnpmDependency | undefined> {\n const range = typeof declaredRange === \"string\" ? declaredRange : undefined\n const located = await this.locateFromDepOrRoot(depName, parentPath, range)\n const exact = located ? this.allDependencies.get(`${depName}@${located.packageJson.version}`) : undefined\n return exact ?? this.getAllDepsByName().get(depName)\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 readPackageJsonAt(dir: string): Promise<Package | null> {\n const packageJson: PackageJson | null = await fs.readJson(path.join(dir, \"package.json\")).catch(() => null)\n return packageJson ? { packageDir: dir, packageJson } : null\n }\n\n /**\n * Visit a single dependency node, adding it and its transitive deps to allDependencies.\n *\n * pnpm 10.29.3+ prints a repeated subtree only once; every later occurrence is a childless\n * `deduped` stub. Stubs must still be registered here: the one full print can sit under a node\n * this walk skips, e.g. a second peer variant of a package with the same `name@version` (the\n * guard below), so a package seen only as stubs was dropped from the asar together with its whole\n * closure (#10253). For a stub (and every dependency discovered beneath one, `fromDisk`), we fall\n * back to the on-disk package.json to discover transitive deps, resolving each one from the\n * package's own store directory first (where pnpm placed them).\n *\n * Other childless entries keep the tree walk. A `link:` package is also printed without children,\n * but its declared deps resolve from the link target's own `node_modules` (e.g. a linked\n * electron-updater checkout's monorepo store), outside the app. Walking them would register those\n * foreign copies under `name@version`, so the guard below then skips the app's own copy of the same\n * `name@version` together with its subtree (`jsonfile` vanished from under `fs-extra`).\n */\n private async visitDep(key: string, value: PnpmDependency, fromDisk = false): Promise<void> {\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\n const located = await this.locateFromDepOrRoot(key, value.path, value.version)\n const resolvedPath = located?.packageDir ?? value.path\n this.allDependencies.set(id, { ...value, path: resolvedPath })\n\n // Fall back to reading package.json straight from the resolved directory when the by-name lookup\n // came up empty, e.g. a workspace package, which nothing above it exposes under `node_modules/`.\n const pkg = located ?? (resolvedPath != null ? await this.readPackageJsonAt(resolvedPath) : null)\n const hasTreeDeps = Object.keys(value.dependencies ?? {}).length > 0 || Object.keys(value.optionalDependencies ?? {}).length > 0\n const isDedupedStub = (value.dedupedDependenciesCount ?? 0) > 0\n if ((isDedupedStub || fromDisk) && !hasTreeDeps && pkg?.packageJson) {\n // Pass the declared version range so that resolution skips wrong-version hoisted packages and\n // finds the correct nested copy.\n const pkgOptionalDecl = pkg.packageJson.optionalDependencies || {}\n const pkgDepsDecl = { ...(pkg.packageJson.dependencies || {}), ...pkgOptionalDecl }\n for (const [depName, depRange] of Object.entries(pkgDepsDecl)) {\n const resolved = await this.locateFromDepOrRoot(depName, pkg.packageDir, typeof depRange === \"string\" ? depRange : undefined)\n if (!resolved) {\n // A miss here silently ships a broken app (the dependency is simply absent from the\n // asar and only fails at runtime with MODULE_NOT_FOUND), so surface it in the log\n // summary. Optional deps are an expected miss and get the quieter bucket.\n this.logMissingDependency(`${depName}@${depRange}`, pkgOptionalDecl[depName] != null)\n continue\n }\n await this.visitDep(\n depName,\n {\n from: depName,\n name: depName,\n version: resolved.packageJson.version,\n path: resolved.packageDir,\n dependencies: {},\n optionalDependencies: {},\n } as unknown as PnpmDependency,\n true\n )\n }\n } else {\n await this.collectDepsRecursively(value)\n }\n }\n\n private async collectDepsRecursively(tree: PnpmDependency): Promise<void> {\n for (const [key, value] of Object.entries(tree.dependencies || {})) {\n await this.visitDep(key, value)\n }\n for (const [key, value] of Object.entries(tree.optionalDependencies || {})) {\n await this.visitDep(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 // 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 this.rootTree = result !== tree ? result : (this.allWorkspacePackages.find(pkg => pkg.name === packageName || pkg.from === packageName) ?? tree)\n return this.rootTree\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"]}
|
|
@@ -76,7 +76,8 @@ export interface WindowsSigntoolConfiguration {
|
|
|
76
76
|
*/
|
|
77
77
|
readonly sign?: CustomWindowsSign | string | null;
|
|
78
78
|
/**
|
|
79
|
-
* Array of signing algorithms used. For AppX `sha256` is always used.
|
|
79
|
+
* Array of signing algorithms used. For AppX/MSIX `sha256` is always used. `.msi` cannot be dual-signed,
|
|
80
|
+
* so it is signed once, with `sha256` unless `sha1` is the only algorithm listed.
|
|
80
81
|
* @default ['sha1', 'sha256']
|
|
81
82
|
*/
|
|
82
83
|
readonly signingHashAlgorithms?: Array<"sha1" | "sha256"> | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"winOptions.js","sourceRoot":"","sources":["../../src/options/winOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { Nullish } from \"builder-util-runtime\"\nimport { CustomWindowsSign } from \"../codeSign/windowsSignToolManager\"\nimport { PlatformSpecificBuildOptions, TargetConfigType } from \"../index\"\n\nexport interface WindowsConfiguration extends PlatformSpecificBuildOptions {\n /**\n * The target package type: list of `nsis`, `nsis-web` (Web installer), `portable` ([portable]https://www.electron.build/nsis#portable) app without installation), `appx`, `msi`, `msi-wrapped`, `squirrel`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`.\n * AppX package can be built only on Windows 10.\n *\n * To use Squirrel.Windows please install `electron-builder-squirrel-windows` dependency.\n *\n * @default nsis\n */\n readonly target?: TargetConfigType\n\n /**\n * The path to application icon.\n * @default build/icon.ico\n */\n readonly icon?: string | null\n\n /**\n * The trademarks and registered trademarks.\n */\n readonly legalTrademarks?: string | null\n\n /**\n * Options for usage with signtool.exe\n * Cannot be used in conjunction with `azureSignOptions`, signing will default to Azure Trusted Signing\n */\n readonly signtoolOptions?: WindowsSigntoolConfiguration | null\n\n /**\n * Options for usage of Azure Trusted Signing service\n * Cannot be used in conjunction with `signtoolOptions`, signing will default to Azure Trusted Signing\n */\n readonly azureSignOptions?: WindowsAzureSigningConfiguration | null\n\n /**\n * Whether to verify the signature of an available update before installation.\n * The [publisher name](#publisherName) will be used for the signature verification.\n *\n * @default true\n */\n readonly verifyUpdateCodeSignature?: boolean\n\n /**\n * The [security level](https://msdn.microsoft.com/en-us/library/6ad1fshk.aspx#Anchor_9) at which the application requests to be executed.\n * Cannot be specified per target, allowed only in the `win`.\n * @default asInvoker\n */\n readonly requestedExecutionLevel?: RequestedExecutionLevel | null\n\n /**\n * Whether to sign and add metadata to executable via [`resedit`](https://www.npmjs.com/package/resedit).\n * Metadata includes information about the app name/description/version, publisher, copyright, etc.\n * This property also is responsible for adding the app icon and setting execution level.\n * Set to `false` only if you need to fully disable resedit-based resource editing.\n * To skip only code signing while keeping resource editing, use `signExecutable: false` instead.\n * @default true\n */\n readonly signAndEditExecutable?: boolean\n\n /**\n * Whether to sign Windows executables and any additional files matched by `signExts`.\n * Set to `false` to skip Windows code signing while still editing executable resources\n * (icon, metadata, etc. via [`resedit`](https://www.npmjs.com/package/resedit)).\n * This option is not limited to the main executable edit/sign flow and can also affect\n * signing of Windows installers or other artifacts that use the standard signing path.\n * @default true\n */\n readonly signExecutable?: boolean\n\n /**\n * Explicit file name/extensions (`str.endsWith`) to also sign. Advanced option.\n * Supports negative patterns, e.g. example that excludes `.appx` files: `[\"somefilename\", \".dll\", \"!.appx\"]`.\n * @see https://github.com/electron-userland/electron-builder/issues/7329\n * @default null\n */\n readonly signExts?: string[] | null\n}\n\nexport type RequestedExecutionLevel = \"asInvoker\" | \"highestAvailable\" | \"requireAdministrator\"\n\nexport interface WindowsSigntoolConfiguration {\n /**\n * The custom function (or path to file or module id) to sign Windows executables\n */\n readonly sign?: CustomWindowsSign | string | null\n\n /**\n * Array of signing algorithms used. For AppX `sha256` is always used.\n * @default ['sha1', 'sha256']\n */\n readonly signingHashAlgorithms?: Array<\"sha1\" | \"sha256\"> | null\n\n /**\n * The path to the *.pfx certificate you want to sign with. Please use it only if you cannot use env variable `CSC_LINK` (`WIN_CSC_LINK`) for some reason.\n * Please see [Code Signing](https://www.electron.build/code-signing).\n */\n readonly certificateFile?: string | null\n\n /**\n * The password to the certificate provided in `certificateFile`. Please use it only if you cannot use env variable `CSC_KEY_PASSWORD` (`WIN_CSC_KEY_PASSWORD`) for some reason.\n * Please see [Code Signing](https://www.electron.build/code-signing).\n */\n readonly certificatePassword?: string | null\n\n /**\n * The name of the subject of the signing certificate, which is often labeled with the field name `issued to`. Required only for EV Code Signing and works only on Windows (or on macOS if [Parallels Desktop](https://www.parallels.com/products/desktop/) Windows 10 virtual machines exits).\n */\n readonly certificateSubjectName?: string | null\n\n /**\n * The SHA1 hash of the signing certificate. The SHA1 hash is commonly specified when multiple certificates satisfy the criteria specified by the remaining switches. Works only on Windows (or on macOS if [Parallels Desktop](https://www.parallels.com/products/desktop/) Windows 10 virtual machines exits).\n */\n readonly certificateSha1?: string | null\n\n /**\n * The path to an additional certificate file you want to add to the signature block.\n */\n readonly additionalCertificateFile?: string | null\n\n /**\n * The URL of the RFC 3161 time stamp server.\n * @default http://timestamp.digicert.com\n */\n readonly rfc3161TimeStampServer?: string | null\n\n /**\n * The URL of the time stamp server.\n * @default http://timestamp.digicert.com\n */\n readonly timeStampServer?: string | null\n\n /**\n * [The publisher name](https://github.com/electron-userland/electron-builder/issues/1187#issuecomment-278972073), exactly as in your code signed certificate. Several names can be provided.\n * Defaults to common name from your code signing certificate.\n */\n readonly publisherName?: string | Array<string> | null\n}\n\n// https://learn.microsoft.com/en-us/azure/trusted-signing/how-to-signing-integrations\nexport interface WindowsAzureSigningConfiguration {\n /**\n * [The publisher name](https://github.com/electron-userland/electron-builder/issues/1187#issuecomment-278972073), exactly as in your code signed certificate. Several names can be provided.\n */\n readonly publisherName: string\n /**\n * The Trusted Signing Account endpoint. The URI value must have a URI that aligns to the\n * region your Trusted Signing Account and Certificate Profile you are specifying were created\n * in during the setup of these resources.\n *\n * Translates to field: Endpoint\n *\n * Requires one of environment variable configurations for authenticating to Microsoft Entra ID per [Microsoft's documentation](https://learn.microsoft.com/en-us/dotnet/api/azure.identity.environmentcredential?view=azure-dotnet#definition)\n */\n readonly endpoint: string\n /**\n * The Certificate Profile name. Translates to field: CertificateProfileName\n */\n readonly certificateProfileName: string\n /**\n * The Code Signing Signing Account name. Translates to field: CodeSigningAccountName\n */\n readonly codeSigningAccountName: string\n /**\n * The File Digest for signing each file. Translates to field: FileDigest\n * @default SHA256\n */\n readonly fileDigest?: string\n /**\n * The Timestamp rfc3161 server. Translates to field: TimestampRfc3161\n * @default http://timestamp.acs.microsoft.com\n */\n readonly timestampRfc3161?: string\n /**\n * The Timestamp Digest. Translates to field: TimestampDigest\n * @default SHA256\n */\n readonly timestampDigest?: string\n /**\n * Allow other CLI parameters (verbatim case-sensitive) to `Invoke-TrustedSigning`\n * Note: Key-Value pairs with `undefined`/`null` value are filtered out of the command.\n */\n [k: string]: string | Nullish\n}\n"]}
|
|
1
|
+
{"version":3,"file":"winOptions.js","sourceRoot":"","sources":["../../src/options/winOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { Nullish } from \"builder-util-runtime\"\nimport { CustomWindowsSign } from \"../codeSign/windowsSignToolManager\"\nimport { PlatformSpecificBuildOptions, TargetConfigType } from \"../index\"\n\nexport interface WindowsConfiguration extends PlatformSpecificBuildOptions {\n /**\n * The target package type: list of `nsis`, `nsis-web` (Web installer), `portable` ([portable]https://www.electron.build/nsis#portable) app without installation), `appx`, `msi`, `msi-wrapped`, `squirrel`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`.\n * AppX package can be built only on Windows 10.\n *\n * To use Squirrel.Windows please install `electron-builder-squirrel-windows` dependency.\n *\n * @default nsis\n */\n readonly target?: TargetConfigType\n\n /**\n * The path to application icon.\n * @default build/icon.ico\n */\n readonly icon?: string | null\n\n /**\n * The trademarks and registered trademarks.\n */\n readonly legalTrademarks?: string | null\n\n /**\n * Options for usage with signtool.exe\n * Cannot be used in conjunction with `azureSignOptions`, signing will default to Azure Trusted Signing\n */\n readonly signtoolOptions?: WindowsSigntoolConfiguration | null\n\n /**\n * Options for usage of Azure Trusted Signing service\n * Cannot be used in conjunction with `signtoolOptions`, signing will default to Azure Trusted Signing\n */\n readonly azureSignOptions?: WindowsAzureSigningConfiguration | null\n\n /**\n * Whether to verify the signature of an available update before installation.\n * The [publisher name](#publisherName) will be used for the signature verification.\n *\n * @default true\n */\n readonly verifyUpdateCodeSignature?: boolean\n\n /**\n * The [security level](https://msdn.microsoft.com/en-us/library/6ad1fshk.aspx#Anchor_9) at which the application requests to be executed.\n * Cannot be specified per target, allowed only in the `win`.\n * @default asInvoker\n */\n readonly requestedExecutionLevel?: RequestedExecutionLevel | null\n\n /**\n * Whether to sign and add metadata to executable via [`resedit`](https://www.npmjs.com/package/resedit).\n * Metadata includes information about the app name/description/version, publisher, copyright, etc.\n * This property also is responsible for adding the app icon and setting execution level.\n * Set to `false` only if you need to fully disable resedit-based resource editing.\n * To skip only code signing while keeping resource editing, use `signExecutable: false` instead.\n * @default true\n */\n readonly signAndEditExecutable?: boolean\n\n /**\n * Whether to sign Windows executables and any additional files matched by `signExts`.\n * Set to `false` to skip Windows code signing while still editing executable resources\n * (icon, metadata, etc. via [`resedit`](https://www.npmjs.com/package/resedit)).\n * This option is not limited to the main executable edit/sign flow and can also affect\n * signing of Windows installers or other artifacts that use the standard signing path.\n * @default true\n */\n readonly signExecutable?: boolean\n\n /**\n * Explicit file name/extensions (`str.endsWith`) to also sign. Advanced option.\n * Supports negative patterns, e.g. example that excludes `.appx` files: `[\"somefilename\", \".dll\", \"!.appx\"]`.\n * @see https://github.com/electron-userland/electron-builder/issues/7329\n * @default null\n */\n readonly signExts?: string[] | null\n}\n\nexport type RequestedExecutionLevel = \"asInvoker\" | \"highestAvailable\" | \"requireAdministrator\"\n\nexport interface WindowsSigntoolConfiguration {\n /**\n * The custom function (or path to file or module id) to sign Windows executables\n */\n readonly sign?: CustomWindowsSign | string | null\n\n /**\n * Array of signing algorithms used. For AppX/MSIX `sha256` is always used. `.msi` cannot be dual-signed,\n * so it is signed once, with `sha256` unless `sha1` is the only algorithm listed.\n * @default ['sha1', 'sha256']\n */\n readonly signingHashAlgorithms?: Array<\"sha1\" | \"sha256\"> | null\n\n /**\n * The path to the *.pfx certificate you want to sign with. Please use it only if you cannot use env variable `CSC_LINK` (`WIN_CSC_LINK`) for some reason.\n * Please see [Code Signing](https://www.electron.build/code-signing).\n */\n readonly certificateFile?: string | null\n\n /**\n * The password to the certificate provided in `certificateFile`. Please use it only if you cannot use env variable `CSC_KEY_PASSWORD` (`WIN_CSC_KEY_PASSWORD`) for some reason.\n * Please see [Code Signing](https://www.electron.build/code-signing).\n */\n readonly certificatePassword?: string | null\n\n /**\n * The name of the subject of the signing certificate, which is often labeled with the field name `issued to`. Required only for EV Code Signing and works only on Windows (or on macOS if [Parallels Desktop](https://www.parallels.com/products/desktop/) Windows 10 virtual machines exits).\n */\n readonly certificateSubjectName?: string | null\n\n /**\n * The SHA1 hash of the signing certificate. The SHA1 hash is commonly specified when multiple certificates satisfy the criteria specified by the remaining switches. Works only on Windows (or on macOS if [Parallels Desktop](https://www.parallels.com/products/desktop/) Windows 10 virtual machines exits).\n */\n readonly certificateSha1?: string | null\n\n /**\n * The path to an additional certificate file you want to add to the signature block.\n */\n readonly additionalCertificateFile?: string | null\n\n /**\n * The URL of the RFC 3161 time stamp server.\n * @default http://timestamp.digicert.com\n */\n readonly rfc3161TimeStampServer?: string | null\n\n /**\n * The URL of the time stamp server.\n * @default http://timestamp.digicert.com\n */\n readonly timeStampServer?: string | null\n\n /**\n * [The publisher name](https://github.com/electron-userland/electron-builder/issues/1187#issuecomment-278972073), exactly as in your code signed certificate. Several names can be provided.\n * Defaults to common name from your code signing certificate.\n */\n readonly publisherName?: string | Array<string> | null\n}\n\n// https://learn.microsoft.com/en-us/azure/trusted-signing/how-to-signing-integrations\nexport interface WindowsAzureSigningConfiguration {\n /**\n * [The publisher name](https://github.com/electron-userland/electron-builder/issues/1187#issuecomment-278972073), exactly as in your code signed certificate. Several names can be provided.\n */\n readonly publisherName: string\n /**\n * The Trusted Signing Account endpoint. The URI value must have a URI that aligns to the\n * region your Trusted Signing Account and Certificate Profile you are specifying were created\n * in during the setup of these resources.\n *\n * Translates to field: Endpoint\n *\n * Requires one of environment variable configurations for authenticating to Microsoft Entra ID per [Microsoft's documentation](https://learn.microsoft.com/en-us/dotnet/api/azure.identity.environmentcredential?view=azure-dotnet#definition)\n */\n readonly endpoint: string\n /**\n * The Certificate Profile name. Translates to field: CertificateProfileName\n */\n readonly certificateProfileName: string\n /**\n * The Code Signing Signing Account name. Translates to field: CodeSigningAccountName\n */\n readonly codeSigningAccountName: string\n /**\n * The File Digest for signing each file. Translates to field: FileDigest\n * @default SHA256\n */\n readonly fileDigest?: string\n /**\n * The Timestamp rfc3161 server. Translates to field: TimestampRfc3161\n * @default http://timestamp.acs.microsoft.com\n */\n readonly timestampRfc3161?: string\n /**\n * The Timestamp Digest. Translates to field: TimestampDigest\n * @default SHA256\n */\n readonly timestampDigest?: string\n /**\n * Allow other CLI parameters (verbatim case-sensitive) to `Invoke-TrustedSigning`\n * Note: Key-Value pairs with `undefined`/`null` value are filtered out of the command.\n */\n [k: string]: string | Nullish\n}\n"]}
|
package/out/targets/archive.d.ts
CHANGED
|
@@ -14,6 +14,12 @@ export interface ArchiveOptions {
|
|
|
14
14
|
*/
|
|
15
15
|
isArchiveHeaderCompressed?: boolean;
|
|
16
16
|
dictSize?: number;
|
|
17
|
+
/**
|
|
18
|
+
* 7z only: LZMA2 block size in MB. Without it, 7-Zip splits LZMA2 into independent blocks only when it compresses with
|
|
19
|
+
* several block threads, so the archive bytes depend on the build host's CPU count. A fixed size makes them identical
|
|
20
|
+
* on any host. Ignored when storing, and when `method` names another codec.
|
|
21
|
+
*/
|
|
22
|
+
blockSize?: number;
|
|
17
23
|
excluded?: Array<string> | null;
|
|
18
24
|
method?: "Copy" | "LZMA" | "Deflate" | "DEFAULT";
|
|
19
25
|
isRegularFile?: boolean;
|
package/out/targets/archive.js
CHANGED
|
@@ -99,14 +99,24 @@ function compute7zCompressArgs(format, options = {}) {
|
|
|
99
99
|
args.push("-mfb=258", "-mpass=15");
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
const { blockSize } = options;
|
|
103
|
+
const is7z = format === "7z" || format.endsWith(".7z");
|
|
104
|
+
// -mx=0 with an explicit -m0=LZMA2 would compress instead of store, so the block size is only pinned when compressing
|
|
105
|
+
const pinBlockSize = is7z && typeof blockSize === "number" && !storeOnly && compressionLevel !== "0" && (options.method == null || options.method === "DEFAULT");
|
|
106
|
+
if (pinBlockSize) {
|
|
107
|
+
if (!Number.isInteger(blockSize) || blockSize <= 0) {
|
|
108
|
+
throw new Error(`blockSize must be a positive integer (MB), got ${blockSize}`);
|
|
109
|
+
}
|
|
110
|
+
args.push(`-m0=LZMA2${options.dictSize != null ? `:d=${options.dictSize}m` : ""}:c=${blockSize}m`);
|
|
111
|
+
}
|
|
112
|
+
else if (options.dictSize != null) {
|
|
103
113
|
args.push(`-md=${options.dictSize}m`);
|
|
104
114
|
}
|
|
105
115
|
// Disable NTFS timestamps for reproducible archives
|
|
106
116
|
if (!options.isRegularFile) {
|
|
107
117
|
args.push("-mtc=off");
|
|
108
118
|
}
|
|
109
|
-
if (
|
|
119
|
+
if (is7z) {
|
|
110
120
|
if (options.solid === false) {
|
|
111
121
|
args.push("-ms=off");
|
|
112
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/targets/archive.ts"],"names":[],"mappings":";;AA+BA,kBAiCC;AAmED,wDAEC;AAkBD,sDA2EC;AAID,0BAoGC;AA1UD,+CAAqF;AACrF,uCAA+B;AAC/B,6BAA4B;AAC5B,6BAA4B;AAG5B,kCAAoD;AACpD,6CAA2D;AAC3D,4CAA6C;AAE7C,sGAAsG;AACtG,qGAAqG;AACrG,6EAA6E;AAC7E,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;AAE1G,SAAS,wBAAwB,CAAC,KAAa;IAC7C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,K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BAAI,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,sBAAO,CAAC,OAAO,CAAC,CAAA;IACnH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,OAAkB;IACrC,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC7B,IAAI,sBAAO,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { debug7z, exec, exists, log, statOrNull, unlinkIfExists } from \"builder-util\"\nimport { move } from \"fs-extra\"\nimport * as path from \"path\"\nimport { create } from \"tar\"\nimport { TarOptionsWithAliasesAsync } from \"tar/dist/commonjs/options\"\nimport { TmpDir } from \"temp-file\"\nimport { CompressionLevel, Platform } from \"../core\"\nimport { getLinuxToolsMacToolset } from \"../toolsets/linux\"\nimport { getPath7za } from \"../toolsets/7zip\"\n\n// Values accepted by ELECTRON_BUILDER_7Z_FILTER (passed through as `-mf=<value>`). \"OFF\" disables the\n// branch/exec filter entirely (plain LZMA2); the rest are 7-Zip branch converters. 7za matches these\n// case-insensitively, so the value is canonicalized to uppercase before use.\nconst ALLOWED_7Z_FILTERS = new Set([\"OFF\", \"BCJ\", \"BCJ2\", \"ARM\", \"ARMT\", \"IA64\", \"PPC\", \"SPARC\", \"DELTA\"])\n\nfunction validateCompressionLevel(level: string): void {\n if (!/^[0-9]$/.test(level)) {\n throw new Error(`ELECTRON_BUILDER_COMPRESSION_LEVEL must be a single digit 0-9, got: \"${level}\"`)\n }\n}\n\ntype TarConfig = {\n compression: CompressionLevel | null | undefined\n format: string\n outFile: string\n dirToArchive: string\n isMacApp: boolean\n tempDirManager: TmpDir\n}\n\n/** @internal */\nexport async function tar({ compression, format, outFile, dirToArchive, isMacApp, tempDirManager }: TarConfig): Promise<void> {\n const tarFile = await tempDirManager.getTempFile({ suffix: \".tar\" })\n const tarArgs: TarOptionsWithAliasesAsync = {\n file: tarFile,\n portable: true,\n cwd: dirToArchive,\n prefix: path.basename(outFile, `.${format}`),\n }\n let tarDirectory = \".\"\n if (isMacApp) {\n delete tarArgs.prefix\n tarArgs.cwd = path.dirname(dirToArchive)\n tarDirectory = path.basename(dirToArchive)\n }\n\n await Promise.all([\n create(tarArgs, [tarDirectory]),\n // remove file before - 7z doesn't overwrite file, but update\n unlinkIfExists(outFile),\n ])\n\n if (format === \"tar.lz\") {\n const lzipPath = process.platform === \"darwin\" ? (await getLinuxToolsMacToolset()).lzip : \"lzip\"\n await exec(lzipPath, [compression === \"store\" ? \"-1\" : \"-9\", \"--keep\" /* keep (don't delete) input files */, tarFile])\n // lzip creates the output file in the same directory as the input with a .lz suffix\n await move(`${tarFile}.lz`, outFile)\n return\n }\n\n const compressFormat = format === \"tar.xz\" ? \"xz\" : format === \"tar.bz2\" ? \"bzip2\" : \"gzip\"\n const args = compute7zCompressArgs(compressFormat, { isRegularFile: true, method: \"DEFAULT\", compression })\n args.push(outFile, tarFile)\n await exec(await getPath7za(), args, { cwd: path.dirname(dirToArchive) }, debug7z.enabled)\n}\n\nexport interface ArchiveOptions {\n compression?: CompressionLevel | null\n\n /**\n * @default false\n */\n withoutDir?: boolean\n\n /**\n * @default true\n */\n solid?: boolean\n\n /**\n * @default true\n */\n isArchiveHeaderCompressed?: boolean\n\n dictSize?: number\n excluded?: Array<string> | null\n\n // DEFAULT allows to disable custom logic and do not pass method switch at all\n method?: \"Copy\" | \"LZMA\" | \"Deflate\" | \"DEFAULT\"\n\n isRegularFile?: boolean\n\n /**\n * Preserve symlinks (e.g. macOS .framework `Versions/Current`) instead of dereferencing them.\n * Passes `-snl` to 7za — modern 7-Zip derefs by default, which breaks bundle codesigning. See #9846.\n * @default false\n */\n preserveSymlinks?: boolean\n\n /**\n * Paths, relative to the archived directory, to append as uncompressed (`Copy`) members instead of\n * compressing them with the rest of the archive. Differential updates diff the *compressed* archive\n * with a content-defined blockmap, and a large compressed member (an asar) diverges wholesale from\n * its previous version on any change — storing it keeps unchanged regions byte-identical between\n * builds, so the delta stays proportional to what actually changed. The stored members are excluded\n * from the main (compressed) pass and appended in a second 7za invocation with `-mx=0`; the\n * `ELECTRON_BUILDER_COMPRESSION_LEVEL` override deliberately does not apply to them (byte-stability\n * is the point), while `preserveSymlinks` and `isArchiveHeaderCompressed` are mirrored into the\n * append pass. Paths that do not exist are skipped. Not supported by the native-zip NFD fallback.\n */\n storedPaths?: Array<string> | null\n\n /**\n * Restrict the 7z filter to one the install-time extractor (the self-vendored Nsis7z plugin) can\n * decode. Modern 7za (24.09) auto-applies a CPU branch converter to executable content at\n * `-mx>=1` — `BCJ2` on x86/x64 and `ARM64` on arm64 — which that decoder silently skips, dropping\n * every executable from the install. When set, the archive is pinned to the single-stream `BCJ`\n * filter while compressing (decodable, and the best-ratio filter that decoder supports) and to\n * plain `Copy` while storing. Deliberately NOT overridable by `ELECTRON_BUILDER_7Z_FILTER`, which\n * could otherwise reintroduce an unreadable archive. Only affects the 7z format. See #9983.\n * @default false\n */\n installTimeDecodable?: boolean\n}\n\n/**\n * Whether archives for the given target platform should preserve symlinks (i.e. pass `-snl`).\n * Non-Windows targets preserve them: macOS `.framework` bundles need them for codesigning (#9846)\n * and Linux bundles may legitimately contain them. Windows dereferences because restoring symlinks\n * there requires elevated privileges. Keyed on the target platform, not the build host.\n */\nexport function shouldPreserveSymlinks(platform: Platform): boolean {\n return platform !== Platform.WINDOWS\n}\n\n/**\n * Builds the exclude switches for the given masks, rejecting any pattern that contains a path\n * traversal sequence. `prefix` is the tool-specific flag (`-xr!` for 7za, `-x` for native zip).\n */\nfunction buildExcludeArgs(excluded: Array<string> | null | undefined, prefix: string): Array<string> {\n if (excluded == null) {\n return []\n }\n return excluded.map(mask => {\n if (mask.includes(\"..\")) {\n throw new Error(`Excluded archive pattern contains path traversal sequence: \"${mask}\"`)\n }\n return `${prefix}${mask}`\n })\n}\n\nexport function compute7zCompressArgs(format: string, options: ArchiveOptions = {}) {\n let storeOnly = options.compression === \"store\"\n const args = debug7zArgs(\"a\")\n\n const compressionLevel = process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL\n if (compressionLevel != null) {\n validateCompressionLevel(compressionLevel)\n storeOnly = false // env var overrides \"store\" config\n args.push(`-mx=${compressionLevel}`)\n } else if (storeOnly) {\n // -mx=0 is the universal \"no compression\" flag across all formats (zip, 7z, gzip, xz, bzip2).\n // -mm=Copy would only be valid for zip/7z and causes E_INVALIDARG on xz/gzip/bzip2.\n args.push(\"-mx=0\")\n } else {\n const isZip = format === \"zip\"\n // ZIP uses level 7 by default; everything else (7z, gzip, xz, bzip2) uses level 9\n args.push(\"-mx=\" + (isZip && options.compression !== \"maximum\" ? \"7\" : \"9\"))\n if (isZip && options.compression === \"maximum\") {\n // http://superuser.com/a/742034\n args.push(\"-mfb=258\", \"-mpass=15\")\n }\n }\n\n if (options.dictSize != null) {\n args.push(`-md=${options.dictSize}m`)\n }\n\n // Disable NTFS timestamps for reproducible archives\n if (!options.isRegularFile) {\n args.push(\"-mtc=off\")\n }\n\n if (format === \"7z\" || format.endsWith(\".7z\")) {\n if (options.solid === false) {\n args.push(\"-ms=off\")\n }\n\n if (options.isArchiveHeaderCompressed === false) {\n args.push(\"-mhc=off\")\n }\n\n // Branch/exec filter selection. installTimeDecodable archives are unpacked by the self-vendored\n // Nsis7z extractor, whose decoder only understands plain LZMA2/Copy and the single-stream BCJ\n // filter — not the CPU branch converters modern 7za auto-applies (BCJ2 on x86/x64, ARM64 on\n // arm64). So pin them to BCJ while compressing (the best filter that decoder can read; Copy\n // needs none) and do not honor ELECTRON_BUILDER_7Z_FILTER, which could reintroduce an unreadable\n // archive. Any other 7z archive may use ELECTRON_BUILDER_7Z_FILTER, else 7za's auto-selection.\n if (options.installTimeDecodable) {\n if (!storeOnly) {\n args.push(\"-mf=BCJ\")\n }\n } else {\n const sevenZFilter = process.env.ELECTRON_BUILDER_7Z_FILTER\n if (sevenZFilter) {\n const canonicalFilter = sevenZFilter.toUpperCase()\n if (!ALLOWED_7Z_FILTERS.has(canonicalFilter)) {\n throw new Error(`ELECTRON_BUILDER_7Z_FILTER must be one of: ${[...ALLOWED_7Z_FILTERS].join(\", \")}`)\n }\n args.push(`-mf=${canonicalFilter}`)\n }\n }\n\n args.push(\"-mtm=off\", \"-mta=off\")\n }\n\n if (options.method != null && options.method !== \"DEFAULT\") {\n args.push(`-mm=${options.method}`)\n } else if (format === \"zip\") {\n // -mm is only set explicitly for zip (Deflate/Copy) and includes the UTF-8 flag.\n // For all other formats the codec is implicit from the output file extension.\n args.push(`-mm=${storeOnly ? \"Copy\" : \"Deflate\"}`)\n args.push(\"-mcu\")\n }\n\n return args\n}\n\n// 7z is very fast, so, use ultra compression\n/** @internal */\nexport async function archive(format: string, outFile: string, dirToArchive: string, options: ArchiveOptions = {}): Promise<string> {\n const outFileStat = await statOrNull(outFile)\n const dirStat = await statOrNull(dirToArchive)\n if (outFileStat && dirStat && outFileStat.mtime > dirStat.mtime) {\n log.info({ reason: \"Archive file is up to date\", outFile }, `skipped archiving`)\n return outFile\n }\n\n // Use 7za for all formats (matches pre-26.15 behavior). Native macOS `zip` is only a\n // fallback for NFD-normalized filenames, which 7za mangles.\n let use7z = true\n if (process.platform === \"darwin\" && format === \"zip\" && dirToArchive.normalize(\"NFC\") !== dirToArchive) {\n log.warn({ reason: \"7z doesn't support NFD-normalized filenames\" }, `using zip`)\n use7z = false\n }\n\n // Resolve storedPaths before the main pass so they can be excluded from it. Member names are\n // native-separator, relative to the 7za cwd (which differs with withoutDir), so the same string\n // works as both the exact `-x!` exclude mask and the append argument.\n const storedMembers: Array<string> = []\n for (const storedPath of options.storedPaths ?? []) {\n if (storedPath.includes(\"..\")) {\n throw new Error(`Stored archive path contains path traversal sequence: \"${storedPath}\"`)\n }\n if (await exists(path.join(dirToArchive, storedPath))) {\n storedMembers.push(path.normalize(options.withoutDir ? storedPath : path.join(path.basename(dirToArchive), storedPath)))\n }\n }\n if (storedMembers.length > 0 && !use7z) {\n throw new Error(\"storedPaths is not supported with the native zip fallback\")\n }\n\n if (use7z) {\n const args = compute7zCompressArgs(format, options)\n // Modern 7-Zip (24.09) dereferences symlinks by default; the 7-Zip 16.02 bundled before\n // 26.15 stored them as links. Without -snl, a macOS .framework `Versions/Current` extracts\n // as a real directory → codesign \"bundle format is ambiguous\" → breaks Squirrel.Mac\n // auto-update (#9846). Callers enable it for all non-Windows targets (see ArchiveTarget).\n if (options.preserveSymlinks) {\n args.push(\"-snl\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n args.push(...buildExcludeArgs(options.excluded, \"-xr!\"))\n // `-x!` (exact, non-recursive) so only the member itself is skipped, never a same-named sibling\n args.push(...storedMembers.map(member => `-x!${member}`))\n\n const cwd = options.withoutDir ? dirToArchive : path.dirname(dirToArchive)\n try {\n await exec(await getPath7za(), args, { cwd }, debug7z.enabled)\n } catch (e: any) {\n if (e.code === \"ENOENT\" && !(await exists(dirToArchive))) {\n throw new Error(`Cannot create archive: \"${dirToArchive}\" doesn't exist`)\n } else {\n throw e\n }\n }\n\n if (storedMembers.length > 0) {\n // Second pass: append the stored members with no compression. -mx=0 unconditionally — the\n // compression-level env override must not reach these members (see storedPaths docs). The\n // main pass's symlink, timestamp, and header-compression flags are mirrored so the option\n // stays generic: the append rewrites the archive header and may itself store a symlink.\n const appendArgs = debug7zArgs(\"a\")\n appendArgs.push(\"-mx=0\")\n if (options.preserveSymlinks) {\n appendArgs.push(\"-snl\")\n }\n if (!options.isRegularFile) {\n appendArgs.push(\"-mtc=off\")\n }\n if (format === \"7z\" || format.endsWith(\".7z\")) {\n if (options.isArchiveHeaderCompressed === false) {\n appendArgs.push(\"-mhc=off\")\n }\n appendArgs.push(\"-mtm=off\", \"-mta=off\")\n } else if (format === \"zip\") {\n appendArgs.push(\"-mm=Copy\", \"-mcu\")\n }\n appendArgs.push(outFile, ...storedMembers)\n await exec(await getPath7za(), appendArgs, { cwd }, debug7z.enabled)\n }\n } else {\n // macOS native zip (NFD fallback): -y preserves symlinks\n const args = [\"-q\", \"-r\", \"-y\"]\n if (debug7z.enabled) {\n args.push(\"-v\")\n }\n if (options.compression === \"store\") {\n args.push(\"-0\")\n } else {\n args.push(options.compression === \"maximum\" ? \"-9\" : \"-7\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n args.push(...buildExcludeArgs(options.excluded, \"-x\"))\n await exec(\"zip\", args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n }\n\n return outFile\n}\n\nfunction debug7zArgs(command: \"a\" | \"x\"): Array<string> {\n const args = [command, \"-bd\"]\n if (debug7z.enabled) {\n args.push(\"-bb\")\n }\n return args\n}\n"]}
|
|
1
|
+
{"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/targets/archive.ts"],"names":[],"mappings":";;AA+BA,kBAiCC;AA2ED,wDAEC;AAkBD,sDAoFC;AAID,0BAoGC;AA3VD,+CAAqF;AACrF,uCAA+B;AAC/B,6BAA4B;AAC5B,6BAA4B;AAG5B,kCAAoD;AACpD,6CAA2D;AAC3D,4CAA6C;AAE7C,sGAAsG;AACtG,qGAAqG;AACrG,6EAA6E;AAC7E,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;AAE1G,SAAS,wBAAwB,CAAC,KAAa;IAC7C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAA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C,OAAO,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjB,CAAC;QACD,IAAI,OAAO,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAC5D,CAAC;QACD,MAAM,IAAA,6BAAc,EAAC,OAAO,CAAC,CAAA;QAC7B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAA;QAC1E,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;QACtD,MAAM,IAAA,mBAAI,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,sBAAO,CAAC,OAAO,CAAC,CAAA;IACnH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,OAAkB;IACrC,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC7B,IAAI,sBAAO,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { debug7z, exec, exists, log, statOrNull, unlinkIfExists } from \"builder-util\"\nimport { move } from \"fs-extra\"\nimport * as path from \"path\"\nimport { create } from \"tar\"\nimport { TarOptionsWithAliasesAsync } from \"tar/dist/commonjs/options\"\nimport { TmpDir } from \"temp-file\"\nimport { CompressionLevel, Platform } from \"../core\"\nimport { getLinuxToolsMacToolset } from \"../toolsets/linux\"\nimport { getPath7za } from \"../toolsets/7zip\"\n\n// Values accepted by ELECTRON_BUILDER_7Z_FILTER (passed through as `-mf=<value>`). \"OFF\" disables the\n// branch/exec filter entirely (plain LZMA2); the rest are 7-Zip branch converters. 7za matches these\n// case-insensitively, so the value is canonicalized to uppercase before use.\nconst ALLOWED_7Z_FILTERS = new Set([\"OFF\", \"BCJ\", \"BCJ2\", \"ARM\", \"ARMT\", \"IA64\", \"PPC\", \"SPARC\", \"DELTA\"])\n\nfunction validateCompressionLevel(level: string): void {\n if (!/^[0-9]$/.test(level)) {\n throw new Error(`ELECTRON_BUILDER_COMPRESSION_LEVEL must be a single digit 0-9, got: \"${level}\"`)\n }\n}\n\ntype TarConfig = {\n compression: CompressionLevel | null | undefined\n format: string\n outFile: string\n dirToArchive: string\n isMacApp: boolean\n tempDirManager: TmpDir\n}\n\n/** @internal */\nexport async function tar({ compression, format, outFile, dirToArchive, isMacApp, tempDirManager }: TarConfig): Promise<void> {\n const tarFile = await tempDirManager.getTempFile({ suffix: \".tar\" })\n const tarArgs: TarOptionsWithAliasesAsync = {\n file: tarFile,\n portable: true,\n cwd: dirToArchive,\n prefix: path.basename(outFile, `.${format}`),\n }\n let tarDirectory = \".\"\n if (isMacApp) {\n delete tarArgs.prefix\n tarArgs.cwd = path.dirname(dirToArchive)\n tarDirectory = path.basename(dirToArchive)\n }\n\n await Promise.all([\n create(tarArgs, [tarDirectory]),\n // remove file before - 7z doesn't overwrite file, but update\n unlinkIfExists(outFile),\n ])\n\n if (format === \"tar.lz\") {\n const lzipPath = process.platform === \"darwin\" ? (await getLinuxToolsMacToolset()).lzip : \"lzip\"\n await exec(lzipPath, [compression === \"store\" ? \"-1\" : \"-9\", \"--keep\" /* keep (don't delete) input files */, tarFile])\n // lzip creates the output file in the same directory as the input with a .lz suffix\n await move(`${tarFile}.lz`, outFile)\n return\n }\n\n const compressFormat = format === \"tar.xz\" ? \"xz\" : format === \"tar.bz2\" ? \"bzip2\" : \"gzip\"\n const args = compute7zCompressArgs(compressFormat, { isRegularFile: true, method: \"DEFAULT\", compression })\n args.push(outFile, tarFile)\n await exec(await getPath7za(), args, { cwd: path.dirname(dirToArchive) }, debug7z.enabled)\n}\n\nexport interface ArchiveOptions {\n compression?: CompressionLevel | null\n\n /**\n * @default false\n */\n withoutDir?: boolean\n\n /**\n * @default true\n */\n solid?: boolean\n\n /**\n * @default true\n */\n isArchiveHeaderCompressed?: boolean\n\n dictSize?: number\n\n /**\n * 7z only: LZMA2 block size in MB. Without it, 7-Zip splits LZMA2 into independent blocks only when it compresses with\n * several block threads, so the archive bytes depend on the build host's CPU count. A fixed size makes them identical\n * on any host. Ignored when storing, and when `method` names another codec.\n */\n blockSize?: number\n\n excluded?: Array<string> | null\n\n // DEFAULT allows to disable custom logic and do not pass method switch at all\n method?: \"Copy\" | \"LZMA\" | \"Deflate\" | \"DEFAULT\"\n\n isRegularFile?: boolean\n\n /**\n * Preserve symlinks (e.g. macOS .framework `Versions/Current`) instead of dereferencing them.\n * Passes `-snl` to 7za — modern 7-Zip derefs by default, which breaks bundle codesigning. See #9846.\n * @default false\n */\n preserveSymlinks?: boolean\n\n /**\n * Paths, relative to the archived directory, to append as uncompressed (`Copy`) members instead of\n * compressing them with the rest of the archive. Differential updates diff the *compressed* archive\n * with a content-defined blockmap, and a large compressed member (an asar) diverges wholesale from\n * its previous version on any change — storing it keeps unchanged regions byte-identical between\n * builds, so the delta stays proportional to what actually changed. The stored members are excluded\n * from the main (compressed) pass and appended in a second 7za invocation with `-mx=0`; the\n * `ELECTRON_BUILDER_COMPRESSION_LEVEL` override deliberately does not apply to them (byte-stability\n * is the point), while `preserveSymlinks` and `isArchiveHeaderCompressed` are mirrored into the\n * append pass. Paths that do not exist are skipped. Not supported by the native-zip NFD fallback.\n */\n storedPaths?: Array<string> | null\n\n /**\n * Restrict the 7z filter to one the install-time extractor (the self-vendored Nsis7z plugin) can\n * decode. Modern 7za (24.09) auto-applies a CPU branch converter to executable content at\n * `-mx>=1` — `BCJ2` on x86/x64 and `ARM64` on arm64 — which that decoder silently skips, dropping\n * every executable from the install. When set, the archive is pinned to the single-stream `BCJ`\n * filter while compressing (decodable, and the best-ratio filter that decoder supports) and to\n * plain `Copy` while storing. Deliberately NOT overridable by `ELECTRON_BUILDER_7Z_FILTER`, which\n * could otherwise reintroduce an unreadable archive. Only affects the 7z format. See #9983.\n * @default false\n */\n installTimeDecodable?: boolean\n}\n\n/**\n * Whether archives for the given target platform should preserve symlinks (i.e. pass `-snl`).\n * Non-Windows targets preserve them: macOS `.framework` bundles need them for codesigning (#9846)\n * and Linux bundles may legitimately contain them. Windows dereferences because restoring symlinks\n * there requires elevated privileges. Keyed on the target platform, not the build host.\n */\nexport function shouldPreserveSymlinks(platform: Platform): boolean {\n return platform !== Platform.WINDOWS\n}\n\n/**\n * Builds the exclude switches for the given masks, rejecting any pattern that contains a path\n * traversal sequence. `prefix` is the tool-specific flag (`-xr!` for 7za, `-x` for native zip).\n */\nfunction buildExcludeArgs(excluded: Array<string> | null | undefined, prefix: string): Array<string> {\n if (excluded == null) {\n return []\n }\n return excluded.map(mask => {\n if (mask.includes(\"..\")) {\n throw new Error(`Excluded archive pattern contains path traversal sequence: \"${mask}\"`)\n }\n return `${prefix}${mask}`\n })\n}\n\nexport function compute7zCompressArgs(format: string, options: ArchiveOptions = {}) {\n let storeOnly = options.compression === \"store\"\n const args = debug7zArgs(\"a\")\n\n const compressionLevel = process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL\n if (compressionLevel != null) {\n validateCompressionLevel(compressionLevel)\n storeOnly = false // env var overrides \"store\" config\n args.push(`-mx=${compressionLevel}`)\n } else if (storeOnly) {\n // -mx=0 is the universal \"no compression\" flag across all formats (zip, 7z, gzip, xz, bzip2).\n // -mm=Copy would only be valid for zip/7z and causes E_INVALIDARG on xz/gzip/bzip2.\n args.push(\"-mx=0\")\n } else {\n const isZip = format === \"zip\"\n // ZIP uses level 7 by default; everything else (7z, gzip, xz, bzip2) uses level 9\n args.push(\"-mx=\" + (isZip && options.compression !== \"maximum\" ? \"7\" : \"9\"))\n if (isZip && options.compression === \"maximum\") {\n // http://superuser.com/a/742034\n args.push(\"-mfb=258\", \"-mpass=15\")\n }\n }\n\n const { blockSize } = options\n const is7z = format === \"7z\" || format.endsWith(\".7z\")\n // -mx=0 with an explicit -m0=LZMA2 would compress instead of store, so the block size is only pinned when compressing\n const pinBlockSize = is7z && typeof blockSize === \"number\" && !storeOnly && compressionLevel !== \"0\" && (options.method == null || options.method === \"DEFAULT\")\n if (pinBlockSize) {\n if (!Number.isInteger(blockSize) || blockSize <= 0) {\n throw new Error(`blockSize must be a positive integer (MB), got ${blockSize}`)\n }\n args.push(`-m0=LZMA2${options.dictSize != null ? `:d=${options.dictSize}m` : \"\"}:c=${blockSize}m`)\n } else if (options.dictSize != null) {\n args.push(`-md=${options.dictSize}m`)\n }\n\n // Disable NTFS timestamps for reproducible archives\n if (!options.isRegularFile) {\n args.push(\"-mtc=off\")\n }\n\n if (is7z) {\n if (options.solid === false) {\n args.push(\"-ms=off\")\n }\n\n if (options.isArchiveHeaderCompressed === false) {\n args.push(\"-mhc=off\")\n }\n\n // Branch/exec filter selection. installTimeDecodable archives are unpacked by the self-vendored\n // Nsis7z extractor, whose decoder only understands plain LZMA2/Copy and the single-stream BCJ\n // filter — not the CPU branch converters modern 7za auto-applies (BCJ2 on x86/x64, ARM64 on\n // arm64). So pin them to BCJ while compressing (the best filter that decoder can read; Copy\n // needs none) and do not honor ELECTRON_BUILDER_7Z_FILTER, which could reintroduce an unreadable\n // archive. Any other 7z archive may use ELECTRON_BUILDER_7Z_FILTER, else 7za's auto-selection.\n if (options.installTimeDecodable) {\n if (!storeOnly) {\n args.push(\"-mf=BCJ\")\n }\n } else {\n const sevenZFilter = process.env.ELECTRON_BUILDER_7Z_FILTER\n if (sevenZFilter) {\n const canonicalFilter = sevenZFilter.toUpperCase()\n if (!ALLOWED_7Z_FILTERS.has(canonicalFilter)) {\n throw new Error(`ELECTRON_BUILDER_7Z_FILTER must be one of: ${[...ALLOWED_7Z_FILTERS].join(\", \")}`)\n }\n args.push(`-mf=${canonicalFilter}`)\n }\n }\n\n args.push(\"-mtm=off\", \"-mta=off\")\n }\n\n if (options.method != null && options.method !== \"DEFAULT\") {\n args.push(`-mm=${options.method}`)\n } else if (format === \"zip\") {\n // -mm is only set explicitly for zip (Deflate/Copy) and includes the UTF-8 flag.\n // For all other formats the codec is implicit from the output file extension.\n args.push(`-mm=${storeOnly ? \"Copy\" : \"Deflate\"}`)\n args.push(\"-mcu\")\n }\n\n return args\n}\n\n// 7z is very fast, so, use ultra compression\n/** @internal */\nexport async function archive(format: string, outFile: string, dirToArchive: string, options: ArchiveOptions = {}): Promise<string> {\n const outFileStat = await statOrNull(outFile)\n const dirStat = await statOrNull(dirToArchive)\n if (outFileStat && dirStat && outFileStat.mtime > dirStat.mtime) {\n log.info({ reason: \"Archive file is up to date\", outFile }, `skipped archiving`)\n return outFile\n }\n\n // Use 7za for all formats (matches pre-26.15 behavior). Native macOS `zip` is only a\n // fallback for NFD-normalized filenames, which 7za mangles.\n let use7z = true\n if (process.platform === \"darwin\" && format === \"zip\" && dirToArchive.normalize(\"NFC\") !== dirToArchive) {\n log.warn({ reason: \"7z doesn't support NFD-normalized filenames\" }, `using zip`)\n use7z = false\n }\n\n // Resolve storedPaths before the main pass so they can be excluded from it. Member names are\n // native-separator, relative to the 7za cwd (which differs with withoutDir), so the same string\n // works as both the exact `-x!` exclude mask and the append argument.\n const storedMembers: Array<string> = []\n for (const storedPath of options.storedPaths ?? []) {\n if (storedPath.includes(\"..\")) {\n throw new Error(`Stored archive path contains path traversal sequence: \"${storedPath}\"`)\n }\n if (await exists(path.join(dirToArchive, storedPath))) {\n storedMembers.push(path.normalize(options.withoutDir ? storedPath : path.join(path.basename(dirToArchive), storedPath)))\n }\n }\n if (storedMembers.length > 0 && !use7z) {\n throw new Error(\"storedPaths is not supported with the native zip fallback\")\n }\n\n if (use7z) {\n const args = compute7zCompressArgs(format, options)\n // Modern 7-Zip (24.09) dereferences symlinks by default; the 7-Zip 16.02 bundled before\n // 26.15 stored them as links. Without -snl, a macOS .framework `Versions/Current` extracts\n // as a real directory → codesign \"bundle format is ambiguous\" → breaks Squirrel.Mac\n // auto-update (#9846). Callers enable it for all non-Windows targets (see ArchiveTarget).\n if (options.preserveSymlinks) {\n args.push(\"-snl\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n args.push(...buildExcludeArgs(options.excluded, \"-xr!\"))\n // `-x!` (exact, non-recursive) so only the member itself is skipped, never a same-named sibling\n args.push(...storedMembers.map(member => `-x!${member}`))\n\n const cwd = options.withoutDir ? dirToArchive : path.dirname(dirToArchive)\n try {\n await exec(await getPath7za(), args, { cwd }, debug7z.enabled)\n } catch (e: any) {\n if (e.code === \"ENOENT\" && !(await exists(dirToArchive))) {\n throw new Error(`Cannot create archive: \"${dirToArchive}\" doesn't exist`)\n } else {\n throw e\n }\n }\n\n if (storedMembers.length > 0) {\n // Second pass: append the stored members with no compression. -mx=0 unconditionally — the\n // compression-level env override must not reach these members (see storedPaths docs). The\n // main pass's symlink, timestamp, and header-compression flags are mirrored so the option\n // stays generic: the append rewrites the archive header and may itself store a symlink.\n const appendArgs = debug7zArgs(\"a\")\n appendArgs.push(\"-mx=0\")\n if (options.preserveSymlinks) {\n appendArgs.push(\"-snl\")\n }\n if (!options.isRegularFile) {\n appendArgs.push(\"-mtc=off\")\n }\n if (format === \"7z\" || format.endsWith(\".7z\")) {\n if (options.isArchiveHeaderCompressed === false) {\n appendArgs.push(\"-mhc=off\")\n }\n appendArgs.push(\"-mtm=off\", \"-mta=off\")\n } else if (format === \"zip\") {\n appendArgs.push(\"-mm=Copy\", \"-mcu\")\n }\n appendArgs.push(outFile, ...storedMembers)\n await exec(await getPath7za(), appendArgs, { cwd }, debug7z.enabled)\n }\n } else {\n // macOS native zip (NFD fallback): -y preserves symlinks\n const args = [\"-q\", \"-r\", \"-y\"]\n if (debug7z.enabled) {\n args.push(\"-v\")\n }\n if (options.compression === \"store\") {\n args.push(\"-0\")\n } else {\n args.push(options.compression === \"maximum\" ? \"-9\" : \"-7\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n args.push(...buildExcludeArgs(options.excluded, \"-x\"))\n await exec(\"zip\", args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n }\n\n return outFile\n}\n\nfunction debug7zArgs(command: \"a\" | \"x\"): Array<string> {\n const args = [command, \"-bd\"]\n if (debug7z.enabled) {\n args.push(\"-bb\")\n }\n return args\n}\n"]}
|