app-builder-lib 23.6.0 → 24.0.0-alpha.2

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 (163) hide show
  1. package/out/ProtonFramework.js +4 -4
  2. package/out/ProtonFramework.js.map +1 -1
  3. package/out/appInfo.js +21 -9
  4. package/out/appInfo.js.map +1 -1
  5. package/out/asar/asar.d.ts +1 -0
  6. package/out/asar/asar.js +10 -10
  7. package/out/asar/asar.js.map +1 -1
  8. package/out/asar/asarFileChecker.js +2 -2
  9. package/out/asar/asarFileChecker.js.map +1 -1
  10. package/out/asar/asarUtil.js +13 -13
  11. package/out/asar/asarUtil.js.map +1 -1
  12. package/out/asar/integrity.js +9 -9
  13. package/out/asar/integrity.js.map +1 -1
  14. package/out/asar/unpackDetector.js +6 -6
  15. package/out/asar/unpackDetector.js.map +1 -1
  16. package/out/binDownload.js +2 -2
  17. package/out/binDownload.js.map +1 -1
  18. package/out/codeSign/codesign.js +4 -4
  19. package/out/codeSign/codesign.js.map +1 -1
  20. package/out/codeSign/macCodeSign.js +24 -24
  21. package/out/codeSign/macCodeSign.js.map +1 -1
  22. package/out/codeSign/windowsCodeSign.js +7 -7
  23. package/out/codeSign/windowsCodeSign.js.map +1 -1
  24. package/out/core.js +1 -1
  25. package/out/core.js.map +1 -1
  26. package/out/electron/ElectronFramework.js +17 -17
  27. package/out/electron/ElectronFramework.js.map +1 -1
  28. package/out/electron/electronMac.js +16 -16
  29. package/out/electron/electronMac.js.map +1 -1
  30. package/out/electron/electronVersion.js +5 -5
  31. package/out/electron/electronVersion.js.map +1 -1
  32. package/out/fileMatcher.js +11 -11
  33. package/out/fileMatcher.js.map +1 -1
  34. package/out/fileTransformer.js +5 -5
  35. package/out/fileTransformer.js.map +1 -1
  36. package/out/forge-maker.js +1 -1
  37. package/out/forge-maker.js.map +1 -1
  38. package/out/frameworks/LibUiFramework.js +10 -10
  39. package/out/frameworks/LibUiFramework.js.map +1 -1
  40. package/out/index.js +3 -3
  41. package/out/index.js.map +1 -1
  42. package/out/linuxPackager.js +2 -2
  43. package/out/linuxPackager.js.map +1 -1
  44. package/out/macPackager.js +26 -26
  45. package/out/macPackager.js.map +1 -1
  46. package/out/options/CommonWindowsInstallerConfiguration.js +3 -3
  47. package/out/options/CommonWindowsInstallerConfiguration.js.map +1 -1
  48. package/out/options/macOptions.d.ts +1 -1
  49. package/out/options/macOptions.js.map +1 -1
  50. package/out/packager.js +34 -34
  51. package/out/packager.js.map +1 -1
  52. package/out/platformPackager.js +39 -39
  53. package/out/platformPackager.js.map +1 -1
  54. package/out/presets/rectCra.js +1 -1
  55. package/out/presets/rectCra.js.map +1 -1
  56. package/out/publish/BitbucketPublisher.js +5 -5
  57. package/out/publish/BitbucketPublisher.js.map +1 -1
  58. package/out/publish/KeygenPublisher.js +7 -7
  59. package/out/publish/KeygenPublisher.js.map +1 -1
  60. package/out/publish/PublishManager.d.ts +0 -1
  61. package/out/publish/PublishManager.js +24 -24
  62. package/out/publish/PublishManager.js.map +1 -1
  63. package/out/publish/SnapStorePublisher.js +1 -1
  64. package/out/publish/SnapStorePublisher.js.map +1 -1
  65. package/out/publish/s3/BaseS3Publisher.js +3 -3
  66. package/out/publish/s3/BaseS3Publisher.js.map +1 -1
  67. package/out/publish/s3/s3Publisher.js +1 -1
  68. package/out/publish/s3/s3Publisher.js.map +1 -1
  69. package/out/publish/s3/spacesPublisher.js +2 -2
  70. package/out/publish/s3/spacesPublisher.js.map +1 -1
  71. package/out/publish/updateInfoBuilder.js +9 -9
  72. package/out/publish/updateInfoBuilder.js.map +1 -1
  73. package/out/remoteBuilder/ProjectInfoManager.js +1 -1
  74. package/out/remoteBuilder/ProjectInfoManager.js.map +1 -1
  75. package/out/remoteBuilder/RemoteBuilder.js +3 -3
  76. package/out/remoteBuilder/RemoteBuilder.js.map +1 -1
  77. package/out/remoteBuilder/builder-cli.js +3 -3
  78. package/out/remoteBuilder/builder-cli.js.map +1 -1
  79. package/out/targets/AppImageTarget.js +6 -6
  80. package/out/targets/AppImageTarget.js.map +1 -1
  81. package/out/targets/AppxTarget.js +19 -19
  82. package/out/targets/AppxTarget.js.map +1 -1
  83. package/out/targets/ArchiveTarget.js +7 -7
  84. package/out/targets/ArchiveTarget.js.map +1 -1
  85. package/out/targets/FlatpakTarget.js +8 -8
  86. package/out/targets/FlatpakTarget.js.map +1 -1
  87. package/out/targets/LinuxTargetHelper.js +9 -9
  88. package/out/targets/LinuxTargetHelper.js.map +1 -1
  89. package/out/targets/MsiTarget.js +11 -11
  90. package/out/targets/MsiTarget.js.map +1 -1
  91. package/out/targets/archive.js +9 -9
  92. package/out/targets/archive.js.map +1 -1
  93. package/out/targets/differentialUpdateInfoBuilder.js +2 -2
  94. package/out/targets/differentialUpdateInfoBuilder.js.map +1 -1
  95. package/out/targets/fpm.js +17 -17
  96. package/out/targets/fpm.js.map +1 -1
  97. package/out/targets/nsis/NsisTarget.js +37 -37
  98. package/out/targets/nsis/NsisTarget.js.map +1 -1
  99. package/out/targets/nsis/WebInstallerTarget.js +2 -2
  100. package/out/targets/nsis/WebInstallerTarget.js.map +1 -1
  101. package/out/targets/nsis/nsisLang.js +5 -5
  102. package/out/targets/nsis/nsisLang.js.map +1 -1
  103. package/out/targets/nsis/nsisLicense.js +2 -2
  104. package/out/targets/nsis/nsisLicense.js.map +1 -1
  105. package/out/targets/nsis/nsisUtil.js +5 -5
  106. package/out/targets/nsis/nsisUtil.js.map +1 -1
  107. package/out/targets/pkg.js +17 -17
  108. package/out/targets/pkg.js.map +1 -1
  109. package/out/targets/snap.js +19 -11
  110. package/out/targets/snap.js.map +1 -1
  111. package/out/targets/targetFactory.js +4 -4
  112. package/out/targets/targetFactory.js.map +1 -1
  113. package/out/targets/tools.js +1 -1
  114. package/out/targets/tools.js.map +1 -1
  115. package/out/util/AppFileWalker.js +2 -2
  116. package/out/util/AppFileWalker.js.map +1 -1
  117. package/out/util/NodeModuleCopyHelper.js +3 -3
  118. package/out/util/NodeModuleCopyHelper.js.map +1 -1
  119. package/out/util/appBuilder.js +2 -2
  120. package/out/util/appBuilder.js.map +1 -1
  121. package/out/util/appFileCopier.d.ts +1 -0
  122. package/out/util/appFileCopier.js +9 -9
  123. package/out/util/appFileCopier.js.map +1 -1
  124. package/out/util/cacheManager.js +5 -5
  125. package/out/util/cacheManager.js.map +1 -1
  126. package/out/util/config.js +10 -10
  127. package/out/util/config.js.map +1 -1
  128. package/out/util/flags.js +2 -2
  129. package/out/util/flags.js.map +1 -1
  130. package/out/util/hash.js +2 -2
  131. package/out/util/hash.js.map +1 -1
  132. package/out/util/license.js +1 -1
  133. package/out/util/license.js.map +1 -1
  134. package/out/util/macosVersion.js +3 -3
  135. package/out/util/macosVersion.js.map +1 -1
  136. package/out/util/normalizePackageData.js +4 -4
  137. package/out/util/normalizePackageData.js.map +1 -1
  138. package/out/util/packageDependencies.js +1 -1
  139. package/out/util/packageDependencies.js.map +1 -1
  140. package/out/util/packageMetadata.js +6 -6
  141. package/out/util/packageMetadata.js.map +1 -1
  142. package/out/util/repositoryInfo.js +2 -2
  143. package/out/util/repositoryInfo.js.map +1 -1
  144. package/out/util/yarn.d.ts +1 -1
  145. package/out/util/yarn.js +27 -38
  146. package/out/util/yarn.js.map +1 -1
  147. package/out/version.d.ts +1 -1
  148. package/out/version.js +1 -1
  149. package/out/version.js.map +1 -1
  150. package/out/vm/MonoVm.js +2 -2
  151. package/out/vm/MonoVm.js.map +1 -1
  152. package/out/vm/ParallelsVm.js +6 -6
  153. package/out/vm/ParallelsVm.js.map +1 -1
  154. package/out/vm/WineVm.js +1 -1
  155. package/out/vm/WineVm.js.map +1 -1
  156. package/out/vm/vm.js +2 -2
  157. package/out/vm/vm.js.map +1 -1
  158. package/out/winPackager.js +25 -25
  159. package/out/winPackager.js.map +1 -1
  160. package/out/wine.js +2 -2
  161. package/out/wine.js.map +1 -1
  162. package/package.json +8 -7
  163. package/scheme.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"nsisLang.js","s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AAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;YAC3E,KAAK,MAAM,cAAc,IAAI,gBAAgB,EAAE;gBAC7C,MAAM,CAAC,IAAI,CAAC,cAAc,SAAS,IAAI,YAAI,CAAC,cAAc,CAAC,KAAK,kBAAkB,GAAG,CAAC,CAAA;aACvF;SACF;KACF;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { asArray } from \"builder-util\"\nimport { bundledLanguages, langIdToName, lcid, toLangWithRegion } from \"../../util/langs\"\nimport _debug from \"debug\"\nimport { outputFile, readFile } from \"fs-extra\"\nimport { load } from \"js-yaml\"\nimport * as path from \"path\"\nimport { PlatformPackager } from \"../../platformPackager\"\nimport { NsisOptions } from \"./nsisOptions\"\nimport { NsisScriptGenerator } from \"./nsisScriptGenerator\"\nimport { nsisTemplatesDir } from \"./nsisUtil\"\n\nconst debug = _debug(\"electron-builder:nsis\")\n\nexport class LangConfigurator {\n readonly isMultiLang: boolean\n readonly langs: Array<string>\n\n constructor(options: NsisOptions) {\n const rawList = options.installerLanguages\n\n if (options.unicode === false || rawList === null || (Array.isArray(rawList) && rawList.length === 0)) {\n this.isMultiLang = false\n } else {\n this.isMultiLang = options.multiLanguageInstaller !== false\n }\n\n if (this.isMultiLang) {\n this.langs = rawList == null ? bundledLanguages.slice() : asArray(rawList).map(it => toLangWithRegion(it.replace(\"-\", \"_\")))\n } else {\n this.langs = [\"en_US\"]\n }\n }\n}\n\nexport function createAddLangsMacro(scriptGenerator: NsisScriptGenerator, langConfigurator: LangConfigurator) {\n const result: Array<string> = []\n for (const langWithRegion of langConfigurator.langs) {\n let name: string\n if (langWithRegion === \"zh_CN\") {\n name = \"SimpChinese\"\n } else if (langWithRegion === \"zh_TW\") {\n name = \"TradChinese\"\n } else if (langWithRegion === \"nb_NO\") {\n name = \"Norwegian\"\n } else if (langWithRegion === \"pt_BR\") {\n name = \"PortugueseBR\"\n } else {\n const lang = langWithRegion.substring(0, langWithRegion.indexOf(\"_\"))\n name = (langIdToName as any)[lang]\n if (name == null) {\n throw new Error(`Language name is unknown for ${lang}`)\n }\n\n if (name === \"Spanish\") {\n name = \"SpanishInternational\"\n }\n }\n result.push(`!insertmacro MUI_LANGUAGE \"${name}\"`)\n }\n\n scriptGenerator.macro(\"addLangs\", result)\n}\n\nasync function writeCustomLangFile(data: string, packager: PlatformPackager<any>) {\n const file = await packager.getTempFile(\"messages.nsh\")\n await outputFile(file, data)\n return file\n}\n\nexport async function addCustomMessageFileInclude(input: string, packager: PlatformPackager<any>, scriptGenerator: NsisScriptGenerator, langConfigurator: LangConfigurator) {\n const data = load(await readFile(path.join(nsisTemplatesDir, input), \"utf-8\"))\n const instructions = computeCustomMessageTranslations(data, langConfigurator).join(\"\\n\")\n debug(instructions)\n scriptGenerator.include(await writeCustomLangFile(instructions, packager))\n}\n\nfunction computeCustomMessageTranslations(messages: any, langConfigurator: LangConfigurator): Array<string> {\n const result: Array<string> = []\n const includedLangs = new Set(langConfigurator.langs)\n for (const messageId of Object.keys(messages)) {\n const langToTranslations = messages[messageId]\n const unspecifiedLangs = new Set(langConfigurator.langs)\n for (const lang of Object.keys(langToTranslations)) {\n const langWithRegion = toLangWithRegion(lang)\n\n if (!includedLangs.has(langWithRegion)) {\n continue\n }\n\n const value = langToTranslations[lang]\n if (value == null) {\n throw new Error(`${messageId} not specified for ${lang}`)\n }\n\n result.push(`LangString ${messageId} ${lcid[langWithRegion]} \"${value.replace(/\\n/g, \"$\\\\r$\\\\n\")}\"`)\n unspecifiedLangs.delete(langWithRegion)\n }\n\n if (langConfigurator.isMultiLang) {\n const defaultTranslation = langToTranslations.en.replace(/\\n/g, \"$\\\\r$\\\\n\")\n for (const langWithRegion of unspecifiedLangs) {\n result.push(`LangString ${messageId} ${lcid[langWithRegion]} \"${defaultTranslation}\"`)\n }\n }\n }\n return result\n}\n"]}
