app-builder-lib 27.0.0-alpha.4 → 27.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/dist/appInfo.d.ts +1 -1
  2. package/dist/appInfo.d.ts.map +1 -1
  3. package/dist/appInfo.js +3 -3
  4. package/dist/appInfo.js.map +1 -1
  5. package/dist/codeSign/mac/macCodeSign.d.ts.map +1 -1
  6. package/dist/codeSign/mac/macCodeSign.js +3 -6
  7. package/dist/codeSign/mac/macCodeSign.js.map +1 -1
  8. package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -1
  9. package/dist/codeSign/win/signtoolBaseSignManager.js +6 -4
  10. package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -1
  11. package/dist/codeSign/win/windowsSignAzureManager.d.ts.map +1 -1
  12. package/dist/codeSign/win/windowsSignAzureManager.js +31 -21
  13. package/dist/codeSign/win/windowsSignAzureManager.js.map +1 -1
  14. package/dist/configuration.d.ts +84 -44
  15. package/dist/configuration.d.ts.map +1 -1
  16. package/dist/configuration.js +11 -1
  17. package/dist/configuration.js.map +1 -1
  18. package/dist/electron/ElectronFramework.d.ts +2 -1
  19. package/dist/electron/ElectronFramework.d.ts.map +1 -1
  20. package/dist/electron/ElectronFramework.js +32 -28
  21. package/dist/electron/ElectronFramework.js.map +1 -1
  22. package/dist/electron/electronArchSupport.d.ts +12 -0
  23. package/dist/electron/electronArchSupport.d.ts.map +1 -0
  24. package/dist/electron/electronArchSupport.js +58 -0
  25. package/dist/electron/electronArchSupport.js.map +1 -0
  26. package/dist/electron/electronVersion.d.ts.map +1 -1
  27. package/dist/electron/electronVersion.js +1 -11
  28. package/dist/electron/electronVersion.js.map +1 -1
  29. package/dist/electron/mac/electronMac.js +12 -21
  30. package/dist/electron/mac/electronMac.js.map +1 -1
  31. package/dist/electron/mac/electronMacUtils.d.ts +24 -0
  32. package/dist/electron/mac/electronMacUtils.d.ts.map +1 -0
  33. package/dist/electron/mac/electronMacUtils.js +42 -0
  34. package/dist/electron/mac/electronMacUtils.js.map +1 -0
  35. package/dist/fileMatcher.d.ts +27 -2
  36. package/dist/fileMatcher.d.ts.map +1 -1
  37. package/dist/fileMatcher.js +204 -16
  38. package/dist/fileMatcher.js.map +1 -1
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/indexInternal.d.ts +8 -5
  43. package/dist/indexInternal.d.ts.map +1 -1
  44. package/dist/indexInternal.js +8 -4
  45. package/dist/indexInternal.js.map +1 -1
  46. package/dist/macPackager.d.ts.map +1 -1
  47. package/dist/macPackager.js +15 -3
  48. package/dist/macPackager.js.map +1 -1
  49. package/dist/node-module-collector/moduleManager.d.ts +3 -1
  50. package/dist/node-module-collector/moduleManager.d.ts.map +1 -1
  51. package/dist/node-module-collector/moduleManager.js +9 -1
  52. package/dist/node-module-collector/moduleManager.js.map +1 -1
  53. package/dist/node-module-collector/nodeModulesCollector.d.ts +17 -1
  54. package/dist/node-module-collector/nodeModulesCollector.d.ts.map +1 -1
  55. package/dist/node-module-collector/nodeModulesCollector.js +67 -1
  56. package/dist/node-module-collector/nodeModulesCollector.js.map +1 -1
  57. package/dist/node-module-collector/pnpmNodeModulesCollector.js +5 -5
  58. package/dist/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
  59. package/dist/node-module-collector/types.d.ts +2 -0
  60. package/dist/node-module-collector/types.d.ts.map +1 -1
  61. package/dist/node-module-collector/types.js.map +1 -1
  62. package/dist/options/MsixOptions.d.ts +126 -0
  63. package/dist/options/MsixOptions.d.ts.map +1 -0
  64. package/dist/options/MsixOptions.js +2 -0
  65. package/dist/options/MsixOptions.js.map +1 -0
  66. package/dist/options/PlatformSpecificBuildOptions.d.ts +0 -6
  67. package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
  68. package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
  69. package/dist/options/SnapOptions.d.ts +15 -13
  70. package/dist/options/SnapOptions.d.ts.map +1 -1
  71. package/dist/options/SnapOptions.js.map +1 -1
  72. package/dist/options/macOptions.d.ts +4 -4
  73. package/dist/options/macOptions.d.ts.map +1 -1
  74. package/dist/options/macOptions.js.map +1 -1
  75. package/dist/options/winOptions.d.ts +166 -36
  76. package/dist/options/winOptions.d.ts.map +1 -1
  77. package/dist/options/winOptions.js.map +1 -1
  78. package/dist/packager.d.ts +2 -0
  79. package/dist/packager.d.ts.map +1 -1
  80. package/dist/packager.js +26 -21
  81. package/dist/packager.js.map +1 -1
  82. package/dist/platformPackager.d.ts +2 -0
  83. package/dist/platformPackager.d.ts.map +1 -1
  84. package/dist/platformPackager.js +6 -0
  85. package/dist/platformPackager.js.map +1 -1
  86. package/dist/publish/PublishManager.d.ts +1 -0
  87. package/dist/publish/PublishManager.d.ts.map +1 -1
  88. package/dist/publish/PublishManager.js +20 -6
  89. package/dist/publish/PublishManager.js.map +1 -1
  90. package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
  91. package/dist/publish/updateInfoBuilder.js +20 -22
  92. package/dist/publish/updateInfoBuilder.js.map +1 -1
  93. package/dist/targets/archive.d.ts +11 -0
  94. package/dist/targets/archive.d.ts.map +1 -1
  95. package/dist/targets/archive.js +40 -22
  96. package/dist/targets/archive.js.map +1 -1
  97. package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
  98. package/dist/targets/linux/FpmTarget.js +3 -3
  99. package/dist/targets/linux/FpmTarget.js.map +1 -1
  100. package/dist/targets/linux/appimage/AppImageTarget.d.ts.map +1 -1
  101. package/dist/targets/linux/appimage/AppImageTarget.js +5 -6
  102. package/dist/targets/linux/appimage/AppImageTarget.js.map +1 -1
  103. package/dist/targets/linux/snap/SnapTarget.d.ts +1 -1
  104. package/dist/targets/linux/snap/SnapTarget.d.ts.map +1 -1
  105. package/dist/targets/linux/snap/SnapTarget.js +23 -1
  106. package/dist/targets/linux/snap/SnapTarget.js.map +1 -1
  107. package/dist/targets/linux/snap/core24.d.ts +1 -1
  108. package/dist/targets/linux/snap/core24.d.ts.map +1 -1
  109. package/dist/targets/linux/snap/core24.js +3 -2
  110. package/dist/targets/linux/snap/core24.js.map +1 -1
  111. package/dist/targets/linux/snap/coreCustom.d.ts +1 -1
  112. package/dist/targets/linux/snap/coreCustom.d.ts.map +1 -1
  113. package/dist/targets/linux/snap/coreCustom.js +2 -2
  114. package/dist/targets/linux/snap/coreCustom.js.map +1 -1
  115. package/dist/targets/linux/snap/coreLegacy.d.ts +1 -1
  116. package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
  117. package/dist/targets/linux/snap/coreLegacy.js +2 -1
  118. package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
  119. package/dist/targets/linux/snap/snapcraft.d.ts +190 -0
  120. package/dist/targets/linux/snap/snapcraft.d.ts.map +1 -0
  121. package/dist/targets/linux/snap/snapcraft.js +11 -0
  122. package/dist/targets/linux/snap/snapcraft.js.map +1 -0
  123. package/dist/targets/linux/snap/snapcraftBuilder.d.ts +7 -1
  124. package/dist/targets/linux/snap/snapcraftBuilder.d.ts.map +1 -1
  125. package/dist/targets/linux/snap/snapcraftBuilder.js +57 -20
  126. package/dist/targets/linux/snap/snapcraftBuilder.js.map +1 -1
  127. package/dist/targets/mac/MacTargetHelper.d.ts +6 -0
  128. package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
  129. package/dist/targets/mac/MacTargetHelper.js +22 -1
  130. package/dist/targets/mac/MacTargetHelper.js.map +1 -1
  131. package/dist/targets/targetFactory.d.ts +7 -0
  132. package/dist/targets/targetFactory.d.ts.map +1 -1
  133. package/dist/targets/targetFactory.js +28 -0
  134. package/dist/targets/targetFactory.js.map +1 -1
  135. package/dist/targets/win/AppxTarget.d.ts +0 -2
  136. package/dist/targets/win/AppxTarget.d.ts.map +1 -1
  137. package/dist/targets/win/AppxTarget.js +37 -317
  138. package/dist/targets/win/AppxTarget.js.map +1 -1
  139. package/dist/targets/win/MsixTarget.d.ts +22 -0
  140. package/dist/targets/win/MsixTarget.d.ts.map +1 -0
  141. package/dist/targets/win/MsixTarget.js +214 -0
  142. package/dist/targets/win/MsixTarget.js.map +1 -0
  143. package/dist/targets/win/nsis/NsisTarget.d.ts +3 -2
  144. package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
  145. package/dist/targets/win/nsis/NsisTarget.js +28 -46
  146. package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
  147. package/dist/targets/win/nsis/nsisScriptGenerator.d.ts.map +1 -1
  148. package/dist/targets/win/nsis/nsisScriptGenerator.js +2 -1
  149. package/dist/targets/win/nsis/nsisScriptGenerator.js.map +1 -1
  150. package/dist/targets/win/nsis/nsisUtil.d.ts +5 -2
  151. package/dist/targets/win/nsis/nsisUtil.d.ts.map +1 -1
  152. package/dist/targets/win/nsis/nsisUtil.js +46 -22
  153. package/dist/targets/win/nsis/nsisUtil.js.map +1 -1
  154. package/dist/targets/win/nsis/progId.d.ts +21 -0
  155. package/dist/targets/win/nsis/progId.d.ts.map +1 -0
  156. package/dist/targets/win/nsis/progId.js +60 -0
  157. package/dist/targets/win/nsis/progId.js.map +1 -0
  158. package/dist/targets/win/winAppUtil.d.ts +115 -0
  159. package/dist/targets/win/winAppUtil.d.ts.map +1 -0
  160. package/dist/targets/win/winAppUtil.js +407 -0
  161. package/dist/targets/win/winAppUtil.js.map +1 -0
  162. package/dist/toolsets/7zip.d.ts.map +1 -1
  163. package/dist/toolsets/7zip.js +3 -1
  164. package/dist/toolsets/7zip.js.map +1 -1
  165. package/dist/toolsets/appimage.d.ts +3 -3
  166. package/dist/toolsets/appimage.d.ts.map +1 -1
  167. package/dist/toolsets/appimage.js +9 -6
  168. package/dist/toolsets/appimage.js.map +1 -1
  169. package/dist/toolsets/custom.d.ts +1 -3
  170. package/dist/toolsets/custom.d.ts.map +1 -1
  171. package/dist/toolsets/custom.js +4 -133
  172. package/dist/toolsets/custom.js.map +1 -1
  173. package/dist/toolsets/fpm.d.ts.map +1 -1
  174. package/dist/toolsets/fpm.js +11 -5
  175. package/dist/toolsets/fpm.js.map +1 -1
  176. package/dist/toolsets/icons.d.ts.map +1 -1
  177. package/dist/toolsets/icons.js +4 -1
  178. package/dist/toolsets/icons.js.map +1 -1
  179. package/dist/toolsets/linuxToolsMac.d.ts.map +1 -1
  180. package/dist/toolsets/linuxToolsMac.js +4 -1
  181. package/dist/toolsets/linuxToolsMac.js.map +1 -1
  182. package/dist/toolsets/nsis.d.ts.map +1 -1
  183. package/dist/toolsets/nsis.js +6 -3
  184. package/dist/toolsets/nsis.js.map +1 -1
  185. package/dist/toolsets/version.d.ts +12 -0
  186. package/dist/toolsets/version.d.ts.map +1 -0
  187. package/dist/toolsets/version.js +13 -0
  188. package/dist/toolsets/version.js.map +1 -0
  189. package/dist/toolsets/winCodeSign.d.ts +20 -3
  190. package/dist/toolsets/winCodeSign.d.ts.map +1 -1
  191. package/dist/toolsets/winCodeSign.js +56 -27
  192. package/dist/toolsets/winCodeSign.js.map +1 -1
  193. package/dist/toolsets/wine.d.ts +2 -1
  194. package/dist/toolsets/wine.d.ts.map +1 -1
  195. package/dist/toolsets/wine.js +15 -13
  196. package/dist/toolsets/wine.js.map +1 -1
  197. package/dist/util/NodeModuleCopyHelper.js +3 -3
  198. package/dist/util/NodeModuleCopyHelper.js.map +1 -1
  199. package/dist/util/appFileCopier.d.ts +39 -0
  200. package/dist/util/appFileCopier.d.ts.map +1 -1
  201. package/dist/util/appFileCopier.js +88 -22
  202. package/dist/util/appFileCopier.js.map +1 -1
  203. package/dist/util/config/config.d.ts +1 -0
  204. package/dist/util/config/config.d.ts.map +1 -1
  205. package/dist/util/config/config.js +4 -1
  206. package/dist/util/config/config.js.map +1 -1
  207. package/dist/util/config/load.d.ts +2 -2
  208. package/dist/util/config/load.d.ts.map +1 -1
  209. package/dist/util/config/load.js +3 -12
  210. package/dist/util/config/load.js.map +1 -1
  211. package/dist/util/config/schemaValidator.js +1 -1
  212. package/dist/util/config/schemaValidator.js.map +1 -1
  213. package/dist/util/electronGet.d.ts +6 -3
  214. package/dist/util/electronGet.d.ts.map +1 -1
  215. package/dist/util/electronGet.js +40 -20
  216. package/dist/util/electronGet.js.map +1 -1
  217. package/dist/util/flags.d.ts +0 -2
  218. package/dist/util/flags.d.ts.map +1 -1
  219. package/dist/util/flags.js +0 -6
  220. package/dist/util/flags.js.map +1 -1
  221. package/dist/util/hash.d.ts +1 -1
  222. package/dist/util/hash.d.ts.map +1 -1
  223. package/dist/util/hash.js +1 -15
  224. package/dist/util/hash.js.map +1 -1
  225. package/dist/util/packageMetadata.js +0 -10
  226. package/dist/util/packageMetadata.js.map +1 -1
  227. package/dist/version.d.ts +1 -1
  228. package/dist/version.js +1 -1
  229. package/dist/version.js.map +1 -1
  230. package/dist/vm/ParallelsVm.d.ts.map +1 -1
  231. package/dist/vm/ParallelsVm.js +18 -5
  232. package/dist/vm/ParallelsVm.js.map +1 -1
  233. package/dist/winPackager.d.ts.map +1 -1
  234. package/dist/winPackager.js +3 -0
  235. package/dist/winPackager.js.map +1 -1
  236. package/package.json +8 -8
  237. package/scheme.json +556 -133
  238. package/templates/appx/appxmanifest.xml +1 -1
  239. package/templates/msix/appxmanifest.xml +45 -0
  240. package/templates/nsis/installSection.nsh +14 -0
