app-builder-lib 27.0.0-alpha.1 → 27.0.0-alpha.11

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 (489) hide show
  1. package/dist/Framework.d.ts +2 -0
  2. package/dist/Framework.d.ts.map +1 -1
  3. package/dist/Framework.js.map +1 -1
  4. package/dist/appInfo.d.ts +1 -1
  5. package/dist/appInfo.d.ts.map +1 -1
  6. package/dist/appInfo.js +3 -3
  7. package/dist/appInfo.js.map +1 -1
  8. package/dist/asar/asar.js.map +1 -1
  9. package/dist/asar/asarAlign.d.ts +35 -0
  10. package/dist/asar/asarAlign.d.ts.map +1 -0
  11. package/dist/asar/asarAlign.js +149 -0
  12. package/dist/asar/asarAlign.js.map +1 -0
  13. package/dist/asar/asarFileChecker.d.ts +4 -2
  14. package/dist/asar/asarFileChecker.d.ts.map +1 -1
  15. package/dist/asar/asarFileChecker.js +2 -3
  16. package/dist/asar/asarFileChecker.js.map +1 -1
  17. package/dist/asar/asarUtil.d.ts +15 -1
  18. package/dist/asar/asarUtil.d.ts.map +1 -1
  19. package/dist/asar/asarUtil.js +132 -72
  20. package/dist/asar/asarUtil.js.map +1 -1
  21. package/dist/codeSign/certInfo.d.ts +14 -0
  22. package/dist/codeSign/certInfo.d.ts.map +1 -1
  23. package/dist/codeSign/certInfo.js +49 -0
  24. package/dist/codeSign/certInfo.js.map +1 -1
  25. package/dist/codeSign/mac/macCodeSign.d.ts +3 -3
  26. package/dist/codeSign/mac/macCodeSign.d.ts.map +1 -1
  27. package/dist/codeSign/mac/macCodeSign.js +50 -25
  28. package/dist/codeSign/mac/macCodeSign.js.map +1 -1
  29. package/dist/codeSign/signResult.d.ts +26 -0
  30. package/dist/codeSign/signResult.d.ts.map +1 -0
  31. package/dist/codeSign/signResult.js +12 -0
  32. package/dist/codeSign/signResult.js.map +1 -0
  33. package/dist/codeSign/win/hsmSignManager.d.ts +10 -0
  34. package/dist/codeSign/win/hsmSignManager.d.ts.map +1 -0
  35. package/dist/codeSign/win/hsmSignManager.js +50 -0
  36. package/dist/codeSign/win/hsmSignManager.js.map +1 -0
  37. package/dist/codeSign/win/pkcs11SignManager.d.ts +14 -0
  38. package/dist/codeSign/win/pkcs11SignManager.d.ts.map +1 -0
  39. package/dist/codeSign/win/pkcs11SignManager.js +82 -0
  40. package/dist/codeSign/win/pkcs11SignManager.js.map +1 -0
  41. package/dist/codeSign/win/signManager.d.ts +17 -0
  42. package/dist/codeSign/win/signManager.d.ts.map +1 -0
  43. package/dist/codeSign/win/signManager.js +19 -0
  44. package/dist/codeSign/win/signManager.js.map +1 -0
  45. package/dist/codeSign/win/signtoolBaseSignManager.d.ts +95 -0
  46. package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -0
  47. package/dist/codeSign/win/signtoolBaseSignManager.js +507 -0
  48. package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -0
  49. package/dist/codeSign/win/windowsCodeSign.d.ts +2 -1
  50. package/dist/codeSign/win/windowsCodeSign.d.ts.map +1 -1
  51. package/dist/codeSign/win/windowsCodeSign.js +22 -8
  52. package/dist/codeSign/win/windowsCodeSign.js.map +1 -1
  53. package/dist/codeSign/win/windowsSignAzureManager.d.ts +11 -4
  54. package/dist/codeSign/win/windowsSignAzureManager.d.ts.map +1 -1
  55. package/dist/codeSign/win/windowsSignAzureManager.js +142 -37
  56. package/dist/codeSign/win/windowsSignAzureManager.js.map +1 -1
  57. package/dist/codeSign/win/windowsSignToolManager.d.ts +1 -58
  58. package/dist/codeSign/win/windowsSignToolManager.d.ts.map +1 -1
  59. package/dist/codeSign/win/windowsSignToolManager.js +3 -363
  60. package/dist/codeSign/win/windowsSignToolManager.js.map +1 -1
  61. package/dist/configuration.d.ts +233 -166
  62. package/dist/configuration.d.ts.map +1 -1
  63. package/dist/configuration.js +11 -1
  64. package/dist/configuration.js.map +1 -1
  65. package/dist/core.d.ts +14 -0
  66. package/dist/core.d.ts.map +1 -1
  67. package/dist/core.js +11 -0
  68. package/dist/core.js.map +1 -1
  69. package/dist/electron/ElectronFramework.d.ts +3 -3
  70. package/dist/electron/ElectronFramework.d.ts.map +1 -1
  71. package/dist/electron/ElectronFramework.js +60 -61
  72. package/dist/electron/ElectronFramework.js.map +1 -1
  73. package/dist/electron/electronArchSupport.d.ts +12 -0
  74. package/dist/electron/electronArchSupport.d.ts.map +1 -0
  75. package/dist/electron/electronArchSupport.js +58 -0
  76. package/dist/electron/electronArchSupport.js.map +1 -0
  77. package/dist/electron/electronVersion.d.ts.map +1 -1
  78. package/dist/electron/electronVersion.js +1 -11
  79. package/dist/electron/electronVersion.js.map +1 -1
  80. package/dist/electron/injectFFMPEG.js +2 -2
  81. package/dist/electron/injectFFMPEG.js.map +1 -1
  82. package/dist/electron/mac/electronMac.js +24 -35
  83. package/dist/electron/mac/electronMac.js.map +1 -1
  84. package/dist/electron/mac/electronMacUtils.d.ts +24 -0
  85. package/dist/electron/mac/electronMacUtils.d.ts.map +1 -0
  86. package/dist/electron/mac/electronMacUtils.js +42 -0
  87. package/dist/electron/mac/electronMacUtils.js.map +1 -0
  88. package/dist/electron/win/electronWin.js +2 -2
  89. package/dist/electron/win/electronWin.js.map +1 -1
  90. package/dist/fileMatcher.d.ts +55 -3
  91. package/dist/fileMatcher.d.ts.map +1 -1
  92. package/dist/fileMatcher.js +274 -28
  93. package/dist/fileMatcher.js.map +1 -1
  94. package/dist/index.d.ts +13 -7
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +17 -1
  97. package/dist/index.js.map +1 -1
  98. package/dist/indexInternal.d.ts +20 -8
  99. package/dist/indexInternal.d.ts.map +1 -1
  100. package/dist/indexInternal.js +19 -7
  101. package/dist/indexInternal.js.map +1 -1
  102. package/dist/linuxPackager.d.ts.map +1 -1
  103. package/dist/linuxPackager.js +19 -1
  104. package/dist/linuxPackager.js.map +1 -1
  105. package/dist/macPackager.d.ts +31 -14
  106. package/dist/macPackager.d.ts.map +1 -1
  107. package/dist/macPackager.js +236 -147
  108. package/dist/macPackager.js.map +1 -1
  109. package/dist/node-module-collector/index.d.ts.map +1 -1
  110. package/dist/node-module-collector/index.js +47 -16
  111. package/dist/node-module-collector/index.js.map +1 -1
  112. package/dist/node-module-collector/moduleManager.d.ts +11 -2
  113. package/dist/node-module-collector/moduleManager.d.ts.map +1 -1
  114. package/dist/node-module-collector/moduleManager.js +34 -14
  115. package/dist/node-module-collector/moduleManager.js.map +1 -1
  116. package/dist/node-module-collector/nodeModulesCollector.d.ts +47 -26
  117. package/dist/node-module-collector/nodeModulesCollector.d.ts.map +1 -1
  118. package/dist/node-module-collector/nodeModulesCollector.js +157 -142
  119. package/dist/node-module-collector/nodeModulesCollector.js.map +1 -1
  120. package/dist/node-module-collector/packageManager.js +1 -1
  121. package/dist/node-module-collector/packageManager.js.map +1 -1
  122. package/dist/node-module-collector/pnpmNodeModulesCollector.d.ts +90 -1
  123. package/dist/node-module-collector/pnpmNodeModulesCollector.d.ts.map +1 -1
  124. package/dist/node-module-collector/pnpmNodeModulesCollector.js +325 -25
  125. package/dist/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
  126. package/dist/node-module-collector/types.d.ts +4 -0
  127. package/dist/node-module-collector/types.d.ts.map +1 -1
  128. package/dist/node-module-collector/types.js.map +1 -1
  129. package/dist/options/FuseOptionsV1.d.ts +137 -0
  130. package/dist/options/FuseOptionsV1.d.ts.map +1 -0
  131. package/dist/options/FuseOptionsV1.js +2 -0
  132. package/dist/options/FuseOptionsV1.js.map +1 -0
  133. package/dist/options/MsixOptions.d.ts +126 -0
  134. package/dist/options/MsixOptions.d.ts.map +1 -0
  135. package/dist/options/MsixOptions.js +2 -0
  136. package/dist/options/MsixOptions.js.map +1 -0
  137. package/dist/options/PlatformSpecificBuildOptions.d.ts +147 -12
  138. package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
  139. package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
  140. package/dist/options/SnapOptions.d.ts +59 -32
  141. package/dist/options/SnapOptions.d.ts.map +1 -1
  142. package/dist/options/SnapOptions.js.map +1 -1
  143. package/dist/options/SquirrelWindowsOptions.d.ts +0 -5
  144. package/dist/options/SquirrelWindowsOptions.d.ts.map +1 -1
  145. package/dist/options/SquirrelWindowsOptions.js.map +1 -1
  146. package/dist/options/linuxOptions.d.ts +61 -30
  147. package/dist/options/linuxOptions.d.ts.map +1 -1
  148. package/dist/options/linuxOptions.js.map +1 -1
  149. package/dist/options/macOptions.d.ts +113 -131
  150. package/dist/options/macOptions.d.ts.map +1 -1
  151. package/dist/options/macOptions.js.map +1 -1
  152. package/dist/options/pkgOptions.d.ts +1 -1
  153. package/dist/options/pkgOptions.js.map +1 -1
  154. package/dist/options/winOptions.d.ts +282 -70
  155. package/dist/options/winOptions.d.ts.map +1 -1
  156. package/dist/options/winOptions.js +12 -1
  157. package/dist/options/winOptions.js.map +1 -1
  158. package/dist/packager.d.ts +6 -1
  159. package/dist/packager.d.ts.map +1 -1
  160. package/dist/packager.js +123 -40
  161. package/dist/packager.js.map +1 -1
  162. package/dist/packagerApi.d.ts +10 -1
  163. package/dist/packagerApi.d.ts.map +1 -1
  164. package/dist/packagerApi.js.map +1 -1
  165. package/dist/platformPackager.d.ts +55 -4
  166. package/dist/platformPackager.d.ts.map +1 -1
  167. package/dist/platformPackager.js +160 -22
  168. package/dist/platformPackager.js.map +1 -1
  169. package/dist/presets/rectCra.js +3 -1
  170. package/dist/presets/rectCra.js.map +1 -1
  171. package/dist/publish/PublishManager.d.ts +40 -2
  172. package/dist/publish/PublishManager.d.ts.map +1 -1
  173. package/dist/publish/PublishManager.js +365 -23
  174. package/dist/publish/PublishManager.js.map +1 -1
  175. package/dist/publish/updateInfoBuilder.d.ts +1 -1
  176. package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
  177. package/dist/publish/updateInfoBuilder.js +108 -32
  178. package/dist/publish/updateInfoBuilder.js.map +1 -1
  179. package/dist/targets/ArchiveTarget.d.ts +1 -0
  180. package/dist/targets/ArchiveTarget.d.ts.map +1 -1
  181. package/dist/targets/ArchiveTarget.js +13 -4
  182. package/dist/targets/ArchiveTarget.js.map +1 -1
  183. package/dist/targets/archive.d.ts +39 -2
  184. package/dist/targets/archive.d.ts.map +1 -1
  185. package/dist/targets/archive.js +114 -30
  186. package/dist/targets/archive.js.map +1 -1
  187. package/dist/targets/blockmap/blockmap.d.ts +44 -3
  188. package/dist/targets/blockmap/blockmap.d.ts.map +1 -1
  189. package/dist/targets/blockmap/blockmap.js +142 -15
  190. package/dist/targets/blockmap/blockmap.js.map +1 -1
  191. package/dist/targets/blockmap/verbatimRange.d.ts +44 -0
  192. package/dist/targets/blockmap/verbatimRange.d.ts.map +1 -0
  193. package/dist/targets/blockmap/verbatimRange.js +117 -0
  194. package/dist/targets/blockmap/verbatimRange.js.map +1 -0
  195. package/dist/targets/differentialUpdateInfoBuilder.d.ts +28 -2
  196. package/dist/targets/differentialUpdateInfoBuilder.d.ts.map +1 -1
  197. package/dist/targets/differentialUpdateInfoBuilder.js +75 -6
  198. package/dist/targets/differentialUpdateInfoBuilder.js.map +1 -1
  199. package/dist/targets/linux/FlatpakTarget.d.ts +17 -0
  200. package/dist/targets/linux/FlatpakTarget.d.ts.map +1 -1
  201. package/dist/targets/linux/FlatpakTarget.js +245 -45
  202. package/dist/targets/linux/FlatpakTarget.js.map +1 -1
  203. package/dist/targets/linux/FpmTarget.d.ts +14 -0
  204. package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
  205. package/dist/targets/linux/FpmTarget.js +92 -12
  206. package/dist/targets/linux/FpmTarget.js.map +1 -1
  207. package/dist/targets/linux/LinuxTargetHelper.d.ts +13 -0
  208. package/dist/targets/linux/LinuxTargetHelper.d.ts.map +1 -1
  209. package/dist/targets/linux/LinuxTargetHelper.js +81 -61
  210. package/dist/targets/linux/LinuxTargetHelper.js.map +1 -1
  211. package/dist/targets/linux/appimage/AppImageTarget.d.ts +2 -0
  212. package/dist/targets/linux/appimage/AppImageTarget.d.ts.map +1 -1
  213. package/dist/targets/linux/appimage/AppImageTarget.js +20 -15
  214. package/dist/targets/linux/appimage/AppImageTarget.js.map +1 -1
  215. package/dist/targets/linux/appimage/appImageUtil.d.ts +8 -2
  216. package/dist/targets/linux/appimage/appImageUtil.d.ts.map +1 -1
  217. package/dist/targets/linux/appimage/appImageUtil.js +16 -9
  218. package/dist/targets/linux/appimage/appImageUtil.js.map +1 -1
  219. package/dist/targets/linux/appimage/appLauncher.d.ts +6 -0
  220. package/dist/targets/linux/appimage/appLauncher.d.ts.map +1 -1
  221. package/dist/targets/linux/appimage/appLauncher.js +18 -20
  222. package/dist/targets/linux/appimage/appLauncher.js.map +1 -1
  223. package/dist/targets/linux/flatpakBundle.d.ts +43 -0
  224. package/dist/targets/linux/flatpakBundle.d.ts.map +1 -0
  225. package/dist/targets/linux/flatpakBundle.js +210 -0
  226. package/dist/targets/linux/flatpakBundle.js.map +1 -0
  227. package/dist/targets/linux/launcherScript.d.ts +32 -0
  228. package/dist/targets/linux/launcherScript.d.ts.map +1 -0
  229. package/dist/targets/linux/launcherScript.js +24 -0
  230. package/dist/targets/linux/launcherScript.js.map +1 -0
  231. package/dist/targets/linux/snap/SnapTarget.d.ts +1 -1
  232. package/dist/targets/linux/snap/SnapTarget.d.ts.map +1 -1
  233. package/dist/targets/linux/snap/SnapTarget.js +23 -1
  234. package/dist/targets/linux/snap/SnapTarget.js.map +1 -1
  235. package/dist/targets/linux/snap/core24.d.ts +13 -2
  236. package/dist/targets/linux/snap/core24.d.ts.map +1 -1
  237. package/dist/targets/linux/snap/core24.js +107 -95
  238. package/dist/targets/linux/snap/core24.js.map +1 -1
  239. package/dist/targets/linux/snap/coreCustom.d.ts +1 -1
  240. package/dist/targets/linux/snap/coreCustom.d.ts.map +1 -1
  241. package/dist/targets/linux/snap/coreCustom.js +2 -2
  242. package/dist/targets/linux/snap/coreCustom.js.map +1 -1
  243. package/dist/targets/linux/snap/coreLegacy.d.ts +10 -3
  244. package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
  245. package/dist/targets/linux/snap/coreLegacy.js +37 -18
  246. package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
  247. package/dist/targets/linux/snap/snapCommand.d.ts +13 -0
  248. package/dist/targets/linux/snap/snapCommand.d.ts.map +1 -0
  249. package/dist/targets/linux/snap/snapCommand.js +21 -0
  250. package/dist/targets/linux/snap/snapCommand.js.map +1 -0
  251. package/dist/targets/linux/snap/snapPlugs.d.ts +76 -0
  252. package/dist/targets/linux/snap/snapPlugs.d.ts.map +1 -0
  253. package/dist/targets/linux/snap/snapPlugs.js +242 -0
  254. package/dist/targets/linux/snap/snapPlugs.js.map +1 -0
  255. package/dist/targets/linux/snap/snapcraft.d.ts +190 -0
  256. package/dist/targets/linux/snap/snapcraft.d.ts.map +1 -0
  257. package/dist/targets/linux/snap/snapcraft.js +11 -0
  258. package/dist/targets/linux/snap/snapcraft.js.map +1 -0
  259. package/dist/targets/linux/snap/snapcraftBuilder.d.ts +7 -1
  260. package/dist/targets/linux/snap/snapcraftBuilder.d.ts.map +1 -1
  261. package/dist/targets/linux/snap/snapcraftBuilder.js +57 -20
  262. package/dist/targets/linux/snap/snapcraftBuilder.js.map +1 -1
  263. package/dist/targets/mac/MacTargetHelper.d.ts +146 -14
  264. package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
  265. package/dist/targets/mac/MacTargetHelper.js +485 -91
  266. package/dist/targets/mac/MacTargetHelper.js.map +1 -1
  267. package/dist/targets/mac/pkg.d.ts +16 -0
  268. package/dist/targets/mac/pkg.d.ts.map +1 -1
  269. package/dist/targets/mac/pkg.js +31 -5
  270. package/dist/targets/mac/pkg.js.map +1 -1
  271. package/dist/targets/targetFactory.d.ts +7 -0
  272. package/dist/targets/targetFactory.d.ts.map +1 -1
  273. package/dist/targets/targetFactory.js +28 -0
  274. package/dist/targets/targetFactory.js.map +1 -1
  275. package/dist/targets/win/AppxTarget.d.ts +1 -2
  276. package/dist/targets/win/AppxTarget.d.ts.map +1 -1
  277. package/dist/targets/win/AppxTarget.js +37 -314
  278. package/dist/targets/win/AppxTarget.js.map +1 -1
  279. package/dist/targets/win/MsiTarget.d.ts.map +1 -1
  280. package/dist/targets/win/MsiTarget.js +13 -13
  281. package/dist/targets/win/MsiTarget.js.map +1 -1
  282. package/dist/targets/win/MsixTarget.d.ts +22 -0
  283. package/dist/targets/win/MsixTarget.d.ts.map +1 -0
  284. package/dist/targets/win/MsixTarget.js +214 -0
  285. package/dist/targets/win/MsixTarget.js.map +1 -0
  286. package/dist/targets/win/nsis/Defines.d.ts +4 -0
  287. package/dist/targets/win/nsis/Defines.d.ts.map +1 -1
  288. package/dist/targets/win/nsis/Defines.js.map +1 -1
  289. package/dist/targets/win/nsis/NsisTarget.d.ts +64 -3
  290. package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
  291. package/dist/targets/win/nsis/NsisTarget.js +277 -113
  292. package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
  293. package/dist/targets/win/nsis/WebInstallerTarget.d.ts.map +1 -1
  294. package/dist/targets/win/nsis/WebInstallerTarget.js +23 -12
  295. package/dist/targets/win/nsis/WebInstallerTarget.js.map +1 -1
  296. package/dist/targets/win/nsis/nsisOptions.d.ts +58 -48
  297. package/dist/targets/win/nsis/nsisOptions.d.ts.map +1 -1
  298. package/dist/targets/win/nsis/nsisOptions.js.map +1 -1
  299. package/dist/targets/win/nsis/nsisScriptGenerator.d.ts.map +1 -1
  300. package/dist/targets/win/nsis/nsisScriptGenerator.js +4 -3
  301. package/dist/targets/win/nsis/nsisScriptGenerator.js.map +1 -1
  302. package/dist/targets/win/nsis/nsisUtil.d.ts +17 -2
  303. package/dist/targets/win/nsis/nsisUtil.d.ts.map +1 -1
  304. package/dist/targets/win/nsis/nsisUtil.js +148 -41
  305. package/dist/targets/win/nsis/nsisUtil.js.map +1 -1
  306. package/dist/targets/win/nsis/progId.d.ts +21 -0
  307. package/dist/targets/win/nsis/progId.d.ts.map +1 -0
  308. package/dist/targets/win/nsis/progId.js +60 -0
  309. package/dist/targets/win/nsis/progId.js.map +1 -0
  310. package/dist/targets/win/winAppUtil.d.ts +115 -0
  311. package/dist/targets/win/winAppUtil.d.ts.map +1 -0
  312. package/dist/targets/win/winAppUtil.js +409 -0
  313. package/dist/targets/win/winAppUtil.js.map +1 -0
  314. package/dist/toolsets/7zip.d.ts +32 -0
  315. package/dist/toolsets/7zip.d.ts.map +1 -1
  316. package/dist/toolsets/7zip.js +39 -11
  317. package/dist/toolsets/7zip.js.map +1 -1
  318. package/dist/toolsets/appimage.d.ts +3 -3
  319. package/dist/toolsets/appimage.d.ts.map +1 -1
  320. package/dist/toolsets/appimage.js +24 -21
  321. package/dist/toolsets/appimage.js.map +1 -1
  322. package/dist/toolsets/custom.d.ts +2 -3
  323. package/dist/toolsets/custom.d.ts.map +1 -1
  324. package/dist/toolsets/custom.js +67 -149
  325. package/dist/toolsets/custom.js.map +1 -1
  326. package/dist/toolsets/fpm.d.ts.map +1 -1
  327. package/dist/toolsets/fpm.js +11 -5
  328. package/dist/toolsets/fpm.js.map +1 -1
  329. package/dist/toolsets/icons.d.ts.map +1 -1
  330. package/dist/toolsets/icons.js +17 -3
  331. package/dist/toolsets/icons.js.map +1 -1
  332. package/dist/toolsets/linuxToolsMac.d.ts.map +1 -1
  333. package/dist/toolsets/linuxToolsMac.js +17 -4
  334. package/dist/toolsets/linuxToolsMac.js.map +1 -1
  335. package/dist/toolsets/nsis.d.ts +5 -0
  336. package/dist/toolsets/nsis.d.ts.map +1 -1
  337. package/dist/toolsets/nsis.js +20 -4
  338. package/dist/toolsets/nsis.js.map +1 -1
  339. package/dist/toolsets/version.d.ts +12 -0
  340. package/dist/toolsets/version.d.ts.map +1 -0
  341. package/dist/toolsets/version.js +13 -0
  342. package/dist/toolsets/version.js.map +1 -0
  343. package/dist/toolsets/winCodeSign.d.ts +56 -3
  344. package/dist/toolsets/winCodeSign.d.ts.map +1 -1
  345. package/dist/toolsets/winCodeSign.js +125 -42
  346. package/dist/toolsets/winCodeSign.js.map +1 -1
  347. package/dist/toolsets/wine.d.ts +2 -1
  348. package/dist/toolsets/wine.d.ts.map +1 -1
  349. package/dist/toolsets/wine.js +31 -15
  350. package/dist/toolsets/wine.js.map +1 -1
  351. package/dist/util/AppFileWalker.js +9 -1
  352. package/dist/util/AppFileWalker.js.map +1 -1
  353. package/dist/util/NodeModuleCopyHelper.js +14 -6
  354. package/dist/util/NodeModuleCopyHelper.js.map +1 -1
  355. package/dist/util/appFileCopier.d.ts +67 -2
  356. package/dist/util/appFileCopier.d.ts.map +1 -1
  357. package/dist/util/appFileCopier.js +244 -32
  358. package/dist/util/appFileCopier.js.map +1 -1
  359. package/dist/util/archCompatibility.d.ts +42 -0
  360. package/dist/util/archCompatibility.d.ts.map +1 -0
  361. package/dist/util/archCompatibility.js +202 -0
  362. package/dist/util/archCompatibility.js.map +1 -0
  363. package/dist/util/checksum.d.ts +36 -0
  364. package/dist/util/checksum.d.ts.map +1 -0
  365. package/dist/util/checksum.js +48 -0
  366. package/dist/util/checksum.js.map +1 -0
  367. package/dist/util/config/config.d.ts +2 -1
  368. package/dist/util/config/config.d.ts.map +1 -1
  369. package/dist/util/config/config.js +42 -20
  370. package/dist/util/config/config.js.map +1 -1
  371. package/dist/util/config/fileOptions.d.ts +30 -0
  372. package/dist/util/config/fileOptions.d.ts.map +1 -0
  373. package/dist/util/config/fileOptions.js +120 -0
  374. package/dist/util/config/fileOptions.js.map +1 -0
  375. package/dist/util/config/legacyConfigGuard.d.ts +7 -0
  376. package/dist/util/config/legacyConfigGuard.d.ts.map +1 -0
  377. package/dist/util/config/legacyConfigGuard.js +214 -0
  378. package/dist/util/config/legacyConfigGuard.js.map +1 -0
  379. package/dist/util/config/legacyOptions.d.ts +86 -0
  380. package/dist/util/config/legacyOptions.d.ts.map +1 -0
  381. package/dist/util/config/legacyOptions.js +413 -0
  382. package/dist/util/config/legacyOptions.js.map +1 -0
  383. package/dist/util/config/load.d.ts +2 -2
  384. package/dist/util/config/load.d.ts.map +1 -1
  385. package/dist/util/config/load.js +3 -12
  386. package/dist/util/config/load.js.map +1 -1
  387. package/dist/util/config/schemaValidator.d.ts.map +1 -1
  388. package/dist/util/config/schemaValidator.js +26 -3
  389. package/dist/util/config/schemaValidator.js.map +1 -1
  390. package/dist/util/electronGet.d.ts +43 -32
  391. package/dist/util/electronGet.d.ts.map +1 -1
  392. package/dist/util/electronGet.js +390 -137
  393. package/dist/util/electronGet.js.map +1 -1
  394. package/dist/util/flags.d.ts +5 -5
  395. package/dist/util/flags.d.ts.map +1 -1
  396. package/dist/util/flags.js +124 -16
  397. package/dist/util/flags.js.map +1 -1
  398. package/dist/util/hash.d.ts +1 -1
  399. package/dist/util/hash.d.ts.map +1 -1
  400. package/dist/util/hash.js +1 -15
  401. package/dist/util/hash.js.map +1 -1
  402. package/dist/util/installOrRebuild.d.ts +44 -0
  403. package/dist/util/installOrRebuild.d.ts.map +1 -0
  404. package/dist/util/installOrRebuild.js +276 -0
  405. package/dist/util/installOrRebuild.js.map +1 -0
  406. package/dist/util/langs.d.ts.map +1 -1
  407. package/dist/util/langs.js +1 -0
  408. package/dist/util/langs.js.map +1 -1
  409. package/dist/util/license.d.ts.map +1 -1
  410. package/dist/util/license.js +4 -1
  411. package/dist/util/license.js.map +1 -1
  412. package/dist/util/mac/macosIconComposer.d.ts +2 -1
  413. package/dist/util/mac/macosIconComposer.d.ts.map +1 -1
  414. package/dist/util/mac/macosIconComposer.js +40 -58
  415. package/dist/util/mac/macosIconComposer.js.map +1 -1
  416. package/dist/util/mac/macosVersion.d.ts +0 -1
  417. package/dist/util/mac/macosVersion.d.ts.map +1 -1
  418. package/dist/util/mac/macosVersion.js +0 -3
  419. package/dist/util/mac/macosVersion.js.map +1 -1
  420. package/dist/util/mac/plist.d.ts +1 -1
  421. package/dist/util/mac/plist.d.ts.map +1 -1
  422. package/dist/util/mac/plist.js +5 -0
  423. package/dist/util/mac/plist.js.map +1 -1
  424. package/dist/util/nativeBinaryVerifier.d.ts +40 -0
  425. package/dist/util/nativeBinaryVerifier.d.ts.map +1 -0
  426. package/dist/util/nativeBinaryVerifier.js +381 -0
  427. package/dist/util/nativeBinaryVerifier.js.map +1 -0
  428. package/dist/util/packageMetadata.js +57 -31
  429. package/dist/util/packageMetadata.js.map +1 -1
  430. package/dist/util/removedEnvVars.d.ts +25 -0
  431. package/dist/util/removedEnvVars.d.ts.map +1 -0
  432. package/dist/util/removedEnvVars.js +54 -0
  433. package/dist/util/removedEnvVars.js.map +1 -0
  434. package/dist/util/repositoryInfo.js +6 -3
  435. package/dist/util/repositoryInfo.js.map +1 -1
  436. package/dist/util/resolve.js +1 -1
  437. package/dist/util/resolve.js.map +1 -1
  438. package/dist/util/streamSpawnToFile.d.ts +47 -0
  439. package/dist/util/streamSpawnToFile.d.ts.map +1 -0
  440. package/dist/util/streamSpawnToFile.js +110 -0
  441. package/dist/util/streamSpawnToFile.js.map +1 -0
  442. package/dist/util/toolsetLock.d.ts +2 -0
  443. package/dist/util/toolsetLock.d.ts.map +1 -1
  444. package/dist/util/toolsetLock.js +31 -5
  445. package/dist/util/toolsetLock.js.map +1 -1
  446. package/dist/util/trustedSourceRoots.d.ts +59 -0
  447. package/dist/util/trustedSourceRoots.d.ts.map +1 -0
  448. package/dist/util/trustedSourceRoots.js +127 -0
  449. package/dist/util/trustedSourceRoots.js.map +1 -0
  450. package/dist/version.d.ts +1 -1
  451. package/dist/version.d.ts.map +1 -1
  452. package/dist/version.js +1 -1
  453. package/dist/version.js.map +1 -1
  454. package/dist/vm/ParallelsVm.d.ts.map +1 -1
  455. package/dist/vm/ParallelsVm.js +29 -3
  456. package/dist/vm/ParallelsVm.js.map +1 -1
  457. package/dist/vm/vm.d.ts +2 -0
  458. package/dist/vm/vm.d.ts.map +1 -1
  459. package/dist/vm/vm.js +29 -6
  460. package/dist/vm/vm.js.map +1 -1
  461. package/dist/winPackager.d.ts +6 -5
  462. package/dist/winPackager.d.ts.map +1 -1
  463. package/dist/winPackager.js +45 -39
  464. package/dist/winPackager.js.map +1 -1
  465. package/package.json +20 -20
  466. package/scheme.json +2112 -1495
  467. package/templates/appx/appxmanifest.xml +2 -3
  468. package/templates/entitlements.mac.adhoc.plist +15 -0
  469. package/templates/entitlements.mac.plist +9 -6
  470. package/templates/msix/appxmanifest.xml +45 -0
  471. package/templates/nsis/assistedMessages.yml +17 -0
  472. package/templates/nsis/common.nsh +2 -2
  473. package/templates/nsis/include/allowOnlyOneInstallerInstance.nsh +96 -13
  474. package/templates/nsis/include/extractAppPackage.nsh +5 -2
  475. package/templates/nsis/include/installUtil.nsh +2 -2
  476. package/templates/nsis/include/installer.nsh +94 -53
  477. package/templates/nsis/include/webPackage.nsh +52 -27
  478. package/templates/nsis/installSection.nsh +29 -0
  479. package/templates/nsis/installer.nsi +1 -1
  480. package/templates/nsis/messages.yml +5 -0
  481. package/templates/nsis/multiUserUi.nsh +1 -1
  482. package/dist/codeSign/signManager.d.ts +0 -14
  483. package/dist/codeSign/signManager.d.ts.map +0 -1
  484. package/dist/codeSign/signManager.js +0 -2
  485. package/dist/codeSign/signManager.js.map +0 -1
  486. package/dist/util/yarn.d.ts +0 -23
  487. package/dist/util/yarn.d.ts.map +0 -1
  488. package/dist/util/yarn.js +0 -153
  489. package/dist/util/yarn.js.map +0 -1
