app-builder-lib 26.8.1 → 26.9.0

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.
Files changed (35) hide show
  1. package/out/binDownload.js +14 -6
  2. package/out/binDownload.js.map +1 -1
  3. package/out/configuration.d.ts +3 -2
  4. package/out/configuration.js.map +1 -1
  5. package/out/electron/ElectronFramework.js +31 -16
  6. package/out/electron/ElectronFramework.js.map +1 -1
  7. package/out/node-module-collector/moduleManager.d.ts +1 -0
  8. package/out/node-module-collector/moduleManager.js +2 -0
  9. package/out/node-module-collector/moduleManager.js.map +1 -1
  10. package/out/node-module-collector/nodeModulesCollector.js +14 -6
  11. package/out/node-module-collector/nodeModulesCollector.js.map +1 -1
  12. package/out/node-module-collector/pnpmNodeModulesCollector.js +23 -5
  13. package/out/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
  14. package/out/node-module-collector/types.d.ts +1 -0
  15. package/out/node-module-collector/types.js.map +1 -1
  16. package/out/publish/PublishManager.js +32 -4
  17. package/out/publish/PublishManager.js.map +1 -1
  18. package/out/targets/appimage/AppImageTarget.js +7 -4
  19. package/out/targets/appimage/AppImageTarget.js.map +1 -1
  20. package/out/targets/appimage/appImageUtil.d.ts +2 -1
  21. package/out/targets/appimage/appImageUtil.js +27 -5
  22. package/out/targets/appimage/appImageUtil.js.map +1 -1
  23. package/out/toolsets/linux.d.ts +11 -1
  24. package/out/toolsets/linux.js +23 -5
  25. package/out/toolsets/linux.js.map +1 -1
  26. package/out/util/normalizePackageData.js +1 -1
  27. package/out/util/normalizePackageData.js.map +1 -1
  28. package/out/version.d.ts +1 -1
  29. package/out/version.js +1 -1
  30. package/out/version.js.map +1 -1
  31. package/out/winPackager.js +10 -2
  32. package/out/winPackager.js.map +1 -1
  33. package/package.json +8 -8
  34. package/scheme.json +3 -2
  35. package/templates/nsis/multiUser.nsh +14 -9