@@ -1 +1 @@
1
- {"version":3,"file":"wine.js","sourceRoot":"","sources":["../../src/toolsets/wine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACjF,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,MAAM,aAAa,GAAG,6CAA6C,CAAA;AAEnE,MAAM,kBAAkB,GAA2C;IACjE,OAAO,EAAE;QACP,mBAAmB,EAAE,kEAAkE;KACxF;IACD,OAAO,EAAE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C,iBAAiB,EAAE,WAAW,CAAC,CAAA;IAE/D,KAAK,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,yBAAyB,CAAC,oBAAoB,WAAW,+BAA+B,CAAC,EAAE,CAAC,CAAA;QACxG,CAAC;IACH,CAAC;IAED,2FAA2F;IAC3F,IAAI,WAAW,GAAkB,IAAI,CAAA;IACrC,KAAK,MAAM,MAAM,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAA;QACzD,IAAI,MAAM,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5B,WAAW,GAAG,SAAS,CAAA;YACvB,MAAK;QACP,CAAC;IACH,CAAC;IACD,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,IAAI,yBAAyB,CAAC,oBAAoB,WAAW,wDAAwD,CAAC,CAAA;IAC9H,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,CAAA;AAC9C,CAAC","sourcesContent":["import { exists, InvalidConfigurationError, sanitizeDirPath } from \"builder-util\"\nimport * as path from \"path\"\nimport { ToolsetConfig } from \"../configuration.js\"\nimport { downloadBuilderToolset } from \"../util/electronGet.js\"\nimport { getCustomToolsetPath } from \"./custom.js\"\n\nconst githubOrgRepo = \"electron-userland/electron-builder-binaries\"\n\nconst wineToolsChecksums: Record<string, Record<string, string>> = {\n \"0.0.0\": {\n \"wine-4.0.1-mac.7z\": \"1baac808a67975b68b9226beea7b64ad0acc3e598a4b45c25bb5d2ae8cac655e\",\n },\n \"1.0.1\": {\n \"wine-11.0-darwin-x86_64.tar.xz\": \"0a4a43867ef225c70ed8d4198aaba24a55cb0e52e5d67b0ac99563e6351a3c61\",\n \"wine-11.0-linux-x86_64.tar.xz\": \"d8cf95442957b75c07166540142c96d8f7be6a68a572cc656194e7b42e8a0f13\",\n },\n}\n\nexport async function getWineToolset(wine: ToolsetConfig[\"wine\"], resourcesDir: string): Promise<{ execPath: string; env: Record<string, string> }> {\n if (process.platform === \"win32\") {\n throw new InvalidConfigurationError(`Wine toolset is not supported on Windows, but got: ${wine}`)\n }\n\n const defaultEnv = { WINEDEBUG: \"-all,err+all\", WINEDLLOVERRIDES: \"winemenubuilder.exe=d\" }\n\n let toolsetPath: string\n let execSubPath: string\n\n if (typeof wine === \"object\" && wine != null) {\n // Custom toolset — honored on every platform (never overridden by the Linux host-wine fallback below).\n toolsetPath = await getCustomToolsetPath(wine, resourcesDir)\n execSubPath = (await exists(path.join(toolsetPath, \"bin\", \"wine\"))) ? \"bin/wine\" : \"bin/wine64\"\n } else if (process.platform === \"linux\") {\n // Linux ships no portable bundle for string/null configs → fall back to the host wine binary.\n return { execPath: \"wine\", env: defaultEnv }\n } else if (wine === \"1.0.1\") {\n // Explicit opt-in to the bundled wine@1.0.1 (wine 11; arm64 macOS via Rosetta).\n // Not the default yet — request it explicitly via `toolsets.wine = \"1.0.1\"`.\n const file = process.platform === \"darwin\" ? \"wine-11.0-darwin-x86_64.tar.xz\" : \"wine-11.0-linux-x86_64.tar.xz\"\n toolsetPath = await downloadBuilderToolset({\n releaseName: \"wine@1.0.1\",\n filenameWithExt: file,\n checksums: wineToolsChecksums[\"1.0.1\"],\n githubOrgRepo,\n })\n execSubPath = (await exists(path.join(toolsetPath, \"bin\", \"wine\"))) ? \"bin/wine\" : \"bin/wine64\"\n } else {\n // Default (null / undefined) and \"0.0.0\" → legacy wine-4.0.1-mac bundle.\n toolsetPath = await downloadBuilderToolset({\n releaseName: \"wine-4.0.1-mac\",\n filenameWithExt: \"wine-4.0.1-mac.7z\",\n checksums: wineToolsChecksums[\"0.0.0\"],\n githubOrgRepo,\n })\n execSubPath = path.join(\"bin\", \"wine64\")\n }\n\n const { execPath, winePrefix, wineLibPath } = await createWineEnvironment(toolsetPath, execSubPath)\n return {\n execPath,\n env: {\n ...defaultEnv,\n WINEPREFIX: winePrefix,\n DYLD_FALLBACK_LIBRARY_PATH: [wineLibPath, process.env.DYLD_FALLBACK_LIBRARY_PATH].filter(Boolean).join(path.delimiter),\n LD_LIBRARY_PATH: [wineLibPath, process.env.LD_LIBRARY_PATH].filter(Boolean).join(path.delimiter),\n },\n }\n}\n\nasync function createWineEnvironment(toolsetPath: string, execSubPath: string) {\n const sanitizedWinePath = sanitizeDirPath(toolsetPath)\n\n const execPath = path.resolve(sanitizedWinePath, execSubPath)\n const winePrefix = path.resolve(sanitizedWinePath, \"wine-home\")\n\n for (const p of [execPath, winePrefix]) {\n if (!(await exists(p))) {\n throw new InvalidConfigurationError(`Wine toolset at \"${toolsetPath}\" is missing expected path: ${p}`)\n }\n }\n\n // Modern bundles ship a `lib` dir; the legacy wine-4.0.1-mac bundle ships `lib64` instead.\n let wineLibPath: string | null = null\n for (const libDir of [\"lib\", \"lib64\"]) {\n const candidate = path.resolve(sanitizedWinePath, libDir)\n if (await exists(candidate)) {\n wineLibPath = candidate\n break\n }\n }\n if (wineLibPath == null) {\n throw new InvalidConfigurationError(`Wine toolset at \"${toolsetPath}\" is missing expected library directory (lib or lib64)`)\n }\n\n return { execPath, winePrefix, wineLibPath }\n}\n"]}
1
+ {"version":3,"file":"wine.js","sourceRoot":"","sources":["../../src/toolsets/wine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEjF,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,MAAM,aAAa,GAAG,6CAA6C,CAAA;AAEnE,4EAA4E;AAC5E,MAAM,WAA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;IAEtD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAA;IAC7D,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAA;IAE/D,KAAK,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,yBAAyB,CAAC,oBAAoB,WAAW,+BAA+B,CAAC,EAAE,CAAC,CAAA;QACxG,CAAC;IACH,CAAC;IAED,2FAA2F;IAC3F,IAAI,WAAW,GAAkB,IAAI,CAAA;IACrC,KAAK,MAAM,MAAM,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAA;QACzD,IAAI,MAAM,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5B,WAAW,GAAG,SAAS,CAAA;YACvB,MAAK;QACP,CAAC;IACH,CAAC;IACD,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,IAAI,yBAAyB,CAAC,oBAAoB,WAAW,wDAAwD,CAAC,CAAA;IAC9H,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,CAAA;AAC9C,CAAC","sourcesContent":["import { exists, InvalidConfigurationError, sanitizeDirPath } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport * as path from \"path\"\nimport { ToolsetConfig } from \"../configuration.js\"\nimport { downloadBuilderToolset } from \"../util/electronGet.js\"\nimport { getCustomToolsetPath } from \"./custom.js\"\n\nconst githubOrgRepo = \"electron-userland/electron-builder-binaries\"\n\n// Newest wine bundle — selected when the config is unset / null / \"latest\".\nconst WINE_LATEST = \"1.0.1\"\n\nconst wineToolsChecksums: Record<string, Record<string, string>> = {\n \"0.0.0\": {\n \"wine-4.0.1-mac.7z\": \"1baac808a67975b68b9226beea7b64ad0acc3e598a4b45c25bb5d2ae8cac655e\",\n },\n \"1.0.1\": {\n \"wine-11.0-darwin-x86_64.tar.xz\": \"0a4a43867ef225c70ed8d4198aaba24a55cb0e52e5d67b0ac99563e6351a3c61\",\n \"wine-11.0-linux-x86_64.tar.xz\": \"d8cf95442957b75c07166540142c96d8f7be6a68a572cc656194e7b42e8a0f13\",\n },\n}\n\nexport async function getWineToolset(wine: ToolsetConfig[\"wine\"] | Nullish, resourcesDir: string): Promise<{ execPath: string; env: Record<string, string> }> {\n if (process.platform === \"win32\") {\n throw new InvalidConfigurationError(`Wine toolset is not supported on Windows, but got: ${wine}`)\n }\n\n const defaultEnv = { WINEDEBUG: \"-all,err+all\", WINEDLLOVERRIDES: \"winemenubuilder.exe=d\" }\n\n let toolsetPath: string\n let execSubPath: string\n\n if (typeof wine === \"object\" && wine != null) {\n // Custom toolset — honored on every platform (never overridden by the Linux host-wine fallback below).\n toolsetPath = await getCustomToolsetPath(wine, resourcesDir)\n execSubPath = (await exists(path.join(toolsetPath, \"bin\", \"wine\"))) ? \"bin/wine\" : \"bin/wine64\"\n } else if (process.platform === \"linux\") {\n // Linux ships no portable bundle for string/null configs → fall back to the host wine binary.\n return { execPath: \"wine\", env: defaultEnv }\n } else if (wine === \"0.0.0\") {\n // Explicit opt-in to the legacy wine-4.0.1-mac bundle (pre-v27).\n toolsetPath = await downloadBuilderToolset({\n releaseName: \"wine-4.0.1-mac\",\n filenameWithExt: \"wine-4.0.1-mac.7z\",\n checksums: wineToolsChecksums[\"0.0.0\"],\n githubOrgRepo,\n })\n execSubPath = path.join(\"bin\", \"wine64\")\n } else {\n // Default (null / undefined / \"latest\") and explicit \"1.0.1\" → bundled wine@1.0.1\n // (wine 11; arm64 macOS via Rosetta).\n const file = process.platform === \"darwin\" ? \"wine-11.0-darwin-x86_64.tar.xz\" : \"wine-11.0-linux-x86_64.tar.xz\"\n toolsetPath = await downloadBuilderToolset({\n releaseName: `wine@${WINE_LATEST}`,\n filenameWithExt: file,\n checksums: wineToolsChecksums[WINE_LATEST],\n githubOrgRepo,\n })\n execSubPath = (await exists(path.join(toolsetPath, \"bin\", \"wine\"))) ? \"bin/wine\" : \"bin/wine64\"\n }\n\n const { execPath, winePrefix, wineLibPath } = await createWineEnvironment(toolsetPath, execSubPath)\n return {\n execPath,\n env: {\n ...defaultEnv,\n WINEPREFIX: winePrefix,\n DYLD_FALLBACK_LIBRARY_PATH: [wineLibPath, process.env.DYLD_FALLBACK_LIBRARY_PATH].filter(Boolean).join(path.delimiter),\n LD_LIBRARY_PATH: [wineLibPath, process.env.LD_LIBRARY_PATH].filter(Boolean).join(path.delimiter),\n },\n }\n}\n\nasync function createWineEnvironment(toolsetPath: string, execSubPath: string) {\n const sanitizedWinePath = sanitizeDirPath(toolsetPath)\n\n const execPath = path.resolve(sanitizedWinePath, execSubPath)\n const winePrefix = path.resolve(sanitizedWinePath, \"wine-home\")\n\n for (const p of [execPath, winePrefix]) {\n if (!(await exists(p))) {\n throw new InvalidConfigurationError(`Wine toolset at \"${toolsetPath}\" is missing expected path: ${p}`)\n }\n }\n\n // Modern bundles ship a `lib` dir; the legacy wine-4.0.1-mac bundle ships `lib64` instead.\n let wineLibPath: string | null = null\n for (const libDir of [\"lib\", \"lib64\"]) {\n const candidate = path.resolve(sanitizedWinePath, libDir)\n if (await exists(candidate)) {\n wineLibPath = candidate\n break\n }\n }\n if (wineLibPath == null) {\n throw new InvalidConfigurationError(`Wine toolset at \"${toolsetPath}\" is missing expected library directory (lib or lib64)`)\n }\n\n return { execPath, winePrefix, wineLibPath }\n}\n"]}
@@ -3,7 +3,7 @@ import { realpathSync } from "fs";
3
3
  import fsExtra from "fs-extra";
4
4
  import * as path from "path";
5
5
  import asyncPool from "tiny-async-pool";
6
- import { excludedNames } from "../fileMatcher.js";
6
+ import { DEFAULT_EXCLUDED_NAMES } from "../fileMatcher.js";
7
7
  import { FileCopyHelper } from "./AppFileWalker.js";
8
8
  import { resolveFunction } from "./resolve.js";
9
9
  const excludedFiles = new Set([
@@ -17,7 +17,7 @@ const excludedFiles = new Set([
17
17
  "binding.gyp",
18
18
  ".npmignore",
19
19
  "node_gyp_bins",
20
- ].concat(excludedNames.split(",")));
20
+ ].concat(DEFAULT_EXCLUDED_NAMES));
21
21
  const topLevelExcludedFiles = new Set([
22
22
  "karma.conf.js",
23
23
  ".coveralls.yml",
@@ -70,7 +70,7 @@ export class NodeModuleCopyHelper extends FileCopyHelper {
70
70
  }
71
71
  // check if filematcher matches the files array as more important than the default excluded files.
72
72
  const fileMatched = filter != null && filter(dirPath, fsExtra.lstatSync(dirPath));
73
- if (!fileMatched || !forceIncluded || !!this.packager.config.disableDefaultIgnoredFiles) {
73
+ if (!fileMatched || !forceIncluded) {
74
74
  for (const ext of nodeModuleExcludedExts) {
75
75
  if (name.endsWith(ext)) {
76
76
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"NodeModuleCopyHelper.js","sourceRoot":"","sources":["../../src/util/NodeModuleCopyHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AACjC,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,aAAa,EAAe,MAAM,mBAAmB,CAAA;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,MAAM,aAAa,GAAG,IAAI,GAAG,CAC3B;IACE,WAAW;IACX,cAAc,CAAC,0BAA0B;IACzC,cAAc;IACd,WAAW;IACX,cAAc;IACd,cAAc;IACd,WAAW;IACX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"\nimport { realpathSync } from \"fs\"\nimport fsExtra from \"fs-extra\"\nimport * as path from \"path\"\nimport asyncPool from \"tiny-async-pool\"\nimport { excludedNames, FileMatcher } from \"../fileMatcher.js\"\nimport { PlatformPackager } from \"../platformPackager.js\"\nimport { FileCopyHelper } from \"./AppFileWalker.js\"\nimport { NodeModuleInfo } from \"../node-module-collector/types.js\"\nimport { resolveFunction } from \"./resolve.js\"\n\nconst excludedFiles = new Set(\n [\n \".DS_Store\",\n \"node_modules\" /* already in the queue */,\n \"CHANGELOG.md\",\n \"ChangeLog\",\n \"changelog.md\",\n \"Changelog.md\",\n \"Changelog\",\n \"binding.gyp\",\n \".npmignore\",\n \"node_gyp_bins\",\n ].concat(excludedNames.split(\",\"))\n)\n\nconst topLevelExcludedFiles = new Set([\n \"karma.conf.js\",\n \".coveralls.yml\",\n \"README.md\",\n \"readme.markdown\",\n \"README\",\n \"readme.md\",\n \"Readme.md\",\n \"Readme\",\n \"readme\",\n \"test\",\n \"tests\",\n \"__tests__\",\n \"powered-test\",\n \"example\",\n \"examples\",\n \".bin\",\n])\n\n/** @internal */\nexport class NodeModuleCopyHelper extends FileCopyHelper {\n constructor(matcher: FileMatcher, packager: PlatformPackager<any>) {\n super(matcher, matcher.isEmpty() ? null : matcher.createFilter(), packager)\n }\n\n async collectNodeModules(moduleInfo: NodeModuleInfo, nodeModuleExcludedExts: Array<string>, destination: string): Promise<Array<string>> {\n const filter = this.filter\n const metadata = this.metadata\n\n const onNodeModuleFile = await resolveFunction(this.packager.appInfo.type, this.packager.config.onNodeModuleFile, \"onNodeModuleFile\", await this.packager.getWorkspaceRoot())\n\n const result: Array<string | undefined> = []\n const queue: Array<string> = []\n const emptyDirs: Set<string> = new Set()\n const symlinkFiles: Map<string, number> = new Map()\n const tmpPath = moduleInfo.dir\n const moduleName = moduleInfo.name\n queue.length = 1\n // The path should be corrected in Windows that when the moduleName is Scoped packages named.\n const depPath = path.normalize(tmpPath)\n queue[0] = depPath\n\n while (queue.length > 0) {\n const dirPath = queue.pop()!\n\n const childNames = await fsExtra.readdir(dirPath)\n childNames.sort()\n\n const isTopLevel = dirPath === depPath\n const dirs: Array<string> = []\n // our handler is async, but we should add sorted files, so, we add file to result not in the mapper, but after map\n const sortedFilePaths = await asyncPool(MAX_FILE_REQUESTS, childNames, async name => {\n const filePath = path.join(dirPath, name)\n\n const forceIncluded = onNodeModuleFile != null && !!onNodeModuleFile(filePath)\n\n if (excludedFiles.has(name) || name.startsWith(\"._\")) {\n return null\n }\n\n // check if filematcher matches the files array as more important than the default excluded files.\n const fileMatched = filter != null && filter(dirPath, fsExtra.lstatSync(dirPath))\n if (!fileMatched || !forceIncluded || !!this.packager.config.disableDefaultIgnoredFiles) {\n for (const ext of nodeModuleExcludedExts) {\n if (name.endsWith(ext)) {\n return null\n }\n }\n\n // noinspection SpellCheckingInspection\n if (isTopLevel && (topLevelExcludedFiles.has(name) || (moduleName === \"libui-node\" && (name === \"build\" || name === \"docs\" || name === \"src\")))) {\n return null\n }\n\n if (dirPath.endsWith(\"build\")) {\n if (name === \"gyp-mac-tool\" || name === \"Makefile\" || name.endsWith(\".mk\") || name.endsWith(\".gypi\") || name.endsWith(\".Makefile\")) {\n return null\n }\n } else if (dirPath.endsWith(\"Release\") && (name === \".deps\" || name === \"obj.target\")) {\n return null\n } else if (name === \"src\" && (dirPath.endsWith(\"keytar\") || dirPath.endsWith(\"keytar-prebuild\"))) {\n return null\n } else if (dirPath.endsWith(\"lzma-native\") && (name === \"build\" || name === \"deps\")) {\n return null\n }\n }\n\n return fsExtra.lstat(filePath).then((stat: FilterStats) => {\n stat.moduleName = moduleName\n stat.moduleRootPath = destination\n stat.moduleFullFilePath = path.join(destination, path.relative(depPath, filePath))\n if (filter != null && !filter(filePath, stat)) {\n return null\n }\n\n if (!stat.isDirectory()) {\n metadata.set(filePath, stat)\n }\n const consumerResult = this.handleFile(filePath, dirPath, stat)\n if (consumerResult == null) {\n if (stat.isDirectory()) {\n dirs.push(name)\n return null\n } else {\n return filePath\n }\n } else {\n return consumerResult.then(it => {\n // asarUtil can return modified stat (symlink handling)\n if ((it == null ? stat : it).isDirectory()) {\n dirs.push(name)\n return null\n } else {\n return filePath\n }\n })\n }\n })\n })\n\n let isEmpty = true\n for (const child of sortedFilePaths) {\n if (child != null) {\n result.push(child)\n if (this.metadata.get(child)?.isSymbolicLink()) {\n symlinkFiles.set(child, result.length - 1)\n }\n isEmpty = false\n }\n }\n\n if (isEmpty) {\n emptyDirs.add(dirPath)\n }\n\n dirs.sort()\n for (const child of dirs) {\n queue.push(dirPath + path.sep + child)\n }\n }\n\n for (const [file, index] of symlinkFiles) {\n const resolvedPath = realpathSync(file)\n if (emptyDirs.has(resolvedPath)) {\n // delete symlink file if target is a empty dir\n result[index] = undefined\n }\n }\n return result.filter((it): it is string => it !== undefined)\n }\n}\n"]}
1
+ {"version":3,"file":"NodeModuleCopyHelper.js","sourceRoot":"","sources":["../../src/util/NodeModuleCopyHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AACjC,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,sBAAsB,EAAe,MAAM,mBAAmB,CAAA;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,MAAM,aAAa,GAAG,IAAI,GAAG,CAC3B;IACE,WAAW;IACX,cAAc,CAAC,0BAA0B;IACzC,cAAc;IACd,WAAW;IACX,cAAc;IACd,cAAc;IACd,WAAW;IACX,aAAa;IACb,YAAY;IACZ,eAAe;CAChB,CAAC,MAAM,CAAC,sBAAsB,CAAC,CACjC,CAAA;AAED,MAAM,qBAAqB,GAAG,I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,IAAI,EAAE,CAAC;oBAClB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;oBAClB,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,cAAc,EAAE,EAAE,CAAC;wBAC/C,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;oBAC5C,CAAC;oBACD,OAAO,GAAG,KAAK,CAAA;gBACjB,CAAC;YACH,CAAC;YAED,IAAI,OAAO,EAAE,CAAC;gBACZ,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACxB,CAAC;YAED,IAAI,CAAC,IAAI,EAAE,CAAA;YACX,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;gBACzB,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,CAAA;YACxC,CAAC;QACH,CAAC;QAED,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,YAAY,EAAE,CAAC;YACzC,MAAM,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;YACvC,IAAI,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;gBAChC,+CAA+C;gBAC/C,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS,CAAA;YAC3B,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAgB,EAAE,CAAC,EAAE,KAAK,SAAS,CAAC,CAAA;IAC9D,CAAC;CACF","sourcesContent":["import { FilterStats, MAX_FILE_REQUESTS } from \"builder-util\"\nimport { realpathSync } from \"fs\"\nimport fsExtra from \"fs-extra\"\nimport * as path from \"path\"\nimport asyncPool from \"tiny-async-pool\"\nimport { DEFAULT_EXCLUDED_NAMES, FileMatcher } from \"../fileMatcher.js\"\nimport { PlatformPackager } from \"../platformPackager.js\"\nimport { FileCopyHelper } from \"./AppFileWalker.js\"\nimport { NodeModuleInfo } from \"../node-module-collector/types.js\"\nimport { resolveFunction } from \"./resolve.js\"\n\nconst excludedFiles = new Set(\n [\n \".DS_Store\",\n \"node_modules\" /* already in the queue */,\n \"CHANGELOG.md\",\n \"ChangeLog\",\n \"changelog.md\",\n \"Changelog.md\",\n \"Changelog\",\n \"binding.gyp\",\n \".npmignore\",\n \"node_gyp_bins\",\n ].concat(DEFAULT_EXCLUDED_NAMES)\n)\n\nconst topLevelExcludedFiles = new Set([\n \"karma.conf.js\",\n \".coveralls.yml\",\n \"README.md\",\n \"readme.markdown\",\n \"README\",\n \"readme.md\",\n \"Readme.md\",\n \"Readme\",\n \"readme\",\n \"test\",\n \"tests\",\n \"__tests__\",\n \"powered-test\",\n \"example\",\n \"examples\",\n \".bin\",\n])\n\n/** @internal */\nexport class NodeModuleCopyHelper extends FileCopyHelper {\n constructor(matcher: FileMatcher, packager: PlatformPackager<any>) {\n super(matcher, matcher.isEmpty() ? null : matcher.createFilter(), packager)\n }\n\n async collectNodeModules(moduleInfo: NodeModuleInfo, nodeModuleExcludedExts: Array<string>, destination: string): Promise<Array<string>> {\n const filter = this.filter\n const metadata = this.metadata\n\n const onNodeModuleFile = await resolveFunction(this.packager.appInfo.type, this.packager.config.onNodeModuleFile, \"onNodeModuleFile\", await this.packager.getWorkspaceRoot())\n\n const result: Array<string | undefined> = []\n const queue: Array<string> = []\n const emptyDirs: Set<string> = new Set()\n const symlinkFiles: Map<string, number> = new Map()\n const tmpPath = moduleInfo.dir\n const moduleName = moduleInfo.name\n queue.length = 1\n // The path should be corrected in Windows that when the moduleName is Scoped packages named.\n const depPath = path.normalize(tmpPath)\n queue[0] = depPath\n\n while (queue.length > 0) {\n const dirPath = queue.pop()!\n\n const childNames = await fsExtra.readdir(dirPath)\n childNames.sort()\n\n const isTopLevel = dirPath === depPath\n const dirs: Array<string> = []\n // our handler is async, but we should add sorted files, so, we add file to result not in the mapper, but after map\n const sortedFilePaths = await asyncPool(MAX_FILE_REQUESTS, childNames, async name => {\n const filePath = path.join(dirPath, name)\n\n const forceIncluded = onNodeModuleFile != null && !!onNodeModuleFile(filePath)\n\n if (excludedFiles.has(name) || name.startsWith(\"._\")) {\n return null\n }\n\n // check if filematcher matches the files array as more important than the default excluded files.\n const fileMatched = filter != null && filter(dirPath, fsExtra.lstatSync(dirPath))\n if (!fileMatched || !forceIncluded) {\n for (const ext of nodeModuleExcludedExts) {\n if (name.endsWith(ext)) {\n return null\n }\n }\n\n // noinspection SpellCheckingInspection\n if (isTopLevel && (topLevelExcludedFiles.has(name) || (moduleName === \"libui-node\" && (name === \"build\" || name === \"docs\" || name === \"src\")))) {\n return null\n }\n\n if (dirPath.endsWith(\"build\")) {\n if (name === \"gyp-mac-tool\" || name === \"Makefile\" || name.endsWith(\".mk\") || name.endsWith(\".gypi\") || name.endsWith(\".Makefile\")) {\n return null\n }\n } else if (dirPath.endsWith(\"Release\") && (name === \".deps\" || name === \"obj.target\")) {\n return null\n } else if (name === \"src\" && (dirPath.endsWith(\"keytar\") || dirPath.endsWith(\"keytar-prebuild\"))) {\n return null\n } else if (dirPath.endsWith(\"lzma-native\") && (name === \"build\" || name === \"deps\")) {\n return null\n }\n }\n\n return fsExtra.lstat(filePath).then((stat: FilterStats) => {\n stat.moduleName = moduleName\n stat.moduleRootPath = destination\n stat.moduleFullFilePath = path.join(destination, path.relative(depPath, filePath))\n if (filter != null && !filter(filePath, stat)) {\n return null\n }\n\n if (!stat.isDirectory()) {\n metadata.set(filePath, stat)\n }\n const consumerResult = this.handleFile(filePath, dirPath, stat)\n if (consumerResult == null) {\n if (stat.isDirectory()) {\n dirs.push(name)\n return null\n } else {\n return filePath\n }\n } else {\n return consumerResult.then(it => {\n // asarUtil can return modified stat (symlink handling)\n if ((it == null ? stat : it).isDirectory()) {\n dirs.push(name)\n return null\n } else {\n return filePath\n }\n })\n }\n })\n })\n\n let isEmpty = true\n for (const child of sortedFilePaths) {\n if (child != null) {\n result.push(child)\n if (this.metadata.get(child)?.isSymbolicLink()) {\n symlinkFiles.set(child, result.length - 1)\n }\n isEmpty = false\n }\n }\n\n if (isEmpty) {\n emptyDirs.add(dirPath)\n }\n\n dirs.sort()\n for (const child of dirs) {\n queue.push(dirPath + path.sep + child)\n }\n }\n\n for (const [file, index] of symlinkFiles) {\n const resolvedPath = realpathSync(file)\n if (emptyDirs.has(resolvedPath)) {\n // delete symlink file if target is a empty dir\n result[index] = undefined\n }\n }\n return result.filter((it): it is string => it !== undefined)\n }\n}\n"]}
@@ -1,8 +1,11 @@
1
1
  import { FileTransformer } from "builder-util";
2
2
  import { Stats } from "fs";
3
3
  import { FileMatcher } from "../fileMatcher.js";
4
+ import { PM } from "../node-module-collector/index.js";
5
+ import { ModuleManager } from "../node-module-collector/moduleManager.js";
4
6
  import { Packager } from "../packager.js";
5
7
  import { PlatformPackager } from "../platformPackager.js";
8
+ import { NodeModuleInfo } from "../node-module-collector/types.js";
6
9
  export declare function getDestinationPath(file: string, fileSet: ResolvedFileSet): string;
7
10
  export declare function copyAppFiles(fileSet: ResolvedFileSet, packager: Packager, transformer: FileTransformer): Promise<void>;
8
11
  export interface ResolvedFileSet {
@@ -14,4 +17,40 @@ export interface ResolvedFileSet {
14
17
  }
15
18
  export declare function transformFiles(transformer: FileTransformer, fileSet: ResolvedFileSet): Promise<void>;
16
19
  export declare function computeFileSets(matchers: Array<FileMatcher>, transformer: FileTransformer | null, platformPackager: PlatformPackager<any>): Promise<Array<ResolvedFileSet>>;
20
+ type CollectedNodeModules = {
21
+ nodeModules: NodeModuleInfo[];
22
+ logSummary: ModuleManager["logSummary"];
23
+ };
24
+ /** Runs a single package-manager collector against a single directory. */
25
+ type CollectorRunner = (pm: PM, dir: string) => Promise<CollectedNodeModules>;
26
+ /**
27
+ * Determines whether a collected module tree actually describes the package being built.
28
+ *
29
+ * A package-manager `list` invocation can resolve to the wrong project root — most notably when
30
+ * electron-builder is run from a workspace sub-package whose dependencies are hoisted to the
31
+ * workspace root. In that case the collector returns a non-empty but unrelated tree. Accepting it
32
+ * would suppress the manual-traversal fallback that resolves the correct modules, so we need to
33
+ * tell a matching collection from a mismatched one.
34
+ *
35
+ * A collection matches when at least one of the package's declared external (registry-installed,
36
+ * non-`workspace:`/`file:`/`link:`/`portal:`) production dependencies is present at the top level —
37
+ * those direct dependencies are always hoisted to the top level of a correct collection. When the
38
+ * package declares no external production dependencies there is nothing to validate against, so any
39
+ * non-empty collection is accepted.
40
+ */
41
+ export declare function collectionMatchesAppDependencies(nodeModules: NodeModuleInfo[], dependencies: Record<string, string> | undefined): boolean;
42
+ /**
43
+ * Walks the candidate (package-manager, directory) combinations and returns the first collection
44
+ * that both contains modules and matches the package being built (see
45
+ * {@link collectionMatchesAppDependencies}). A non-empty collection that does NOT match — e.g. a
46
+ * workspace-root tree returned for a sub-package — is retained only as a last-resort fallback so a
47
+ * later approach (notably {@link PM.TRAVERSAL}) can supply the correct modules.
48
+ */
49
+ export declare function resolveFirstMatchingCollection(options: {
50
+ pmApproaches: PM[];
51
+ searchDirectories: string[];
52
+ dependencies: Record<string, string> | undefined;
53
+ run: CollectorRunner;
54
+ }): Promise<CollectedNodeModules | undefined>;
55
+ export {};
17
56
  //# sourceMappingURL=appFileCopier.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"appFileCopier.d.ts","sourceRoot":"","sources":["../../src/util/appFileCopier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,eAAe,EAAmE,MAAM,cAAc,CAAA;AACnJ,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAA;AAO1B,OAAO,EAAgB,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAG7D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAMzD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,UAYxE;AAED,wBAAsB,YAAY,CAAC,OAAO,EA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AA;IAClB,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;IAChD,GAAG,EAAE,eAAe,CAAA;CACrB,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAqB5C"}
@@ -1,11 +1,12 @@
1
1
  import { AsyncTaskManager, FileCopier, isEmptyOrSpaces, log, MAX_FILE_REQUESTS, statOrNull, walk } from "builder-util";
2
+ import { DEFAULT_IGNORED_PRODUCTION_DEPENDENCIES } from "../configuration.js";
2
3
  import fsExtra from "fs-extra";
3
4
  import { mkdir, readlink } from "fs/promises";
4
5
  import * as path from "path";
5
6
  import asyncPool from "tiny-async-pool";
6
7
  import { isLibOrExe } from "../asar/unpackDetector.js";
7
8
  import { Platform } from "../core.js";
8
- import { excludedExts, FileMatcher } from "../fileMatcher.js";
9
+ import { DEFAULT_EXCLUDED_EXTENSIONS, FileMatcher } from "../fileMatcher.js";
9
10
  import { getCollectorByPackageManager, PM } from "../node-module-collector/index.js";
10
11
  import { logMessageLevelByKey } from "../node-module-collector/moduleManager.js";
11
12
  import { AppFileWalker } from "./AppFileWalker.js";
@@ -110,7 +111,7 @@ export async function computeFileSets(matchers, transformer, platformPackager) {
110
111
  }
111
112
  function getNodeModuleExcludedExts(platformPackager) {
112
113
  // do not exclude *.h files (https://github.com/electron-userland/electron-builder/issues/2852)
113
- const result = [".o", ".obj"].concat(excludedExts.split(",").map(it => `.${it}`));
114
+ const result = DEFAULT_EXCLUDED_EXTENSIONS.map(it => `.${it}`);
114
115
  if (platformPackager.config.includePdb !== true) {
115
116
  result.push(".pdb");
116
117
  }
@@ -136,6 +137,10 @@ export async function computeNodeModuleFileSets(platformPackager, mainMatcher, a
136
137
  let index = 0;
137
138
  const NODE_MODULES = "node_modules";
138
139
  const collectNodeModules = async (dep, destination) => {
140
+ // Ignore excluded dependencies.
141
+ if (dep.excluded) {
142
+ return;
143
+ }
139
144
  const source = dep.dir;
140
145
  const matcher = new FileMatcher(source, destination, mainMatcher.macroExpander, mainMatcher.patterns);
141
146
  const copier = new NodeModuleCopyHelper(matcher, platformPackager);
@@ -154,33 +159,86 @@ export async function computeNodeModuleFileSets(platformPackager, mainMatcher, a
154
159
  }
155
160
  return result;
156
161
  }
157
- async function collectNodeModulesWithLogging(platformPackager, arch) {
158
- const { tempDirManager, appDir, projectDir } = platformPackager;
159
- let deps = undefined;
160
- // Drop packages whose `package.json` `cpu`/`os` is incompatible with the target arch/platform while
161
- // collecting (e.g. exclude `@esbuild/darwin-arm64` from the x64 slice). See NodeModulesCollector.
162
- // `null` arch (universal slices) disables the filter so both slices stay symmetric for the merge.
163
- const archFilter = arch == null ? undefined : { cpu: archToNodeCpu(arch), os: platformPackager.platform.nodeName };
164
- const searchDirectories = Array.from(new Set([appDir, projectDir, await platformPackager.getWorkspaceRoot()])).filter((it) => isEmptyOrSpaces(it) === false);
165
- const pmApproaches = [await platformPackager.getPackageManager(), PM.TRAVERSAL];
162
+ // `workspace:`/`file:`/`link:`/`portal:` dependencies are symlinked into place rather than
163
+ // installed as standalone, hoistable packages, so they may legitimately be absent from a
164
+ // collected tree and cannot be used to validate it.
165
+ const LOCAL_DEPENDENCY_SPEC = /^(?:workspace|file|link|portal):/;
166
+ /**
167
+ * Determines whether a collected module tree actually describes the package being built.
168
+ *
169
+ * A package-manager `list` invocation can resolve to the wrong project root — most notably when
170
+ * electron-builder is run from a workspace sub-package whose dependencies are hoisted to the
171
+ * workspace root. In that case the collector returns a non-empty but unrelated tree. Accepting it
172
+ * would suppress the manual-traversal fallback that resolves the correct modules, so we need to
173
+ * tell a matching collection from a mismatched one.
174
+ *
175
+ * A collection matches when at least one of the package's declared external (registry-installed,
176
+ * non-`workspace:`/`file:`/`link:`/`portal:`) production dependencies is present at the top level —
177
+ * those direct dependencies are always hoisted to the top level of a correct collection. When the
178
+ * package declares no external production dependencies there is nothing to validate against, so any
179
+ * non-empty collection is accepted.
180
+ */
181
+ export function collectionMatchesAppDependencies(nodeModules, dependencies) {
182
+ const requiredExternalDeps = Object.entries(dependencies ?? {})
183
+ .filter(([, spec]) => !LOCAL_DEPENDENCY_SPEC.test(spec))
184
+ .map(([name]) => name);
185
+ if (requiredExternalDeps.length === 0) {
186
+ return true;
187
+ }
188
+ const collected = new Set(nodeModules.map(it => it.name));
189
+ return requiredExternalDeps.some(name => collected.has(name));
190
+ }
191
+ /**
192
+ * Walks the candidate (package-manager, directory) combinations and returns the first collection
193
+ * that both contains modules and matches the package being built (see
194
+ * {@link collectionMatchesAppDependencies}). A non-empty collection that does NOT match — e.g. a
195
+ * workspace-root tree returned for a sub-package — is retained only as a last-resort fallback so a
196
+ * later approach (notably {@link PM.TRAVERSAL}) can supply the correct modules.
197
+ */
198
+ export async function resolveFirstMatchingCollection(options) {
199
+ const { pmApproaches, searchDirectories, dependencies, run } = options;
200
+ let fallback;
166
201
  for (const pm of pmApproaches) {
167
202
  for (const dir of searchDirectories) {
168
203
  log.info({ pm, searchDir: dir }, "searching for node modules");
169
- const collector = getCollectorByPackageManager(pm, dir, tempDirManager);
170
- deps = await collector.getNodeModules({ packageName: platformPackager.nodePackageName, archFilter });
171
- if (deps.nodeModules.length > 0) {
172
- break;
204
+ const deps = await run(pm, dir);
205
+ if (deps.nodeModules.length === 0) {
206
+ log.info({ pm, searchDir: dir }, "no node modules found in collection, trying next search directory");
207
+ continue;
173
208
  }
174
- const attempt = searchDirectories.indexOf(dir);
175
- if (attempt < searchDirectories.length - 1) {
176
- log.info({ searchDir: dir, attempt }, "no node modules found in collection, trying next search directory");
209
+ if (collectionMatchesAppDependencies(deps.nodeModules, dependencies)) {
210
+ log.debug({ pm, searchDir: dir, depCount: deps.nodeModules.length }, "collected node modules");
211
+ return deps;
177
212
  }
178
- }
179
- if (deps?.nodeModules?.length) {
180
- log.debug({ pm, nodeModules: deps.nodeModules }, "collected node modules");
181
- break;
213
+ log.info({ pm, searchDir: dir }, "collected node modules do not match the target package, trying next search directory/approach");
214
+ fallback ??= deps;
182
215
  }
183
216
  }
217
+ return fallback;
218
+ }
219
+ /** @internal */
220
+ export async function collectNodeModulesWithLogging(platformPackager, arch) {
221
+ const { tempDirManager, appDir, projectDir } = platformPackager;
222
+ // Drop packages whose `package.json` `cpu`/`os` is incompatible with the target arch/platform while
223
+ // collecting (e.g. exclude `@esbuild/darwin-arm64` from the x64 slice). See NodeModulesCollector.
224
+ // `null` arch (universal slices) disables the filter so both slices stay symmetric for the merge.
225
+ const archFilter = arch == null ? undefined : { cpu: archToNodeCpu(arch), os: platformPackager.platform.nodeName };
226
+ const searchDirectories = Array.from(new Set([appDir, projectDir, await platformPackager.getWorkspaceRoot()])).filter((it) => isEmptyOrSpaces(it) === false);
227
+ const pmApproaches = [await platformPackager.getPackageManager(), PM.TRAVERSAL];
228
+ // The default-ignored packages are excluded from the copied `node_modules` — together with any
229
+ // transitive dependency they alone require — because electron-builder already provides them another
230
+ // way (the Electron runtime is embedded separately), so copying them would be redundant. They remain
231
+ // valid production dependencies for tooling such as SBOM generation. See NodeModulesCollector.getNodeModules.
232
+ const configuredIgnored = platformPackager.config.ignoredProductionDependencies;
233
+ const ignoredDependencies = configuredIgnored == null ? DEFAULT_IGNORED_PRODUCTION_DEPENDENCIES : configuredIgnored;
234
+ // Validate against the as-declared (pre-extraMetadata) production dependencies so a configured
235
+ // `extraMetadata.dependencies` entry that isn't installed cannot reject a correct collection.
236
+ const deps = await resolveFirstMatchingCollection({
237
+ pmApproaches,
238
+ searchDirectories,
239
+ dependencies: platformPackager.originalMetadata.dependencies,
240
+ run: (pm, dir) => getCollectorByPackageManager(pm, dir, tempDirManager).getNodeModules({ packageName: platformPackager.nodePackageName, archFilter, ignoredDependencies }),
241
+ });
184
242
  if (!deps?.nodeModules?.length) {
185
243
  log.warn({ searchDirectories: searchDirectories.map(it => log.filePath(it)) }, "no node modules returned while searching directories");
186
244
  return [];
@@ -190,6 +248,14 @@ async function collectNodeModulesWithLogging(platformPackager, arch) {
190
248
  const logLevel = logMessageLevelByKey[errorMessage] || "debug";
191
249
  log[logLevel]({ dependencies }, errorMessage);
192
250
  }
251
+ // Tripwire: the default-ignored packages are excluded because electron-builder already provides them
252
+ // (e.g. the embedded Electron runtime), so a copy in `node_modules` is redundant. They only reach this
253
+ // point unflagged when a user has removed them from `ignoredProductionDependencies`; record any that
254
+ // are therefore about to be copied (present but not marked `excluded`) so the summary below warns.
255
+ const bundledDefaultIgnored = deps.nodeModules.filter(it => !it.excluded && DEFAULT_IGNORED_PRODUCTION_DEPENDENCIES.includes(it.name)).map(it => it.name);
256
+ if (bundledDefaultIgnored.length > 0) {
257
+ log.warn({ dependencies: bundledDefaultIgnored }, "copied dependencies that shouldn't be needed, see ignoredProductionDependencies");
258
+ }
193
259
  return deps.nodeModules;
194
260
  }
195
261
  //# sourceMappingURL=appFileCopier.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"appFileCopier.js","sourceRoot":"","sources":["../../src/util/appFileCopier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,gBAAgB,EAAE,UAAU,EAAmB,eAAe,EAAQ,GAAG,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnJ,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAE,4BAA4B,EAAE,EAAE,EAAE,MAAM,mCAAmC,CAAA;AACpF,OAAO,EAAmB,oBAAoB,EAAiB,MAAM,2CAA2C,CAAA;AAGhH,OAAO,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zB,CAAC","sourcesContent":["import { Arch, AsyncTaskManager, FileCopier, FileTransformer, isEmptyOrSpaces, Link, log, MAX_FILE_REQUESTS, statOrNull, walk } from \"builder-util\"\nimport { Stats } from \"fs\"\nimport fsExtra from \"fs-extra\"\nimport { mkdir, readlink } from \"fs/promises\"\nimport * as path from \"path\"\nimport asyncPool from \"tiny-async-pool\"\nimport { isLibOrExe } from \"../asar/unpackDetector.js\"\nimport { Platform } from \"../core.js\"\nimport { excludedExts, FileMatcher } from \"../fileMatcher.js\"\nimport { getCollectorByPackageManager, PM } from \"../node-module-collector/index.js\"\nimport { LogMessageByKey, logMessageLevelByKey, ModuleManager } from \"../node-module-collector/moduleManager.js\"\nimport { Packager } from \"../packager.js\"\nimport { PlatformPackager } from \"../platformPackager.js\"\nimport { AppFileWalker } from \"./AppFileWalker.js\"\nimport { NodeModuleCopyHelper } from \"./NodeModuleCopyHelper.js\"\nimport { NodeModuleInfo } from \"../node-module-collector/types.js\"\nimport { archToNodeCpu } from \"./archCompatibility.js\"\n\nexport function getDestinationPath(file: string, fileSet: ResolvedFileSet) {\n if (file === fileSet.src) {\n return fileSet.destination\n }\n\n const src = fileSet.src\n const dest = fileSet.destination\n // get node_modules path relative to src and then append to dest\n if (file.startsWith(src)) {\n return path.join(dest, path.relative(src, file))\n }\n return dest\n}\n\nexport async function copyAppFiles(fileSet: ResolvedFileSet, packager: Packager, transformer: FileTransformer) {\n const metadata = fileSet.metadata\n // search auto unpacked dir\n const taskManager = new AsyncTaskManager(packager.cancellationToken)\n const createdParentDirs = new Set<string>()\n\n const fileCopier = new FileCopier(file => {\n return !isLibOrExe(file)\n }, transformer)\n const links: Array<Link> = []\n for (let i = 0, n = fileSet.files.length; i < n; i++) {\n const sourceFile = fileSet.files[i]\n const stat = metadata.get(sourceFile)\n if (stat == null) {\n // dir\n continue\n }\n\n const destinationFile = getDestinationPath(sourceFile, fileSet)\n if (stat.isSymbolicLink()) {\n links.push({ file: destinationFile, link: await readlink(sourceFile) })\n continue\n }\n\n const fileParent = path.dirname(destinationFile)\n if (!createdParentDirs.has(fileParent)) {\n createdParentDirs.add(fileParent)\n await mkdir(fileParent, { recursive: true })\n }\n\n taskManager.addTask(fileCopier.copy(sourceFile, destinationFile, stat))\n if (taskManager.tasks.length > MAX_FILE_REQUESTS) {\n await taskManager.awaitTasks()\n }\n }\n\n if (taskManager.tasks.length > 0) {\n await taskManager.awaitTasks()\n }\n\n await asyncPool(MAX_FILE_REQUESTS, links, it => fsExtra.ensureSymlink(it.link, it.file))\n}\n\n// os path separator is used\nexport interface ResolvedFileSet {\n src: string\n destination: string\n\n files: Array<string>\n metadata: Map<string, Stats>\n transformedFiles?: Map<number, string | Buffer> | null\n}\n\n// used only for ASAR, if no asar, file transformed on the fly\nexport async function transformFiles(transformer: FileTransformer, fileSet: ResolvedFileSet): Promise<void> {\n if (transformer == null) {\n return\n }\n\n let transformedFiles = fileSet.transformedFiles\n if (fileSet.transformedFiles == null) {\n transformedFiles = new Map()\n fileSet.transformedFiles = transformedFiles\n }\n\n const metadata = fileSet.metadata\n const filesPromise = fileSet.files.map(async (it, index) => {\n const fileStat = metadata.get(it)\n if (fileStat == null || !fileStat.isFile()) {\n return\n }\n\n const transformedValue = transformer(it)\n if (transformedValue == null) {\n return\n }\n\n if (typeof transformedValue === \"object\" && \"then\" in transformedValue) {\n return (transformedValue as Promise<any>).then(it => {\n if (it != null) {\n transformedFiles!.set(index, it)\n }\n return\n })\n }\n transformedFiles!.set(index, transformedValue as string | Buffer)\n return\n })\n // `asyncPool` doesn't provide `index` in it's handler, so we `map` first before using it\n await asyncPool(MAX_FILE_REQUESTS, filesPromise, promise => promise)\n}\n\nexport async function computeFileSets(matchers: Array<FileMatcher>, transformer: FileTransformer | null, platformPackager: PlatformPackager<any>): Promise<Array<ResolvedFileSet>> {\n const fileSets: Array<ResolvedFileSet> = []\n\n for (const matcher of matchers) {\n const fileWalker = new AppFileWalker(matcher, platformPackager)\n\n const fromStat = await statOrNull(matcher.from)\n if (fromStat == null) {\n log.debug({ directory: matcher.from, reason: \"doesn't exist\" }, `skipped copying`)\n continue\n }\n\n const files = await walk(matcher.from, fileWalker.filter, fileWalker)\n const metadata = fileWalker.metadata\n fileSets.push(validateFileSet({ src: matcher.from, files, metadata, destination: matcher.to }))\n }\n\n return fileSets\n}\n\nfunction getNodeModuleExcludedExts(platformPackager: PlatformPackager<any>) {\n // do not exclude *.h files (https://github.com/electron-userland/electron-builder/issues/2852)\n const result = [\".o\", \".obj\"].concat(excludedExts.split(\",\").map(it => `.${it}`))\n if (platformPackager.config.includePdb !== true) {\n result.push(\".pdb\")\n }\n if (platformPackager.platform !== Platform.WINDOWS) {\n // https://github.com/electron-userland/electron-builder/issues/1738\n result.push(\".dll\")\n result.push(\".exe\")\n }\n return result\n}\n\nfunction validateFileSet(fileSet: ResolvedFileSet): ResolvedFileSet {\n if (fileSet.src == null || fileSet.src.length === 0) {\n throw new Error(\"fileset src is empty\")\n }\n return fileSet\n}\n\n/** @internal */\nexport async function computeNodeModuleFileSets(\n platformPackager: PlatformPackager<any>,\n mainMatcher: FileMatcher,\n arch: Arch,\n applyArchFilter = true\n): Promise<Array<ResolvedFileSet>> {\n const deps = await collectNodeModulesWithLogging(platformPackager, applyArchFilter ? arch : null)\n\n const nodeModuleExcludedExts = getNodeModuleExcludedExts(platformPackager)\n // serial execution because copyNodeModules is concurrent and so, no need to increase queue/pressure\n const result = new Array<ResolvedFileSet>()\n let index = 0\n const NODE_MODULES = \"node_modules\"\n\n const collectNodeModules = async (dep: NodeModuleInfo, destination: string) => {\n const source = dep.dir\n const matcher = new FileMatcher(source, destination, mainMatcher.macroExpander, mainMatcher.patterns)\n const copier = new NodeModuleCopyHelper(matcher, platformPackager)\n const files = await copier.collectNodeModules(dep, nodeModuleExcludedExts, path.relative(mainMatcher.to, destination))\n result[index++] = validateFileSet({ src: source, destination, files, metadata: copier.metadata })\n\n log.debug({ dep: dep.name, from: log.filePath(source), to: log.filePath(destination), filesCount: files.length }, \"identified module\")\n\n if (dep.dependencies) {\n for (const c of dep.dependencies) {\n await collectNodeModules(c, path.join(destination, NODE_MODULES, c.name))\n }\n }\n }\n\n for (const dep of deps) {\n const destination = path.join(mainMatcher.to, NODE_MODULES, dep.name)\n await collectNodeModules(dep, destination)\n }\n return result\n}\n\nasync function collectNodeModulesWithLogging(platformPackager: PlatformPackager<any>, arch: Arch | null) {\n const { tempDirManager, appDir, projectDir } = platformPackager\n\n let deps: { nodeModules: NodeModuleInfo[]; logSummary: ModuleManager[\"logSummary\"] } | undefined = undefined\n\n // Drop packages whose `package.json` `cpu`/`os` is incompatible with the target arch/platform while\n // collecting (e.g. exclude `@esbuild/darwin-arm64` from the x64 slice). See NodeModulesCollector.\n // `null` arch (universal slices) disables the filter so both slices stay symmetric for the merge.\n const archFilter = arch == null ? undefined : { cpu: archToNodeCpu(arch), os: platformPackager.platform.nodeName }\n\n const searchDirectories = Array.from(new Set([appDir, projectDir, await platformPackager.getWorkspaceRoot()])).filter((it): it is string => isEmptyOrSpaces(it) === false)\n const pmApproaches = [await platformPackager.getPackageManager(), PM.TRAVERSAL]\n for (const pm of pmApproaches) {\n for (const dir of searchDirectories) {\n log.info({ pm, searchDir: dir }, \"searching for node modules\")\n const collector = getCollectorByPackageManager(pm, dir, tempDirManager)\n deps = await collector.getNodeModules({ packageName: platformPackager.nodePackageName, archFilter })\n if (deps.nodeModules.length > 0) {\n break\n }\n const attempt = searchDirectories.indexOf(dir)\n if (attempt < searchDirectories.length - 1) {\n log.info({ searchDir: dir, attempt }, \"no node modules found in collection, trying next search directory\")\n }\n }\n if (deps?.nodeModules?.length) {\n log.debug({ pm, nodeModules: deps.nodeModules }, \"collected node modules\")\n break\n }\n }\n if (!deps?.nodeModules?.length) {\n log.warn({ searchDirectories: searchDirectories.map(it => log.filePath(it)) }, \"no node modules returned while searching directories\")\n return []\n }\n\n const summary = Object.entries(deps.logSummary ?? {}).filter(([, dependencies]) => Array.isArray(dependencies) && dependencies.length > 0)\n for (const [errorMessage, dependencies] of summary) {\n const logLevel = logMessageLevelByKey[errorMessage as LogMessageByKey] || \"debug\"\n log[logLevel]({ dependencies }, errorMessage)\n }\n\n return deps.nodeModules\n}\n"]}
1
+ {"version":3,"file":"appFileCopier.js","sourceRoot":"","sources":["../../src/util/appFileCopier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,gBAAgB,EAAE,UAAU,EAAmB,eAAe,EAAQ,GAAG,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnJ,OAAO,EAAE,uCAAuC,EAAE,MAAM,qBAAqB,CAAA;AAE7E,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,EAAE,4BAA4B,EAAE,EAAE,EAAE,MAAM,mCAAmC,CAAA;AACpF,OAAO,EAAmB,oBAAoB,EAAiB,MAAM,2CAA2C,CAAA;AAGhH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEtD,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,OAAwB;IACvE,IAAI,IAAI,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,WAAW,CAAA;IAC5B,CAAC;IAED,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;IACvB,MAAM,IAAI,G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AAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,QAAQ,IAAI,uCAAuC,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;IACzJ,IAAI,qBAAqB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrC,GAAG,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,qBAAqB,EAAE,EAAE,iFAAiF,CAAC,CAAA;IACtI,CAAC;IAED,OAAO,IAAI,CAAC,WAAW,CAAA;AACzB,CAAC","sourcesContent":["import { Arch, AsyncTaskManager, FileCopier, FileTransformer, isEmptyOrSpaces, Link, log, MAX_FILE_REQUESTS, statOrNull, walk } from \"builder-util\"\nimport { DEFAULT_IGNORED_PRODUCTION_DEPENDENCIES } from \"../configuration.js\"\nimport { Stats } from \"fs\"\nimport fsExtra from \"fs-extra\"\nimport { mkdir, readlink } from \"fs/promises\"\nimport * as path from \"path\"\nimport asyncPool from \"tiny-async-pool\"\nimport { isLibOrExe } from \"../asar/unpackDetector.js\"\nimport { Platform } from \"../core.js\"\nimport { DEFAULT_EXCLUDED_EXTENSIONS, FileMatcher } from \"../fileMatcher.js\"\nimport { getCollectorByPackageManager, PM } from \"../node-module-collector/index.js\"\nimport { LogMessageByKey, logMessageLevelByKey, ModuleManager } from \"../node-module-collector/moduleManager.js\"\nimport { Packager } from \"../packager.js\"\nimport { PlatformPackager } from \"../platformPackager.js\"\nimport { AppFileWalker } from \"./AppFileWalker.js\"\nimport { NodeModuleCopyHelper } from \"./NodeModuleCopyHelper.js\"\nimport { NodeModuleInfo } from \"../node-module-collector/types.js\"\nimport { archToNodeCpu } from \"./archCompatibility.js\"\n\nexport function getDestinationPath(file: string, fileSet: ResolvedFileSet) {\n if (file === fileSet.src) {\n return fileSet.destination\n }\n\n const src = fileSet.src\n const dest = fileSet.destination\n // get node_modules path relative to src and then append to dest\n if (file.startsWith(src)) {\n return path.join(dest, path.relative(src, file))\n }\n return dest\n}\n\nexport async function copyAppFiles(fileSet: ResolvedFileSet, packager: Packager, transformer: FileTransformer) {\n const metadata = fileSet.metadata\n // search auto unpacked dir\n const taskManager = new AsyncTaskManager(packager.cancellationToken)\n const createdParentDirs = new Set<string>()\n\n const fileCopier = new FileCopier(file => {\n return !isLibOrExe(file)\n }, transformer)\n const links: Array<Link> = []\n for (let i = 0, n = fileSet.files.length; i < n; i++) {\n const sourceFile = fileSet.files[i]\n const stat = metadata.get(sourceFile)\n if (stat == null) {\n // dir\n continue\n }\n\n const destinationFile = getDestinationPath(sourceFile, fileSet)\n if (stat.isSymbolicLink()) {\n links.push({ file: destinationFile, link: await readlink(sourceFile) })\n continue\n }\n\n const fileParent = path.dirname(destinationFile)\n if (!createdParentDirs.has(fileParent)) {\n createdParentDirs.add(fileParent)\n await mkdir(fileParent, { recursive: true })\n }\n\n taskManager.addTask(fileCopier.copy(sourceFile, destinationFile, stat))\n if (taskManager.tasks.length > MAX_FILE_REQUESTS) {\n await taskManager.awaitTasks()\n }\n }\n\n if (taskManager.tasks.length > 0) {\n await taskManager.awaitTasks()\n }\n\n await asyncPool(MAX_FILE_REQUESTS, links, it => fsExtra.ensureSymlink(it.link, it.file))\n}\n\n// os path separator is used\nexport interface ResolvedFileSet {\n src: string\n destination: string\n\n files: Array<string>\n metadata: Map<string, Stats>\n transformedFiles?: Map<number, string | Buffer> | null\n}\n\n// used only for ASAR, if no asar, file transformed on the fly\nexport async function transformFiles(transformer: FileTransformer, fileSet: ResolvedFileSet): Promise<void> {\n if (transformer == null) {\n return\n }\n\n let transformedFiles = fileSet.transformedFiles\n if (fileSet.transformedFiles == null) {\n transformedFiles = new Map()\n fileSet.transformedFiles = transformedFiles\n }\n\n const metadata = fileSet.metadata\n const filesPromise = fileSet.files.map(async (it, index) => {\n const fileStat = metadata.get(it)\n if (fileStat == null || !fileStat.isFile()) {\n return\n }\n\n const transformedValue = transformer(it)\n if (transformedValue == null) {\n return\n }\n\n if (typeof transformedValue === \"object\" && \"then\" in transformedValue) {\n return (transformedValue as Promise<any>).then(it => {\n if (it != null) {\n transformedFiles!.set(index, it)\n }\n return\n })\n }\n transformedFiles!.set(index, transformedValue as string | Buffer)\n return\n })\n // `asyncPool` doesn't provide `index` in it's handler, so we `map` first before using it\n await asyncPool(MAX_FILE_REQUESTS, filesPromise, promise => promise)\n}\n\nexport async function computeFileSets(matchers: Array<FileMatcher>, transformer: FileTransformer | null, platformPackager: PlatformPackager<any>): Promise<Array<ResolvedFileSet>> {\n const fileSets: Array<ResolvedFileSet> = []\n\n for (const matcher of matchers) {\n const fileWalker = new AppFileWalker(matcher, platformPackager)\n\n const fromStat = await statOrNull(matcher.from)\n if (fromStat == null) {\n log.debug({ directory: matcher.from, reason: \"doesn't exist\" }, `skipped copying`)\n continue\n }\n\n const files = await walk(matcher.from, fileWalker.filter, fileWalker)\n const metadata = fileWalker.metadata\n fileSets.push(validateFileSet({ src: matcher.from, files, metadata, destination: matcher.to }))\n }\n\n return fileSets\n}\n\nfunction getNodeModuleExcludedExts(platformPackager: PlatformPackager<any>) {\n // do not exclude *.h files (https://github.com/electron-userland/electron-builder/issues/2852)\n const result = DEFAULT_EXCLUDED_EXTENSIONS.map(it => `.${it}`)\n if (platformPackager.config.includePdb !== true) {\n result.push(\".pdb\")\n }\n if (platformPackager.platform !== Platform.WINDOWS) {\n // https://github.com/electron-userland/electron-builder/issues/1738\n result.push(\".dll\")\n result.push(\".exe\")\n }\n return result\n}\n\nfunction validateFileSet(fileSet: ResolvedFileSet): ResolvedFileSet {\n if (fileSet.src == null || fileSet.src.length === 0) {\n throw new Error(\"fileset src is empty\")\n }\n return fileSet\n}\n\n/** @internal */\nexport async function computeNodeModuleFileSets(\n platformPackager: PlatformPackager<any>,\n mainMatcher: FileMatcher,\n arch: Arch,\n applyArchFilter = true\n): Promise<Array<ResolvedFileSet>> {\n const deps = await collectNodeModulesWithLogging(platformPackager, applyArchFilter ? arch : null)\n\n const nodeModuleExcludedExts = getNodeModuleExcludedExts(platformPackager)\n // serial execution because copyNodeModules is concurrent and so, no need to increase queue/pressure\n const result = new Array<ResolvedFileSet>()\n let index = 0\n const NODE_MODULES = \"node_modules\"\n\n const collectNodeModules = async (dep: NodeModuleInfo, destination: string) => {\n // Ignore excluded dependencies.\n if (dep.excluded) {\n return\n }\n\n const source = dep.dir\n const matcher = new FileMatcher(source, destination, mainMatcher.macroExpander, mainMatcher.patterns)\n const copier = new NodeModuleCopyHelper(matcher, platformPackager)\n const files = await copier.collectNodeModules(dep, nodeModuleExcludedExts, path.relative(mainMatcher.to, destination))\n result[index++] = validateFileSet({ src: source, destination, files, metadata: copier.metadata })\n\n log.debug({ dep: dep.name, from: log.filePath(source), to: log.filePath(destination), filesCount: files.length }, \"identified module\")\n\n if (dep.dependencies) {\n for (const c of dep.dependencies) {\n await collectNodeModules(c, path.join(destination, NODE_MODULES, c.name))\n }\n }\n }\n\n for (const dep of deps) {\n const destination = path.join(mainMatcher.to, NODE_MODULES, dep.name)\n await collectNodeModules(dep, destination)\n }\n return result\n}\n\ntype CollectedNodeModules = { nodeModules: NodeModuleInfo[]; logSummary: ModuleManager[\"logSummary\"] }\n\n/** Runs a single package-manager collector against a single directory. */\ntype CollectorRunner = (pm: PM, dir: string) => Promise<CollectedNodeModules>\n\n// `workspace:`/`file:`/`link:`/`portal:` dependencies are symlinked into place rather than\n// installed as standalone, hoistable packages, so they may legitimately be absent from a\n// collected tree and cannot be used to validate it.\nconst LOCAL_DEPENDENCY_SPEC = /^(?:workspace|file|link|portal):/\n\n/**\n * Determines whether a collected module tree actually describes the package being built.\n *\n * A package-manager `list` invocation can resolve to the wrong project root — most notably when\n * electron-builder is run from a workspace sub-package whose dependencies are hoisted to the\n * workspace root. In that case the collector returns a non-empty but unrelated tree. Accepting it\n * would suppress the manual-traversal fallback that resolves the correct modules, so we need to\n * tell a matching collection from a mismatched one.\n *\n * A collection matches when at least one of the package's declared external (registry-installed,\n * non-`workspace:`/`file:`/`link:`/`portal:`) production dependencies is present at the top level —\n * those direct dependencies are always hoisted to the top level of a correct collection. When the\n * package declares no external production dependencies there is nothing to validate against, so any\n * non-empty collection is accepted.\n */\nexport function collectionMatchesAppDependencies(nodeModules: NodeModuleInfo[], dependencies: Record<string, string> | undefined): boolean {\n const requiredExternalDeps = Object.entries(dependencies ?? {})\n .filter(([, spec]) => !LOCAL_DEPENDENCY_SPEC.test(spec))\n .map(([name]) => name)\n if (requiredExternalDeps.length === 0) {\n return true\n }\n const collected = new Set(nodeModules.map(it => it.name))\n return requiredExternalDeps.some(name => collected.has(name))\n}\n\n/**\n * Walks the candidate (package-manager, directory) combinations and returns the first collection\n * that both contains modules and matches the package being built (see\n * {@link collectionMatchesAppDependencies}). A non-empty collection that does NOT match — e.g. a\n * workspace-root tree returned for a sub-package — is retained only as a last-resort fallback so a\n * later approach (notably {@link PM.TRAVERSAL}) can supply the correct modules.\n */\nexport async function resolveFirstMatchingCollection(options: {\n pmApproaches: PM[]\n searchDirectories: string[]\n dependencies: Record<string, string> | undefined\n run: CollectorRunner\n}): Promise<CollectedNodeModules | undefined> {\n const { pmApproaches, searchDirectories, dependencies, run } = options\n let fallback: CollectedNodeModules | undefined\n\n for (const pm of pmApproaches) {\n for (const dir of searchDirectories) {\n log.info({ pm, searchDir: dir }, \"searching for node modules\")\n const deps = await run(pm, dir)\n if (deps.nodeModules.length === 0) {\n log.info({ pm, searchDir: dir }, \"no node modules found in collection, trying next search directory\")\n continue\n }\n if (collectionMatchesAppDependencies(deps.nodeModules, dependencies)) {\n log.debug({ pm, searchDir: dir, depCount: deps.nodeModules.length }, \"collected node modules\")\n return deps\n }\n log.info({ pm, searchDir: dir }, \"collected node modules do not match the target package, trying next search directory/approach\")\n fallback ??= deps\n }\n }\n return fallback\n}\n\n/** @internal */\nexport async function collectNodeModulesWithLogging(platformPackager: PlatformPackager<any>, arch: Arch | null) {\n const { tempDirManager, appDir, projectDir } = platformPackager\n\n // Drop packages whose `package.json` `cpu`/`os` is incompatible with the target arch/platform while\n // collecting (e.g. exclude `@esbuild/darwin-arm64` from the x64 slice). See NodeModulesCollector.\n // `null` arch (universal slices) disables the filter so both slices stay symmetric for the merge.\n const archFilter = arch == null ? undefined : { cpu: archToNodeCpu(arch), os: platformPackager.platform.nodeName }\n\n const searchDirectories = Array.from(new Set([appDir, projectDir, await platformPackager.getWorkspaceRoot()])).filter((it): it is string => isEmptyOrSpaces(it) === false)\n const pmApproaches = [await platformPackager.getPackageManager(), PM.TRAVERSAL]\n\n // The default-ignored packages are excluded from the copied `node_modules` — together with any\n // transitive dependency they alone require — because electron-builder already provides them another\n // way (the Electron runtime is embedded separately), so copying them would be redundant. They remain\n // valid production dependencies for tooling such as SBOM generation. See NodeModulesCollector.getNodeModules.\n const configuredIgnored = platformPackager.config.ignoredProductionDependencies\n const ignoredDependencies = configuredIgnored == null ? DEFAULT_IGNORED_PRODUCTION_DEPENDENCIES : configuredIgnored\n\n // Validate against the as-declared (pre-extraMetadata) production dependencies so a configured\n // `extraMetadata.dependencies` entry that isn't installed cannot reject a correct collection.\n const deps = await resolveFirstMatchingCollection({\n pmApproaches,\n searchDirectories,\n dependencies: platformPackager.originalMetadata.dependencies,\n run: (pm, dir) => getCollectorByPackageManager(pm, dir, tempDirManager).getNodeModules({ packageName: platformPackager.nodePackageName, archFilter, ignoredDependencies }),\n })\n\n if (!deps?.nodeModules?.length) {\n log.warn({ searchDirectories: searchDirectories.map(it => log.filePath(it)) }, \"no node modules returned while searching directories\")\n return []\n }\n\n const summary = Object.entries(deps.logSummary ?? {}).filter(([, dependencies]) => Array.isArray(dependencies) && dependencies.length > 0)\n for (const [errorMessage, dependencies] of summary) {\n const logLevel = logMessageLevelByKey[errorMessage as LogMessageByKey] || \"debug\"\n log[logLevel]({ dependencies }, errorMessage)\n }\n\n // Tripwire: the default-ignored packages are excluded because electron-builder already provides them\n // (e.g. the embedded Electron runtime), so a copy in `node_modules` is redundant. They only reach this\n // point unflagged when a user has removed them from `ignoredProductionDependencies`; record any that\n // are therefore about to be copied (present but not marked `excluded`) so the summary below warns.\n const bundledDefaultIgnored = deps.nodeModules.filter(it => !it.excluded && DEFAULT_IGNORED_PRODUCTION_DEPENDENCIES.includes(it.name)).map(it => it.name)\n if (bundledDefaultIgnored.length > 0) {\n log.warn({ dependencies: bundledDefaultIgnored }, \"copied dependencies that shouldn't be needed, see ignoredProductionDependencies\")\n }\n\n return deps.nodeModules\n}\n"]}
@@ -2,6 +2,7 @@ import { DebugLogger } from "builder-util";
2
2
  import { Nullish } from "builder-util-runtime";
3
3
  import { Lazy } from "lazy-val";
4
4
  import { Configuration } from "../../configuration.js";
5
+ export declare function createProjectMetadataLazy(projectDir: string): Lazy<Record<string, any> | null>;
5
6
  export declare function getConfig(projectDir: string, configPath: string | null, configFromOptions: Configuration | Nullish, packageMetadata?: Lazy<Record<string, any> | null>): Promise<Configuration>;
6
7
  /**
7
8
  * `doMergeConfigs` takes configs in the order you would pass them to
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/util/config/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAiE,MAAM,cAAc,CAAA;AAGzG,OAAO,EAAc,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAgCtD,wBAAsB,SAAS,CAC7B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,iBAAiB,EAAE,aAAa,GAAG,OAAO,EAC1C,eAAe,GAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAyF,GACxI,OAAO,CAAC,aAAa,CAAC,CA0CxB;AAuGD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,aAAa,CAgBtE;AAaD,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,iBAwB1F;AAID,wBAAsB,0BAA0B,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAuBlH"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/util/config/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAiE,MAAM,cAAc,CAAA;AAGzG,OAAO,EAAc,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAgCtD,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAE9F;AAED,wBAAsB,SAAS,CAC7B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,iBAAiB,EAAE,aAAa,GAAG,OAAO,EAC1C,eAAe,GAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAyC,GACxF,OAAO,CAAC,aAAa,CAAC,CA0CxB;AAuGD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,aAAa,CAgBtE;AAaD,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,iBAwB1F;AAID,wBAAsB,0BAA0B,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAuBlH"}
@@ -30,7 +30,10 @@ function mergePublish(config, configFromOptions) {
30
30
  deepAssign(listOnDisk[0], publish);
31
31
  }
32
32
  }
33
- export async function getConfig(projectDir, configPath, configFromOptions, packageMetadata = new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, "package.json"))))) {
33
+ export function createProjectMetadataLazy(projectDir) {
34
+ return new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, "package.json"))));
35
+ }
36
+ export async function getConfig(projectDir, configPath, configFromOptions, packageMetadata = createProjectMetadataLazy(projectDir)) {
34
37
  const configRequest = { packageKey: "build", configFilename: "electron-builder", projectDir, packageMetadata };
35
38
  const configAndEffectiveFile = await _getConfig(configRequest, configPath);
36
39
  const config = configAndEffectiveFile == null ? {} : configAndEffectiveFile.result;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/util/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAe,yBAAyB,EAAE,GAAG,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzG,MAAM,eAAe,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAW,MAAM,sBAAsB,CAAA;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAG5B,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,SAAS,IAAI,UAAU,EAAE,gBAAgB,EAAE,oBAAoB,EAAqB,MAAM,WAAW,CAAA;AAC9G,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAA;AAE7B,oEAAoE;AACpE,SAAS,YAAY,CAAC,MAAqB,EAA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0BAA0B,CAAC,UAAkB,EAAE,UAA4B;IAC/F,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;QACzD,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,CAAA;QAC3C,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,yBAAyB,CAAC,yBAAyB,UAAU,gBAAgB,CAAC,CAAA;QAC1F,CAAC;aAAM,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YAC/B,MAAM,IAAI,yBAAyB,CAAC,yBAAyB,UAAU,qBAAqB,CAAC,CAAA;QAC/F,CAAC;aAAM,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;YACvC,GAAG,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,4FAA4F,CAAC,CAAA;QACtI,CAAC;QACD,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,qBAAqB,EAAE,CAAC;QACxC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;QAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAA;QAC3D,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,WAAW,CAAC,CAAA;QAC1C,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YAClC,OAAO,YAAY,CAAA;QACrB,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { createRequire } from \"node:module\"\nimport { DebugLogger, InvalidConfigurationError, log, safeStringifyJson, statOrNull } from \"builder-util\"\n\nconst _requireResolve = createRequire(import.meta.url).resolve\nimport { deepAssign, Nullish } from \"builder-util-runtime\"\n\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { Configuration } from \"../../configuration.js\"\nimport { FileSet } from \"../../options/PlatformSpecificBuildOptions.js\"\nimport { reactCra } from \"../../presets/rectCra.js\"\nimport { PACKAGE_VERSION } from \"../../version.js\"\nimport { getConfig as _getConfig, loadParentConfig, orNullIfFileNotExist, ReadConfigRequest } from \"./load.js\"\nimport { validateSchema } from \"./schemaValidator.js\"\nimport _fsExtra from \"fs-extra\"\nconst { readJson } = _fsExtra\n\n// https://github.com/electron-userland/electron-builder/issues/1847\nfunction mergePublish(config: Configuration, configFromOptions: Configuration) {\n // if config from disk doesn't have publish (or object), no need to handle, it will be simply merged by deepAssign\n const publish = Array.isArray(config.publish) ? configFromOptions.publish : null\n if (publish != null) {\n delete (configFromOptions as any).publish\n }\n\n deepAssign(config, configFromOptions)\n\n if (publish == null) {\n return\n }\n\n const listOnDisk = config.publish as Array<any>\n if (listOnDisk.length === 0) {\n config.publish = publish\n } else {\n // apply to first\n deepAssign(listOnDisk[0], publish)\n }\n}\n\nexport async function getConfig(\n projectDir: string,\n configPath: string | null,\n configFromOptions: Configuration | Nullish,\n packageMetadata: Lazy<Record<string, any> | null> = new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, \"package.json\"))))\n): Promise<Configuration> {\n const configRequest: ReadConfigRequest = { packageKey: \"build\", configFilename: \"electron-builder\", projectDir, packageMetadata }\n const configAndEffectiveFile = await _getConfig<Configuration>(configRequest, configPath)\n const config = configAndEffectiveFile == null ? {} : configAndEffectiveFile.result\n if (configFromOptions != null) {\n mergePublish(config, configFromOptions)\n }\n\n if (configAndEffectiveFile != null) {\n log.info({ file: configAndEffectiveFile.configFile == null ? 'package.json (\"build\" field)' : configAndEffectiveFile.configFile }, \"loaded configuration\")\n }\n\n if (config.extends == null && config.extends !== null) {\n const metadata = (await packageMetadata.value) || {}\n const devDependencies = metadata.devDependencies\n const dependencies = metadata.dependencies\n if ((dependencies != null && \"react-scripts\" in dependencies) || (devDependencies != null && \"react-scripts\" in devDependencies)) {\n config.extends = \"react-cra\"\n } else if (devDependencies != null && \"electron-webpack\" in devDependencies) {\n let file = \"electron-webpack/out/electron-builder.js\"\n try {\n file = _requireResolve(file)\n } catch (_ignore) {\n file = _requireResolve(\"electron-webpack/electron-builder.yml\")\n }\n config.extends = `file:${file}`\n }\n }\n\n const parentConfigs = await loadParentConfigsRecursively(config.extends, async configExtend => {\n if (configExtend === \"react-cra\") {\n const result = await reactCra(projectDir)\n log.info({ preset: configExtend }, \"loaded parent configuration\")\n return result\n } else {\n const { configFile, result } = await loadParentConfig<Configuration>(configRequest, configExtend)\n log.info({ file: configFile }, \"loaded parent configuration\")\n return result\n }\n })\n\n return doMergeConfigs([...parentConfigs, config])\n}\n\nfunction asArray(value: string[] | string | Nullish): string[] {\n return Array.isArray(value) ? value : typeof value === \"string\" ? [value] : []\n}\n\nasync function loadParentConfigsRecursively(configExtends: Configuration[\"extends\"], loader: (configExtend: string) => Promise<Configuration>): Promise<Configuration[]> {\n const configs = []\n\n for (const configExtend of asArray(configExtends)) {\n const result = await loader(configExtend)\n const parentConfigs = await loadParentConfigsRecursively(result.extends, loader)\n configs.push(...parentConfigs, result)\n }\n\n return configs\n}\n\n// normalize for easy merge\nfunction normalizeFiles(configuration: Configuration, name: \"files\" | \"extraFiles\" | \"extraResources\") {\n let value = configuration[name]\n if (value == null) {\n return\n }\n\n if (!Array.isArray(value)) {\n value = [value]\n }\n\n itemLoop: for (let i = 0; i < value.length; i++) {\n let item = value[i]\n if (typeof item === \"string\") {\n // merge with previous if possible\n if (i !== 0) {\n let prevItemIndex = i - 1\n let prevItem: FileSet\n do {\n prevItem = value[prevItemIndex--] as FileSet\n } while (prevItem == null)\n\n if (prevItem.from == null && prevItem.to == null) {\n if (prevItem.filter == null) {\n prevItem.filter = [item]\n } else {\n ;(prevItem.filter as Array<string>).push(item)\n }\n value[i] = null as any\n continue itemLoop\n }\n }\n\n item = {\n filter: [item],\n }\n value[i] = item\n } else if (Array.isArray(item)) {\n throw new Error(`${name} configuration is invalid, nested array not expected for index ${i}: ${item}`)\n }\n\n // make sure that merge logic is not complex - unify different presentations\n if (item.from === \".\") {\n item.from = undefined\n }\n\n if (item.to === \".\") {\n item.to = undefined\n }\n\n if (item.filter != null && typeof item.filter === \"string\") {\n item.filter = [item.filter]\n }\n }\n\n configuration[name] = value.filter(it => it != null)\n}\n\nfunction isSimilarFileSet(value: FileSet, other: FileSet): boolean {\n return value.from === other.from && value.to === other.to\n}\n\ntype Filter = FileSet[\"filter\"]\n\nfunction mergeFilters(value: Filter, other: Filter): string[] {\n return asArray(value).concat(asArray(other))\n}\n\nfunction mergeFileSets(lists: FileSet[][]): FileSet[] {\n const result: FileSet[] = []\n\n for (const list of lists) {\n for (const item of list) {\n const existingItem = result.find(i => isSimilarFileSet(i, item))\n if (existingItem) {\n existingItem.filter = mergeFilters(item.filter, existingItem.filter)\n } else {\n result.push(item)\n }\n }\n }\n\n return result\n}\n\n/**\n * `doMergeConfigs` takes configs in the order you would pass them to\n * Object.assign as sources.\n */\nexport function doMergeConfigs(configs: Configuration[]): Configuration {\n for (const config of configs) {\n normalizeFiles(config, \"files\")\n normalizeFiles(config, \"extraFiles\")\n normalizeFiles(config, \"extraResources\")\n }\n\n const result = deepAssign(getDefaultConfig(), ...configs)\n\n // `deepAssign` prioritises latter configs, while `mergeFilesSets` prioritises\n // former configs, so we have to reverse the order, because latter configs\n // must have higher priority.\n configs = configs.slice().reverse()\n\n result.files = mergeFileSets(configs.map(config => (config.files ?? []) as FileSet[]))\n return result\n}\n\nfunction getDefaultConfig(): Configuration {\n return {\n directories: {\n output: \"dist\",\n buildResources: \"build\",\n },\n }\n}\n\nconst schemeDataPromise = new Lazy(() => readJson(path.join(import.meta.dirname, \"..\", \"..\", \"..\", \"scheme.json\")))\n\nexport async function validateConfiguration(config: Configuration, debugLogger: DebugLogger) {\n validateSchema(await schemeDataPromise.value, config, {\n name: `electron-builder ${PACKAGE_VERSION}`,\n postFormatter: (formattedError, error): string => {\n if (debugLogger.isEnabled) {\n debugLogger.add(\"invalidConfig\", safeStringifyJson(error))\n }\n\n const site = \"https://www.electron.build\"\n let url = `${site}/configuration`\n const targets = new Set([\"mac\", \"dmg\", \"pkg\", \"mas\", \"win\", \"nsis\", \"appx\", \"linux\", \"appimage\", \"snap\"])\n const firstSegment = (error.instancePath ?? \"\").split(\"/\").filter(Boolean)[0]?.toLowerCase()\n if (firstSegment != null && targets.has(firstSegment)) {\n url = `${site}/${firstSegment}`\n }\n\n return `${formattedError}\\n How to fix:\n 1. Open ${url}\n 2. Search the option name on the page (or type in into Search to find across the docs).\n * Not found? The option was deprecated or not exists (check spelling).\n * Found? Check that the option in the appropriate place. e.g. \"title\" only in the \"dmg\", not in the root.\n`\n },\n })\n}\n\nconst DEFAULT_APP_DIR_NAMES = [\"app\", \"www\"]\n\nexport async function computeDefaultAppDirectory(projectDir: string, userAppDir: string | Nullish): Promise<string> {\n if (userAppDir != null) {\n const absolutePath = path.resolve(projectDir, userAppDir)\n const stat = await statOrNull(absolutePath)\n if (stat == null) {\n throw new InvalidConfigurationError(`Application directory ${userAppDir} doesn't exist`)\n } else if (!stat.isDirectory()) {\n throw new InvalidConfigurationError(`Application directory ${userAppDir} is not a directory`)\n } else if (projectDir === absolutePath) {\n log.warn({ appDirectory: userAppDir }, `Specified application directory equals to project dir — superfluous or wrong configuration`)\n }\n return absolutePath\n }\n\n for (const dir of DEFAULT_APP_DIR_NAMES) {\n const absolutePath = path.join(projectDir, dir)\n const packageJson = path.join(absolutePath, \"package.json\")\n const stat = await statOrNull(packageJson)\n if (stat != null && stat.isFile()) {\n return absolutePath\n }\n }\n return projectDir\n}\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/util/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAe,yBAAyB,EAAE,GAAG,EAAE,iBAAiB,EAAE,UAAU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UAAU,KAAK,YAAY,EAAE,CAAC;YACvC,GAAG,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,4FAA4F,CAAC,CAAA;QACtI,CAAC;QACD,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,qBAAqB,EAAE,CAAC;QACxC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;QAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAA;QAC3D,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,WAAW,CAAC,CAAA;QAC1C,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YAClC,OAAO,YAAY,CAAA;QACrB,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { createRequire } from \"node:module\"\nimport { DebugLogger, InvalidConfigurationError, log, safeStringifyJson, statOrNull } from \"builder-util\"\n\nconst _requireResolve = createRequire(import.meta.url).resolve\nimport { deepAssign, Nullish } from \"builder-util-runtime\"\n\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { Configuration } from \"../../configuration.js\"\nimport { FileSet } from \"../../options/PlatformSpecificBuildOptions.js\"\nimport { reactCra } from \"../../presets/rectCra.js\"\nimport { PACKAGE_VERSION } from \"../../version.js\"\nimport { getConfig as _getConfig, loadParentConfig, orNullIfFileNotExist, ReadConfigRequest } from \"./load.js\"\nimport { validateSchema } from \"./schemaValidator.js\"\nimport _fsExtra from \"fs-extra\"\nconst { readJson } = _fsExtra\n\n// https://github.com/electron-userland/electron-builder/issues/1847\nfunction mergePublish(config: Configuration, configFromOptions: Configuration) {\n // if config from disk doesn't have publish (or object), no need to handle, it will be simply merged by deepAssign\n const publish = Array.isArray(config.publish) ? configFromOptions.publish : null\n if (publish != null) {\n delete (configFromOptions as any).publish\n }\n\n deepAssign(config, configFromOptions)\n\n if (publish == null) {\n return\n }\n\n const listOnDisk = config.publish as Array<any>\n if (listOnDisk.length === 0) {\n config.publish = publish\n } else {\n // apply to first\n deepAssign(listOnDisk[0], publish)\n }\n}\n\nexport function createProjectMetadataLazy(projectDir: string): Lazy<Record<string, any> | null> {\n return new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, \"package.json\"))))\n}\n\nexport async function getConfig(\n projectDir: string,\n configPath: string | null,\n configFromOptions: Configuration | Nullish,\n packageMetadata: Lazy<Record<string, any> | null> = createProjectMetadataLazy(projectDir)\n): Promise<Configuration> {\n const configRequest: ReadConfigRequest = { packageKey: \"build\", configFilename: \"electron-builder\", projectDir, packageMetadata }\n const configAndEffectiveFile = await _getConfig<Configuration>(configRequest, configPath)\n const config = configAndEffectiveFile == null ? {} : configAndEffectiveFile.result\n if (configFromOptions != null) {\n mergePublish(config, configFromOptions)\n }\n\n if (configAndEffectiveFile != null) {\n log.info({ file: configAndEffectiveFile.configFile == null ? 'package.json (\"build\" field)' : configAndEffectiveFile.configFile }, \"loaded configuration\")\n }\n\n if (config.extends == null && config.extends !== null) {\n const metadata = (await packageMetadata.value) || {}\n const devDependencies = metadata.devDependencies\n const dependencies = metadata.dependencies\n if ((dependencies != null && \"react-scripts\" in dependencies) || (devDependencies != null && \"react-scripts\" in devDependencies)) {\n config.extends = \"react-cra\"\n } else if (devDependencies != null && \"electron-webpack\" in devDependencies) {\n let file = \"electron-webpack/out/electron-builder.js\"\n try {\n file = _requireResolve(file)\n } catch (_ignore) {\n file = _requireResolve(\"electron-webpack/electron-builder.yml\")\n }\n config.extends = `file:${file}`\n }\n }\n\n const parentConfigs = await loadParentConfigsRecursively(config.extends, async configExtend => {\n if (configExtend === \"react-cra\") {\n const result = await reactCra(projectDir)\n log.info({ preset: configExtend }, \"loaded parent configuration\")\n return result\n } else {\n const { configFile, result } = await loadParentConfig<Configuration>(configRequest, configExtend)\n log.info({ file: configFile }, \"loaded parent configuration\")\n return result\n }\n })\n\n return doMergeConfigs([...parentConfigs, config])\n}\n\nfunction asArray(value: string[] | string | Nullish): string[] {\n return Array.isArray(value) ? value : typeof value === \"string\" ? [value] : []\n}\n\nasync function loadParentConfigsRecursively(configExtends: Configuration[\"extends\"], loader: (configExtend: string) => Promise<Configuration>): Promise<Configuration[]> {\n const configs = []\n\n for (const configExtend of asArray(configExtends)) {\n const result = await loader(configExtend)\n const parentConfigs = await loadParentConfigsRecursively(result.extends, loader)\n configs.push(...parentConfigs, result)\n }\n\n return configs\n}\n\n// normalize for easy merge\nfunction normalizeFiles(configuration: Configuration, name: \"files\" | \"extraFiles\" | \"extraResources\") {\n let value = configuration[name]\n if (value == null) {\n return\n }\n\n if (!Array.isArray(value)) {\n value = [value]\n }\n\n itemLoop: for (let i = 0; i < value.length; i++) {\n let item = value[i]\n if (typeof item === \"string\") {\n // merge with previous if possible\n if (i !== 0) {\n let prevItemIndex = i - 1\n let prevItem: FileSet\n do {\n prevItem = value[prevItemIndex--] as FileSet\n } while (prevItem == null)\n\n if (prevItem.from == null && prevItem.to == null) {\n if (prevItem.filter == null) {\n prevItem.filter = [item]\n } else {\n ;(prevItem.filter as Array<string>).push(item)\n }\n value[i] = null as any\n continue itemLoop\n }\n }\n\n item = {\n filter: [item],\n }\n value[i] = item\n } else if (Array.isArray(item)) {\n throw new Error(`${name} configuration is invalid, nested array not expected for index ${i}: ${item}`)\n }\n\n // make sure that merge logic is not complex - unify different presentations\n if (item.from === \".\") {\n item.from = undefined\n }\n\n if (item.to === \".\") {\n item.to = undefined\n }\n\n if (item.filter != null && typeof item.filter === \"string\") {\n item.filter = [item.filter]\n }\n }\n\n configuration[name] = value.filter(it => it != null)\n}\n\nfunction isSimilarFileSet(value: FileSet, other: FileSet): boolean {\n return value.from === other.from && value.to === other.to\n}\n\ntype Filter = FileSet[\"filter\"]\n\nfunction mergeFilters(value: Filter, other: Filter): string[] {\n return asArray(value).concat(asArray(other))\n}\n\nfunction mergeFileSets(lists: FileSet[][]): FileSet[] {\n const result: FileSet[] = []\n\n for (const list of lists) {\n for (const item of list) {\n const existingItem = result.find(i => isSimilarFileSet(i, item))\n if (existingItem) {\n existingItem.filter = mergeFilters(item.filter, existingItem.filter)\n } else {\n result.push(item)\n }\n }\n }\n\n return result\n}\n\n/**\n * `doMergeConfigs` takes configs in the order you would pass them to\n * Object.assign as sources.\n */\nexport function doMergeConfigs(configs: Configuration[]): Configuration {\n for (const config of configs) {\n normalizeFiles(config, \"files\")\n normalizeFiles(config, \"extraFiles\")\n normalizeFiles(config, \"extraResources\")\n }\n\n const result = deepAssign(getDefaultConfig(), ...configs)\n\n // `deepAssign` prioritises latter configs, while `mergeFilesSets` prioritises\n // former configs, so we have to reverse the order, because latter configs\n // must have higher priority.\n configs = configs.slice().reverse()\n\n result.files = mergeFileSets(configs.map(config => (config.files ?? []) as FileSet[]))\n return result\n}\n\nfunction getDefaultConfig(): Configuration {\n return {\n directories: {\n output: \"dist\",\n buildResources: \"build\",\n },\n }\n}\n\nconst schemeDataPromise = new Lazy(() => readJson(path.join(import.meta.dirname, \"..\", \"..\", \"..\", \"scheme.json\")))\n\nexport async function validateConfiguration(config: Configuration, debugLogger: DebugLogger) {\n validateSchema(await schemeDataPromise.value, config, {\n name: `electron-builder ${PACKAGE_VERSION}`,\n postFormatter: (formattedError, error): string => {\n if (debugLogger.isEnabled) {\n debugLogger.add(\"invalidConfig\", safeStringifyJson(error))\n }\n\n const site = \"https://www.electron.build\"\n let url = `${site}/configuration`\n const targets = new Set([\"mac\", \"dmg\", \"pkg\", \"mas\", \"win\", \"nsis\", \"appx\", \"linux\", \"appimage\", \"snap\"])\n const firstSegment = (error.instancePath ?? \"\").split(\"/\").filter(Boolean)[0]?.toLowerCase()\n if (firstSegment != null && targets.has(firstSegment)) {\n url = `${site}/${firstSegment}`\n }\n\n return `${formattedError}\\n How to fix:\n 1. Open ${url}\n 2. Search the option name on the page (or type in into Search to find across the docs).\n * Not found? The option was deprecated or not exists (check spelling).\n * Found? Check that the option in the appropriate place. e.g. \"title\" only in the \"dmg\", not in the root.\n`\n },\n })\n}\n\nconst DEFAULT_APP_DIR_NAMES = [\"app\", \"www\"]\n\nexport async function computeDefaultAppDirectory(projectDir: string, userAppDir: string | Nullish): Promise<string> {\n if (userAppDir != null) {\n const absolutePath = path.resolve(projectDir, userAppDir)\n const stat = await statOrNull(absolutePath)\n if (stat == null) {\n throw new InvalidConfigurationError(`Application directory ${userAppDir} doesn't exist`)\n } else if (!stat.isDirectory()) {\n throw new InvalidConfigurationError(`Application directory ${userAppDir} is not a directory`)\n } else if (projectDir === absolutePath) {\n log.warn({ appDirectory: userAppDir }, `Specified application directory equals to project dir — superfluous or wrong configuration`)\n }\n return absolutePath\n }\n\n for (const dir of DEFAULT_APP_DIR_NAMES) {\n const absolutePath = path.join(projectDir, dir)\n const packageJson = path.join(absolutePath, \"package.json\")\n const stat = await statOrNull(packageJson)\n if (stat != null && stat.isFile()) {\n return absolutePath\n }\n }\n return projectDir\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { orNullIfFileNotExist } from "builder-util";
1
2
  import { DotenvParseInput } from "dotenv-expand";
2
3
  import { Lazy } from "lazy-val";
3
4
  export interface ReadConfigResult<T> {
@@ -5,8 +6,7 @@ export interface ReadConfigResult<T> {
5
6
  readonly configFile: string | null;
6
7
  }
7
8
  export declare function findAndReadConfig<T>(request: ReadConfigRequest): Promise<ReadConfigResult<T> | null>;
8
- export declare function orNullIfFileNotExist<T>(promise: Promise<T>): Promise<T | null>;
9
- export declare function orIfFileNotExist<T>(promise: Promise<T>, fallbackValue: T): Promise<T>;
9
+ export { orNullIfFileNotExist };
10
10
  export interface ReadConfigRequest {
11
11
  packageKey: string;
12
12
  configFilename: string;