app-builder-lib 27.0.0-alpha.4 → 27.0.0-alpha.6
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/dist/appInfo.d.ts +1 -1
- package/dist/appInfo.d.ts.map +1 -1
- package/dist/appInfo.js +3 -3
- package/dist/appInfo.js.map +1 -1
- package/dist/codeSign/mac/macCodeSign.d.ts.map +1 -1
- package/dist/codeSign/mac/macCodeSign.js +3 -6
- package/dist/codeSign/mac/macCodeSign.js.map +1 -1
- package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -1
- package/dist/codeSign/win/signtoolBaseSignManager.js +6 -4
- package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -1
- package/dist/codeSign/win/windowsSignAzureManager.d.ts.map +1 -1
- package/dist/codeSign/win/windowsSignAzureManager.js +31 -21
- package/dist/codeSign/win/windowsSignAzureManager.js.map +1 -1
- package/dist/configuration.d.ts +84 -44
- package/dist/configuration.d.ts.map +1 -1
- package/dist/configuration.js +11 -1
- package/dist/configuration.js.map +1 -1
- package/dist/electron/ElectronFramework.d.ts +2 -1
- package/dist/electron/ElectronFramework.d.ts.map +1 -1
- package/dist/electron/ElectronFramework.js +32 -28
- package/dist/electron/ElectronFramework.js.map +1 -1
- package/dist/electron/electronArchSupport.d.ts +12 -0
- package/dist/electron/electronArchSupport.d.ts.map +1 -0
- package/dist/electron/electronArchSupport.js +58 -0
- package/dist/electron/electronArchSupport.js.map +1 -0
- package/dist/electron/electronVersion.d.ts.map +1 -1
- package/dist/electron/electronVersion.js +1 -11
- package/dist/electron/electronVersion.js.map +1 -1
- package/dist/electron/mac/electronMac.js +12 -21
- package/dist/electron/mac/electronMac.js.map +1 -1
- package/dist/electron/mac/electronMacUtils.d.ts +24 -0
- package/dist/electron/mac/electronMacUtils.d.ts.map +1 -0
- package/dist/electron/mac/electronMacUtils.js +42 -0
- package/dist/electron/mac/electronMacUtils.js.map +1 -0
- package/dist/fileMatcher.d.ts +27 -2
- package/dist/fileMatcher.d.ts.map +1 -1
- package/dist/fileMatcher.js +204 -16
- package/dist/fileMatcher.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/indexInternal.d.ts +8 -5
- package/dist/indexInternal.d.ts.map +1 -1
- package/dist/indexInternal.js +8 -4
- package/dist/indexInternal.js.map +1 -1
- package/dist/macPackager.d.ts.map +1 -1
- package/dist/macPackager.js +15 -3
- package/dist/macPackager.js.map +1 -1
- package/dist/node-module-collector/moduleManager.d.ts +3 -1
- package/dist/node-module-collector/moduleManager.d.ts.map +1 -1
- package/dist/node-module-collector/moduleManager.js +9 -1
- package/dist/node-module-collector/moduleManager.js.map +1 -1
- package/dist/node-module-collector/nodeModulesCollector.d.ts +17 -1
- package/dist/node-module-collector/nodeModulesCollector.d.ts.map +1 -1
- package/dist/node-module-collector/nodeModulesCollector.js +67 -1
- package/dist/node-module-collector/nodeModulesCollector.js.map +1 -1
- package/dist/node-module-collector/pnpmNodeModulesCollector.js +5 -5
- package/dist/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
- package/dist/node-module-collector/types.d.ts +2 -0
- package/dist/node-module-collector/types.d.ts.map +1 -1
- package/dist/node-module-collector/types.js.map +1 -1
- package/dist/options/MsixOptions.d.ts +126 -0
- package/dist/options/MsixOptions.d.ts.map +1 -0
- package/dist/options/MsixOptions.js +2 -0
- package/dist/options/MsixOptions.js.map +1 -0
- package/dist/options/PlatformSpecificBuildOptions.d.ts +0 -6
- package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
- package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
- package/dist/options/SnapOptions.d.ts +15 -13
- package/dist/options/SnapOptions.d.ts.map +1 -1
- package/dist/options/SnapOptions.js.map +1 -1
- package/dist/options/macOptions.d.ts +4 -4
- package/dist/options/macOptions.d.ts.map +1 -1
- package/dist/options/macOptions.js.map +1 -1
- package/dist/options/winOptions.d.ts +166 -36
- package/dist/options/winOptions.d.ts.map +1 -1
- package/dist/options/winOptions.js.map +1 -1
- package/dist/packager.d.ts +2 -0
- package/dist/packager.d.ts.map +1 -1
- package/dist/packager.js +26 -21
- package/dist/packager.js.map +1 -1
- package/dist/platformPackager.d.ts +2 -0
- package/dist/platformPackager.d.ts.map +1 -1
- package/dist/platformPackager.js +6 -0
- package/dist/platformPackager.js.map +1 -1
- package/dist/publish/PublishManager.d.ts +1 -0
- package/dist/publish/PublishManager.d.ts.map +1 -1
- package/dist/publish/PublishManager.js +20 -6
- package/dist/publish/PublishManager.js.map +1 -1
- package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
- package/dist/publish/updateInfoBuilder.js +20 -22
- package/dist/publish/updateInfoBuilder.js.map +1 -1
- package/dist/targets/archive.d.ts +11 -0
- package/dist/targets/archive.d.ts.map +1 -1
- package/dist/targets/archive.js +40 -22
- package/dist/targets/archive.js.map +1 -1
- package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
- package/dist/targets/linux/FpmTarget.js +3 -3
- package/dist/targets/linux/FpmTarget.js.map +1 -1
- package/dist/targets/linux/appimage/AppImageTarget.d.ts.map +1 -1
- package/dist/targets/linux/appimage/AppImageTarget.js +5 -6
- package/dist/targets/linux/appimage/AppImageTarget.js.map +1 -1
- package/dist/targets/linux/snap/SnapTarget.d.ts +1 -1
- package/dist/targets/linux/snap/SnapTarget.d.ts.map +1 -1
- package/dist/targets/linux/snap/SnapTarget.js +23 -1
- package/dist/targets/linux/snap/SnapTarget.js.map +1 -1
- package/dist/targets/linux/snap/core24.d.ts +1 -1
- package/dist/targets/linux/snap/core24.d.ts.map +1 -1
- package/dist/targets/linux/snap/core24.js +3 -2
- package/dist/targets/linux/snap/core24.js.map +1 -1
- package/dist/targets/linux/snap/coreCustom.d.ts +1 -1
- package/dist/targets/linux/snap/coreCustom.d.ts.map +1 -1
- package/dist/targets/linux/snap/coreCustom.js +2 -2
- package/dist/targets/linux/snap/coreCustom.js.map +1 -1
- package/dist/targets/linux/snap/coreLegacy.d.ts +1 -1
- package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
- package/dist/targets/linux/snap/coreLegacy.js +2 -1
- package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
- package/dist/targets/linux/snap/snapcraft.d.ts +190 -0
- package/dist/targets/linux/snap/snapcraft.d.ts.map +1 -0
- package/dist/targets/linux/snap/snapcraft.js +11 -0
- package/dist/targets/linux/snap/snapcraft.js.map +1 -0
- package/dist/targets/linux/snap/snapcraftBuilder.d.ts +7 -1
- package/dist/targets/linux/snap/snapcraftBuilder.d.ts.map +1 -1
- package/dist/targets/linux/snap/snapcraftBuilder.js +57 -20
- package/dist/targets/linux/snap/snapcraftBuilder.js.map +1 -1
- package/dist/targets/mac/MacTargetHelper.d.ts +6 -0
- package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
- package/dist/targets/mac/MacTargetHelper.js +22 -1
- package/dist/targets/mac/MacTargetHelper.js.map +1 -1
- package/dist/targets/targetFactory.d.ts +7 -0
- package/dist/targets/targetFactory.d.ts.map +1 -1
- package/dist/targets/targetFactory.js +28 -0
- package/dist/targets/targetFactory.js.map +1 -1
- package/dist/targets/win/AppxTarget.d.ts +0 -2
- package/dist/targets/win/AppxTarget.d.ts.map +1 -1
- package/dist/targets/win/AppxTarget.js +37 -317
- package/dist/targets/win/AppxTarget.js.map +1 -1
- package/dist/targets/win/MsixTarget.d.ts +22 -0
- package/dist/targets/win/MsixTarget.d.ts.map +1 -0
- package/dist/targets/win/MsixTarget.js +214 -0
- package/dist/targets/win/MsixTarget.js.map +1 -0
- package/dist/targets/win/nsis/NsisTarget.d.ts +3 -2
- package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.js +28 -46
- package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
- package/dist/targets/win/nsis/nsisScriptGenerator.d.ts.map +1 -1
- package/dist/targets/win/nsis/nsisScriptGenerator.js +2 -1
- package/dist/targets/win/nsis/nsisScriptGenerator.js.map +1 -1
- package/dist/targets/win/nsis/nsisUtil.d.ts +5 -2
- package/dist/targets/win/nsis/nsisUtil.d.ts.map +1 -1
- package/dist/targets/win/nsis/nsisUtil.js +46 -22
- package/dist/targets/win/nsis/nsisUtil.js.map +1 -1
- package/dist/targets/win/nsis/progId.d.ts +21 -0
- package/dist/targets/win/nsis/progId.d.ts.map +1 -0
- package/dist/targets/win/nsis/progId.js +60 -0
- package/dist/targets/win/nsis/progId.js.map +1 -0
- package/dist/targets/win/winAppUtil.d.ts +115 -0
- package/dist/targets/win/winAppUtil.d.ts.map +1 -0
- package/dist/targets/win/winAppUtil.js +407 -0
- package/dist/targets/win/winAppUtil.js.map +1 -0
- package/dist/toolsets/7zip.d.ts.map +1 -1
- package/dist/toolsets/7zip.js +3 -1
- package/dist/toolsets/7zip.js.map +1 -1
- package/dist/toolsets/appimage.d.ts +3 -3
- package/dist/toolsets/appimage.d.ts.map +1 -1
- package/dist/toolsets/appimage.js +9 -6
- package/dist/toolsets/appimage.js.map +1 -1
- package/dist/toolsets/custom.d.ts +1 -3
- package/dist/toolsets/custom.d.ts.map +1 -1
- package/dist/toolsets/custom.js +4 -133
- package/dist/toolsets/custom.js.map +1 -1
- package/dist/toolsets/fpm.d.ts.map +1 -1
- package/dist/toolsets/fpm.js +11 -5
- package/dist/toolsets/fpm.js.map +1 -1
- package/dist/toolsets/icons.d.ts.map +1 -1
- package/dist/toolsets/icons.js +4 -1
- package/dist/toolsets/icons.js.map +1 -1
- package/dist/toolsets/linuxToolsMac.d.ts.map +1 -1
- package/dist/toolsets/linuxToolsMac.js +4 -1
- package/dist/toolsets/linuxToolsMac.js.map +1 -1
- package/dist/toolsets/nsis.d.ts.map +1 -1
- package/dist/toolsets/nsis.js +6 -3
- package/dist/toolsets/nsis.js.map +1 -1
- package/dist/toolsets/version.d.ts +12 -0
- package/dist/toolsets/version.d.ts.map +1 -0
- package/dist/toolsets/version.js +13 -0
- package/dist/toolsets/version.js.map +1 -0
- package/dist/toolsets/winCodeSign.d.ts +20 -3
- package/dist/toolsets/winCodeSign.d.ts.map +1 -1
- package/dist/toolsets/winCodeSign.js +56 -27
- package/dist/toolsets/winCodeSign.js.map +1 -1
- package/dist/toolsets/wine.d.ts +2 -1
- package/dist/toolsets/wine.d.ts.map +1 -1
- package/dist/toolsets/wine.js +15 -13
- package/dist/toolsets/wine.js.map +1 -1
- package/dist/util/NodeModuleCopyHelper.js +3 -3
- package/dist/util/NodeModuleCopyHelper.js.map +1 -1
- package/dist/util/appFileCopier.d.ts +39 -0
- package/dist/util/appFileCopier.d.ts.map +1 -1
- package/dist/util/appFileCopier.js +88 -22
- package/dist/util/appFileCopier.js.map +1 -1
- package/dist/util/config/config.d.ts +1 -0
- package/dist/util/config/config.d.ts.map +1 -1
- package/dist/util/config/config.js +4 -1
- package/dist/util/config/config.js.map +1 -1
- package/dist/util/config/load.d.ts +2 -2
- package/dist/util/config/load.d.ts.map +1 -1
- package/dist/util/config/load.js +3 -12
- package/dist/util/config/load.js.map +1 -1
- package/dist/util/config/schemaValidator.js +1 -1
- package/dist/util/config/schemaValidator.js.map +1 -1
- package/dist/util/electronGet.d.ts +6 -3
- package/dist/util/electronGet.d.ts.map +1 -1
- package/dist/util/electronGet.js +40 -20
- package/dist/util/electronGet.js.map +1 -1
- package/dist/util/flags.d.ts +0 -2
- package/dist/util/flags.d.ts.map +1 -1
- package/dist/util/flags.js +0 -6
- package/dist/util/flags.js.map +1 -1
- package/dist/util/hash.d.ts +1 -1
- package/dist/util/hash.d.ts.map +1 -1
- package/dist/util/hash.js +1 -15
- package/dist/util/hash.js.map +1 -1
- package/dist/util/packageMetadata.js +0 -10
- package/dist/util/packageMetadata.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/vm/ParallelsVm.d.ts.map +1 -1
- package/dist/vm/ParallelsVm.js +18 -5
- package/dist/vm/ParallelsVm.js.map +1 -1
- package/dist/winPackager.d.ts.map +1 -1
- package/dist/winPackager.js +3 -0
- package/dist/winPackager.js.map +1 -1
- package/package.json +8 -8
- package/scheme.json +556 -133
- package/templates/appx/appxmanifest.xml +1 -1
- package/templates/msix/appxmanifest.xml +45 -0
- package/templates/nsis/installSection.nsh +14 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/util/config/load.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/util/config/load.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAIxD,OAAO,EAAE,gBAAgB,EAAU,MAAM,eAAe,CAAA;AAIxD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAM/B,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;IAClB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CACnC;AAiCD,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAU1G;AAGD,OAAO,EAAE,oBAAoB,EAAE,CAAA;AAE/B,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,MAAM,CAAA;IAEtB,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;CACzD;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CASnG;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAMxH;AAED,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CA0BhH;AAED,wBAAsB,OAAO,CAAC,OAAO,EAAE,MAAM,oCAgB5C"}
|
package/dist/util/config/load.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { log } from "builder-util";
|
|
2
|
+
import { log, orNullIfFileNotExist } from "builder-util";
|
|
3
3
|
const require = createRequire(import.meta.url);
|
|
4
4
|
import { parse as parseEnv } from "dotenv";
|
|
5
5
|
import { expand } from "dotenv-expand";
|
|
@@ -52,17 +52,8 @@ export async function findAndReadConfig(request) {
|
|
|
52
52
|
}
|
|
53
53
|
return null;
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
export function orIfFileNotExist(promise, fallbackValue) {
|
|
59
|
-
return promise.catch(e => {
|
|
60
|
-
if (e.code === "ENOENT" || e.code === "ENOTDIR") {
|
|
61
|
-
return fallbackValue;
|
|
62
|
-
}
|
|
63
|
-
throw e;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
55
|
+
// re-exported for downstream consumers (indexInternal.ts, config.ts, electronVersion.ts) that historically imported it from here
|
|
56
|
+
export { orNullIfFileNotExist };
|
|
66
57
|
export async function loadConfig(request) {
|
|
67
58
|
let packageMetadata = request.packageMetadata == null ? null : await request.packageMetadata.value;
|
|
68
59
|
if (packageMetadata == null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/util/config/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,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,EAAE,MAAM,EAAE,CAAC,CAAA;IAClB,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { createRequire } from \"node:module\"\nimport { log } from \"builder-util\"\n\nconst require = createRequire(import.meta.url)\nimport { parse as parseEnv } from \"dotenv\"\nimport { DotenvParseInput, expand } from \"dotenv-expand\"\nimport { promises as fs } from \"fs\"\nimport { createJiti } from \"jiti\"\nimport { load } from \"js-yaml\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { resolveModule } from \"../resolve.js\"\n\nconst jiti = createJiti(import.meta.filename)\n\nexport interface ReadConfigResult<T> {\n readonly result: T\n readonly configFile: string | null\n}\n\nasync function readConfig<T>(configFile: string, request: ReadConfigRequest): Promise<ReadConfigResult<T>> {\n const data = await fs.readFile(configFile, \"utf8\")\n let result: any\n if (configFile.endsWith(\".json5\") || configFile.endsWith(\".json\")) {\n result = require(\"json5\").parse(data)\n } else if (configFile.endsWith(\".js\") || configFile.endsWith(\".cjs\") || configFile.endsWith(\".mjs\")) {\n const json = await orNullIfFileNotExist(fs.readFile(path.join(process.cwd(), \"package.json\"), \"utf8\"))\n const moduleType = json === null ? null : JSON.parse(json).type\n result = await resolveModule(moduleType, configFile)\n if (result.default != null) {\n result = result.default\n }\n if (typeof result === \"function\") {\n result = result(request)\n }\n result = await Promise.resolve(result)\n } else if (configFile.endsWith(\".ts\")) {\n result = await jiti.import(configFile, { default: true })\n\n if (typeof result === \"function\") {\n result = result(request)\n }\n result = await Promise.resolve(result)\n } else if (configFile.endsWith(\".toml\")) {\n result = require(\"toml\").parse(data)\n } else {\n result = load(data)\n }\n return { result, configFile }\n}\n\nexport async function findAndReadConfig<T>(request: ReadConfigRequest): Promise<ReadConfigResult<T> | null> {\n const prefix = request.configFilename\n for (const configFile of [`${prefix}.yml`, `${prefix}.yaml`, `${prefix}.json`, `${prefix}.json5`, `${prefix}.toml`, `${prefix}.js`, `${prefix}.cjs`, `${prefix}.ts`]) {\n const data = await orNullIfFileNotExist(readConfig<T>(path.join(request.projectDir, configFile), request))\n if (data != null) {\n return data\n }\n }\n\n return null\n}\n\nexport function orNullIfFileNotExist<T>(promise: Promise<T>): Promise<T | null> {\n return orIfFileNotExist(promise, null)\n}\n\nexport function orIfFileNotExist<T>(promise: Promise<T>, fallbackValue: T): Promise<T> {\n return promise.catch(e => {\n if (e.code === \"ENOENT\" || e.code === \"ENOTDIR\") {\n return fallbackValue\n }\n throw e\n })\n}\n\nexport interface ReadConfigRequest {\n packageKey: string\n configFilename: string\n\n projectDir: string\n packageMetadata: Lazy<Record<string, any> | null> | null\n}\n\nexport async function loadConfig<T>(request: ReadConfigRequest): Promise<ReadConfigResult<T> | null> {\n let packageMetadata = request.packageMetadata == null ? null : await request.packageMetadata.value\n if (packageMetadata == null) {\n const json = await orNullIfFileNotExist(fs.readFile(path.join(request.projectDir, \"package.json\"), \"utf8\"))\n packageMetadata = json == null ? null : JSON.parse(json)\n }\n\n const data: T = packageMetadata == null ? null : packageMetadata[request.packageKey]\n return data == null ? findAndReadConfig<T>(request) : { result: data, configFile: null }\n}\n\nexport function getConfig<T>(request: ReadConfigRequest, configPath?: string | null): Promise<ReadConfigResult<T> | null> {\n if (configPath == null) {\n return loadConfig<T>(request)\n } else {\n return readConfig<T>(path.resolve(request.projectDir, configPath), request)\n }\n}\n\nexport async function loadParentConfig<T>(request: ReadConfigRequest, spec: string): Promise<ReadConfigResult<T>> {\n let isFileSpec: boolean | undefined\n if (spec.startsWith(\"file:\")) {\n spec = spec.substring(\"file:\".length)\n isFileSpec = true\n }\n\n let parentConfig = await orNullIfFileNotExist(readConfig<T>(path.resolve(request.projectDir, spec), request))\n if (parentConfig == null && isFileSpec !== true) {\n let resolved: string | null = null\n try {\n resolved = require.resolve(spec)\n } catch (_e) {\n // ignore\n }\n\n if (resolved != null) {\n parentConfig = await readConfig<T>(resolved, request)\n }\n }\n\n if (parentConfig == null) {\n throw new Error(`Cannot find parent config file: ${spec}`)\n }\n\n return parentConfig\n}\n\nexport async function loadEnv(envFile: string) {\n const data = await orNullIfFileNotExist(fs.readFile(envFile, \"utf8\"))\n if (data == null) {\n return null\n }\n\n const parsed = parseEnv<DotenvParseInput>(data)\n\n log.info({ envFile }, \"injecting environment\")\n Object.entries(parsed).forEach(([key, value]) => {\n if (!Object.prototype.hasOwnProperty.call(process.env, key)) {\n process.env[key] = value\n }\n })\n expand({ parsed })\n return parsed\n}\n"]}
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/util/config/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAExD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAC1C,OAAO,EAAoB,MAAM,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAE9B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AAO7C,KAAK,UAAU,UAAU,CAAI,UAAkB,EAAE,OAA0B;IACzE,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IAClD,IAAI,MAAW,CAAA;IACf,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAA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AAC,CAAA;IACF,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IAClB,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { createRequire } from \"node:module\"\nimport { log, orNullIfFileNotExist } from \"builder-util\"\n\nconst require = createRequire(import.meta.url)\nimport { parse as parseEnv } from \"dotenv\"\nimport { DotenvParseInput, expand } from \"dotenv-expand\"\nimport { promises as fs } from \"fs\"\nimport { createJiti } from \"jiti\"\nimport { load } from \"js-yaml\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { resolveModule } from \"../resolve.js\"\n\nconst jiti = createJiti(import.meta.filename)\n\nexport interface ReadConfigResult<T> {\n readonly result: T\n readonly configFile: string | null\n}\n\nasync function readConfig<T>(configFile: string, request: ReadConfigRequest): Promise<ReadConfigResult<T>> {\n const data = await fs.readFile(configFile, \"utf8\")\n let result: any\n if (configFile.endsWith(\".json5\") || configFile.endsWith(\".json\")) {\n result = require(\"json5\").parse(data)\n } else if (configFile.endsWith(\".js\") || configFile.endsWith(\".cjs\") || configFile.endsWith(\".mjs\")) {\n const json = await orNullIfFileNotExist(fs.readFile(path.join(process.cwd(), \"package.json\"), \"utf8\"))\n const moduleType = json === null ? null : JSON.parse(json).type\n result = await resolveModule(moduleType, configFile)\n if (result.default != null) {\n result = result.default\n }\n if (typeof result === \"function\") {\n result = result(request)\n }\n result = await Promise.resolve(result)\n } else if (configFile.endsWith(\".ts\")) {\n result = await jiti.import(configFile, { default: true })\n\n if (typeof result === \"function\") {\n result = result(request)\n }\n result = await Promise.resolve(result)\n } else if (configFile.endsWith(\".toml\")) {\n result = require(\"toml\").parse(data)\n } else {\n result = load(data)\n }\n return { result, configFile }\n}\n\nexport async function findAndReadConfig<T>(request: ReadConfigRequest): Promise<ReadConfigResult<T> | null> {\n const prefix = request.configFilename\n for (const configFile of [`${prefix}.yml`, `${prefix}.yaml`, `${prefix}.json`, `${prefix}.json5`, `${prefix}.toml`, `${prefix}.js`, `${prefix}.cjs`, `${prefix}.ts`]) {\n const data = await orNullIfFileNotExist(readConfig<T>(path.join(request.projectDir, configFile), request))\n if (data != null) {\n return data\n }\n }\n\n return null\n}\n\n// re-exported for downstream consumers (indexInternal.ts, config.ts, electronVersion.ts) that historically imported it from here\nexport { orNullIfFileNotExist }\n\nexport interface ReadConfigRequest {\n packageKey: string\n configFilename: string\n\n projectDir: string\n packageMetadata: Lazy<Record<string, any> | null> | null\n}\n\nexport async function loadConfig<T>(request: ReadConfigRequest): Promise<ReadConfigResult<T> | null> {\n let packageMetadata = request.packageMetadata == null ? null : await request.packageMetadata.value\n if (packageMetadata == null) {\n const json = await orNullIfFileNotExist(fs.readFile(path.join(request.projectDir, \"package.json\"), \"utf8\"))\n packageMetadata = json == null ? null : JSON.parse(json)\n }\n\n const data: T = packageMetadata == null ? null : packageMetadata[request.packageKey]\n return data == null ? findAndReadConfig<T>(request) : { result: data, configFile: null }\n}\n\nexport function getConfig<T>(request: ReadConfigRequest, configPath?: string | null): Promise<ReadConfigResult<T> | null> {\n if (configPath == null) {\n return loadConfig<T>(request)\n } else {\n return readConfig<T>(path.resolve(request.projectDir, configPath), request)\n }\n}\n\nexport async function loadParentConfig<T>(request: ReadConfigRequest, spec: string): Promise<ReadConfigResult<T>> {\n let isFileSpec: boolean | undefined\n if (spec.startsWith(\"file:\")) {\n spec = spec.substring(\"file:\".length)\n isFileSpec = true\n }\n\n let parentConfig = await orNullIfFileNotExist(readConfig<T>(path.resolve(request.projectDir, spec), request))\n if (parentConfig == null && isFileSpec !== true) {\n let resolved: string | null = null\n try {\n resolved = require.resolve(spec)\n } catch (_e) {\n // ignore\n }\n\n if (resolved != null) {\n parentConfig = await readConfig<T>(resolved, request)\n }\n }\n\n if (parentConfig == null) {\n throw new Error(`Cannot find parent config file: ${spec}`)\n }\n\n return parentConfig\n}\n\nexport async function loadEnv(envFile: string) {\n const data = await orNullIfFileNotExist(fs.readFile(envFile, \"utf8\"))\n if (data == null) {\n return null\n }\n\n const parsed = parseEnv<DotenvParseInput>(data)\n\n log.info({ envFile }, \"injecting environment\")\n Object.entries(parsed).forEach(([key, value]) => {\n if (!Object.prototype.hasOwnProperty.call(process.env, key)) {\n process.env[key] = value\n }\n })\n expand({ parsed })\n return parsed\n}\n"]}
|
|
@@ -31,7 +31,7 @@ export function validateSchema(schema, data, config = {}) {
|
|
|
31
31
|
const guidance = [
|
|
32
32
|
`Please check the documentation to ensure that your configuration matches the expected schema: https://www.electron.build/configuration`,
|
|
33
33
|
`If you recently upgraded electron-builder to v27, please run \`electron-builder migrate-schema\` to automatically update your configuration.`,
|
|
34
|
-
`Check the release notes for breaking changes: https://www.electron.build/docs/migration/
|
|
34
|
+
`Check the release notes for breaking changes: https://www.electron.build/docs/migration/v27-breaking-changes`,
|
|
35
35
|
];
|
|
36
36
|
throw new Error(`${header}\n${formatted.join("\n")}\n${guidance.join("\n")}`);
|
|
37
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaValidator.js","sourceRoot":"","sources":["../../../src/util/config/schemaValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiC,MAAM,KAAK,CAAA;AASxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC;IAClB,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,IAAI;IACjB,MAAM,EAAE,KAAK;CACd,CAAC,CAAA;AAEF,2EAA2E;AAC3E,sCAAsC;AACtC,IAAI,eAA6C,CAAA;AAEjD,MAAM,UAAU,cAAc,CAAC,MAAe,EAAE,IAAa,EAAE,SAA2B,EAAE;IAC1F,IAAI,eAAe,IAAI,IAAI,IAAI,eAAe,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QACjE,eAAe,GAAG,GAAG,CAAC,OAAO,CAAC,MAAgB,CAAC,CAAA;IACjD,CAAC;IACD,MAAM,QAAQ,GAAG,eAAe,CAAA;IAEhC,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,C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type PostFormatter = (formattedError: string, error: ErrorObject) => string\n\nexport interface ValidationConfig {\n name?: string\n postFormatter?: PostFormatter\n}\n\nconst ajv = new Ajv({\n allErrors: true,\n verbose: true,\n coerceTypes: true,\n strict: false,\n})\n\n// Cache the compiled validator for the canonical scheme.json so it is only\n// compiled once per process lifetime.\nlet _cachedValidate: ValidateFunction | undefined\n\nexport function validateSchema(schema: unknown, data: unknown, config: ValidationConfig = {}): void {\n if (_cachedValidate == null || _cachedValidate.schema !== schema) {\n _cachedValidate = ajv.compile(schema as object)\n }\n const validate = _cachedValidate\n\n if (validate(data)) {\n return\n }\n\n const errors = validate.errors ?? []\n const baseDataPath = \"configuration\"\n const name = config.name ?? \"Object\"\n\n const relevant = filterRelevantErrors(errors)\n const formatted = relevant.map(error => {\n let msg = formatError(error, baseDataPath)\n if (config.postFormatter != null) {\n msg = config.postFormatter(msg, error)\n }\n return ` - ${indentNewlines(msg, \" \")}`\n })\n\n const header = `Invalid configuration object. ${name} has been initialized using a configuration object that does not match the API schema.`\n const guidance = [\n `Please check the documentation to ensure that your configuration matches the expected schema: https://www.electron.build/configuration`,\n `If you recently upgraded electron-builder to v27, please run \\`electron-builder migrate-schema\\` to automatically update your configuration.`,\n `Check the release notes for breaking changes: https://www.electron.build/docs/migration/v26-to-v27`,\n ]\n throw new Error(`${header}\\n${formatted.join(\"\\n\")}\\n${guidance.join(\"\\n\")}`)\n}\n\n/**\n * Filters the flat list of ajv errors to the most actionable subset.\n * Composite keywords (anyOf/oneOf/if) are suppressed when more specific\n * errors exist at the same or deeper paths. When all errors share the\n * same instancePath and a composite parent for that path exists, the\n * parent is kept instead so the user sees a single \"should be one of\"\n * message rather than every failed branch listed separately.\n */\nfunction filterRelevantErrors(errors: ErrorObject[]): ErrorObject[] {\n const compositeKeywords = new Set([\"anyOf\", \"oneOf\", \"if\"])\n const specific = errors.filter(e => !compositeKeywords.has(e.keyword))\n\n if (specific.length === 0) {\n return errors.filter(e => compositeKeywords.has(e.keyword))\n }\n\n // Group specific errors by instancePath\n const byPath = new Map<string, ErrorObject[]>()\n for (const e of specific) {\n const list = byPath.get(e.instancePath)\n if (list != null) {\n list.push(e)\n } else {\n byPath.set(e.instancePath, [e])\n }\n }\n\n const result: ErrorObject[] = []\n for (const [path, group] of byPath) {\n if (group.length > 1) {\n // additionalProperties errors are the most actionable (\"has unknown\n // property X\") — prefer them over anyOf-parent collapse or type noise.\n const additionalProps = group.filter(e => e.keyword === \"additionalProperties\")\n if (additionalProps.length > 0) {\n result.push(...additionalProps)\n continue\n }\n // For other multi-error groups, prefer the anyOf parent (one concise\n // \"should be one of these\" message).\n const parent = errors.find(e => e.instancePath === path && compositeKeywords.has(e.keyword))\n if (parent != null) {\n result.push(parent)\n continue\n }\n }\n result.push(...group)\n }\n return result\n}\n\n/** Decodes a single RFC 6901 JSON Pointer segment (`~1` → `/`, `~0` → `~`). */\nfunction decodePointerSegment(segment: string): string {\n return segment.replace(/~1/g, \"/\").replace(/~0/g, \"~\")\n}\n\nfunction instancePathToLabel(instancePath: string, baseDataPath: string): string {\n if (!instancePath) {\n return baseDataPath\n }\n const segments = instancePath.split(\"/\").filter(Boolean).map(decodePointerSegment)\n return [baseDataPath, ...segments].join(\".\")\n}\n\nfunction formatError(error: ErrorObject, baseDataPath: string): string {\n const label = instancePathToLabel(error.instancePath, baseDataPath)\n const params = error.params as Record<string, unknown>\n const parentSchema = (error as ErrorObject & { parentSchema?: Record<string, unknown> }).parentSchema\n\n switch (error.keyword) {\n case \"additionalProperties\":\n return `${label} has an unknown property '${params.additionalProperty}'`\n\n case \"required\": {\n const missingProp = String(params.missingProperty).replace(/^\\./, \"\")\n return `${label} misses the property '${missingProp}'`\n }\n\n case \"type\": {\n const type = params.type\n if (Array.isArray(type)) {\n const typeList = (type as string[]).join(\" | \")\n const desc = descriptionSuffix(parentSchema)\n return `${label} should be:\\n${typeList}${desc}`\n }\n return `${label} should be a ${type}`\n }\n\n case \"enum\": {\n const enumVals = (parentSchema?.enum as unknown[] | undefined) ?? []\n if (enumVals.length === 1) {\n return `${label} should be ${JSON.stringify(enumVals[0])}`\n }\n return `${label} should be one of these:\\n${enumVals.map(v => JSON.stringify(v)).join(\" | \")}`\n }\n\n case \"anyOf\":\n case \"oneOf\": {\n const schemaText = formatSchemaType(parentSchema)\n return `${label} should be one of these:\\n${schemaText}`\n }\n\n default:\n return `${label} ${error.message}`\n }\n}\n\nfunction descriptionSuffix(schema: Record<string, unknown> | undefined): string {\n return typeof schema?.description === \"string\" ? `\\n-> ${schema.description}` : \"\"\n}\n\nfunction formatSchemaType(schema: Record<string, unknown> | undefined): string {\n if (schema == null) {\n return \"\"\n }\n if (Array.isArray(schema.type)) {\n return (schema.type as string[]).join(\" | \")\n }\n if (typeof schema.type === \"string\") {\n return schema.type\n }\n if (Array.isArray(schema.anyOf)) {\n return (schema.anyOf as Array<Record<string, unknown>>)\n .map(s => {\n if (Array.isArray(s.type)) {\n return (s.type as string[]).join(\" | \")\n }\n return typeof s.type === \"string\" ? s.type : \"\"\n })\n .filter(Boolean)\n .join(\" | \")\n }\n return JSON.stringify(schema)\n}\n\nfunction indentNewlines(str: string, prefix: string): string {\n return str.replace(/\\n(?!$)/g, `\\n${prefix}`)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schemaValidator.js","sourceRoot":"","sources":["../../../src/util/config/schemaValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiC,MAAM,KAAK,CAAA;AASxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC;IAClB,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,IAAI;IACjB,MAAM,EAAE,KAAK;CACd,CAAC,CAAA;AAEF,2EAA2E;AAC3E,sCAAsC;AACtC,IAAI,eAA6C,CAAA;AAEjD,MAAM,UAAU,cAAc,CAAC,MAAe,EAAE,IAAa,EAAE,SAA2B,EAAE;IAC1F,IAAI,eAAe,IAAI,IAAI,IAAI,eAAe,CAAC,MAAM,KAA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S,cAAc,CAAC,GAAW,EAAE,MAAc;IACjD,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["import { Ajv, ErrorObject, ValidateFunction } from \"ajv\"\n\nexport type PostFormatter = (formattedError: string, error: ErrorObject) => string\n\nexport interface ValidationConfig {\n name?: string\n postFormatter?: PostFormatter\n}\n\nconst ajv = new Ajv({\n allErrors: true,\n verbose: true,\n coerceTypes: true,\n strict: false,\n})\n\n// Cache the compiled validator for the canonical scheme.json so it is only\n// compiled once per process lifetime.\nlet _cachedValidate: ValidateFunction | undefined\n\nexport function validateSchema(schema: unknown, data: unknown, config: ValidationConfig = {}): void {\n if (_cachedValidate == null || _cachedValidate.schema !== schema) {\n _cachedValidate = ajv.compile(schema as object)\n }\n const validate = _cachedValidate\n\n if (validate(data)) {\n return\n }\n\n const errors = validate.errors ?? []\n const baseDataPath = \"configuration\"\n const name = config.name ?? \"Object\"\n\n const relevant = filterRelevantErrors(errors)\n const formatted = relevant.map(error => {\n let msg = formatError(error, baseDataPath)\n if (config.postFormatter != null) {\n msg = config.postFormatter(msg, error)\n }\n return ` - ${indentNewlines(msg, \" \")}`\n })\n\n const header = `Invalid configuration object. ${name} has been initialized using a configuration object that does not match the API schema.`\n const guidance = [\n `Please check the documentation to ensure that your configuration matches the expected schema: https://www.electron.build/configuration`,\n `If you recently upgraded electron-builder to v27, please run \\`electron-builder migrate-schema\\` to automatically update your configuration.`,\n `Check the release notes for breaking changes: https://www.electron.build/docs/migration/v27-breaking-changes`,\n ]\n throw new Error(`${header}\\n${formatted.join(\"\\n\")}\\n${guidance.join(\"\\n\")}`)\n}\n\n/**\n * Filters the flat list of ajv errors to the most actionable subset.\n * Composite keywords (anyOf/oneOf/if) are suppressed when more specific\n * errors exist at the same or deeper paths. When all errors share the\n * same instancePath and a composite parent for that path exists, the\n * parent is kept instead so the user sees a single \"should be one of\"\n * message rather than every failed branch listed separately.\n */\nfunction filterRelevantErrors(errors: ErrorObject[]): ErrorObject[] {\n const compositeKeywords = new Set([\"anyOf\", \"oneOf\", \"if\"])\n const specific = errors.filter(e => !compositeKeywords.has(e.keyword))\n\n if (specific.length === 0) {\n return errors.filter(e => compositeKeywords.has(e.keyword))\n }\n\n // Group specific errors by instancePath\n const byPath = new Map<string, ErrorObject[]>()\n for (const e of specific) {\n const list = byPath.get(e.instancePath)\n if (list != null) {\n list.push(e)\n } else {\n byPath.set(e.instancePath, [e])\n }\n }\n\n const result: ErrorObject[] = []\n for (const [path, group] of byPath) {\n if (group.length > 1) {\n // additionalProperties errors are the most actionable (\"has unknown\n // property X\") — prefer them over anyOf-parent collapse or type noise.\n const additionalProps = group.filter(e => e.keyword === \"additionalProperties\")\n if (additionalProps.length > 0) {\n result.push(...additionalProps)\n continue\n }\n // For other multi-error groups, prefer the anyOf parent (one concise\n // \"should be one of these\" message).\n const parent = errors.find(e => e.instancePath === path && compositeKeywords.has(e.keyword))\n if (parent != null) {\n result.push(parent)\n continue\n }\n }\n result.push(...group)\n }\n return result\n}\n\n/** Decodes a single RFC 6901 JSON Pointer segment (`~1` → `/`, `~0` → `~`). */\nfunction decodePointerSegment(segment: string): string {\n return segment.replace(/~1/g, \"/\").replace(/~0/g, \"~\")\n}\n\nfunction instancePathToLabel(instancePath: string, baseDataPath: string): string {\n if (!instancePath) {\n return baseDataPath\n }\n const segments = instancePath.split(\"/\").filter(Boolean).map(decodePointerSegment)\n return [baseDataPath, ...segments].join(\".\")\n}\n\nfunction formatError(error: ErrorObject, baseDataPath: string): string {\n const label = instancePathToLabel(error.instancePath, baseDataPath)\n const params = error.params as Record<string, unknown>\n const parentSchema = (error as ErrorObject & { parentSchema?: Record<string, unknown> }).parentSchema\n\n switch (error.keyword) {\n case \"additionalProperties\":\n return `${label} has an unknown property '${params.additionalProperty}'`\n\n case \"required\": {\n const missingProp = String(params.missingProperty).replace(/^\\./, \"\")\n return `${label} misses the property '${missingProp}'`\n }\n\n case \"type\": {\n const type = params.type\n if (Array.isArray(type)) {\n const typeList = (type as string[]).join(\" | \")\n const desc = descriptionSuffix(parentSchema)\n return `${label} should be:\\n${typeList}${desc}`\n }\n return `${label} should be a ${type}`\n }\n\n case \"enum\": {\n const enumVals = (parentSchema?.enum as unknown[] | undefined) ?? []\n if (enumVals.length === 1) {\n return `${label} should be ${JSON.stringify(enumVals[0])}`\n }\n return `${label} should be one of these:\\n${enumVals.map(v => JSON.stringify(v)).join(\" | \")}`\n }\n\n case \"anyOf\":\n case \"oneOf\": {\n const schemaText = formatSchemaType(parentSchema)\n return `${label} should be one of these:\\n${schemaText}`\n }\n\n default:\n return `${label} ${error.message}`\n }\n}\n\nfunction descriptionSuffix(schema: Record<string, unknown> | undefined): string {\n return typeof schema?.description === \"string\" ? `\\n-> ${schema.description}` : \"\"\n}\n\nfunction formatSchemaType(schema: Record<string, unknown> | undefined): string {\n if (schema == null) {\n return \"\"\n }\n if (Array.isArray(schema.type)) {\n return (schema.type as string[]).join(\" | \")\n }\n if (typeof schema.type === \"string\") {\n return schema.type\n }\n if (Array.isArray(schema.anyOf)) {\n return (schema.anyOf as Array<Record<string, unknown>>)\n .map(s => {\n if (Array.isArray(s.type)) {\n return (s.type as string[]).join(\" | \")\n }\n return typeof s.type === \"string\" ? s.type : \"\"\n })\n .filter(Boolean)\n .join(\" | \")\n }\n return JSON.stringify(schema)\n}\n\nfunction indentNewlines(str: string, prefix: string): string {\n return str.replace(/\\n(?!$)/g, `\\n${prefix}`)\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ElectronPlatformArtifactDetails, MirrorOptions } from "@electron/get";
|
|
2
|
+
import { MemoLazy } from "builder-util-runtime";
|
|
2
3
|
export interface ElectronGetOptions extends Omit<ElectronPlatformArtifactDetails, "platform" | "arch" | "version" | "artifactName" | "artifactSuffix" | "customFilename" | "tempDirectory" | "downloader" | "cacheMode" | "cacheRoot" | "downloadOptions" | "isGeneric" | "mirrorOptions"> {
|
|
3
4
|
mirrorOptions?: Omit<MirrorOptions, "customDir" | "customFilename" | "customVersion">;
|
|
4
5
|
}
|
|
@@ -10,11 +11,13 @@ export type ArtifactDownloadOptions = {
|
|
|
10
11
|
version: string;
|
|
11
12
|
cacheDir?: string;
|
|
12
13
|
};
|
|
13
|
-
export declare function
|
|
14
|
+
export declare function hashUrlSafe(input: string, length?: number): string;
|
|
15
|
+
export declare const cacheDirectoryOverrideAllowed: MemoLazy<string | undefined, string>;
|
|
16
|
+
export declare function getCacheDirectoryInternal(options: {
|
|
14
17
|
isAvoidSystemOnWindows?: boolean;
|
|
15
18
|
allowEnvVarOverride: boolean;
|
|
16
|
-
}): string
|
|
17
|
-
export declare function extractArchive(
|
|
19
|
+
}): Promise<string>;
|
|
20
|
+
export declare function extractArchive(archive: string, dir: string): Promise<void>;
|
|
18
21
|
/**
|
|
19
22
|
* Forces undici's global proxy dispatcher to re-read the current HTTP(S)_PROXY / NO_PROXY env vars,
|
|
20
23
|
* bypassing the once-guard in initializeProxyOnce(). Exported for integration testing only.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electronGet.d.ts","sourceRoot":"","sources":["../../src/util/electronGet.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,+BAA+B,EAE/B,aAAa,EACd,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"electronGet.d.ts","sourceRoot":"","sources":["../../src/util/electronGet.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,+BAA+B,EAE/B,aAAa,EACd,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAa,QAAQ,EAAgB,MAAM,sBAAsB,CAAA;AAexE,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAC9C,+BAA+B,EAC7B,UAAU,GACV,MAAM,GACN,SAAS,GACT,cAAc,GACd,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,YAAY,GACZ,WAAW,GACX,WAAW,GACX,iBAAiB,GACjB,WAAW,GACX,eAAe,CAClB;IAC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GAGG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAG7F;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAShG;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAclE"}
|
package/dist/util/electronGet.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as get from "@electron/get";
|
|
2
2
|
import { ElectronDownloadCacheMode, } from "@electron/get";
|
|
3
3
|
import { exec, exists, log, PADDING, parseValidEnvVarUrl, sanitizeDirPath, to7zaOutputSwitch, ensureDir, moveDirAtomic } from "builder-util";
|
|
4
|
-
import { HttpError, retry, sleep } from "builder-util-runtime";
|
|
4
|
+
import { HttpError, MemoLazy, retry, sleep } from "builder-util-runtime";
|
|
5
5
|
import * as crypto from "crypto";
|
|
6
6
|
import { MultiProgress } from "electron-publish";
|
|
7
7
|
import { createReadStream, createWriteStream } from "fs";
|
|
@@ -14,7 +14,7 @@ import * as tar from "tar";
|
|
|
14
14
|
import * as unzipper from "unzipper";
|
|
15
15
|
import { getPath7za } from "../toolsets/7zip.js";
|
|
16
16
|
import { CacheState, cleanupCacheDirectory, computeCacheMetadata, readCacheStateFile, validateCacheDirectory, writeCacheState } from "./cacheState.js";
|
|
17
|
-
function hashUrlSafe(input, length = 6) {
|
|
17
|
+
export function hashUrlSafe(input, length = 6) {
|
|
18
18
|
let hash = 5381;
|
|
19
19
|
for (let i = 0; i < input.length; i++) {
|
|
20
20
|
hash = ((hash << 5) + hash) ^ input.charCodeAt(i);
|
|
@@ -23,11 +23,24 @@ function hashUrlSafe(input, length = 6) {
|
|
|
23
23
|
const out = hash.toString(36);
|
|
24
24
|
return out.length >= length ? out.slice(0, length) : out.padStart(length, "0");
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
// MemoLazy (not Lazy): keyed on ELECTRON_BUILDER_CACHE so the resolved cache dir is recomputed if the
|
|
27
|
+
// override env var changes, while staying memoized when it doesn't (the production case). The creator
|
|
28
|
+
// also ensures the resolved dir exists — that side effect lives here, at the point of use, so
|
|
29
|
+
// getCacheDirectoryInternal stays a pure path resolver.
|
|
30
|
+
export const cacheDirectoryOverrideAllowed = new MemoLazy(() => process.env.ELECTRON_BUILDER_CACHE?.trim(), async () => {
|
|
31
|
+
const dir = await getCacheDirectoryInternal({ isAvoidSystemOnWindows: true, allowEnvVarOverride: true });
|
|
32
|
+
await ensureDir(dir);
|
|
33
|
+
return dir;
|
|
34
|
+
});
|
|
35
|
+
// Exposed for testing; not intended for public use. Pure path resolution (no I/O) — use the memoized
|
|
36
|
+
// const's above when you need the directory to exist on disk. Kept async for a stable Promise-returning
|
|
37
|
+
// contract across all call sites.
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
39
|
+
export async function getCacheDirectoryInternal(options) {
|
|
27
40
|
const { isAvoidSystemOnWindows = true, allowEnvVarOverride } = options;
|
|
28
41
|
const env = process.env.ELECTRON_BUILDER_CACHE?.trim();
|
|
29
42
|
if (allowEnvVarOverride && env && path.parse(env).root) {
|
|
30
|
-
return env;
|
|
43
|
+
return sanitizeDirPath(env);
|
|
31
44
|
}
|
|
32
45
|
const appName = "electron-builder";
|
|
33
46
|
const platform = os.platform();
|
|
@@ -125,7 +138,8 @@ async function extractZipStreaming(file, dir) {
|
|
|
125
138
|
readStream.destroy();
|
|
126
139
|
}
|
|
127
140
|
}
|
|
128
|
-
export async function extractArchive(
|
|
141
|
+
export async function extractArchive(archive, dir) {
|
|
142
|
+
const file = sanitizeDirPath(archive);
|
|
129
143
|
const tmpDir = `${dir}.tmp`;
|
|
130
144
|
await fs.mkdir(tmpDir, { recursive: true });
|
|
131
145
|
const release = await lockfile.lock(tmpDir, {
|
|
@@ -150,22 +164,25 @@ export async function extractArchive(file, dir) {
|
|
|
150
164
|
if (file.endsWith(".tar.gz") || file.endsWith(".tgz")) {
|
|
151
165
|
await tar.extract({ file, cwd: tmpDir, strip: 1 });
|
|
152
166
|
}
|
|
153
|
-
else if (file.endsWith(".tar.xz") || file.endsWith(".txz")) {
|
|
154
|
-
// node-tar cannot decompress xz,
|
|
167
|
+
else if (file.endsWith(".tar.xz") || file.endsWith(".txz") || file.endsWith(".tar.7z")) {
|
|
168
|
+
// Compressed tarballs node-tar cannot decompress itself (xz, 7z): use 7za to strip the outer
|
|
169
|
+
// compression layer into a .tar, then extract that tar.
|
|
170
|
+
// Note: the .tar.7z check MUST stay ahead of the plain .7z branch below, otherwise only the outer
|
|
171
|
+
// 7z layer is removed and the inner tar is left behind as-is (see https://github.com/electron-userland/electron-builder/issues/10002).
|
|
155
172
|
const cmd7za = await getPath7za();
|
|
156
|
-
const
|
|
157
|
-
await fs.rm(
|
|
158
|
-
await fs.mkdir(
|
|
173
|
+
const decompressOutDir = `${tmpDir}.decompress`;
|
|
174
|
+
await fs.rm(decompressOutDir, { recursive: true, force: true });
|
|
175
|
+
await fs.mkdir(decompressOutDir, { recursive: true });
|
|
159
176
|
try {
|
|
160
|
-
await exec(cmd7za, ["x", "-bd", file, to7zaOutputSwitch(sanitizeDirPath(
|
|
161
|
-
const innerTar = (await fs.readdir(
|
|
177
|
+
await exec(cmd7za, ["x", "-bd", file, to7zaOutputSwitch(sanitizeDirPath(decompressOutDir)), "-y"]);
|
|
178
|
+
const innerTar = (await fs.readdir(decompressOutDir)).find(f => f.endsWith(".tar"));
|
|
162
179
|
if (innerTar == null) {
|
|
163
|
-
throw new Error(`
|
|
180
|
+
throw new Error(`decompression of ${path.basename(file)} produced no .tar archive`);
|
|
164
181
|
}
|
|
165
|
-
await tar.extract({ file: path.join(
|
|
182
|
+
await tar.extract({ file: path.join(decompressOutDir, innerTar), cwd: tmpDir, strip: 1 });
|
|
166
183
|
}
|
|
167
184
|
finally {
|
|
168
|
-
await fs.rm(
|
|
185
|
+
await fs.rm(decompressOutDir, { recursive: true, force: true });
|
|
169
186
|
}
|
|
170
187
|
}
|
|
171
188
|
else if (file.endsWith(".zip")) {
|
|
@@ -451,7 +468,7 @@ export async function download(url, output, checksum) {
|
|
|
451
468
|
const downloadedFile = await downloadArtifactToFile({
|
|
452
469
|
version: "9.9.9",
|
|
453
470
|
artifactName: filenameWithExt,
|
|
454
|
-
cacheRoot: path.resolve(
|
|
471
|
+
cacheRoot: path.resolve(await cacheDirectoryOverrideAllowed.value, "downloads"),
|
|
455
472
|
cacheMode: resolveCacheMode(),
|
|
456
473
|
...(checksum != null ? { checksums: { [filenameWithExt]: checksum } } : { unsafelyDisableChecksums: true }),
|
|
457
474
|
mirrorOptions: { resolveAssetURL: async () => Promise.resolve(url) },
|
|
@@ -506,9 +523,12 @@ export async function downloadBuilderToolset(options) {
|
|
|
506
523
|
const baseUrl = getBinariesMirrorUrl(githubOrgRepo);
|
|
507
524
|
const fullUrl = resolveBuilderBinaryUrl(releaseName, filenameWithExt, baseUrl, overrideUrl);
|
|
508
525
|
const suffix = hashUrlSafe(fullUrl, 5);
|
|
509
|
-
|
|
526
|
+
// tar.7z is listed before 7z so the full extension is stripped. Deliberate side effect: this changes the
|
|
527
|
+
// extract-dir name for .tar.7z toolsets (e.g. the snap template) from "<name>.tar-<hash>" to "<name>-<hash>",
|
|
528
|
+
// which busts caches poisoned by the broken .tar.7z extraction in 26.15.0-26.15.6 (issue #10002).
|
|
529
|
+
const folderName = `${filenameWithExt.replace(/\.(tar\.gz|tgz|tar\.xz|txz|tar\.7z|zip|7z)$/, "")}-${suffix}`;
|
|
510
530
|
// releaseName is library input; enforce cache-dir containment (rejects traversal, clears taint into shell extraction)
|
|
511
|
-
const cacheDir =
|
|
531
|
+
const cacheDir = await cacheDirectoryOverrideAllowed.value;
|
|
512
532
|
const extractDir = sanitizeDirPath(path.join(cacheDir, releaseName, folderName), cacheDir);
|
|
513
533
|
// Use resolveAssetURL so @electron/get's ELECTRON_MIRROR env var check cannot override
|
|
514
534
|
// the builder-binaries URL we've already resolved (see getArtifactRemoteURL in @electron/get).
|
|
@@ -522,7 +542,7 @@ export async function downloadBuilderToolset(options) {
|
|
|
522
542
|
const config = {
|
|
523
543
|
version: "9.9.9", // must be >1.3.2 to bypass @electron/get validation shortcut
|
|
524
544
|
artifactName: filenameWithExt,
|
|
525
|
-
cacheRoot: path.resolve(
|
|
545
|
+
cacheRoot: path.resolve(await cacheDirectoryOverrideAllowed.value, "downloads"),
|
|
526
546
|
cacheMode: resolveCacheMode(),
|
|
527
547
|
...(checksums != null ? { checksums } : { unsafelyDisableChecksums: true }),
|
|
528
548
|
mirrorOptions,
|
|
@@ -555,7 +575,7 @@ export async function downloadElectronArtifact(options) {
|
|
|
555
575
|
const artifactConfig = buildElectronArtifactConfig(options);
|
|
556
576
|
const suffix = hashUrlSafe(JSON.stringify(artifactConfig), 5);
|
|
557
577
|
const folderName = `${artifactName}-v${version}-${platform}-${arch}-${suffix}`;
|
|
558
|
-
const extractDir = path.join(
|
|
578
|
+
const extractDir = path.join(await cacheDirectoryOverrideAllowed.value, `${artifactName}-v${version}`, folderName);
|
|
559
579
|
return downloadAndExtract(artifactConfig, extractDir, artifactName);
|
|
560
580
|
}
|
|
561
581
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electronGet.js","sourceRoot":"","sources":["../../src/util/electronGet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,eAAe,CAAA;AACpC,OAAO,EAEL,yBAAyB,GAM1B,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5I,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC9D,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,OAAO,EAAE,aAAa,E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CAAA;IAEzH,OAAO,kBAAkB,CAAC,cAAc,EAAE,UAAU,EAAE,YAAY,CAAC,CAAA;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,aAAqB;IACxD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,KAAK,MAAM,CAAA;IACnF,KAAK,MAAM,MAAM,IAAI;QACnB,6CAA6C;QAC7C,6CAA6C;QAC7C,qDAAqD;QACrD,kCAAkC;KACnC,EAAE,CAAC;QACF,MAAM,GAAG,GAAG,mBAAmB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;QAClD,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAA;QAC5C,CAAC;IACH,CAAC;IACD,OAAO,sBAAsB,aAAa,qBAAqB,CAAA;AACjE,CAAC","sourcesContent":["import * as get from \"@electron/get\"\nimport {\n ElectronArtifactDetails,\n ElectronDownloadCacheMode,\n ElectronDownloadRequest,\n ElectronDownloadRequestOptions,\n ElectronPlatformArtifactDetails,\n FetchDownloaderOptions,\n MirrorOptions,\n} from \"@electron/get\"\nimport { exec, exists, log, PADDING, parseValidEnvVarUrl, sanitizeDirPath, to7zaOutputSwitch, ensureDir, moveDirAtomic } from \"builder-util\"\nimport { HttpError, retry, sleep } from \"builder-util-runtime\"\nimport * as crypto from \"crypto\"\nimport type { ProgressBar } from \"electron-publish\"\nimport { MultiProgress } from \"electron-publish\"\nimport { createReadStream, createWriteStream } from \"fs\"\nimport * as fs from \"fs/promises\"\nimport * as os from \"os\"\nimport * as path from \"path\"\nimport * as lockfile from \"proper-lockfile\"\nimport { pipeline } from \"stream/promises\"\nimport * as tar from \"tar\"\nimport * as unzipper from \"unzipper\"\nimport { getPath7za } from \"../toolsets/7zip.js\"\nimport { CacheState, cleanupCacheDirectory, computeCacheMetadata, readCacheStateFile, validateCacheDirectory, writeCacheState } from \"./cacheState.js\"\n\nexport interface ElectronGetOptions extends Omit<\n ElectronPlatformArtifactDetails,\n | \"platform\"\n | \"arch\"\n | \"version\"\n | \"artifactName\"\n | \"artifactSuffix\"\n | \"customFilename\"\n | \"tempDirectory\"\n | \"downloader\"\n | \"cacheMode\"\n | \"cacheRoot\"\n | \"downloadOptions\"\n | \"isGeneric\"\n | \"mirrorOptions\"\n> {\n mirrorOptions?: Omit<MirrorOptions, \"customDir\" | \"customFilename\" | \"customVersion\">\n}\n\nexport type ArtifactDownloadOptions = {\n options?: ElectronGetOptions | null\n artifactName: string\n platformName: string\n arch: string\n version: string\n cacheDir?: string\n}\n\nfunction hashUrlSafe(input: string, length = 6): string {\n let hash = 5381\n for (let i = 0; i < input.length; i++) {\n hash = ((hash << 5) + hash) ^ input.charCodeAt(i)\n }\n hash >>>= 0\n const out = hash.toString(36)\n return out.length >= length ? out.slice(0, length) : out.padStart(length, \"0\")\n}\n\nexport function getCacheDirectory(options: { isAvoidSystemOnWindows?: boolean; allowEnvVarOverride: boolean }): string {\n const { isAvoidSystemOnWindows = true, allowEnvVarOverride } = options\n const env = process.env.ELECTRON_BUILDER_CACHE?.trim()\n if (allowEnvVarOverride && env && path.parse(env).root) {\n return env\n }\n\n const appName = \"electron-builder\"\n const platform = os.platform()\n const homeDir = os.homedir()\n\n if (platform === \"darwin\") {\n return path.join(homeDir, \"Library\", \"Caches\", appName)\n }\n if (platform === \"win32\") {\n const localAppData = process.env.LOCALAPPDATA?.trim()\n const username = process.env.USERNAME?.trim()?.toLowerCase()\n // https://github.com/electron-userland/electron-builder/issues/1164\n const isSystemUser = isAvoidSystemOnWindows && (localAppData?.toLowerCase()?.includes(\"\\\\windows\\\\system32\\\\\") || username === \"system\")\n if (!localAppData || isSystemUser) {\n return path.join(os.tmpdir(), `${appName}-cache`)\n }\n return path.join(localAppData, appName, \"Cache\")\n }\n\n const xdgCache = process.env.XDG_CACHE_HOME\n return xdgCache && path.parse(xdgCache).root ? path.join(xdgCache, appName) : path.join(homeDir, \".cache\", appName)\n}\n\nfunction resolveCacheMode(): ElectronDownloadCacheMode {\n const varName = \"ELECTRON_DOWNLOAD_CACHE_MODE\"\n const cacheOverride = process.env[varName]?.trim()\n if (cacheOverride && Number(cacheOverride) in ElectronDownloadCacheMode) {\n const mode = Number(cacheOverride) as ElectronDownloadCacheMode\n log.debug({ mode }, `cache mode overridden via env var ${varName}`)\n return mode\n }\n return ElectronDownloadCacheMode.ReadWrite\n}\n\n/**\n * Returns true when `destPath` is safely contained within `dir` (direct child or deeper).\n * On Windows the filesystem is case-insensitive so the comparison is normalised to lowercase.\n * @internal exported for unit testing\n */\nexport function isSafeExtractPath(destPath: string, dir: string): boolean {\n const normalizedDest = path.resolve(destPath)\n const normalizedDir = path.resolve(dir)\n if (process.platform === \"win32\") {\n const d = normalizedDest.toLowerCase()\n const b = normalizedDir.toLowerCase()\n return d.startsWith(b + path.sep) || d === b\n }\n return normalizedDest.startsWith(normalizedDir + path.sep) || normalizedDest === normalizedDir\n}\n\nasync function extractZipStreaming(file: string, dir: string): Promise<void> {\n // Pass 1: read central directory once to collect Unix modes (one seek to EOF)\n const zipDir = await unzipper.Open.file(file)\n const entryModes = new Map<string, number>()\n for (const entry of zipDir.files) {\n const mode = (entry.externalFileAttributes >> 16) & 0xffff\n if (mode > 0) {\n entryModes.set(entry.path, mode)\n }\n }\n const isSymlink = (mode: number) => (mode & 0o170000) === 0o120000\n\n // Pass 2: stream from byte 0 — no per-entry seeks, no Docker hang.\n // Destroy the read stream in a finally block so the file handle is always released,\n // including when the loop exits early due to a thrown error.\n const readStream = createReadStream(file)\n try {\n const entries = readStream.pipe(unzipper.Parse({ forceStream: true }))\n for await (const entry of entries as AsyncIterable<unzipper.Entry>) {\n const destPath = path.resolve(dir, entry.path)\n if (!isSafeExtractPath(destPath, dir)) {\n throw new Error(`Path traversal blocked: ${entry.path}`)\n }\n const mode = entryModes.get(entry.path) ?? 0\n if (mode > 0 && isSymlink(mode)) {\n const target = (await entry.buffer()).toString()\n if (path.isAbsolute(target)) {\n throw new Error(`Absolute symlink target blocked: ${target}`)\n }\n const resolvedTarget = path.resolve(path.dirname(destPath), target)\n if (!isSafeExtractPath(resolvedTarget, dir)) {\n throw new Error(`Symlink target escapes extraction dir: ${target}`)\n }\n await fs.mkdir(path.dirname(destPath), { recursive: true })\n await fs.symlink(target, destPath)\n } else if (entry.type === \"Directory\") {\n await fs.mkdir(destPath, { recursive: true })\n entry.autodrain()\n } else {\n await fs.mkdir(path.dirname(destPath), { recursive: true })\n await pipeline(entry, createWriteStream(destPath))\n if (mode > 0) {\n await fs.chmod(destPath, mode & 0o7777)\n }\n }\n }\n } finally {\n readStream.destroy()\n }\n}\n\nexport async function extractArchive(file: string, dir: string) {\n const tmpDir = `${dir}.tmp`\n await fs.mkdir(tmpDir, { recursive: true })\n\n const release = await lockfile.lock(tmpDir, {\n // 100 retries (not 15) so concurrent callers wait out a slow first extraction instead of failing\n // with ELOCKED; the update heartbeat keeps an in-progress holder's lock fresh against `stale`.\n retries: { retries: 100, minTimeout: 1000, maxTimeout: 5000 },\n stale: 120000, // Increased from 60s to allow long-running extractions\n })\n\n try {\n // rm + mkdir happen AFTER acquiring the lock so no concurrent caller can clear our tmpDir mid-extraction\n await fs.rm(tmpDir, { recursive: true, force: true })\n await fs.mkdir(tmpDir, { recursive: true })\n\n // Guard against the transient window in @electron/get's non-atomic putFileInCache (remove → move).\n // A concurrent worker may have deleted and not yet replaced the source archive; wait briefly for it.\n for (let i = 0; !(await exists(file)); i++) {\n if (i >= 4) {\n throw Object.assign(new Error(`Source archive not found after retries: ${file}`), { code: \"ENOENT\", path: file })\n }\n log.warn({ file, attempt: i + 1 }, \"source archive transiently missing, retrying\")\n await sleep(300 * (i + 1))\n }\n\n if (file.endsWith(\".tar.gz\") || file.endsWith(\".tgz\")) {\n await tar.extract({ file, cwd: tmpDir, strip: 1 })\n } else if (file.endsWith(\".tar.xz\") || file.endsWith(\".txz\")) {\n // node-tar cannot decompress xz, so use 7za to turn the .tar.xz into a .tar, then extract that tar.\n const cmd7za = await getPath7za()\n const xzOutDir = `${tmpDir}.xz`\n await fs.rm(xzOutDir, { recursive: true, force: true })\n await fs.mkdir(xzOutDir, { recursive: true })\n try {\n await exec(cmd7za, [\"x\", \"-bd\", file, to7zaOutputSwitch(sanitizeDirPath(xzOutDir)), \"-y\"])\n const innerTar = (await fs.readdir(xzOutDir)).find(f => f.endsWith(\".tar\"))\n if (innerTar == null) {\n throw new Error(`xz decompression of ${path.basename(file)} produced no .tar archive`)\n }\n await tar.extract({ file: path.join(xzOutDir, innerTar), cwd: tmpDir, strip: 1 })\n } finally {\n await fs.rm(xzOutDir, { recursive: true, force: true })\n }\n } else if (file.endsWith(\".zip\")) {\n await extractZipStreaming(file, tmpDir)\n } else if (file.endsWith(\".7z\")) {\n const cmd7za = await getPath7za()\n try {\n await exec(cmd7za, [\"x\", \"-bd\", file, to7zaOutputSwitch(sanitizeDirPath(tmpDir)), \"-y\"])\n } catch (e: any) {\n // Check if extraction actually failed or just had benign warnings\n const files = await fs.readdir(tmpDir)\n if (files.length === 0) {\n log.warn({ file: log.filePath(file), tmpDir: log.filePath(tmpDir), error: e.message }, \"7z extraction produced no output\")\n throw new Error(`7z extraction failed for ${file}: ${e.message}`)\n }\n // If files were extracted despite the error, log and continue\n log.warn({ error: e.message, filesExtracted: files.length }, \"7z reported error but extracted files\")\n }\n } else {\n throw new Error(`Unsupported archive format: ${path.basename(file)}`)\n }\n\n // Verify extraction produced files\n const extractedFiles = await fs.readdir(tmpDir)\n if (extractedFiles.length === 0) {\n throw new Error(`Extraction of ${path.basename(file)} produced no files`)\n }\n\n await fs.rm(dir, { recursive: true, force: true })\n await moveDirAtomic(tmpDir, dir)\n } finally {\n await release().catch(err => log.warn({ err }, \"failed to release lockfile\"))\n }\n}\n\nlet proxyInitialized = false\nfunction initializeProxyOnce(): void {\n if (!proxyInitialized) {\n reinitializeProxy()\n proxyInitialized = true\n }\n}\n\n/**\n * Forces undici's global proxy dispatcher to re-read the current HTTP(S)_PROXY / NO_PROXY env vars,\n * bypassing the once-guard in initializeProxyOnce(). Exported for integration testing only.\n */\nexport function reinitializeProxy(): void {\n get.initializeProxy()\n}\n\nasync function downloadArtifactToFile(config: ElectronArtifactDetails, label: string): Promise<string> {\n // Serialize concurrent downloads of the same artifact across vitest workers to prevent @electron/get's\n // non-atomic putFileInCache (remove + move) from racing with a concurrent reader.\n const key = {\n p: (config as ElectronPlatformArtifactDetails).platform,\n a: (config as ElectronPlatformArtifactDetails).arch,\n v: config.version,\n n: config.artifactName,\n g: config.isGeneric,\n }\n\n const artifactLockKey = crypto.createHash(\"sha256\").update(JSON.stringify(key)).digest(\"hex\").slice(0, 20)\n const artifactLockPath = path.join(os.tmpdir(), `eb-dl-${artifactLockKey}.lock`)\n // This lock is taken even for cache hits (the cache-hit check lives inside @electron/get), so under\n // heavy concurrency many builds serialize here. 30 retries (~137s of backoff) is too few — waiters\n // were exhausting it and failing with ELOCKED while the holder fetched a large artifact. 100 retries\n // matches the other toolset locks; stale (10min) + proper-lockfile's update heartbeat keep a live\n // downloader's lock fresh so the longer wait never falsely steals an in-progress download.\n const releaseArtifactLock = await lockfile.lock(artifactLockPath, {\n retries: { retries: 100, minTimeout: 500, maxTimeout: 5000 },\n stale: 600_000,\n realpath: false,\n })\n let lastLoggedMilestone = -1\n const state: { bar: ProgressBar | undefined } = { bar: undefined }\n\n // @electron/get v5 downloads via fetch, whose proxy support comes from undici's global dispatcher.\n // initializeProxy() wires that up from HTTP(S)_PROXY/NO_PROXY env vars (replaces the got proxy agent).\n initializeProxyOnce()\n\n const downloadOptions: FetchDownloaderOptions = {\n signal: AbortSignal.timeout(10 * 60 * 1000), // prevent indefinite hang on stalled connections\n ...config.downloadOptions,\n getProgressCallback: info => {\n // @electron/get passes downloadOptions (including this callback) to its internal\n // SHASUMS256.txt validation download. That file is tiny (<1 MB) and fires at 100%\n // immediately, producing a spurious bar even when the artifact itself is cached.\n // Skip progress display for any download whose total size is known and small.\n if (info.total && info.total < 1_000_000) {\n return Promise.resolve()\n }\n if (!state.bar && process.stdout.isTTY) {\n log.info({ label }, \"downloading\")\n state.bar = new MultiProgress().createBar(`${\" \".repeat(PADDING + 2)}[:bar] :percent | ${label}`, { total: 100 })\n }\n const pct = info.percent != null ? Math.floor(info.percent * 100) : 0\n if (state.bar) {\n state.bar.update(pct)\n } else {\n // log every 25% milestone for non-TTY environments (e.g. CI logs) to provide some visibility into download progress without overwhelming logs with too many updates\n const percentCompleted = info.transferred && info.total ? Math.floor((info.transferred / info.total) * 100) : Math.floor(pct / 25) * 25\n if (percentCompleted > lastLoggedMilestone && percentCompleted > 0) {\n lastLoggedMilestone = percentCompleted\n log.info({ label, progress: `${percentCompleted}%` }, percentCompleted !== 100 ? \"downloading\" : \"downloaded\")\n }\n }\n return Promise.resolve()\n },\n }\n\n const configWithProgress = { ...config, downloadOptions }\n try {\n let filePath: string\n try {\n filePath = await retry(() => get.downloadArtifact(configWithProgress), {\n retries: 3,\n interval: 2000,\n backoff: 2000,\n shouldRetry: (e: any) =>\n e instanceof HttpError ? e.isServerError() : typeof e?.code === \"string\" && [\"ENOTFOUND\", \"ETIMEDOUT\", \"ECONNRESET\", \"EPIPE\", \"ENOENT\"].includes(e.code),\n })\n } catch (err) {\n if (typeof (err as any)?.message === \"string\" && (err as any).message.includes(\"dest already exists\")) {\n filePath = await get.downloadArtifact(configWithProgress)\n } else {\n throw err\n }\n }\n if (!(await exists(filePath))) {\n log.warn({ filePath, label }, \"cached artifact missing from disk; retrying with cache write\")\n filePath = await get.downloadArtifact({ ...configWithProgress, cacheMode: ElectronDownloadCacheMode.WriteOnly })\n }\n if (!state.bar && lastLoggedMilestone === -1) {\n log.info({ label }, \"using cached artifact\")\n }\n return filePath\n } finally {\n state.bar?.update(100)\n state.bar?.terminate()\n await releaseArtifactLock().catch(err => log.warn({ err }, \"failed to release artifact download lock\"))\n }\n}\n\n/**\n * Checks electron-builder's own archive cache for a previously downloaded archive.\n * Validates the SHA-256 checksum when one is known. Returns the cached path on hit,\n * null on miss or checksum mismatch (mismatch also deletes the stale file).\n */\nasync function resolveFromArchiveCache(archiveCachePath: string, label: string, expectedSha256: string | undefined): Promise<string | null> {\n if (!(await exists(archiveCachePath))) {\n return null\n }\n if (expectedSha256) {\n const hash = await new Promise<string>((resolve, reject) => {\n const h = crypto.createHash(\"sha256\")\n const s = createReadStream(archiveCachePath)\n s.on(\"error\", reject)\n s.on(\"data\", (chunk: Buffer | string) => h.update(chunk))\n s.on(\"end\", () => resolve(h.digest(\"hex\")))\n })\n if (hash !== expectedSha256) {\n log.warn({ file: label, archiveCachePath }, \"cached archive checksum mismatch — removing and re-downloading\")\n await fs.rm(archiveCachePath).catch(() => {})\n return null\n }\n }\n log.debug({ file: label, archiveCachePath }, \"using cached archive — skipping download\")\n return archiveCachePath\n}\n\n/**\n * Copies a freshly downloaded archive into electron-builder's own archive cache so that\n * future builds (including offline environments) can skip the network request entirely.\n */\nasync function persistToArchiveCache(sourcePath: string, archiveCachePath: string): Promise<void> {\n try {\n await fs.mkdir(path.dirname(archiveCachePath), { recursive: true })\n await fs.copyFile(sourcePath, archiveCachePath)\n } catch (err) {\n log.warn({ err, archiveCachePath }, \"failed to persist archive to cache — will re-download next time\")\n }\n}\n\n/**\n * Core download + extract engine. Handles lockfile, cache-hit short-circuit,\n * progress bar, extraction (.zip or .tar.gz), and completion marker.\n * Both public download functions delegate here after building their respective configs.\n */\nasync function downloadAndExtract(config: ElectronArtifactDetails, extractDir: string, label: string, archiveCachePath?: string): Promise<string> {\n // Create only the PARENT dir (e.g. <cache>/fpm@2.2.1), never extractDir itself, before locking.\n // The parent is stable — cleanup only ever removes extractDir and its .state/.tmp/.lock siblings —\n // so extractDir's whole lifecycle (mkdir, rm, re-mkdir) stays inside the lock. ensureDir absorbs\n // the concurrent-recursive-mkdir ENOENT/EEXIST race while peers populate the cold cache tree.\n await ensureDir(path.dirname(extractDir))\n\n // Pre-lock fast path: read-only short-circuit for a definitively complete and valid cache.\n // Safe unlocked — the cache-state helpers return null/false for a missing or half-written dir,\n // so a racing read only ever falls through to take the lock. Do NOT mutate the dir here.\n const stateData = await readCacheStateFile(extractDir)\n if (stateData?.state === CacheState.complete) {\n const isValid = await validateCacheDirectory(extractDir, stateData.fileCount)\n if (isValid) {\n log.debug({ file: label, path: extractDir }, \"using cached artifact - cache valid\")\n return extractDir\n }\n }\n\n // Be patient: when many targets/builds contend on the same toolset cache concurrently, all but the\n // first wait here while the winner downloads+extracts (a large bundle can take >1min). 15 retries\n // (~67s) is too few and waiters fail with ELOCKED before the winner finishes; 100 matches the\n // patience of withToolsetLock. proper-lockfile's update heartbeat keeps a live holder's lock fresh,\n // so increasing waiter retries never falsely steals an in-progress extraction.\n const release = await lockfile.lock(extractDir, {\n // realpath:false so proper-lockfile creates <extractDir>.lock in the (already-created) parent\n // WITHOUT calling fs.realpath(extractDir) first — which would throw ENOENT now that extractDir\n // is created lazily inside the lock. This filesystem lock serializes peers both across worker\n // processes AND within a single process (a second lock() for the same path retries until the\n // first releases), so no in-process promise cache is needed — and one wouldn't help across the\n // separate test worker processes anyway.\n realpath: false,\n retries: { retries: 100, minTimeout: 1000, maxTimeout: 5000 },\n stale: 120000,\n })\n let downloadedFile: string | null = null\n try {\n // Re-check after acquiring lock: another worker may have completed while we waited.\n const stateDataAfterLock = await readCacheStateFile(extractDir)\n if (stateDataAfterLock?.state === CacheState.complete) {\n const isValid = await validateCacheDirectory(extractDir, stateDataAfterLock.fileCount)\n if (isValid) {\n log.debug({ file: label, path: extractDir }, \"using cached artifact - skipping download/extract\")\n return extractDir\n }\n log.warn({ extractDir }, \"Cache marked complete but files invalid, clearing\")\n } else if (stateDataAfterLock?.state === CacheState.corrupted) {\n log.warn({ extractDir }, \"Corrupted cache detected, cleaning up and re-extracting\")\n }\n\n // Cleanup inside the lock — skip lock files since we currently hold them\n await cleanupCacheDirectory(extractDir, { skipLockFiles: true })\n await ensureDir(extractDir)\n\n // Check electron-builder's own archive cache before touching @electron/get.\n // The cache lives alongside the extract dir: <cacheDir>/<releaseName>/<filename>.\n // This lets repeated builds (or offline environments) skip the download entirely once\n // the archive has been fetched at least once.\n if (archiveCachePath) {\n downloadedFile = await resolveFromArchiveCache(archiveCachePath, label, (config as any).checksums?.[label])\n }\n\n if (!downloadedFile) {\n log.debug({ file: label }, \"downloading\")\n downloadedFile = await downloadArtifactToFile(config, label)\n if (!downloadedFile) {\n throw new Error(`Failed to download artifact: ${label}`)\n }\n // Persist the downloaded archive so future builds (and offline environments) can\n // skip the network request entirely.\n if (archiveCachePath) {\n await persistToArchiveCache(downloadedFile, archiveCachePath)\n }\n }\n\n await writeCacheState(extractDir, CacheState.downloaded)\n\n // Mark extracting so stale-lock detection can recover a crashed mid-extraction process\n await writeCacheState(extractDir, CacheState.extracting)\n\n // Extract while holding the lock to prevent concurrent interference\n await extractArchive(downloadedFile, extractDir)\n\n // Compute metadata with a full recursive walk now that tmpDir has been renamed to extractDir\n const { fileCount, extractedSize } = await computeCacheMetadata(extractDir)\n\n // Write complete state with metadata BEFORE releasing the lock; throwOnError=true so a\n // failed write (disk full, permissions) propagates instead of silently producing a no-op cache\n await writeCacheState(extractDir, CacheState.complete, { fileCount, extractedSize }, true)\n } finally {\n await release().catch(err => log.warn({ err }, \"failed to release lockfile\"))\n }\n return extractDir\n}\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\n/**\n * Copies a remote artifact to a specific output path on disk.\n * Unlike downloadBuilderToolset, this does not extract archives — it copies the raw file.\n * Used for certificate imports where the caller needs the file at a known path.\n */\nexport async function download(url: string, output: string, checksum?: string | null): Promise<void> {\n const filenameWithExt = path.basename(new URL(url).pathname)\n if (checksum == null) {\n log.warn({ url }, \"downloading without an integrity checksum — the download is not verified against a known-good hash\")\n }\n const downloadedFile = await downloadArtifactToFile(\n {\n version: \"9.9.9\",\n artifactName: filenameWithExt,\n cacheRoot: path.resolve(getCacheDirectory({ allowEnvVarOverride: true }), \"downloads\"),\n cacheMode: resolveCacheMode(),\n ...(checksum != null ? { checksums: { [filenameWithExt]: checksum } } : { unsafelyDisableChecksums: true }),\n mirrorOptions: { resolveAssetURL: async () => Promise.resolve(url) },\n isGeneric: true,\n },\n filenameWithExt\n )\n await fs.copyFile(downloadedFile, output)\n}\n\nfunction validateBinaryCustomDir(envVarName: string, value: string): string {\n if (value.includes(\"://\") || value.includes(\"..\") || value.startsWith(\"/\")) {\n throw new Error(\n `${envVarName} must be a safe relative path component (e.g. \"v1.0.0-custom\"). ` + `Values containing \"://\", \"..\", or a leading \"/\" are not allowed. Got: \"${value}\"`\n )\n }\n return value\n}\n\nconst CUSTOM_DIR_ENV_VARS = [\n \"NPM_CONFIG_ELECTRON_BUILDER_BINARIES_CUSTOM_DIR\",\n \"npm_config_electron_builder_binaries_custom_dir\",\n \"npm_package_config_electron_builder_binaries_custom_dir\",\n \"ELECTRON_BUILDER_BINARIES_CUSTOM_DIR\",\n] as const\n\n/**\n * Resolves the final download URL for a builder binary, honouring:\n * ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL – fully replaces the URL directory\n * ELECTRON_BUILDER_BINARIES_CUSTOM_DIR (and npm_ variants) – replaces releaseName in the path\n * overrideUrl (caller-supplied) – used as-is when no env var is set\n *\n * Exported for unit testing; not part of the public API.\n * @internal\n */\nexport function resolveBuilderBinaryUrl(releaseName: string, filenameWithExt: string, baseUrl: string, overrideUrl?: string): string {\n const envOverrideUrl = parseValidEnvVarUrl(\"ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL\")\n if (envOverrideUrl != null) {\n return `${envOverrideUrl}/${filenameWithExt}`\n }\n if (overrideUrl != null) {\n return `${overrideUrl}/${filenameWithExt}`\n }\n const customDirEntry = CUSTOM_DIR_ENV_VARS.map(name => ({ name, value: process.env[name] })).find(e => e.value != null)\n if (customDirEntry != null) {\n return `${baseUrl}${validateBinaryCustomDir(customDirEntry.name, customDirEntry.value!)}/${filenameWithExt}`\n }\n return `${baseUrl}${releaseName}/${filenameWithExt}`\n}\n\n/**\n * Downloads a generic artifact (.tar.gz or .zip) from a GitHub release.\n * Used for electron-builder-binaries tools (appimage, etc.).\n */\nexport async function downloadBuilderToolset(options: {\n releaseName: string\n filenameWithExt: string\n checksums?: Record<string, string>\n githubOrgRepo?: string\n overrideUrl?: string\n}): Promise<string> {\n const { releaseName, filenameWithExt, checksums, githubOrgRepo = \"electron-userland/electron-builder-binaries\", overrideUrl } = options\n\n if (/[/\\\\]|^\\.\\./.test(filenameWithExt) || filenameWithExt.includes(\"..\")) {\n throw new Error(`downloadBuilderToolset: unsafe filenameWithExt \"${filenameWithExt}\" — must be a plain filename with no path separators or traversal sequences`)\n }\n\n const baseUrl = getBinariesMirrorUrl(githubOrgRepo)\n const fullUrl = resolveBuilderBinaryUrl(releaseName, filenameWithExt, baseUrl, overrideUrl)\n const suffix = hashUrlSafe(fullUrl, 5)\n const folderName = `${filenameWithExt.replace(/\\.(tar\\.gz|tgz|tar\\.xz|txz|zip|7z)$/, \"\")}-${suffix}`\n // releaseName is library input; enforce cache-dir containment (rejects traversal, clears taint into shell extraction)\n const cacheDir = getCacheDirectory({ allowEnvVarOverride: true })\n const extractDir = sanitizeDirPath(path.join(cacheDir, releaseName, folderName), cacheDir)\n\n // Use resolveAssetURL so @electron/get's ELECTRON_MIRROR env var check cannot override\n // the builder-binaries URL we've already resolved (see getArtifactRemoteURL in @electron/get).\n const mirrorOptions: MirrorOptions = {\n resolveAssetURL: async () => Promise.resolve(fullUrl),\n }\n\n // Predictable archive cache: <cacheDir>/<releaseName>/<filename>, next to the extract dir.\n // downloadAndExtract checks here before touching @electron/get and persists the archive here\n // after every successful download, so subsequent builds never need a network round-trip.\n const archiveCachePath = sanitizeDirPath(path.join(cacheDir, releaseName, filenameWithExt), cacheDir)\n\n const config: ElectronDownloadRequest & ElectronDownloadRequestOptions & { isGeneric: true } = {\n version: \"9.9.9\", // must be >1.3.2 to bypass @electron/get validation shortcut\n artifactName: filenameWithExt,\n cacheRoot: path.resolve(getCacheDirectory({ allowEnvVarOverride: true }), \"downloads\"),\n cacheMode: resolveCacheMode(),\n ...(checksums != null ? { checksums } : { unsafelyDisableChecksums: true }),\n mirrorOptions,\n isGeneric: true,\n }\n return downloadAndExtract(config, extractDir, filenameWithExt, archiveCachePath)\n}\n\n/**\n * Downloads and extracts an electron platform artifact (e.g. ffmpeg) using @electron/get.\n * Deduplicates concurrent calls for the same artifact within the same process.\n */\nfunction buildElectronArtifactConfig(artifactOptions: ArtifactDownloadOptions): ElectronPlatformArtifactDetails {\n const { options, arch, version, platformName: platform, artifactName, cacheDir: cacheRoot } = artifactOptions\n\n if (options?.unsafelyDisableChecksums) {\n log.warn(\n { artifactName },\n \"electronGet.unsafelyDisableChecksums is enabled — downloaded artifacts will NOT be verified.txt; a compromised mirror can serve malicious binaries undetected\"\n )\n }\n\n const artifactConfig: ElectronPlatformArtifactDetails = { ...options, cacheRoot, platform, arch, version, artifactName, cacheMode: resolveCacheMode() }\n return artifactConfig\n}\n\n/**\n * Downloads the electron artifact zip via @electron/get (with caching) and returns the zip file path.\n * Use when you need to extract the zip yourself (e.g. directly to appOutDir to preserve empty dirs and symlinks).\n */\nexport function downloadElectronArtifactZip(options: ArtifactDownloadOptions): Promise<string> {\n const config = buildElectronArtifactConfig(options)\n return downloadArtifactToFile(config, config.artifactName)\n}\n\nexport async function downloadElectronArtifact(options: ArtifactDownloadOptions): Promise<string> {\n const { arch, version, platformName: platform, artifactName } = options\n const artifactConfig = buildElectronArtifactConfig(options)\n\n const suffix = hashUrlSafe(JSON.stringify(artifactConfig), 5)\n const folderName = `${artifactName}-v${version}-${platform}-${arch}-${suffix}`\n const extractDir = path.join(getCacheDirectory({ allowEnvVarOverride: true }), `${artifactName}-v${version}`, folderName)\n\n return downloadAndExtract(artifactConfig, extractDir, artifactName)\n}\n\n/**\n * Get the binaries mirror URL from environment variables.\n * Supports various npm config formats and falls back to GitHub.\n */\nexport function getBinariesMirrorUrl(githubOrgRepo: string): string {\n const allowHttp = process.env[\"ELECTRON_BUILDER_DANGEROUSLY_ALLOW_HTTP\"] === \"true\"\n for (const envVar of [\n \"NPM_CONFIG_ELECTRON_BUILDER_BINARIES_MIRROR\",\n \"npm_config_electron_builder_binaries_mirror\",\n \"npm_package_config_electron_builder_binaries_mirror\",\n \"ELECTRON_BUILDER_BINARIES_MIRROR\",\n ]) {\n const url = parseValidEnvVarUrl(envVar, allowHttp)\n if (url) {\n return url.endsWith(\"/\") ? url : `${url}/`\n }\n }\n return `https://github.com/${githubOrgRepo}/releases/download/`\n}\n"]}
|
|
1
|
+
{"version":3,"file":"electronGet.js","sourceRoot":"","sources":["../../src/util/electronGet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,eAAe,CAAA;AACpC,OAAO,EAEL,yBAAyB,GAM1B,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5I,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA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AC,CAAA;IAC7D,MAAM,UAAU,GAAG,GAAG,YAAY,KAAK,OAAO,IAAI,QAAQ,IAAI,IAAI,IAAI,MAAM,EAAE,CAAA;IAC9E,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,6BAA6B,CAAC,KAAK,EAAE,GAAG,YAAY,KAAK,OAAO,EAAE,EAAE,UAAU,CAAC,CAAA;IAElH,OAAO,kBAAkB,CAAC,cAAc,EAAE,UAAU,EAAE,YAAY,CAAC,CAAA;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,aAAqB;IACxD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,KAAK,MAAM,CAAA;IACnF,KAAK,MAAM,MAAM,IAAI;QACnB,6CAA6C;QAC7C,6CAA6C;QAC7C,qDAAqD;QACrD,kCAAkC;KACnC,EAAE,CAAC;QACF,MAAM,GAAG,GAAG,mBAAmB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;QAClD,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAA;QAC5C,CAAC;IACH,CAAC;IACD,OAAO,sBAAsB,aAAa,qBAAqB,CAAA;AACjE,CAAC","sourcesContent":["import * as get from \"@electron/get\"\nimport {\n ElectronArtifactDetails,\n ElectronDownloadCacheMode,\n ElectronDownloadRequest,\n ElectronDownloadRequestOptions,\n ElectronPlatformArtifactDetails,\n FetchDownloaderOptions,\n MirrorOptions,\n} from \"@electron/get\"\nimport { exec, exists, log, PADDING, parseValidEnvVarUrl, sanitizeDirPath, to7zaOutputSwitch, ensureDir, moveDirAtomic } from \"builder-util\"\nimport { HttpError, MemoLazy, retry, sleep } from \"builder-util-runtime\"\nimport * as crypto from \"crypto\"\nimport type { ProgressBar } from \"electron-publish\"\nimport { MultiProgress } from \"electron-publish\"\nimport { createReadStream, createWriteStream } from \"fs\"\nimport * as fs from \"fs/promises\"\nimport * as os from \"os\"\nimport * as path from \"path\"\nimport * as lockfile from \"proper-lockfile\"\nimport { pipeline } from \"stream/promises\"\nimport * as tar from \"tar\"\nimport * as unzipper from \"unzipper\"\nimport { getPath7za } from \"../toolsets/7zip.js\"\nimport { CacheState, cleanupCacheDirectory, computeCacheMetadata, readCacheStateFile, validateCacheDirectory, writeCacheState } from \"./cacheState.js\"\n\nexport interface ElectronGetOptions extends Omit<\n ElectronPlatformArtifactDetails,\n | \"platform\"\n | \"arch\"\n | \"version\"\n | \"artifactName\"\n | \"artifactSuffix\"\n | \"customFilename\"\n | \"tempDirectory\"\n | \"downloader\"\n | \"cacheMode\"\n | \"cacheRoot\"\n | \"downloadOptions\"\n | \"isGeneric\"\n | \"mirrorOptions\"\n> {\n mirrorOptions?: Omit<MirrorOptions, \"customDir\" | \"customFilename\" | \"customVersion\">\n}\n\nexport type ArtifactDownloadOptions = {\n options?: ElectronGetOptions | null\n artifactName: string\n platformName: string\n arch: string\n version: string\n cacheDir?: string\n}\n\nexport function hashUrlSafe(input: string, length = 6): string {\n let hash = 5381\n for (let i = 0; i < input.length; i++) {\n hash = ((hash << 5) + hash) ^ input.charCodeAt(i)\n }\n hash >>>= 0\n const out = hash.toString(36)\n return out.length >= length ? out.slice(0, length) : out.padStart(length, \"0\")\n}\n\n// MemoLazy (not Lazy): keyed on ELECTRON_BUILDER_CACHE so the resolved cache dir is recomputed if the\n// override env var changes, while staying memoized when it doesn't (the production case). The creator\n// also ensures the resolved dir exists — that side effect lives here, at the point of use, so\n// getCacheDirectoryInternal stays a pure path resolver.\nexport const cacheDirectoryOverrideAllowed = new MemoLazy<string | undefined, string>(\n () => process.env.ELECTRON_BUILDER_CACHE?.trim(),\n async () => {\n const dir = await getCacheDirectoryInternal({ isAvoidSystemOnWindows: true, allowEnvVarOverride: true })\n await ensureDir(dir)\n return dir\n }\n)\n// Exposed for testing; not intended for public use. Pure path resolution (no I/O) — use the memoized\n// const's above when you need the directory to exist on disk. Kept async for a stable Promise-returning\n// contract across all call sites.\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function getCacheDirectoryInternal(options: { isAvoidSystemOnWindows?: boolean; allowEnvVarOverride: boolean }): Promise<string> {\n const { isAvoidSystemOnWindows = true, allowEnvVarOverride } = options\n const env = process.env.ELECTRON_BUILDER_CACHE?.trim()\n if (allowEnvVarOverride && env && path.parse(env).root) {\n return sanitizeDirPath(env)\n }\n\n const appName = \"electron-builder\"\n const platform = os.platform()\n const homeDir = os.homedir()\n\n if (platform === \"darwin\") {\n return path.join(homeDir, \"Library\", \"Caches\", appName)\n }\n if (platform === \"win32\") {\n const localAppData = process.env.LOCALAPPDATA?.trim()\n const username = process.env.USERNAME?.trim()?.toLowerCase()\n // https://github.com/electron-userland/electron-builder/issues/1164\n const isSystemUser = isAvoidSystemOnWindows && (localAppData?.toLowerCase()?.includes(\"\\\\windows\\\\system32\\\\\") || username === \"system\")\n if (!localAppData || isSystemUser) {\n return path.join(os.tmpdir(), `${appName}-cache`)\n }\n return path.join(localAppData, appName, \"Cache\")\n }\n\n const xdgCache = process.env.XDG_CACHE_HOME\n return xdgCache && path.parse(xdgCache).root ? path.join(xdgCache, appName) : path.join(homeDir, \".cache\", appName)\n}\n\nfunction resolveCacheMode(): ElectronDownloadCacheMode {\n const varName = \"ELECTRON_DOWNLOAD_CACHE_MODE\"\n const cacheOverride = process.env[varName]?.trim()\n if (cacheOverride && Number(cacheOverride) in ElectronDownloadCacheMode) {\n const mode = Number(cacheOverride) as ElectronDownloadCacheMode\n log.debug({ mode }, `cache mode overridden via env var ${varName}`)\n return mode\n }\n return ElectronDownloadCacheMode.ReadWrite\n}\n\n/**\n * Returns true when `destPath` is safely contained within `dir` (direct child or deeper).\n * On Windows the filesystem is case-insensitive so the comparison is normalised to lowercase.\n * @internal exported for unit testing\n */\nexport function isSafeExtractPath(destPath: string, dir: string): boolean {\n const normalizedDest = path.resolve(destPath)\n const normalizedDir = path.resolve(dir)\n if (process.platform === \"win32\") {\n const d = normalizedDest.toLowerCase()\n const b = normalizedDir.toLowerCase()\n return d.startsWith(b + path.sep) || d === b\n }\n return normalizedDest.startsWith(normalizedDir + path.sep) || normalizedDest === normalizedDir\n}\n\nasync function extractZipStreaming(file: string, dir: string): Promise<void> {\n // Pass 1: read central directory once to collect Unix modes (one seek to EOF)\n const zipDir = await unzipper.Open.file(file)\n const entryModes = new Map<string, number>()\n for (const entry of zipDir.files) {\n const mode = (entry.externalFileAttributes >> 16) & 0xffff\n if (mode > 0) {\n entryModes.set(entry.path, mode)\n }\n }\n const isSymlink = (mode: number) => (mode & 0o170000) === 0o120000\n\n // Pass 2: stream from byte 0 — no per-entry seeks, no Docker hang.\n // Destroy the read stream in a finally block so the file handle is always released,\n // including when the loop exits early due to a thrown error.\n const readStream = createReadStream(file)\n try {\n const entries = readStream.pipe(unzipper.Parse({ forceStream: true }))\n for await (const entry of entries as AsyncIterable<unzipper.Entry>) {\n const destPath = path.resolve(dir, entry.path)\n if (!isSafeExtractPath(destPath, dir)) {\n throw new Error(`Path traversal blocked: ${entry.path}`)\n }\n const mode = entryModes.get(entry.path) ?? 0\n if (mode > 0 && isSymlink(mode)) {\n const target = (await entry.buffer()).toString()\n if (path.isAbsolute(target)) {\n throw new Error(`Absolute symlink target blocked: ${target}`)\n }\n const resolvedTarget = path.resolve(path.dirname(destPath), target)\n if (!isSafeExtractPath(resolvedTarget, dir)) {\n throw new Error(`Symlink target escapes extraction dir: ${target}`)\n }\n await fs.mkdir(path.dirname(destPath), { recursive: true })\n await fs.symlink(target, destPath)\n } else if (entry.type === \"Directory\") {\n await fs.mkdir(destPath, { recursive: true })\n entry.autodrain()\n } else {\n await fs.mkdir(path.dirname(destPath), { recursive: true })\n await pipeline(entry, createWriteStream(destPath))\n if (mode > 0) {\n await fs.chmod(destPath, mode & 0o7777)\n }\n }\n }\n } finally {\n readStream.destroy()\n }\n}\n\nexport async function extractArchive(archive: string, dir: string) {\n const file = sanitizeDirPath(archive)\n\n const tmpDir = `${dir}.tmp`\n await fs.mkdir(tmpDir, { recursive: true })\n\n const release = await lockfile.lock(tmpDir, {\n // 100 retries (not 15) so concurrent callers wait out a slow first extraction instead of failing\n // with ELOCKED; the update heartbeat keeps an in-progress holder's lock fresh against `stale`.\n retries: { retries: 100, minTimeout: 1000, maxTimeout: 5000 },\n stale: 120000, // Increased from 60s to allow long-running extractions\n })\n\n try {\n // rm + mkdir happen AFTER acquiring the lock so no concurrent caller can clear our tmpDir mid-extraction\n await fs.rm(tmpDir, { recursive: true, force: true })\n await fs.mkdir(tmpDir, { recursive: true })\n\n // Guard against the transient window in @electron/get's non-atomic putFileInCache (remove → move).\n // A concurrent worker may have deleted and not yet replaced the source archive; wait briefly for it.\n for (let i = 0; !(await exists(file)); i++) {\n if (i >= 4) {\n throw Object.assign(new Error(`Source archive not found after retries: ${file}`), { code: \"ENOENT\", path: file })\n }\n log.warn({ file, attempt: i + 1 }, \"source archive transiently missing, retrying\")\n await sleep(300 * (i + 1))\n }\n\n if (file.endsWith(\".tar.gz\") || file.endsWith(\".tgz\")) {\n await tar.extract({ file, cwd: tmpDir, strip: 1 })\n } else if (file.endsWith(\".tar.xz\") || file.endsWith(\".txz\") || file.endsWith(\".tar.7z\")) {\n // Compressed tarballs node-tar cannot decompress itself (xz, 7z): use 7za to strip the outer\n // compression layer into a .tar, then extract that tar.\n // Note: the .tar.7z check MUST stay ahead of the plain .7z branch below, otherwise only the outer\n // 7z layer is removed and the inner tar is left behind as-is (see https://github.com/electron-userland/electron-builder/issues/10002).\n const cmd7za = await getPath7za()\n const decompressOutDir = `${tmpDir}.decompress`\n await fs.rm(decompressOutDir, { recursive: true, force: true })\n await fs.mkdir(decompressOutDir, { recursive: true })\n try {\n await exec(cmd7za, [\"x\", \"-bd\", file, to7zaOutputSwitch(sanitizeDirPath(decompressOutDir)), \"-y\"])\n const innerTar = (await fs.readdir(decompressOutDir)).find(f => f.endsWith(\".tar\"))\n if (innerTar == null) {\n throw new Error(`decompression of ${path.basename(file)} produced no .tar archive`)\n }\n await tar.extract({ file: path.join(decompressOutDir, innerTar), cwd: tmpDir, strip: 1 })\n } finally {\n await fs.rm(decompressOutDir, { recursive: true, force: true })\n }\n } else if (file.endsWith(\".zip\")) {\n await extractZipStreaming(file, tmpDir)\n } else if (file.endsWith(\".7z\")) {\n const cmd7za = await getPath7za()\n try {\n await exec(cmd7za, [\"x\", \"-bd\", file, to7zaOutputSwitch(sanitizeDirPath(tmpDir)), \"-y\"])\n } catch (e: any) {\n // Check if extraction actually failed or just had benign warnings\n const files = await fs.readdir(tmpDir)\n if (files.length === 0) {\n log.warn({ file: log.filePath(file), tmpDir: log.filePath(tmpDir), error: e.message }, \"7z extraction produced no output\")\n throw new Error(`7z extraction failed for ${file}: ${e.message}`)\n }\n // If files were extracted despite the error, log and continue\n log.warn({ error: e.message, filesExtracted: files.length }, \"7z reported error but extracted files\")\n }\n } else {\n throw new Error(`Unsupported archive format: ${path.basename(file)}`)\n }\n\n // Verify extraction produced files\n const extractedFiles = await fs.readdir(tmpDir)\n if (extractedFiles.length === 0) {\n throw new Error(`Extraction of ${path.basename(file)} produced no files`)\n }\n\n await fs.rm(dir, { recursive: true, force: true })\n await moveDirAtomic(tmpDir, dir)\n } finally {\n await release().catch(err => log.warn({ err }, \"failed to release lockfile\"))\n }\n}\n\nlet proxyInitialized = false\nfunction initializeProxyOnce(): void {\n if (!proxyInitialized) {\n reinitializeProxy()\n proxyInitialized = true\n }\n}\n\n/**\n * Forces undici's global proxy dispatcher to re-read the current HTTP(S)_PROXY / NO_PROXY env vars,\n * bypassing the once-guard in initializeProxyOnce(). Exported for integration testing only.\n */\nexport function reinitializeProxy(): void {\n get.initializeProxy()\n}\n\nasync function downloadArtifactToFile(config: ElectronArtifactDetails, label: string): Promise<string> {\n // Serialize concurrent downloads of the same artifact across vitest workers to prevent @electron/get's\n // non-atomic putFileInCache (remove + move) from racing with a concurrent reader.\n const key = {\n p: (config as ElectronPlatformArtifactDetails).platform,\n a: (config as ElectronPlatformArtifactDetails).arch,\n v: config.version,\n n: config.artifactName,\n g: config.isGeneric,\n }\n\n const artifactLockKey = crypto.createHash(\"sha256\").update(JSON.stringify(key)).digest(\"hex\").slice(0, 20)\n const artifactLockPath = path.join(os.tmpdir(), `eb-dl-${artifactLockKey}.lock`)\n // This lock is taken even for cache hits (the cache-hit check lives inside @electron/get), so under\n // heavy concurrency many builds serialize here. 30 retries (~137s of backoff) is too few — waiters\n // were exhausting it and failing with ELOCKED while the holder fetched a large artifact. 100 retries\n // matches the other toolset locks; stale (10min) + proper-lockfile's update heartbeat keep a live\n // downloader's lock fresh so the longer wait never falsely steals an in-progress download.\n const releaseArtifactLock = await lockfile.lock(artifactLockPath, {\n retries: { retries: 100, minTimeout: 500, maxTimeout: 5000 },\n stale: 600_000,\n realpath: false,\n })\n let lastLoggedMilestone = -1\n const state: { bar: ProgressBar | undefined } = { bar: undefined }\n\n // @electron/get v5 downloads via fetch, whose proxy support comes from undici's global dispatcher.\n // initializeProxy() wires that up from HTTP(S)_PROXY/NO_PROXY env vars (replaces the got proxy agent).\n initializeProxyOnce()\n\n const downloadOptions: FetchDownloaderOptions = {\n signal: AbortSignal.timeout(10 * 60 * 1000), // prevent indefinite hang on stalled connections\n ...config.downloadOptions,\n getProgressCallback: info => {\n // @electron/get passes downloadOptions (including this callback) to its internal\n // SHASUMS256.txt validation download. That file is tiny (<1 MB) and fires at 100%\n // immediately, producing a spurious bar even when the artifact itself is cached.\n // Skip progress display for any download whose total size is known and small.\n if (info.total && info.total < 1_000_000) {\n return Promise.resolve()\n }\n if (!state.bar && process.stdout.isTTY) {\n log.info({ label }, \"downloading\")\n state.bar = new MultiProgress().createBar(`${\" \".repeat(PADDING + 2)}[:bar] :percent | ${label}`, { total: 100 })\n }\n const pct = info.percent != null ? Math.floor(info.percent * 100) : 0\n if (state.bar) {\n state.bar.update(pct)\n } else {\n // log every 25% milestone for non-TTY environments (e.g. CI logs) to provide some visibility into download progress without overwhelming logs with too many updates\n const percentCompleted = info.transferred && info.total ? Math.floor((info.transferred / info.total) * 100) : Math.floor(pct / 25) * 25\n if (percentCompleted > lastLoggedMilestone && percentCompleted > 0) {\n lastLoggedMilestone = percentCompleted\n log.info({ label, progress: `${percentCompleted}%` }, percentCompleted !== 100 ? \"downloading\" : \"downloaded\")\n }\n }\n return Promise.resolve()\n },\n }\n\n const configWithProgress = { ...config, downloadOptions }\n try {\n let filePath: string\n try {\n filePath = await retry(() => get.downloadArtifact(configWithProgress), {\n retries: 3,\n interval: 2000,\n backoff: 2000,\n shouldRetry: (e: any) =>\n e instanceof HttpError ? e.isServerError() : typeof e?.code === \"string\" && [\"ENOTFOUND\", \"ETIMEDOUT\", \"ECONNRESET\", \"EPIPE\", \"ENOENT\"].includes(e.code),\n })\n } catch (err) {\n if (typeof (err as any)?.message === \"string\" && (err as any).message.includes(\"dest already exists\")) {\n filePath = await get.downloadArtifact(configWithProgress)\n } else {\n throw err\n }\n }\n if (!(await exists(filePath))) {\n log.warn({ filePath, label }, \"cached artifact missing from disk; retrying with cache write\")\n filePath = await get.downloadArtifact({ ...configWithProgress, cacheMode: ElectronDownloadCacheMode.WriteOnly })\n }\n if (!state.bar && lastLoggedMilestone === -1) {\n log.info({ label }, \"using cached artifact\")\n }\n return filePath\n } finally {\n state.bar?.update(100)\n state.bar?.terminate()\n await releaseArtifactLock().catch(err => log.warn({ err }, \"failed to release artifact download lock\"))\n }\n}\n\n/**\n * Checks electron-builder's own archive cache for a previously downloaded archive.\n * Validates the SHA-256 checksum when one is known. Returns the cached path on hit,\n * null on miss or checksum mismatch (mismatch also deletes the stale file).\n */\nasync function resolveFromArchiveCache(archiveCachePath: string, label: string, expectedSha256: string | undefined): Promise<string | null> {\n if (!(await exists(archiveCachePath))) {\n return null\n }\n if (expectedSha256) {\n const hash = await new Promise<string>((resolve, reject) => {\n const h = crypto.createHash(\"sha256\")\n const s = createReadStream(archiveCachePath)\n s.on(\"error\", reject)\n s.on(\"data\", (chunk: Buffer | string) => h.update(chunk))\n s.on(\"end\", () => resolve(h.digest(\"hex\")))\n })\n if (hash !== expectedSha256) {\n log.warn({ file: label, archiveCachePath }, \"cached archive checksum mismatch — removing and re-downloading\")\n await fs.rm(archiveCachePath).catch(() => {})\n return null\n }\n }\n log.debug({ file: label, archiveCachePath }, \"using cached archive — skipping download\")\n return archiveCachePath\n}\n\n/**\n * Copies a freshly downloaded archive into electron-builder's own archive cache so that\n * future builds (including offline environments) can skip the network request entirely.\n */\nasync function persistToArchiveCache(sourcePath: string, archiveCachePath: string): Promise<void> {\n try {\n await fs.mkdir(path.dirname(archiveCachePath), { recursive: true })\n await fs.copyFile(sourcePath, archiveCachePath)\n } catch (err) {\n log.warn({ err, archiveCachePath }, \"failed to persist archive to cache — will re-download next time\")\n }\n}\n\n/**\n * Core download + extract engine. Handles lockfile, cache-hit short-circuit,\n * progress bar, extraction (.zip or .tar.gz), and completion marker.\n * Both public download functions delegate here after building their respective configs.\n */\nasync function downloadAndExtract(config: ElectronArtifactDetails, extractDir: string, label: string, archiveCachePath?: string): Promise<string> {\n // Create only the PARENT dir (e.g. <cache>/fpm@2.2.1), never extractDir itself, before locking.\n // The parent is stable — cleanup only ever removes extractDir and its .state/.tmp/.lock siblings —\n // so extractDir's whole lifecycle (mkdir, rm, re-mkdir) stays inside the lock. ensureDir absorbs\n // the concurrent-recursive-mkdir ENOENT/EEXIST race while peers populate the cold cache tree.\n await ensureDir(path.dirname(extractDir))\n\n // Pre-lock fast path: read-only short-circuit for a definitively complete and valid cache.\n // Safe unlocked — the cache-state helpers return null/false for a missing or half-written dir,\n // so a racing read only ever falls through to take the lock. Do NOT mutate the dir here.\n const stateData = await readCacheStateFile(extractDir)\n if (stateData?.state === CacheState.complete) {\n const isValid = await validateCacheDirectory(extractDir, stateData.fileCount)\n if (isValid) {\n log.debug({ file: label, path: extractDir }, \"using cached artifact - cache valid\")\n return extractDir\n }\n }\n\n // Be patient: when many targets/builds contend on the same toolset cache concurrently, all but the\n // first wait here while the winner downloads+extracts (a large bundle can take >1min). 15 retries\n // (~67s) is too few and waiters fail with ELOCKED before the winner finishes; 100 matches the\n // patience of withToolsetLock. proper-lockfile's update heartbeat keeps a live holder's lock fresh,\n // so increasing waiter retries never falsely steals an in-progress extraction.\n const release = await lockfile.lock(extractDir, {\n // realpath:false so proper-lockfile creates <extractDir>.lock in the (already-created) parent\n // WITHOUT calling fs.realpath(extractDir) first — which would throw ENOENT now that extractDir\n // is created lazily inside the lock. This filesystem lock serializes peers both across worker\n // processes AND within a single process (a second lock() for the same path retries until the\n // first releases), so no in-process promise cache is needed — and one wouldn't help across the\n // separate test worker processes anyway.\n realpath: false,\n retries: { retries: 100, minTimeout: 1000, maxTimeout: 5000 },\n stale: 120000,\n })\n let downloadedFile: string | null = null\n try {\n // Re-check after acquiring lock: another worker may have completed while we waited.\n const stateDataAfterLock = await readCacheStateFile(extractDir)\n if (stateDataAfterLock?.state === CacheState.complete) {\n const isValid = await validateCacheDirectory(extractDir, stateDataAfterLock.fileCount)\n if (isValid) {\n log.debug({ file: label, path: extractDir }, \"using cached artifact - skipping download/extract\")\n return extractDir\n }\n log.warn({ extractDir }, \"Cache marked complete but files invalid, clearing\")\n } else if (stateDataAfterLock?.state === CacheState.corrupted) {\n log.warn({ extractDir }, \"Corrupted cache detected, cleaning up and re-extracting\")\n }\n\n // Cleanup inside the lock — skip lock files since we currently hold them\n await cleanupCacheDirectory(extractDir, { skipLockFiles: true })\n await ensureDir(extractDir)\n\n // Check electron-builder's own archive cache before touching @electron/get.\n // The cache lives alongside the extract dir: <cacheDir>/<releaseName>/<filename>.\n // This lets repeated builds (or offline environments) skip the download entirely once\n // the archive has been fetched at least once.\n if (archiveCachePath) {\n downloadedFile = await resolveFromArchiveCache(archiveCachePath, label, (config as any).checksums?.[label])\n }\n\n if (!downloadedFile) {\n log.debug({ file: label }, \"downloading\")\n downloadedFile = await downloadArtifactToFile(config, label)\n if (!downloadedFile) {\n throw new Error(`Failed to download artifact: ${label}`)\n }\n // Persist the downloaded archive so future builds (and offline environments) can\n // skip the network request entirely.\n if (archiveCachePath) {\n await persistToArchiveCache(downloadedFile, archiveCachePath)\n }\n }\n\n await writeCacheState(extractDir, CacheState.downloaded)\n\n // Mark extracting so stale-lock detection can recover a crashed mid-extraction process\n await writeCacheState(extractDir, CacheState.extracting)\n\n // Extract while holding the lock to prevent concurrent interference\n await extractArchive(downloadedFile, extractDir)\n\n // Compute metadata with a full recursive walk now that tmpDir has been renamed to extractDir\n const { fileCount, extractedSize } = await computeCacheMetadata(extractDir)\n\n // Write complete state with metadata BEFORE releasing the lock; throwOnError=true so a\n // failed write (disk full, permissions) propagates instead of silently producing a no-op cache\n await writeCacheState(extractDir, CacheState.complete, { fileCount, extractedSize }, true)\n } finally {\n await release().catch(err => log.warn({ err }, \"failed to release lockfile\"))\n }\n return extractDir\n}\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\n/**\n * Copies a remote artifact to a specific output path on disk.\n * Unlike downloadBuilderToolset, this does not extract archives — it copies the raw file.\n * Used for certificate imports where the caller needs the file at a known path.\n */\nexport async function download(url: string, output: string, checksum?: string | null): Promise<void> {\n const filenameWithExt = path.basename(new URL(url).pathname)\n if (checksum == null) {\n log.warn({ url }, \"downloading without an integrity checksum — the download is not verified against a known-good hash\")\n }\n const downloadedFile = await downloadArtifactToFile(\n {\n version: \"9.9.9\",\n artifactName: filenameWithExt,\n cacheRoot: path.resolve(await cacheDirectoryOverrideAllowed.value, \"downloads\"),\n cacheMode: resolveCacheMode(),\n ...(checksum != null ? { checksums: { [filenameWithExt]: checksum } } : { unsafelyDisableChecksums: true }),\n mirrorOptions: { resolveAssetURL: async () => Promise.resolve(url) },\n isGeneric: true,\n },\n filenameWithExt\n )\n await fs.copyFile(downloadedFile, output)\n}\n\nfunction validateBinaryCustomDir(envVarName: string, value: string): string {\n if (value.includes(\"://\") || value.includes(\"..\") || value.startsWith(\"/\")) {\n throw new Error(\n `${envVarName} must be a safe relative path component (e.g. \"v1.0.0-custom\"). ` + `Values containing \"://\", \"..\", or a leading \"/\" are not allowed. Got: \"${value}\"`\n )\n }\n return value\n}\n\nconst CUSTOM_DIR_ENV_VARS = [\n \"NPM_CONFIG_ELECTRON_BUILDER_BINARIES_CUSTOM_DIR\",\n \"npm_config_electron_builder_binaries_custom_dir\",\n \"npm_package_config_electron_builder_binaries_custom_dir\",\n \"ELECTRON_BUILDER_BINARIES_CUSTOM_DIR\",\n] as const\n\n/**\n * Resolves the final download URL for a builder binary, honouring:\n * ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL – fully replaces the URL directory\n * ELECTRON_BUILDER_BINARIES_CUSTOM_DIR (and npm_ variants) – replaces releaseName in the path\n * overrideUrl (caller-supplied) – used as-is when no env var is set\n *\n * Exported for unit testing; not part of the public API.\n * @internal\n */\nexport function resolveBuilderBinaryUrl(releaseName: string, filenameWithExt: string, baseUrl: string, overrideUrl?: string): string {\n const envOverrideUrl = parseValidEnvVarUrl(\"ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL\")\n if (envOverrideUrl != null) {\n return `${envOverrideUrl}/${filenameWithExt}`\n }\n if (overrideUrl != null) {\n return `${overrideUrl}/${filenameWithExt}`\n }\n const customDirEntry = CUSTOM_DIR_ENV_VARS.map(name => ({ name, value: process.env[name] })).find(e => e.value != null)\n if (customDirEntry != null) {\n return `${baseUrl}${validateBinaryCustomDir(customDirEntry.name, customDirEntry.value!)}/${filenameWithExt}`\n }\n return `${baseUrl}${releaseName}/${filenameWithExt}`\n}\n\n/**\n * Downloads a generic artifact (.tar.gz or .zip) from a GitHub release.\n * Used for electron-builder-binaries tools (appimage, etc.).\n */\nexport async function downloadBuilderToolset(options: {\n releaseName: string\n filenameWithExt: string\n checksums?: Record<string, string>\n githubOrgRepo?: string\n overrideUrl?: string\n}): Promise<string> {\n const { releaseName, filenameWithExt, checksums, githubOrgRepo = \"electron-userland/electron-builder-binaries\", overrideUrl } = options\n\n if (/[/\\\\]|^\\.\\./.test(filenameWithExt) || filenameWithExt.includes(\"..\")) {\n throw new Error(`downloadBuilderToolset: unsafe filenameWithExt \"${filenameWithExt}\" — must be a plain filename with no path separators or traversal sequences`)\n }\n\n const baseUrl = getBinariesMirrorUrl(githubOrgRepo)\n const fullUrl = resolveBuilderBinaryUrl(releaseName, filenameWithExt, baseUrl, overrideUrl)\n const suffix = hashUrlSafe(fullUrl, 5)\n // tar.7z is listed before 7z so the full extension is stripped. Deliberate side effect: this changes the\n // extract-dir name for .tar.7z toolsets (e.g. the snap template) from \"<name>.tar-<hash>\" to \"<name>-<hash>\",\n // which busts caches poisoned by the broken .tar.7z extraction in 26.15.0-26.15.6 (issue #10002).\n const folderName = `${filenameWithExt.replace(/\\.(tar\\.gz|tgz|tar\\.xz|txz|tar\\.7z|zip|7z)$/, \"\")}-${suffix}`\n // releaseName is library input; enforce cache-dir containment (rejects traversal, clears taint into shell extraction)\n const cacheDir = await cacheDirectoryOverrideAllowed.value\n const extractDir = sanitizeDirPath(path.join(cacheDir, releaseName, folderName), cacheDir)\n\n // Use resolveAssetURL so @electron/get's ELECTRON_MIRROR env var check cannot override\n // the builder-binaries URL we've already resolved (see getArtifactRemoteURL in @electron/get).\n const mirrorOptions: MirrorOptions = {\n resolveAssetURL: async () => Promise.resolve(fullUrl),\n }\n\n // Predictable archive cache: <cacheDir>/<releaseName>/<filename>, next to the extract dir.\n // downloadAndExtract checks here before touching @electron/get and persists the archive here\n // after every successful download, so subsequent builds never need a network round-trip.\n const archiveCachePath = sanitizeDirPath(path.join(cacheDir, releaseName, filenameWithExt), cacheDir)\n\n const config: ElectronDownloadRequest & ElectronDownloadRequestOptions & { isGeneric: true } = {\n version: \"9.9.9\", // must be >1.3.2 to bypass @electron/get validation shortcut\n artifactName: filenameWithExt,\n cacheRoot: path.resolve(await cacheDirectoryOverrideAllowed.value, \"downloads\"),\n cacheMode: resolveCacheMode(),\n ...(checksums != null ? { checksums } : { unsafelyDisableChecksums: true }),\n mirrorOptions,\n isGeneric: true,\n }\n return downloadAndExtract(config, extractDir, filenameWithExt, archiveCachePath)\n}\n\n/**\n * Downloads and extracts an electron platform artifact (e.g. ffmpeg) using @electron/get.\n * Deduplicates concurrent calls for the same artifact within the same process.\n */\nfunction buildElectronArtifactConfig(artifactOptions: ArtifactDownloadOptions): ElectronPlatformArtifactDetails {\n const { options, arch, version, platformName: platform, artifactName, cacheDir: cacheRoot } = artifactOptions\n\n if (options?.unsafelyDisableChecksums) {\n log.warn(\n { artifactName },\n \"electronGet.unsafelyDisableChecksums is enabled — downloaded artifacts will NOT be verified.txt; a compromised mirror can serve malicious binaries undetected\"\n )\n }\n\n const artifactConfig: ElectronPlatformArtifactDetails = { ...options, cacheRoot, platform, arch, version, artifactName, cacheMode: resolveCacheMode() }\n return artifactConfig\n}\n\n/**\n * Downloads the electron artifact zip via @electron/get (with caching) and returns the zip file path.\n * Use when you need to extract the zip yourself (e.g. directly to appOutDir to preserve empty dirs and symlinks).\n */\nexport function downloadElectronArtifactZip(options: ArtifactDownloadOptions): Promise<string> {\n const config = buildElectronArtifactConfig(options)\n return downloadArtifactToFile(config, config.artifactName)\n}\n\nexport async function downloadElectronArtifact(options: ArtifactDownloadOptions): Promise<string> {\n const { arch, version, platformName: platform, artifactName } = options\n const artifactConfig = buildElectronArtifactConfig(options)\n\n const suffix = hashUrlSafe(JSON.stringify(artifactConfig), 5)\n const folderName = `${artifactName}-v${version}-${platform}-${arch}-${suffix}`\n const extractDir = path.join(await cacheDirectoryOverrideAllowed.value, `${artifactName}-v${version}`, folderName)\n\n return downloadAndExtract(artifactConfig, extractDir, artifactName)\n}\n\n/**\n * Get the binaries mirror URL from environment variables.\n * Supports various npm config formats and falls back to GitHub.\n */\nexport function getBinariesMirrorUrl(githubOrgRepo: string): string {\n const allowHttp = process.env[\"ELECTRON_BUILDER_DANGEROUSLY_ALLOW_HTTP\"] === \"true\"\n for (const envVar of [\n \"NPM_CONFIG_ELECTRON_BUILDER_BINARIES_MIRROR\",\n \"npm_config_electron_builder_binaries_mirror\",\n \"npm_package_config_electron_builder_binaries_mirror\",\n \"ELECTRON_BUILDER_BINARIES_MIRROR\",\n ]) {\n const url = parseValidEnvVarUrl(envVar, allowHttp)\n if (url) {\n return url.endsWith(\"/\") ? url : `${url}/`\n }\n }\n return `https://github.com/${githubOrgRepo}/releases/download/`\n}\n"]}
|