@@ -1,14 +1,8 @@
1
- import * as path from "path";
1
+ import path from "path";
2
2
  import fs from "fs-extra";
3
- import { copyOrLinkFile, log } from "builder-util";
3
+ import { copyOrLinkFile, log, escapeForXml } from "builder-util";
4
4
  const ICON_DIR_RELATIVE_PATH = "usr/share/icons/hicolor";
5
5
  const MIME_TYPE_DIR_RELATIVE_PATH = "usr/share/mime/packages";
6
- /**
7
- * Escapes special XML characters to prevent injection
8
- */
9
- function xmlEscape(str) {
10
- return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
11
- }
12
6
  export async function copyIcons(options) {
13
7
  const { stageDir, options: configuration } = options;
14
8
  const iconCommonDir = path.join(stageDir, ICON_DIR_RELATIVE_PATH);
@@ -46,22 +40,19 @@ export async function copyIcons(options) {
46
40
  await fs.symlink(iconRelativeToStageFile, path.join(stageDir, iconFileName));
47
41
  await fs.symlink(iconRelativeToStageFile, path.join(stageDir, ".DirIcon"));
48
42
  }
49
- export async function copyMimeTypes(stageDir, options) {
50
- const { fileAssociations, productName, executableName } = options;
51
- if (!fileAssociations || fileAssociations.length === 0) {
52
- return null;
53
- }
54
- if (!fileAssociations || fileAssociations.length === 0) {
55
- return null;
56
- }
43
+ /**
44
+ * The shared-mime-info XML that declares the MIME types of the file associations that have one, or null when none has. Every value
45
+ * is XML-escaped, and an extension with characters other than `A-Za-z0-9_-` is skipped with a warning.
46
+ */
47
+ export function generateMimeTypeXml(fileAssociations, productName) {
57
48
  const mimeTypeParts = [];
58
49
  for (const fileAssociation of fileAssociations) {
59
50
  if (!fileAssociation.mimeType) {
60
51
  continue;
61
52
  }
62
53
  // XML-escape to prevent injection
63
- mimeTypeParts.push(`<mime-type type="${xmlEscape(fileAssociation.mimeType)}">`);
64
- mimeTypeParts.push(` <comment>${xmlEscape(productName)} document</comment>`);
54
+ mimeTypeParts.push(`<mime-type type="${escapeForXml(fileAssociation.mimeType)}">`);
55
+ mimeTypeParts.push(` <comment>${escapeForXml(productName)} document</comment>`);
65
56
  // Handle extension(s)
66
57
  const extensions = Array.isArray(fileAssociation.ext) ? fileAssociation.ext : [fileAssociation.ext];
67
58
  for (const ext of extensions) {
@@ -70,7 +61,7 @@ export async function copyMimeTypes(stageDir, options) {
70
61
  log.warn({ extension: ext }, `file extension contains unexpected characters and will be skipped`);
71
62
  continue;
72
63
  }
73
- mimeTypeParts.push(` <glob pattern="*.${xmlEscape(ext)}"/>`);
64
+ mimeTypeParts.push(` <glob pattern="*.${escapeForXml(ext)}"/>`);
74
65
  }
75
66
  mimeTypeParts.push(' <generic-icon name="x-office-document"/>');
76
67
  mimeTypeParts.push("</mime-type>");
@@ -79,11 +70,18 @@ export async function copyMimeTypes(stageDir, options) {
79
70
  if (mimeTypeParts.length === 0) {
80
71
  return null;
81
72
  }
73
+ return ['<?xml version="1.0"?>', '<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">', ...mimeTypeParts, "</mime-info>"].join("\n");
74
+ }
75
+ export async function copyMimeTypes(stageDir, options) {
76
+ const { fileAssociations, productName, executableName } = options;
77
+ const xmlContent = generateMimeTypeXml(fileAssociations ?? [], productName);
78
+ if (xmlContent == null) {
79
+ return null;
80
+ }
82
81
  const mimeTypeDir = path.join(stageDir, MIME_TYPE_DIR_RELATIVE_PATH);
83
82
  const fileName = `${executableName}.xml`;
84
83
  const mimeTypeFile = path.join(mimeTypeDir, fileName);
85
84
  await fs.ensureDir(mimeTypeDir);
86
- const xmlContent = ['<?xml version="1.0"?>', '<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">', ...mimeTypeParts, "</mime-info>"].join("\n");
87
85
  // Use 0o644 (rw-r--r--) instead of 0o666 to avoid world-writable permissions
88
86
  await fs.writeFile(mimeTypeFile, xmlContent, { mode: 0o644 });
89
87
  return path.join(MIME_TYPE_DIR_RELATIVE_PATH, fileName);
@@ -1 +1 @@
1
- {"version":3,"file":"appLauncher.js","sourceRoot":"","sources":["../../../../src/targets/linux/appimage/appLauncher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAGlD,MAAM,sBAAsB,GAAG,yBAAyB,CAAA;AACxD,MAAM,2BAA2B,GAAG,yBAAyB,CAAA;AAE7D;;GAEG;AACH,SAAS,SAAS,CAAC,GAAW;IAC5B,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAA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AI,CAAC,IAAI,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAA;IACpE,MAAM,QAAQ,GAAG,GAAG,cAAc,MAAM,CAAA;IACxC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;IAErD,MAAM,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IAE/B,MAAM,UAAU,GAAG,CAAC,uBAAuB,EAAE,2EAA2E,EAAE,GAAG,aAAa,EAAE,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEtK,6EAA6E;IAC7E,MAAM,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IAE7D,OAAO,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,QAAQ,CAAC,CAAA;AACzD,CAAC","sourcesContent":["import * as path from \"path\"\nimport fs from \"fs-extra\"\nimport { copyOrLinkFile, log } from \"builder-util\"\nimport { AppImageBuilderOptions } from \"./appImageUtil.js\"\n\nconst ICON_DIR_RELATIVE_PATH = \"usr/share/icons/hicolor\"\nconst MIME_TYPE_DIR_RELATIVE_PATH = \"usr/share/mime/packages\"\n\n/**\n * Escapes special XML characters to prevent injection\n */\nfunction xmlEscape(str: string): string {\n return str.replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\").replace(/\"/g, \"&quot;\").replace(/'/g, \"&apos;\")\n}\n\nexport async function copyIcons(options: AppImageBuilderOptions): Promise<void> {\n const { stageDir, options: configuration } = options\n const iconCommonDir = path.join(stageDir, ICON_DIR_RELATIVE_PATH)\n\n await fs.ensureDir(iconCommonDir)\n\n const icons = configuration.icons\n if (!icons || icons.length === 0) {\n throw new Error(\"At least one icon is required for AppImage\")\n }\n\n const iconExtWithDot = path.extname(icons[0].file)\n const iconFileName = `${configuration.executableName}${iconExtWithDot}`\n const maxIconIndex = icons.length - 1\n\n const iconInfoList = icons.map(icon => {\n if (path.extname(icon.file) !== iconExtWithDot) {\n throw new Error(`All icons must have the same extension: expected ${iconExtWithDot}, but got ${icon.file}`)\n }\n let iconSizeDir: string\n\n if (iconExtWithDot === \".svg\") {\n // SVG icons go in scalable/apps directory per freedesktop icon theme spec\n iconSizeDir = \"scalable/apps\"\n } else {\n iconSizeDir = `${icon.size}x${icon.size}/apps`\n }\n\n const iconRelativeToStageFile = path.join(ICON_DIR_RELATIVE_PATH, iconSizeDir, iconFileName)\n const iconDir = path.join(iconCommonDir, iconSizeDir)\n const iconFile = path.join(iconDir, iconFileName)\n return { icon, iconDir, iconFile, iconRelativeToStageFile }\n })\n await Promise.all(\n iconInfoList.map(async ({ icon, iconDir, iconFile }) => {\n await fs.ensureDir(iconDir)\n await copyOrLinkFile(icon.file, iconFile)\n })\n )\n // Create symlinks for the last (largest) icon\n const { iconRelativeToStageFile } = iconInfoList[maxIconIndex]\n await fs.symlink(iconRelativeToStageFile, path.join(stageDir, iconFileName))\n await fs.symlink(iconRelativeToStageFile, path.join(stageDir, \".DirIcon\"))\n}\n\nexport async function copyMimeTypes(\n stageDir: string,\n options: Pick<AppImageBuilderOptions[\"options\"], \"fileAssociations\" | \"productName\" | \"executableName\">\n): Promise<string | null> {\n const { fileAssociations, productName, executableName } = options\n\n if (!fileAssociations || fileAssociations.length === 0) {\n return null\n }\n\n if (!fileAssociations || fileAssociations.length === 0) {\n return null\n }\n\n const mimeTypeParts: string[] = []\n\n for (const fileAssociation of fileAssociations) {\n if (!fileAssociation.mimeType) {\n continue\n }\n\n // XML-escape to prevent injection\n mimeTypeParts.push(`<mime-type type=\"${xmlEscape(fileAssociation.mimeType)}\">`)\n mimeTypeParts.push(` <comment>${xmlEscape(productName)} document</comment>`)\n\n // Handle extension(s)\n const extensions = Array.isArray(fileAssociation.ext) ? fileAssociation.ext : [fileAssociation.ext]\n\n for (const ext of extensions) {\n // Validate extension doesn't contain dangerous characters\n if (!/^[a-zA-Z0-9_-]+$/.test(ext)) {\n log.warn({ extension: ext }, `file extension contains unexpected characters and will be skipped`)\n continue\n }\n mimeTypeParts.push(` <glob pattern=\"*.${xmlEscape(ext)}\"/>`)\n }\n\n mimeTypeParts.push(' <generic-icon name=\"x-office-document\"/>')\n mimeTypeParts.push(\"</mime-type>\")\n }\n\n // If no mime-types were generated, return null\n if (mimeTypeParts.length === 0) {\n return null\n }\n\n const mimeTypeDir = path.join(stageDir, MIME_TYPE_DIR_RELATIVE_PATH)\n const fileName = `${executableName}.xml`\n const mimeTypeFile = path.join(mimeTypeDir, fileName)\n\n await fs.ensureDir(mimeTypeDir)\n\n const xmlContent = ['<?xml version=\"1.0\"?>', '<mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">', ...mimeTypeParts, \"</mime-info>\"].join(\"\\n\")\n\n // Use 0o644 (rw-r--r--) instead of 0o666 to avoid world-writable permissions\n await fs.writeFile(mimeTypeFile, xmlContent, { mode: 0o644 })\n\n return path.join(MIME_TYPE_DIR_RELATIVE_PATH, fileName)\n}\n"]}
1
+ {"version":3,"file":"appLauncher.js","sourceRoot":"","sources":["../../../../src/targets/linux/appimage/appLauncher.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAIhE,MAAM,sBAAsB,GAAG,yBAAyB,CAAA;AACxD,MAAM,2BAA2B,GAAG,yBAAyB,CAAA;AAE7D,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAA+B;IAC7D,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,OAAO,CAAA;IACpD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAA;IAEjE,MAAM,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,CAAA;IA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IAC7E,MAAM,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IAE7D,OAAO,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,QAAQ,CAAC,CAAA;AACzD,CAAC","sourcesContent":["import path from \"path\"\nimport fs from \"fs-extra\"\nimport { copyOrLinkFile, log, escapeForXml } from \"builder-util\"\nimport { FileAssociation } from \"../../../options/FileAssociation.js\"\nimport { AppImageBuilderOptions } from \"./appImageUtil.js\"\n\nconst ICON_DIR_RELATIVE_PATH = \"usr/share/icons/hicolor\"\nconst MIME_TYPE_DIR_RELATIVE_PATH = \"usr/share/mime/packages\"\n\nexport async function copyIcons(options: AppImageBuilderOptions): Promise<void> {\n const { stageDir, options: configuration } = options\n const iconCommonDir = path.join(stageDir, ICON_DIR_RELATIVE_PATH)\n\n await fs.ensureDir(iconCommonDir)\n\n const icons = configuration.icons\n if (!icons || icons.length === 0) {\n throw new Error(\"At least one icon is required for AppImage\")\n }\n\n const iconExtWithDot = path.extname(icons[0].file)\n const iconFileName = `${configuration.executableName}${iconExtWithDot}`\n const maxIconIndex = icons.length - 1\n\n const iconInfoList = icons.map(icon => {\n if (path.extname(icon.file) !== iconExtWithDot) {\n throw new Error(`All icons must have the same extension: expected ${iconExtWithDot}, but got ${icon.file}`)\n }\n let iconSizeDir: string\n\n if (iconExtWithDot === \".svg\") {\n // SVG icons go in scalable/apps directory per freedesktop icon theme spec\n iconSizeDir = \"scalable/apps\"\n } else {\n iconSizeDir = `${icon.size}x${icon.size}/apps`\n }\n\n const iconRelativeToStageFile = path.join(ICON_DIR_RELATIVE_PATH, iconSizeDir, iconFileName)\n const iconDir = path.join(iconCommonDir, iconSizeDir)\n const iconFile = path.join(iconDir, iconFileName)\n return { icon, iconDir, iconFile, iconRelativeToStageFile }\n })\n await Promise.all(\n iconInfoList.map(async ({ icon, iconDir, iconFile }) => {\n await fs.ensureDir(iconDir)\n await copyOrLinkFile(icon.file, iconFile)\n })\n )\n // Create symlinks for the last (largest) icon\n const { iconRelativeToStageFile } = iconInfoList[maxIconIndex]\n await fs.symlink(iconRelativeToStageFile, path.join(stageDir, iconFileName))\n await fs.symlink(iconRelativeToStageFile, path.join(stageDir, \".DirIcon\"))\n}\n\n/**\n * The shared-mime-info XML that declares the MIME types of the file associations that have one, or null when none has. Every value\n * is XML-escaped, and an extension with characters other than `A-Za-z0-9_-` is skipped with a warning.\n */\nexport function generateMimeTypeXml(fileAssociations: ReadonlyArray<FileAssociation>, productName: string): string | null {\n const mimeTypeParts: string[] = []\n\n for (const fileAssociation of fileAssociations) {\n if (!fileAssociation.mimeType) {\n continue\n }\n\n // XML-escape to prevent injection\n mimeTypeParts.push(`<mime-type type=\"${escapeForXml(fileAssociation.mimeType)}\">`)\n mimeTypeParts.push(` <comment>${escapeForXml(productName)} document</comment>`)\n\n // Handle extension(s)\n const extensions = Array.isArray(fileAssociation.ext) ? fileAssociation.ext : [fileAssociation.ext]\n\n for (const ext of extensions) {\n // Validate extension doesn't contain dangerous characters\n if (!/^[a-zA-Z0-9_-]+$/.test(ext)) {\n log.warn({ extension: ext }, `file extension contains unexpected characters and will be skipped`)\n continue\n }\n mimeTypeParts.push(` <glob pattern=\"*.${escapeForXml(ext)}\"/>`)\n }\n\n mimeTypeParts.push(' <generic-icon name=\"x-office-document\"/>')\n mimeTypeParts.push(\"</mime-type>\")\n }\n\n // If no mime-types were generated, return null\n if (mimeTypeParts.length === 0) {\n return null\n }\n\n return ['<?xml version=\"1.0\"?>', '<mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">', ...mimeTypeParts, \"</mime-info>\"].join(\"\\n\")\n}\n\nexport async function copyMimeTypes(\n stageDir: string,\n options: Pick<AppImageBuilderOptions[\"options\"], \"fileAssociations\" | \"productName\" | \"executableName\">\n): Promise<string | null> {\n const { fileAssociations, productName, executableName } = options\n\n const xmlContent = generateMimeTypeXml(fileAssociations ?? [], productName)\n if (xmlContent == null) {\n return null\n }\n\n const mimeTypeDir = path.join(stageDir, MIME_TYPE_DIR_RELATIVE_PATH)\n const fileName = `${executableName}.xml`\n const mimeTypeFile = path.join(mimeTypeDir, fileName)\n\n await fs.ensureDir(mimeTypeDir)\n\n // Use 0o644 (rw-r--r--) instead of 0o666 to avoid world-writable permissions\n await fs.writeFile(mimeTypeFile, xmlContent, { mode: 0o644 })\n\n return path.join(MIME_TYPE_DIR_RELATIVE_PATH, fileName)\n}\n"]}
@@ -0,0 +1,43 @@
1
+ /** The part of a [flatpak-builder manifest](https://docs.flatpak.org/en/latest/flatpak-builder-command-reference.html#flatpak-manifest) that the flatpak target writes. */
2
+ export interface FlatpakBuilderManifest {
3
+ id: string;
4
+ command: string;
5
+ runtime: string;
6
+ "runtime-version": string;
7
+ sdk: string;
8
+ base: string;
9
+ "base-version": string;
10
+ "finish-args": string[];
11
+ branch?: string;
12
+ modules?: (string | any)[];
13
+ }
14
+ /** The refs a build needs: the runtime, the SDK and the base app of the manifest. */
15
+ export type FlatpakRefKind = "runtime" | "sdk" | "base";
16
+ export interface FlatpakBundleOptions {
17
+ manifest: FlatpakBuilderManifest;
18
+ /** flatpak's name for the target architecture, e.g. `x86_64` */
19
+ arch: string;
20
+ /** where to write the single-file bundle */
21
+ artifactPath: string;
22
+ /** an empty directory for the manifest, the app directory, the repository and the state of flatpak-builder */
23
+ tempDir: string;
24
+ /** `[source, destination]` pairs, copied in order; a destination is relative to the app prefix (`/app` in the sandbox) */
25
+ files: [string, string][];
26
+ /** `[target, link]` pairs, both relative to the app prefix */
27
+ symlinks: [string, string][];
28
+ /** the refs to install when they are missing and update when they are installed; the others are used as installed, and have to be */
29
+ installOrUpdateRefs: ReadonlyArray<FlatpakRefKind>;
30
+ /** added to both runs of flatpak-builder */
31
+ flatpakBuilderArgs: string[];
32
+ buildExportArgs: string[];
33
+ buildBundleArgs: string[];
34
+ }
35
+ /**
36
+ * Builds a single-file flatpak bundle out of files that are already built.
37
+ *
38
+ * flatpak-builder runs twice. `--build-only` creates the app directory from the base app (and builds the modules of the
39
+ * manifest, if any) and stops, the files are then placed into the app prefix, and `--finish-only` turns the directory into an
40
+ * app with the permissions of the manifest. Nothing has to run inside the build sandbox to get the files in.
41
+ */
42
+ export declare function buildFlatpakBundle(options: FlatpakBundleOptions): Promise<void>;
43
+ //# sourceMappingURL=flatpakBundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flatpakBundle.d.ts","sourceRoot":"","sources":["../../../src/targets/linux/flatpakBundle.ts"],"names":[],"mappings":"AAmBA,2KAA2K;AAC3K,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,iBAAiB,EAAE,MAAM,CAAA;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,CAAA;CAC3B;AAED,qFAAqF;AACrF,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,CAAA;AAEvD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,sBAAsB,CAAA;IAChC,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAA;IACZ,4CAA4C;IAC5C,YAAY,EAAE,MAAM,CAAA;IACpB,8GAA8G;IAC9G,OAAO,EAAE,MAAM,CAAA;IACf,0HAA0H;IAC1H,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;IACzB,8DAA8D;IAC9D,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;IAC5B,qIAAqI;IACrI,mBAAmB,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAClD,4CAA4C;IAC5C,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B;AAiID;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoGrF"}
@@ -0,0 +1,210 @@
1
+ import { exec, InvalidConfigurationError, log } from "builder-util";
2
+ import { cp, mkdir, realpath, symlink, writeFile } from "fs/promises";
3
+ import * as path from "path";
4
+ import * as semver from "semver";
5
+ import { BREAKING_CHANGES_URL } from "../../util/config/legacyOptions.js";
6
+ // flatpak-builder 1.2.2 is the one of Ubuntu 22.04, the oldest current distribution release (Debian 12 and RHEL 8/9 have 1.2.3). It fixes
7
+ // CVE-2022-21682 with an option that flatpak supports from 1.12.4 on; Ubuntu 22.04 has flatpak 1.12.7
8
+ const MIN_VERSIONS = { flatpak: "1.12.4", "flatpak-builder": "1.2.2" };
9
+ // the freedesktop SDK 24.08 and newer recommend it for meson and cmake modules
10
+ const MODULES_FLATPAK_BUILDER_VERSION = "1.4.4";
11
+ const MODULES_FREEDESKTOP_SDK_VERSION = "24.8.0";
12
+ const NEW_IN_V27 = `This is new in electron-builder v27. See ${BREAKING_CHANGES_URL}#flatpak-tooling-requirements`;
13
+ const FLATPAK_DOCS = "https://www.electron.build/docs/flatpak";
14
+ const UNPRIVILEGED_CONTAINERS_DOCS = `${FLATPAK_DOCS}#building-in-unprivileged-containers`;
15
+ /**
16
+ * Logs how to fix a failure that has a known cause, given as `[marker, hint]` pairs: the hint of the first marker that the error
17
+ * contains. The error is rethrown as is: `exec` has already put the output of the tool in it.
18
+ */
19
+ function hintOn(...hints) {
20
+ return (e) => {
21
+ const hint = hints.find(([marker]) => e.message.includes(marker));
22
+ if (hint != null) {
23
+ log.error(null, hint[1]);
24
+ }
25
+ throw e;
26
+ };
27
+ }
28
+ /** Checks that the tool runs and is new enough, and returns its version, or null when the output has none. */
29
+ async function requireTool(tool, cwd) {
30
+ let stdout;
31
+ try {
32
+ stdout = await exec(tool, ["--version"], { cwd });
33
+ }
34
+ catch (e) {
35
+ log.error({ error: e.message }, `cannot run ${tool}`);
36
+ throw new InvalidConfigurationError(`cannot run ${tool} - flatpak and flatpak-builder must be installed to build the flatpak target`);
37
+ }
38
+ log.info({ version: stdout.trim() }, `${tool} found`);
39
+ // the output is "Flatpak 1.16.6", "flatpak-builder 1.2.3" or "flatpak-builder-1.4.4" depending on the tool and the distribution
40
+ const version = semver.coerce(stdout);
41
+ if (version != null && semver.lt(version, MIN_VERSIONS[tool])) {
42
+ throw new InvalidConfigurationError(`${tool} ${version.version} is not supported - version ${MIN_VERSIONS[tool]} or newer is required to build the flatpak target. ${NEW_IN_V27}`);
43
+ }
44
+ return version;
45
+ }
46
+ function isInside(dir, file) {
47
+ const relative = path.relative(dir, file);
48
+ return relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
49
+ }
50
+ /**
51
+ * Where a path given relative to the app prefix lands in the build directory. One that leaves the prefix is refused: the copy or
52
+ * the link would be written elsewhere on the build machine, such as over the metadata of the build directory.
53
+ */
54
+ function inAppPrefix(prefix, relativePath, what) {
55
+ const resolved = path.join(prefix, relativePath);
56
+ if (!isInside(prefix, resolved)) {
57
+ throw new InvalidConfigurationError(`${what} "${relativePath}" is outside the app prefix (/app in the sandbox): use a path inside it, such as "/lib/<name>". ${NEW_IN_V27}`);
58
+ }
59
+ return resolved;
60
+ }
61
+ /**
62
+ * Refuses to write `file` when a symlink takes its directory out of the app prefix, which inAppPrefix cannot see: the base app, the
63
+ * modules and an earlier flatpak.files pair put files into the prefix that are not checked, and a link among them, such as
64
+ * `lib -> ../..` or `lib -> /home`, would make the copy or the link land elsewhere on the build machine. Only the directory is
65
+ * resolved: what is at `file` itself is replaced, not followed, by both cp and symlink.
66
+ */
67
+ async function requireDirectoryInAppPrefix(prefix, realPrefix, file, what) {
68
+ const relative = path.relative(prefix, file);
69
+ if (relative === "") {
70
+ // the prefix itself, which a directory is merged into
71
+ return;
72
+ }
73
+ // the deepest directory that exists, since what is still to be created cannot be a link. A link that leads nowhere is passed over
74
+ // as well: mkdir and cp fail on it rather than create anything through it
75
+ let existing = path.dirname(file);
76
+ let resolved = null;
77
+ while (resolved == null) {
78
+ try {
79
+ resolved = await realpath(existing);
80
+ }
81
+ catch (e) {
82
+ // ENOTDIR: a file of an earlier pair is in the way, which the copy or mkdir reports itself
83
+ if ((e.code !== "ENOENT" && e.code !== "ENOTDIR") || existing === path.dirname(existing)) {
84
+ throw e;
85
+ }
86
+ existing = path.dirname(existing);
87
+ }
88
+ }
89
+ if (!isInside(realPrefix, resolved)) {
90
+ const shown = `/${relative.split(path.sep).join("/")}`;
91
+ throw new InvalidConfigurationError(`${what} "${shown}" resolves outside the app prefix (/app in the sandbox) through a symlink, to "${resolved}": a link in the prefix, from the base app, a module or an earlier flatpak.files pair, points outside it. ${NEW_IN_V27}`);
92
+ }
93
+ }
94
+ /** Whether a ref is installed for the user and system-wide. */
95
+ async function findRef(ref, cwd) {
96
+ const isInstalled = (installation) => exec("flatpak", ["info", "--show-commit", installation, ref], { cwd }).then(() => true, () => false);
97
+ const [inUser, inSystem] = await Promise.all([isInstalled("--user"), isInstalled("--system")]);
98
+ return { inUser, inSystem };
99
+ }
100
+ /** Brings a ref that the build needs up to date, wherever it is installed, and installs it for the user when it is installed nowhere. */
101
+ async function installOrUpdateRef(ref, cwd) {
102
+ const { inUser, inSystem } = await findRef(ref, cwd);
103
+ if (inUser || inSystem) {
104
+ await exec("flatpak", ["update", ...(inUser ? ["--user"] : []), "--no-deps", "--noninteractive", ref], { cwd });
105
+ return;
106
+ }
107
+ log.info({ ref }, "installing flatpak ref, this can download several gigabytes");
108
+ await exec("flatpak", ["install", "--user", "--no-deps", "--noninteractive", ref], { cwd }).catch(hintOn([
109
+ "No remote refs found",
110
+ `missing flatpak refs are installed with "flatpak install --user", which only searches the remotes of the user installation. If flathub is not one of them, add it with: flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo (otherwise check that the configured runtime, sdk and base versions exist)`,
111
+ ]));
112
+ }
113
+ /** Checks that a ref that the build is not to install or update is installed, in either installation. */
114
+ async function requireInstalledRef(kind, ref, cwd) {
115
+ const { inUser, inSystem } = await findRef(ref, cwd);
116
+ if (!inUser && !inSystem) {
117
+ throw new InvalidConfigurationError(`the ${kind} ${ref} is not installed, and flatpak.installOrUpdateRefs does not include "${kind}", so the build does not install it. Install it, for example with: flatpak install --user flathub ${ref} (or add "${kind}" to flatpak.installOrUpdateRefs)`);
118
+ }
119
+ log.info({ ref }, "flatpak ref is used as installed, without an update");
120
+ }
121
+ /**
122
+ * Builds a single-file flatpak bundle out of files that are already built.
123
+ *
124
+ * flatpak-builder runs twice. `--build-only` creates the app directory from the base app (and builds the modules of the
125
+ * manifest, if any) and stops, the files are then placed into the app prefix, and `--finish-only` turns the directory into an
126
+ * app with the permissions of the manifest. Nothing has to run inside the build sandbox to get the files in.
127
+ */
128
+ export async function buildFlatpakBundle(options) {
129
+ const { manifest, arch, tempDir: cwd } = options;
130
+ const manifestFile = path.join(cwd, "manifest.json");
131
+ const appDir = path.join(cwd, "build");
132
+ const prefix = path.join(appDir, "files");
133
+ const repo = path.join(cwd, "repo");
134
+ const branch = manifest.branch ? [manifest.branch] : [];
135
+ // checked before anything is installed or built
136
+ const copies = options.files.map(([source, destination]) => [source, inAppPrefix(prefix, destination, "flatpak.files destination")]);
137
+ const links = options.symlinks.map(([target, link]) => [target, inAppPrefix(prefix, link, "flatpak.symlinks link")]);
138
+ await requireTool("flatpak", cwd);
139
+ const builderVersion = await requireTool("flatpak-builder", cwd);
140
+ // a freedesktop SDK before 24.08 is left out; any other SDK is not modelled and warned about. Loose, because the strict coerce rejects
141
+ // the zero-padded minor of "22.08"
142
+ const sdkVersion = manifest.sdk === "org.freedesktop.Sdk" ? semver.coerce(manifest["runtime-version"], { loose: true }) : null;
143
+ const isOldFreedesktopSdk = sdkVersion != null && semver.lt(sdkVersion, MODULES_FREEDESKTOP_SDK_VERSION);
144
+ if ((manifest.modules?.length ?? 0) > 0 && builderVersion != null && semver.lt(builderVersion, MODULES_FLATPAK_BUILDER_VERSION) && !isOldFreedesktopSdk) {
145
+ // once per process: every arch is built with the same flatpak-builder
146
+ log
147
+ .once("flatpak-builder-modules-version")
148
+ .warn({ flatpakBuilder: builderVersion.version, recommended: MODULES_FLATPAK_BUILDER_VERSION }, `flatpak.modules are built with flatpak-builder ${builderVersion.version}. The freedesktop SDK 24.08 and newer recommend flatpak-builder ${MODULES_FLATPAK_BUILDER_VERSION} or newer for meson and cmake modules: update it if a module fails to build or does not install where it should`);
149
+ }
150
+ // the sdk has the version of the runtime
151
+ const refs = [
152
+ ["runtime", `runtime/${manifest.runtime}/${arch}/${manifest["runtime-version"]}`],
153
+ ["sdk", `runtime/${manifest.sdk}/${arch}/${manifest["runtime-version"]}`],
154
+ ["base", `app/${manifest.base}/${arch}/${manifest["base-version"]}`],
155
+ ];
156
+ // the refs to use as installed are checked first, so that a missing one fails the build before anything is downloaded
157
+ const toInstallOrUpdate = refs.filter(([kind]) => options.installOrUpdateRefs.includes(kind));
158
+ for (const [kind, ref] of refs.filter(it => !toInstallOrUpdate.includes(it))) {
159
+ await requireInstalledRef(kind, ref, cwd);
160
+ }
161
+ for (const [, ref] of toInstallOrUpdate) {
162
+ await installOrUpdateRef(ref, cwd);
163
+ }
164
+ await writeFile(manifestFile, JSON.stringify(manifest, null, 2));
165
+ // flatpak-builder downloads the sources of the modules, and git or curl may need credentials from the environment for that. Without
166
+ // modules it fetches nothing, so it gets the environment that exec filters for every other command
167
+ const builderEnv = (manifest.modules?.length ?? 0) > 0 ? process.env : undefined;
168
+ const runFlatpakBuilder = (stage) => exec("flatpak-builder", ["--arch", arch, stage, ...options.flatpakBuilderArgs, appDir, manifestFile], { cwd, env: builderEnv }).catch(hintOn([
169
+ "Failure spawning rofiles-fuse",
170
+ `flatpak-builder could not start rofiles-fuse because FUSE is not available, which is typical in unprivileged containers. Set flatpak.additionalArgs.flatpakBuilder to ["--disable-rofiles-fuse"]. Such containers usually also need flatpak.additionalArgs.buildExport set to ["--disable-sandbox"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,
171
+ ],
172
+ // rofiles-fuse started, but could not mount the app directory, so flatpak-builder finds it empty
173
+ [
174
+ `Command '${manifest.command}' not found`,
175
+ `flatpak-builder did not find ${manifest.command}, which electron-builder placed in the app directory, because rofiles-fuse could not mount that directory. It needs the FUSE mount helper on the build machine: fusermount3 from the fuse3 package, or fusermount from the fuse package where rofiles-fuse is built against FUSE 2. Install it, or set flatpak.additionalArgs.flatpakBuilder to ["--disable-rofiles-fuse"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,
176
+ ],
177
+ // flatpak-builder before 1.4 composes AppStream metadata with appstream-compose, which the freedesktop SDK 24.08 and newer do
178
+ // not ship; it runs only when the app has a metainfo or appdata file named after its id
179
+ [
180
+ "execvp appstream-compose",
181
+ `flatpak-builder could not compose the AppStream metadata of the app (share/metainfo/${manifest.id}.metainfo.xml or share/appdata/${manifest.id}.appdata.xml, from flatpak.files or a module): it runs appstream-compose, which the freedesktop SDK no longer ships from 24.08 on. flatpak-builder 1.4 and newer use appstreamcli instead: update flatpak-builder, or leave the file out. See ${FLATPAK_DOCS}#build-requirements`,
182
+ ]));
183
+ await runFlatpakBuilder("--build-only");
184
+ // flatpak-builder has created it, and the paths that the links in it lead to are compared with the one it resolves to
185
+ const realPrefix = await realpath(prefix);
186
+ // one after another, so that a pair can add to what an earlier one has placed. The filter sees every item of a directory, and the
187
+ // destination itself, before it is written or its parent directory created; a symlink in the copied directory is still kept as it is
188
+ const filter = async (_source, file) => {
189
+ await requireDirectoryInAppPrefix(prefix, realPrefix, file, "flatpak.files destination");
190
+ return true;
191
+ };
192
+ for (const [source, destination] of copies) {
193
+ await cp(source, destination, { recursive: true, verbatimSymlinks: true, filter });
194
+ }
195
+ for (const [target, linkPath] of links) {
196
+ // before mkdir, which would create the missing directories wherever a link leads
197
+ await requireDirectoryInAppPrefix(prefix, realPrefix, linkPath, "flatpak.symlinks link");
198
+ await mkdir(path.dirname(linkPath), { recursive: true });
199
+ // resolved in the sandbox, where the prefix is mounted at /app
200
+ await symlink(path.posix.join("/app", target), linkPath);
201
+ }
202
+ await runFlatpakBuilder("--finish-only");
203
+ await exec("flatpak", ["build-export", "--arch", arch, ...options.buildExportArgs, repo, appDir, ...branch], { cwd }).catch(hintOn([
204
+ "bwrap: ",
205
+ `flatpak build-export could not start the sandbox of its icon validator because bubblewrap (bwrap) cannot create namespaces, which is typical in unprivileged containers. Set flatpak.additionalArgs.buildExport to ["--disable-sandbox"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,
206
+ ]));
207
+ await mkdir(path.dirname(options.artifactPath), { recursive: true });
208
+ await exec("flatpak", ["build-bundle", "--arch", arch, ...options.buildBundleArgs, repo, options.artifactPath, manifest.id, ...branch], { cwd });
209
+ }
210
+ //# sourceMappingURL=flatpakBundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flatpakBundle.js","sourceRoot":"","sources":["../../../src/targets/linux/flatpakBundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,yBAAyB,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACrE,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAEzE,0IAA0I;AAC1I,sGAAsG;AACtG,MAAM,YAAY,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,CAAA;AAEtE,+EAA+E;AAC/E,M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C,SAAS,EAAE,CAAC,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CACzH,MAAM,CAAC;QACL,SAAS;QACT,iPAAiP,4BAA4B,EAAE;KAChR,CAAC,CACH,CAAA;IAED,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACpE,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;AAClJ,CAAC","sourcesContent":["import { exec, InvalidConfigurationError, log } from \"builder-util\"\nimport { cp, mkdir, realpath, symlink, writeFile } from \"fs/promises\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport { BREAKING_CHANGES_URL } from \"../../util/config/legacyOptions.js\"\n\n// flatpak-builder 1.2.2 is the one of Ubuntu 22.04, the oldest current distribution release (Debian 12 and RHEL 8/9 have 1.2.3). It fixes\n// CVE-2022-21682 with an option that flatpak supports from 1.12.4 on; Ubuntu 22.04 has flatpak 1.12.7\nconst MIN_VERSIONS = { flatpak: \"1.12.4\", \"flatpak-builder\": \"1.2.2\" }\n\n// the freedesktop SDK 24.08 and newer recommend it for meson and cmake modules\nconst MODULES_FLATPAK_BUILDER_VERSION = \"1.4.4\"\nconst MODULES_FREEDESKTOP_SDK_VERSION = \"24.8.0\"\n\nconst NEW_IN_V27 = `This is new in electron-builder v27. See ${BREAKING_CHANGES_URL}#flatpak-tooling-requirements`\n\nconst FLATPAK_DOCS = \"https://www.electron.build/docs/flatpak\"\nconst UNPRIVILEGED_CONTAINERS_DOCS = `${FLATPAK_DOCS}#building-in-unprivileged-containers`\n\n/** The part of a [flatpak-builder manifest](https://docs.flatpak.org/en/latest/flatpak-builder-command-reference.html#flatpak-manifest) that the flatpak target writes. */\nexport interface FlatpakBuilderManifest {\n id: string\n command: string\n runtime: string\n \"runtime-version\": string\n sdk: string\n base: string\n \"base-version\": string\n \"finish-args\": string[]\n branch?: string\n modules?: (string | any)[]\n}\n\n/** The refs a build needs: the runtime, the SDK and the base app of the manifest. */\nexport type FlatpakRefKind = \"runtime\" | \"sdk\" | \"base\"\n\nexport interface FlatpakBundleOptions {\n manifest: FlatpakBuilderManifest\n /** flatpak's name for the target architecture, e.g. `x86_64` */\n arch: string\n /** where to write the single-file bundle */\n artifactPath: string\n /** an empty directory for the manifest, the app directory, the repository and the state of flatpak-builder */\n tempDir: string\n /** `[source, destination]` pairs, copied in order; a destination is relative to the app prefix (`/app` in the sandbox) */\n files: [string, string][]\n /** `[target, link]` pairs, both relative to the app prefix */\n symlinks: [string, string][]\n /** the refs to install when they are missing and update when they are installed; the others are used as installed, and have to be */\n installOrUpdateRefs: ReadonlyArray<FlatpakRefKind>\n /** added to both runs of flatpak-builder */\n flatpakBuilderArgs: string[]\n buildExportArgs: string[]\n buildBundleArgs: string[]\n}\n\n/**\n * Logs how to fix a failure that has a known cause, given as `[marker, hint]` pairs: the hint of the first marker that the error\n * contains. The error is rethrown as is: `exec` has already put the output of the tool in it.\n */\nfunction hintOn(...hints: Array<[marker: string, hint: string]>) {\n return (e: Error): never => {\n const hint = hints.find(([marker]) => e.message.includes(marker))\n if (hint != null) {\n log.error(null, hint[1])\n }\n throw e\n }\n}\n\n/** Checks that the tool runs and is new enough, and returns its version, or null when the output has none. */\nasync function requireTool(tool: keyof typeof MIN_VERSIONS, cwd: string): Promise<semver.SemVer | null> {\n let stdout: string\n try {\n stdout = await exec(tool, [\"--version\"], { cwd })\n } catch (e: any) {\n log.error({ error: e.message }, `cannot run ${tool}`)\n throw new InvalidConfigurationError(`cannot run ${tool} - flatpak and flatpak-builder must be installed to build the flatpak target`)\n }\n log.info({ version: stdout.trim() }, `${tool} found`)\n\n // the output is \"Flatpak 1.16.6\", \"flatpak-builder 1.2.3\" or \"flatpak-builder-1.4.4\" depending on the tool and the distribution\n const version = semver.coerce(stdout)\n if (version != null && semver.lt(version, MIN_VERSIONS[tool])) {\n throw new InvalidConfigurationError(\n `${tool} ${version.version} is not supported - version ${MIN_VERSIONS[tool]} or newer is required to build the flatpak target. ${NEW_IN_V27}`\n )\n }\n return version\n}\n\nfunction isInside(dir: string, file: string): boolean {\n const relative = path.relative(dir, file)\n return relative !== \"..\" && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative)\n}\n\n/**\n * Where a path given relative to the app prefix lands in the build directory. One that leaves the prefix is refused: the copy or\n * the link would be written elsewhere on the build machine, such as over the metadata of the build directory.\n */\nfunction inAppPrefix(prefix: string, relativePath: string, what: string): string {\n const resolved = path.join(prefix, relativePath)\n if (!isInside(prefix, resolved)) {\n throw new InvalidConfigurationError(`${what} \"${relativePath}\" is outside the app prefix (/app in the sandbox): use a path inside it, such as \"/lib/<name>\". ${NEW_IN_V27}`)\n }\n return resolved\n}\n\n/**\n * Refuses to write `file` when a symlink takes its directory out of the app prefix, which inAppPrefix cannot see: the base app, the\n * modules and an earlier flatpak.files pair put files into the prefix that are not checked, and a link among them, such as\n * `lib -> ../..` or `lib -> /home`, would make the copy or the link land elsewhere on the build machine. Only the directory is\n * resolved: what is at `file` itself is replaced, not followed, by both cp and symlink.\n */\nasync function requireDirectoryInAppPrefix(prefix: string, realPrefix: string, file: string, what: string): Promise<void> {\n const relative = path.relative(prefix, file)\n if (relative === \"\") {\n // the prefix itself, which a directory is merged into\n return\n }\n // the deepest directory that exists, since what is still to be created cannot be a link. A link that leads nowhere is passed over\n // as well: mkdir and cp fail on it rather than create anything through it\n let existing = path.dirname(file)\n let resolved: string | null = null\n while (resolved == null) {\n try {\n resolved = await realpath(existing)\n } catch (e: any) {\n // ENOTDIR: a file of an earlier pair is in the way, which the copy or mkdir reports itself\n if ((e.code !== \"ENOENT\" && e.code !== \"ENOTDIR\") || existing === path.dirname(existing)) {\n throw e\n }\n existing = path.dirname(existing)\n }\n }\n if (!isInside(realPrefix, resolved)) {\n const shown = `/${relative.split(path.sep).join(\"/\")}`\n throw new InvalidConfigurationError(\n `${what} \"${shown}\" resolves outside the app prefix (/app in the sandbox) through a symlink, to \"${resolved}\": a link in the prefix, from the base app, a module or an earlier flatpak.files pair, points outside it. ${NEW_IN_V27}`\n )\n }\n}\n\n/** Whether a ref is installed for the user and system-wide. */\nasync function findRef(ref: string, cwd: string): Promise<{ inUser: boolean; inSystem: boolean }> {\n const isInstalled = (installation: \"--user\" | \"--system\") =>\n exec(\"flatpak\", [\"info\", \"--show-commit\", installation, ref], { cwd }).then(\n () => true,\n () => false\n )\n const [inUser, inSystem] = await Promise.all([isInstalled(\"--user\"), isInstalled(\"--system\")])\n return { inUser, inSystem }\n}\n\n/** Brings a ref that the build needs up to date, wherever it is installed, and installs it for the user when it is installed nowhere. */\nasync function installOrUpdateRef(ref: string, cwd: string): Promise<void> {\n const { inUser, inSystem } = await findRef(ref, cwd)\n\n if (inUser || inSystem) {\n await exec(\"flatpak\", [\"update\", ...(inUser ? [\"--user\"] : []), \"--no-deps\", \"--noninteractive\", ref], { cwd })\n return\n }\n\n log.info({ ref }, \"installing flatpak ref, this can download several gigabytes\")\n await exec(\"flatpak\", [\"install\", \"--user\", \"--no-deps\", \"--noninteractive\", ref], { cwd }).catch(\n hintOn([\n \"No remote refs found\",\n `missing flatpak refs are installed with \"flatpak install --user\", which only searches the remotes of the user installation. If flathub is not one of them, add it with: flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo (otherwise check that the configured runtime, sdk and base versions exist)`,\n ])\n )\n}\n\n/** Checks that a ref that the build is not to install or update is installed, in either installation. */\nasync function requireInstalledRef(kind: FlatpakRefKind, ref: string, cwd: string): Promise<void> {\n const { inUser, inSystem } = await findRef(ref, cwd)\n if (!inUser && !inSystem) {\n throw new InvalidConfigurationError(\n `the ${kind} ${ref} is not installed, and flatpak.installOrUpdateRefs does not include \"${kind}\", so the build does not install it. Install it, for example with: flatpak install --user flathub ${ref} (or add \"${kind}\" to flatpak.installOrUpdateRefs)`\n )\n }\n log.info({ ref }, \"flatpak ref is used as installed, without an update\")\n}\n\n/**\n * Builds a single-file flatpak bundle out of files that are already built.\n *\n * flatpak-builder runs twice. `--build-only` creates the app directory from the base app (and builds the modules of the\n * manifest, if any) and stops, the files are then placed into the app prefix, and `--finish-only` turns the directory into an\n * app with the permissions of the manifest. Nothing has to run inside the build sandbox to get the files in.\n */\nexport async function buildFlatpakBundle(options: FlatpakBundleOptions): Promise<void> {\n const { manifest, arch, tempDir: cwd } = options\n const manifestFile = path.join(cwd, \"manifest.json\")\n const appDir = path.join(cwd, \"build\")\n const prefix = path.join(appDir, \"files\")\n const repo = path.join(cwd, \"repo\")\n const branch = manifest.branch ? [manifest.branch] : []\n // checked before anything is installed or built\n const copies = options.files.map(([source, destination]) => [source, inAppPrefix(prefix, destination, \"flatpak.files destination\")] as const)\n const links = options.symlinks.map(([target, link]) => [target, inAppPrefix(prefix, link, \"flatpak.symlinks link\")] as const)\n\n await requireTool(\"flatpak\", cwd)\n const builderVersion = await requireTool(\"flatpak-builder\", cwd)\n // a freedesktop SDK before 24.08 is left out; any other SDK is not modelled and warned about. Loose, because the strict coerce rejects\n // the zero-padded minor of \"22.08\"\n const sdkVersion = manifest.sdk === \"org.freedesktop.Sdk\" ? semver.coerce(manifest[\"runtime-version\"], { loose: true }) : null\n const isOldFreedesktopSdk = sdkVersion != null && semver.lt(sdkVersion, MODULES_FREEDESKTOP_SDK_VERSION)\n if ((manifest.modules?.length ?? 0) > 0 && builderVersion != null && semver.lt(builderVersion, MODULES_FLATPAK_BUILDER_VERSION) && !isOldFreedesktopSdk) {\n // once per process: every arch is built with the same flatpak-builder\n log\n .once(\"flatpak-builder-modules-version\")\n .warn(\n { flatpakBuilder: builderVersion.version, recommended: MODULES_FLATPAK_BUILDER_VERSION },\n `flatpak.modules are built with flatpak-builder ${builderVersion.version}. The freedesktop SDK 24.08 and newer recommend flatpak-builder ${MODULES_FLATPAK_BUILDER_VERSION} or newer for meson and cmake modules: update it if a module fails to build or does not install where it should`\n )\n }\n\n // the sdk has the version of the runtime\n const refs: [FlatpakRefKind, string][] = [\n [\"runtime\", `runtime/${manifest.runtime}/${arch}/${manifest[\"runtime-version\"]}`],\n [\"sdk\", `runtime/${manifest.sdk}/${arch}/${manifest[\"runtime-version\"]}`],\n [\"base\", `app/${manifest.base}/${arch}/${manifest[\"base-version\"]}`],\n ]\n // the refs to use as installed are checked first, so that a missing one fails the build before anything is downloaded\n const toInstallOrUpdate = refs.filter(([kind]) => options.installOrUpdateRefs.includes(kind))\n for (const [kind, ref] of refs.filter(it => !toInstallOrUpdate.includes(it))) {\n await requireInstalledRef(kind, ref, cwd)\n }\n for (const [, ref] of toInstallOrUpdate) {\n await installOrUpdateRef(ref, cwd)\n }\n\n await writeFile(manifestFile, JSON.stringify(manifest, null, 2))\n\n // flatpak-builder downloads the sources of the modules, and git or curl may need credentials from the environment for that. Without\n // modules it fetches nothing, so it gets the environment that exec filters for every other command\n const builderEnv = (manifest.modules?.length ?? 0) > 0 ? process.env : undefined\n const runFlatpakBuilder = (stage: \"--build-only\" | \"--finish-only\") =>\n exec(\"flatpak-builder\", [\"--arch\", arch, stage, ...options.flatpakBuilderArgs, appDir, manifestFile], { cwd, env: builderEnv }).catch(\n hintOn(\n [\n \"Failure spawning rofiles-fuse\",\n `flatpak-builder could not start rofiles-fuse because FUSE is not available, which is typical in unprivileged containers. Set flatpak.additionalArgs.flatpakBuilder to [\"--disable-rofiles-fuse\"]. Such containers usually also need flatpak.additionalArgs.buildExport set to [\"--disable-sandbox\"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,\n ],\n // rofiles-fuse started, but could not mount the app directory, so flatpak-builder finds it empty\n [\n `Command '${manifest.command}' not found`,\n `flatpak-builder did not find ${manifest.command}, which electron-builder placed in the app directory, because rofiles-fuse could not mount that directory. It needs the FUSE mount helper on the build machine: fusermount3 from the fuse3 package, or fusermount from the fuse package where rofiles-fuse is built against FUSE 2. Install it, or set flatpak.additionalArgs.flatpakBuilder to [\"--disable-rofiles-fuse\"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,\n ],\n // flatpak-builder before 1.4 composes AppStream metadata with appstream-compose, which the freedesktop SDK 24.08 and newer do\n // not ship; it runs only when the app has a metainfo or appdata file named after its id\n [\n \"execvp appstream-compose\",\n `flatpak-builder could not compose the AppStream metadata of the app (share/metainfo/${manifest.id}.metainfo.xml or share/appdata/${manifest.id}.appdata.xml, from flatpak.files or a module): it runs appstream-compose, which the freedesktop SDK no longer ships from 24.08 on. flatpak-builder 1.4 and newer use appstreamcli instead: update flatpak-builder, or leave the file out. See ${FLATPAK_DOCS}#build-requirements`,\n ]\n )\n )\n\n await runFlatpakBuilder(\"--build-only\")\n\n // flatpak-builder has created it, and the paths that the links in it lead to are compared with the one it resolves to\n const realPrefix = await realpath(prefix)\n // one after another, so that a pair can add to what an earlier one has placed. The filter sees every item of a directory, and the\n // destination itself, before it is written or its parent directory created; a symlink in the copied directory is still kept as it is\n const filter = async (_source: string, file: string) => {\n await requireDirectoryInAppPrefix(prefix, realPrefix, file, \"flatpak.files destination\")\n return true\n }\n for (const [source, destination] of copies) {\n await cp(source, destination, { recursive: true, verbatimSymlinks: true, filter })\n }\n for (const [target, linkPath] of links) {\n // before mkdir, which would create the missing directories wherever a link leads\n await requireDirectoryInAppPrefix(prefix, realPrefix, linkPath, \"flatpak.symlinks link\")\n await mkdir(path.dirname(linkPath), { recursive: true })\n // resolved in the sandbox, where the prefix is mounted at /app\n await symlink(path.posix.join(\"/app\", target), linkPath)\n }\n\n await runFlatpakBuilder(\"--finish-only\")\n\n await exec(\"flatpak\", [\"build-export\", \"--arch\", arch, ...options.buildExportArgs, repo, appDir, ...branch], { cwd }).catch(\n hintOn([\n \"bwrap: \",\n `flatpak build-export could not start the sandbox of its icon validator because bubblewrap (bwrap) cannot create namespaces, which is typical in unprivileged containers. Set flatpak.additionalArgs.buildExport to [\"--disable-sandbox\"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,\n ])\n )\n\n await mkdir(path.dirname(options.artifactPath), { recursive: true })\n await exec(\"flatpak\", [\"build-bundle\", \"--arch\", arch, ...options.buildBundleArgs, repo, options.artifactPath, manifest.id, ...branch], { cwd })\n}\n"]}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Shared launcher-entrypoint helpers for the Linux targets.
3
+ *
4
+ * Every Linux target (deb/rpm, AppImage, snap, flatpak) launches the app through a generated
5
+ * launcher script rather than inlining `executableArgs` into the freedesktop `.desktop` Exec key.
6
+ * Routing through a launcher keeps the Exec key a plain command (no fragile freedesktop quoting),
7
+ * injects the arguments in a single, consistent place, and lets `"$@"` forward the launch-time
8
+ * arguments (desktop field-code expansions) on to the app.
9
+ */
10
+ /** Single-quote a shell argument, escaping any embedded single quotes. */
11
+ export declare function shellQuote(arg: string): string;
12
+ export interface LauncherScriptOptions {
13
+ /**
14
+ * The already-safe exec target tokens, joined with a space to form the start of the `exec` line
15
+ * (e.g. `['"$SNAP/app/foo"']` or `['zypak-wrapper', '"foo"']`). Callers are responsible for
16
+ * quoting these tokens — they are emitted verbatim so that shell variables such as `$SNAP`
17
+ * remain expandable.
18
+ */
19
+ command: ReadonlyArray<string>;
20
+ /** User/derived arguments. Each is single-quoted so embedded characters are passed literally. */
21
+ args?: ReadonlyArray<string>;
22
+ /** Shebang line. Defaults to `#!/bin/sh`. */
23
+ shebang?: string;
24
+ /** Optional lines inserted between the shebang and the `exec` line (e.g. `export` statements). */
25
+ preamble?: string;
26
+ }
27
+ /**
28
+ * Build a launcher entrypoint script that execs `command` with `args` (single-quoted) and always
29
+ * forwards `"$@"`.
30
+ */
31
+ export declare function buildLauncherScript(opts: LauncherScriptOptions): string;
32
+ //# sourceMappingURL=launcherScript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launcherScript.d.ts","sourceRoot":"","sources":["../../../src/targets/linux/launcherScript.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC9B,iGAAiG;IACjG,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC5B,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kGAAkG;IAClG,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM,CAKvE"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Shared launcher-entrypoint helpers for the Linux targets.
3
+ *
4
+ * Every Linux target (deb/rpm, AppImage, snap, flatpak) launches the app through a generated
5
+ * launcher script rather than inlining `executableArgs` into the freedesktop `.desktop` Exec key.
6
+ * Routing through a launcher keeps the Exec key a plain command (no fragile freedesktop quoting),
7
+ * injects the arguments in a single, consistent place, and lets `"$@"` forward the launch-time
8
+ * arguments (desktop field-code expansions) on to the app.
9
+ */
10
+ /** Single-quote a shell argument, escaping any embedded single quotes. */
11
+ export function shellQuote(arg) {
12
+ return "'" + arg.replace(/'/g, "'\\''") + "'";
13
+ }
14
+ /**
15
+ * Build a launcher entrypoint script that execs `command` with `args` (single-quoted) and always
16
+ * forwards `"$@"`.
17
+ */
18
+ export function buildLauncherScript(opts) {
19
+ const shebang = opts.shebang ?? "#!/bin/sh";
20
+ const argsPart = opts.args && opts.args.length > 0 ? " " + opts.args.map(shellQuote).join(" ") : "";
21
+ const preamble = opts.preamble ? `\n${opts.preamble}\n` : "\n";
22
+ return `${shebang}${preamble}exec ${opts.command.join(" ")}${argsPart} "$@"\n`;
23
+ }
24
+ //# sourceMappingURL=launcherScript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launcherScript.js","sourceRoot":"","sources":["../../../src/targets/linux/launcherScript.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,0EAA0E;AAC1E,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,GAAG,CAAA;AAC/C,CAAC;AAkBD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAA2B;IAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,WAAW,CAAA;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACnG,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;IAC9D,OAAO,GAAG,OAAO,GAAG,QAAQ,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,SAAS,CAAA;AAChF,CAAC","sourcesContent":["/**\n * Shared launcher-entrypoint helpers for the Linux targets.\n *\n * Every Linux target (deb/rpm, AppImage, snap, flatpak) launches the app through a generated\n * launcher script rather than inlining `executableArgs` into the freedesktop `.desktop` Exec key.\n * Routing through a launcher keeps the Exec key a plain command (no fragile freedesktop quoting),\n * injects the arguments in a single, consistent place, and lets `\"$@\"` forward the launch-time\n * arguments (desktop field-code expansions) on to the app.\n */\n\n/** Single-quote a shell argument, escaping any embedded single quotes. */\nexport function shellQuote(arg: string): string {\n return \"'\" + arg.replace(/'/g, \"'\\\\''\") + \"'\"\n}\n\nexport interface LauncherScriptOptions {\n /**\n * The already-safe exec target tokens, joined with a space to form the start of the `exec` line\n * (e.g. `['\"$SNAP/app/foo\"']` or `['zypak-wrapper', '\"foo\"']`). Callers are responsible for\n * quoting these tokens — they are emitted verbatim so that shell variables such as `$SNAP`\n * remain expandable.\n */\n command: ReadonlyArray<string>\n /** User/derived arguments. Each is single-quoted so embedded characters are passed literally. */\n args?: ReadonlyArray<string>\n /** Shebang line. Defaults to `#!/bin/sh`. */\n shebang?: string\n /** Optional lines inserted between the shebang and the `exec` line (e.g. `export` statements). */\n preamble?: string\n}\n\n/**\n * Build a launcher entrypoint script that execs `command` with `args` (single-quoted) and always\n * forwards `\"$@\"`.\n */\nexport function buildLauncherScript(opts: LauncherScriptOptions): string {\n const shebang = opts.shebang ?? \"#!/bin/sh\"\n const argsPart = opts.args && opts.args.length > 0 ? \" \" + opts.args.map(shellQuote).join(\" \") : \"\"\n const preamble = opts.preamble ? `\\n${opts.preamble}\\n` : \"\\n\"\n return `${shebang}${preamble}exec ${opts.command.join(\" \")}${argsPart} \"$@\"\\n`\n}\n"]}
@@ -20,7 +20,7 @@ export declare abstract class SnapCore<T> {
20
20
  stageDir: string;
21
21
  snapArch: Arch;
22
22
  artifactPath: string;
23
- }): Promise<void>;
23
+ }): Promise<string[]>;
24
24
  }
25
25
  /** Snap build target — reads `snapcraft` config and delegates to the appropriate `SnapCore` strategy. */
26
26
  export default class SnapTarget extends Target {
@@ -1 +1 @@
1
- {"version":3,"file":"SnapTarget.d.ts","sourceRoot":"","sources":["../../../../src/targets/linux/snap/SnapTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAO,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEvD,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AAgB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC;IAE7D,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,aAAa,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAClJ;AAED,yGAAyG;AACzG,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,MAAM;IAK1C,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa;IAC1C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM;IANzB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;gBAGhC,IAAI,EAAE,MAAM,EACO,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,iBAAiB,EACnC,MAAM,EAAE,MAAM;IAOnB,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;IA4DxD,SAAS,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,gBAAgB,GAAG,IAAI;IA+BhF,OAAO,CAAC,kCAAkC;IAoB1C,OAAO,CAAC,kBAAkB;CAI3B"}
@@ -1,4 +1,5 @@
1
1
  import { log } from "builder-util";
2
+ import { snapArchStringToArch } from "./snapcraftBuilder.js";
2
3
  import * as path from "path";
3
4
  import { Target } from "../../../core.js";
4
5
  import { createStageDirPath } from "../../targetUtil.js";
@@ -32,7 +33,7 @@ export default class SnapTarget extends Target {
32
33
  const core = this.helper.getSnapCore();
33
34
  const snap = await core.createDescriptor(arch);
34
35
  log.debug({ snap }, "snapcraft.yaml descriptor created");
35
- await core.buildSnap({
36
+ const allArtifactPaths = await core.buildSnap({
36
37
  snap,
37
38
  appOutDir,
38
39
  stageDir: await createStageDirPath(this, packager, arch),
@@ -48,6 +49,27 @@ export default class SnapTarget extends Target {
48
49
  packager,
49
50
  publishConfig,
50
51
  });
52
+ // Emit additional artifacts produced by a multi-arch remote-build invocation.
53
+ for (const extraPath of allArtifactPaths) {
54
+ if (extraPath === artifactPath) {
55
+ continue;
56
+ }
57
+ const snapArch = path
58
+ .basename(extraPath)
59
+ .replace(/\.snap$/, "")
60
+ .split("_")
61
+ .pop() ?? "amd64";
62
+ const extraArch = snapArchStringToArch(snapArch);
63
+ const extraArtifactName = path.basename(extraPath);
64
+ await packager.emitArtifactBuildCompleted({
65
+ file: extraPath,
66
+ safeArtifactName: packager.computeSafeArtifactName(extraArtifactName, "snap", extraArch, false),
67
+ target: this,
68
+ arch: extraArch,
69
+ packager,
70
+ publishConfig,
71
+ });
72
+ }
51
73
  }
52
74
  findSnapPublishConfig(config) {
53
75
  const fallback = { provider: "snapStore" };