1
+ {"version":3,"file":"nsisLang.js","sourceRoot":"","sources":["../../../src/targets/nsis/nsisLang.ts"],"names":[],"mappings":";;;A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,EAAE,UAAU,CAAC,CAAA;YAC3E,KAAK,MAAM,cAAc,IAAI,gBAAgB,EAAE;gBAC7C,MAAM,CAAC,IAAI,CAAC,cAAc,SAAS,IAAI,YAAI,CAAC,cAAc,CAAC,KAAK,kBAAkB,GAAG,CAAC,CAAA;aACvF;SACF;KACF;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { asArray } from \"builder-util\"\nimport { bundledLanguages, langIdToName, lcid, toLangWithRegion } from \"../../util/langs\"\nimport _debug from \"debug\"\nimport { outputFile, readFile } from \"fs-extra\"\nimport { load } from \"js-yaml\"\nimport * as path from \"path\"\nimport { PlatformPackager } from \"../../platformPackager\"\nimport { NsisOptions } from \"./nsisOptions\"\nimport { NsisScriptGenerator } from \"./nsisScriptGenerator\"\nimport { nsisTemplatesDir } from \"./nsisUtil\"\n\nconst debug = _debug(\"electron-builder:nsis\")\n\nexport class LangConfigurator {\n readonly isMultiLang: boolean\n readonly langs: Array<string>\n\n constructor(options: NsisOptions) {\n const rawList = options.installerLanguages\n\n if (options.unicode === false || rawList === null || (Array.isArray(rawList) && rawList.length === 0)) {\n this.isMultiLang = false\n } else {\n this.isMultiLang = options.multiLanguageInstaller !== false\n }\n\n if (this.isMultiLang) {\n this.langs = rawList == null ? bundledLanguages.slice() : asArray(rawList).map(it => toLangWithRegion(it.replace(\"-\", \"_\")))\n } else {\n this.langs = [\"en_US\"]\n }\n }\n}\n\nexport function createAddLangsMacro(scriptGenerator: NsisScriptGenerator, langConfigurator: LangConfigurator) {\n const result: Array<string> = []\n for (const langWithRegion of langConfigurator.langs) {\n let name: string\n if (langWithRegion === \"zh_CN\") {\n name = \"SimpChinese\"\n } else if (langWithRegion === \"zh_TW\") {\n name = \"TradChinese\"\n } else if (langWithRegion === \"nb_NO\") {\n name = \"Norwegian\"\n } else if (langWithRegion === \"pt_BR\") {\n name = \"PortugueseBR\"\n } else {\n const lang = langWithRegion.substring(0, langWithRegion.indexOf(\"_\"))\n name = (langIdToName as any)[lang]\n if (name == null) {\n throw new Error(`Language name is unknown for ${lang}`)\n }\n\n if (name === \"Spanish\") {\n name = \"SpanishInternational\"\n }\n }\n result.push(`!insertmacro MUI_LANGUAGE \"${name}\"`)\n }\n\n scriptGenerator.macro(\"addLangs\", result)\n}\n\nasync function writeCustomLangFile(data: string, packager: PlatformPackager<any>) {\n const file = await packager.getTempFile(\"messages.nsh\")\n await outputFile(file, data)\n return file\n}\n\nexport async function addCustomMessageFileInclude(input: string, packager: PlatformPackager<any>, scriptGenerator: NsisScriptGenerator, langConfigurator: LangConfigurator) {\n const data = load(await readFile(path.join(nsisTemplatesDir, input), \"utf-8\"))\n const instructions = computeCustomMessageTranslations(data, langConfigurator).join(\"\\n\")\n debug(instructions)\n scriptGenerator.include(await writeCustomLangFile(instructions, packager))\n}\n\nfunction computeCustomMessageTranslations(messages: any, langConfigurator: LangConfigurator): Array<string> {\n const result: Array<string> = []\n const includedLangs = new Set(langConfigurator.langs)\n for (const messageId of Object.keys(messages)) {\n const langToTranslations = messages[messageId]\n const unspecifiedLangs = new Set(langConfigurator.langs)\n for (const lang of Object.keys(langToTranslations)) {\n const langWithRegion = toLangWithRegion(lang)\n\n if (!includedLangs.has(langWithRegion)) {\n continue\n }\n\n const value = langToTranslations[lang]\n if (value == null) {\n throw new Error(`${messageId} not specified for ${lang}`)\n }\n\n result.push(`LangString ${messageId} ${lcid[langWithRegion]} \"${value.replace(/\\n/g, \"$\\\\r$\\\\n\")}\"`)\n unspecifiedLangs.delete(langWithRegion)\n }\n\n if (langConfigurator.isMultiLang) {\n const defaultTranslation = langToTranslations.en.replace(/\\n/g, \"$\\\\r$\\\\n\")\n for (const langWithRegion of unspecifiedLangs) {\n result.push(`LangString ${messageId} ${lcid[langWithRegion]} \"${defaultTranslation}\"`)\n }\n }\n }\n return result\n}\n"]}
@@ -6,7 +6,7 @@ const license_1 = require("../../util/license");
6
6
  const path = require("path");
7
7
  const nsisUtil_1 = require("./nsisUtil");
8
8
  async function computeLicensePage(packager, options, scriptGenerator, languages) {
9
- const license = await license_1.getNotLocalizedLicenseFile(options.license, packager);
9
+ const license = await (0, license_1.getNotLocalizedLicenseFile)(options.license, packager);
10
10
  if (license != null) {
11
11
  let licensePage;
12
12
  if (license.endsWith(".html")) {
@@ -29,7 +29,7 @@ async function computeLicensePage(packager, options, scriptGenerator, languages)
29
29
  }
30
30
  return;
31
31
  }
32
- const licenseFiles = await license_1.getLicenseFiles(packager);
32
+ const licenseFiles = await (0, license_1.getLicenseFiles)(packager);
33
33
  if (licenseFiles.length === 0) {
34
34
  return;
35
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nsisLicense.js","sourceRoot":"","sources":["../../../src/targets/nsis/nsisLicense.ts"],"names":[],"mappings":";;;AAAA,4CAAuC;AACvC,gDAAgF;AAChF,6BAA4B;AAI5B,yCAA6C;AAEtC,KAAK,UAAU,kBAAkB,CAAC,QAAqB,EAAE,OAAoB,EAAE,eAAoC,EAAE,SAAwB;IAClJ,MAAM,OAAO,GAAG,MAAM,oCAA0B,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IAC3E,IAAI,OAAO,IAAI,IAAI,EAAE;QACnB,IAAI,WAA0B,CAAA;QAC9B,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC7B,WAAW,GAAG;gBACZ,kDAAkD;gBAClD,sBAAsB;gBACtB,0CAA0C;gBAC1C,2BAA2B;gBAC3B,+DAA+D;gBAC/D,aAAa;gBAEb,kCAAkC,IAAI,CAAC,IAAI,CAAC,2BAAgB,EAAE,mBAAmB,CAAC,GAAG;aACtF,CAAA;SACF;aAAM;YACL,WAAW,GAAG,CAAC,kCAAkC,OAAO,GAAG,CAAC,CAAA;SAC7D;QAED,eAAe,CAAC,KAAK,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA;QACjD,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC7B,eAAe,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,0CAA0C,OAAO,GAAG,CAAC,CAAC,CAAA;SACjG;QACD,OAAM;KACP;IAED,MAAM,YAAY,GAAG,MAAM,yBAAe,CAAC,QAAQ,CAAC,CAAA;IACpD,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;QAC7B,OAAM;KACP;IAED,MAAM,WAAW,GAAkB,EAAE,CAAA;IACrC,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAA;IAE3C,IAAI,WAAW,GAAkB,IAAI,CAAA;IACrC,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE;QAC/B,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;QAC5C,IAAI,WAAW,IAAI,IAAI,EAAE;YACvB,WAAW,GAAG,IAAI,CAAC,IAAI,CAAA;SACxB;QACD,WAAW,CAAC,IAAI,CAAC,gCAAgC,YAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,GAAG,CAAC,CAAA;KAC1G;IAED,KAAK,MAAM,CAAC,IAAI,gBAAgB,EAAE;QAChC,WAAW,CAAC,IAAI,CAAC,gCAAgC,YAAI,CAAC,CAAC,CAAC,KAAK,WAAW,GAAG,CAAC,CAAA;KAC7E;IAED,WAAW,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAA;IACjE,eAAe,CAAC,KAAK,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA;AACnD,CAAC;AAjDD,gDAiDC","sourcesContent":["import { lcid } from \"../../util/langs\"\nimport { getLicenseFiles, getNotLocalizedLicenseFile } from \"../../util/license\"\nimport * as path from \"path\"\nimport { WinPackager } from \"../../winPackager\"\nimport { NsisOptions } from \"./nsisOptions\"\nimport { NsisScriptGenerator } from \"./nsisScriptGenerator\"\nimport { nsisTemplatesDir } from \"./nsisUtil\"\n\nexport async function computeLicensePage(packager: WinPackager, options: NsisOptions, scriptGenerator: NsisScriptGenerator, languages: Array<string>): Promise<void> {\n const license = await getNotLocalizedLicenseFile(options.license, packager)\n if (license != null) {\n let licensePage: Array<string>\n if (license.endsWith(\".html\")) {\n licensePage = [\n \"!define MUI_PAGE_CUSTOMFUNCTION_SHOW LicenseShow\",\n \"Function LicenseShow\",\n \" FindWindow $R0 `#32770` `` $HWNDPARENT\",\n \" GetDlgItem $R0 $R0 1000\",\n \"EmbedHTML::Load /replace $R0 file://$PLUGINSDIR\\\\license.html\",\n \"FunctionEnd\",\n\n `!insertmacro MUI_PAGE_LICENSE \"${path.join(nsisTemplatesDir, \"empty-license.txt\")}\"`,\n ]\n } else {\n licensePage = [`!insertmacro MUI_PAGE_LICENSE \"${license}\"`]\n }\n\n scriptGenerator.macro(\"licensePage\", licensePage)\n if (license.endsWith(\".html\")) {\n scriptGenerator.macro(\"addLicenseFiles\", [`File /oname=$PLUGINSDIR\\\\license.html \"${license}\"`])\n }\n return\n }\n\n const licenseFiles = await getLicenseFiles(packager)\n if (licenseFiles.length === 0) {\n return\n }\n\n const licensePage: Array<string> = []\n const unspecifiedLangs = new Set(languages)\n\n let defaultFile: string | null = null\n for (const item of licenseFiles) {\n unspecifiedLangs.delete(item.langWithRegion)\n if (defaultFile == null) {\n defaultFile = item.file\n }\n licensePage.push(`LicenseLangString MUILicense ${lcid[item.langWithRegion] || item.lang} \"${item.file}\"`)\n }\n\n for (const l of unspecifiedLangs) {\n licensePage.push(`LicenseLangString MUILicense ${lcid[l]} \"${defaultFile}\"`)\n }\n\n licensePage.push('!insertmacro MUI_PAGE_LICENSE \"$(MUILicense)\"')\n scriptGenerator.macro(\"licensePage\", licensePage)\n}\n"]}
1
+ {"version":3,"file":"nsisLicense.js","sourceRoot":"","sources":["../../../src/targets/nsis/nsisLicense.ts"],"names":[],"mappings":";;;AAAA,4CAAuC;AACvC,gDAAgF;AAChF,6BAA4B;AAI5B,yCAA6C;AAEtC,KAAK,UAAU,kBAAkB,CAAC,QAAqB,EAAE,OAAoB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,gCAAgC,YAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,GAAG,CAAC,CAAA;KAC1G;IAED,KAAK,MAAM,CAAC,IAAI,gBAAgB,EAAE;QAChC,WAAW,CAAC,IAAI,CAAC,gCAAgC,YAAI,CAAC,CAAC,CAAC,KAAK,WAAW,GAAG,CAAC,CAAA;KAC7E;IAED,WAAW,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAA;IACjE,eAAe,CAAC,KAAK,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA;AACnD,CAAC;AAjDD,gDAiDC","sourcesContent":["import { lcid } from \"../../util/langs\"\nimport { getLicenseFiles, getNotLocalizedLicenseFile } from \"../../util/license\"\nimport * as path from \"path\"\nimport { WinPackager } from \"../../winPackager\"\nimport { NsisOptions } from \"./nsisOptions\"\nimport { NsisScriptGenerator } from \"./nsisScriptGenerator\"\nimport { nsisTemplatesDir } from \"./nsisUtil\"\n\nexport async function computeLicensePage(packager: WinPackager, options: NsisOptions, scriptGenerator: NsisScriptGenerator, languages: Array<string>): Promise<void> {\n const license = await getNotLocalizedLicenseFile(options.license, packager)\n if (license != null) {\n let licensePage: Array<string>\n if (license.endsWith(\".html\")) {\n licensePage = [\n \"!define MUI_PAGE_CUSTOMFUNCTION_SHOW LicenseShow\",\n \"Function LicenseShow\",\n \" FindWindow $R0 `#32770` `` $HWNDPARENT\",\n \" GetDlgItem $R0 $R0 1000\",\n \"EmbedHTML::Load /replace $R0 file://$PLUGINSDIR\\\\license.html\",\n \"FunctionEnd\",\n\n `!insertmacro MUI_PAGE_LICENSE \"${path.join(nsisTemplatesDir, \"empty-license.txt\")}\"`,\n ]\n } else {\n licensePage = [`!insertmacro MUI_PAGE_LICENSE \"${license}\"`]\n }\n\n scriptGenerator.macro(\"licensePage\", licensePage)\n if (license.endsWith(\".html\")) {\n scriptGenerator.macro(\"addLicenseFiles\", [`File /oname=$PLUGINSDIR\\\\license.html \"${license}\"`])\n }\n return\n }\n\n const licenseFiles = await getLicenseFiles(packager)\n if (licenseFiles.length === 0) {\n return\n }\n\n const licensePage: Array<string> = []\n const unspecifiedLangs = new Set(languages)\n\n let defaultFile: string | null = null\n for (const item of licenseFiles) {\n unspecifiedLangs.delete(item.langWithRegion)\n if (defaultFile == null) {\n defaultFile = item.file\n }\n licensePage.push(`LicenseLangString MUILicense ${lcid[item.langWithRegion] || item.lang} \"${item.file}\"`)\n }\n\n for (const l of unspecifiedLangs) {\n licensePage.push(`LicenseLangString MUILicense ${lcid[l]} \"${defaultFile}\"`)\n }\n\n licensePage.push('!insertmacro MUI_PAGE_LICENSE \"$(MUILicense)\"')\n scriptGenerator.macro(\"licensePage\", licensePage)\n}\n"]}
@@ -8,7 +8,7 @@ const path = require("path");
8
8
  const pathManager_1 = require("../../util/pathManager");
