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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/appInfo.d.ts +1 -1
  2. package/dist/appInfo.d.ts.map +1 -1
  3. package/dist/appInfo.js +3 -3
  4. package/dist/appInfo.js.map +1 -1
  5. package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -1
  6. package/dist/codeSign/win/signtoolBaseSignManager.js +4 -3
  7. package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -1
  8. package/dist/configuration.d.ts +47 -0
  9. package/dist/configuration.d.ts.map +1 -1
  10. package/dist/configuration.js +11 -1
  11. package/dist/configuration.js.map +1 -1
  12. package/dist/electron/ElectronFramework.d.ts +2 -1
  13. package/dist/electron/ElectronFramework.d.ts.map +1 -1
  14. package/dist/electron/ElectronFramework.js +30 -26
  15. package/dist/electron/ElectronFramework.js.map +1 -1
  16. package/dist/electron/electronArchSupport.d.ts +12 -0
  17. package/dist/electron/electronArchSupport.d.ts.map +1 -0
  18. package/dist/electron/electronArchSupport.js +58 -0
  19. package/dist/electron/electronArchSupport.js.map +1 -0
  20. package/dist/electron/mac/electronMac.js +12 -21
  21. package/dist/electron/mac/electronMac.js.map +1 -1
  22. package/dist/electron/mac/electronMacUtils.d.ts +24 -0
  23. package/dist/electron/mac/electronMacUtils.d.ts.map +1 -0
  24. package/dist/electron/mac/electronMacUtils.js +42 -0
  25. package/dist/electron/mac/electronMacUtils.js.map +1 -0
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/indexInternal.d.ts +3 -1
  30. package/dist/indexInternal.d.ts.map +1 -1
  31. package/dist/indexInternal.js +3 -0
  32. package/dist/indexInternal.js.map +1 -1
  33. package/dist/macPackager.d.ts.map +1 -1
  34. package/dist/macPackager.js +15 -3
  35. package/dist/macPackager.js.map +1 -1
  36. package/dist/node-module-collector/moduleManager.d.ts +2 -1
  37. package/dist/node-module-collector/moduleManager.d.ts.map +1 -1
  38. package/dist/node-module-collector/moduleManager.js +2 -0
  39. package/dist/node-module-collector/moduleManager.js.map +1 -1
  40. package/dist/node-module-collector/nodeModulesCollector.d.ts +17 -1
  41. package/dist/node-module-collector/nodeModulesCollector.d.ts.map +1 -1
  42. package/dist/node-module-collector/nodeModulesCollector.js +67 -1
  43. package/dist/node-module-collector/nodeModulesCollector.js.map +1 -1
  44. package/dist/node-module-collector/types.d.ts +2 -0
  45. package/dist/node-module-collector/types.d.ts.map +1 -1
  46. package/dist/node-module-collector/types.js.map +1 -1
  47. package/dist/options/MsixOptions.d.ts +126 -0
  48. package/dist/options/MsixOptions.d.ts.map +1 -0
  49. package/dist/options/MsixOptions.js +2 -0
  50. package/dist/options/MsixOptions.js.map +1 -0
  51. package/dist/options/macOptions.d.ts +4 -4
  52. package/dist/options/macOptions.d.ts.map +1 -1
  53. package/dist/options/macOptions.js.map +1 -1
  54. package/dist/options/winOptions.d.ts +2 -2
  55. package/dist/options/winOptions.js.map +1 -1
  56. package/dist/packager.d.ts.map +1 -1
  57. package/dist/packager.js +7 -0
  58. package/dist/packager.js.map +1 -1
  59. package/dist/publish/PublishManager.d.ts.map +1 -1
  60. package/dist/publish/PublishManager.js +13 -4
  61. package/dist/publish/PublishManager.js.map +1 -1
  62. package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
  63. package/dist/publish/updateInfoBuilder.js +20 -22
  64. package/dist/publish/updateInfoBuilder.js.map +1 -1
  65. package/dist/targets/archive.d.ts +11 -0
  66. package/dist/targets/archive.d.ts.map +1 -1
  67. package/dist/targets/archive.js +40 -22
  68. package/dist/targets/archive.js.map +1 -1
  69. package/dist/targets/linux/snap/snapcraft.d.ts +190 -0
  70. package/dist/targets/linux/snap/snapcraft.d.ts.map +1 -0
  71. package/dist/targets/linux/snap/snapcraft.js +11 -0
  72. package/dist/targets/linux/snap/snapcraft.js.map +1 -0
  73. package/dist/targets/mac/MacTargetHelper.d.ts +6 -0
  74. package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
  75. package/dist/targets/mac/MacTargetHelper.js +22 -1
  76. package/dist/targets/mac/MacTargetHelper.js.map +1 -1
  77. package/dist/targets/win/AppxTarget.d.ts +0 -2
  78. package/dist/targets/win/AppxTarget.d.ts.map +1 -1
  79. package/dist/targets/win/AppxTarget.js +37 -325
  80. package/dist/targets/win/AppxTarget.js.map +1 -1
  81. package/dist/targets/win/MsixTarget.d.ts +22 -0
  82. package/dist/targets/win/MsixTarget.d.ts.map +1 -0
  83. package/dist/targets/win/MsixTarget.js +214 -0
  84. package/dist/targets/win/MsixTarget.js.map +1 -0
  85. package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
  86. package/dist/targets/win/nsis/NsisTarget.js +5 -0
  87. package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
  88. package/dist/targets/win/winAppUtil.d.ts +115 -0
  89. package/dist/targets/win/winAppUtil.d.ts.map +1 -0
  90. package/dist/targets/win/winAppUtil.js +407 -0
  91. package/dist/targets/win/winAppUtil.js.map +1 -0
  92. package/dist/toolsets/winCodeSign.d.ts +9 -0
  93. package/dist/toolsets/winCodeSign.d.ts.map +1 -1
  94. package/dist/toolsets/winCodeSign.js +11 -0
  95. package/dist/toolsets/winCodeSign.js.map +1 -1
  96. package/dist/util/appFileCopier.d.ts.map +1 -1
  97. package/dist/util/appFileCopier.js +22 -2
  98. package/dist/util/appFileCopier.js.map +1 -1
  99. package/dist/util/electronGet.d.ts.map +1 -1
  100. package/dist/util/electronGet.js +17 -11
  101. package/dist/util/electronGet.js.map +1 -1
  102. package/dist/util/flags.d.ts +0 -1
  103. package/dist/util/flags.d.ts.map +1 -1
  104. package/dist/util/flags.js +0 -3
  105. package/dist/util/flags.js.map +1 -1
  106. package/dist/util/packageMetadata.js +0 -10
  107. package/dist/util/packageMetadata.js.map +1 -1
  108. package/dist/version.d.ts +1 -1
  109. package/dist/version.js +1 -1
  110. package/dist/version.js.map +1 -1
  111. package/dist/vm/ParallelsVm.d.ts.map +1 -1
  112. package/dist/vm/ParallelsVm.js +18 -5
  113. package/dist/vm/ParallelsVm.js.map +1 -1
  114. package/dist/winPackager.d.ts.map +1 -1
  115. package/dist/winPackager.js +3 -0
  116. package/dist/winPackager.js.map +1 -1
  117. package/package.json +8 -8
  118. package/scheme.json +462 -8
  119. package/templates/appx/appxmanifest.xml +1 -1
  120. package/templates/msix/appxmanifest.xml +45 -0
  121. package/templates/nsis/installSection.nsh +14 -0
@@ -54,17 +54,6 @@ function getArchPrefixForUpdateFile(arch, packager) {
54
54
  }
55
55
  return arch === Arch.armv7l ? "-arm" : `-${Arch[arch]}`;
56
56
  }