@@ -71,7 +71,8 @@ function getCacheDirectory(isAvoidSystemOnWindows = false) {
71
71
  */
72
72
  async function downloadArtifact(options) {
73
73
  const { releaseName, filenameWithExt, checksums, githubOrgRepo = "electron-userland/electron-builder-binaries" } = options;
74
- const file = await _downloadArtifact(`https://github.com/${githubOrgRepo}/releases/download/`, releaseName, filenameWithExt, checksums);
74
+ const baseUrl = getBinariesMirrorUrl(githubOrgRepo);
75
+ const file = await _downloadArtifact(baseUrl, releaseName, filenameWithExt, checksums);
75
76
  return file;
76
77
  }
77
78
  /**
@@ -161,6 +162,17 @@ async function _downloadArtifact(baseUrl, releaseName, filenameWithExt, checksum
161
162
  }
162
163
  }
163
164
  const versionToPromise = new Map();
165
+ /**
166
+ * Get the binaries mirror URL from environment variables.
167
+ * Supports various npm config formats and falls back to GitHub.
168
+ */
169
+ function getBinariesMirrorUrl(githubOrgRepo) {
170
+ return (process.env.NPM_CONFIG_ELECTRON_BUILDER_BINARIES_MIRROR ||
171
+ process.env.npm_config_electron_builder_binaries_mirror ||
172
+ process.env.npm_package_config_electron_builder_binaries_mirror ||
173
+ process.env.ELECTRON_BUILDER_BINARIES_MIRROR ||
174
+ `https://github.com/${githubOrgRepo}/releases/download/`);
175
+ }
164
176
  function download(url, output, checksum) {
165
177
  const args = ["download", "--url", url, "--output", output];
166
178
  if (checksum != null) {
@@ -178,11 +190,7 @@ function getBinFromUrl(releaseName, filenameWithExt, checksum, githubOrgRepo = "
178
190
  url = process.env.ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL + "/" + filenameWithExt;
179
191
  }
180
192
  else {
181
- const baseUrl = process.env.NPM_CONFIG_ELECTRON_BUILDER_BINARIES_MIRROR ||
182
- process.env.npm_config_electron_builder_binaries_mirror ||
183
- process.env.npm_package_config_electron_builder_binaries_mirror ||
184
- process.env.ELECTRON_BUILDER_BINARIES_MIRROR ||
185
- `https://github.com/${githubOrgRepo}/releases/download/`;
193
+ const baseUrl = getBinariesMirrorUrl(githubOrgRepo);
186
194
  const middleUrl = process.env.NPM_CONFIG_ELECTRON_BUILDER_BINARIES_CUSTOM_DIR ||
187
195
  process.env.npm_config_electron_builder_binaries_custom_dir ||
188
196
  process.env.npm_package_config_electron_builder_binaries_custom_dir ||
@@ -1 +1 @@
1
- {"version":3,"file":"binDownload.js","sourceRoot":"","sources":["../src/binDownload.ts"],"names":[],"mappings":";;AAeA,kCAcC;AAKD,8CAgCC;AAKD,4CAMC;AAsGD,4BAMC;AAED,kDAGC;AAED,sCAsBC;AAED,wBAYC;AApOD,qCAAoC;AACpC,uCAAwI;AACxI,+CAAsE;AAEtE,wDAA4D;AAC5D,sEAAkE;AAClE,kCAAiC;AACjC,yBAAwB;AACxB,6BAA4B;AAC5B,4CAA2C;AAC3C,2BAA0B;AAE1B;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAa,EAAE,MAAM,GAAG,CAAC;IACnD,IAAI,IAAI,GAAG,IAAI,CAAA;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA,CAAC,gBAAgB;IACpE,CAAC;IACD,wBAAwB;IACxB,IAAI,MAAM,CAAC,CAAA;IACX,mBAAmB;IACnB,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC7B,gCAAgC;IAChC,IAAI,GAAG,CAAC,MAAM,IAAI,MAAM,EAAE,CAAC;QACzB,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;IAC7B,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,sBAAsB,GAAG,KAAK;;IAC9D,MAAM,GAAG,GAAG,MAAA,OAAO,CAAC,GAA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I,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACzB,CAAC;IACD,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IACjC,CAAC;IACD,OAAO,IAAA,gCAAiB,EAAC,IAAI,CAAC,CAAA;AAChC,CAAC","sourcesContent":["import * as get from \"@electron/get\"\nimport { ElectronDownloadCacheMode, ElectronDownloadRequest, ElectronDownloadRequestOptions, GotDownloaderOptions } from \"@electron/get\"\nimport { executeAppBuilder, exists, log, PADDING } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { sanitizeFileName } from \"builder-util/out/filename\"\nimport { MultiProgress } from \"electron-publish/out/multiProgress\"\nimport * as fs from \"fs/promises\"\nimport * as os from \"os\"\nimport * as path from \"path\"\nimport * as lockfile from \"proper-lockfile\"\nimport * as tar from \"tar\"\n\n/**\n * Deterministic <length>-character URL-safe hash (a–z0–9)\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) // hash * 33 ^ c\n }\n // Force unsigned 32-bit\n hash >>>= 0\n // Base-36 (0–9a–z)\n const out = hash.toString(36)\n // Ensure exactly `length` chars\n if (out.length >= length) {\n return out.slice(0, length)\n }\n return out.padStart(length, \"0\")\n}\n\n/**\n * Get cache directory for electron-builder\n */\nexport function getCacheDirectory(isAvoidSystemOnWindows = false): string {\n const env = process.env.ELECTRON_BUILDER_CACHE?.trim()\n if (env) {\n return env\n }\n\n const appName = \"electron-builder\"\n\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\n if (platform === \"win32\") {\n const localAppData = process.env.LOCALAPPDATA?.trim()\n const username = process.env.USERNAME?.trim()?.toLowerCase()\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 // linux\n const xdgCache = process.env.XDG_CACHE_HOME\n if (xdgCache) {\n return path.join(xdgCache, appName)\n }\n\n return path.join(homeDir, \".cache\", appName)\n}\n\n/**\n * Downloads an artifact from GitHub releases (convenience wrapper)\n */\nexport async function downloadArtifact(options: { releaseName: string; filenameWithExt: string; checksums: Record<string, string>; githubOrgRepo?: string }): Promise<string> {\n const { releaseName, filenameWithExt, checksums, githubOrgRepo = \"electron-userland/electron-builder-binaries\" } = options\n\n const file = await _downloadArtifact(`https://github.com/${githubOrgRepo}/releases/download/`, releaseName, filenameWithExt, checksums)\n\n return file\n}\n\n/**\n * Downloads, validates, and extracts a .tar.gz from a release URL\n */\nasync function _downloadArtifact(baseUrl: string, releaseName: string, filenameWithExt: string, checksums: Record<string, string>): Promise<string> {\n const suffix = hashUrlSafe(`${baseUrl}-${releaseName}-${filenameWithExt}`, 5)\n const folderName = `${filenameWithExt.replace(/\\.(tar\\.gz|tgz)$/, \"\")}-${suffix}`\n const extractDir = path.join(getCacheDirectory(), releaseName, folderName)\n const extractionCompleteMarker = `${extractDir}.complete`\n\n // Ensure download directory exists before trying to lock\n await fs.mkdir(extractDir, { recursive: true })\n\n // Acquire the lock\n let release: (() => Promise<void>) | undefined\n try {\n release = await lockfile.lock(extractDir, {\n retries: {\n retries: 5,\n minTimeout: 1000,\n maxTimeout: 5000,\n },\n stale: 60000,\n })\n\n const varName = \"ELECTRON_DOWNLOAD_CACHE_MODE\"\n const cacheOverride = process.env[varName]?.trim()\n\n let cacheMode: ElectronDownloadCacheMode = ElectronDownloadCacheMode.ReadWrite\n if (cacheOverride && Number(cacheOverride) in ElectronDownloadCacheMode) {\n cacheMode = Number(cacheOverride)\n log.debug({ mode: cacheMode }, `cache mode overridden via env var ${varName}`)\n }\n\n if (await exists(extractionCompleteMarker)) {\n log.debug({ file: filenameWithExt, path: extractDir }, \"using cached artifact - skipping download/extract\")\n return extractDir\n }\n\n // These are just stubs. Actual url construction/file naming are in `mirrorOptions` below.\n const details: ElectronDownloadRequest = {\n // Needs to be higher than 1.3.2 to avoid @electron/get validation shortcut\n // https://github.com/electron/get/blob/05c466d4fc60fa0c83064df28dce245eb83d63c9/src/index.ts#L60\n version: \"9.9.9\",\n artifactName: filenameWithExt, // also is the output filename\n }\n\n const progress = process.stdout.isTTY ? new MultiProgress() : null\n const progressBar = progress?.createBar(`${\" \".repeat(PADDING + 2)}[:bar] :percent | ${filenameWithExt}`, { total: 100 })\n\n const downloadOptions: GotDownloaderOptions = {\n getProgressCallback: info => {\n progressBar?.update(info.percent != null ? Math.floor(info.percent * 100) : 0)\n return Promise.resolve()\n },\n }\n const options: ElectronDownloadRequestOptions = {\n cacheRoot: path.resolve(getCacheDirectory(), \"downloads\"),\n cacheMode,\n downloadOptions,\n checksums,\n mirrorOptions: {\n // `${opts.mirror}${opts.customDir}/${opts.customFilename}`\n mirror: baseUrl,\n customDir: releaseName,\n customFilename: filenameWithExt,\n },\n }\n\n log.info({ release: releaseName, file: filenameWithExt }, \"downloading\")\n progressBar?.render()\n const downloadedFile = await get.downloadArtifact({\n ...details,\n ...options,\n isGeneric: true,\n })\n\n await tar.extract({\n file: downloadedFile,\n cwd: extractDir,\n strip: 1, // Strip the top-level directory from the archive\n })\n\n // Write the extraction complete marker file to indicate successful extraction and prevent future re-extraction\n await fs.writeFile(extractionCompleteMarker, \"\")\n\n log.debug({ file: filenameWithExt, path: extractDir }, \"downloaded\")\n progressBar?.update(100)\n progressBar?.terminate()\n\n return extractDir\n } finally {\n // Release the lock\n if (release) {\n await release()\n }\n }\n}\n\nconst versionToPromise = new Map<string, Promise<string>>()\n\nexport function download(url: string, output: string, checksum?: string | null): Promise<void> {\n const args = [\"download\", \"--url\", url, \"--output\", output]\n if (checksum != null) {\n args.push(\"--sha512\", checksum)\n }\n return executeAppBuilder(args) as Promise<any>\n}\n\nexport function getBinFromCustomLoc(name: string, version: string, binariesLocUrl: string, checksum: string): Promise<string> {\n const dirName = `${name}-${version}`\n return getBin(dirName, binariesLocUrl, checksum)\n}\n\nexport function getBinFromUrl(releaseName: string, filenameWithExt: string, checksum: string, githubOrgRepo = \"electron-userland/electron-builder-binaries\"): Promise<string> {\n let url: string\n if (process.env.ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL) {\n url = process.env.ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL + \"/\" + filenameWithExt\n } else {\n const baseUrl =\n process.env.NPM_CONFIG_ELECTRON_BUILDER_BINARIES_MIRROR ||\n process.env.npm_config_electron_builder_binaries_mirror ||\n process.env.npm_package_config_electron_builder_binaries_mirror ||\n process.env.ELECTRON_BUILDER_BINARIES_MIRROR ||\n `https://github.com/${githubOrgRepo}/releases/download/`\n const middleUrl =\n process.env.NPM_CONFIG_ELECTRON_BUILDER_BINARIES_CUSTOM_DIR ||\n process.env.npm_config_electron_builder_binaries_custom_dir ||\n process.env.npm_package_config_electron_builder_binaries_custom_dir ||\n process.env.ELECTRON_BUILDER_BINARIES_CUSTOM_DIR ||\n releaseName\n url = `${baseUrl}${middleUrl}/${filenameWithExt}`\n }\n\n const cacheKey = `${releaseName}-${path.basename(filenameWithExt, path.extname(filenameWithExt))}`\n return getBin(cacheKey, url, checksum)\n}\n\nexport function getBin(cacheKey: string, url?: string | null, checksum?: string | null): Promise<string> {\n // Old cache is ignored if cache environment variable changes\n const cacheName = sanitizeFileName(`${process.env.ELECTRON_BUILDER_CACHE ?? \"\"}${cacheKey}`)\n let promise = versionToPromise.get(cacheName) // if rejected, we will try to download again\n\n if (promise != null) {\n return promise\n }\n\n promise = doGetBin(cacheKey, url, checksum)\n versionToPromise.set(cacheName, promise)\n return promise\n}\n\nfunction doGetBin(name: string, url: string | Nullish, checksum: string | Nullish): Promise<string> {\n const args = [\"download-artifact\", \"--name\", name]\n if (url != null) {\n args.push(\"--url\", url)\n }\n if (checksum != null) {\n args.push(\"--sha512\", checksum)\n }\n return executeAppBuilder(args)\n}\n"]}
1
+ {"version":3,"file":"binDownload.js","sourceRoot":"","sources":["../src/binDownload.ts"],"names":[],"mappings":";;AAeA,kCAcC;AAKD,8CAgCC;AAKD,4CAOC;AAoHD,4BAMC;AAED,kDAGC;AAED,sCAiBC;AAED,wBAYC;AA9OD,qCAAoC;AACpC,uCAAwI;AACxI,+CAAsE;AAEtE,wDAA4D;AAC5D,sEAAkE;AAClE,kCAAiC;AACjC,yBAAwB;AACxB,6BAA4B;AAC5B,4CAA2C;AAC3C,2BAA0B;AAE1B;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAa,EAAE,MAAM,GAAG,CAAC;IACnD,IAAI,IAAI,GAAG,IAAI,CAAA;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA,CAAC,gBAAgB;IACpE,CAAC;IACD,wBAAwB;IACxB,IAAI,MAAM,CAAC,CAAA;IACX,mBAAmB;IACnB,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC7B,gCAAgC;IAChC,IAAI,GAAG,CAAC,MAAM,IAAI,MAAM,EAAE,CAAC;QACzB,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;IAC7B,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,sBAAsB,GAAG,KAAK;;IAC9D,MAAM,GAAG,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,sBAAs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/E,MAAM,IAAI,GAAG,CAAC,mBAAmB,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;IAClD,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACzB,CAAC;IACD,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IACjC,CAAC;IACD,OAAO,IAAA,gCAAiB,EAAC,IAAI,CAAC,CAAA;AAChC,CAAC","sourcesContent":["import * as get from \"@electron/get\"\nimport { ElectronDownloadCacheMode, ElectronDownloadRequest, ElectronDownloadRequestOptions, GotDownloaderOptions } from \"@electron/get\"\nimport { executeAppBuilder, exists, log, PADDING } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { sanitizeFileName } from \"builder-util/out/filename\"\nimport { MultiProgress } from \"electron-publish/out/multiProgress\"\nimport * as fs from \"fs/promises\"\nimport * as os from \"os\"\nimport * as path from \"path\"\nimport * as lockfile from \"proper-lockfile\"\nimport * as tar from \"tar\"\n\n/**\n * Deterministic <length>-character URL-safe hash (a–z0–9)\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) // hash * 33 ^ c\n }\n // Force unsigned 32-bit\n hash >>>= 0\n // Base-36 (0–9a–z)\n const out = hash.toString(36)\n // Ensure exactly `length` chars\n if (out.length >= length) {\n return out.slice(0, length)\n }\n return out.padStart(length, \"0\")\n}\n\n/**\n * Get cache directory for electron-builder\n */\nexport function getCacheDirectory(isAvoidSystemOnWindows = false): string {\n const env = process.env.ELECTRON_BUILDER_CACHE?.trim()\n if (env) {\n return env\n }\n\n const appName = \"electron-builder\"\n\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\n if (platform === \"win32\") {\n const localAppData = process.env.LOCALAPPDATA?.trim()\n const username = process.env.USERNAME?.trim()?.toLowerCase()\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 // linux\n const xdgCache = process.env.XDG_CACHE_HOME\n if (xdgCache) {\n return path.join(xdgCache, appName)\n }\n\n return path.join(homeDir, \".cache\", appName)\n}\n\n/**\n * Downloads an artifact from GitHub releases (convenience wrapper)\n */\nexport async function downloadArtifact(options: { releaseName: string; filenameWithExt: string; checksums: Record<string, string>; githubOrgRepo?: string }): Promise<string> {\n const { releaseName, filenameWithExt, checksums, githubOrgRepo = \"electron-userland/electron-builder-binaries\" } = options\n\n const baseUrl = getBinariesMirrorUrl(githubOrgRepo)\n const file = await _downloadArtifact(baseUrl, releaseName, filenameWithExt, checksums)\n\n return file\n}\n\n/**\n * Downloads, validates, and extracts a .tar.gz from a release URL\n */\nasync function _downloadArtifact(baseUrl: string, releaseName: string, filenameWithExt: string, checksums: Record<string, string>): Promise<string> {\n const suffix = hashUrlSafe(`${baseUrl}-${releaseName}-${filenameWithExt}`, 5)\n const folderName = `${filenameWithExt.replace(/\\.(tar\\.gz|tgz)$/, \"\")}-${suffix}`\n const extractDir = path.join(getCacheDirectory(), releaseName, folderName)\n const extractionCompleteMarker = `${extractDir}.complete`\n\n // Ensure download directory exists before trying to lock\n await fs.mkdir(extractDir, { recursive: true })\n\n // Acquire the lock\n let release: (() => Promise<void>) | undefined\n try {\n release = await lockfile.lock(extractDir, {\n retries: {\n retries: 5,\n minTimeout: 1000,\n maxTimeout: 5000,\n },\n stale: 60000,\n })\n\n const varName = \"ELECTRON_DOWNLOAD_CACHE_MODE\"\n const cacheOverride = process.env[varName]?.trim()\n\n let cacheMode: ElectronDownloadCacheMode = ElectronDownloadCacheMode.ReadWrite\n if (cacheOverride && Number(cacheOverride) in ElectronDownloadCacheMode) {\n cacheMode = Number(cacheOverride)\n log.debug({ mode: cacheMode }, `cache mode overridden via env var ${varName}`)\n }\n\n if (await exists(extractionCompleteMarker)) {\n log.debug({ file: filenameWithExt, path: extractDir }, \"using cached artifact - skipping download/extract\")\n return extractDir\n }\n\n // These are just stubs. Actual url construction/file naming are in `mirrorOptions` below.\n const details: ElectronDownloadRequest = {\n // Needs to be higher than 1.3.2 to avoid @electron/get validation shortcut\n // https://github.com/electron/get/blob/05c466d4fc60fa0c83064df28dce245eb83d63c9/src/index.ts#L60\n version: \"9.9.9\",\n artifactName: filenameWithExt, // also is the output filename\n }\n\n const progress = process.stdout.isTTY ? new MultiProgress() : null\n const progressBar = progress?.createBar(`${\" \".repeat(PADDING + 2)}[:bar] :percent | ${filenameWithExt}`, { total: 100 })\n\n const downloadOptions: GotDownloaderOptions = {\n getProgressCallback: info => {\n progressBar?.update(info.percent != null ? Math.floor(info.percent * 100) : 0)\n return Promise.resolve()\n },\n }\n const options: ElectronDownloadRequestOptions = {\n cacheRoot: path.resolve(getCacheDirectory(), \"downloads\"),\n cacheMode,\n downloadOptions,\n checksums,\n mirrorOptions: {\n // `${opts.mirror}${opts.customDir}/${opts.customFilename}`\n mirror: baseUrl,\n customDir: releaseName,\n customFilename: filenameWithExt,\n },\n }\n\n log.info({ release: releaseName, file: filenameWithExt }, \"downloading\")\n progressBar?.render()\n const downloadedFile = await get.downloadArtifact({\n ...details,\n ...options,\n isGeneric: true,\n })\n\n await tar.extract({\n file: downloadedFile,\n cwd: extractDir,\n strip: 1, // Strip the top-level directory from the archive\n })\n\n // Write the extraction complete marker file to indicate successful extraction and prevent future re-extraction\n await fs.writeFile(extractionCompleteMarker, \"\")\n\n log.debug({ file: filenameWithExt, path: extractDir }, \"downloaded\")\n progressBar?.update(100)\n progressBar?.terminate()\n\n return extractDir\n } finally {\n // Release the lock\n if (release) {\n await release()\n }\n }\n}\n\nconst versionToPromise = new Map<string, Promise<string>>()\n\n/**\n * Get the binaries mirror URL from environment variables.\n * Supports various npm config formats and falls back to GitHub.\n */\nfunction getBinariesMirrorUrl(githubOrgRepo: string): string {\n return (\n process.env.NPM_CONFIG_ELECTRON_BUILDER_BINARIES_MIRROR ||\n process.env.npm_config_electron_builder_binaries_mirror ||\n process.env.npm_package_config_electron_builder_binaries_mirror ||\n process.env.ELECTRON_BUILDER_BINARIES_MIRROR ||\n `https://github.com/${githubOrgRepo}/releases/download/`\n )\n}\n\nexport function download(url: string, output: string, checksum?: string | null): Promise<void> {\n const args = [\"download\", \"--url\", url, \"--output\", output]\n if (checksum != null) {\n args.push(\"--sha512\", checksum)\n }\n return executeAppBuilder(args) as Promise<any>\n}\n\nexport function getBinFromCustomLoc(name: string, version: string, binariesLocUrl: string, checksum: string): Promise<string> {\n const dirName = `${name}-${version}`\n return getBin(dirName, binariesLocUrl, checksum)\n}\n\nexport function getBinFromUrl(releaseName: string, filenameWithExt: string, checksum: string, githubOrgRepo = \"electron-userland/electron-builder-binaries\"): Promise<string> {\n let url: string\n if (process.env.ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL) {\n url = process.env.ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL + \"/\" + filenameWithExt\n } else {\n const baseUrl = getBinariesMirrorUrl(githubOrgRepo)\n const middleUrl =\n process.env.NPM_CONFIG_ELECTRON_BUILDER_BINARIES_CUSTOM_DIR ||\n process.env.npm_config_electron_builder_binaries_custom_dir ||\n process.env.npm_package_config_electron_builder_binaries_custom_dir ||\n process.env.ELECTRON_BUILDER_BINARIES_CUSTOM_DIR ||\n releaseName\n url = `${baseUrl}${middleUrl}/${filenameWithExt}`\n }\n\n const cacheKey = `${releaseName}-${path.basename(filenameWithExt, path.extname(filenameWithExt))}`\n return getBin(cacheKey, url, checksum)\n}\n\nexport function getBin(cacheKey: string, url?: string | null, checksum?: string | null): Promise<string> {\n // Old cache is ignored if cache environment variable changes\n const cacheName = sanitizeFileName(`${process.env.ELECTRON_BUILDER_CACHE ?? \"\"}${cacheKey}`)\n let promise = versionToPromise.get(cacheName) // if rejected, we will try to download again\n\n if (promise != null) {\n return promise\n }\n\n promise = doGetBin(cacheKey, url, checksum)\n versionToPromise.set(cacheName, promise)\n return promise\n}\n\nfunction doGetBin(name: string, url: string | Nullish, checksum: string | Nullish): Promise<string> {\n const args = [\"download-artifact\", \"--name\", name]\n if (url != null) {\n args.push(\"--url\", url)\n }\n if (checksum != null) {\n args.push(\"--sha512\", checksum)\n }\n return executeAppBuilder(args)\n}\n"]}
@@ -257,12 +257,13 @@ export interface ToolsetConfig {
257
257
  * Located at https://github.com/electron-userland/electron-builder-binaries/releases?q=appimage&expanded=true
258
258
  * 0.0.0 - legacy toolset (appimage)
259
259
  *
260
- * Beta:
260
+ * Betas:
261
261
  * 1.0.2 - Runtime 20251108
262
+ * 1.0.3 - Runtime 20251108 (Resolves GH issue #9598)
262
263
  *
263
264
  * @default "0.0.0"
264
265
  */
265
- readonly appimage?: "0.0.0" | "1.0.2" | null;
266
+ readonly appimage?: "0.0.0" | "1.0.2" | "1.0.3" | null;
266
267
  }
267
268
  export interface Hooks {
268
269
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"","sourcesContent":["import { Arch } from \"builder-util\"\nimport { BeforeBuildContext, Target } from \"./core\"\nimport { ElectronBrandingOptions, ElectronDownloadOptions } from \"./electron/ElectronFramework\"\nimport { PrepareApplicationStageDirectoryOptions } from \"./Framework\"\nimport { AppXOptions } from \"./options/AppXOptions\"\nimport { AppImageOptions, DebOptions, FlatpakOptions, LinuxConfiguration, LinuxTargetSpecificOptions } from \"./options/linuxOptions\"\nimport { DmgOptions, MacConfiguration, MasConfiguration } from \"./options/macOptions\"\nimport { MsiOptions } from \"./options/MsiOptions\"\nimport { MsiWrappedOptions } from \"./options/MsiWrappedOptions\"\nimport { PkgOptions } from \"./options/pkgOptions\"\nimport { PlatformSpecificBuildOptions } from \"./options/PlatformSpecificBuildOptions\"\nimport { SnapOptions } from \"./options/SnapOptions\"\nimport { SquirrelWindowsOptions } from \"./options/SquirrelWindowsOptions\"\nimport { WindowsConfiguration } from \"./options/winOptions\"\nimport { BuildResult } from \"./packager\"\nimport { ArtifactBuildStarted, ArtifactCreated } from \"./packagerApi\"\nimport { PlatformPackager } from \"./platformPackager\"\nimport { NsisOptions, NsisWebOptions, PortableOptions } from \"./targets/nsis/nsisOptions\"\n\n// duplicate appId here because it is important\n/**\n * Configuration Options\n */\nexport interface CommonConfiguration {\n /**\n * The application id. Used as [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070) for MacOS and as\n * [Application User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx) for Windows (NSIS target only, Squirrel.Windows not supported). It is strongly recommended that an explicit ID is set.\n * @default com.electron.${name}\n */\n readonly appId?: string | null\n\n /**\n * As [name](#metadata), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name).\n * If not specified inside of the `build` configuration, `productName` property defined at the top level of `package.json` is used. If not specified at the top level of `package.json`, [name property](https://docs.npmjs.com/files/package.json#name) is used.\n */\n readonly productName?: string | null\n\n /**\n * The human-readable copyright line for the app.\n * @default Copyright © year ${author}\n */\n readonly copyright?: string | null\n\n /**\n * Directories for build resources\n */\n readonly directories?: MetadataDirectories | null\n\n /**\n * Configuration of toolsets utilized by electron-builder\n */\n readonly toolsets?: ToolsetConfig | null\n\n /**\n * Options related to how build macOS targets.\n */\n readonly mac?: MacConfiguration | null\n /**\n * MAS (Mac Application Store) options.\n */\n readonly mas?: MasConfiguration | null\n /**\n * MAS (Mac Application Store) development options (`mas-dev` target).\n */\n readonly masDev?: MasConfiguration | null\n /**\n * macOS DMG options.\n */\n readonly dmg?: DmgOptions | null\n /**\n * macOS PKG options.\n */\n readonly pkg?: PkgOptions | null\n\n /**\n * Options related to how build Windows targets.\n */\n readonly win?: WindowsConfiguration | null\n readonly nsis?: NsisOptions | null\n readonly nsisWeb?: NsisWebOptions | null\n readonly portable?: PortableOptions | null\n readonly appx?: AppXOptions | null\n /** @private */\n readonly msi?: MsiOptions | null\n /** @private */\n readonly msiWrapped?: MsiWrappedOptions | null\n readonly squirrelWindows?: SquirrelWindowsOptions | null\n\n /**\n * Options related to how build Linux targets.\n */\n readonly linux?: LinuxConfiguration | null\n /**\n * Debian package options.\n */\n readonly deb?: DebOptions | null\n /**\n * Snap options.\n */\n readonly snap?: SnapOptions | null\n /**\n * AppImage options.\n */\n readonly appImage?: AppImageOptions | null\n /**\n * Flatpak options.\n */\n readonly flatpak?: FlatpakOptions | null\n readonly pacman?: LinuxTargetSpecificOptions | null\n readonly rpm?: LinuxTargetSpecificOptions | null\n readonly freebsd?: LinuxTargetSpecificOptions | null\n readonly p5p?: LinuxTargetSpecificOptions | null\n readonly apk?: LinuxTargetSpecificOptions | null\n\n /**\n * Whether to build the application native dependencies from source.\n * @default false\n */\n buildDependenciesFromSource?: boolean\n /**\n * Whether to execute `node-gyp rebuild` before starting to package the app.\n *\n * Don't [use](https://github.com/electron-userland/electron-builder/issues/683#issuecomment-241214075) [npm](http://electron.atom.io/docs/tutorial/using-native-node-modules/#using-npm) (neither `.npmrc`) for configuring electron headers. Use `electron-builder node-gyp-rebuild` instead.\n * @default false\n */\n readonly nodeGypRebuild?: boolean\n /**\n * Additional command line arguments to use when installing app native deps.\n */\n readonly npmArgs?: Array<string> | string | null\n /**\n * Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies before starting to package the app.\n * @default true\n */\n readonly npmRebuild?: boolean\n /**\n * Use `legacy` app-builder binary for installing native dependencies, or `@electron/rebuild` in `sequential` or `parallel` compilation modes.\n * @default sequential\n */\n readonly nativeRebuilder?: \"legacy\" | \"sequential\" | \"parallel\" | null\n\n /**\n * The build number. Maps to the `--iteration` flag for builds using FPM on Linux.\n * If not defined, then it will fallback to `BUILD_NUMBER` or `TRAVIS_BUILD_NUMBER` or `APPVEYOR_BUILD_NUMBER` or `CIRCLE_BUILD_NUM` or `BUILD_BUILDNUMBER` or `CI_PIPELINE_IID` env.\n */\n readonly buildNumber?: string | null\n\n /**\n * The build version. Maps to the `CFBundleVersion` on macOS, and `FileVersion` metadata property on Windows. Defaults to the `version`.\n * If `buildVersion` is not defined and `buildNumber` (or one of the `buildNumber` envs) is defined, it will be used as a build version (`version.buildNumber`).\n */\n readonly buildVersion?: string | null\n\n /**\n * Whether to download the alternate FFmpeg library from Electron's release assets and replace the default FFmpeg library prior to signing\n */\n readonly downloadAlternateFFmpeg?: boolean\n\n /**\n * Inject properties to `package.json`.\n */\n readonly extraMetadata?: any\n\n /**\n * Whether to fail if the application is not signed (to prevent unsigned app if code signing configuration is not correct).\n * @default false\n */\n readonly forceCodeSigning?: boolean\n\n /**\n * Whether to include PDB files.\n * @default false\n */\n readonly includePdb?: boolean\n\n /**\n * Whether to remove `scripts` field from `package.json` files.\n *\n * @default true\n */\n readonly removePackageScripts?: boolean\n\n /**\n * Whether to remove `keywords` field from `package.json` files.\n *\n * @default true\n */\n readonly removePackageKeywords?: boolean\n\n /**\n * Options to pass to `@electron/fuses`\n * Ref: https://github.com/electron/fuses\n */\n readonly electronFuses?: FuseOptionsV1 | null\n\n /**\n * [Experimental] Configuration for concurrent builds.\n */\n readonly concurrency?: Concurrency | null\n}\n\nexport interface Configuration extends CommonConfiguration, PlatformSpecificBuildOptions, Hooks {\n /**\n * Whether to use [electron-compile](http://github.com/electron/electron-compile) to compile app. Defaults to `true` if `electron-compile` in the dependencies. And `false` if in the `devDependencies` or doesn't specified.\n */\n readonly electronCompile?: boolean\n\n /**\n * The [electron-download](https://github.com/electron-userland/electron-download#usage) options.\n */\n readonly electronDownload?: ElectronDownloadOptions\n\n /**\n * The branding used by Electron's distributables. This is needed if a fork has modified Electron's BRANDING.json file.\n */\n readonly electronBranding?: ElectronBrandingOptions\n\n /**\n * The version of electron you are packaging for. Defaults to version of `electron`, `electron-prebuilt` or `electron-prebuilt-compile` dependency.\n */\n electronVersion?: string | null\n\n /**\n * The name of a built-in configuration preset (currently, only `react-cra` is supported) or any number of paths to config files (relative to project dir).\n *\n * The latter allows to mixin a config from multiple other configs, as if you `Object.assign` them, but properly combine `files` glob patterns.\n *\n * If `react-scripts` in the app dependencies, `react-cra` will be set automatically. Set to `null` to disable automatic detection.\n */\n extends?: Array<string> | string | null\n\n /**\n * *libui-based frameworks only* The version of NodeJS you are packaging for.\n * You can set it to `current` to set the Node.js version that you use to run.\n */\n readonly nodeVersion?: string | null\n\n /**\n * *libui-based frameworks only* The version of LaunchUI you are packaging for. Applicable for Windows only. Defaults to version suitable for used framework version.\n */\n readonly launchUiVersion?: boolean | string | null\n\n /**\n * The framework name. One of `electron`, `proton`, `libui`. Defaults to `electron`.\n */\n readonly framework?: string | null\n\n /**\n * Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)\n * @default false\n */\n readonly disableSanityCheckAsar?: boolean\n}\n\nexport type Hook<T, V> = (contextOrPath: T) => Promise<V> | V\n\nexport interface PackContext {\n readonly outDir: string\n readonly appOutDir: string\n readonly packager: PlatformPackager<any>\n readonly electronPlatformName: string\n readonly arch: Arch\n readonly targets: Array<Target>\n}\nexport type AfterPackContext = PackContext\nexport type BeforePackContext = PackContext\nexport type AfterExtractContext = PackContext\n\n/**\n * Configuration of toolsets utilized by electron-builder\n */\nexport interface ToolsetConfig {\n /**\n * `win-codesign` version to use for signing Windows artifacts.\n * Located at https://github.com/electron-userland/electron-builder-binaries/releases?q=win-codesign&expanded=true\n *\n * Stable:\n * v0.0.0 (winCodeSign)\n *\n * Beta:\n * Windows Kits 10.0.26100.0\n * v1.0.0, v1.1.0\n *\n * @default \"0.0.0\"\n */\n readonly winCodeSign?: \"0.0.0\" | \"1.0.0\" | \"1.1.0\" | null\n\n /**\n * `appimage` bundle version to use for Appimage packaging and runtime.\n * Located at https://github.com/electron-userland/electron-builder-binaries/releases?q=appimage&expanded=true\n * 0.0.0 - legacy toolset (appimage)\n *\n * Beta:\n * 1.0.2 - Runtime 20251108\n *\n * @default \"0.0.0\"\n */\n readonly appimage?: \"0.0.0\" | \"1.0.2\" | null\n}\n\nexport interface Hooks {\n /**\nThe function (or path to file or module id) to be run before pack.\n\n```typescript\n(context: BeforePackContext): Promise<any> | any\n```\n\n!!! example \"As function\"\n\n ```js\n beforePack: async (context) => {\n // your code\n }\n ```\n\nBecause in a configuration file you cannot use JavaScript, can be specified as a path to file or module id. Function must be exported as default export.\n\n```json\n\"build\": {\n \"beforePack\": \"./myBeforePackHook.js\"\n}\n```\n\nFile `myBeforePackHook.js` in the project root directory:\n\n!!! example \"myBeforePackHook.js\"\n ```js\n exports.default = async function(context) {\n // your custom code\n }\n ```\n */\n readonly beforePack?: Hook<BeforePackContext, void> | string | null\n\n /**\n * The function (or path to file or module id) to be [run after the prebuilt Electron binary has been extracted to the output directory](#afterextract)\n * Same setup as {@link beforePack}\n */\n readonly afterExtract?: Hook<AfterExtractContext, void> | string | null\n\n /**\n * The function (or path to file or module id) to be [run after pack](#afterpack) (but before pack into distributable format and sign).\n * Same setup as {@link beforePack}\n */\n readonly afterPack?: Hook<AfterPackContext, void> | string | null\n\n /**\n * The function (or path to file or module id) to be [run after pack and sign](#aftersign) (but before pack into distributable format).\n * Same setup as {@link beforePack}\n */\n readonly afterSign?: Hook<AfterPackContext, void> | string | null\n\n /**\n * The function (or path to file or module id) to be run on artifact build start.\n * Same setup as {@link beforePack}\n */\n readonly artifactBuildStarted?: Hook<ArtifactBuildStarted, void> | string | null\n /**\n * The function (or path to file or module id) to be run on artifact build completed.\n * Same setup as {@link beforePack}\n */\n readonly artifactBuildCompleted?: Hook<ArtifactCreated, void> | string | null\n /**\n * The function (or path to file or module id) to be run after all artifacts are built.\n\n```typescript\n(buildResult: BuildResult): Promise<Array<string>> | Array<string>\n```\n\nConfiguration in the same way as `afterPack` (see above).\n\n!!! example \"myAfterAllArtifactBuild.js\"\n ```js\n exports.default = function () {\n // you can return additional files to publish\n return [\"/path/to/additional/result/file\"]\n }\n ```\n */\n readonly afterAllArtifactBuild?: Hook<BuildResult, Array<string>> | string | null\n /**\n * The function (or path to file or module id) to be run after MSI project created on disk - not packed into .msi package yet.\n */\n readonly msiProjectCreated?: Hook<string, void> | string | null\n /**\n * The function (or path to file or module id) to be run after Appx manifest created on disk - not packed into .appx package yet.\n */\n readonly appxManifestCreated?: Hook<string, void> | string | null\n /**\n * The function (or path to file or module id) to be [run on each node module](#onnodemodulefile) file. Returning `true`/`false` will determine whether to force include or to use the default copier logic\n */\n readonly onNodeModuleFile?: Hook<string, void | boolean> | string | null\n /**\n * The function (or path to file or module id) to be run before dependencies are installed or rebuilt. Works when `npmRebuild` is set to `true`. Resolving to `false` will skip dependencies install or rebuild.\n *\n * If provided and `node_modules` are missing, it will not invoke production dependencies check.\n */\n readonly beforeBuild?: Hook<BeforeBuildContext, boolean | void> | string | null\n /**\n * The function (or path to file or module id) to be run when staging the electron artifact environment.\n * Returns the path to custom Electron build (e.g. `~/electron/out/R`) or folder of electron zips.\n *\n * Zip files must follow the pattern `electron-v${version}-${platformName}-${arch}.zip`, otherwise it will be assumed to be an unpacked Electron app directory\n */\n readonly electronDist?: Hook<PrepareApplicationStageDirectoryOptions, string> | string | null\n}\n\nexport interface MetadataDirectories {\n /**\n * The path to build resources.\n *\n * Please note — build resources are not packed into the app. If you need to use some files, e.g. as tray icon, please include required files explicitly: `\"files\": [\"**\\/*\", \"build/icon.*\"]`\n * @default build\n */\n readonly buildResources?: string | null\n\n /**\n * The output directory. [File macros](./file-patterns.md#file-macros) are supported.\n * @default dist\n */\n readonly output?: string | null\n\n /**\n * The application directory (containing the application package.json), defaults to `app`, `www` or working directory.\n */\n readonly app?: string | null\n}\n\n/**\n * All options come from [@electron/fuses](https://github.com/electron/fuses)\n * Ref: https://raw.githubusercontent.com/electron/electron/refs/heads/main/docs/tutorial/fuses.md\n */\nexport interface FuseOptionsV1 {\n /**\n *The runAsNode fuse toggles whether the `ELECTRON_RUN_AS_NODE` environment variable is respected or not. Please note that if this fuse is disabled then `process.fork` in the main process will not function as expected as it depends on this environment variable to function. Instead, we recommend that you use [Utility Processes](https://github.com/electron/electron/blob/main/docs/api/utility-process.md), which work for many use cases where you need a standalone Node.js process (like a Sqlite server process or similar scenarios).\n */\n runAsNode?: boolean\n /**\n * The cookieEncryption fuse toggles whether the cookie store on disk is encrypted using OS level cryptography keys. By default the sqlite database that Chromium uses to store cookies stores the values in plaintext. If you wish to ensure your apps cookies are encrypted in the same way Chrome does then you should enable this fuse. Please note it is a one-way transition, if you enable this fuse existing unencrypted cookies will be encrypted-on-write but if you then disable the fuse again your cookie store will effectively be corrupt and useless. Most apps can safely enable this fuse.\n */\n enableCookieEncryption?: boolean\n /**\n * The nodeOptions fuse toggles whether the [`NODE_OPTIONS`](https://nodejs.org/api/cli.html#node_optionsoptions) and [`NODE_EXTRA_CA_CERTS`](https://github.com/nodejs/node/blob/main/doc/api/cli.md#node_extra_ca_certsfile) environment variables are respected. The `NODE_OPTIONS` environment variable can be used to pass all kinds of custom options to the Node.js runtime and isn't typically used by apps in production. Most apps can safely disable this fuse.\n */\n enableNodeOptionsEnvironmentVariable?: boolean\n /**\n * The nodeCliInspect fuse toggles whether the `--inspect`, `--inspect-brk`, etc. flags are respected or not. When disabled it also ensures that `SIGUSR1` signal does not initialize the main process inspector. Most apps can safely disable this fuse.\n */\n enableNodeCliInspectArguments?: boolean\n /**\n * The embeddedAsarIntegrityValidation fuse toggles an experimental feature on macOS that validates the content of the `app.asar` file when it is loaded. This feature is designed to have a minimal performance impact but may marginally slow down file reads from inside the `app.asar` archive.\n * Currently, ASAR integrity checking is supported on:\n *\n * - macOS as of electron>=16.0.0\n * - Windows as of electron>=30.0.0\n *\n * For more information on how to use asar integrity validation please read the [Asar Integrity](https://github.com/electron/electron/blob/main/docs/tutorial/asar-integrity.md) documentation.\n */\n enableEmbeddedAsarIntegrityValidation?: boolean\n /**\n * The onlyLoadAppFromAsar fuse changes the search system that Electron uses to locate your app code. By default Electron will search in the following order `app.asar` -> `app` -> `default_app.asar`. When this fuse is enabled the search order becomes a single entry `app.asar` thus ensuring that when combined with the `embeddedAsarIntegrityValidation` fuse it is impossible to load non-validated code.\n */\n onlyLoadAppFromAsar?: boolean\n /**\n * The loadBrowserProcessSpecificV8Snapshot fuse changes which V8 snapshot file is used for the browser process. By default Electron's processes will all use the same V8 snapshot file. When this fuse is enabled the browser process uses the file called `browser_v8_context_snapshot.bin` for its V8 snapshot. The other processes will use the V8 snapshot file that they normally do.\n */\n loadBrowserProcessSpecificV8Snapshot?: boolean\n /**\n * The grantFileProtocolExtraPrivileges fuse changes whether pages loaded from the `file://` protocol are given privileges beyond what they would receive in a traditional web browser. This behavior was core to Electron apps in original versions of Electron but is no longer required as apps should be [serving local files from custom protocols](https://github.com/electron/electron/blob/main/docs/tutorial/security.md#18-avoid-usage-of-the-file-protocol-and-prefer-usage-of-custom-protocols) now instead. If you aren't serving pages from `file://` you should disable this fuse.\n * The extra privileges granted to the `file://` protocol by this fuse are incompletely documented below:\n *\n * - `file://` protocol pages can use `fetch` to load other assets over `file://`\n * - `file://` protocol pages can use service workers\n * - `file://` protocol pages have universal access granted to child frames also running on `file://` protocols regardless of sandbox settings\n */\n grantFileProtocolExtraPrivileges?: boolean\n /**\n * Resets the app signature, specifically used for macOS.\n * Note: This should be unneeded since electron-builder signs the app directly after flipping the fuses.\n * Ref: https://github.com/electron/fuses?tab=readme-ov-file#apple-silicon\n */\n resetAdHocDarwinSignature?: boolean\n}\n\nexport interface Concurrency {\n /**\n * The maximum number of concurrent jobs to run.\n * @default 1\n */\n jobs: number\n}\n"]}
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"","sourcesContent":["import { Arch } from \"builder-util\"\nimport { BeforeBuildContext, Target } from \"./core\"\nimport { ElectronBrandingOptions, ElectronDownloadOptions } from \"./electron/ElectronFramework\"\nimport { PrepareApplicationStageDirectoryOptions } from \"./Framework\"\nimport { AppXOptions } from \"./options/AppXOptions\"\nimport { AppImageOptions, DebOptions, FlatpakOptions, LinuxConfiguration, LinuxTargetSpecificOptions } from \"./options/linuxOptions\"\nimport { DmgOptions, MacConfiguration, MasConfiguration } from \"./options/macOptions\"\nimport { MsiOptions } from \"./options/MsiOptions\"\nimport { MsiWrappedOptions } from \"./options/MsiWrappedOptions\"\nimport { PkgOptions } from \"./options/pkgOptions\"\nimport { PlatformSpecificBuildOptions } from \"./options/PlatformSpecificBuildOptions\"\nimport { SnapOptions } from \"./options/SnapOptions\"\nimport { SquirrelWindowsOptions } from \"./options/SquirrelWindowsOptions\"\nimport { WindowsConfiguration } from \"./options/winOptions\"\nimport { BuildResult } from \"./packager\"\nimport { ArtifactBuildStarted, ArtifactCreated } from \"./packagerApi\"\nimport { PlatformPackager } from \"./platformPackager\"\nimport { NsisOptions, NsisWebOptions, PortableOptions } from \"./targets/nsis/nsisOptions\"\n\n// duplicate appId here because it is important\n/**\n * Configuration Options\n */\nexport interface CommonConfiguration {\n /**\n * The application id. Used as [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070) for MacOS and as\n * [Application User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx) for Windows (NSIS target only, Squirrel.Windows not supported). It is strongly recommended that an explicit ID is set.\n * @default com.electron.${name}\n */\n readonly appId?: string | null\n\n /**\n * As [name](#metadata), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name).\n * If not specified inside of the `build` configuration, `productName` property defined at the top level of `package.json` is used. If not specified at the top level of `package.json`, [name property](https://docs.npmjs.com/files/package.json#name) is used.\n */\n readonly productName?: string | null\n\n /**\n * The human-readable copyright line for the app.\n * @default Copyright © year ${author}\n */\n readonly copyright?: string | null\n\n /**\n * Directories for build resources\n */\n readonly directories?: MetadataDirectories | null\n\n /**\n * Configuration of toolsets utilized by electron-builder\n */\n readonly toolsets?: ToolsetConfig | null\n\n /**\n * Options related to how build macOS targets.\n */\n readonly mac?: MacConfiguration | null\n /**\n * MAS (Mac Application Store) options.\n */\n readonly mas?: MasConfiguration | null\n /**\n * MAS (Mac Application Store) development options (`mas-dev` target).\n */\n readonly masDev?: MasConfiguration | null\n /**\n * macOS DMG options.\n */\n readonly dmg?: DmgOptions | null\n /**\n * macOS PKG options.\n */\n readonly pkg?: PkgOptions | null\n\n /**\n * Options related to how build Windows targets.\n */\n readonly win?: WindowsConfiguration | null\n readonly nsis?: NsisOptions | null\n readonly nsisWeb?: NsisWebOptions | null\n readonly portable?: PortableOptions | null\n readonly appx?: AppXOptions | null\n /** @private */\n readonly msi?: MsiOptions | null\n /** @private */\n readonly msiWrapped?: MsiWrappedOptions | null\n readonly squirrelWindows?: SquirrelWindowsOptions | null\n\n /**\n * Options related to how build Linux targets.\n */\n readonly linux?: LinuxConfiguration | null\n /**\n * Debian package options.\n */\n readonly deb?: DebOptions | null\n /**\n * Snap options.\n */\n readonly snap?: SnapOptions | null\n /**\n * AppImage options.\n */\n readonly appImage?: AppImageOptions | null\n /**\n * Flatpak options.\n */\n readonly flatpak?: FlatpakOptions | null\n readonly pacman?: LinuxTargetSpecificOptions | null\n readonly rpm?: LinuxTargetSpecificOptions | null\n readonly freebsd?: LinuxTargetSpecificOptions | null\n readonly p5p?: LinuxTargetSpecificOptions | null\n readonly apk?: LinuxTargetSpecificOptions | null\n\n /**\n * Whether to build the application native dependencies from source.\n * @default false\n */\n buildDependenciesFromSource?: boolean\n /**\n * Whether to execute `node-gyp rebuild` before starting to package the app.\n *\n * Don't [use](https://github.com/electron-userland/electron-builder/issues/683#issuecomment-241214075) [npm](http://electron.atom.io/docs/tutorial/using-native-node-modules/#using-npm) (neither `.npmrc`) for configuring electron headers. Use `electron-builder node-gyp-rebuild` instead.\n * @default false\n */\n readonly nodeGypRebuild?: boolean\n /**\n * Additional command line arguments to use when installing app native deps.\n */\n readonly npmArgs?: Array<string> | string | null\n /**\n * Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies before starting to package the app.\n * @default true\n */\n readonly npmRebuild?: boolean\n /**\n * Use `legacy` app-builder binary for installing native dependencies, or `@electron/rebuild` in `sequential` or `parallel` compilation modes.\n * @default sequential\n */\n readonly nativeRebuilder?: \"legacy\" | \"sequential\" | \"parallel\" | null\n\n /**\n * The build number. Maps to the `--iteration` flag for builds using FPM on Linux.\n * If not defined, then it will fallback to `BUILD_NUMBER` or `TRAVIS_BUILD_NUMBER` or `APPVEYOR_BUILD_NUMBER` or `CIRCLE_BUILD_NUM` or `BUILD_BUILDNUMBER` or `CI_PIPELINE_IID` env.\n */\n readonly buildNumber?: string | null\n\n /**\n * The build version. Maps to the `CFBundleVersion` on macOS, and `FileVersion` metadata property on Windows. Defaults to the `version`.\n * If `buildVersion` is not defined and `buildNumber` (or one of the `buildNumber` envs) is defined, it will be used as a build version (`version.buildNumber`).\n */\n readonly buildVersion?: string | null\n\n /**\n * Whether to download the alternate FFmpeg library from Electron's release assets and replace the default FFmpeg library prior to signing\n */\n readonly downloadAlternateFFmpeg?: boolean\n\n /**\n * Inject properties to `package.json`.\n */\n readonly extraMetadata?: any\n\n /**\n * Whether to fail if the application is not signed (to prevent unsigned app if code signing configuration is not correct).\n * @default false\n */\n readonly forceCodeSigning?: boolean\n\n /**\n * Whether to include PDB files.\n * @default false\n */\n readonly includePdb?: boolean\n\n /**\n * Whether to remove `scripts` field from `package.json` files.\n *\n * @default true\n */\n readonly removePackageScripts?: boolean\n\n /**\n * Whether to remove `keywords` field from `package.json` files.\n *\n * @default true\n */\n readonly removePackageKeywords?: boolean\n\n /**\n * Options to pass to `@electron/fuses`\n * Ref: https://github.com/electron/fuses\n */\n readonly electronFuses?: FuseOptionsV1 | null\n\n /**\n * [Experimental] Configuration for concurrent builds.\n */\n readonly concurrency?: Concurrency | null\n}\n\nexport interface Configuration extends CommonConfiguration, PlatformSpecificBuildOptions, Hooks {\n /**\n * Whether to use [electron-compile](http://github.com/electron/electron-compile) to compile app. Defaults to `true` if `electron-compile` in the dependencies. And `false` if in the `devDependencies` or doesn't specified.\n */\n readonly electronCompile?: boolean\n\n /**\n * The [electron-download](https://github.com/electron-userland/electron-download#usage) options.\n */\n readonly electronDownload?: ElectronDownloadOptions\n\n /**\n * The branding used by Electron's distributables. This is needed if a fork has modified Electron's BRANDING.json file.\n */\n readonly electronBranding?: ElectronBrandingOptions\n\n /**\n * The version of electron you are packaging for. Defaults to version of `electron`, `electron-prebuilt` or `electron-prebuilt-compile` dependency.\n */\n electronVersion?: string | null\n\n /**\n * The name of a built-in configuration preset (currently, only `react-cra` is supported) or any number of paths to config files (relative to project dir).\n *\n * The latter allows to mixin a config from multiple other configs, as if you `Object.assign` them, but properly combine `files` glob patterns.\n *\n * If `react-scripts` in the app dependencies, `react-cra` will be set automatically. Set to `null` to disable automatic detection.\n */\n extends?: Array<string> | string | null\n\n /**\n * *libui-based frameworks only* The version of NodeJS you are packaging for.\n * You can set it to `current` to set the Node.js version that you use to run.\n */\n readonly nodeVersion?: string | null\n\n /**\n * *libui-based frameworks only* The version of LaunchUI you are packaging for. Applicable for Windows only. Defaults to version suitable for used framework version.\n */\n readonly launchUiVersion?: boolean | string | null\n\n /**\n * The framework name. One of `electron`, `proton`, `libui`. Defaults to `electron`.\n */\n readonly framework?: string | null\n\n /**\n * Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)\n * @default false\n */\n readonly disableSanityCheckAsar?: boolean\n}\n\nexport type Hook<T, V> = (contextOrPath: T) => Promise<V> | V\n\nexport interface PackContext {\n readonly outDir: string\n readonly appOutDir: string\n readonly packager: PlatformPackager<any>\n readonly electronPlatformName: string\n readonly arch: Arch\n readonly targets: Array<Target>\n}\nexport type AfterPackContext = PackContext\nexport type BeforePackContext = PackContext\nexport type AfterExtractContext = PackContext\n\n/**\n * Configuration of toolsets utilized by electron-builder\n */\nexport interface ToolsetConfig {\n /**\n * `win-codesign` version to use for signing Windows artifacts.\n * Located at https://github.com/electron-userland/electron-builder-binaries/releases?q=win-codesign&expanded=true\n *\n * Stable:\n * v0.0.0 (winCodeSign)\n *\n * Beta:\n * Windows Kits 10.0.26100.0\n * v1.0.0, v1.1.0\n *\n * @default \"0.0.0\"\n */\n readonly winCodeSign?: \"0.0.0\" | \"1.0.0\" | \"1.1.0\" | null\n\n /**\n * `appimage` bundle version to use for Appimage packaging and runtime.\n * Located at https://github.com/electron-userland/electron-builder-binaries/releases?q=appimage&expanded=true\n * 0.0.0 - legacy toolset (appimage)\n *\n * Betas:\n * 1.0.2 - Runtime 20251108\n * 1.0.3 - Runtime 20251108 (Resolves GH issue #9598)\n *\n * @default \"0.0.0\"\n */\n readonly appimage?: \"0.0.0\" | \"1.0.2\" | \"1.0.3\" | null\n}\n\nexport interface Hooks {\n /**\nThe function (or path to file or module id) to be run before pack.\n\n```typescript\n(context: BeforePackContext): Promise<any> | any\n```\n\n!!! example \"As function\"\n\n ```js\n beforePack: async (context) => {\n // your code\n }\n ```\n\nBecause in a configuration file you cannot use JavaScript, can be specified as a path to file or module id. Function must be exported as default export.\n\n```json\n\"build\": {\n \"beforePack\": \"./myBeforePackHook.js\"\n}\n```\n\nFile `myBeforePackHook.js` in the project root directory:\n\n!!! example \"myBeforePackHook.js\"\n ```js\n exports.default = async function(context) {\n // your custom code\n }\n ```\n */\n readonly beforePack?: Hook<BeforePackContext, void> | string | null\n\n /**\n * The function (or path to file or module id) to be [run after the prebuilt Electron binary has been extracted to the output directory](#afterextract)\n * Same setup as {@link beforePack}\n */\n readonly afterExtract?: Hook<AfterExtractContext, void> | string | null\n\n /**\n * The function (or path to file or module id) to be [run after pack](#afterpack) (but before pack into distributable format and sign).\n * Same setup as {@link beforePack}\n */\n readonly afterPack?: Hook<AfterPackContext, void> | string | null\n\n /**\n * The function (or path to file or module id) to be [run after pack and sign](#aftersign) (but before pack into distributable format).\n * Same setup as {@link beforePack}\n */\n readonly afterSign?: Hook<AfterPackContext, void> | string | null\n\n /**\n * The function (or path to file or module id) to be run on artifact build start.\n * Same setup as {@link beforePack}\n */\n readonly artifactBuildStarted?: Hook<ArtifactBuildStarted, void> | string | null\n /**\n * The function (or path to file or module id) to be run on artifact build completed.\n * Same setup as {@link beforePack}\n */\n readonly artifactBuildCompleted?: Hook<ArtifactCreated, void> | string | null\n /**\n * The function (or path to file or module id) to be run after all artifacts are built.\n\n```typescript\n(buildResult: BuildResult): Promise<Array<string>> | Array<string>\n```\n\nConfiguration in the same way as `afterPack` (see above).\n\n!!! example \"myAfterAllArtifactBuild.js\"\n ```js\n exports.default = function () {\n // you can return additional files to publish\n return [\"/path/to/additional/result/file\"]\n }\n ```\n */\n readonly afterAllArtifactBuild?: Hook<BuildResult, Array<string>> | string | null\n /**\n * The function (or path to file or module id) to be run after MSI project created on disk - not packed into .msi package yet.\n */\n readonly msiProjectCreated?: Hook<string, void> | string | null\n /**\n * The function (or path to file or module id) to be run after Appx manifest created on disk - not packed into .appx package yet.\n */\n readonly appxManifestCreated?: Hook<string, void> | string | null\n /**\n * The function (or path to file or module id) to be [run on each node module](#onnodemodulefile) file. Returning `true`/`false` will determine whether to force include or to use the default copier logic\n */\n readonly onNodeModuleFile?: Hook<string, void | boolean> | string | null\n /**\n * The function (or path to file or module id) to be run before dependencies are installed or rebuilt. Works when `npmRebuild` is set to `true`. Resolving to `false` will skip dependencies install or rebuild.\n *\n * If provided and `node_modules` are missing, it will not invoke production dependencies check.\n */\n readonly beforeBuild?: Hook<BeforeBuildContext, boolean | void> | string | null\n /**\n * The function (or path to file or module id) to be run when staging the electron artifact environment.\n * Returns the path to custom Electron build (e.g. `~/electron/out/R`) or folder of electron zips.\n *\n * Zip files must follow the pattern `electron-v${version}-${platformName}-${arch}.zip`, otherwise it will be assumed to be an unpacked Electron app directory\n */\n readonly electronDist?: Hook<PrepareApplicationStageDirectoryOptions, string> | string | null\n}\n\nexport interface MetadataDirectories {\n /**\n * The path to build resources.\n *\n * Please note — build resources are not packed into the app. If you need to use some files, e.g. as tray icon, please include required files explicitly: `\"files\": [\"**\\/*\", \"build/icon.*\"]`\n * @default build\n */\n readonly buildResources?: string | null\n\n /**\n * The output directory. [File macros](./file-patterns.md#file-macros) are supported.\n * @default dist\n */\n readonly output?: string | null\n\n /**\n * The application directory (containing the application package.json), defaults to `app`, `www` or working directory.\n */\n readonly app?: string | null\n}\n\n/**\n * All options come from [@electron/fuses](https://github.com/electron/fuses)\n * Ref: https://raw.githubusercontent.com/electron/electron/refs/heads/main/docs/tutorial/fuses.md\n */\nexport interface FuseOptionsV1 {\n /**\n *The runAsNode fuse toggles whether the `ELECTRON_RUN_AS_NODE` environment variable is respected or not. Please note that if this fuse is disabled then `process.fork` in the main process will not function as expected as it depends on this environment variable to function. Instead, we recommend that you use [Utility Processes](https://github.com/electron/electron/blob/main/docs/api/utility-process.md), which work for many use cases where you need a standalone Node.js process (like a Sqlite server process or similar scenarios).\n */\n runAsNode?: boolean\n /**\n * The cookieEncryption fuse toggles whether the cookie store on disk is encrypted using OS level cryptography keys. By default the sqlite database that Chromium uses to store cookies stores the values in plaintext. If you wish to ensure your apps cookies are encrypted in the same way Chrome does then you should enable this fuse. Please note it is a one-way transition, if you enable this fuse existing unencrypted cookies will be encrypted-on-write but if you then disable the fuse again your cookie store will effectively be corrupt and useless. Most apps can safely enable this fuse.\n */\n enableCookieEncryption?: boolean\n /**\n * The nodeOptions fuse toggles whether the [`NODE_OPTIONS`](https://nodejs.org/api/cli.html#node_optionsoptions) and [`NODE_EXTRA_CA_CERTS`](https://github.com/nodejs/node/blob/main/doc/api/cli.md#node_extra_ca_certsfile) environment variables are respected. The `NODE_OPTIONS` environment variable can be used to pass all kinds of custom options to the Node.js runtime and isn't typically used by apps in production. Most apps can safely disable this fuse.\n */\n enableNodeOptionsEnvironmentVariable?: boolean\n /**\n * The nodeCliInspect fuse toggles whether the `--inspect`, `--inspect-brk`, etc. flags are respected or not. When disabled it also ensures that `SIGUSR1` signal does not initialize the main process inspector. Most apps can safely disable this fuse.\n */\n enableNodeCliInspectArguments?: boolean\n /**\n * The embeddedAsarIntegrityValidation fuse toggles an experimental feature on macOS that validates the content of the `app.asar` file when it is loaded. This feature is designed to have a minimal performance impact but may marginally slow down file reads from inside the `app.asar` archive.\n * Currently, ASAR integrity checking is supported on:\n *\n * - macOS as of electron>=16.0.0\n * - Windows as of electron>=30.0.0\n *\n * For more information on how to use asar integrity validation please read the [Asar Integrity](https://github.com/electron/electron/blob/main/docs/tutorial/asar-integrity.md) documentation.\n */\n enableEmbeddedAsarIntegrityValidation?: boolean\n /**\n * The onlyLoadAppFromAsar fuse changes the search system that Electron uses to locate your app code. By default Electron will search in the following order `app.asar` -> `app` -> `default_app.asar`. When this fuse is enabled the search order becomes a single entry `app.asar` thus ensuring that when combined with the `embeddedAsarIntegrityValidation` fuse it is impossible to load non-validated code.\n */\n onlyLoadAppFromAsar?: boolean\n /**\n * The loadBrowserProcessSpecificV8Snapshot fuse changes which V8 snapshot file is used for the browser process. By default Electron's processes will all use the same V8 snapshot file. When this fuse is enabled the browser process uses the file called `browser_v8_context_snapshot.bin` for its V8 snapshot. The other processes will use the V8 snapshot file that they normally do.\n */\n loadBrowserProcessSpecificV8Snapshot?: boolean\n /**\n * The grantFileProtocolExtraPrivileges fuse changes whether pages loaded from the `file://` protocol are given privileges beyond what they would receive in a traditional web browser. This behavior was core to Electron apps in original versions of Electron but is no longer required as apps should be [serving local files from custom protocols](https://github.com/electron/electron/blob/main/docs/tutorial/security.md#18-avoid-usage-of-the-file-protocol-and-prefer-usage-of-custom-protocols) now instead. If you aren't serving pages from `file://` you should disable this fuse.\n * The extra privileges granted to the `file://` protocol by this fuse are incompletely documented below:\n *\n * - `file://` protocol pages can use `fetch` to load other assets over `file://`\n * - `file://` protocol pages can use service workers\n * - `file://` protocol pages have universal access granted to child frames also running on `file://` protocols regardless of sandbox settings\n */\n grantFileProtocolExtraPrivileges?: boolean\n /**\n * Resets the app signature, specifically used for macOS.\n * Note: This should be unneeded since electron-builder signs the app directly after flipping the fuses.\n * Ref: https://github.com/electron/fuses?tab=readme-ov-file#apple-silicon\n */\n resetAdHocDarwinSignature?: boolean\n}\n\nexport interface Concurrency {\n /**\n * The maximum number of concurrent jobs to run.\n * @default 1\n */\n jobs: number\n}\n"]}
@@ -49,33 +49,48 @@ async function beforeCopyExtraFiles(options) {
49
49
  await removeUnusedLanguagesIfNeeded(options);
50
50
  }
51
51
  async function removeUnusedLanguagesIfNeeded(options) {
52
- const { packager: { config, platformSpecificBuildOptions }, } = options;
53
- const wantedLanguages = (0, builder_util_1.asArray)(platformSpecificBuildOptions.electronLanguages || config.electronLanguages);
52
+ const { packager, appOutDir } = options;
53
+ const { config, platformSpecificBuildOptions, platform } = packager;
54
+ const getLocalesConfig = () => {
55
+ if (platform === index_1.Platform.MAC) {
56
+ return { dirs: [packager.getResourcesDir(appOutDir), packager.getMacOsElectronFrameworkResourcesDir(appOutDir)], langFileExt: ".lproj" };
57
+ }
58
+ return { dirs: [path.join(packager.getResourcesDir(appOutDir), "..", "locales")], langFileExt: ".pak" };
59
+ };
60
+ const wantedLanguages = (0, builder_util_1.asArray)(platformSpecificBuildOptions.electronLanguages || config.electronLanguages)
61
+ .map(it => it.trim().toLowerCase())
62
+ .filter(it => it.length > 0);
54
63
  if (!wantedLanguages.length) {
55
64
  return;
56
65
  }
57
- const { dirs, langFileExt } = getLocalesConfig(options);
66
+ const { dirs, langFileExt } = getLocalesConfig();
58
67
  // noinspection SpellCheckingInspection
59
- const deletedFiles = async (dir) => {
60
- await (0, tiny_async_pool_1.default)(builder_util_1.MAX_FILE_REQUESTS, await (0, fs_extra_1.readdir)(dir), async (file) => {
68
+ const deleteNonMatchedLanguages = async (dir) => {
69
+ const files = await (0, fs_extra_1.readdir)(dir);
70
+ return files.map(async (file) => {
61
71
  if (path.extname(file) !== langFileExt) {
62
72
  return;
63
73
  }
64
- const language = path.basename(file, langFileExt);
65
- if (!wantedLanguages.includes(language)) {
66
- return (0, fs_extra_1.rm)(path.join(dir, file), { recursive: true, force: true });
74
+ const language = path.basename(file, langFileExt).toLowerCase();
75
+ const isWantedLocale = wantedLanguages.some(wantedLanguage =>
76
+ // exact file
77
+ wantedLanguage === language ||
78
+ // prefix (e.g. "en" matches "en-US")
79
+ wantedLanguage.startsWith(`${language}-`) ||
80
+ // prefix (e.g. "en" matches "en_US")
81
+ wantedLanguage.startsWith(`${language}_`));
82
+ if (isWantedLocale) {
83
+ return undefined;
67
84
  }
68
- return;
85
+ return (0, fs_extra_1.rm)(path.join(dir, file), { recursive: true, force: true });
69
86
  });
70
87
  };
71
- await Promise.all(dirs.map(deletedFiles));
72
- function getLocalesConfig(options) {
73
- const { appOutDir, packager } = options;
74
- if (packager.platform === index_1.Platform.MAC) {
75
- return { dirs: [packager.getResourcesDir(appOutDir), packager.getMacOsElectronFrameworkResourcesDir(appOutDir)], langFileExt: ".lproj" };
76
- }
77
- return { dirs: [path.join(packager.getResourcesDir(appOutDir), "..", "locales")], langFileExt: ".pak" };
88
+ const allDeletedFiles = (await Promise.all(dirs.map(deleteNonMatchedLanguages))).flat().filter((it) => it != null);
89
+ if (allDeletedFiles.length === 0) {
90
+ builder_util_1.log.warn({ electronLanguages: wantedLanguages }, "no locales found matching wanted languages, skipping cleanup");
91
+ return;
78
92
  }
93
+ await (0, tiny_async_pool_1.default)(builder_util_1.MAX_FILE_REQUESTS, allDeletedFiles, it => it);
79
94
  }
80
95
  class ElectronFramework {
81
96
  constructor(name, version, distMacOsAppName) {
@@ -1 +1 @@
1
- {"version":3,"file":"ElectronFramework.js","sourceRoot":"","sources":["../../src/electron/ElectronFramework.ts"],"names":[],"mappings":";;AA2BA,gDAKC;AAmID,wEAiBC;AApLD,+CAA8J;AAC9J,uCAAwD;AACxD,6BAA4B;AAC5B,q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YAAY;YACd,CAAC,CAAC;KACP,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { asArray, copyDir, DO_NOT_USE_HARD_LINKS, executeAppBuilder, isEmptyOrSpaces, log, MAX_FILE_REQUESTS, statOrNull, unlinkIfExists } from \"builder-util\"\nimport { emptyDir, readdir, rename, rm } from \"fs-extra\"\nimport * as path from \"path\"\nimport asyncPool from \"tiny-async-pool\"\nimport { Configuration } from \"../configuration\"\nimport { BeforeCopyExtraFilesOptions, Framework, PrepareApplicationStageDirectoryOptions } from \"../Framework\"\nimport { Packager, Platform } from \"../index\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { MacPackager } from \"../macPackager\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { resolveFunction } from \"../util/resolve\"\nimport { createMacApp } from \"./electronMac\"\nimport { computeElectronVersion, getElectronVersionFromInstalled } from \"./electronVersion\"\nimport { addWinAsarIntegrity } from \"./electronWin\"\nimport injectFFMPEG from \"./injectFFMPEG\"\n\nexport type ElectronPlatformName = \"darwin\" | \"linux\" | \"win32\" | \"mas\"\n\n/**\n * Electron distributables branding options.\n * @see [Electron BRANDING.json](https://github.com/electron/electron/blob/master/shell/app/BRANDING.json).\n */\nexport interface ElectronBrandingOptions {\n projectName?: string\n productName?: string\n}\n\nexport function createBrandingOpts(opts: Configuration): Required<ElectronBrandingOptions> {\n return {\n projectName: opts.electronBranding?.projectName || \"electron\",\n productName: opts.electronBranding?.productName || \"Electron\",\n }\n}\n\nexport interface ElectronDownloadOptions {\n // https://github.com/electron-userland/electron-builder/issues/3077\n // must be optional\n version?: string\n\n /**\n * The [cache location](https://github.com/electron-userland/electron-download#cache-location).\n */\n cache?: string | null\n\n /**\n * The mirror.\n */\n mirror?: string | null\n\n /** @private */\n customDir?: string | null\n /** @private */\n customFilename?: string | null\n\n strictSSL?: boolean\n isVerifyChecksum?: boolean\n\n platform?: ElectronPlatformName\n arch?: string\n}\n\nfunction createDownloadOpts(opts: Configuration, platform: ElectronPlatformName, arch: string, electronVersion: string): ElectronDownloadOptions {\n return {\n platform,\n arch,\n version: electronVersion,\n ...opts.electronDownload,\n }\n}\n\nasync function beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n const { appOutDir, packager } = options\n const electronBranding = createBrandingOpts(packager.config)\n if (packager.platform === Platform.LINUX) {\n const linuxPackager = packager as LinuxPackager\n const executable = path.join(appOutDir, linuxPackager.executableName)\n await rename(path.join(appOutDir, electronBranding.projectName), executable)\n } else if (packager.platform === Platform.WINDOWS) {\n const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`)\n await rename(path.join(appOutDir, `${electronBranding.projectName}.exe`), executable)\n if (options.asarIntegrity) {\n await addWinAsarIntegrity(executable, options.asarIntegrity)\n }\n } else {\n await createMacApp(packager as MacPackager, appOutDir, options.asarIntegrity, (options.platformName as ElectronPlatformName) === \"mas\")\n }\n await removeUnusedLanguagesIfNeeded(options)\n}\n\nasync function removeUnusedLanguagesIfNeeded(options: BeforeCopyExtraFilesOptions) {\n const {\n packager: { config, platformSpecificBuildOptions },\n } = options\n const wantedLanguages = asArray(platformSpecificBuildOptions.electronLanguages || config.electronLanguages)\n if (!wantedLanguages.length) {\n return\n }\n\n const { dirs, langFileExt } = getLocalesConfig(options)\n // noinspection SpellCheckingInspection\n const deletedFiles = async (dir: string) => {\n await asyncPool(MAX_FILE_REQUESTS, await readdir(dir), async file => {\n if (path.extname(file) !== langFileExt) {\n return\n }\n\n const language = path.basename(file, langFileExt)\n if (!wantedLanguages.includes(language)) {\n return rm(path.join(dir, file), { recursive: true, force: true })\n }\n return\n })\n }\n await Promise.all(dirs.map(deletedFiles))\n\n function getLocalesConfig(options: BeforeCopyExtraFilesOptions) {\n const { appOutDir, packager } = options\n if (packager.platform === Platform.MAC) {\n return { dirs: [packager.getResourcesDir(appOutDir), packager.getMacOsElectronFrameworkResourcesDir(appOutDir)], langFileExt: \".lproj\" }\n }\n return { dirs: [path.join(packager.getResourcesDir(appOutDir), \"..\", \"locales\")], langFileExt: \".pak\" }\n }\n}\n\nclass ElectronFramework implements Framework {\n // noinspection JSUnusedGlobalSymbols\n readonly macOsDefaultTargets = [\"zip\", \"dmg\"]\n // noinspection JSUnusedGlobalSymbols\n readonly defaultAppIdPrefix = \"com.electron.\"\n // noinspection JSUnusedGlobalSymbols\n readonly isCopyElevateHelper = true\n // noinspection JSUnusedGlobalSymbols\n readonly isNpmRebuildRequired = true\n\n constructor(\n readonly name: string,\n readonly version: string,\n readonly distMacOsAppName: string\n ) {}\n\n getDefaultIcon(platform: Platform) {\n if (platform === Platform.LINUX) {\n return path.join(getTemplatePath(\"icons\"), \"electron-linux\")\n } else {\n // default icon is embedded into app skeleton\n return null\n }\n }\n\n async prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions) {\n const downloadOptions = createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version)\n const shouldCleanup = await unpack(options, downloadOptions, this.distMacOsAppName)\n await cleanupAfterUnpack(options, this.distMacOsAppName, shouldCleanup)\n if (options.packager.config.downloadAlternateFFmpeg) {\n await injectFFMPEG(options, this.version)\n }\n }\n\n beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n return beforeCopyExtraFiles(options)\n }\n}\n\nexport async function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise<Framework> {\n let version = configuration.electronVersion\n if (version == null) {\n // for prepacked app asar no dev deps in the app.asar\n if (packager.isPrepackedAppAsar) {\n version = await getElectronVersionFromInstalled(packager.projectDir)\n if (version == null) {\n throw new Error(`Cannot compute electron version for prepacked asar`)\n }\n } else {\n version = await computeElectronVersion(packager.projectDir)\n }\n configuration.electronVersion = version\n }\n\n const branding = createBrandingOpts(configuration)\n return new ElectronFramework(branding.projectName, version, `${branding.productName}.app`)\n}\n\n/**\n * Unpacks a custom or default Electron distribution into the app output directory.\n */\nasync function unpack(prepareOptions: PrepareApplicationStageDirectoryOptions, downloadOptions: ElectronDownloadOptions, distMacOsAppName: string): Promise<boolean> {\n const downloadUsingAdjustedConfig = (options: ElectronDownloadOptions) => {\n return executeAppBuilder([\"unpack-electron\", \"--configuration\", JSON.stringify([options]), \"--output\", appOutDir, \"--distMacOsAppName\", distMacOsAppName])\n }\n\n const copyUnpackedElectronDistribution = async (folderPath: string) => {\n log.info({ electronDist: log.filePath(folderPath) }, \"using custom unpacked Electron distribution\")\n const source = packager.getElectronSrcDir(folderPath)\n const destination = packager.getElectronDestinationDir(appOutDir)\n log.info({ source, destination }, \"copying unpacked Electron\")\n await emptyDir(appOutDir)\n await copyDir(source, destination, {\n isUseHardLink: DO_NOT_USE_HARD_LINKS,\n })\n return false\n }\n\n const selectElectron = async (filepath: string) => {\n const resolvedDist = path.isAbsolute(filepath) ? filepath : path.resolve(packager.projectDir, filepath)\n\n const electronDistStats = await statOrNull(resolvedDist)\n if (!electronDistStats) {\n throw new Error(\n `The specified electronDist does not exist: ${resolvedDist}. Please provide a valid path to the Electron zip file, cache directory, or electron build directory.`\n )\n }\n\n if (resolvedDist.endsWith(\".zip\")) {\n log.info({ zipFile: resolvedDist }, \"using custom electronDist zip file\")\n await downloadUsingAdjustedConfig({\n ...downloadOptions,\n cache: path.dirname(resolvedDist), // set custom directory to the zip file's directory\n customFilename: path.basename(resolvedDist), // set custom filename to the zip file's name\n })\n return false // do not clean up after unpacking, it's a custom bundle and we should respect its configuration/contents as required\n }\n\n if (electronDistStats.isDirectory()) {\n // backward compatibility: if electronDist is a directory, check for the default zip file inside it\n const files = await readdir(resolvedDist)\n if (files.includes(defaultZipName)) {\n log.info({ electronDist: log.filePath(resolvedDist) }, \"using custom electronDist directory\")\n await downloadUsingAdjustedConfig({\n ...downloadOptions,\n cache: resolvedDist,\n customFilename: defaultZipName,\n })\n return false\n }\n // if we reach here, it means the provided electronDist is neither a zip file nor a directory with the default zip file\n // e.g. we treat it as a custom already-unpacked Electron distribution\n return await copyUnpackedElectronDistribution(resolvedDist)\n }\n throw new Error(`The specified electronDist is neither a zip file nor a directory: ${resolvedDist}. Please provide a valid path to the Electron zip file or cache directory.`)\n }\n\n const { packager, appOutDir, platformName } = prepareOptions\n const { version, arch } = downloadOptions\n const defaultZipName = `electron-v${version}-${platformName}-${arch}.zip`\n\n const electronDist = packager.config.electronDist\n if (typeof electronDist === \"string\" && !isEmptyOrSpaces(electronDist)) {\n return selectElectron(electronDist)\n }\n\n let resolvedDist: string | null = null\n try {\n const electronDistHook: any = await resolveFunction(packager.appInfo.type, electronDist, \"electronDist\")\n resolvedDist = typeof electronDistHook === \"function\" ? await Promise.resolve(electronDistHook(prepareOptions)) : electronDistHook\n } catch (error: any) {\n log.warn({ error }, \"Failed to resolve electronDist, using default unpack logic\")\n }\n\n if (resolvedDist == null) {\n // if no custom electronDist is provided, use the default unpack logic\n log.debug(null, \"no custom electronDist provided, unpacking default Electron distribution\")\n await downloadUsingAdjustedConfig(downloadOptions)\n return true // indicates that we should clean up after unpacking\n }\n return selectElectron(resolvedDist)\n}\n\nfunction cleanupAfterUnpack(prepareOptions: PrepareApplicationStageDirectoryOptions, distMacOsAppName: string, isFullCleanup: boolean) {\n const out = prepareOptions.appOutDir\n const isMac = prepareOptions.packager.platform === Platform.MAC\n const resourcesPath = isMac ? path.join(out, distMacOsAppName, \"Contents\", \"Resources\") : path.join(out, \"resources\")\n\n return Promise.all([\n isFullCleanup ? unlinkIfExists(path.join(resourcesPath, \"default_app.asar\")) : Promise.resolve(),\n isFullCleanup ? unlinkIfExists(path.join(out, \"version\")) : Promise.resolve(),\n isMac\n ? Promise.resolve()\n : rename(path.join(out, \"LICENSE\"), path.join(out, \"LICENSE.electron.txt\")).catch(() => {\n /* ignore */\n }),\n ])\n}\n"]}
1
+ {"version":3,"file":"ElectronFramework.js","sourceRoot":"","sources":["../../src/electron/ElectronFramework.ts"],"names":[],"mappings":";;AA2BA,gDAKC;AAmJD,wEAiBC;AApMD,+CAA8J;AAC9J,uCAAwD;AACxD,6BAA4B;AAC5B,qDAAuC;AAGvC,oCAA6C;AAG7C,qDAAqD;AACrD,6CAA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D,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IAErH,OAAO,OAAO,CAAC,GAAG,CAAC;QACjB,aAAa,CAAC,CAAC,CAAC,IAAA,6BAAc,EAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;QAChG,aAAa,CAAC,CAAC,CAAC,IAAA,6BAAc,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;QAC7E,KAAK;YACH,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;YACnB,CAAC,CAAC,IAAA,iBAAM,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;gBACnF,YAAY;YACd,CAAC,CAAC;KACP,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { asArray, copyDir, DO_NOT_USE_HARD_LINKS, executeAppBuilder, isEmptyOrSpaces, log, MAX_FILE_REQUESTS, statOrNull, unlinkIfExists } from \"builder-util\"\nimport { emptyDir, readdir, rename, rm } from \"fs-extra\"\nimport * as path from \"path\"\nimport asyncPool from \"tiny-async-pool\"\nimport { Configuration } from \"../configuration\"\nimport { BeforeCopyExtraFilesOptions, Framework, PrepareApplicationStageDirectoryOptions } from \"../Framework\"\nimport { Packager, Platform } from \"../index\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { MacPackager } from \"../macPackager\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { resolveFunction } from \"../util/resolve\"\nimport { createMacApp } from \"./electronMac\"\nimport { computeElectronVersion, getElectronVersionFromInstalled } from \"./electronVersion\"\nimport { addWinAsarIntegrity } from \"./electronWin\"\nimport injectFFMPEG from \"./injectFFMPEG\"\n\nexport type ElectronPlatformName = \"darwin\" | \"linux\" | \"win32\" | \"mas\"\n\n/**\n * Electron distributables branding options.\n * @see [Electron BRANDING.json](https://github.com/electron/electron/blob/master/shell/app/BRANDING.json).\n */\nexport interface ElectronBrandingOptions {\n projectName?: string\n productName?: string\n}\n\nexport function createBrandingOpts(opts: Configuration): Required<ElectronBrandingOptions> {\n return {\n projectName: opts.electronBranding?.projectName || \"electron\",\n productName: opts.electronBranding?.productName || \"Electron\",\n }\n}\n\nexport interface ElectronDownloadOptions {\n // https://github.com/electron-userland/electron-builder/issues/3077\n // must be optional\n version?: string\n\n /**\n * The [cache location](https://github.com/electron-userland/electron-download#cache-location).\n */\n cache?: string | null\n\n /**\n * The mirror.\n */\n mirror?: string | null\n\n /** @private */\n customDir?: string | null\n /** @private */\n customFilename?: string | null\n\n strictSSL?: boolean\n isVerifyChecksum?: boolean\n\n platform?: ElectronPlatformName\n arch?: string\n}\n\nfunction createDownloadOpts(opts: Configuration, platform: ElectronPlatformName, arch: string, electronVersion: string): ElectronDownloadOptions {\n return {\n platform,\n arch,\n version: electronVersion,\n ...opts.electronDownload,\n }\n}\n\nasync function beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n const { appOutDir, packager } = options\n const electronBranding = createBrandingOpts(packager.config)\n if (packager.platform === Platform.LINUX) {\n const linuxPackager = packager as LinuxPackager\n const executable = path.join(appOutDir, linuxPackager.executableName)\n await rename(path.join(appOutDir, electronBranding.projectName), executable)\n } else if (packager.platform === Platform.WINDOWS) {\n const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`)\n await rename(path.join(appOutDir, `${electronBranding.projectName}.exe`), executable)\n if (options.asarIntegrity) {\n await addWinAsarIntegrity(executable, options.asarIntegrity)\n }\n } else {\n await createMacApp(packager as MacPackager, appOutDir, options.asarIntegrity, (options.platformName as ElectronPlatformName) === \"mas\")\n }\n await removeUnusedLanguagesIfNeeded(options)\n}\n\nasync function removeUnusedLanguagesIfNeeded(options: BeforeCopyExtraFilesOptions) {\n const { packager, appOutDir } = options\n const { config, platformSpecificBuildOptions, platform } = packager\n\n const getLocalesConfig = () => {\n if (platform === Platform.MAC) {\n return { dirs: [packager.getResourcesDir(appOutDir), packager.getMacOsElectronFrameworkResourcesDir(appOutDir)], langFileExt: \".lproj\" }\n }\n return { dirs: [path.join(packager.getResourcesDir(appOutDir), \"..\", \"locales\")], langFileExt: \".pak\" }\n }\n\n const wantedLanguages = asArray(platformSpecificBuildOptions.electronLanguages || config.electronLanguages)\n .map(it => it.trim().toLowerCase())\n .filter(it => it.length > 0)\n if (!wantedLanguages.length) {\n return\n }\n\n const { dirs, langFileExt } = getLocalesConfig()\n // noinspection SpellCheckingInspection\n const deleteNonMatchedLanguages: (dir: string) => Promise<Promise<void>[] | undefined> = async (dir: string) => {\n const files = await readdir(dir)\n return files.map(async file => {\n if (path.extname(file) !== langFileExt) {\n return\n }\n\n const language = path.basename(file, langFileExt).toLowerCase()\n const isWantedLocale = wantedLanguages.some(\n wantedLanguage =>\n // exact file\n wantedLanguage === language ||\n // prefix (e.g. \"en\" matches \"en-US\")\n wantedLanguage.startsWith(`${language}-`) ||\n // prefix (e.g. \"en\" matches \"en_US\")\n wantedLanguage.startsWith(`${language}_`)\n )\n if (isWantedLocale) {\n return undefined\n }\n return rm(path.join(dir, file), { recursive: true, force: true })\n })\n }\n const allDeletedFiles = (await Promise.all(dirs.map(deleteNonMatchedLanguages))).flat().filter((it): it is Promise<void> => it != null)\n if (allDeletedFiles.length === 0) {\n log.warn({ electronLanguages: wantedLanguages }, \"no locales found matching wanted languages, skipping cleanup\")\n return\n }\n await asyncPool(MAX_FILE_REQUESTS, allDeletedFiles, it => it)\n}\n\nclass ElectronFramework implements Framework {\n // noinspection JSUnusedGlobalSymbols\n readonly macOsDefaultTargets = [\"zip\", \"dmg\"]\n // noinspection JSUnusedGlobalSymbols\n readonly defaultAppIdPrefix = \"com.electron.\"\n // noinspection JSUnusedGlobalSymbols\n readonly isCopyElevateHelper = true\n // noinspection JSUnusedGlobalSymbols\n readonly isNpmRebuildRequired = true\n\n constructor(\n readonly name: string,\n readonly version: string,\n readonly distMacOsAppName: string\n ) {}\n\n getDefaultIcon(platform: Platform) {\n if (platform === Platform.LINUX) {\n return path.join(getTemplatePath(\"icons\"), \"electron-linux\")\n } else {\n // default icon is embedded into app skeleton\n return null\n }\n }\n\n async prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions) {\n const downloadOptions = createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version)\n const shouldCleanup = await unpack(options, downloadOptions, this.distMacOsAppName)\n await cleanupAfterUnpack(options, this.distMacOsAppName, shouldCleanup)\n if (options.packager.config.downloadAlternateFFmpeg) {\n await injectFFMPEG(options, this.version)\n }\n }\n\n beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n return beforeCopyExtraFiles(options)\n }\n}\n\nexport async function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise<Framework> {\n let version = configuration.electronVersion\n if (version == null) {\n // for prepacked app asar no dev deps in the app.asar\n if (packager.isPrepackedAppAsar) {\n version = await getElectronVersionFromInstalled(packager.projectDir)\n if (version == null) {\n throw new Error(`Cannot compute electron version for prepacked asar`)\n }\n } else {\n version = await computeElectronVersion(packager.projectDir)\n }\n configuration.electronVersion = version\n }\n\n const branding = createBrandingOpts(configuration)\n return new ElectronFramework(branding.projectName, version, `${branding.productName}.app`)\n}\n\n/**\n * Unpacks a custom or default Electron distribution into the app output directory.\n */\nasync function unpack(prepareOptions: PrepareApplicationStageDirectoryOptions, downloadOptions: ElectronDownloadOptions, distMacOsAppName: string): Promise<boolean> {\n const downloadUsingAdjustedConfig = (options: ElectronDownloadOptions) => {\n return executeAppBuilder([\"unpack-electron\", \"--configuration\", JSON.stringify([options]), \"--output\", appOutDir, \"--distMacOsAppName\", distMacOsAppName])\n }\n\n const copyUnpackedElectronDistribution = async (folderPath: string) => {\n log.info({ electronDist: log.filePath(folderPath) }, \"using custom unpacked Electron distribution\")\n const source = packager.getElectronSrcDir(folderPath)\n const destination = packager.getElectronDestinationDir(appOutDir)\n log.info({ source, destination }, \"copying unpacked Electron\")\n await emptyDir(appOutDir)\n await copyDir(source, destination, {\n isUseHardLink: DO_NOT_USE_HARD_LINKS,\n })\n return false\n }\n\n const selectElectron = async (filepath: string) => {\n const resolvedDist = path.isAbsolute(filepath) ? filepath : path.resolve(packager.projectDir, filepath)\n\n const electronDistStats = await statOrNull(resolvedDist)\n if (!electronDistStats) {\n throw new Error(\n `The specified electronDist does not exist: ${resolvedDist}. Please provide a valid path to the Electron zip file, cache directory, or electron build directory.`\n )\n }\n\n if (resolvedDist.endsWith(\".zip\")) {\n log.info({ zipFile: resolvedDist }, \"using custom electronDist zip file\")\n await downloadUsingAdjustedConfig({\n ...downloadOptions,\n cache: path.dirname(resolvedDist), // set custom directory to the zip file's directory\n customFilename: path.basename(resolvedDist), // set custom filename to the zip file's name\n })\n return false // do not clean up after unpacking, it's a custom bundle and we should respect its configuration/contents as required\n }\n\n if (electronDistStats.isDirectory()) {\n // backward compatibility: if electronDist is a directory, check for the default zip file inside it\n const files = await readdir(resolvedDist)\n if (files.includes(defaultZipName)) {\n log.info({ electronDist: log.filePath(resolvedDist) }, \"using custom electronDist directory\")\n await downloadUsingAdjustedConfig({\n ...downloadOptions,\n cache: resolvedDist,\n customFilename: defaultZipName,\n })\n return false\n }\n // if we reach here, it means the provided electronDist is neither a zip file nor a directory with the default zip file\n // e.g. we treat it as a custom already-unpacked Electron distribution\n return await copyUnpackedElectronDistribution(resolvedDist)\n }\n throw new Error(`The specified electronDist is neither a zip file nor a directory: ${resolvedDist}. Please provide a valid path to the Electron zip file or cache directory.`)\n }\n\n const { packager, appOutDir, platformName } = prepareOptions\n const { version, arch } = downloadOptions\n const defaultZipName = `electron-v${version}-${platformName}-${arch}.zip`\n\n const electronDist = packager.config.electronDist\n if (typeof electronDist === \"string\" && !isEmptyOrSpaces(electronDist)) {\n return selectElectron(electronDist)\n }\n\n let resolvedDist: string | null = null\n try {\n const electronDistHook: any = await resolveFunction(packager.appInfo.type, electronDist, \"electronDist\")\n resolvedDist = typeof electronDistHook === \"function\" ? await Promise.resolve(electronDistHook(prepareOptions)) : electronDistHook\n } catch (error: any) {\n log.warn({ error }, \"Failed to resolve electronDist, using default unpack logic\")\n }\n\n if (resolvedDist == null) {\n // if no custom electronDist is provided, use the default unpack logic\n log.debug(null, \"no custom electronDist provided, unpacking default Electron distribution\")\n await downloadUsingAdjustedConfig(downloadOptions)\n return true // indicates that we should clean up after unpacking\n }\n return selectElectron(resolvedDist)\n}\n\nfunction cleanupAfterUnpack(prepareOptions: PrepareApplicationStageDirectoryOptions, distMacOsAppName: string, isFullCleanup: boolean) {\n const out = prepareOptions.appOutDir\n const isMac = prepareOptions.packager.platform === Platform.MAC\n const resourcesPath = isMac ? path.join(out, distMacOsAppName, \"Contents\", \"Resources\") : path.join(out, \"resources\")\n\n return Promise.all([\n isFullCleanup ? unlinkIfExists(path.join(resourcesPath, \"default_app.asar\")) : Promise.resolve(),\n isFullCleanup ? unlinkIfExists(path.join(out, \"version\")) : Promise.resolve(),\n isMac\n ? Promise.resolve()\n : rename(path.join(out, \"LICENSE\"), path.join(out, \"LICENSE.electron.txt\")).catch(() => {\n /* ignore */\n }),\n ])\n}\n"]}
@@ -3,6 +3,7 @@ import { PackageJson } from "./types";
3
3
  import * as fs from "fs-extra";
4
4
  export declare enum LogMessageByKey {
5
5
  PKG_DUPLICATE_REF = "duplicate dependency references",
6
+ PKG_DUPLICATE_REF_UNRESOLVED = "unresolved duplicate dependency references",
6
7
  PKG_NOT_FOUND = "cannot find path for dependency",
7
8
  PKG_NOT_ON_DISK = "dependency not found on disk",
8
9
  PKG_SELF_REF = "self-referential dependencies",
@@ -8,6 +8,7 @@ const semver = require("semver");
8
8
  var LogMessageByKey;
9
9
  (function (LogMessageByKey) {
10
10
  LogMessageByKey["PKG_DUPLICATE_REF"] = "duplicate dependency references";
11
+ LogMessageByKey["PKG_DUPLICATE_REF_UNRESOLVED"] = "unresolved duplicate dependency references";
11
12
  LogMessageByKey["PKG_NOT_FOUND"] = "cannot find path for dependency";
12
13
  LogMessageByKey["PKG_NOT_ON_DISK"] = "dependency not found on disk";
13
14
  LogMessageByKey["PKG_SELF_REF"] = "self-referential dependencies";
@@ -16,6 +17,7 @@ var LogMessageByKey;
16
17
  })(LogMessageByKey || (exports.LogMessageByKey = LogMessageByKey = {}));
17
18
  exports.logMessageLevelByKey = {
18
19
  [LogMessageByKey.PKG_DUPLICATE_REF]: "info",
20
+ [LogMessageByKey.PKG_DUPLICATE_REF_UNRESOLVED]: "warn",
19
21
  [LogMessageByKey.PKG_NOT_FOUND]: "warn",
20
22
  [LogMessageByKey.PKG_NOT_ON_DISK]: "warn",
21
23
  [LogMessageByKey.PKG_SELF_REF]: "debug",
@@ -1 +1 @@
1
- {"version":3,"file":"moduleManager.js","sourceRoot":"","sources":["../../src/node-module-collector/moduleManager.ts"],"names":[],"mappings":";;;AAAA,+CAAqE;AAErE,+BAA8B;AAC9B,6BAA4B;AAC5B,iCAAgC;AAEhC,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,wEAAqD,CAAA;IACrD,oEAAiD,CAAA;IACjD,mEAAgD,CAAA;IAChD,iEAA8C,CAAA;IAC9C,+EAA4D,CAAA;IAC5D,mEAAgD,CAAA;AAClD,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AACY,QAAA,oBAAoB,GAAsC;IACrE,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,MAAM;IAC3C,CAAC,eAAe,CAAC,aAAa,CAAC,EAAE,MAAM;IACvC,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,MAAM;IACzC,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,O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CAAA;oBAC7C,IAAI,IAAI,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC;wBAC9D,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAA;oBACzE,CAAC;gBACH,CAAC;gBAED,kDAAkD;gBAClD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;gBAC5D,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,KAAI,MAAA,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,0CAAE,WAAW,EAAE,CAAA,EAAE,CAAC;oBAC/F,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC;wBAClC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;wBAC5B,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAA;oBACxD,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAvRD,sCAuRC","sourcesContent":["import { exists, isEmptyOrSpaces, log, LogLevel } from \"builder-util\"\nimport { PackageJson } from \"./types\"\nimport * as fs from \"fs-extra\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\n\nexport enum LogMessageByKey {\n PKG_DUPLICATE_REF = \"duplicate dependency references\",\n PKG_NOT_FOUND = \"cannot find path for dependency\",\n PKG_NOT_ON_DISK = \"dependency not found on disk\",\n PKG_SELF_REF = \"self-referential dependencies\",\n PKG_OPTIONAL_NOT_INSTALLED = \"missing optional dependencies\",\n PKG_COLLECTOR_OUTPUT = \"collector stderr output\",\n}\nexport const logMessageLevelByKey: Record<LogMessageByKey, LogLevel> = {\n [LogMessageByKey.PKG_DUPLICATE_REF]: \"info\",\n [LogMessageByKey.PKG_NOT_FOUND]: \"warn\",\n [LogMessageByKey.PKG_NOT_ON_DISK]: \"warn\",\n [LogMessageByKey.PKG_SELF_REF]: \"debug\",\n [LogMessageByKey.PKG_OPTIONAL_NOT_INSTALLED]: \"info\",\n [LogMessageByKey.PKG_COLLECTOR_OUTPUT]: \"warn\",\n}\n\nexport type Package = { packageDir: string; packageJson: PackageJson }\n\n// Type aliases for clarity\ntype JsonCache = Record<string, Promise<PackageJson | null>>\ntype RealPathCache = Record<string, Promise<string>>\ntype ExistsCache = Record<string, Promise<boolean>>\ntype LstatCache = Record<string, Promise<fs.Stats | null>>\ntype PackageCache = Record<string, Promise<Package | null>>\ntype LogSummaryCache = Record<LogMessageByKey, string[]>\n\nexport class ModuleManager {\n /** Cache for package.json contents (readJson) */\n readonly json: JsonCache\n /** Cache for resolved real paths (if symlink, realpath; otherwise resolve) */\n readonly realPath: RealPathCache\n /** Cache for file/directory existence checks */\n readonly exists: ExistsCache\n /** Cache for lstat results */\n readonly lstat: LstatCache\n /** Cache for package lookups (key: \"packageName||fromDir||semverRange\"). Use helper function `versionedCacheKey` */\n readonly packageData: PackageCache\n /** For logging purposes, just track all dependencies for each key */\n readonly logSummary: LogSummaryCache\n\n private readonly jsonMap: Map<string, PackageJson | null> = new Map()\n private readonly realPathMap: Map<string, string> = new Map()\n private readonly existsMap: Map<string, boolean> = new Map()\n private readonly lstatMap: Map<string, fs.Stats | null> = new Map()\n private readonly packageDataMap: Map<string, Package | null> = new Map()\n private readonly logSummaryMap: Map<LogMessageByKey, string[]> = new Map()\n\n constructor() {\n this.logSummary = this.createLogSummarySyncProxy()\n\n this.exists = this.createAsyncProxy(this.existsMap, (p: string) => exists(p))\n this.json = this.createAsyncProxy(this.jsonMap, (p: string) => fs.readJson(p).catch(() => null))\n this.lstat = this.createAsyncProxy(this.lstatMap, (p: string) => fs.lstat(p).catch(() => null))\n this.packageData = this.createAsyncProxy(this.packageDataMap, (p: string) => this.locatePackageVersionFromCacheKey(p).catch(() => null))\n this.realPath = this.createAsyncProxy(this.realPathMap, async (p: string) => {\n const filePath = path.resolve(p)\n const stat = await this.lstat[filePath]\n return stat?.isSymbolicLink() ? fs.realpath(filePath) : filePath\n })\n }\n\n private createLogSummarySyncProxy(): LogSummaryCache {\n return new Proxy({} as LogSummaryCache, {\n get: (_, key: LogMessageByKey) => {\n if (!this.logSummaryMap.has(key)) {\n this.logSummaryMap.set(key, [])\n }\n return this.logSummaryMap.get(key)!\n },\n set: (_, key: LogMessageByKey, value: string[]) => {\n this.logSummaryMap.set(key, value)\n return true\n },\n has: (_, key: LogMessageByKey) => {\n return this.logSummaryMap.has(key)\n },\n // Add these to make Object.entries() work\n ownKeys: _ => {\n return Array.from(this.logSummaryMap.keys())\n },\n getOwnPropertyDescriptor: (_, key) => {\n if (this.logSummaryMap.has(key as LogMessageByKey)) {\n return {\n enumerable: true,\n configurable: true,\n }\n }\n return undefined\n },\n })\n }\n\n // this allows dot-notation access while still supporting async retrieval\n // e.g., cache.packageJson[somePath] returns Promise<PackageJson>\n private createAsyncProxy<T>(map: Map<string, T>, compute: (key: string) => T | Promise<T>): Record<string, Promise<T>> {\n return new Proxy({} as Record<string, Promise<T>>, {\n async get(_, key: string) {\n if (map.has(key)) {\n return Promise.resolve(map.get(key)!)\n }\n return await Promise.resolve(compute(key)).then(value => {\n map.set(key, value)\n return value\n })\n },\n set(_, key: string, value: T) {\n map.set(key, value)\n return true\n },\n has(_, key: string) {\n return map.has(key)\n },\n })\n }\n\n versionedCacheKey(pkg: { name: string; path: string; semver?: string }): string {\n return [pkg.name, pkg.path, pkg.semver || \"\"].join(\"||\")\n }\n\n protected async locatePackageVersionFromCacheKey(key: string): Promise<Package | null> {\n const [name, fromDir, semverRange] = key.split(\"||\")\n const result = await this.locatePackageVersion({ parentDir: fromDir, pkgName: name, requiredRange: semverRange })\n if (result == null) {\n return null\n }\n return { ...result, packageDir: await this.realPath[result.packageDir] }\n }\n\n public async locatePackageVersion({ parentDir, pkgName, requiredRange }: { parentDir: string; pkgName: string; requiredRange?: string }): Promise<Package | null> {\n // 1) check direct parent node_modules/pkgName first\n const direct = path.join(path.resolve(parentDir), \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[direct]) {\n const json = await this.json[direct]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(direct), packageJson: json }\n }\n }\n\n // 2) upward hoisted search, then 3) downward non-hoisted search\n return (await this.upwardSearch(parentDir, pkgName, requiredRange)) || (await this.downwardSearch(parentDir, pkgName, requiredRange)) || null\n }\n\n private semverSatisfies(found: string, range?: string): boolean {\n if (isEmptyOrSpaces(range) || range === \"*\") {\n return true\n }\n\n if (range === found) {\n return true\n }\n\n if (semver.validRange(range) == null) {\n // ignore, we can't verify non-semver ranges\n // e.g. git urls, file:, patch:, etc. Example:\n // \"@ai-sdk/google\": \"patch:@ai-sdk/google@npm%3A2.0.43#~/.yarn/patches/@ai-sdk-google-npm-2.0.43-689ed559b3.patch\"\n log.debug({ found, range }, \"unable to validate semver version range, assuming match\")\n return true\n }\n\n try {\n return semver.satisfies(found, range)\n } catch {\n // fallback: simple equality or basic prefix handling (^, ~)\n if (range.startsWith(\"^\") || range.startsWith(\"~\")) {\n const r = range.slice(1)\n return r === found\n }\n // if range is like \"8.x\" or \"8.*\" match major\n const m = range.match(/^(\\d+)[.(*|x)]*/)\n const fm = found.match(/^(\\d+)\\./)\n if (m && fm) {\n return m[1] === fm[1]\n }\n return false\n }\n }\n\n /**\n * Upward search (hoisted)\n */\n private async upwardSearch(parentDir: string, pkgName: string, requiredRange?: string): Promise<Package | null> {\n let current = path.resolve(parentDir)\n const root = path.parse(current).root\n while (true) {\n const candidate = path.join(current, \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[candidate]) {\n const json = await this.json[candidate]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(candidate), packageJson: json }\n }\n // otherwise keep searching upward (we may find a different hoisted version)\n }\n if (current === root) {\n break\n }\n const parent = path.dirname(current)\n if (parent === current) {\n break\n }\n current = parent\n }\n return null\n }\n\n /**\n * Breadth-first downward search from parentDir/node_modules\n * Looks for node_modules/\\*\\/node_modules/pkgName (and deeper)\n */\n private async downwardSearch(parentDir: string, pkgName: string, requiredRange?: string, maxExplored = 2000, maxDepth = 6): Promise<Package | null> {\n const start = path.join(path.resolve(parentDir), \"node_modules\")\n if (!(await this.exists[start]) || !(await this.lstat[start])?.isDirectory()) {\n return null\n }\n\n const visited = new Set<string>()\n const queue: Array<{ dir: string; depth: number }> = [{ dir: start, depth: 0 }]\n let explored = 0\n\n while (queue.length > 0) {\n const { dir, depth } = queue.shift()!\n if (explored++ > maxExplored) {\n break\n }\n if (depth > maxDepth) {\n continue\n }\n let entries: string[]\n try {\n entries = await fs.readdir(dir)\n } catch {\n continue\n }\n for (const entry of entries) {\n if (entry.startsWith(\".\")) {\n continue\n }\n const entryPath = path.join(dir, entry)\n // handle scoped packages @scope/name\n if (entry.startsWith(\"@\")) {\n // queue the scope directory itself to explore its children\n if ((await this.exists[entryPath]) && (await this.lstat[entryPath])?.isDirectory()) {\n const scopeEntries = await fs.readdir(entryPath)\n for (const sc of scopeEntries) {\n const scPath = path.join(entryPath, sc)\n // check scPath/node_modules/pkgName\n const candidatePkgJson = path.join(scPath, \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[candidatePkgJson]) {\n const json = await this.json[candidatePkgJson]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(candidatePkgJson), packageJson: json }\n }\n }\n // enqueue scPath/node_modules to explore further\n const scNodeModules = path.join(scPath, \"node_modules\")\n if ((await this.exists[scNodeModules]) && (await this.lstat[scNodeModules])?.isDirectory()) {\n if (!visited.has(scNodeModules)) {\n visited.add(scNodeModules)\n queue.push({ dir: scNodeModules, depth: depth + 1 })\n }\n }\n }\n }\n continue\n }\n\n // check for direct candidate: entry/node_modules/pkgName\n try {\n const stat = await this.lstat[entryPath]\n if (!stat?.isDirectory()) {\n continue\n }\n } catch {\n continue\n }\n\n const candidatePkgJson = path.join(entryPath, \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[candidatePkgJson]) {\n const json = await this.json[candidatePkgJson]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(candidatePkgJson), packageJson: json }\n }\n }\n\n // also check entry/node_modules directly for pkgName (some layouts)\n const candidateDirect = path.join(entryPath, pkgName, \"package.json\")\n if (await this.exists[candidateDirect]) {\n const json = await this.json[candidateDirect]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(candidateDirect), packageJson: json }\n }\n }\n\n // enqueue entry/node_modules for deeper traversal\n const nextNodeModules = path.join(entryPath, \"node_modules\")\n if ((await this.exists[nextNodeModules]) && (await this.lstat[nextNodeModules])?.isDirectory()) {\n if (!visited.has(nextNodeModules)) {\n visited.add(nextNodeModules)\n queue.push({ dir: nextNodeModules, depth: depth + 1 })\n }\n }\n }\n }\n\n return null\n }\n}\n"]}
1
+ {"version":3,"file":"moduleManager.js","sourceRoot":"","sources":["../../src/node-module-collector/moduleManager.ts"],"names":[],"mappings":";;;AAAA,+CAAqE;AAErE,+BAA8B;AAC9B,6BAA4B;AAC5B,iCAAgC;AAEhC,IAAY,eAQX;AARD,WAAY,eAAe;IACzB,wEAAqD,CAAA;IACrD,8FAA2E,CAAA;IAC3E,oEAAiD,CAAA;IACjD,mEAAgD,CAAA;IAChD,iEAA8C,CAAA;IAC9C,+EAA4D,CAAA;IAC5D,mEAAgD,CAAA;AAClD,CAAC,EARW,eAAe,+BAAf,eAAe,QAQ1B;AACY,QAAA,oBAAoB,GAAsC;IACrE,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,MAAM;IAC3C,CAAC,eAAe,CAAC,4BAA4B,CAAC,EAAE,MAAM;IACtD,CAAC,eAAe,CAAC,aAAa,CAAC,EAAE,MAAM;IACvC,C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AAC,EAAE,CAAC;oBACvC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;oBAC7C,IAAI,IAAI,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC;wBAC9D,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAA;oBACzE,CAAC;gBACH,CAAC;gBAED,kDAAkD;gBAClD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;gBAC5D,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,KAAI,MAAA,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,0CAAE,WAAW,EAAE,CAAA,EAAE,CAAC;oBAC/F,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC;wBAClC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;wBAC5B,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAA;oBACxD,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAvRD,sCAuRC","sourcesContent":["import { exists, isEmptyOrSpaces, log, LogLevel } from \"builder-util\"\nimport { PackageJson } from \"./types\"\nimport * as fs from \"fs-extra\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\n\nexport enum LogMessageByKey {\n PKG_DUPLICATE_REF = \"duplicate dependency references\",\n PKG_DUPLICATE_REF_UNRESOLVED = \"unresolved duplicate dependency references\",\n PKG_NOT_FOUND = \"cannot find path for dependency\",\n PKG_NOT_ON_DISK = \"dependency not found on disk\",\n PKG_SELF_REF = \"self-referential dependencies\",\n PKG_OPTIONAL_NOT_INSTALLED = \"missing optional dependencies\",\n PKG_COLLECTOR_OUTPUT = \"collector stderr output\",\n}\nexport const logMessageLevelByKey: Record<LogMessageByKey, LogLevel> = {\n [LogMessageByKey.PKG_DUPLICATE_REF]: \"info\",\n [LogMessageByKey.PKG_DUPLICATE_REF_UNRESOLVED]: \"warn\",\n [LogMessageByKey.PKG_NOT_FOUND]: \"warn\",\n [LogMessageByKey.PKG_NOT_ON_DISK]: \"warn\",\n [LogMessageByKey.PKG_SELF_REF]: \"debug\",\n [LogMessageByKey.PKG_OPTIONAL_NOT_INSTALLED]: \"info\",\n [LogMessageByKey.PKG_COLLECTOR_OUTPUT]: \"warn\",\n}\n\nexport type Package = { packageDir: string; packageJson: PackageJson }\n\n// Type aliases for clarity\ntype JsonCache = Record<string, Promise<PackageJson | null>>\ntype RealPathCache = Record<string, Promise<string>>\ntype ExistsCache = Record<string, Promise<boolean>>\ntype LstatCache = Record<string, Promise<fs.Stats | null>>\ntype PackageCache = Record<string, Promise<Package | null>>\ntype LogSummaryCache = Record<LogMessageByKey, string[]>\n\nexport class ModuleManager {\n /** Cache for package.json contents (readJson) */\n readonly json: JsonCache\n /** Cache for resolved real paths (if symlink, realpath; otherwise resolve) */\n readonly realPath: RealPathCache\n /** Cache for file/directory existence checks */\n readonly exists: ExistsCache\n /** Cache for lstat results */\n readonly lstat: LstatCache\n /** Cache for package lookups (key: \"packageName||fromDir||semverRange\"). Use helper function `versionedCacheKey` */\n readonly packageData: PackageCache\n /** For logging purposes, just track all dependencies for each key */\n readonly logSummary: LogSummaryCache\n\n private readonly jsonMap: Map<string, PackageJson | null> = new Map()\n private readonly realPathMap: Map<string, string> = new Map()\n private readonly existsMap: Map<string, boolean> = new Map()\n private readonly lstatMap: Map<string, fs.Stats | null> = new Map()\n private readonly packageDataMap: Map<string, Package | null> = new Map()\n private readonly logSummaryMap: Map<LogMessageByKey, string[]> = new Map()\n\n constructor() {\n this.logSummary = this.createLogSummarySyncProxy()\n\n this.exists = this.createAsyncProxy(this.existsMap, (p: string) => exists(p))\n this.json = this.createAsyncProxy(this.jsonMap, (p: string) => fs.readJson(p).catch(() => null))\n this.lstat = this.createAsyncProxy(this.lstatMap, (p: string) => fs.lstat(p).catch(() => null))\n this.packageData = this.createAsyncProxy(this.packageDataMap, (p: string) => this.locatePackageVersionFromCacheKey(p).catch(() => null))\n this.realPath = this.createAsyncProxy(this.realPathMap, async (p: string) => {\n const filePath = path.resolve(p)\n const stat = await this.lstat[filePath]\n return stat?.isSymbolicLink() ? fs.realpath(filePath) : filePath\n })\n }\n\n private createLogSummarySyncProxy(): LogSummaryCache {\n return new Proxy({} as LogSummaryCache, {\n get: (_, key: LogMessageByKey) => {\n if (!this.logSummaryMap.has(key)) {\n this.logSummaryMap.set(key, [])\n }\n return this.logSummaryMap.get(key)!\n },\n set: (_, key: LogMessageByKey, value: string[]) => {\n this.logSummaryMap.set(key, value)\n return true\n },\n has: (_, key: LogMessageByKey) => {\n return this.logSummaryMap.has(key)\n },\n // Add these to make Object.entries() work\n ownKeys: _ => {\n return Array.from(this.logSummaryMap.keys())\n },\n getOwnPropertyDescriptor: (_, key) => {\n if (this.logSummaryMap.has(key as LogMessageByKey)) {\n return {\n enumerable: true,\n configurable: true,\n }\n }\n return undefined\n },\n })\n }\n\n // this allows dot-notation access while still supporting async retrieval\n // e.g., cache.packageJson[somePath] returns Promise<PackageJson>\n private createAsyncProxy<T>(map: Map<string, T>, compute: (key: string) => T | Promise<T>): Record<string, Promise<T>> {\n return new Proxy({} as Record<string, Promise<T>>, {\n async get(_, key: string) {\n if (map.has(key)) {\n return Promise.resolve(map.get(key)!)\n }\n return await Promise.resolve(compute(key)).then(value => {\n map.set(key, value)\n return value\n })\n },\n set(_, key: string, value: T) {\n map.set(key, value)\n return true\n },\n has(_, key: string) {\n return map.has(key)\n },\n })\n }\n\n versionedCacheKey(pkg: { name: string; path: string; semver?: string }): string {\n return [pkg.name, pkg.path, pkg.semver || \"\"].join(\"||\")\n }\n\n protected async locatePackageVersionFromCacheKey(key: string): Promise<Package | null> {\n const [name, fromDir, semverRange] = key.split(\"||\")\n const result = await this.locatePackageVersion({ parentDir: fromDir, pkgName: name, requiredRange: semverRange })\n if (result == null) {\n return null\n }\n return { ...result, packageDir: await this.realPath[result.packageDir] }\n }\n\n public async locatePackageVersion({ parentDir, pkgName, requiredRange }: { parentDir: string; pkgName: string; requiredRange?: string }): Promise<Package | null> {\n // 1) check direct parent node_modules/pkgName first\n const direct = path.join(path.resolve(parentDir), \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[direct]) {\n const json = await this.json[direct]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(direct), packageJson: json }\n }\n }\n\n // 2) upward hoisted search, then 3) downward non-hoisted search\n return (await this.upwardSearch(parentDir, pkgName, requiredRange)) || (await this.downwardSearch(parentDir, pkgName, requiredRange)) || null\n }\n\n private semverSatisfies(found: string, range?: string): boolean {\n if (isEmptyOrSpaces(range) || range === \"*\") {\n return true\n }\n\n if (range === found) {\n return true\n }\n\n if (semver.validRange(range) == null) {\n // ignore, we can't verify non-semver ranges\n // e.g. git urls, file:, patch:, etc. Example:\n // \"@ai-sdk/google\": \"patch:@ai-sdk/google@npm%3A2.0.43#~/.yarn/patches/@ai-sdk-google-npm-2.0.43-689ed559b3.patch\"\n log.debug({ found, range }, \"unable to validate semver version range, assuming match\")\n return true\n }\n\n try {\n return semver.satisfies(found, range)\n } catch {\n // fallback: simple equality or basic prefix handling (^, ~)\n if (range.startsWith(\"^\") || range.startsWith(\"~\")) {\n const r = range.slice(1)\n return r === found\n }\n // if range is like \"8.x\" or \"8.*\" match major\n const m = range.match(/^(\\d+)[.(*|x)]*/)\n const fm = found.match(/^(\\d+)\\./)\n if (m && fm) {\n return m[1] === fm[1]\n }\n return false\n }\n }\n\n /**\n * Upward search (hoisted)\n */\n private async upwardSearch(parentDir: string, pkgName: string, requiredRange?: string): Promise<Package | null> {\n let current = path.resolve(parentDir)\n const root = path.parse(current).root\n while (true) {\n const candidate = path.join(current, \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[candidate]) {\n const json = await this.json[candidate]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(candidate), packageJson: json }\n }\n // otherwise keep searching upward (we may find a different hoisted version)\n }\n if (current === root) {\n break\n }\n const parent = path.dirname(current)\n if (parent === current) {\n break\n }\n current = parent\n }\n return null\n }\n\n /**\n * Breadth-first downward search from parentDir/node_modules\n * Looks for node_modules/\\*\\/node_modules/pkgName (and deeper)\n */\n private async downwardSearch(parentDir: string, pkgName: string, requiredRange?: string, maxExplored = 2000, maxDepth = 6): Promise<Package | null> {\n const start = path.join(path.resolve(parentDir), \"node_modules\")\n if (!(await this.exists[start]) || !(await this.lstat[start])?.isDirectory()) {\n return null\n }\n\n const visited = new Set<string>()\n const queue: Array<{ dir: string; depth: number }> = [{ dir: start, depth: 0 }]\n let explored = 0\n\n while (queue.length > 0) {\n const { dir, depth } = queue.shift()!\n if (explored++ > maxExplored) {\n break\n }\n if (depth > maxDepth) {\n continue\n }\n let entries: string[]\n try {\n entries = await fs.readdir(dir)\n } catch {\n continue\n }\n for (const entry of entries) {\n if (entry.startsWith(\".\")) {\n continue\n }\n const entryPath = path.join(dir, entry)\n // handle scoped packages @scope/name\n if (entry.startsWith(\"@\")) {\n // queue the scope directory itself to explore its children\n if ((await this.exists[entryPath]) && (await this.lstat[entryPath])?.isDirectory()) {\n const scopeEntries = await fs.readdir(entryPath)\n for (const sc of scopeEntries) {\n const scPath = path.join(entryPath, sc)\n // check scPath/node_modules/pkgName\n const candidatePkgJson = path.join(scPath, \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[candidatePkgJson]) {\n const json = await this.json[candidatePkgJson]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(candidatePkgJson), packageJson: json }\n }\n }\n // enqueue scPath/node_modules to explore further\n const scNodeModules = path.join(scPath, \"node_modules\")\n if ((await this.exists[scNodeModules]) && (await this.lstat[scNodeModules])?.isDirectory()) {\n if (!visited.has(scNodeModules)) {\n visited.add(scNodeModules)\n queue.push({ dir: scNodeModules, depth: depth + 1 })\n }\n }\n }\n }\n continue\n }\n\n // check for direct candidate: entry/node_modules/pkgName\n try {\n const stat = await this.lstat[entryPath]\n if (!stat?.isDirectory()) {\n continue\n }\n } catch {\n continue\n }\n\n const candidatePkgJson = path.join(entryPath, \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[candidatePkgJson]) {\n const json = await this.json[candidatePkgJson]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(candidatePkgJson), packageJson: json }\n }\n }\n\n // also check entry/node_modules directly for pkgName (some layouts)\n const candidateDirect = path.join(entryPath, pkgName, \"package.json\")\n if (await this.exists[candidateDirect]) {\n const json = await this.json[candidateDirect]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(candidateDirect), packageJson: json }\n }\n }\n\n // enqueue entry/node_modules for deeper traversal\n const nextNodeModules = path.join(entryPath, \"node_modules\")\n if ((await this.exists[nextNodeModules]) && (await this.lstat[nextNodeModules])?.isDirectory()) {\n if (!visited.has(nextNodeModules)) {\n visited.add(nextNodeModules)\n queue.push({ dir: nextNodeModules, depth: depth + 1 })\n }\n }\n }\n }\n\n return null\n }\n}\n"]}
@@ -183,14 +183,22 @@ class NodeModulesCollector {
183
183
  * the package name with an "unknown" version.
184
184
  */
185
185
  parseNameVersion(identifier) {
186
- const lastAt = identifier.lastIndexOf("@");
187
- if (lastAt <= 0) {
188
- // fallback for scoped packages or malformed strings
186
+ let at;
187
+ if (identifier.startsWith("@")) {
188
+ // Scoped package: find the version separator after the scope (e.g. "@scope/pkg@1.2.3")
189
+ const slashIndex = identifier.indexOf("/");
190
+ if (slashIndex === -1) {
191
+ return { name: identifier, version: "unknown" };
192
+ }
193
+ at = identifier.indexOf("@", slashIndex + 1);
194
+ }
195
+ else {
196
+ at = identifier.indexOf("@");
197
+ }
198
+ if (at <= 0) {
189
199
  return { name: identifier, version: "unknown" };
190
200
  }
191
- const name = identifier.slice(0, lastAt);
192
- const version = identifier.slice(lastAt + 1);
193
- return { name, version };
201
+ return { name: identifier.slice(0, at), version: identifier.slice(at + 1) };
194
202
  }
195
203
  /**
196
204
  * Retrieves the dependency tree and handles workspace package self-references.