9
9
  const fs = require("fs/promises");
10
10
  const zlib = require("zlib");
11
- exports.nsisTemplatesDir = pathManager_1.getTemplatePath("nsis");
11
+ exports.nsisTemplatesDir = (0, pathManager_1.getTemplatePath)("nsis");
12
12
  exports.NsisTargetOptions = (() => {
13
13
  let _resolve;
14
14
  const promise = new Promise(resolve => (_resolve = resolve));
@@ -27,12 +27,12 @@ const NSIS_PATH = () => {
27
27
  const { checksum, url, version } = options.customNsisBinary;
28
28
  if (checksum && url) {
29
29
  const binaryVersion = version || checksum.substr(0, 8);
30
- return binDownload_1.getBinFromCustomLoc("nsis", binaryVersion, url, checksum);
30
+ return (0, binDownload_1.getBinFromCustomLoc)("nsis", binaryVersion, url, checksum);
31
31
  }
32
32
  }
33
33
  // Warning: Don't use v3.0.4.2 - https://github.com/electron-userland/electron-builder/issues/6334
34
34
  // noinspection SpellCheckingInspection
35
- return binDownload_1.getBinFromUrl("nsis", "3.0.4.1", "VKMiizYdmNdJOWpRGz4trl4lD++BvYP2irAXpMilheUP0pc93iKlWAoP843Vlraj8YG19CVn0j+dCo/hURz9+Q==");
35
+ return (0, binDownload_1.getBinFromUrl)("nsis", "3.0.4.1", "VKMiizYdmNdJOWpRGz4trl4lD++BvYP2irAXpMilheUP0pc93iKlWAoP843Vlraj8YG19CVn0j+dCo/hURz9+Q==");
36
36
  });
37
37
  };
38
38
  exports.NSIS_PATH = NSIS_PATH;