57
- function checkUpdaterCompatibility(updaterCompatibility, publishConfiguration, packager) {
58
- if (updaterCompatibility != null) {
59
- return semver.satisfies("1.0.0", updaterCompatibility);
60
- }
61
- // spaces is a new publish provider, no need to keep backward compatibility
62
- if (publishConfiguration.provider === "spaces") {
63
- return false;
64
- }
65
- const updaterVersion = packager.metadata.dependencies == null ? null : packager.metadata.dependencies["electron-updater"];
66
- return updaterVersion == null || semver.lt(updaterVersion, "4.0.0");
67
- }
68
57
  export async function createUpdateInfoTasks(event, _publishConfigs) {
69
58
  const packager = event.packager;
70
59
  const publishConfigs = await getPublishConfigsForUpdateInfo(packager, _publishConfigs, event.arch);
@@ -78,20 +67,32 @@ export async function createUpdateInfoTasks(event, _publishConfigs) {
78
67
  const createdFiles = new Set();
79
68
  const sharedInfo = await createUpdateInfo(version, event, await getReleaseInfo(packager));
80
69
  const tasks = [];
81
- const electronUpdaterCompatibility = packager.platformOptions.electronUpdaterCompatibility || packager.config.electronUpdaterCompatibility || ">=2.15";
70
+ const electronUpdaterCompatibility = packager.platformOptions.electronUpdaterCompatibility || packager.config.electronUpdaterCompatibility || ">=2.16";
71
+ // electron-updater < 2.16.0 predates the files[] array and reads the top-level path/sha512 (and Windows sha2) fields instead
72
+ // (do not pass includePrerelease — it would make the default ">=2.16" intersect "<2.16.0" at the 2.16.0-0 prerelease point)
73
+ const needsLegacyPathSha512 = semver.intersects(electronUpdaterCompatibility, "<2.16.0");
74
+ // electron-updater < 2.0.0 on macOS reads the legacy <channel>-mac.json instead of <channel>-mac.yml
75
+ const needsLegacyMacJsonCompatibility = semver.intersects(electronUpdaterCompatibility, "<2.0.0");
82
76
  for (const publishConfiguration of publishConfigs) {
83
77
  let dir = outDir;
84
78
  if (publishConfigs.length > 1 && publishConfiguration !== publishConfigs[0]) {
85
79
  dir = path.join(outDir, publishConfiguration.provider);
86
80
  }
87
- let isElectronUpdater1xCompatibility = checkUpdaterCompatibility(electronUpdaterCompatibility, publishConfiguration, packager);
81
+ let needsLegacyMacJson = needsLegacyMacJsonCompatibility;
88
82
  let info = sharedInfo;
89
83
  // noinspection JSDeprecatedSymbols
90
- if (isElectronUpdater1xCompatibility && packager.platform === Platform.WINDOWS) {
84
+ if (needsLegacyPathSha512) {
85
+ // legacy top-level path/sha512 (and Windows sha2) for electron-updater 1.x – 2.15.0; modern clients read files[]
91
86
  info = {
92
87
  ...info,
88
+ path: info.files[0].url,
89
+ sha512: info.files[0].sha512,
93
90
  };
94
- info.sha2 = await sha2.value;
91
+ if (packager.platform === Platform.WINDOWS) {
92
+ // noinspection JSDeprecatedSymbols
93
+ ;
94
+ info.sha2 = await sha2.value;
95
+ }
95
96
  }
96
97
  if (event.safeArtifactName != null && publishConfiguration.provider === "github") {
97
98
  const newFiles = info.files.slice();
@@ -99,13 +100,14 @@ export async function createUpdateInfoTasks(event, _publishConfigs) {
99
100
  info = {
100
101
  ...info,
101
102
  files: newFiles,
102
- path: event.safeArtifactName,
103
+ // legacy top-level path mirrors files[0].url; only emitted for pre-2.16 compatibility
104
+ ...(needsLegacyPathSha512 ? { path: event.safeArtifactName } : {}),
103
105
  };
104
106
  }
105
107
  for (const channel of computeChannelNames(packager, publishConfiguration)) {
106
- if (isMac && isElectronUpdater1xCompatibility && event.file.endsWith(".zip")) {
108
+ if (isMac && needsLegacyMacJson && event.file.endsWith(".zip")) {
107
109
  // write only for first channel (generateUpdatesFilesForAllChannels is a new functionality, no need to generate old mac update info file)
108
- isElectronUpdater1xCompatibility = false;
110
+ needsLegacyMacJson = false;
109
111
  await writeOldMacInfo(publishConfiguration, outDir, dir, channel, createdFiles, version, packager);
110
112
  }
111
113
  const updateInfoFile = path.join(dir, getUpdateInfoFileName(channel, packager, event.arch));
@@ -135,10 +137,6 @@ async function createUpdateInfo(version, event, releaseInfo) {
135
137
  version,
136
138
  // @ts-ignore
137
139
  files,
138
- // @ts-ignore
139
- path: url /* backward compatibility, electron-updater 1.x - electron-updater 2.15.0 */,
140
- // @ts-ignore
141
- sha512 /* backward compatibility, electron-updater 1.x - electron-updater 2.15.0 */,
142
140
  ...releaseInfo,
143
141
  };
144
142
  if (customUpdateInfo != null) {
@@ -1 +1 @@
1
- {"version":3,"file":"updateInfoBuilder.js","sourceRoot":"","sources":["../../src/publish/updateInfoBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE5E,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAKrC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,kBAAkB,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAA;AAExF,KAAK,UAAU,cAAc,CAAC,QAA+B;IAC3D,MAAM,WAAW,GAAgB,EAAE,GAAG,CAAC,QAAQ,CAAC,eAAe,CAAC,WAAW,IAAI,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EAAE,QAAQ,CAAC;SACjG,EACD,EAAE,MAAM,EAAE,CAAC,EAAE,CACd,CAAA;QAED,MAAM,QAAQ,CAAC,mBAAmB,CAAC;YACjC,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE,IAAI;YACV,QAAQ;YACR,MAAM,EAAE,IAAI;YACZ,aAAa;SACd,CAAC,CAAA;IACJ,CAAC;AACH,CAAC","sourcesContent":["import asyncPool from \"tiny-async-pool\"\nimport { Arch, log, safeStringifyJson, serializeToYaml } from \"builder-util\"\nimport { GenericServerOptions, PublishConfiguration, UpdateInfo, WindowsUpdateInfo } from \"builder-util-runtime\"\nimport fsExtra from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport { Platform } from \"../core.js\"\nimport { ReleaseInfo } from \"../options/PlatformSpecificBuildOptions.js\"\nimport { Packager } from \"../packager.js\"\nimport { ArtifactCreated } from \"../packagerApi.js\"\nimport { PlatformPackager } from \"../platformPackager.js\"\nimport { hashFile } from \"../util/hash.js\"\nimport { computeDownloadUrl, getPublishConfigsForUpdateInfo } from \"./PublishManager.js\"\n\nasync function getReleaseInfo(packager: PlatformPackager<any>) {\n const releaseInfo: ReleaseInfo = { ...(packager.platformOptions.releaseInfo || packager.config.releaseInfo) }\n if (releaseInfo.releaseNotes == null) {\n const releaseNotesFile = await packager.getResource(\n releaseInfo.releaseNotesFile,\n `release-notes-${packager.platform.buildConfigurationKey}.md`,\n `release-notes-${packager.platform.name}.md`,\n `release-notes-${packager.platform.nodeName}.md`,\n \"release-notes.md\"\n )\n const releaseNotes = releaseNotesFile == null ? null : await fsExtra.readFile(releaseNotesFile, \"utf-8\")\n // to avoid undefined in the file, check for null\n if (releaseNotes != null) {\n releaseInfo.releaseNotes = releaseNotes\n }\n }\n delete releaseInfo.releaseNotesFile\n return releaseInfo\n}\n\nfunction isGenerateUpdatesFilesForAllChannels(packager: PlatformPackager<any>) {\n const value = packager.platformOptions.generateUpdatesFilesForAllChannels\n return value == null ? packager.config.generateUpdatesFilesForAllChannels : value\n}\n\n/**\n if this is an \"alpha\" version, we need to generate only the \"alpha\" .yml file\n if this is a \"beta\" version, we need to generate both the \"alpha\" and \"beta\" .yml file\n if this is a \"stable\" version, we need to generate all the \"alpha\", \"beta\" and \"stable\" .yml file\n */\nfunction computeChannelNames(packager: PlatformPackager<any>, publishConfig: PublishConfiguration): Array<string> {\n const currentChannel: string = (publishConfig as GenericServerOptions).channel || \"latest\"\n // for GitHub should be pre-release way be used\n if (currentChannel === \"alpha\" || publishConfig.provider === \"github\" || !isGenerateUpdatesFilesForAllChannels(packager)) {\n return [currentChannel]\n }\n\n switch (currentChannel) {\n case \"beta\":\n return [currentChannel, \"alpha\"]\n\n case \"latest\":\n return [currentChannel, \"alpha\", \"beta\"]\n\n default:\n return [currentChannel]\n }\n}\n\nfunction getUpdateInfoFileName(channel: string, packager: PlatformPackager<any>, arch: Arch | null): string {\n const osSuffix = packager.platform === Platform.WINDOWS ? \"\" : `-${packager.platform.buildConfigurationKey}`\n return `${channel}${osSuffix}${getArchPrefixForUpdateFile(arch, packager)}.yml`\n}\n\nfunction getArchPrefixForUpdateFile(arch: Arch | null, packager: PlatformPackager<any>) {\n if (arch == null || arch === Arch.x64 || packager.platform !== Platform.LINUX) {\n return \"\"\n }\n return arch === Arch.armv7l ? \"-arm\" : `-${Arch[arch]}`\n}\n\nexport interface UpdateInfoFileTask {\n readonly file: string\n readonly info: UpdateInfo\n readonly publishConfiguration: PublishConfiguration\n readonly packager: PlatformPackager<any>\n readonly arch?: Arch | null\n}\n\nfunction checkUpdaterCompatibility(updaterCompatibility: string | null, publishConfiguration: PublishConfiguration, packager: PlatformPackager<any>) {\n if (updaterCompatibility != null) {\n return semver.satisfies(\"1.0.0\", updaterCompatibility)\n }\n\n // spaces is a new publish provider, no need to keep backward compatibility\n if (publishConfiguration.provider === \"spaces\") {\n return false\n }\n\n const updaterVersion = packager.metadata.dependencies == null ? null : packager.metadata.dependencies[\"electron-updater\"]\n return updaterVersion == null || semver.lt(updaterVersion, \"4.0.0\")\n}\n\nexport async function createUpdateInfoTasks(event: ArtifactCreated, _publishConfigs: Array<PublishConfiguration>): Promise<Array<UpdateInfoFileTask>> {\n const packager = event.packager\n const publishConfigs = await getPublishConfigsForUpdateInfo(packager, _publishConfigs, event.arch)\n if (publishConfigs == null || publishConfigs.length === 0) {\n return []\n }\n\n const outDir = event.target!.outDir\n const version = packager.appInfo.version\n const sha2 = new Lazy<string>(() => hashFile(event.file, \"sha256\", \"hex\"))\n const isMac = packager.platform === Platform.MAC\n const createdFiles = new Set<string>()\n const sharedInfo = await createUpdateInfo(version, event, await getReleaseInfo(packager))\n const tasks: Array<UpdateInfoFileTask> = []\n const electronUpdaterCompatibility = packager.platformOptions.electronUpdaterCompatibility || packager.config.electronUpdaterCompatibility || \">=2.15\"\n for (const publishConfiguration of publishConfigs) {\n let dir = outDir\n if (publishConfigs.length > 1 && publishConfiguration !== publishConfigs[0]) {\n dir = path.join(outDir, publishConfiguration.provider)\n }\n\n let isElectronUpdater1xCompatibility = checkUpdaterCompatibility(electronUpdaterCompatibility, publishConfiguration, packager)\n\n let info = sharedInfo\n // noinspection JSDeprecatedSymbols\n if (isElectronUpdater1xCompatibility && packager.platform === Platform.WINDOWS) {\n info = {\n ...info,\n }\n // noinspection JSDeprecatedSymbols\n ;(info as WindowsUpdateInfo).sha2 = await sha2.value\n }\n\n if (event.safeArtifactName != null && publishConfiguration.provider === \"github\") {\n const newFiles = info.files.slice()\n newFiles[0].url = event.safeArtifactName\n info = {\n ...info,\n files: newFiles,\n path: event.safeArtifactName,\n }\n }\n\n for (const channel of computeChannelNames(packager, publishConfiguration)) {\n if (isMac && isElectronUpdater1xCompatibility && event.file.endsWith(\".zip\")) {\n // write only for first channel (generateUpdatesFilesForAllChannels is a new functionality, no need to generate old mac update info file)\n isElectronUpdater1xCompatibility = false\n await writeOldMacInfo(publishConfiguration, outDir, dir, channel, createdFiles, version, packager)\n }\n\n const updateInfoFile = path.join(dir, getUpdateInfoFileName(channel, packager, event.arch))\n if (createdFiles.has(updateInfoFile)) {\n continue\n }\n\n createdFiles.add(updateInfoFile)\n\n // artifact should be uploaded only to designated publish provider\n tasks.push({\n file: updateInfoFile,\n info,\n publishConfiguration,\n packager,\n arch: event.arch,\n })\n }\n }\n return tasks\n}\n\nasync function createUpdateInfo(version: string, event: ArtifactCreated, releaseInfo: ReleaseInfo): Promise<UpdateInfo> {\n const customUpdateInfo = event.updateInfo\n const url = path.basename(event.file)\n const sha512 = (customUpdateInfo == null ? null : customUpdateInfo.sha512) || (await hashFile(event.file))\n const files = [{ url, sha512 }]\n const result: UpdateInfo = {\n // @ts-ignore\n version,\n // @ts-ignore\n files,\n // @ts-ignore\n path: url /* backward compatibility, electron-updater 1.x - electron-updater 2.15.0 */,\n // @ts-ignore\n sha512 /* backward compatibility, electron-updater 1.x - electron-updater 2.15.0 */,\n ...(releaseInfo as UpdateInfo),\n }\n\n if (customUpdateInfo != null) {\n // file info or nsis web installer packages info\n Object.assign(\"sha512\" in customUpdateInfo ? files[0] : result, customUpdateInfo)\n }\n return result\n}\n\nexport async function writeUpdateInfoFiles(updateInfoFileTasks: Array<UpdateInfoFileTask>, packager: Packager) {\n // zip must be first and zip info must be used for old path/sha512 properties in the update info\n // universal installer (arch === null) must precede arch-specific ones so path:/sha512: point to the right artifact\n updateInfoFileTasks.sort((a, b) => {\n const zipDiff = (a.info.files[0].url.endsWith(\".zip\") ? 0 : 100) - (b.info.files[0].url.endsWith(\".zip\") ? 0 : 100)\n if (zipDiff !== 0) {\n return zipDiff\n }\n // universal (arch === null) before arch-specific; tie-break by Arch enum value for full determinism\n // undefined arch (external callers predating this field) treated as arch-specific via strict === null check\n const aArch = a.arch === null ? -1 : (a.arch ?? Number.MAX_SAFE_INTEGER)\n const bArch = b.arch === null ? -1 : (b.arch ?? Number.MAX_SAFE_INTEGER)\n return aArch - bArch\n })\n\n const updateChannelFileToInfo = new Map<string, UpdateInfoFileTask>()\n for (const task of updateInfoFileTasks) {\n // https://github.com/electron-userland/electron-builder/pull/2994\n const key = `${task.file}@${safeStringifyJson(task.publishConfiguration, new Set([\"releaseType\"]))}`\n const existingTask = updateChannelFileToInfo.get(key)\n if (existingTask == null) {\n updateChannelFileToInfo.set(key, task)\n continue\n }\n\n existingTask.info.files.push(...task.info.files)\n }\n\n const releaseDate = new Date().toISOString()\n const concurrency = 4\n await asyncPool<UpdateInfoFileTask, void>(concurrency, Array.from(updateChannelFileToInfo.values()), async task => {\n const publishConfig = task.publishConfiguration\n if (publishConfig.publishAutoUpdate === false) {\n log.debug(\n {\n provider: publishConfig.provider,\n reason: \"publishAutoUpdate is set to false\",\n },\n \"auto update metadata file not published\"\n )\n return\n }\n\n if (task.info.releaseDate == null) {\n task.info.releaseDate = releaseDate\n }\n\n const fileContent = Buffer.from(serializeToYaml(task.info, false, true))\n await fsExtra.outputFile(task.file, fileContent)\n await packager.emitArtifactCreated({\n file: task.file,\n fileContent,\n arch: null,\n packager: task.packager,\n target: null,\n publishConfig,\n })\n })\n}\n\n// backward compatibility - write json file\nasync function writeOldMacInfo(\n publishConfig: PublishConfiguration,\n outDir: string,\n dir: string,\n channel: string,\n createdFiles: Set<string>,\n version: string,\n packager: PlatformPackager<any>\n) {\n const isGitHub = publishConfig.provider === \"github\"\n const updateInfoFile = isGitHub && outDir === dir ? path.join(dir, \"github\", `${channel}-mac.json`) : path.join(dir, `${channel}-mac.json`)\n if (!createdFiles.has(updateInfoFile)) {\n createdFiles.add(updateInfoFile)\n await fsExtra.outputJson(\n updateInfoFile,\n {\n version,\n releaseDate: new Date().toISOString(),\n url: computeDownloadUrl(publishConfig, packager.generateName2(\"zip\", \"mac\", isGitHub), packager),\n },\n { spaces: 2 }\n )\n\n await packager.emitArtifactCreated({\n file: updateInfoFile,\n arch: null,\n packager,\n target: null,\n publishConfig,\n })\n }\n}\n"]}
1
+ {"version":3,"file":"updateInfoBuilder.js","sourceRoot":"","sources":["../../src/publish/updateIn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,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,WAAW,CAAC,CAAA;IAC3I,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;QACtC,YAAY,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;QAChC,MAAM,OAAO,CAAC,UAAU,CACtB,cAAc,EACd;YACE,OAAO;YACP,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACrC,GAAG,EAAE,kBAAkB,CAAC,aAAa,EAAE,QAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;SACjG,EACD,EAAE,MAAM,EAAE,CAAC,EAAE,CACd,CAAA;QAED,MAAM,QAAQ,CAAC,mBAAmB,CAAC;YACjC,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE,IAAI;YACV,QAAQ;YACR,MAAM,EAAE,IAAI;YACZ,aAAa;SACd,CAAC,CAAA;IACJ,CAAC;AACH,CAAC","sourcesContent":["import asyncPool from \"tiny-async-pool\"\nimport { Arch, log, safeStringifyJson, serializeToYaml } from \"builder-util\"\nimport { GenericServerOptions, PublishConfiguration, UpdateInfo, WindowsUpdateInfo } from \"builder-util-runtime\"\nimport fsExtra from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport { Platform } from \"../core.js\"\nimport { ReleaseInfo } from \"../options/PlatformSpecificBuildOptions.js\"\nimport { Packager } from \"../packager.js\"\nimport { ArtifactCreated } from \"../packagerApi.js\"\nimport { PlatformPackager } from \"../platformPackager.js\"\nimport { hashFile } from \"../util/hash.js\"\nimport { computeDownloadUrl, getPublishConfigsForUpdateInfo } from \"./PublishManager.js\"\n\nasync function getReleaseInfo(packager: PlatformPackager<any>) {\n const releaseInfo: ReleaseInfo = { ...(packager.platformOptions.releaseInfo || packager.config.releaseInfo) }\n if (releaseInfo.releaseNotes == null) {\n const releaseNotesFile = await packager.getResource(\n releaseInfo.releaseNotesFile,\n `release-notes-${packager.platform.buildConfigurationKey}.md`,\n `release-notes-${packager.platform.name}.md`,\n `release-notes-${packager.platform.nodeName}.md`,\n \"release-notes.md\"\n )\n const releaseNotes = releaseNotesFile == null ? null : await fsExtra.readFile(releaseNotesFile, \"utf-8\")\n // to avoid undefined in the file, check for null\n if (releaseNotes != null) {\n releaseInfo.releaseNotes = releaseNotes\n }\n }\n delete releaseInfo.releaseNotesFile\n return releaseInfo\n}\n\nfunction isGenerateUpdatesFilesForAllChannels(packager: PlatformPackager<any>) {\n const value = packager.platformOptions.generateUpdatesFilesForAllChannels\n return value == null ? packager.config.generateUpdatesFilesForAllChannels : value\n}\n\n/**\n if this is an \"alpha\" version, we need to generate only the \"alpha\" .yml file\n if this is a \"beta\" version, we need to generate both the \"alpha\" and \"beta\" .yml file\n if this is a \"stable\" version, we need to generate all the \"alpha\", \"beta\" and \"stable\" .yml file\n */\nfunction computeChannelNames(packager: PlatformPackager<any>, publishConfig: PublishConfiguration): Array<string> {\n const currentChannel: string = (publishConfig as GenericServerOptions).channel || \"latest\"\n // for GitHub should be pre-release way be used\n if (currentChannel === \"alpha\" || publishConfig.provider === \"github\" || !isGenerateUpdatesFilesForAllChannels(packager)) {\n return [currentChannel]\n }\n\n switch (currentChannel) {\n case \"beta\":\n return [currentChannel, \"alpha\"]\n\n case \"latest\":\n return [currentChannel, \"alpha\", \"beta\"]\n\n default:\n return [currentChannel]\n }\n}\n\nfunction getUpdateInfoFileName(channel: string, packager: PlatformPackager<any>, arch: Arch | null): string {\n const osSuffix = packager.platform === Platform.WINDOWS ? \"\" : `-${packager.platform.buildConfigurationKey}`\n return `${channel}${osSuffix}${getArchPrefixForUpdateFile(arch, packager)}.yml`\n}\n\nfunction getArchPrefixForUpdateFile(arch: Arch | null, packager: PlatformPackager<any>) {\n if (arch == null || arch === Arch.x64 || packager.platform !== Platform.LINUX) {\n return \"\"\n }\n return arch === Arch.armv7l ? \"-arm\" : `-${Arch[arch]}`\n}\n\nexport interface UpdateInfoFileTask {\n readonly file: string\n readonly info: UpdateInfo\n readonly publishConfiguration: PublishConfiguration\n readonly packager: PlatformPackager<any>\n readonly arch?: Arch | null\n}\n\nexport async function createUpdateInfoTasks(event: ArtifactCreated, _publishConfigs: Array<PublishConfiguration>): Promise<Array<UpdateInfoFileTask>> {\n const packager = event.packager\n const publishConfigs = await getPublishConfigsForUpdateInfo(packager, _publishConfigs, event.arch)\n if (publishConfigs == null || publishConfigs.length === 0) {\n return []\n }\n\n const outDir = event.target!.outDir\n const version = packager.appInfo.version\n const sha2 = new Lazy<string>(() => hashFile(event.file, \"sha256\", \"hex\"))\n const isMac = packager.platform === Platform.MAC\n const createdFiles = new Set<string>()\n const sharedInfo = await createUpdateInfo(version, event, await getReleaseInfo(packager))\n const tasks: Array<UpdateInfoFileTask> = []\n const electronUpdaterCompatibility = packager.platformOptions.electronUpdaterCompatibility || packager.config.electronUpdaterCompatibility || \">=2.16\"\n // electron-updater < 2.16.0 predates the files[] array and reads the top-level path/sha512 (and Windows sha2) fields instead\n // (do not pass includePrerelease — it would make the default \">=2.16\" intersect \"<2.16.0\" at the 2.16.0-0 prerelease point)\n const needsLegacyPathSha512 = semver.intersects(electronUpdaterCompatibility, \"<2.16.0\")\n // electron-updater < 2.0.0 on macOS reads the legacy <channel>-mac.json instead of <channel>-mac.yml\n const needsLegacyMacJsonCompatibility = semver.intersects(electronUpdaterCompatibility, \"<2.0.0\")\n for (const publishConfiguration of publishConfigs) {\n let dir = outDir\n if (publishConfigs.length > 1 && publishConfiguration !== publishConfigs[0]) {\n dir = path.join(outDir, publishConfiguration.provider)\n }\n\n let needsLegacyMacJson = needsLegacyMacJsonCompatibility\n\n let info = sharedInfo\n // noinspection JSDeprecatedSymbols\n if (needsLegacyPathSha512) {\n // legacy top-level path/sha512 (and Windows sha2) for electron-updater 1.x – 2.15.0; modern clients read files[]\n info = {\n ...info,\n path: info.files[0].url,\n sha512: info.files[0].sha512,\n }\n if (packager.platform === Platform.WINDOWS) {\n // noinspection JSDeprecatedSymbols\n ;(info as WindowsUpdateInfo).sha2 = await sha2.value\n }\n }\n\n if (event.safeArtifactName != null && publishConfiguration.provider === \"github\") {\n const newFiles = info.files.slice()\n newFiles[0].url = event.safeArtifactName\n info = {\n ...info,\n files: newFiles,\n // legacy top-level path mirrors files[0].url; only emitted for pre-2.16 compatibility\n ...(needsLegacyPathSha512 ? { path: event.safeArtifactName } : {}),\n }\n }\n\n for (const channel of computeChannelNames(packager, publishConfiguration)) {\n if (isMac && needsLegacyMacJson && event.file.endsWith(\".zip\")) {\n // write only for first channel (generateUpdatesFilesForAllChannels is a new functionality, no need to generate old mac update info file)\n needsLegacyMacJson = false\n await writeOldMacInfo(publishConfiguration, outDir, dir, channel, createdFiles, version, packager)\n }\n\n const updateInfoFile = path.join(dir, getUpdateInfoFileName(channel, packager, event.arch))\n if (createdFiles.has(updateInfoFile)) {\n continue\n }\n\n createdFiles.add(updateInfoFile)\n\n // artifact should be uploaded only to designated publish provider\n tasks.push({\n file: updateInfoFile,\n info,\n publishConfiguration,\n packager,\n arch: event.arch,\n })\n }\n }\n return tasks\n}\n\nasync function createUpdateInfo(version: string, event: ArtifactCreated, releaseInfo: ReleaseInfo): Promise<UpdateInfo> {\n const customUpdateInfo = event.updateInfo\n const url = path.basename(event.file)\n const sha512 = (customUpdateInfo == null ? null : customUpdateInfo.sha512) || (await hashFile(event.file))\n const files = [{ url, sha512 }]\n const result: UpdateInfo = {\n // @ts-ignore\n version,\n // @ts-ignore\n files,\n ...(releaseInfo as UpdateInfo),\n }\n\n if (customUpdateInfo != null) {\n // file info or nsis web installer packages info\n Object.assign(\"sha512\" in customUpdateInfo ? files[0] : result, customUpdateInfo)\n }\n return result\n}\n\nexport async function writeUpdateInfoFiles(updateInfoFileTasks: Array<UpdateInfoFileTask>, packager: Packager) {\n // zip must be first and zip info must be used for old path/sha512 properties in the update info\n // universal installer (arch === null) must precede arch-specific ones so path:/sha512: point to the right artifact\n updateInfoFileTasks.sort((a, b) => {\n const zipDiff = (a.info.files[0].url.endsWith(\".zip\") ? 0 : 100) - (b.info.files[0].url.endsWith(\".zip\") ? 0 : 100)\n if (zipDiff !== 0) {\n return zipDiff\n }\n // universal (arch === null) before arch-specific; tie-break by Arch enum value for full determinism\n // undefined arch (external callers predating this field) treated as arch-specific via strict === null check\n const aArch = a.arch === null ? -1 : (a.arch ?? Number.MAX_SAFE_INTEGER)\n const bArch = b.arch === null ? -1 : (b.arch ?? Number.MAX_SAFE_INTEGER)\n return aArch - bArch\n })\n\n const updateChannelFileToInfo = new Map<string, UpdateInfoFileTask>()\n for (const task of updateInfoFileTasks) {\n // https://github.com/electron-userland/electron-builder/pull/2994\n const key = `${task.file}@${safeStringifyJson(task.publishConfiguration, new Set([\"releaseType\"]))}`\n const existingTask = updateChannelFileToInfo.get(key)\n if (existingTask == null) {\n updateChannelFileToInfo.set(key, task)\n continue\n }\n\n existingTask.info.files.push(...task.info.files)\n }\n\n const releaseDate = new Date().toISOString()\n const concurrency = 4\n await asyncPool<UpdateInfoFileTask, void>(concurrency, Array.from(updateChannelFileToInfo.values()), async task => {\n const publishConfig = task.publishConfiguration\n if (publishConfig.publishAutoUpdate === false) {\n log.debug(\n {\n provider: publishConfig.provider,\n reason: \"publishAutoUpdate is set to false\",\n },\n \"auto update metadata file not published\"\n )\n return\n }\n\n if (task.info.releaseDate == null) {\n task.info.releaseDate = releaseDate\n }\n\n const fileContent = Buffer.from(serializeToYaml(task.info, false, true))\n await fsExtra.outputFile(task.file, fileContent)\n await packager.emitArtifactCreated({\n file: task.file,\n fileContent,\n arch: null,\n packager: task.packager,\n target: null,\n publishConfig,\n })\n })\n}\n\n// backward compatibility - write json file\nasync function writeOldMacInfo(\n publishConfig: PublishConfiguration,\n outDir: string,\n dir: string,\n channel: string,\n createdFiles: Set<string>,\n version: string,\n packager: PlatformPackager<any>\n) {\n const isGitHub = publishConfig.provider === \"github\"\n const updateInfoFile = isGitHub && outDir === dir ? path.join(dir, \"github\", `${channel}-mac.json`) : path.join(dir, `${channel}-mac.json`)\n if (!createdFiles.has(updateInfoFile)) {\n createdFiles.add(updateInfoFile)\n await fsExtra.outputJson(\n updateInfoFile,\n {\n version,\n releaseDate: new Date().toISOString(),\n url: computeDownloadUrl(publishConfig, packager.generateName2(\"zip\", \"mac\", isGitHub), packager),\n },\n { spaces: 2 }\n )\n\n await packager.emitArtifactCreated({\n file: updateInfoFile,\n arch: null,\n packager,\n target: null,\n publishConfig,\n })\n }\n}\n"]}
@@ -23,6 +23,17 @@ export interface ArchiveOptions {
23
23
  * @default false
24
24
  */
25
25
  preserveSymlinks?: boolean;
26
+ /**
27
+ * Restrict the 7z filter to one the install-time extractor (the self-vendored Nsis7z plugin) can
28
+ * decode. Modern 7za (24.09) auto-applies a CPU branch converter to executable content at
29
+ * `-mx>=1` — `BCJ2` on x86/x64 and `ARM64` on arm64 — which that decoder silently skips, dropping
30
+ * every executable from the install. When set, the archive is pinned to the single-stream `BCJ`
31
+ * filter while compressing (decodable, and the best-ratio filter that decoder supports) and to
32
+ * plain `Copy` while storing. Deliberately NOT overridable by `ELECTRON_BUILDER_7Z_FILTER`, which
33
+ * could otherwise reintroduce an unreadable archive. Only affects the 7z format. See #9983.
34
+ * @default false
35
+ */
36
+ installTimeDecodable?: boolean;
26
37
  }
27
38
  /**
28
39
  * Whether archives for the given target platform should preserve symlinks (i.e. pass `-snl`).
@@ -1 +1 @@
1
- {"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../src/targets/archive.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AA8DvD,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAA;IAErC;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB;;OAEG;IACH,KAAK,CAAC,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AAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAElE;AAkBD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,YA2EjF"}
@@ -6,7 +6,10 @@ import { getLinuxToolsMacToolset } from "../toolsets/linuxToolsMac.js";
6
6
  import { getPath7za } from "../toolsets/7zip.js";
7
7
  import _fsExtra from "fs-extra";
8
8
  const { move } = _fsExtra;
9
- const ALLOWED_7Z_FILTERS = new Set(["BCJ", "BCJ2", "ARM", "ARMT", "IA64", "PPC", "SPARC", "DELTA"]);
9
+ // Values accepted by ELECTRON_BUILDER_7Z_FILTER (passed through as `-mf=<value>`). "OFF" disables the
10
+ // branch/exec filter entirely (plain LZMA2); the rest are 7-Zip branch converters. 7za matches these
11
+ // case-insensitively, so the value is canonicalized to uppercase before use.
12
+ const ALLOWED_7Z_FILTERS = new Set(["OFF", "BCJ", "BCJ2", "ARM", "ARMT", "IA64", "PPC", "SPARC", "DELTA"]);
10
13
  function validateCompressionLevel(level) {
11
14
  if (!/^[0-9]$/.test(level)) {
12
15
  throw new Error(`ELECTRON_BUILDER_COMPRESSION_LEVEL must be a single digit 0-9, got: "${level}"`);
@@ -53,6 +56,21 @@ export async function tar({ compression, format, outFile, dirToArchive, isMacApp
53
56
  export function shouldPreserveSymlinks(platform) {
54
57
  return platform !== Platform.WINDOWS;
55
58
  }
59
+ /**
60
+ * Builds the exclude switches for the given masks, rejecting any pattern that contains a path
61
+ * traversal sequence. `prefix` is the tool-specific flag (`-xr!` for 7za, `-x` for native zip).
62
+ */
63
+ function buildExcludeArgs(excluded, prefix) {
64
+ if (excluded == null) {
65
+ return [];
66
+ }
67
+ return excluded.map(mask => {
68
+ if (mask.includes("..")) {
69
+ throw new Error(`Excluded archive pattern contains path traversal sequence: "${mask}"`);
70
+ }
71
+ return `${prefix}${mask}`;
72
+ });
73
+ }
56
74
  export function compute7zCompressArgs(format, options = {}) {
57
75
  let storeOnly = options.compression === "store";
58
76
  const args = debug7zArgs("a");
@@ -90,12 +108,26 @@ export function compute7zCompressArgs(format, options = {}) {
90
108
  if (options.isArchiveHeaderCompressed === false) {
91
109
  args.push("-mhc=off");
92
110
  }
93
- const sevenZFilter = process.env.ELECTRON_BUILDER_7Z_FILTER;
94
- if (sevenZFilter) {
95
- if (!ALLOWED_7Z_FILTERS.has(sevenZFilter.toUpperCase())) {
96
- throw new Error(`ELECTRON_BUILDER_7Z_FILTER must be one of: ${[...ALLOWED_7Z_FILTERS].join(", ")}`);
111
+ // Branch/exec filter selection. installTimeDecodable archives are unpacked by the self-vendored
112
+ // Nsis7z extractor, whose decoder only understands plain LZMA2/Copy and the single-stream BCJ
113
+ // filter — not the CPU branch converters modern 7za auto-applies (BCJ2 on x86/x64, ARM64 on
114
+ // arm64). So pin them to BCJ while compressing (the best filter that decoder can read; Copy
115
+ // needs none) and do not honor ELECTRON_BUILDER_7Z_FILTER, which could reintroduce an unreadable
116
+ // archive. Any other 7z archive may use ELECTRON_BUILDER_7Z_FILTER, else 7za's auto-selection.
117
+ if (options.installTimeDecodable) {
118
+ if (!storeOnly) {
119
+ args.push("-mf=BCJ");
120
+ }
121
+ }
122
+ else {
123
+ const sevenZFilter = process.env.ELECTRON_BUILDER_7Z_FILTER;
124
+ if (sevenZFilter) {
125
+ const canonicalFilter = sevenZFilter.toUpperCase();
126
+ if (!ALLOWED_7Z_FILTERS.has(canonicalFilter)) {
127
+ throw new Error(`ELECTRON_BUILDER_7Z_FILTER must be one of: ${[...ALLOWED_7Z_FILTERS].join(", ")}`);
128
+ }
129
+ args.push(`-mf=${canonicalFilter}`);
97
130
  }
98
- args.push(`-mf=${sevenZFilter}`);
99
131
  }
100
132
  args.push("-mtm=off", "-mta=off");
101
133
  }
@@ -137,14 +169,7 @@ export async function archive(format, outFile, dirToArchive, options = {}) {
137
169
  }
138
170
  await unlinkIfExists(outFile);
139
171
  args.push(outFile, options.withoutDir ? "." : path.basename(dirToArchive));
140
- if (options.excluded != null) {
141
- for (const mask of options.excluded) {
142
- if (mask.includes("..")) {
143
- throw new Error(`Excluded archive pattern contains path traversal sequence: "${mask}"`);
144
- }
145
- args.push(`-xr!${mask}`);
146
- }
147
- }
172
+ args.push(...buildExcludeArgs(options.excluded, "-xr!"));
148
173
  try {
149
174
  await exec(await getPath7za(), args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled);
150
175
  }
@@ -171,14 +196,7 @@ export async function archive(format, outFile, dirToArchive, options = {}) {
171
196
  }
172
197
  await unlinkIfExists(outFile);
173
198
  args.push(outFile, options.withoutDir ? "." : path.basename(dirToArchive));
174
- if (options.excluded != null) {
175
- for (const mask of options.excluded) {
176
- if (mask.includes("..")) {
177
- throw new Error(`Excluded archive pattern contains path traversal sequence: "${mask}"`);
178
- }
179
- args.push(`-x${mask}`);
180
- }
181
- }
199
+ args.push(...buildExcludeArgs(options.excluded, "-x"));
182
200
  await exec("zip", args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled);
183
201
  }
184
202
  return outFile;
@@ -1 +1 @@
1
- {"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/targets/archive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AACrF,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AAG5B,OAAO,EAAoB,QAAQ,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAA;AAEzB,MAAM,kBAAkB,GAAG,IAAI,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AAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAA;QAC1E,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC7B,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACpC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;oBACxB,MAAM,IAAI,KAAK,CAAC,+DAA+D,IAAI,GAAG,CAAC,CAAA;gBACzF,CAAC;gBACD,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;QACD,MAAM,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IACnH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,OAAkB;IACrC,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC7B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { debug7z, exec, exists, log, statOrNull, unlinkIfExists } from \"builder-util\"\nimport * as path from \"path\"\nimport { create } from \"tar\"\nimport type { TarOptionsWithAliasesAsync } from \"tar\"\nimport { TmpDir } from \"temp-file\"\nimport { CompressionLevel, Platform } from \"../core.js\"\nimport { getLinuxToolsMacToolset } from \"../toolsets/linuxToolsMac.js\"\nimport { ToolsetConfig } from \"../configuration.js\"\nimport { getPath7za } from \"../toolsets/7zip.js\"\nimport _fsExtra from \"fs-extra\"\nconst { move } = _fsExtra\n\nconst ALLOWED_7Z_FILTERS = new Set([\"BCJ\", \"BCJ2\", \"ARM\", \"ARMT\", \"IA64\", \"PPC\", \"SPARC\", \"DELTA\"])\n\nfunction validateCompressionLevel(level: string): void {\n if (!/^[0-9]$/.test(level)) {\n throw new Error(`ELECTRON_BUILDER_COMPRESSION_LEVEL must be a single digit 0-9, got: \"${level}\"`)\n }\n}\n\ntype TarConfig = {\n compression: CompressionLevel | null | undefined\n format: string\n outFile: string\n dirToArchive: string\n isMacApp: boolean\n tempDirManager: TmpDir\n linuxToolsMac: ToolsetConfig[\"linuxToolsMac\"]\n buildResourcesDir: string\n}\n\n/** @internal */\nexport async function tar({ compression, format, outFile, dirToArchive, isMacApp, tempDirManager, linuxToolsMac, buildResourcesDir }: TarConfig): Promise<void> {\n const tarFile = await tempDirManager.getTempFile({ suffix: \".tar\" })\n const tarArgs: TarOptionsWithAliasesAsync = {\n file: tarFile,\n portable: true,\n cwd: dirToArchive,\n prefix: path.basename(outFile, `.${format}`),\n }\n let tarDirectory = \".\"\n if (isMacApp) {\n delete tarArgs.prefix\n tarArgs.cwd = path.dirname(dirToArchive)\n tarDirectory = path.basename(dirToArchive)\n }\n\n await Promise.all([\n create(tarArgs, [tarDirectory]),\n // remove file before - 7z doesn't overwrite file, but update\n unlinkIfExists(outFile),\n ])\n\n if (format === \"tar.lz\") {\n const lzipPath = process.platform === \"darwin\" ? (await getLinuxToolsMacToolset(linuxToolsMac, buildResourcesDir)).lzip : \"lzip\"\n await exec(lzipPath, [compression === \"store\" ? \"-1\" : \"-9\", \"--keep\" /* keep (don't delete) input files */, tarFile])\n // lzip creates the output file in the same directory as the input with a .lz suffix\n await move(`${tarFile}.lz`, outFile)\n return\n }\n\n const compressFormat = format === \"tar.xz\" ? \"xz\" : format === \"tar.bz2\" ? \"bzip2\" : \"gzip\"\n const args = compute7zCompressArgs(compressFormat, { isRegularFile: true, method: \"DEFAULT\", compression })\n args.push(outFile, tarFile)\n await exec(await getPath7za(), args, { cwd: path.dirname(dirToArchive) }, debug7z.enabled)\n}\n\nexport interface ArchiveOptions {\n compression?: CompressionLevel | null\n\n /**\n * @default false\n */\n withoutDir?: boolean\n\n /**\n * @default true\n */\n solid?: boolean\n\n /**\n * @default true\n */\n isArchiveHeaderCompressed?: boolean\n\n dictSize?: number\n excluded?: Array<string> | null\n\n // DEFAULT allows to disable custom logic and do not pass method switch at all\n method?: \"Copy\" | \"LZMA\" | \"Deflate\" | \"DEFAULT\"\n\n isRegularFile?: boolean\n\n /**\n * Preserve symlinks (e.g. macOS .framework `Versions/Current`) instead of dereferencing them.\n * Passes `-snl` to 7za — modern 7-Zip derefs by default, which breaks bundle codesigning. See #9846.\n * @default false\n */\n preserveSymlinks?: boolean\n}\n\n/**\n * Whether archives for the given target platform should preserve symlinks (i.e. pass `-snl`).\n * Non-Windows targets preserve them: macOS `.framework` bundles need them for codesigning (#9846)\n * and Linux bundles may legitimately contain them. Windows dereferences because restoring symlinks\n * there requires elevated privileges. Keyed on the target platform, not the build host.\n */\nexport function shouldPreserveSymlinks(platform: Platform): boolean {\n return platform !== Platform.WINDOWS\n}\n\nexport function compute7zCompressArgs(format: string, options: ArchiveOptions = {}) {\n let storeOnly = options.compression === \"store\"\n const args = debug7zArgs(\"a\")\n\n const compressionLevel = process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL\n if (compressionLevel != null) {\n validateCompressionLevel(compressionLevel)\n storeOnly = false // env var overrides \"store\" config\n args.push(`-mx=${compressionLevel}`)\n } else if (storeOnly) {\n // -mx=0 is the universal \"no compression\" flag across all formats (zip, 7z, gzip, xz, bzip2).\n // -mm=Copy would only be valid for zip/7z and causes E_INVALIDARG on xz/gzip/bzip2.\n args.push(\"-mx=0\")\n } else {\n const isZip = format === \"zip\"\n // ZIP uses level 7 by default; everything else (7z, gzip, xz, bzip2) uses level 9\n args.push(\"-mx=\" + (isZip && options.compression !== \"maximum\" ? \"7\" : \"9\"))\n if (isZip && options.compression === \"maximum\") {\n // http://superuser.com/a/742034\n args.push(\"-mfb=258\", \"-mpass=15\")\n }\n }\n\n if (options.dictSize != null) {\n args.push(`-md=${options.dictSize}m`)\n }\n\n // Disable NTFS timestamps for reproducible archives\n if (!options.isRegularFile) {\n args.push(\"-mtc=off\")\n }\n\n if (format === \"7z\" || format.endsWith(\".7z\")) {\n if (options.solid === false) {\n args.push(\"-ms=off\")\n }\n\n if (options.isArchiveHeaderCompressed === false) {\n args.push(\"-mhc=off\")\n }\n\n const sevenZFilter = process.env.ELECTRON_BUILDER_7Z_FILTER\n if (sevenZFilter) {\n if (!ALLOWED_7Z_FILTERS.has(sevenZFilter.toUpperCase())) {\n throw new Error(`ELECTRON_BUILDER_7Z_FILTER must be one of: ${[...ALLOWED_7Z_FILTERS].join(\", \")}`)\n }\n args.push(`-mf=${sevenZFilter}`)\n }\n\n args.push(\"-mtm=off\", \"-mta=off\")\n }\n\n if (options.method != null && options.method !== \"DEFAULT\") {\n args.push(`-mm=${options.method}`)\n } else if (format === \"zip\") {\n // -mm is only set explicitly for zip (Deflate/Copy) and includes the UTF-8 flag.\n // For all other formats the codec is implicit from the output file extension.\n args.push(`-mm=${storeOnly ? \"Copy\" : \"Deflate\"}`)\n args.push(\"-mcu\")\n }\n\n return args\n}\n\n// 7z is very fast, so, use ultra compression\n/** @internal */\nexport async function archive(format: string, outFile: string, dirToArchive: string, options: ArchiveOptions = {}): Promise<string> {\n const outFileStat = await statOrNull(outFile)\n const dirStat = await statOrNull(dirToArchive)\n if (outFileStat && dirStat && outFileStat.mtime > dirStat.mtime) {\n log.info({ reason: \"Archive file is up to date\", outFile }, `skipped archiving`)\n return outFile\n }\n\n // Use 7za for all formats (matches pre-26.15 behavior). Native macOS `zip` is only a\n // fallback for NFD-normalized filenames, which 7za mangles.\n let use7z = true\n if (process.platform === \"darwin\" && format === \"zip\" && dirToArchive.normalize(\"NFC\") !== dirToArchive) {\n log.warn({ reason: \"7z doesn't support NFD-normalized filenames\" }, `using zip`)\n use7z = false\n }\n\n if (use7z) {\n const args = compute7zCompressArgs(format, options)\n // Modern 7-Zip (24.09) dereferences symlinks by default; the 7-Zip 16.02 bundled before\n // 26.15 stored them as links. Without -snl, a macOS .framework `Versions/Current` extracts\n // as a real directory → codesign \"bundle format is ambiguous\" → breaks Squirrel.Mac\n // auto-update (#9846). Callers enable it for all non-Windows targets (see ArchiveTarget).\n if (options.preserveSymlinks) {\n args.push(\"-snl\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n if (options.excluded != null) {\n for (const mask of options.excluded) {\n if (mask.includes(\"..\")) {\n throw new Error(`Excluded archive pattern contains path traversal sequence: \"${mask}\"`)\n }\n args.push(`-xr!${mask}`)\n }\n }\n\n try {\n await exec(await getPath7za(), args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n } catch (e: any) {\n if (e.code === \"ENOENT\" && !(await exists(dirToArchive))) {\n throw new Error(`Cannot create archive: \"${dirToArchive}\" doesn't exist`)\n } else {\n throw e\n }\n }\n } else {\n // macOS native zip (NFD fallback): -y preserves symlinks\n const args = [\"-q\", \"-r\", \"-y\"]\n if (debug7z.enabled) {\n args.push(\"-v\")\n }\n if (options.compression === \"store\") {\n args.push(\"-0\")\n } else {\n args.push(options.compression === \"maximum\" ? \"-9\" : \"-7\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n if (options.excluded != null) {\n for (const mask of options.excluded) {\n if (mask.includes(\"..\")) {\n throw new Error(`Excluded archive pattern contains path traversal sequence: \"${mask}\"`)\n }\n args.push(`-x${mask}`)\n }\n }\n await exec(\"zip\", args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n }\n\n return outFile\n}\n\nfunction debug7zArgs(command: \"a\" | \"x\"): Array<string> {\n const args = [command, \"-bd\"]\n if (debug7z.enabled) {\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,CAAA;QAC1E,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;QACtD,MAAM,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IACnH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,OAAkB;IACrC,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC7B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { debug7z, exec, exists, log, statOrNull, unlinkIfExists } from \"builder-util\"\nimport * as path from \"path\"\nimport { create } from \"tar\"\nimport type { TarOptionsWithAliasesAsync } from \"tar\"\nimport { TmpDir } from \"temp-file\"\nimport { CompressionLevel, Platform } from \"../core.js\"\nimport { getLinuxToolsMacToolset } from \"../toolsets/linuxToolsMac.js\"\nimport { ToolsetConfig } from \"../configuration.js\"\nimport { getPath7za } from \"../toolsets/7zip.js\"\nimport _fsExtra from \"fs-extra\"\nconst { move } = _fsExtra\n\n// Values accepted by ELECTRON_BUILDER_7Z_FILTER (passed through as `-mf=<value>`). \"OFF\" disables the\n// branch/exec filter entirely (plain LZMA2); the rest are 7-Zip branch converters. 7za matches these\n// case-insensitively, so the value is canonicalized to uppercase before use.\nconst ALLOWED_7Z_FILTERS = new Set([\"OFF\", \"BCJ\", \"BCJ2\", \"ARM\", \"ARMT\", \"IA64\", \"PPC\", \"SPARC\", \"DELTA\"])\n\nfunction validateCompressionLevel(level: string): void {\n if (!/^[0-9]$/.test(level)) {\n throw new Error(`ELECTRON_BUILDER_COMPRESSION_LEVEL must be a single digit 0-9, got: \"${level}\"`)\n }\n}\n\ntype TarConfig = {\n compression: CompressionLevel | null | undefined\n format: string\n outFile: string\n dirToArchive: string\n isMacApp: boolean\n tempDirManager: TmpDir\n linuxToolsMac: ToolsetConfig[\"linuxToolsMac\"]\n buildResourcesDir: string\n}\n\n/** @internal */\nexport async function tar({ compression, format, outFile, dirToArchive, isMacApp, tempDirManager, linuxToolsMac, buildResourcesDir }: TarConfig): Promise<void> {\n const tarFile = await tempDirManager.getTempFile({ suffix: \".tar\" })\n const tarArgs: TarOptionsWithAliasesAsync = {\n file: tarFile,\n portable: true,\n cwd: dirToArchive,\n prefix: path.basename(outFile, `.${format}`),\n }\n let tarDirectory = \".\"\n if (isMacApp) {\n delete tarArgs.prefix\n tarArgs.cwd = path.dirname(dirToArchive)\n tarDirectory = path.basename(dirToArchive)\n }\n\n await Promise.all([\n create(tarArgs, [tarDirectory]),\n // remove file before - 7z doesn't overwrite file, but update\n unlinkIfExists(outFile),\n ])\n\n if (format === \"tar.lz\") {\n const lzipPath = process.platform === \"darwin\" ? (await getLinuxToolsMacToolset(linuxToolsMac, buildResourcesDir)).lzip : \"lzip\"\n await exec(lzipPath, [compression === \"store\" ? \"-1\" : \"-9\", \"--keep\" /* keep (don't delete) input files */, tarFile])\n // lzip creates the output file in the same directory as the input with a .lz suffix\n await move(`${tarFile}.lz`, outFile)\n return\n }\n\n const compressFormat = format === \"tar.xz\" ? \"xz\" : format === \"tar.bz2\" ? \"bzip2\" : \"gzip\"\n const args = compute7zCompressArgs(compressFormat, { isRegularFile: true, method: \"DEFAULT\", compression })\n args.push(outFile, tarFile)\n await exec(await getPath7za(), args, { cwd: path.dirname(dirToArchive) }, debug7z.enabled)\n}\n\nexport interface ArchiveOptions {\n compression?: CompressionLevel | null\n\n /**\n * @default false\n */\n withoutDir?: boolean\n\n /**\n * @default true\n */\n solid?: boolean\n\n /**\n * @default true\n */\n isArchiveHeaderCompressed?: boolean\n\n dictSize?: number\n excluded?: Array<string> | null\n\n // DEFAULT allows to disable custom logic and do not pass method switch at all\n method?: \"Copy\" | \"LZMA\" | \"Deflate\" | \"DEFAULT\"\n\n isRegularFile?: boolean\n\n /**\n * Preserve symlinks (e.g. macOS .framework `Versions/Current`) instead of dereferencing them.\n * Passes `-snl` to 7za — modern 7-Zip derefs by default, which breaks bundle codesigning. See #9846.\n * @default false\n */\n preserveSymlinks?: boolean\n\n /**\n * Restrict the 7z filter to one the install-time extractor (the self-vendored Nsis7z plugin) can\n * decode. Modern 7za (24.09) auto-applies a CPU branch converter to executable content at\n * `-mx>=1` — `BCJ2` on x86/x64 and `ARM64` on arm64 — which that decoder silently skips, dropping\n * every executable from the install. When set, the archive is pinned to the single-stream `BCJ`\n * filter while compressing (decodable, and the best-ratio filter that decoder supports) and to\n * plain `Copy` while storing. Deliberately NOT overridable by `ELECTRON_BUILDER_7Z_FILTER`, which\n * could otherwise reintroduce an unreadable archive. Only affects the 7z format. See #9983.\n * @default false\n */\n installTimeDecodable?: boolean\n}\n\n/**\n * Whether archives for the given target platform should preserve symlinks (i.e. pass `-snl`).\n * Non-Windows targets preserve them: macOS `.framework` bundles need them for codesigning (#9846)\n * and Linux bundles may legitimately contain them. Windows dereferences because restoring symlinks\n * there requires elevated privileges. Keyed on the target platform, not the build host.\n */\nexport function shouldPreserveSymlinks(platform: Platform): boolean {\n return platform !== Platform.WINDOWS\n}\n\n/**\n * Builds the exclude switches for the given masks, rejecting any pattern that contains a path\n * traversal sequence. `prefix` is the tool-specific flag (`-xr!` for 7za, `-x` for native zip).\n */\nfunction buildExcludeArgs(excluded: Array<string> | null | undefined, prefix: string): Array<string> {\n if (excluded == null) {\n return []\n }\n return excluded.map(mask => {\n if (mask.includes(\"..\")) {\n throw new Error(`Excluded archive pattern contains path traversal sequence: \"${mask}\"`)\n }\n return `${prefix}${mask}`\n })\n}\n\nexport function compute7zCompressArgs(format: string, options: ArchiveOptions = {}) {\n let storeOnly = options.compression === \"store\"\n const args = debug7zArgs(\"a\")\n\n const compressionLevel = process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL\n if (compressionLevel != null) {\n validateCompressionLevel(compressionLevel)\n storeOnly = false // env var overrides \"store\" config\n args.push(`-mx=${compressionLevel}`)\n } else if (storeOnly) {\n // -mx=0 is the universal \"no compression\" flag across all formats (zip, 7z, gzip, xz, bzip2).\n // -mm=Copy would only be valid for zip/7z and causes E_INVALIDARG on xz/gzip/bzip2.\n args.push(\"-mx=0\")\n } else {\n const isZip = format === \"zip\"\n // ZIP uses level 7 by default; everything else (7z, gzip, xz, bzip2) uses level 9\n args.push(\"-mx=\" + (isZip && options.compression !== \"maximum\" ? \"7\" : \"9\"))\n if (isZip && options.compression === \"maximum\") {\n // http://superuser.com/a/742034\n args.push(\"-mfb=258\", \"-mpass=15\")\n }\n }\n\n if (options.dictSize != null) {\n args.push(`-md=${options.dictSize}m`)\n }\n\n // Disable NTFS timestamps for reproducible archives\n if (!options.isRegularFile) {\n args.push(\"-mtc=off\")\n }\n\n if (format === \"7z\" || format.endsWith(\".7z\")) {\n if (options.solid === false) {\n args.push(\"-ms=off\")\n }\n\n if (options.isArchiveHeaderCompressed === false) {\n args.push(\"-mhc=off\")\n }\n\n // Branch/exec filter selection. installTimeDecodable archives are unpacked by the self-vendored\n // Nsis7z extractor, whose decoder only understands plain LZMA2/Copy and the single-stream BCJ\n // filter — not the CPU branch converters modern 7za auto-applies (BCJ2 on x86/x64, ARM64 on\n // arm64). So pin them to BCJ while compressing (the best filter that decoder can read; Copy\n // needs none) and do not honor ELECTRON_BUILDER_7Z_FILTER, which could reintroduce an unreadable\n // archive. Any other 7z archive may use ELECTRON_BUILDER_7Z_FILTER, else 7za's auto-selection.\n if (options.installTimeDecodable) {\n if (!storeOnly) {\n args.push(\"-mf=BCJ\")\n }\n } else {\n const sevenZFilter = process.env.ELECTRON_BUILDER_7Z_FILTER\n if (sevenZFilter) {\n const canonicalFilter = sevenZFilter.toUpperCase()\n if (!ALLOWED_7Z_FILTERS.has(canonicalFilter)) {\n throw new Error(`ELECTRON_BUILDER_7Z_FILTER must be one of: ${[...ALLOWED_7Z_FILTERS].join(\", \")}`)\n }\n args.push(`-mf=${canonicalFilter}`)\n }\n }\n\n args.push(\"-mtm=off\", \"-mta=off\")\n }\n\n if (options.method != null && options.method !== \"DEFAULT\") {\n args.push(`-mm=${options.method}`)\n } else if (format === \"zip\") {\n // -mm is only set explicitly for zip (Deflate/Copy) and includes the UTF-8 flag.\n // For all other formats the codec is implicit from the output file extension.\n args.push(`-mm=${storeOnly ? \"Copy\" : \"Deflate\"}`)\n args.push(\"-mcu\")\n }\n\n return args\n}\n\n// 7z is very fast, so, use ultra compression\n/** @internal */\nexport async function archive(format: string, outFile: string, dirToArchive: string, options: ArchiveOptions = {}): Promise<string> {\n const outFileStat = await statOrNull(outFile)\n const dirStat = await statOrNull(dirToArchive)\n if (outFileStat && dirStat && outFileStat.mtime > dirStat.mtime) {\n log.info({ reason: \"Archive file is up to date\", outFile }, `skipped archiving`)\n return outFile\n }\n\n // Use 7za for all formats (matches pre-26.15 behavior). Native macOS `zip` is only a\n // fallback for NFD-normalized filenames, which 7za mangles.\n let use7z = true\n if (process.platform === \"darwin\" && format === \"zip\" && dirToArchive.normalize(\"NFC\") !== dirToArchive) {\n log.warn({ reason: \"7z doesn't support NFD-normalized filenames\" }, `using zip`)\n use7z = false\n }\n\n if (use7z) {\n const args = compute7zCompressArgs(format, options)\n // Modern 7-Zip (24.09) dereferences symlinks by default; the 7-Zip 16.02 bundled before\n // 26.15 stored them as links. Without -snl, a macOS .framework `Versions/Current` extracts\n // as a real directory → codesign \"bundle format is ambiguous\" → breaks Squirrel.Mac\n // auto-update (#9846). Callers enable it for all non-Windows targets (see ArchiveTarget).\n if (options.preserveSymlinks) {\n args.push(\"-snl\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n args.push(...buildExcludeArgs(options.excluded, \"-xr!\"))\n\n try {\n await exec(await getPath7za(), args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n } catch (e: any) {\n if (e.code === \"ENOENT\" && !(await exists(dirToArchive))) {\n throw new Error(`Cannot create archive: \"${dirToArchive}\" doesn't exist`)\n } else {\n throw e\n }\n }\n } else {\n // macOS native zip (NFD fallback): -y preserves symlinks\n const args = [\"-q\", \"-r\", \"-y\"]\n if (debug7z.enabled) {\n args.push(\"-v\")\n }\n if (options.compression === \"store\") {\n args.push(\"-0\")\n } else {\n args.push(options.compression === \"maximum\" ? \"-9\" : \"-7\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n args.push(...buildExcludeArgs(options.excluded, \"-x\"))\n await exec(\"zip\", args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n }\n\n return outFile\n}\n\nfunction debug7zArgs(command: \"a\" | \"x\"): Array<string> {\n const args = [command, \"-bd\"]\n if (debug7z.enabled) {\n args.push(\"-bb\")\n }\n return args\n}\n"]}
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Latest TypeScript types for snapcraft.yaml
3
+ * Focuses on the most common Core24 configuration
4
+ * Based on https://snapcraft.io/docs/snapcraft-yaml-reference
5
+ * npm install -g json-schema-to-typescript
6
+ * curl -o snapcraft-schema.json https://raw.githubusercontent.com/canonical/snapcraft/refs/heads/main/schema/snapcraft.json
7
+ * npx json2ts -i snapcraft-schema.json -o snapcraft.ts
8
+ * (manual edits to simplify and make more strict)
9
+ */
10
+ export interface SnapcraftYAML {
11
+ /** The identifying name of the snap */
12
+ name: string;
13
+ /** The baseline system that the snap is built in */
14
+ base: "core22" | "core24" | "core26" | "bare" | "devel";
15
+ /** The amount of isolation the snap has from the host system */
16
+ confinement: "classic" | "devmode" | "strict";
17
+ /** The self-contained software pieces needed to create the final artifact */
18
+ parts: Record<string, Part>;
19
+ version?: string;
20
+ title?: string;
21
+ /** A short description of the project (max 78 chars) */
22
+ summary?: string;
23
+ description?: string;
24
+ grade?: "stable" | "devel";
25
+ /** The project's license as an SPDX expression */
26
+ license?: string;
27
+ /** The path to the snap's icon file */
28
+ icon?: string;
29
+ /** The baseline system that the snap is built in */
30
+ "build-base"?: string;
31
+ /** The platforms where the snap can be built and run (core24+) */
32
+ platforms?: Record<string, Platform>;
33
+ /** The architectures that the snap builds and runs on (core22 and earlier) */
34
+ architectures?: (string | Architecture)[];
35
+ /** Specifies the algorithm that compresses the snap */
36
+ compression?: "lzo" | "xz";
37
+ /** The individual programs and services that the snap runs */
38
+ apps?: Record<string, App>;
39
+ /** Declares the snap's plugs */
40
+ plugs?: Record<string, unknown>;
41
+ /** Declares the snap's slots */
42
+ slots?: Record<string, unknown>;
43
+ /** Configures the snap's hooks */
44
+ hooks?: Record<string, Hook>;
45
+ /** The file layouts in the execution environment */
46
+ layout?: Record<string, Record<string, string>>;
47
+ /** The snap's runtime environment variables */
48
+ environment?: Record<string, string | null>;
49
+ /** The minimum version of snapd and features the snap requires */
50
+ assumes?: string[];
51
+ /** The epoch associated with this version of the snap */
52
+ epoch?: string;
53
+ /** The package repositories to use for build and stage packages */
54
+ "package-repositories"?: Array<Record<string, unknown>>;
55
+ /** Selects a part to inherit metadata from */
56
+ "adopt-info"?: string;
57
+ /** The system usernames the snap can use */
58
+ "system-usernames"?: Record<string, unknown>;
59
+ /** Ubuntu Pro services to enable when building */
60
+ "ua-services"?: string[];
61
+ /** The linter configuration settings */
62
+ lint?: {
63
+ ignore: (string | Record<string, string[]>)[];
64
+ };
65
+ /** Components to build in conjunction with the snap */
66
+ components?: Record<string, Component>;
67
+ /** Snap type */
68
+ type?: "app" | "gadget" | "base" | "kernel" | "snapd";
69
+ /** Attributes to pass to snap's metadata file */
70
+ passthrough?: Record<string, unknown>;
71
+ /** The snap author's contact links and email addresses */
72
+ contact?: string | string[];
73
+ /** Links for submitting issues, bugs, and feature requests */
74
+ issues?: string | string[];
75
+ /** Links to the source code */
76
+ "source-code"?: string | string[];
77
+ /** The snap's donation links */
78
+ donation?: string | string[];
79
+ /** Links to the original software's web pages */
80
+ website?: string | string[];
81
+ /** Primary-key header for snaps signed by third parties */
82
+ provenance?: string;
83
+ }
84
+ export interface Part {
85
+ /** Plugin to use for building */
86
+ plugin: string;
87
+ source?: string;
88
+ "source-type"?: "git" | "bzr" | "hg" | "svn" | "tar" | "zip" | "7z" | "deb" | "rpm" | "local";
89
+ "source-branch"?: string;
90
+ "source-tag"?: string;
91
+ "source-commit"?: string;
92
+ "source-depth"?: number;
93
+ "source-subdir"?: string;
94
+ "source-checksum"?: string;
95
+ "build-packages"?: string[];
96
+ "stage-packages"?: string[];
97
+ "build-snaps"?: string[];
98
+ "stage-snaps"?: string[];
99
+ "build-environment"?: Array<Record<string, string>>;
100
+ "override-build"?: string;
101
+ "override-pull"?: string;
102
+ "override-stage"?: string;
103
+ "override-prime"?: string;
104
+ organize?: Record<string, string>;
105
+ stage?: string[];
106
+ prime?: string[];
107
+ after?: string[];
108
+ }
109
+ export interface Platform {
110
+ /** The architectures to build the snap on */
111
+ "build-on"?: string | string[];
112
+ /** The target architecture for the build */
113
+ "build-for"?: string | string[];
114
+ }
115
+ export interface Architecture {
116
+ /** The architectures to build the snap on */
117
+ "build-on": string | string[];
118
+ /** The target architecture for the build */
119
+ "build-for"?: string | string[];
120
+ }
121
+ export interface App {
122
+ /** The command to run inside the snap when invoked */
123
+ command: string;
124
+ /** The extensions to add to the app (e.g., 'gnome', 'kde-neon') */
125
+ extensions?: string[];
126
+ /** The interfaces that the app can connect to */
127
+ plugs?: string[];
128
+ /** The list of slots that the app provides */
129
+ slots?: string[];
130
+ /** Configures the app as a service */
131
+ daemon?: "simple" | "forking" | "oneshot" | "notify" | "dbus";
132
+ "daemon-scope"?: "system" | "user";
133
+ after?: string[];
134
+ before?: string[];
135
+ "refresh-mode"?: "endure" | "restart" | "ignore-running";
136
+ "stop-mode"?: "sigterm" | "sigterm-all" | "sighup" | "sighup-all" | "sigusr1" | "sigusr1-all" | "sigusr2" | "sigusr2-all" | "sigint" | "sigint-all";
137
+ "restart-condition"?: "on-success" | "on-failure" | "on-abnormal" | "on-abort" | "on-watchdog" | "always" | "never";
138
+ "install-mode"?: "enable" | "disable";
139
+ "stop-command"?: string;
140
+ "post-stop-command"?: string;
141
+ "reload-command"?: string;
142
+ "start-timeout"?: string;
143
+ "stop-timeout"?: string;
144
+ "watchdog-timeout"?: string;
145
+ "restart-delay"?: string;
146
+ desktop?: string;
147
+ autostart?: string;
148
+ "common-id"?: string;
149
+ completer?: string;
150
+ "bus-name"?: string;
151
+ "activates-on"?: string[];
152
+ sockets?: Record<string, Socket>;
153
+ timer?: string;
154
+ environment?: Record<string, string>;
155
+ "command-chain"?: string[];
156
+ aliases?: string[];
157
+ "success-exit-status"?: number[];
158
+ passthrough?: Record<string, unknown>;
159
+ }
160
+ export interface Socket {
161
+ /** The socket's abstract name or socket path */
162
+ "listen-stream": number | string;
163
+ /** The mode or permissions of the socket in octal */
164
+ "socket-mode"?: number;
165
+ }
166
+ export interface Hook {
167
+ /** The ordered list of commands to run before the hook runs */
168
+ "command-chain"?: string[];
169
+ /** The environment variables for the hook */
170
+ environment?: Record<string, string | null>;
171
+ /** The list of interfaces that the hook can connect to */
172
+ plugs?: string[];
173
+ /** Attributes to pass to snap's metadata file for the hook */
174
+ passthrough?: Record<string, unknown>;
175
+ }
176
+ export interface Component {
177
+ /** The summary of the component */
178
+ summary: string;
179
+ /** The full description of the component */
180
+ description: string;
181
+ /** The type of the component */
182
+ type: "test" | "kernel-modules" | "standard";
183
+ /** The version of the component */
184
+ version?: string;
185
+ /** The configuration for the component's hooks */
186
+ hooks?: Record<string, Hook>;
187
+ /** Selects a part to inherit metadata from */
188
+ "adopt-info"?: string;
189
+ }
190
+ //# sourceMappingURL=snapcraft.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapcraft.d.ts","sourceRoot":"","sources":["../../../../src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,CAAA;IAC3C,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACtC;AAGD,MAAM,WAAW,SAAS;IACxB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAA;IACnB,gCAAgC;IAChC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,UAAU,CAAA;IAC5C,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC5B,8CAA8C;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Latest TypeScript types for snapcraft.yaml
3
+ * Focuses on the most common Core24 configuration
4
+ * Based on https://snapcraft.io/docs/snapcraft-yaml-reference
5
+ * npm install -g json-schema-to-typescript
6
+ * curl -o snapcraft-schema.json https://raw.githubusercontent.com/canonical/snapcraft/refs/heads/main/schema/snapcraft.json
7
+ * npx json2ts -i snapcraft-schema.json -o snapcraft.ts
8
+ * (manual edits to simplify and make more strict)
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=snapcraft.js.map