@@ -94,9 +94,9 @@ class CopyElevateHelper {
94
94
  if (promise != null) {
95
95
  return promise;
96
96
  }
97
- promise = exports.NSIS_PATH().then(it => {
97
+ promise = (0, exports.NSIS_PATH)().then(it => {
98
98
  const outFile = path.join(appOutDir, "resources", "elevate.exe");
99
- const promise = fs_1.copyFile(path.join(it, "elevate.exe"), outFile, false);
99
+ const promise = (0, fs_1.copyFile)(path.join(it, "elevate.exe"), outFile, false);
100
100
  if (target.packager.platformSpecificBuildOptions.signAndEditExecutable !== false) {
101
101
  return promise.then(() => target.packager.sign(outFile));
102
102
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nsisUtil.js","sourceRoot":"","sources":["../../../src/targets/nsis/nsisUtil.ts"],"names":[],"mappings":";;;AAAA,+CAAwC;AAExC,mDAAsE;AACtE,4CAA8C;AAC9C,6BAA4B;AAC5B,wDAAwD;AAExD,kCAAiC;AACjC,6BAA4B;AAGf,QAAA,gBAAgB,GAAG,6BAAe,CAAC,MAAM,CAAC,CAAA;AAE1C,QAAA,iBAAiB,GAAG,CAAC,GAAG,EAAE;IACrC,IAAI,QAAuC,CAAA;IAC3C,MAAM,OAAO,GAAG,IAAI,OAAO,CAAc,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAA;IACzE,OAAO;QACL,IAAI,EAAE,CAAC,QAAuC,EAAmB,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC1F,OAAO,EAAE,CAAC,OAAoB,EAAO,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;KAC1D,CAAA;AACH,CAAC,CAAC,EAAE,CAAA;AAEG,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MA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MAAM,CAAC,CAAA;aACrC;YACD,MAAM,WAAW,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAA;YAC5C,WAAW,CAAC,MAAM,EAAE,CAAA,CAAC,IAAI;YACzB,IAAI,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE;gBACpC,IAAI,WAAW,EAAE;oBACf,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;iBAC1C;gBACD,WAAW,GAAG,MAAM,CAAA;aACrB;SACF;QACD,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;SAC1C;QACD,MAAM,EAAE,CAAC,SAAS,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;QAC/C,MAAM,EAAE,CAAC,UAAU,CAAC,eAAe,EAAE,WAAW,CAAC,CAAA;IACnD,CAAC;CACF;AAtFD,8CAsFC","sourcesContent":["import { Arch, log } from \"builder-util\"\nimport { PackageFileInfo } from \"builder-util-runtime\"\nimport { getBinFromUrl, getBinFromCustomLoc } from \"../../binDownload\"\nimport { copyFile } from \"builder-util/out/fs\"\nimport * as path from \"path\"\nimport { getTemplatePath } from \"../../util/pathManager\"\nimport { NsisTarget } from \"./NsisTarget\"\nimport * as fs from \"fs/promises\"\nimport * as zlib from \"zlib\"\nimport { NsisOptions } from \"./nsisOptions\"\n\nexport const nsisTemplatesDir = getTemplatePath(\"nsis\")\n\nexport const NsisTargetOptions = (() => {\n let _resolve: (options: NsisOptions) => any\n const promise = new Promise<NsisOptions>(resolve => (_resolve = resolve))\n return {\n then: (callback: (options: NsisOptions) => any): Promise<string> => promise.then(callback),\n resolve: (options: NsisOptions): any => _resolve(options),\n }\n})()\n\nexport const NSIS_PATH = () => {\n const custom = process.env.ELECTRON_BUILDER_NSIS_DIR\n if (custom != null && custom.length > 0) {\n return Promise.resolve(custom.trim())\n }\n return NsisTargetOptions.then((options: NsisOptions) => {\n if (options.customNsisBinary) {\n const { checksum, url, version } = options.customNsisBinary\n if (checksum && url) {\n const binaryVersion = version || checksum.substr(0, 8)\n return getBinFromCustomLoc(\"nsis\", binaryVersion, url, checksum)\n }\n }\n // Warning: Don't use v3.0.4.2 - https://github.com/electron-userland/electron-builder/issues/6334\n // noinspection SpellCheckingInspection\n return getBinFromUrl(\"nsis\", \"3.0.4.1\", \"VKMiizYdmNdJOWpRGz4trl4lD++BvYP2irAXpMilheUP0pc93iKlWAoP843Vlraj8YG19CVn0j+dCo/hURz9+Q==\")\n })\n}\n\nexport class AppPackageHelper {\n private readonly archToFileInfo = new Map<Arch, Promise<PackageFileInfo>>()\n private readonly infoToIsDelete = new Map<PackageFileInfo, boolean>()\n\n /** @private */\n refCount = 0\n\n constructor(private readonly elevateHelper: CopyElevateHelper) {}\n\n async packArch(arch: Arch, target: NsisTarget): Promise<PackageFileInfo> {\n let infoPromise = this.archToFileInfo.get(arch)\n if (infoPromise == null) {\n const appOutDir = target.archs.get(arch)!\n infoPromise = this.elevateHelper.copy(appOutDir, target).then(() => target.buildAppPackage(appOutDir, arch))\n this.archToFileInfo.set(arch, infoPromise)\n }\n\n const info = await infoPromise\n if (target.isWebInstaller) {\n this.infoToIsDelete.set(info, false)\n } else if (!this.infoToIsDelete.has(info)) {\n this.infoToIsDelete.set(info, true)\n }\n return info\n }\n\n async finishBuild(): Promise<any> {\n if (--this.refCount > 0) {\n return\n }\n\n const filesToDelete: Array<string> = []\n for (const [info, isDelete] of this.infoToIsDelete.entries()) {\n if (isDelete) {\n filesToDelete.push(info.path)\n }\n }\n\n await Promise.all(filesToDelete.map(it => fs.unlink(it)))\n }\n}\n\nexport class CopyElevateHelper {\n private readonly copied = new Map<string, Promise<any>>()\n\n copy(appOutDir: string, target: NsisTarget): Promise<any> {\n if (!target.packager.info.framework.isCopyElevateHelper) {\n return Promise.resolve()\n }\n\n let isPackElevateHelper = target.options.packElevateHelper\n if (isPackElevateHelper === false && target.options.perMachine === true) {\n isPackElevateHelper = true\n log.warn(\"`packElevateHelper = false` is ignored, because `perMachine` is set to `true`\")\n }\n\n if (isPackElevateHelper === false) {\n return Promise.resolve()\n }\n\n let promise = this.copied.get(appOutDir)\n if (promise != null) {\n return promise\n }\n\n promise = NSIS_PATH().then(it => {\n const outFile = path.join(appOutDir, \"resources\", \"elevate.exe\")\n const promise = copyFile(path.join(it, \"elevate.exe\"), outFile, false)\n if (target.packager.platformSpecificBuildOptions.signAndEditExecutable !== false) {\n return promise.then(() => target.packager.sign(outFile))\n }\n return promise\n })\n this.copied.set(appOutDir, promise)\n return promise\n }\n}\n\nclass BinaryReader {\n private readonly _buffer: Buffer\n private _position: number\n\n constructor(buffer: Buffer) {\n this._buffer = buffer\n this._position = 0\n }\n\n get length(): number {\n return this._buffer.length\n }\n\n get position(): number {\n return this._position\n }\n\n match(signature: Array<number>): boolean {\n if (signature.every((v, i) => this._buffer[this._position + i] === v)) {\n this._position += signature.length\n return true\n }\n return false\n }\n\n skip(offset: number) {\n this._position += offset\n }\n\n bytes(size: number): Buffer {\n const value = this._buffer.subarray(this._position, this._position + size)\n this._position += size\n return value\n }\n\n uint16(): number {\n const value = this._buffer[this._position] | (this._buffer[this._position + 1] << 8)\n this._position += 2\n return value\n }\n\n uint32(): number {\n return this.uint16() | (this.uint16() << 16)\n }\n\n string(length: number): string {\n let value = \"\"\n for (let i = 0; i < length; i++) {\n const c = this._buffer[this._position + i]\n if (c === 0x00) {\n break\n }\n value += String.fromCharCode(c)\n }\n this._position += length\n return value\n }\n}\n\nexport class UninstallerReader {\n // noinspection SpellCheckingInspection\n static async exec(installerPath: string, uninstallerPath: string) {\n const buffer = await fs.readFile(installerPath)\n const reader = new BinaryReader(buffer)\n // IMAGE_DOS_HEADER\n if (!reader.match([0x4d, 0x5a])) {\n throw new Error(\"Invalid 'MZ' signature.\")\n }\n reader.skip(58)\n // e_lfanew\n reader.skip(reader.uint32() - reader.position)\n // IMAGE_FILE_HEADER\n if (!reader.match([0x50, 0x45, 0x00, 0x00])) {\n throw new Error(\"Invalid 'PE' signature.\")\n }\n reader.skip(2)\n const numberOfSections = reader.uint16()\n reader.skip(12)\n const sizeOfOptionalHeader = reader.uint16()\n reader.skip(2)\n reader.skip(sizeOfOptionalHeader)\n // IMAGE_SECTION_HEADER\n let nsisOffset = 0\n for (let i = 0; i < numberOfSections; i++) {\n const name = reader.string(8)\n reader.skip(8)\n const rawSize = reader.uint32()\n const rawPointer = reader.uint32()\n reader.skip(16)\n switch (name) {\n case \".text\":\n case \".rdata\":\n case \".data\":\n case \".rsrc\": {\n nsisOffset = Math.max(rawPointer + rawSize, nsisOffset)\n break\n }\n default: {\n if (rawPointer !== 0 && rawSize !== 0) {\n throw new Error(\"Unsupported section '\" + name + \"'.\")\n }\n break\n }\n }\n }\n const executable = buffer.subarray(0, nsisOffset)\n const nsisSize = buffer.length - nsisOffset\n const nsisReader = new BinaryReader(buffer.subarray(nsisOffset, nsisOffset + nsisSize))\n const nsisSignature = [0xef, 0xbe, 0xad, 0xde, 0x4e, 0x75, 0x6c, 0x6c, 0x73, 0x6f, 0x66, 0x74, 0x49, 0x6e, 0x73, 0x74]\n nsisReader.uint32() // ?\n if (!nsisReader.match(nsisSignature)) {\n throw new Error(\"Invalid signature.\")\n }\n nsisReader.uint32() // ?\n if (nsisSize !== nsisReader.uint32()) {\n throw new Error(\"Size mismatch.\")\n }\n\n let innerBuffer = null\n while (true) {\n let size = nsisReader.uint32()\n const compressed = (size & 0x80000000) !== 0\n size = size & 0x7fffffff\n if (size === 0 || nsisReader.position + size > nsisReader.length || nsisReader.position >= nsisReader.length) {\n break\n }\n let buffer = nsisReader.bytes(size)\n if (compressed) {\n buffer = zlib.inflateRawSync(buffer)\n }\n const innerReader = new BinaryReader(buffer)\n innerReader.uint32() // ?\n if (innerReader.match(nsisSignature)) {\n if (innerBuffer) {\n throw new Error(\"Multiple inner blocks.\")\n }\n innerBuffer = buffer\n }\n }\n if (!innerBuffer) {\n throw new Error(\"Inner block not found.\")\n }\n await fs.writeFile(uninstallerPath, executable)\n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/C,MAAM,EAAE,CAAC,UAAU,CAAC,eAAe,EAAE,WAAW,CAAC,CAAA;IACnD,CAAC;CACF;AAtFD,8CAsFC","sourcesContent":["import { Arch, log } from \"builder-util\"\nimport { PackageFileInfo } from \"builder-util-runtime\"\nimport { getBinFromUrl, getBinFromCustomLoc } from \"../../binDownload\"\nimport { copyFile } from \"builder-util/out/fs\"\nimport * as path from \"path\"\nimport { getTemplatePath } from \"../../util/pathManager\"\nimport { NsisTarget } from \"./NsisTarget\"\nimport * as fs from \"fs/promises\"\nimport * as zlib from \"zlib\"\nimport { NsisOptions } from \"./nsisOptions\"\n\nexport const nsisTemplatesDir = getTemplatePath(\"nsis\")\n\nexport const NsisTargetOptions = (() => {\n let _resolve: (options: NsisOptions) => any\n const promise = new Promise<NsisOptions>(resolve => (_resolve = resolve))\n return {\n then: (callback: (options: NsisOptions) => any): Promise<string> => promise.then(callback),\n resolve: (options: NsisOptions): any => _resolve(options),\n }\n})()\n\nexport const NSIS_PATH = () => {\n const custom = process.env.ELECTRON_BUILDER_NSIS_DIR\n if (custom != null && custom.length > 0) {\n return Promise.resolve(custom.trim())\n }\n return NsisTargetOptions.then((options: NsisOptions) => {\n if (options.customNsisBinary) {\n const { checksum, url, version } = options.customNsisBinary\n if (checksum && url) {\n const binaryVersion = version || checksum.substr(0, 8)\n return getBinFromCustomLoc(\"nsis\", binaryVersion, url, checksum)\n }\n }\n // Warning: Don't use v3.0.4.2 - https://github.com/electron-userland/electron-builder/issues/6334\n // noinspection SpellCheckingInspection\n return getBinFromUrl(\"nsis\", \"3.0.4.1\", \"VKMiizYdmNdJOWpRGz4trl4lD++BvYP2irAXpMilheUP0pc93iKlWAoP843Vlraj8YG19CVn0j+dCo/hURz9+Q==\")\n })\n}\n\nexport class AppPackageHelper {\n private readonly archToFileInfo = new Map<Arch, Promise<PackageFileInfo>>()\n private readonly infoToIsDelete = new Map<PackageFileInfo, boolean>()\n\n /** @private */\n refCount = 0\n\n constructor(private readonly elevateHelper: CopyElevateHelper) {}\n\n async packArch(arch: Arch, target: NsisTarget): Promise<PackageFileInfo> {\n let infoPromise = this.archToFileInfo.get(arch)\n if (infoPromise == null) {\n const appOutDir = target.archs.get(arch)!\n infoPromise = this.elevateHelper.copy(appOutDir, target).then(() => target.buildAppPackage(appOutDir, arch))\n this.archToFileInfo.set(arch, infoPromise)\n }\n\n const info = await infoPromise\n if (target.isWebInstaller) {\n this.infoToIsDelete.set(info, false)\n } else if (!this.infoToIsDelete.has(info)) {\n this.infoToIsDelete.set(info, true)\n }\n return info\n }\n\n async finishBuild(): Promise<any> {\n if (--this.refCount > 0) {\n return\n }\n\n const filesToDelete: Array<string> = []\n for (const [info, isDelete] of this.infoToIsDelete.entries()) {\n if (isDelete) {\n filesToDelete.push(info.path)\n }\n }\n\n await Promise.all(filesToDelete.map(it => fs.unlink(it)))\n }\n}\n\nexport class CopyElevateHelper {\n private readonly copied = new Map<string, Promise<any>>()\n\n copy(appOutDir: string, target: NsisTarget): Promise<any> {\n if (!target.packager.info.framework.isCopyElevateHelper) {\n return Promise.resolve()\n }\n\n let isPackElevateHelper = target.options.packElevateHelper\n if (isPackElevateHelper === false && target.options.perMachine === true) {\n isPackElevateHelper = true\n log.warn(\"`packElevateHelper = false` is ignored, because `perMachine` is set to `true`\")\n }\n\n if (isPackElevateHelper === false) {\n return Promise.resolve()\n }\n\n let promise = this.copied.get(appOutDir)\n if (promise != null) {\n return promise\n }\n\n promise = NSIS_PATH().then(it => {\n const outFile = path.join(appOutDir, \"resources\", \"elevate.exe\")\n const promise = copyFile(path.join(it, \"elevate.exe\"), outFile, false)\n if (target.packager.platformSpecificBuildOptions.signAndEditExecutable !== false) {\n return promise.then(() => target.packager.sign(outFile))\n }\n return promise\n })\n this.copied.set(appOutDir, promise)\n return promise\n }\n}\n\nclass BinaryReader {\n private readonly _buffer: Buffer\n private _position: number\n\n constructor(buffer: Buffer) {\n this._buffer = buffer\n this._position = 0\n }\n\n get length(): number {\n return this._buffer.length\n }\n\n get position(): number {\n return this._position\n }\n\n match(signature: Array<number>): boolean {\n if (signature.every((v, i) => this._buffer[this._position + i] === v)) {\n this._position += signature.length\n return true\n }\n return false\n }\n\n skip(offset: number) {\n this._position += offset\n }\n\n bytes(size: number): Buffer {\n const value = this._buffer.subarray(this._position, this._position + size)\n this._position += size\n return value\n }\n\n uint16(): number {\n const value = this._buffer[this._position] | (this._buffer[this._position + 1] << 8)\n this._position += 2\n return value\n }\n\n uint32(): number {\n return this.uint16() | (this.uint16() << 16)\n }\n\n string(length: number): string {\n let value = \"\"\n for (let i = 0; i < length; i++) {\n const c = this._buffer[this._position + i]\n if (c === 0x00) {\n break\n }\n value += String.fromCharCode(c)\n }\n this._position += length\n return value\n }\n}\n\nexport class UninstallerReader {\n // noinspection SpellCheckingInspection\n static async exec(installerPath: string, uninstallerPath: string) {\n const buffer = await fs.readFile(installerPath)\n const reader = new BinaryReader(buffer)\n // IMAGE_DOS_HEADER\n if (!reader.match([0x4d, 0x5a])) {\n throw new Error(\"Invalid 'MZ' signature.\")\n }\n reader.skip(58)\n // e_lfanew\n reader.skip(reader.uint32() - reader.position)\n // IMAGE_FILE_HEADER\n if (!reader.match([0x50, 0x45, 0x00, 0x00])) {\n throw new Error(\"Invalid 'PE' signature.\")\n }\n reader.skip(2)\n const numberOfSections = reader.uint16()\n reader.skip(12)\n const sizeOfOptionalHeader = reader.uint16()\n reader.skip(2)\n reader.skip(sizeOfOptionalHeader)\n // IMAGE_SECTION_HEADER\n let nsisOffset = 0\n for (let i = 0; i < numberOfSections; i++) {\n const name = reader.string(8)\n reader.skip(8)\n const rawSize = reader.uint32()\n const rawPointer = reader.uint32()\n reader.skip(16)\n switch (name) {\n case \".text\":\n case \".rdata\":\n case \".data\":\n case \".rsrc\": {\n nsisOffset = Math.max(rawPointer + rawSize, nsisOffset)\n break\n }\n default: {\n if (rawPointer !== 0 && rawSize !== 0) {\n throw new Error(\"Unsupported section '\" + name + \"'.\")\n }\n break\n }\n }\n }\n const executable = buffer.subarray(0, nsisOffset)\n const nsisSize = buffer.length - nsisOffset\n const nsisReader = new BinaryReader(buffer.subarray(nsisOffset, nsisOffset + nsisSize))\n const nsisSignature = [0xef, 0xbe, 0xad, 0xde, 0x4e, 0x75, 0x6c, 0x6c, 0x73, 0x6f, 0x66, 0x74, 0x49, 0x6e, 0x73, 0x74]\n nsisReader.uint32() // ?\n if (!nsisReader.match(nsisSignature)) {\n throw new Error(\"Invalid signature.\")\n }\n nsisReader.uint32() // ?\n if (nsisSize !== nsisReader.uint32()) {\n throw new Error(\"Size mismatch.\")\n }\n\n let innerBuffer = null\n while (true) {\n let size = nsisReader.uint32()\n const compressed = (size & 0x80000000) !== 0\n size = size & 0x7fffffff\n if (size === 0 || nsisReader.position + size > nsisReader.length || nsisReader.position >= nsisReader.length) {\n break\n }\n let buffer = nsisReader.bytes(size)\n if (compressed) {\n buffer = zlib.inflateRawSync(buffer)\n }\n const innerReader = new BinaryReader(buffer)\n innerReader.uint32() // ?\n if (innerReader.match(nsisSignature)) {\n if (innerBuffer) {\n throw new Error(\"Multiple inner blocks.\")\n }\n innerBuffer = buffer\n }\n }\n if (!innerBuffer) {\n throw new Error(\"Inner block not found.\")\n }\n await fs.writeFile(uninstallerPath, executable)\n await fs.appendFile(uninstallerPath, innerBuffer)\n }\n}\n"]}
@@ -43,10 +43,10 @@ class PkgTarget extends core_1.Target {
43
43
  const appOutDir = this.outDir;
44
44
  // https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html
45
45
  const distInfoFile = path.join(appOutDir, "distribution.xml");
46
- const innerPackageFile = path.join(appOutDir, `${appInfo_1.filterCFBundleIdentifier(appInfo.id)}.pkg`);
47
- const componentPropertyListFile = path.join(appOutDir, `${appInfo_1.filterCFBundleIdentifier(appInfo.id)}.plist`);
46
+ const innerPackageFile = path.join(appOutDir, `${(0, appInfo_1.filterCFBundleIdentifier)(appInfo.id)}.pkg`);
47
+ const componentPropertyListFile = path.join(appOutDir, `${(0, appInfo_1.filterCFBundleIdentifier)(appInfo.id)}.plist`);
48
48
  const identity = (await Promise.all([
49
- macCodeSign_1.findIdentity(certType, options.identity || packager.platformSpecificBuildOptions.identity, keychainFile),
49
+ (0, macCodeSign_1.findIdentity)(certType, options.identity || packager.platformSpecificBuildOptions.identity, keychainFile),
50
50
  this.customizeDistributionConfiguration(distInfoFile, appPath),
51
51
  this.buildComponentPackage(appPath, componentPropertyListFile, innerPackageFile),
52
52
  ]))[0];
@@ -56,19 +56,19 @@ class PkgTarget extends core_1.Target {
56
56
  const args = prepareProductBuildArgs(identity, keychainFile);
57
57
  args.push("--distribution", distInfoFile);
58
58
  args.push(artifactPath);
59
- builder_util_1.use(options.productbuild, it => args.push(...it));
60
- await builder_util_1.exec("productbuild", args, {
59
+ (0, builder_util_1.use)(options.productbuild, it => args.push(...it));
60
+ await (0, builder_util_1.exec)("productbuild", args, {
61
61
  cwd: appOutDir,
62
62
  });
63
- await Promise.all([promises_1.unlink(innerPackageFile), promises_1.unlink(distInfoFile)]);
63
+ await Promise.all([(0, promises_1.unlink)(innerPackageFile), (0, promises_1.unlink)(distInfoFile)]);
64
64
  await packager.dispatchArtifactCreated(artifactPath, this, arch, packager.computeSafeArtifactName(artifactName, "pkg", arch));
65
65
  }
66
66
  async customizeDistributionConfiguration(distInfoFile, appPath) {
67
- await builder_util_1.exec("productbuild", ["--synthesize", "--component", appPath, distInfoFile], {
67
+ await (0, builder_util_1.exec)("productbuild", ["--synthesize", "--component", appPath, distInfoFile], {
68
68
  cwd: this.outDir,
69
69
  });
70
70
  const options = this.options;
71
- let distInfo = await promises_1.readFile(distInfoFile, "utf-8");
71
+ let distInfo = await (0, promises_1.readFile)(distInfoFile, "utf-8");
72
72
  if (options.mustClose != null && options.mustClose.length !== 0) {
73
73
  const startContent = ` <pkg-ref id="${this.packager.appInfo.id}">\n <must-close>\n`;
74
74
  const endContent = " </must-close>\n </pkg-ref>\n</installer-gui-script>";
@@ -98,7 +98,7 @@ class PkgTarget extends core_1.Target {
98
98
  if (welcome != null) {
99
99
  distInfo = distInfo.substring(0, insertIndex) + ` <welcome file="${welcome}"/>\n` + distInfo.substring(insertIndex);
100
100
  }
101
- const license = await license_1.getNotLocalizedLicenseFile(options.license, this.packager);
101
+ const license = await (0, license_1.getNotLocalizedLicenseFile)(options.license, this.packager);
102
102
  if (license != null) {
103
103
  distInfo = distInfo.substring(0, insertIndex) + ` <license file="${license}"/>\n` + distInfo.substring(insertIndex);
104
104
  }
@@ -106,16 +106,16 @@ class PkgTarget extends core_1.Target {
106
106
  if (conclusion != null) {
107
107
  distInfo = distInfo.substring(0, insertIndex) + ` <conclusion file="${conclusion}"/>\n` + distInfo.substring(insertIndex);
108
108
  }
109
- builder_util_1.debug(distInfo);
110
- await promises_1.writeFile(distInfoFile, distInfo);
109
+ (0, builder_util_1.debug)(distInfo);
110
+ await (0, promises_1.writeFile)(distInfoFile, distInfo);
111
111
  }
112
112
  async buildComponentPackage(appPath, propertyListOutputFile, packageOutputFile) {
113
113
  const options = this.options;
114
114
  const rootPath = path.dirname(appPath);
115
115
  // first produce a component plist template
116
- await builder_util_1.exec("pkgbuild", ["--analyze", "--root", rootPath, propertyListOutputFile]);
116
+ await (0, builder_util_1.exec)("pkgbuild", ["--analyze", "--root", rootPath, propertyListOutputFile]);
117
117
  // process the template plist
118
- const plistInfo = (await appBuilder_1.executeAppBuilderAsJson(["decode-plist", "-f", propertyListOutputFile]))[0].filter((it) => it.RootRelativeBundlePath !== "Electron.dSYM");
118
+ const plistInfo = (await (0, appBuilder_1.executeAppBuilderAsJson)(["decode-plist", "-f", propertyListOutputFile]))[0].filter((it) => it.RootRelativeBundlePath !== "Electron.dSYM");
119
119
  if (plistInfo.length > 0) {
120
120
  const packageInfo = plistInfo[0];
121
121
  // ChildBundles lists all of electron binaries within the .app.
@@ -134,7 +134,7 @@ class PkgTarget extends core_1.Target {
134
134
  if (options.overwriteAction != null) {
135
135
  packageInfo.BundleOverwriteAction = options.overwriteAction;
136
136
  }
137
- await appBuilder_1.executeAppBuilderAndWriteJson(["encode-plist"], { [propertyListOutputFile]: plistInfo });
137
+ await (0, appBuilder_1.executeAppBuilderAndWriteJson)(["encode-plist"], { [propertyListOutputFile]: plistInfo });
138
138
  }
139
139
  // now build the package
140
140
  const args = [
@@ -144,19 +144,19 @@ class PkgTarget extends core_1.Target {
144
144
  "--component-plist",
145
145
  propertyListOutputFile,
146
146
  ];
147
- builder_util_1.use(this.options.installLocation || "/Applications", it => args.push("--install-location", it));
147
+ (0, builder_util_1.use)(this.options.installLocation || "/Applications", it => args.push("--install-location", it));
148
148
  if (options.scripts != null) {
149
149
  args.push("--scripts", path.resolve(this.packager.info.buildResourcesDir, options.scripts));
150
150
  }
151
151
  else if (options.scripts !== null) {
152
152
  const dir = path.join(this.packager.info.buildResourcesDir, "pkg-scripts");
153
- const stat = await fs_1.statOrNull(dir);
153
+ const stat = await (0, fs_1.statOrNull)(dir);
154
154
  if (stat != null && stat.isDirectory()) {
155
155
  args.push("--scripts", dir);
156
156
  }
157
157
  }
158
158
  args.push(packageOutputFile);
159
- await builder_util_1.exec("pkgbuild", args);
159
+ await (0, builder_util_1.exec)("pkgbuild", args);
160
160
  }
161
161
  }
162
162
  exports.PkgTarget = PkgTarget;
@@ -1 +1 @@
1
- {"version":3,"file":"pkg.js","sourceRoot":"","sources":["../../src/targets/pkg.ts"],"names":[],"mappings":";;;AAAA,+CAAqD;AACrD,4CAAgD;AAEhD,mDAA2F;AAC3F,6CAA4D;AAC5D,0CAAyD;AACzD,6BAA4B;AAC5B,wCAAqD;AACrD,yDAAgE;AAChE,kCAAgC;AAGhC,MAAM,QAAQ,GAAG,wBAAwB,CAAA;AAEzC,kEAAkE;AAClE,wEAAwE;AACxE,8FAA8F;AAC9F,0FAA0F;AAC1F,MAAa,SAAU,SAAQ,aAAM;IAQnC,YAA6B,QAAqB,EAAW,MAAc;QACzE,KAAK,CAAC,KAAK,CAAC,CAAA;QADe,aAAQ,GAAR,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,CAAC,iBAAiB,CAAC,CAAA;QAE5B,MAAM,mBAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IAC9B,CAAC;CACF;AAhLD,8BAgLC;AAED,SAAgB,uBAAuB,CAAC,QAAyB,EAAE,QAAmC;IACpG,MAAM,IAAI,GAAkB,EAAE,CAAA;IAC9B,IAAI,QAAQ,IAAI,IAAI,EAAE;QACpB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;QAClC,IAAI,QAAQ,IAAI,IAAI,EAAE;YACpB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;SAClC;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AATD,0DASC","sourcesContent":["import { Arch, debug, exec, use } from \"builder-util\"\nimport { statOrNull } from \"builder-util/out/fs\"\nimport { PkgOptions } from \"../options/pkgOptions\"\nimport { executeAppBuilderAndWriteJson, executeAppBuilderAsJson } from \"../util/appBuilder\"\nimport { getNotLocalizedLicenseFile } from \"../util/license\"\nimport { readFile, unlink, writeFile } from \"fs/promises\"\nimport * as path from \"path\"\nimport { filterCFBundleIdentifier } from \"../appInfo\"\nimport { findIdentity, Identity } from \"../codeSign/macCodeSign\"\nimport { Target } from \"../core\"\nimport MacPackager from \"../macPackager\"\n\nconst certType = \"Developer ID Installer\"\n\n// http://www.shanekirk.com/2013/10/creating-flat-packages-in-osx/\n// to use --scripts, we must build .app bundle separately using pkgbuild\n// productbuild --scripts doesn't work (because scripts in this case not added to our package)\n// https://github.com/electron-userland/electron-osx-sign/issues/96#issuecomment-274986942\nexport class PkgTarget extends Target {\n readonly options: PkgOptions = {\n allowAnywhere: true,\n allowCurrentUserHome: true,\n allowRootDirectory: true,\n ...this.packager.config.pkg,\n }\n\n constructor(private readonly packager: MacPackager, readonly outDir: string) {\n super(\"pkg\")\n }\n\n async build(appPath: string, arch: Arch): Promise<any> {\n const packager = this.packager\n const options = this.options\n const appInfo = packager.appInfo\n\n // pkg doesn't like not ASCII symbols (Could not open package to list files: /Volumes/test/t-gIjdGK/test-project-0/dist/Test App ßW-1.1.0.pkg)\n const artifactName = packager.expandArtifactNamePattern(options, \"pkg\", arch)\n const artifactPath = path.join(this.outDir, artifactName)\n\n await packager.info.callArtifactBuildStarted({\n targetPresentableName: \"pkg\",\n file: artifactPath,\n arch,\n })\n\n const keychainFile = (await packager.codeSigningInfo.value).keychainFile\n\n const appOutDir = this.outDir\n // https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html\n const distInfoFile = path.join(appOutDir, \"distribution.xml\")\n\n const innerPackageFile = path.join(appOutDir, `${filterCFBundleIdentifier(appInfo.id)}.pkg`)\n const componentPropertyListFile = path.join(appOutDir, `${filterCFBundleIdentifier(appInfo.id)}.plist`)\n const identity = (\n await Promise.all([\n findIdentity(certType, options.identity || packager.platformSpecificBuildOptions.identity, keychainFile),\n this.customizeDistributionConfiguration(distInfoFile, appPath),\n this.buildComponentPackage(appPath, componentPropertyListFile, innerPackageFile),\n ])\n )[0]\n\n if (identity == null && packager.forceCodeSigning) {\n throw new Error(`Cannot find valid \"${certType}\" to sign standalone installer, please see https://electron.build/code-signing`)\n }\n\n const args = prepareProductBuildArgs(identity, keychainFile)\n args.push(\"--distribution\", distInfoFile)\n args.push(artifactPath)\n use(options.productbuild, it => args.push(...(it as any)))\n await exec(\"productbuild\", args, {\n cwd: appOutDir,\n })\n await Promise.all([unlink(innerPackageFile), unlink(distInfoFile)])\n\n await packager.dispatchArtifactCreated(artifactPath, this, arch, packager.computeSafeArtifactName(artifactName, \"pkg\", arch))\n }\n\n private async customizeDistributionConfiguration(distInfoFile: string, appPath: string) {\n await exec(\"productbuild\", [\"--synthesize\", \"--component\", appPath, distInfoFile], {\n cwd: this.outDir,\n })\n\n const options = this.options\n let distInfo = await readFile(distInfoFile, \"utf-8\")\n\n if (options.mustClose != null && options.mustClose.length !== 0) {\n const startContent = ` <pkg-ref id=\"${this.packager.appInfo.id}\">\\n <must-close>\\n`\n const endContent = \" </must-close>\\n </pkg-ref>\\n</installer-gui-script>\"\n let mustCloseContent = \"\"\n options.mustClose.forEach(appId => {\n mustCloseContent += ` <app id=\"${appId}\"/>\\n`\n })\n distInfo = distInfo.replace(\"</installer-gui-script>\", `${startContent}${mustCloseContent}${endContent}`)\n }\n\n const insertIndex = distInfo.lastIndexOf(\"</installer-gui-script>\")\n distInfo =\n distInfo.substring(0, insertIndex) +\n ` <domains enable_anywhere=\"${options.allowAnywhere}\" enable_currentUserHome=\"${options.allowCurrentUserHome}\" enable_localSystem=\"${options.allowRootDirectory}\" />\\n` +\n distInfo.substring(insertIndex)\n\n if (options.background != null) {\n const background = await this.packager.getResource(options.background.file)\n if (background != null) {\n const alignment = options.background.alignment || \"center\"\n // noinspection SpellCheckingInspection\n const scaling = options.background.scaling || \"tofit\"\n distInfo = distInfo.substring(0, insertIndex) + ` <background file=\"${background}\" alignment=\"${alignment}\" scaling=\"${scaling}\"/>\\n` + distInfo.substring(insertIndex)\n distInfo =\n distInfo.substring(0, insertIndex) + ` <background-darkAqua file=\"${background}\" alignment=\"${alignment}\" scaling=\"${scaling}\"/>\\n` + distInfo.substring(insertIndex)\n }\n }\n\n const welcome = await this.packager.getResource(options.welcome)\n if (welcome != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <welcome file=\"${welcome}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n const license = await getNotLocalizedLicenseFile(options.license, this.packager)\n if (license != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <license file=\"${license}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n const conclusion = await this.packager.getResource(options.conclusion)\n if (conclusion != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <conclusion file=\"${conclusion}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n debug(distInfo)\n await writeFile(distInfoFile, distInfo)\n }\n\n private async buildComponentPackage(appPath: string, propertyListOutputFile: string, packageOutputFile: string) {\n const options = this.options\n const rootPath = path.dirname(appPath)\n\n // first produce a component plist template\n await exec(\"pkgbuild\", [\"--analyze\", \"--root\", rootPath, propertyListOutputFile])\n\n // process the template plist\n const plistInfo = (await executeAppBuilderAsJson<Array<any>>([\"decode-plist\", \"-f\", propertyListOutputFile]))[0].filter(\n (it: any) => it.RootRelativeBundlePath !== \"Electron.dSYM\"\n )\n if (plistInfo.length > 0) {\n const packageInfo = plistInfo[0]\n\n // ChildBundles lists all of electron binaries within the .app.\n // There is no particular reason for removing that key, except to be as close as possible to\n // the PackageInfo generated by previous versions of electron-builder.\n delete packageInfo.ChildBundles\n\n if (options.isRelocatable != null) {\n packageInfo.BundleIsRelocatable = options.isRelocatable\n }\n\n if (options.isVersionChecked != null) {\n packageInfo.BundleIsVersionChecked = options.isVersionChecked\n }\n\n if (options.hasStrictIdentifier != null) {\n packageInfo.BundleHasStrictIdentifier = options.hasStrictIdentifier\n }\n\n if (options.overwriteAction != null) {\n packageInfo.BundleOverwriteAction = options.overwriteAction\n }\n\n await executeAppBuilderAndWriteJson([\"encode-plist\"], { [propertyListOutputFile]: plistInfo })\n }\n\n // now build the package\n const args = [\n \"--root\",\n rootPath,\n // \"--identifier\", this.packager.appInfo.id,\n \"--component-plist\",\n propertyListOutputFile,\n ]\n\n use(this.options.installLocation || \"/Applications\", it => args.push(\"--install-location\", it))\n if (options.scripts != null) {\n args.push(\"--scripts\", path.resolve(this.packager.info.buildResourcesDir, options.scripts))\n } else if (options.scripts !== null) {\n const dir = path.join(this.packager.info.buildResourcesDir, \"pkg-scripts\")\n const stat = await statOrNull(dir)\n if (stat != null && stat.isDirectory()) {\n args.push(\"--scripts\", dir)\n }\n }\n\n args.push(packageOutputFile)\n\n await exec(\"pkgbuild\", args)\n }\n}\n\nexport function prepareProductBuildArgs(identity: Identity | null, keychain: string | null | undefined): Array<string> {\n const args: Array<string> = []\n if (identity != null) {\n args.push(\"--sign\", identity.hash)\n if (keychain != null) {\n args.push(\"--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I,EAAE;YAC3B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;SAC5F;aAAM,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,EAAE;YACnC,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAA;YAC1E,MAAM,IAAI,GAAG,MAAM,IAAA,eAAU,EAAC,GAAG,CAAC,CAAA;YAClC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;gBACtC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;aAC5B;SACF;QAED,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;QAE5B,MAAM,IAAA,mBAAI,EAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IAC9B,CAAC;CACF;AAhLD,8BAgLC;AAED,SAAgB,uBAAuB,CAAC,QAAyB,EAAE,QAAmC;IACpG,MAAM,IAAI,GAAkB,EAAE,CAAA;IAC9B,IAAI,QAAQ,IAAI,IAAI,EAAE;QACpB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;QAClC,IAAI,QAAQ,IAAI,IAAI,EAAE;YACpB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;SAClC;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AATD,0DASC","sourcesContent":["import { Arch, debug, exec, use } from \"builder-util\"\nimport { statOrNull } from \"builder-util/out/fs\"\nimport { PkgOptions } from \"../options/pkgOptions\"\nimport { executeAppBuilderAndWriteJson, executeAppBuilderAsJson } from \"../util/appBuilder\"\nimport { getNotLocalizedLicenseFile } from \"../util/license\"\nimport { readFile, unlink, writeFile } from \"fs/promises\"\nimport * as path from \"path\"\nimport { filterCFBundleIdentifier } from \"../appInfo\"\nimport { findIdentity, Identity } from \"../codeSign/macCodeSign\"\nimport { Target } from \"../core\"\nimport MacPackager from \"../macPackager\"\n\nconst certType = \"Developer ID Installer\"\n\n// http://www.shanekirk.com/2013/10/creating-flat-packages-in-osx/\n// to use --scripts, we must build .app bundle separately using pkgbuild\n// productbuild --scripts doesn't work (because scripts in this case not added to our package)\n// https://github.com/electron-userland/electron-osx-sign/issues/96#issuecomment-274986942\nexport class PkgTarget extends Target {\n readonly options: PkgOptions = {\n allowAnywhere: true,\n allowCurrentUserHome: true,\n allowRootDirectory: true,\n ...this.packager.config.pkg,\n }\n\n constructor(private readonly packager: MacPackager, readonly outDir: string) {\n super(\"pkg\")\n }\n\n async build(appPath: string, arch: Arch): Promise<any> {\n const packager = this.packager\n const options = this.options\n const appInfo = packager.appInfo\n\n // pkg doesn't like not ASCII symbols (Could not open package to list files: /Volumes/test/t-gIjdGK/test-project-0/dist/Test App ßW-1.1.0.pkg)\n const artifactName = packager.expandArtifactNamePattern(options, \"pkg\", arch)\n const artifactPath = path.join(this.outDir, artifactName)\n\n await packager.info.callArtifactBuildStarted({\n targetPresentableName: \"pkg\",\n file: artifactPath,\n arch,\n })\n\n const keychainFile = (await packager.codeSigningInfo.value).keychainFile\n\n const appOutDir = this.outDir\n // https://developer.apple.com/library/content/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html\n const distInfoFile = path.join(appOutDir, \"distribution.xml\")\n\n const innerPackageFile = path.join(appOutDir, `${filterCFBundleIdentifier(appInfo.id)}.pkg`)\n const componentPropertyListFile = path.join(appOutDir, `${filterCFBundleIdentifier(appInfo.id)}.plist`)\n const identity = (\n await Promise.all([\n findIdentity(certType, options.identity || packager.platformSpecificBuildOptions.identity, keychainFile),\n this.customizeDistributionConfiguration(distInfoFile, appPath),\n this.buildComponentPackage(appPath, componentPropertyListFile, innerPackageFile),\n ])\n )[0]\n\n if (identity == null && packager.forceCodeSigning) {\n throw new Error(`Cannot find valid \"${certType}\" to sign standalone installer, please see https://electron.build/code-signing`)\n }\n\n const args = prepareProductBuildArgs(identity, keychainFile)\n args.push(\"--distribution\", distInfoFile)\n args.push(artifactPath)\n use(options.productbuild, it => args.push(...(it as any)))\n await exec(\"productbuild\", args, {\n cwd: appOutDir,\n })\n await Promise.all([unlink(innerPackageFile), unlink(distInfoFile)])\n\n await packager.dispatchArtifactCreated(artifactPath, this, arch, packager.computeSafeArtifactName(artifactName, \"pkg\", arch))\n }\n\n private async customizeDistributionConfiguration(distInfoFile: string, appPath: string) {\n await exec(\"productbuild\", [\"--synthesize\", \"--component\", appPath, distInfoFile], {\n cwd: this.outDir,\n })\n\n const options = this.options\n let distInfo = await readFile(distInfoFile, \"utf-8\")\n\n if (options.mustClose != null && options.mustClose.length !== 0) {\n const startContent = ` <pkg-ref id=\"${this.packager.appInfo.id}\">\\n <must-close>\\n`\n const endContent = \" </must-close>\\n </pkg-ref>\\n</installer-gui-script>\"\n let mustCloseContent = \"\"\n options.mustClose.forEach(appId => {\n mustCloseContent += ` <app id=\"${appId}\"/>\\n`\n })\n distInfo = distInfo.replace(\"</installer-gui-script>\", `${startContent}${mustCloseContent}${endContent}`)\n }\n\n const insertIndex = distInfo.lastIndexOf(\"</installer-gui-script>\")\n distInfo =\n distInfo.substring(0, insertIndex) +\n ` <domains enable_anywhere=\"${options.allowAnywhere}\" enable_currentUserHome=\"${options.allowCurrentUserHome}\" enable_localSystem=\"${options.allowRootDirectory}\" />\\n` +\n distInfo.substring(insertIndex)\n\n if (options.background != null) {\n const background = await this.packager.getResource(options.background.file)\n if (background != null) {\n const alignment = options.background.alignment || \"center\"\n // noinspection SpellCheckingInspection\n const scaling = options.background.scaling || \"tofit\"\n distInfo = distInfo.substring(0, insertIndex) + ` <background file=\"${background}\" alignment=\"${alignment}\" scaling=\"${scaling}\"/>\\n` + distInfo.substring(insertIndex)\n distInfo =\n distInfo.substring(0, insertIndex) + ` <background-darkAqua file=\"${background}\" alignment=\"${alignment}\" scaling=\"${scaling}\"/>\\n` + distInfo.substring(insertIndex)\n }\n }\n\n const welcome = await this.packager.getResource(options.welcome)\n if (welcome != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <welcome file=\"${welcome}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n const license = await getNotLocalizedLicenseFile(options.license, this.packager)\n if (license != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <license file=\"${license}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n const conclusion = await this.packager.getResource(options.conclusion)\n if (conclusion != null) {\n distInfo = distInfo.substring(0, insertIndex) + ` <conclusion file=\"${conclusion}\"/>\\n` + distInfo.substring(insertIndex)\n }\n\n debug(distInfo)\n await writeFile(distInfoFile, distInfo)\n }\n\n private async buildComponentPackage(appPath: string, propertyListOutputFile: string, packageOutputFile: string) {\n const options = this.options\n const rootPath = path.dirname(appPath)\n\n // first produce a component plist template\n await exec(\"pkgbuild\", [\"--analyze\", \"--root\", rootPath, propertyListOutputFile])\n\n // process the template plist\n const plistInfo = (await executeAppBuilderAsJson<Array<any>>([\"decode-plist\", \"-f\", propertyListOutputFile]))[0].filter(\n (it: any) => it.RootRelativeBundlePath !== \"Electron.dSYM\"\n )\n if (plistInfo.length > 0) {\n const packageInfo = plistInfo[0]\n\n // ChildBundles lists all of electron binaries within the .app.\n // There is no particular reason for removing that key, except to be as close as possible to\n // the PackageInfo generated by previous versions of electron-builder.\n delete packageInfo.ChildBundles\n\n if (options.isRelocatable != null) {\n packageInfo.BundleIsRelocatable = options.isRelocatable\n }\n\n if (options.isVersionChecked != null) {\n packageInfo.BundleIsVersionChecked = options.isVersionChecked\n }\n\n if (options.hasStrictIdentifier != null) {\n packageInfo.BundleHasStrictIdentifier = options.hasStrictIdentifier\n }\n\n if (options.overwriteAction != null) {\n packageInfo.BundleOverwriteAction = options.overwriteAction\n }\n\n await executeAppBuilderAndWriteJson([\"encode-plist\"], { [propertyListOutputFile]: plistInfo })\n }\n\n // now build the package\n const args = [\n \"--root\",\n rootPath,\n // \"--identifier\", this.packager.appInfo.id,\n \"--component-plist\",\n propertyListOutputFile,\n ]\n\n use(this.options.installLocation || \"/Applications\", it => args.push(\"--install-location\", it))\n if (options.scripts != null) {\n args.push(\"--scripts\", path.resolve(this.packager.info.buildResourcesDir, options.scripts))\n } else if (options.scripts !== null) {\n const dir = path.join(this.packager.info.buildResourcesDir, \"pkg-scripts\")\n const stat = await statOrNull(dir)\n if (stat != null && stat.isDirectory()) {\n args.push(\"--scripts\", dir)\n }\n }\n\n args.push(packageOutputFile)\n\n await exec(\"pkgbuild\", args)\n }\n}\n\nexport function prepareProductBuildArgs(identity: Identity | null, keychain: string | null | undefined): Array<string> {\n const args: Array<string> = []\n if (identity != null) {\n args.push(\"--sign\", identity.hash)\n if (keychain != null) {\n args.push(\"--keychain\", keychain)\n }\n }\n return args\n}\n"]}
@@ -20,7 +20,7 @@ class SnapTarget extends core_1.Target {
20
20
  this.isUseTemplateApp = false;
21
21
  }
22
22
  replaceDefault(inList, defaultList) {
23
- const result = builder_util_1.replaceDefault(inList, defaultList);
23
+ const result = (0, builder_util_1.replaceDefault)(inList, defaultList);
24
24
  if (result !== defaultList) {
25
25
  this.isUseTemplateApp = false;
26
26
  }
@@ -39,7 +39,7 @@ class SnapTarget extends core_1.Target {
39
39
  const plugs = normalizePlugConfiguration(this.options.plugs);
40
40
  const plugNames = this.replaceDefault(plugs == null ? null : Object.getOwnPropertyNames(plugs), defaultPlugs);
41
41
  const slots = normalizePlugConfiguration(this.options.slots);
42
- const buildPackages = builder_util_runtime_1.asArray(options.buildPackages);
42
+ const buildPackages = (0, builder_util_runtime_1.asArray)(options.buildPackages);
43
43
  const defaultStagePackages = getDefaultStagePackages();
44
44
  const stagePackages = this.replaceDefault(options.stagePackages, defaultStagePackages);
45
45
  this.isUseTemplateApp =
@@ -52,7 +52,7 @@ class SnapTarget extends core_1.Target {
52
52
  plugs: plugNames,
53
53
  adapter: "none",
54
54
  };
55
- const snap = js_yaml_1.load(await fs_extra_1.readFile(path.join(pathManager_1.getTemplatePath("snap"), "snapcraft.yaml"), "utf-8"));
55
+ const snap = (0, js_yaml_1.load)(await (0, fs_extra_1.readFile)(path.join((0, pathManager_1.getTemplatePath)("snap"), "snapcraft.yaml"), "utf-8"));
56
56
  if (this.isUseTemplateApp) {
57
57
  delete appDescriptor.adapter;
58
58
  }
@@ -81,14 +81,14 @@ class SnapTarget extends core_1.Target {
81
81
  snap.slots[slotName] = slotOptions;
82
82
  }
83
83
  }
84
- builder_util_1.deepAssign(snap, {
84
+ (0, builder_util_1.deepAssign)(snap, {
85
85
  name: snapName,
86
86
  version: appInfo.version,
87
87
  title: options.title || appInfo.productName,
88
88
  summary: options.summary || appInfo.productName,
89
89
  compression: options.compression,
90
90
  description: this.helper.getDescription(options),
91
- architectures: [builder_util_1.toLinuxArchString(arch, "snap")],
91
+ architectures: [(0, builder_util_1.toLinuxArchString)(arch, "snap")],
92
92
  apps: {
93
93
  [snapName]: appDescriptor,
94
94
  },
@@ -136,11 +136,12 @@ class SnapTarget extends core_1.Target {
136
136
  snap.parts.app.after = options.after;
137
137
  }
138
138
  if (options.assumes != null) {
139
- snap.assumes = builder_util_runtime_1.asArray(options.assumes);
139
+ snap.assumes = (0, builder_util_runtime_1.asArray)(options.assumes);
140
140
  }
141
141
  return snap;
142
142
  }
143
143
  async build(appOutDir, arch) {
144
+ var _a;
144
145
  const packager = this.packager;
145
146
  const options = this.options;
146
147
  // tslint:disable-next-line:no-invalid-template-strings
@@ -152,8 +153,8 @@ class SnapTarget extends core_1.Target {
152
153
  arch,
153
154
  });
154
155
  const snap = await this.createDescriptor(arch);
155
- const stageDir = await targetUtil_1.createStageDirPath(this, packager, arch);
156
- const snapArch = builder_util_1.toLinuxArchString(arch, "snap");
156
+ const stageDir = await (0, targetUtil_1.createStageDirPath)(this, packager, arch);
157
+ const snapArch = (0, builder_util_1.toLinuxArchString)(arch, "snap");
157
158
  const args = ["snap", "--app", appOutDir, "--stage", stageDir, "--arch", snapArch, "--output", artifactPath, "--executable", this.packager.executableName];
158
159
  await this.helper.icons;
159
160
  if (this.helper.maxIconPath != null) {
@@ -169,12 +170,19 @@ class SnapTarget extends core_1.Target {
169
170
  // tslint:disable:no-invalid-template-strings
170
171
  Icon: "${SNAP}/meta/gui/icon.png",
171
172
  });
173
+ const extraAppArgs = (_a = options.executableArgs) !== null && _a !== void 0 ? _a : [];
172
174
  if (this.isElectronVersionGreaterOrEqualThan("5.0.0") && !isBrowserSandboxAllowed(snap)) {
173
- args.push("--extraAppArgs=--no-sandbox");
175
+ const noSandboxArg = "--no-sandbox";
176
+ if (!extraAppArgs.includes(noSandboxArg)) {
177
+ extraAppArgs.push(noSandboxArg);
178
+ }
174
179
  if (this.isUseTemplateApp) {
175
180
  args.push("--exclude", "chrome-sandbox");
176
181
  }
177
182
  }
183
+ if (extraAppArgs.length > 0) {
184
+ args.push("--extraAppArgs=" + extraAppArgs.join(" "));
185
+ }
178
186
  if (snap.compression != null) {
179
187
  args.push("--compression", snap.compression);
180
188
  }
@@ -188,7 +196,7 @@ class SnapTarget extends core_1.Target {
188
196
  if (packager.packagerOptions.effectiveOptionComputed != null && (await packager.packagerOptions.effectiveOptionComputed({ snap, desktopFile, args }))) {
189
197
  return;
190
198
  }
191
- await fs_extra_1.outputFile(path.join(snapMetaDir, this.isUseTemplateApp ? "snap.yaml" : "snapcraft.yaml"), builder_util_1.serializeToYaml(snap));
199
+ await (0, fs_extra_1.outputFile)(path.join(snapMetaDir, this.isUseTemplateApp ? "snap.yaml" : "snapcraft.yaml"), (0, builder_util_1.serializeToYaml)(snap));
192
200
  const hooksDir = await packager.getResource(options.hooks, "snap-hooks");
193
201
  if (hooksDir != null) {
194
202
  args.push("--hooks", hooksDir);
@@ -196,7 +204,7 @@ class SnapTarget extends core_1.Target {
196
204
  if (this.isUseTemplateApp) {
197
205
  args.push("--template-url", `electron4:${snapArch}`);
198
206
  }
199
- await builder_util_1.executeAppBuilder(args);
207
+ await (0, builder_util_1.executeAppBuilder)(args);
200
208
  await packager.info.callArtifactBuildCompleted({
201
209
  file: artifactPath,
202
210
  safeArtifactName: packager.computeSafeArtifactName(artifactName, "snap", arch, false),
@@ -1 +1 @@
1
- {"version":3,"file":"snap.js","sourceRoot":"","sources":["../../src/targets/snap.ts"],"names":[],"mappings":";;AAAA,+CAAyK;AACzK,+DAA8C;AAC9C,uCAA+C;AAC/C,qCAA8B;AAC9B,6BAA4B;AAC5B,iCAAgC;AAChC,kCAAgC;AAGhC,qDAAqD;AAErD,6CAAiD;AAEjD,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAA;AAE3K,MAAqB,UAAW,SAAQ,aAAM;IAK5C,YAAY,IAAY,EAAmB,QAAuB,EAAmB,MAAyB,EAAW,MAAc;QACrI,KAAK,CAAC,IAAI,CAAC,CAAA;QAD8B,aAAQ,GAAR,QAAQ,CAAe;QAAmB,WAAM,GAAN,MAAM,CAAmB;QAAW,WAAM,GAAN,MAAM,CAAQ;QAJ9H,YAAO,GAAgB,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,4BAA4B,EAAE,GAAI,IAAI,CAAC,QAAQ,CAAC,MAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;QAEvH,qBAAgB,GAAG,KAAK,CAAA;IAI/B,CAAC;IAEO,cAAc,CAAC,MAAwC,EAAE,WAA0B;QACzF,MAAM,MAAM,GAAG,6BAAe,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QACnD,IAAI,MAAM,KAAK,WAAW,EAAE;YAC1B,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAA;SAC9B;QACD,OAAO,MAAM,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OAAO,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,oBAAoB,EAAE,eAAe,CAAC,CAAA;AAClF,CAAC","sourcesContent":["import { Arch, deepAssign, executeAppBuilder, InvalidConfigurationError, log, replaceDefault as _replaceDefault, serializeToYaml, toLinuxArchString } from \"builder-util\"\nimport { asArray } from \"builder-util-runtime\"\nimport { outputFile, readFile } from \"fs-extra\"\nimport { load } from \"js-yaml\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport { Target } from \"../core\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { PlugDescriptor, SnapOptions } from \"../options/SnapOptions\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { LinuxTargetHelper } from \"./LinuxTargetHelper\"\nimport { createStageDirPath } from \"./targetUtil\"\n\nconst defaultPlugs = [\"desktop\", \"desktop-legacy\", \"home\", \"x11\", \"wayland\", \"unity7\", \"browser-support\", \"network\", \"gsettings\", \"audio-playback\", \"pulseaudio\", \"opengl\"]\n\nexport default class SnapTarget extends Target {\n readonly options: SnapOptions = { ...this.packager.platformSpecificBuildOptions, ...(this.packager.config as any)[this.name] }\n\n public isUseTemplateApp = false\n\n constructor(name: string, private readonly packager: LinuxPackager, private readonly helper: LinuxTargetHelper, readonly outDir: string) {\n super(name)\n }\n\n private replaceDefault(inList: Array<string> | null | undefined, defaultList: Array<string>) {\n const result = _replaceDefault(inList, defaultList)\n if (result !== defaultList) {\n this.isUseTemplateApp = false\n }\n return result\n }\n\n private async createDescriptor(arch: Arch): Promise<any> {\n if (!this.isElectronVersionGreaterOrEqualThan(\"4.0.0\")) {\n if (!this.isElectronVersionGreaterOrEqualThan(\"2.0.0-beta.1\")) {\n throw new InvalidConfigurationError(\"Electron 2 and higher is required to build Snap\")\n }\n\n log.warn(\"Electron 4 and higher is highly recommended for Snap\")\n }\n\n const appInfo = this.packager.appInfo\n const snapName = this.packager.executableName.toLowerCase()\n const options = this.options\n\n const plugs = normalizePlugConfiguration(this.options.plugs)\n\n const plugNames = this.replaceDefault(plugs == null ? null : Object.getOwnPropertyNames(plugs), defaultPlugs)\n\n const slots = normalizePlugConfiguration(this.options.slots)\n\n const buildPackages = asArray(options.buildPackages)\n const defaultStagePackages = getDefaultStagePackages()\n const stagePackages = this.replaceDefault(options.stagePackages, defaultStagePackages)\n\n this.isUseTemplateApp =\n this.options.useTemplateApp !== false &&\n (arch === Arch.x64 || arch === Arch.armv7l) &&\n buildPackages.length === 0 &&\n isArrayEqualRegardlessOfSort(stagePackages, defaultStagePackages)\n\n const appDescriptor: any = {\n command: \"command.sh\",\n plugs: plugNames,\n adapter: \"none\",\n }\n\n const snap: any = load(await readFile(path.join(getTemplatePath(\"snap\"), \"snapcraft.yaml\"), \"utf-8\"))\n if (this.isUseTemplateApp) {\n delete appDescriptor.adapter\n }\n if (options.grade != null) {\n snap.grade = options.grade\n }\n if (options.confinement != null) {\n snap.confinement = options.confinement\n }\n if (options.appPartStage != null) {\n snap.parts.app.stage = options.appPartStage\n }\n if (options.layout != null) {\n snap.layout = options.layout\n }\n if (slots != null) {\n appDescriptor.slots = Object.getOwnPropertyNames(slots)\n for (const slotName of appDescriptor.slots) {\n const slotOptions = slots[slotName]\n if (slotOptions == null) {\n continue\n }\n if (!snap.slots) {\n snap.slots = {}\n }\n snap.slots[slotName] = slotOptions\n }\n }\n\n deepAssign(snap, {\n name: snapName,\n version: appInfo.version,\n title: options.title || appInfo.productName,\n summary: options.summary || appInfo.productName,\n compression: options.compression,\n description: this.helper.getDescription(options),\n architectures: [toLinuxArchString(arch, \"snap\")],\n apps: {\n [snapName]: appDescriptor,\n },\n parts: {\n app: {\n \"stage-packages\": stagePackages,\n },\n },\n })\n\n if (options.autoStart) {\n appDescriptor.autostart = `${snap.name}.desktop`\n }\n\n if (options.confinement === \"classic\") {\n delete appDescriptor.plugs\n delete snap.plugs\n } else {\n const archTriplet = archNameToTriplet(arch)\n appDescriptor.environment = {\n DISABLE_WAYLAND: options.allowNativeWayland ? \"\" : \"1\",\n PATH: \"$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH\",\n SNAP_DESKTOP_RUNTIME: \"$SNAP/gnome-platform\",\n LD_LIBRARY_PATH: [\n \"$SNAP_LIBRARY_PATH\",\n \"$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/\" + archTriplet + \":$SNAP/usr/lib/\" + archTriplet,\n \"$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib\",\n \"$SNAP/lib/\" + archTriplet + \":$SNAP/usr/lib/\" + archTriplet,\n ].join(\":\"),\n ...options.environment,\n }\n\n if (plugs != null) {\n for (const plugName of plugNames) {\n const plugOptions = plugs[plugName]\n if (plugOptions == null) {\n continue\n }\n\n snap.plugs[plugName] = plugOptions\n }\n }\n }\n\n if (buildPackages.length > 0) {\n snap.parts.app[\"build-packages\"] = buildPackages\n }\n if (options.after != null) {\n snap.parts.app.after = options.after\n }\n\n if (options.assumes != null) {\n snap.assumes = asArray(options.assumes)\n }\n\n return snap\n }\n\n async build(appOutDir: string, arch: Arch): Promise<any> {\n const packager = this.packager\n const options = this.options\n // tslint:disable-next-line:no-invalid-template-strings\n const artifactName = packager.expandArtifactNamePattern(this.options, \"snap\", arch, \"${name}_${version}_${arch}.${ext}\", false)\n const artifactPath = path.join(this.outDir, artifactName)\n await packager.info.callArtifactBuildStarted({\n targetPresentableName: \"snap\",\n file: artifactPath,\n arch,\n })\n\n const snap = await this.createDescriptor(arch)\n\n const stageDir = await createStageDirPath(this, packager, arch)\n const snapArch = toLinuxArchString(arch, \"snap\")\n const args = [\"snap\", \"--app\", appOutDir, \"--stage\", stageDir, \"--arch\", snapArch, \"--output\", artifactPath, \"--executable\", this.packager.executableName]\n\n await this.helper.icons\n if (this.helper.maxIconPath != null) {\n if (!this.isUseTemplateApp) {\n snap.icon = \"snap/gui/icon.png\"\n }\n args.push(\"--icon\", this.helper.maxIconPath)\n }\n\n // snapcraft.yaml inside a snap directory\n const snapMetaDir = path.join(stageDir, this.isUseTemplateApp ? \"meta\" : \"snap\")\n const desktopFile = path.join(snapMetaDir, \"gui\", `${snap.name}.desktop`)\n await this.helper.writeDesktopEntry(this.options, packager.executableName + \" %U\", desktopFile, {\n // tslint:disable:no-invalid-template-strings\n Icon: \"${SNAP}/meta/gui/icon.png\",\n })\n\n if (this.isElectronVersionGreaterOrEqualThan(\"5.0.0\") && !isBrowserSandboxAllowed(snap)) {\n args.push(\"--extraAppArgs=--no-sandbox\")\n if (this.isUseTemplateApp) {\n args.push(\"--exclude\", \"chrome-sandbox\")\n }\n }\n\n if (snap.compression != null) {\n args.push(\"--compression\", snap.compression)\n }\n\n if (this.isUseTemplateApp) {\n // remove fields that are valid in snapcraft.yaml, but not snap.yaml\n const fieldsToStrip = [\"compression\", \"contact\", \"donation\", \"issues\", \"parts\", \"source-code\", \"website\"]\n for (const field of fieldsToStrip) {\n delete snap[field]\n }\n }\n\n if (packager.packagerOptions.effectiveOptionComputed != null && (await packager.packagerOptions.effectiveOptionComputed({ snap, desktopFile, args }))) {\n return\n }\n\n await outputFile(path.join(snapMetaDir, this.isUseTemplateApp ? \"snap.yaml\" : \"snapcraft.yaml\"), serializeToYaml(snap))\n\n const hooksDir = await packager.getResource(options.hooks, \"snap-hooks\")\n if (hooksDir != null) {\n args.push(\"--hooks\", hooksDir)\n }\n\n if (this.isUseTemplateApp) {\n args.push(\"--template-url\", `electron4:${snapArch}`)\n }\n\n await executeAppBuilder(args)\n\n await packager.info.callArtifactBuildCompleted({\n file: artifactPath,\n safeArtifactName: packager.computeSafeArtifactName(artifactName, \"snap\", arch, false),\n target: this,\n arch,\n packager,\n publishConfig: options.publish == null ? { provider: \"snapStore\" } : null,\n })\n }\n\n private isElectronVersionGreaterOrEqualThan(version: string) {\n return semver.gte(this.packager.config.electronVersion || \"7.0.0\", version)\n }\n}\n\nfunction archNameToTriplet(arch: Arch): string {\n switch (arch) {\n case Arch.x64:\n return \"x86_64-linux-gnu\"\n case Arch.ia32:\n return \"i386-linux-gnu\"\n case Arch.armv7l:\n // noinspection SpellCheckingInspection\n return \"arm-linux-gnueabihf\"\n case Arch.arm64:\n return \"aarch64-linux-gnu\"\n\n default:\n throw new Error(`Unsupported arch ${arch}`)\n }\n}\n\nfunction isArrayEqualRegardlessOfSort(a: Array<string>, b: Array<string>) {\n a = a.slice()\n b = b.slice()\n a.sort()\n b.sort()\n return a.length === b.length && a.every((value, index) => value === b[index])\n}\n\nfunction normalizePlugConfiguration(raw: Array<string | PlugDescriptor> | PlugDescriptor | null | undefined): { [key: string]: { [name: string]: any } | null } | null {\n if (raw == null) {\n return null\n }\n\n const result: any = {}\n for (const item of Array.isArray(raw) ? raw : [raw]) {\n if (typeof item === \"string\") {\n result[item] = null\n } else {\n Object.assign(result, item)\n }\n }\n return result\n}\n\nfunction isBrowserSandboxAllowed(snap: any): boolean {\n if (snap.plugs != null) {\n for (const plugName of Object.keys(snap.plugs)) {\n const plug = snap.plugs[plugName]\n if (plug.interface === \"browser-support\" && plug[\"allow-sandbox\"] === true) {\n return true\n }\n }\n }\n return false\n}\n\nfunction getDefaultStagePackages() {\n // libxss1 - was \"error while loading shared libraries: libXss.so.1\" on Xubuntu 16.04\n // noinspection SpellCheckingInspection\n return [\"libnspr4\", \"libnss3\", \"libxss1\", \"libappindicator3-1\", \"libsecret-1-0\"]\n}\n"]}
1
+ {"version":3,"file":"snap.js","sourceRoot":"","sources":["../../src/targets/snap.ts"],"names":[],"mappings":";;AAAA,+CAAyK;AACzK,+DAA8C;AAC9C,uCAA+C;AAC/C,qCAA8B;AAC9B,6BAA4B;AAC5B,iCAAgC;AAChC,kCAAgC;AAGhC,qDAAqD;AAErD,6CAAiD;AAEjD,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAA;AAE3K,M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K,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;AAC/E,CAAC;AAED,SAAS,0BAA0B,CAAC,GAAuE;IACzG,IAAI,GAAG,IAAI,IAAI,EAAE;QACf,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,MAAM,GAAQ,EAAE,CAAA;IACtB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;QACnD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;SACpB;aAAM;YACL,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;SAC5B;KACF;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,uBAAuB,CAAC,IAAS;IACxC,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE;QACtB,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;YACjC,IAAI,IAAI,CAAC,SAAS,KAAK,iBAAiB,IAAI,IAAI,CAAC,eAAe,CAAC,KAAK,IAAI,EAAE;gBAC1E,OAAO,IAAI,CAAA;aACZ;SACF;KACF;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,uBAAuB;IAC9B,qFAAqF;IACrF,uCAAuC;IACvC,OAAO,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,oBAAoB,EAAE,eAAe,CAAC,CAAA;AAClF,CAAC","sourcesContent":["import { Arch, deepAssign, executeAppBuilder, InvalidConfigurationError, log, replaceDefault as _replaceDefault, serializeToYaml, toLinuxArchString } from \"builder-util\"\nimport { asArray } from \"builder-util-runtime\"\nimport { outputFile, readFile } from \"fs-extra\"\nimport { load } from \"js-yaml\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport { Target } from \"../core\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { PlugDescriptor, SnapOptions } from \"../options/SnapOptions\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { LinuxTargetHelper } from \"./LinuxTargetHelper\"\nimport { createStageDirPath } from \"./targetUtil\"\n\nconst defaultPlugs = [\"desktop\", \"desktop-legacy\", \"home\", \"x11\", \"wayland\", \"unity7\", \"browser-support\", \"network\", \"gsettings\", \"audio-playback\", \"pulseaudio\", \"opengl\"]\n\nexport default class SnapTarget extends Target {\n readonly options: SnapOptions = { ...this.packager.platformSpecificBuildOptions, ...(this.packager.config as any)[this.name] }\n\n public isUseTemplateApp = false\n\n constructor(name: string, private readonly packager: LinuxPackager, private readonly helper: LinuxTargetHelper, readonly outDir: string) {\n super(name)\n }\n\n private replaceDefault(inList: Array<string> | null | undefined, defaultList: Array<string>) {\n const result = _replaceDefault(inList, defaultList)\n if (result !== defaultList) {\n this.isUseTemplateApp = false\n }\n return result\n }\n\n private async createDescriptor(arch: Arch): Promise<any> {\n if (!this.isElectronVersionGreaterOrEqualThan(\"4.0.0\")) {\n if (!this.isElectronVersionGreaterOrEqualThan(\"2.0.0-beta.1\")) {\n throw new InvalidConfigurationError(\"Electron 2 and higher is required to build Snap\")\n }\n\n log.warn(\"Electron 4 and higher is highly recommended for Snap\")\n }\n\n const appInfo = this.packager.appInfo\n const snapName = this.packager.executableName.toLowerCase()\n const options = this.options\n\n const plugs = normalizePlugConfiguration(this.options.plugs)\n\n const plugNames = this.replaceDefault(plugs == null ? null : Object.getOwnPropertyNames(plugs), defaultPlugs)\n\n const slots = normalizePlugConfiguration(this.options.slots)\n\n const buildPackages = asArray(options.buildPackages)\n const defaultStagePackages = getDefaultStagePackages()\n const stagePackages = this.replaceDefault(options.stagePackages, defaultStagePackages)\n\n this.isUseTemplateApp =\n this.options.useTemplateApp !== false &&\n (arch === Arch.x64 || arch === Arch.armv7l) &&\n buildPackages.length === 0 &&\n isArrayEqualRegardlessOfSort(stagePackages, defaultStagePackages)\n\n const appDescriptor: any = {\n command: \"command.sh\",\n plugs: plugNames,\n adapter: \"none\",\n }\n\n const snap: any = load(await readFile(path.join(getTemplatePath(\"snap\"), \"snapcraft.yaml\"), \"utf-8\"))\n if (this.isUseTemplateApp) {\n delete appDescriptor.adapter\n }\n if (options.grade != null) {\n snap.grade = options.grade\n }\n if (options.confinement != null) {\n snap.confinement = options.confinement\n }\n if (options.appPartStage != null) {\n snap.parts.app.stage = options.appPartStage\n }\n if (options.layout != null) {\n snap.layout = options.layout\n }\n if (slots != null) {\n appDescriptor.slots = Object.getOwnPropertyNames(slots)\n for (const slotName of appDescriptor.slots) {\n const slotOptions = slots[slotName]\n if (slotOptions == null) {\n continue\n }\n if (!snap.slots) {\n snap.slots = {}\n }\n snap.slots[slotName] = slotOptions\n }\n }\n\n deepAssign(snap, {\n name: snapName,\n version: appInfo.version,\n title: options.title || appInfo.productName,\n summary: options.summary || appInfo.productName,\n compression: options.compression,\n description: this.helper.getDescription(options),\n architectures: [toLinuxArchString(arch, \"snap\")],\n apps: {\n [snapName]: appDescriptor,\n },\n parts: {\n app: {\n \"stage-packages\": stagePackages,\n },\n },\n })\n\n if (options.autoStart) {\n appDescriptor.autostart = `${snap.name}.desktop`\n }\n\n if (options.confinement === \"classic\") {\n delete appDescriptor.plugs\n delete snap.plugs\n } else {\n const archTriplet = archNameToTriplet(arch)\n appDescriptor.environment = {\n DISABLE_WAYLAND: options.allowNativeWayland ? \"\" : \"1\",\n PATH: \"$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH\",\n SNAP_DESKTOP_RUNTIME: \"$SNAP/gnome-platform\",\n LD_LIBRARY_PATH: [\n \"$SNAP_LIBRARY_PATH\",\n \"$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/\" + archTriplet + \":$SNAP/usr/lib/\" + archTriplet,\n \"$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib\",\n \"$SNAP/lib/\" + archTriplet + \":$SNAP/usr/lib/\" + archTriplet,\n ].join(\":\"),\n ...options.environment,\n }\n\n if (plugs != null) {\n for (const plugName of plugNames) {\n const plugOptions = plugs[plugName]\n if (plugOptions == null) {\n continue\n }\n\n snap.plugs[plugName] = plugOptions\n }\n }\n }\n\n if (buildPackages.length > 0) {\n snap.parts.app[\"build-packages\"] = buildPackages\n }\n if (options.after != null) {\n snap.parts.app.after = options.after\n }\n\n if (options.assumes != null) {\n snap.assumes = asArray(options.assumes)\n }\n\n return snap\n }\n\n async build(appOutDir: string, arch: Arch): Promise<any> {\n const packager = this.packager\n const options = this.options\n // tslint:disable-next-line:no-invalid-template-strings\n const artifactName = packager.expandArtifactNamePattern(this.options, \"snap\", arch, \"${name}_${version}_${arch}.${ext}\", false)\n const artifactPath = path.join(this.outDir, artifactName)\n await packager.info.callArtifactBuildStarted({\n targetPresentableName: \"snap\",\n file: artifactPath,\n arch,\n })\n\n const snap = await this.createDescriptor(arch)\n\n const stageDir = await createStageDirPath(this, packager, arch)\n const snapArch = toLinuxArchString(arch, \"snap\")\n const args = [\"snap\", \"--app\", appOutDir, \"--stage\", stageDir, \"--arch\", snapArch, \"--output\", artifactPath, \"--executable\", this.packager.executableName]\n\n await this.helper.icons\n if (this.helper.maxIconPath != null) {\n if (!this.isUseTemplateApp) {\n snap.icon = \"snap/gui/icon.png\"\n }\n args.push(\"--icon\", this.helper.maxIconPath)\n }\n\n // snapcraft.yaml inside a snap directory\n const snapMetaDir = path.join(stageDir, this.isUseTemplateApp ? \"meta\" : \"snap\")\n const desktopFile = path.join(snapMetaDir, \"gui\", `${snap.name}.desktop`)\n await this.helper.writeDesktopEntry(this.options, packager.executableName + \" %U\", desktopFile, {\n // tslint:disable:no-invalid-template-strings\n Icon: \"${SNAP}/meta/gui/icon.png\",\n })\n\n const extraAppArgs: Array<string> = options.executableArgs ?? []\n if (this.isElectronVersionGreaterOrEqualThan(\"5.0.0\") && !isBrowserSandboxAllowed(snap)) {\n const noSandboxArg = \"--no-sandbox\"\n if (!extraAppArgs.includes(noSandboxArg)) {\n extraAppArgs.push(noSandboxArg)\n }\n if (this.isUseTemplateApp) {\n args.push(\"--exclude\", \"chrome-sandbox\")\n }\n }\n if (extraAppArgs.length > 0) {\n args.push(\"--extraAppArgs=\" + extraAppArgs.join(\" \"))\n }\n\n if (snap.compression != null) {\n args.push(\"--compression\", snap.compression)\n }\n\n if (this.isUseTemplateApp) {\n // remove fields that are valid in snapcraft.yaml, but not snap.yaml\n const fieldsToStrip = [\"compression\", \"contact\", \"donation\", \"issues\", \"parts\", \"source-code\", \"website\"]\n for (const field of fieldsToStrip) {\n delete snap[field]\n }\n }\n\n if (packager.packagerOptions.effectiveOptionComputed != null && (await packager.packagerOptions.effectiveOptionComputed({ snap, desktopFile, args }))) {\n return\n }\n\n await outputFile(path.join(snapMetaDir, this.isUseTemplateApp ? \"snap.yaml\" : \"snapcraft.yaml\"), serializeToYaml(snap))\n\n const hooksDir = await packager.getResource(options.hooks, \"snap-hooks\")\n if (hooksDir != null) {\n args.push(\"--hooks\", hooksDir)\n }\n\n if (this.isUseTemplateApp) {\n args.push(\"--template-url\", `electron4:${snapArch}`)\n }\n\n await executeAppBuilder(args)\n\n await packager.info.callArtifactBuildCompleted({\n file: artifactPath,\n safeArtifactName: packager.computeSafeArtifactName(artifactName, \"snap\", arch, false),\n target: this,\n arch,\n packager,\n publishConfig: options.publish == null ? { provider: \"snapStore\" } : null,\n })\n }\n\n private isElectronVersionGreaterOrEqualThan(version: string) {\n return semver.gte(this.packager.config.electronVersion || \"7.0.0\", version)\n }\n}\n\nfunction archNameToTriplet(arch: Arch): string {\n switch (arch) {\n case Arch.x64:\n return \"x86_64-linux-gnu\"\n case Arch.ia32:\n return \"i386-linux-gnu\"\n case Arch.armv7l:\n // noinspection SpellCheckingInspection\n return \"arm-linux-gnueabihf\"\n case Arch.arm64:\n return \"aarch64-linux-gnu\"\n\n default:\n throw new Error(`Unsupported arch ${arch}`)\n }\n}\n\nfunction isArrayEqualRegardlessOfSort(a: Array<string>, b: Array<string>) {\n a = a.slice()\n b = b.slice()\n a.sort()\n b.sort()\n return a.length === b.length && a.every((value, index) => value === b[index])\n}\n\nfunction normalizePlugConfiguration(raw: Array<string | PlugDescriptor> | PlugDescriptor | null | undefined): { [key: string]: { [name: string]: any } | null } | null {\n if (raw == null) {\n return null\n }\n\n const result: any = {}\n for (const item of Array.isArray(raw) ? raw : [raw]) {\n if (typeof item === \"string\") {\n result[item] = null\n } else {\n Object.assign(result, item)\n }\n }\n return result\n}\n\nfunction isBrowserSandboxAllowed(snap: any): boolean {\n if (snap.plugs != null) {\n for (const plugName of Object.keys(snap.plugs)) {\n const plug = snap.plugs[plugName]\n if (plug.interface === \"browser-support\" && plug[\"allow-sandbox\"] === true) {\n return true\n }\n }\n }\n return false\n}\n\nfunction getDefaultStagePackages() {\n // libxss1 - was \"error while loading shared libraries: libXss.so.1\" on Xubuntu 16.04\n // noinspection SpellCheckingInspection\n return [\"libnspr4\", \"libnss3\", \"libxss1\", \"libappindicator3-1\", \"libsecret-1-0\"]\n}\n"]}