app-builder-lib 27.0.0-alpha.12 → 27.0.0-alpha.14

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 (259) hide show
  1. package/dist/asar/asarUtil.js +1 -1
  2. package/dist/asar/asarUtil.js.map +1 -1
  3. package/dist/codeSign/certInfo.d.ts +4 -1
  4. package/dist/codeSign/certInfo.d.ts.map +1 -1
  5. package/dist/codeSign/certInfo.js +5 -3
  6. package/dist/codeSign/certInfo.js.map +1 -1
  7. package/dist/codeSign/forceCodeSigning.d.ts +22 -0
  8. package/dist/codeSign/forceCodeSigning.d.ts.map +1 -0
  9. package/dist/codeSign/forceCodeSigning.js +18 -0
  10. package/dist/codeSign/forceCodeSigning.js.map +1 -0
  11. package/dist/codeSign/mac/macCodeSign.d.ts +13 -1
  12. package/dist/codeSign/mac/macCodeSign.d.ts.map +1 -1
  13. package/dist/codeSign/mac/macCodeSign.js +29 -2
  14. package/dist/codeSign/mac/macCodeSign.js.map +1 -1
  15. package/dist/codeSign/mac/macSignatureVerifier.d.ts +23 -0
  16. package/dist/codeSign/mac/macSignatureVerifier.d.ts.map +1 -0
  17. package/dist/codeSign/mac/macSignatureVerifier.js +96 -0
  18. package/dist/codeSign/mac/macSignatureVerifier.js.map +1 -0
  19. package/dist/codeSign/win/authenticodeSignature.d.ts +14 -2
  20. package/dist/codeSign/win/authenticodeSignature.d.ts.map +1 -1
  21. package/dist/codeSign/win/authenticodeSignature.js +78 -30
  22. package/dist/codeSign/win/authenticodeSignature.js.map +1 -1
  23. package/dist/codeSign/win/pkcs11SignManager.d.ts.map +1 -1
  24. package/dist/codeSign/win/pkcs11SignManager.js +4 -3
  25. package/dist/codeSign/win/pkcs11SignManager.js.map +1 -1
  26. package/dist/codeSign/win/publisherName.d.ts +31 -0
  27. package/dist/codeSign/win/publisherName.d.ts.map +1 -0
  28. package/dist/codeSign/win/publisherName.js +78 -0
  29. package/dist/codeSign/win/publisherName.js.map +1 -0
  30. package/dist/codeSign/win/signtoolBaseSignManager.d.ts +16 -9
  31. package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -1
  32. package/dist/codeSign/win/signtoolBaseSignManager.js +46 -35
  33. package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -1
  34. package/dist/codeSign/win/verifyUpdatePublisher.d.ts.map +1 -1
  35. package/dist/codeSign/win/verifyUpdatePublisher.js +7 -4
  36. package/dist/codeSign/win/verifyUpdatePublisher.js.map +1 -1
  37. package/dist/codeSign/win/windowsSignAzureManager.d.ts +1 -1
  38. package/dist/codeSign/win/windowsSignAzureManager.d.ts.map +1 -1
  39. package/dist/codeSign/win/windowsSignAzureManager.js +24 -6
  40. package/dist/codeSign/win/windowsSignAzureManager.js.map +1 -1
  41. package/dist/configuration.d.ts +93 -4
  42. package/dist/configuration.d.ts.map +1 -1
  43. package/dist/configuration.js.map +1 -1
  44. package/dist/electron/mac/asarIntegrityDigest.js +2 -2
  45. package/dist/electron/mac/asarIntegrityDigest.js.map +1 -1
  46. package/dist/electron/mac/electronMacUtils.d.ts +3 -2
  47. package/dist/electron/mac/electronMacUtils.d.ts.map +1 -1
  48. package/dist/electron/mac/electronMacUtils.js +3 -2
  49. package/dist/electron/mac/electronMacUtils.js.map +1 -1
  50. package/dist/fileMatcher.d.ts.map +1 -1
  51. package/dist/fileMatcher.js +4 -2
  52. package/dist/fileMatcher.js.map +1 -1
  53. package/dist/index.d.ts +1 -1
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +4 -3
  56. package/dist/index.js.map +1 -1
  57. package/dist/indexInternal.d.ts +7 -2
  58. package/dist/indexInternal.d.ts.map +1 -1
  59. package/dist/indexInternal.js +6 -2
  60. package/dist/indexInternal.js.map +1 -1
  61. package/dist/linuxPackager.js +1 -1
  62. package/dist/linuxPackager.js.map +1 -1
  63. package/dist/macPackager.d.ts +26 -0
  64. package/dist/macPackager.d.ts.map +1 -1
  65. package/dist/macPackager.js +168 -12
  66. package/dist/macPackager.js.map +1 -1
  67. package/dist/options/PlatformSpecificBuildOptions.d.ts +19 -13
  68. package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
  69. package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
  70. package/dist/options/SquirrelWindowsOptions.d.ts +3 -0
  71. package/dist/options/SquirrelWindowsOptions.d.ts.map +1 -1
  72. package/dist/options/SquirrelWindowsOptions.js.map +1 -1
  73. package/dist/options/macOptions.d.ts +7 -2
  74. package/dist/options/macOptions.d.ts.map +1 -1
  75. package/dist/options/macOptions.js.map +1 -1
  76. package/dist/options/winOptions.d.ts +61 -15
  77. package/dist/options/winOptions.d.ts.map +1 -1
  78. package/dist/options/winOptions.js +20 -0
  79. package/dist/options/winOptions.js.map +1 -1
  80. package/dist/packager.d.ts +7 -0
  81. package/dist/packager.d.ts.map +1 -1
  82. package/dist/packager.js +21 -5
  83. package/dist/packager.js.map +1 -1
  84. package/dist/platformPackager.d.ts +14 -5
  85. package/dist/platformPackager.d.ts.map +1 -1
  86. package/dist/platformPackager.js +44 -13
  87. package/dist/platformPackager.js.map +1 -1
  88. package/dist/publish/PublishManager.d.ts +3 -0
  89. package/dist/publish/PublishManager.d.ts.map +1 -1
  90. package/dist/publish/PublishManager.js +50 -16
  91. package/dist/publish/PublishManager.js.map +1 -1
  92. package/dist/publish/manifestUploadCheck.d.ts +10 -0
  93. package/dist/publish/manifestUploadCheck.d.ts.map +1 -0
  94. package/dist/publish/manifestUploadCheck.js +75 -0
  95. package/dist/publish/manifestUploadCheck.js.map +1 -0
  96. package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
  97. package/dist/publish/updateInfoBuilder.js +58 -22
  98. package/dist/publish/updateInfoBuilder.js.map +1 -1
  99. package/dist/publish/updateManifestVerifier.d.ts +22 -0
  100. package/dist/publish/updateManifestVerifier.d.ts.map +1 -0
  101. package/dist/publish/updateManifestVerifier.js +65 -0
  102. package/dist/publish/updateManifestVerifier.js.map +1 -0
  103. package/dist/targets/ArchiveTarget.d.ts.map +1 -1
  104. package/dist/targets/ArchiveTarget.js +6 -2
  105. package/dist/targets/ArchiveTarget.js.map +1 -1
  106. package/dist/targets/archive.d.ts.map +1 -1
  107. package/dist/targets/archive.js +3 -3
  108. package/dist/targets/archive.js.map +1 -1
  109. package/dist/targets/blockmap/blockmap.d.ts +30 -0
  110. package/dist/targets/blockmap/blockmap.d.ts.map +1 -1
  111. package/dist/targets/blockmap/blockmap.js +99 -31
  112. package/dist/targets/blockmap/blockmap.js.map +1 -1
  113. package/dist/targets/blockmap/blockmapV3.d.ts +36 -0
  114. package/dist/targets/blockmap/blockmapV3.d.ts.map +1 -0
  115. package/dist/targets/blockmap/blockmapV3.js +41 -0
  116. package/dist/targets/blockmap/blockmapV3.js.map +1 -0
  117. package/dist/targets/blockmap/verbatimRange.d.ts +6 -0
  118. package/dist/targets/blockmap/verbatimRange.d.ts.map +1 -1
  119. package/dist/targets/blockmap/verbatimRange.js +11 -0
  120. package/dist/targets/blockmap/verbatimRange.js.map +1 -1
  121. package/dist/targets/differentialUpdateInfoBuilder.d.ts +92 -4
  122. package/dist/targets/differentialUpdateInfoBuilder.d.ts.map +1 -1
  123. package/dist/targets/differentialUpdateInfoBuilder.js +266 -10
  124. package/dist/targets/differentialUpdateInfoBuilder.js.map +1 -1
  125. package/dist/targets/linux/FlatpakTarget.js +5 -5
  126. package/dist/targets/linux/FlatpakTarget.js.map +1 -1
  127. package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
  128. package/dist/targets/linux/FpmTarget.js +25 -8
  129. package/dist/targets/linux/FpmTarget.js.map +1 -1
  130. package/dist/targets/linux/LinuxTargetHelper.js +1 -1
  131. package/dist/targets/linux/LinuxTargetHelper.js.map +1 -1
  132. package/dist/targets/linux/appimage/AppImageTarget.d.ts.map +1 -1
  133. package/dist/targets/linux/appimage/AppImageTarget.js +6 -1
  134. package/dist/targets/linux/appimage/AppImageTarget.js.map +1 -1
  135. package/dist/targets/linux/appimage/appImageUtil.js +9 -9
  136. package/dist/targets/linux/appimage/appImageUtil.js.map +1 -1
  137. package/dist/targets/linux/flatpakBundle.d.ts.map +1 -1
  138. package/dist/targets/linux/flatpakBundle.js +25 -20
  139. package/dist/targets/linux/flatpakBundle.js.map +1 -1
  140. package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
  141. package/dist/targets/linux/snap/coreLegacy.js +22 -6
  142. package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
  143. package/dist/targets/linux/snap/snapPlugs.d.ts +2 -2
  144. package/dist/targets/linux/snap/snapPlugs.d.ts.map +1 -1
  145. package/dist/targets/linux/snap/snapPlugs.js +1 -1
  146. package/dist/targets/linux/snap/snapPlugs.js.map +1 -1
  147. package/dist/targets/linux/snap/snapcraftBuilder.d.ts.map +1 -1
  148. package/dist/targets/linux/snap/snapcraftBuilder.js +19 -17
  149. package/dist/targets/linux/snap/snapcraftBuilder.js.map +1 -1
  150. package/dist/targets/mac/MacTargetHelper.d.ts +15 -3
  151. package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
  152. package/dist/targets/mac/MacTargetHelper.js +96 -13
  153. package/dist/targets/mac/MacTargetHelper.js.map +1 -1
  154. package/dist/targets/mac/pkg.d.ts.map +1 -1
  155. package/dist/targets/mac/pkg.js +7 -5
  156. package/dist/targets/mac/pkg.js.map +1 -1
  157. package/dist/targets/targetFactory.d.ts +1 -1
  158. package/dist/targets/targetFactory.d.ts.map +1 -1
  159. package/dist/targets/targetFactory.js +22 -0
  160. package/dist/targets/targetFactory.js.map +1 -1
  161. package/dist/targets/win/MsiTarget.d.ts +7 -0
  162. package/dist/targets/win/MsiTarget.d.ts.map +1 -1
  163. package/dist/targets/win/MsiTarget.js +140 -21
  164. package/dist/targets/win/MsiTarget.js.map +1 -1
  165. package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
  166. package/dist/targets/win/nsis/NsisTarget.js +22 -8
  167. package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
  168. package/dist/targets/win/nsis/nsisOptions.d.ts +1 -1
  169. package/dist/targets/win/nsis/nsisOptions.js.map +1 -1
  170. package/dist/toolsets/appimage.d.ts +3 -0
  171. package/dist/toolsets/appimage.d.ts.map +1 -1
  172. package/dist/toolsets/appimage.js +4 -1
  173. package/dist/toolsets/appimage.js.map +1 -1
  174. package/dist/toolsets/nsis.js +1 -1
  175. package/dist/toolsets/nsis.js.map +1 -1
  176. package/dist/toolsets/wine.d.ts +3 -0
  177. package/dist/toolsets/wine.d.ts.map +1 -1
  178. package/dist/toolsets/wine.js +14 -5
  179. package/dist/toolsets/wine.js.map +1 -1
  180. package/dist/toolsets/wix.d.ts +44 -0
  181. package/dist/toolsets/wix.d.ts.map +1 -0
  182. package/dist/toolsets/wix.js +91 -0
  183. package/dist/toolsets/wix.js.map +1 -0
  184. package/dist/util/appFileCopier.d.ts.map +1 -1
  185. package/dist/util/appFileCopier.js +9 -3
  186. package/dist/util/appFileCopier.js.map +1 -1
  187. package/dist/util/buildOutputVerifier.d.ts +40 -0
  188. package/dist/util/buildOutputVerifier.d.ts.map +1 -0
  189. package/dist/util/buildOutputVerifier.js +420 -0
  190. package/dist/util/buildOutputVerifier.js.map +1 -0
  191. package/dist/util/config/fileOptions.js +2 -2
  192. package/dist/util/config/fileOptions.js.map +1 -1
  193. package/dist/util/config/legacyConfigGuard.d.ts.map +1 -1
  194. package/dist/util/config/legacyConfigGuard.js +2 -2
  195. package/dist/util/config/legacyConfigGuard.js.map +1 -1
  196. package/dist/util/config/legacyOptions.d.ts +9 -2
  197. package/dist/util/config/legacyOptions.d.ts.map +1 -1
  198. package/dist/util/config/legacyOptions.js +8 -2
  199. package/dist/util/config/legacyOptions.js.map +1 -1
  200. package/dist/util/electronGet.d.ts.map +1 -1
  201. package/dist/util/electronGet.js +3 -1
  202. package/dist/util/electronGet.js.map +1 -1
  203. package/dist/util/electronUpdaterCompatibility.d.ts +43 -0
  204. package/dist/util/electronUpdaterCompatibility.d.ts.map +1 -0
  205. package/dist/util/electronUpdaterCompatibility.js +53 -0
  206. package/dist/util/electronUpdaterCompatibility.js.map +1 -0
  207. package/dist/util/flags.d.ts.map +1 -1
  208. package/dist/util/flags.js +3 -9
  209. package/dist/util/flags.js.map +1 -1
  210. package/dist/util/mac/macosIconComposer.d.ts.map +1 -1
  211. package/dist/util/mac/macosIconComposer.js +6 -5
  212. package/dist/util/mac/macosIconComposer.js.map +1 -1
  213. package/dist/util/macroExpander.js +1 -1
  214. package/dist/util/macroExpander.js.map +1 -1
  215. package/dist/util/nativeBinaryVerifier.d.ts.map +1 -1
  216. package/dist/util/nativeBinaryVerifier.js +3 -1
  217. package/dist/util/nativeBinaryVerifier.js.map +1 -1
  218. package/dist/util/packageMetadata.js +116 -52
  219. package/dist/util/packageMetadata.js.map +1 -1
  220. package/dist/util/removedEnvVars.d.ts +2 -0
  221. package/dist/util/removedEnvVars.d.ts.map +1 -1
  222. package/dist/util/removedEnvVars.js +15 -1
  223. package/dist/util/removedEnvVars.js.map +1 -1
  224. package/dist/util/streamSpawnToFile.d.ts +3 -1
  225. package/dist/util/streamSpawnToFile.d.ts.map +1 -1
  226. package/dist/util/streamSpawnToFile.js +6 -2
  227. package/dist/util/streamSpawnToFile.js.map +1 -1
  228. package/dist/version.d.ts +1 -1
  229. package/dist/version.js +1 -1
  230. package/dist/version.js.map +1 -1
  231. package/dist/vm/ParallelsVm.d.ts +10 -0
  232. package/dist/vm/ParallelsVm.d.ts.map +1 -1
  233. package/dist/vm/ParallelsVm.js +22 -8
  234. package/dist/vm/ParallelsVm.js.map +1 -1
  235. package/dist/vm/PwshVm.d.ts +0 -1
  236. package/dist/vm/PwshVm.d.ts.map +1 -1
  237. package/dist/vm/PwshVm.js +10 -15
  238. package/dist/vm/PwshVm.js.map +1 -1
  239. package/dist/vm/WineVm.d.ts.map +1 -1
  240. package/dist/vm/WineVm.js +4 -4
  241. package/dist/vm/WineVm.js.map +1 -1
  242. package/dist/vm/vm.d.ts +9 -3
  243. package/dist/vm/vm.d.ts.map +1 -1
  244. package/dist/vm/vm.js +40 -32
  245. package/dist/vm/vm.js.map +1 -1
  246. package/dist/winPackager.d.ts +16 -1
  247. package/dist/winPackager.d.ts.map +1 -1
  248. package/dist/winPackager.js +77 -19
  249. package/dist/winPackager.js.map +1 -1
  250. package/package.json +9 -9
  251. package/scheme.json +542 -29
  252. package/templates/msi/template.xml +5 -5
  253. package/templates/msiWrapped/template.xml +1 -1
  254. package/templates/nsis/assistedInstaller.nsh +32 -1
  255. package/templates/nsis/include/allowOnlyOneInstallerInstance.nsh +14 -9
  256. package/dist/vm/MonoVm.d.ts +0 -9
  257. package/dist/vm/MonoVm.d.ts.map +0 -1
  258. package/dist/vm/MonoVm.js +0 -16
  259. package/dist/vm/MonoVm.js.map +0 -1
@@ -15,6 +15,8 @@ interface RemovedEnvVar {
15
15
  * not a signal — the removed `"release"` auto-publish behavior is covered in the migration docs).
16
16
  */
17
17
  export declare const REMOVED_ENV_VARS: ReadonlyArray<RemovedEnvVar>;
18
+ /** The section of the v27 build-changes page that documents a removed environment variable. */
19
+ export declare function removedEnvVarDocsUrl(name: string): string;
18
20
  /**
19
21
  * Logs a one-time deprecation warning for every {@link REMOVED_ENV_VARS} entry still present in the
20
22
  * environment. Called once per build (from the {@link Packager} constructor) so both the CLI and the
@@ -1 +1 @@
1
- {"version":3,"file":"removedEnvVars.d.ts","sourceRoot":"","sources":["../../src/util/removedEnvVars.ts"],"names":[],"mappings":"AAEA,UAAU,aAAa;IACrB,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,gEAAgE;IAChE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,aAAa,CAgCzD,CAAA;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,IAAI,CAM/E"}
1
+ {"version":3,"file":"removedEnvVars.d.ts","sourceRoot":"","sources":["../../src/util/removedEnvVars.ts"],"names":[],"mappings":"AAGA,UAAU,aAAa;IACrB,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,gEAAgE;IAChE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,aAAa,CAgCzD,CAAA;AAED,+FAA+F;AAC/F,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWzD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,IAAI,CAM/E"}
@@ -1,4 +1,5 @@
1
1
  import { log } from "builder-util";
2
+ import { BUILD_CHANGES_URL } from "./config/legacyOptions.js";
2
3
  /**
3
4
  * Environment variables that were honored in electron-builder v26 but were removed in v27. When a
4
5
  * project upgrades from v26 and still has one of these set, the build silently ignores it — the
@@ -39,6 +40,19 @@ export const REMOVED_ENV_VARS = [
39
40
  remediation: `electron-builder in \`dependencies\` no longer errors and is excluded from the packaged app by default — remove this variable, and use the \`ignoredProductionDependencies\` option to customize exclusions.`,
40
41
  },
41
42
  ];
43
+ /** The section of the v27 build-changes page that documents a removed environment variable. */
44
+ export function removedEnvVarDocsUrl(name) {
45
+ switch (name) {
46
+ case "CI_BUILD_TAG":
47
+ return `${BUILD_CHANGES_URL}#ci_build_tag-environment-variable`;
48
+ case "ELECTRON_BUILDER_BINARIES_ALLOW_HTTP":
49
+ return `${BUILD_CHANGES_URL}#electron_builder_binaries_allow_http-renamed`;
50
+ case "ALLOW_ELECTRON_BUILDER_AS_PRODUCTION_DEPENDENCY":
51
+ return `${BUILD_CHANGES_URL}#allow_electron_builder_as_production_dependency-is-removed-and-the-default-flipped`;
52
+ default:
53
+ return `${BUILD_CHANGES_URL}#toolset-env-var-overrides-removed`;
54
+ }
55
+ }
42
56
  /**
43
57
  * Logs a one-time deprecation warning for every {@link REMOVED_ENV_VARS} entry still present in the
44
58
  * environment. Called once per build (from the {@link Packager} constructor) so both the CLI and the
@@ -47,7 +61,7 @@ export const REMOVED_ENV_VARS = [
47
61
  export function warnOnRemovedEnvVars(env = process.env) {
48
62
  for (const { name, remediation } of REMOVED_ENV_VARS) {
49
63
  if (env[name] != null) {
50
- log.warn({ envVar: name }, `environment variable was removed in electron-builder v27 and no longer has any effect — ${remediation}`);
64
+ log.warn({ envVar: name, docs: removedEnvVarDocsUrl(name) }, `environment variable was removed in electron-builder v27 and no longer has any effect — ${remediation}`);
51
65
  }
52
66
  }
53
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"removedEnvVars.js","sourceRoot":"","sources":["../../src/util/removedEnvVars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AASlC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAiC;IAC5D,yHAAyH;IACzH,EAAE,IAAI,EAAE,qBAAqB,EAAE,WAAW,EAAE,oEAAoE,EAAE;IAClH,EAAE,IAAI,EAAE,iBAAiB,EAAE,WAAW,EAAE,uIAAuI,EAAE;IACjL,EAAE,IAAI,EAAE,sBAAsB,EAAE,WAAW,EAAE,yEAAyE,EAAE;IACxH,EAAE,IAAI,EAAE,iBAAiB,EAAE,WAAW,EAAE,+DAA+D,EAAE;IACzG,EAAE,IAAI,EAAE,2BAA2B,EAAE,WAAW,EAAE,gEAAgE,EAAE;IACpH,EAAE,IAAI,EAAE,qCAAqC,EAAE,WAAW,EAAE,gEAAgE,EAAE;IAC9H,EAAE,IAAI,EAAE,uBAAuB,EAAE,WAAW,EAAE,gEAAgE,EAAE;IAChH,EAAE,IAAI,EAAE,mCAAmC,EAAE,WAAW,EAAE,gEAAgE,EAAE;IAC5H,EAAE,IAAI,EAAE,4BAA4B,EAAE,WAAW,EAAE,oEAAoE,EAAE;IACzH,EAAE,IAAI,EAAE,oCAAoC,EAAE,WAAW,EAAE,iEAAiE,EAAE;IAC9H,EAAE,IAAI,EAAE,qCAAqC,EAAE,WAAW,EAAE,uEAAuE,EAAE;IACrI,EAAE,IAAI,EAAE,8BAA8B,EAAE,WAAW,EAAE,uEAAuE,EAAE;IAC9H,EAAE,IAAI,EAAE,oCAAoC,EAAE,WAAW,EAAE,uEAAuE,EAAE;IACpI,EAAE,IAAI,EAAE,eAAe,EAAE,WAAW,EAAE,6EAA6E,EAAE;IAErH,0GAA0G;IAC1G,EAAE,IAAI,EAAE,iBAAiB,EAAE,WAAW,EAAE,4HAA4H,EAAE;IACtK,EAAE,IAAI,EAAE,qBAAqB,EAAE,WAAW,EAAE,6EAA6E,EAAE;IAC3H,EAAE,IAAI,EAAE,yBAAyB,EAAE,WAAW,EAAE,6EAA6E,EAAE;IAC/H,EAAE,IAAI,EAAE,gBAAgB,EAAE,WAAW,EAAE,2GAA2G,EAAE;IAEpJ,sDAAsD;IACtD,EAAE,IAAI,EAAE,sCAAsC,EAAE,WAAW,EAAE,+DAA+D,EAAE;IAC9H,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,kEAAkE,EAAE;IAEzG,+DAA+D;IAC/D;QACE,IAAI,EAAE,iDAAiD;QACvD,WAAW,EAAE,8MAA8M;KAC5N;CACF,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACvE,KAAK,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,gBAAgB,EAAE,CAAC;QACrD,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;YACtB,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,2FAA2F,WAAW,EAAE,CAAC,CAAA;QACtI,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { log } from \"builder-util\"\n\ninterface RemovedEnvVar {\n /** The environment variable that was read in v26 but is no longer read in v27. */\n readonly name: string\n /** What to use instead, appended to the deprecation warning. */\n readonly remediation: string\n}\n\n/**\n * Environment variables that were honored in electron-builder v26 but were removed in v27. When a\n * project upgrades from v26 and still has one of these set, the build silently ignores it — the\n * `process.env` read was deleted, so there is no other signal. {@link warnOnRemovedEnvVars} scans\n * the environment once per build and logs a deprecation warning with the remediation.\n *\n * Deliberately excluded: internal/test-only variables that end users never set (`JEST_WORKER_ID`,\n * `TEST_SET_BABEL_PRESET`), and `npm_lifecycle_event` (npm sets it for every script, so presence is\n * not a signal — the removed `\"release\"` auto-publish behavior is covered in the migration docs).\n */\nexport const REMOVED_ENV_VARS: ReadonlyArray<RemovedEnvVar> = [\n // Toolset path/dir overrides — the `resolveEnvToolsetPath` mechanism was removed; supply a ToolsetCustom object instead.\n { name: \"APPIMAGE_TOOLS_PATH\", remediation: `set \\`toolsets.appimage: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"MKSQUASHFS_PATH\", remediation: `the mksquashfs binary now ships with the appimage toolset — set \\`toolsets.appimage: { url: \"file:///path/to/dir\" }\\` to override it.` },\n { name: \"LINUX_TOOLS_MAC_PATH\", remediation: `set \\`toolsets.linuxToolsMac: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"CUSTOM_FPM_PATH\", remediation: `set \\`toolsets.fpm: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_NSIS_DIR\", remediation: `set \\`toolsets.nsis: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_NSIS_RESOURCES_DIR\", remediation: `set \\`toolsets.nsis: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"CUSTOM_NSIS_RESOURCES\", remediation: `set \\`toolsets.nsis: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_WINE_TOOLSET_DIR\", remediation: `set \\`toolsets.wine: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_7ZIP_PATH\", remediation: `set \\`toolsets.sevenZip: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_ICONS_TOOLSET_DIR\", remediation: `set \\`toolsets.icons: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_OSSL_SIGNCODE_PATH\", remediation: `set \\`toolsets.winCodeSign: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_RCEDIT_PATH\", remediation: `set \\`toolsets.winCodeSign: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_WINDOWS_KITS_PATH\", remediation: `set \\`toolsets.winCodeSign: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"SIGNTOOL_PATH\", remediation: `configure signing via \\`win.sign\\` and the \\`winCodeSign\\` toolset instead.` },\n\n // `USE_SYSTEM_*` toggles — removed with no env-var replacement; configure via the toolset/signing config.\n { name: \"USE_SYSTEM_WINE\", remediation: `Linux uses the host \\`wine\\` by default; to use a custom Wine build set \\`toolsets.wine: { url: \"file:///path/to/dir\" }\\`.` },\n { name: \"USE_SYSTEM_SIGNCODE\", remediation: `configure signing via \\`win.sign\\` and the \\`winCodeSign\\` toolset instead.` },\n { name: \"USE_SYSTEM_OSSLSIGNCODE\", remediation: `configure signing via \\`win.sign\\` and the \\`winCodeSign\\` toolset instead.` },\n { name: \"USE_SYSTEM_FPM\", remediation: `set \\`toolsets.fpm: { url: \"file:///path/to/dir\" }\\` instead (required on Windows for FPM-based targets).` },\n\n // Renamed / replaced by another environment variable.\n { name: \"ELECTRON_BUILDER_BINARIES_ALLOW_HTTP\", remediation: `use \\`ELECTRON_BUILDER_DANGEROUSLY_ALLOW_HTTP=true\\` instead.` },\n { name: \"CI_BUILD_TAG\", remediation: `use \\`CI_COMMIT_TAG\\` (the standard GitLab CI variable) instead.` },\n\n // Replaced by a configuration option (with a behavior change).\n {\n name: \"ALLOW_ELECTRON_BUILDER_AS_PRODUCTION_DEPENDENCY\",\n remediation: `electron-builder in \\`dependencies\\` no longer errors and is excluded from the packaged app by default — remove this variable, and use the \\`ignoredProductionDependencies\\` option to customize exclusions.`,\n },\n]\n\n/**\n * Logs a one-time deprecation warning for every {@link REMOVED_ENV_VARS} entry still present in the\n * environment. Called once per build (from the {@link Packager} constructor) so both the CLI and the\n * programmatic `build()` API surface the same guidance.\n */\nexport function warnOnRemovedEnvVars(env: NodeJS.ProcessEnv = process.env): void {\n for (const { name, remediation } of REMOVED_ENV_VARS) {\n if (env[name] != null) {\n log.warn({ envVar: name }, `environment variable was removed in electron-builder v27 and no longer has any effect — ${remediation}`)\n }\n }\n}\n"]}
1
+ {"version":3,"file":"removedEnvVars.js","sourceRoot":"","sources":["../../src/util/removedEnvVars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAS7D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAiC;IAC5D,yHAAyH;IACzH,EAAE,IAAI,EAAE,qBAAqB,EAAE,WAAW,EAAE,oEAAoE,EAAE;IAClH,EAAE,IAAI,EAAE,iBAAiB,EAAE,WAAW,EAAE,uIAAuI,EAAE;IACjL,EAAE,IAAI,EAAE,sBAAsB,EAAE,WAAW,EAAE,yEAAyE,EAAE;IACxH,EAAE,IAAI,EAAE,iBAAiB,EAAE,WAAW,EAAE,+DAA+D,EAAE;IACzG,EAAE,IAAI,EAAE,2BAA2B,EAAE,WAAW,EAAE,gEAAgE,EAAE;IACpH,EAAE,IAAI,EAAE,qCAAqC,EAAE,WAAW,EAAE,gEAAgE,EAAE;IAC9H,EAAE,IAAI,EAAE,uBAAuB,EAAE,WAAW,EAAE,gEAAgE,EAAE;IAChH,EAAE,IAAI,EAAE,mCAAmC,EAAE,WAAW,EAAE,gEAAgE,EAAE;IAC5H,EAAE,IAAI,EAAE,4BAA4B,EAAE,WA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oBAAoB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACvE,KAAK,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,gBAAgB,EAAE,CAAC;QACrD,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;YACtB,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,CAAC,IAAI,CAAC,EAAE,EAAE,2FAA2F,WAAW,EAAE,CAAC,CAAA;QACxK,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { log } from \"builder-util\"\nimport { BUILD_CHANGES_URL } from \"./config/legacyOptions.js\"\n\ninterface RemovedEnvVar {\n /** The environment variable that was read in v26 but is no longer read in v27. */\n readonly name: string\n /** What to use instead, appended to the deprecation warning. */\n readonly remediation: string\n}\n\n/**\n * Environment variables that were honored in electron-builder v26 but were removed in v27. When a\n * project upgrades from v26 and still has one of these set, the build silently ignores it — the\n * `process.env` read was deleted, so there is no other signal. {@link warnOnRemovedEnvVars} scans\n * the environment once per build and logs a deprecation warning with the remediation.\n *\n * Deliberately excluded: internal/test-only variables that end users never set (`JEST_WORKER_ID`,\n * `TEST_SET_BABEL_PRESET`), and `npm_lifecycle_event` (npm sets it for every script, so presence is\n * not a signal — the removed `\"release\"` auto-publish behavior is covered in the migration docs).\n */\nexport const REMOVED_ENV_VARS: ReadonlyArray<RemovedEnvVar> = [\n // Toolset path/dir overrides — the `resolveEnvToolsetPath` mechanism was removed; supply a ToolsetCustom object instead.\n { name: \"APPIMAGE_TOOLS_PATH\", remediation: `set \\`toolsets.appimage: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"MKSQUASHFS_PATH\", remediation: `the mksquashfs binary now ships with the appimage toolset — set \\`toolsets.appimage: { url: \"file:///path/to/dir\" }\\` to override it.` },\n { name: \"LINUX_TOOLS_MAC_PATH\", remediation: `set \\`toolsets.linuxToolsMac: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"CUSTOM_FPM_PATH\", remediation: `set \\`toolsets.fpm: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_NSIS_DIR\", remediation: `set \\`toolsets.nsis: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_NSIS_RESOURCES_DIR\", remediation: `set \\`toolsets.nsis: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"CUSTOM_NSIS_RESOURCES\", remediation: `set \\`toolsets.nsis: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_WINE_TOOLSET_DIR\", remediation: `set \\`toolsets.wine: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_7ZIP_PATH\", remediation: `set \\`toolsets.sevenZip: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_ICONS_TOOLSET_DIR\", remediation: `set \\`toolsets.icons: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_OSSL_SIGNCODE_PATH\", remediation: `set \\`toolsets.winCodeSign: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_RCEDIT_PATH\", remediation: `set \\`toolsets.winCodeSign: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"ELECTRON_BUILDER_WINDOWS_KITS_PATH\", remediation: `set \\`toolsets.winCodeSign: { url: \"file:///path/to/dir\" }\\` instead.` },\n { name: \"SIGNTOOL_PATH\", remediation: `configure signing via \\`win.sign\\` and the \\`winCodeSign\\` toolset instead.` },\n\n // `USE_SYSTEM_*` toggles — removed with no env-var replacement; configure via the toolset/signing config.\n { name: \"USE_SYSTEM_WINE\", remediation: `Linux uses the host \\`wine\\` by default; to use a custom Wine build set \\`toolsets.wine: { url: \"file:///path/to/dir\" }\\`.` },\n { name: \"USE_SYSTEM_SIGNCODE\", remediation: `configure signing via \\`win.sign\\` and the \\`winCodeSign\\` toolset instead.` },\n { name: \"USE_SYSTEM_OSSLSIGNCODE\", remediation: `configure signing via \\`win.sign\\` and the \\`winCodeSign\\` toolset instead.` },\n { name: \"USE_SYSTEM_FPM\", remediation: `set \\`toolsets.fpm: { url: \"file:///path/to/dir\" }\\` instead (required on Windows for FPM-based targets).` },\n\n // Renamed / replaced by another environment variable.\n { name: \"ELECTRON_BUILDER_BINARIES_ALLOW_HTTP\", remediation: `use \\`ELECTRON_BUILDER_DANGEROUSLY_ALLOW_HTTP=true\\` instead.` },\n { name: \"CI_BUILD_TAG\", remediation: `use \\`CI_COMMIT_TAG\\` (the standard GitLab CI variable) instead.` },\n\n // Replaced by a configuration option (with a behavior change).\n {\n name: \"ALLOW_ELECTRON_BUILDER_AS_PRODUCTION_DEPENDENCY\",\n remediation: `electron-builder in \\`dependencies\\` no longer errors and is excluded from the packaged app by default — remove this variable, and use the \\`ignoredProductionDependencies\\` option to customize exclusions.`,\n },\n]\n\n/** The section of the v27 build-changes page that documents a removed environment variable. */\nexport function removedEnvVarDocsUrl(name: string): string {\n switch (name) {\n case \"CI_BUILD_TAG\":\n return `${BUILD_CHANGES_URL}#ci_build_tag-environment-variable`\n case \"ELECTRON_BUILDER_BINARIES_ALLOW_HTTP\":\n return `${BUILD_CHANGES_URL}#electron_builder_binaries_allow_http-renamed`\n case \"ALLOW_ELECTRON_BUILDER_AS_PRODUCTION_DEPENDENCY\":\n return `${BUILD_CHANGES_URL}#allow_electron_builder_as_production_dependency-is-removed-and-the-default-flipped`\n default:\n return `${BUILD_CHANGES_URL}#toolset-env-var-overrides-removed`\n }\n}\n\n/**\n * Logs a one-time deprecation warning for every {@link REMOVED_ENV_VARS} entry still present in the\n * environment. Called once per build (from the {@link Packager} constructor) so both the CLI and the\n * programmatic `build()` API surface the same guidance.\n */\nexport function warnOnRemovedEnvVars(env: NodeJS.ProcessEnv = process.env): void {\n for (const { name, remediation } of REMOVED_ENV_VARS) {\n if (env[name] != null) {\n log.warn({ envVar: name, docs: removedEnvVarDocsUrl(name) }, `environment variable was removed in electron-builder v27 and no longer has any effect — ${remediation}`)\n }\n }\n}\n"]}
@@ -16,7 +16,9 @@ export interface StreamSpawnResult {
16
16
  * which emits the DEP0190 "args with shell" deprecation warning and forces manual metacharacter
17
17
  * escaping — wrap the invocation in a single PowerShell `-EncodedCommand`. The base64 (UTF-16LE)
18
18
  * payload sidesteps every shell-quoting layer, and `powershell.exe` is a real executable we spawn
19
- * directly with no shell. See buildPowerShellEncodedArgs for the UTF-8 / exit-code handling. This
19
+ * directly with no shell, by its absolute path (`toolsets.executables.powershell` or its default location;
20
+ * never looked up in the current directory or on PATH).
21
+ * See buildPowerShellEncodedArgs for the UTF-8 / exit-code handling. This
20
22
  * also avoids the cmd.exe "The batch file cannot be found." re-open race that plagues `.cmd` shims.
21
23
  *
22
24
  * Resolves with `{ code, stderr }` for ANY exit code — interpreting a non-zero code is the caller's
@@ -1 +1 @@
1
- {"version":3,"file":"streamSpawnToFile.d.ts","sourceRoot":"","sources":["../../src/util/streamSpawnToFile.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,iBAAiB;IAChC,iEAAiE;IACjE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAkEtJ;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAMpF"}
1
+ {"version":3,"file":"streamSpawnToFile.d.ts","sourceRoot":"","sources":["../../src/util/streamSpawnToFile.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,iEAAiE;IACjE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAmEtJ;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAMpF"}
@@ -1,5 +1,6 @@
1
1
  import * as childProcess from "child_process";
2
2
  import { createWriteStream } from "node:fs";
3
+ import { Executables } from "builder-util";
3
4
  /**
4
5
  * Spawns a command and streams its stdout to a file, returning the exit code and captured stderr.
5
6
  *
@@ -12,7 +13,9 @@ import { createWriteStream } from "node:fs";
12
13
  * which emits the DEP0190 "args with shell" deprecation warning and forces manual metacharacter
13
14
  * escaping — wrap the invocation in a single PowerShell `-EncodedCommand`. The base64 (UTF-16LE)
14
15
  * payload sidesteps every shell-quoting layer, and `powershell.exe` is a real executable we spawn
15
- * directly with no shell. See buildPowerShellEncodedArgs for the UTF-8 / exit-code handling. This
16
+ * directly with no shell, by its absolute path (`toolsets.executables.powershell` or its default location;
17
+ * never looked up in the current directory or on PATH).
18
+ * See buildPowerShellEncodedArgs for the UTF-8 / exit-code handling. This
16
19
  * also avoids the cmd.exe "The batch file cannot be found." re-open race that plagues `.cmd` shims.
17
20
  *
18
21
  * Resolves with `{ code, stderr }` for ANY exit code — interpreting a non-zero code is the caller's
@@ -26,8 +29,9 @@ import { createWriteStream } from "node:fs";
26
29
  * @param env - The environment for the child process (callers are responsible for stripping secrets)
27
30
  */
28
31
  export function streamSpawnToFile(command, args, cwd, outputFile, env) {
29
- const [spawnCommand, spawnArgs] = process.platform === "win32" ? ["powershell.exe", buildPowerShellEncodedArgs(command, args)] : [command, args];
30
32
  return new Promise((resolve, reject) => {
33
+ // inside the executor, so a SystemRoot that cannot locate PowerShell rejects like any other spawn failure
34
+ const [spawnCommand, spawnArgs] = process.platform === "win32" ? [Executables.resolve("powershell"), buildPowerShellEncodedArgs(command, args)] : [command, args];
31
35
  const outStream = createWriteStream(outputFile);
32
36
  const child = childProcess.spawn(spawnCommand, spawnArgs, { cwd, env });
33
37
  let stderr = "";
@@ -1 +1 @@
1
- {"version":3,"file":"streamSpawnToFile.js","sourceRoot":"","sources":["../../src/util/streamSpawnToFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAS3C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,IAAc,EAAE,GAAW,EAAE,UAAkB,EAAE,GAAsB;IACxH,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAE,CAAC,gBAAgB,EAAE,0BAA0B,CAAC,OAAO,EAAE,IAAI,CAAC,CAAW,CAAC,CAAC,CAAE,CAAC,OAAO,EAAE,IAAI,CAAW,CAAA;IAEtK,OAAO,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxD,MAAM,SAAS,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAA;QAE/C,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,YAAY,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA;QAEvE,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,2FAA2F;QAC3F,yFAAyF;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face StreamSpawnResult {\n /** The child's exit code (null if it was killed by a signal). */\n code: number | null\n /** Everything the child wrote to stderr, accumulated. */\n stderr: string\n}\n\n/**\n * Spawns a command and streams its stdout to a file, returning the exit code and captured stderr.\n *\n * stdout is piped straight to `outputFile` (never buffered in memory), so arbitrarily large output —\n * a full dependency tree, a verbose `install` log — costs no heap. stderr is small by comparison and\n * is accumulated so the caller can surface it on failure.\n *\n * On Windows the package-manager command is typically a `.cmd` shim (npm.cmd/pnpm.cmd/yarn.cmd),\n * which Node can no longer spawn directly (CVE-2024-27980). Rather than spawn with `shell: true` —\n * which emits the DEP0190 \"args with shell\" deprecation warning and forces manual metacharacter\n * escaping — wrap the invocation in a single PowerShell `-EncodedCommand`. The base64 (UTF-16LE)\n * payload sidesteps every shell-quoting layer, and `powershell.exe` is a real executable we spawn\n * directly with no shell. See buildPowerShellEncodedArgs for the UTF-8 / exit-code handling. This\n * also avoids the cmd.exe \"The batch file cannot be found.\" re-open race that plagues `.cmd` shims.\n *\n * Resolves with `{ code, stderr }` for ANY exit code — interpreting a non-zero code is the caller's\n * job (e.g. `npm list` returns 1 in expected scenarios). Only genuine infrastructure failures —\n * spawn errors and write-stream errors — reject.\n *\n * @param command - The command to execute\n * @param args - Array of command-line arguments\n * @param cwd - The working directory to execute the command in\n * @param outputFile - The path to the file where stdout will be streamed\n * @param env - The environment for the child process (callers are responsible for stripping secrets)\n */\nexport function streamSpawnToFile(command: string, args: string[], cwd: string, outputFile: string, env: NodeJS.ProcessEnv): Promise<StreamSpawnResult> {\n const [spawnCommand, spawnArgs] = process.platform === \"win32\" ? ([\"powershell.exe\", buildPowerShellEncodedArgs(command, args)] as const) : ([command, args] as const)\n\n return new Promise<StreamSpawnResult>((resolve, reject) => {\n const outStream = createWriteStream(outputFile)\n\n const child = childProcess.spawn(spawnCommand, spawnArgs, { cwd, env })\n\n let stderr = \"\"\n // The process can close before all piped stdout has been flushed to disk. Resolving on the\n // child's \"close\" alone races the write stream and lets the caller read a TRUNCATED file\n // (manifesting as \"No JSON content found in output\"). Gate the settle on BOTH the child exit\n // (for the code/stderr) and the write stream's \"finish\" (all bytes flushed).\n let exitCode: number | null = null\n let childClosed = false\n let streamFinished = false\n let settled = false\n\n // `pipe` ends `outStream` when stdout EOFs, which triggers its \"finish\" once flushed.\n child.stdout.pipe(outStream)\n child.stderr.on(\"data\", chunk => {\n stderr += chunk.toString()\n })\n\n const fail = (err: Error) => {\n if (settled) {\n return\n }\n settled = true\n // Best-effort cleanup: stop the child and close the stream so we don't\n // waste CPU writing to a broken fd after rejection.\n try {\n child.kill()\n } catch {\n // ignore\n }\n try {\n outStream.destroy()\n } catch {\n // ignore\n }\n reject(err)\n }\n\n const settle = () => {\n if (settled || !childClosed || !streamFinished) {\n return\n }\n settled = true\n resolve({ code: exitCode, stderr })\n }\n\n outStream.on(\"error\", err => fail(new Error(`Failed writing process output (${command}): ${err.message}`)))\n outStream.on(\"finish\", () => {\n streamFinished = true\n settle()\n })\n child.on(\"error\", err => {\n fail(new Error(`Process spawn (${command} ${JSON.stringify(args)}) failed: ${err.message}`))\n })\n child.on(\"close\", code => {\n exitCode = code\n childClosed = true\n settle()\n })\n })\n}\n\n/**\n * Build the argv for invoking a Windows command through `powershell.exe -EncodedCommand`.\n *\n * Each token is wrapped in a PowerShell single-quoted string (with embedded single quotes doubled),\n * so no character is interpreted by a shell. The script:\n * - pins `[Console]::OutputEncoding` to UTF-8 *without* a BOM so the JSON dependency tree is not\n * corrupted by the console's OEM code page (and no BOM is prepended to break `JSON.parse`),\n * - invokes the command via the call operator `&`,\n * - re-emits the command's own exit code via `exit $LASTEXITCODE` (e.g. `npm list` returns 1 in\n * expected scenarios, which the caller's shouldIgnore logic relies on).\n *\n * The whole script is base64-encoded as UTF-16LE per PowerShell's `-EncodedCommand` contract.\n */\nexport function buildPowerShellEncodedArgs(command: string, args: string[]): string[] {\n const psQuote = (value: string) => `'${value.replace(/'/g, \"''\")}'`\n const invocation = [\"&\", psQuote(command), ...args.map(psQuote)].join(\" \")\n const script = `[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new($false); ${invocation}; exit $LASTEXITCODE`\n const encoded = Buffer.from(script, \"utf16le\").toString(\"base64\")\n return [\"-NoProfile\", \"-NonInteractive\", \"-EncodedCommand\", encoded]\n}\n"]}
1
+ {"version":3,"file":"streamSpawnToFile.js","sourceRoot":"","sources":["../../src/util/streamSpawnToFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAS1C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,IAAc,EAAE,GAAW,EAAE,UAAkB,EAAE,GAAsB;IACxH,OAAO,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxD,0GAA0G;QAC1G,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,GAC7B,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAE,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,0BAA0B,CAAC,OAAO,EAAE,IAAI,CAAC,CAAW,CAAC,CAAC,CAAE,CAAC,OAAO,EAAE,IAAI,CAAW,CAAA;QACvJ,MAAM,SAAS,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAA;QAE/C,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,YAAY,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA;QAEvE,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,2FAA2F;QAC3F,yFAAyF;QACzF,6FAA6F;QAC7F,6EAA6E;QAC7E,IAAI,QAAQ,GAAkB,IAAI,CAAA;QAClC,IAAI,WAAW,GAAG,KAAK,CAAA;QACvB,IAAI,cAAc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AAC,CAAC,CAAA;QACF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE;YACtB,IAAI,CAAC,IAAI,KAAK,CAAC,kBAAkB,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;QAC9F,CAAC,CAAC,CAAA;QACF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;YACvB,QAAQ,GAAG,IAAI,CAAA;YACf,WAAW,GAAG,IAAI,CAAA;YAClB,MAAM,EAAE,CAAA;QACV,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAAe,EAAE,IAAc;IACxE,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAA;IACnE,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC1E,MAAM,MAAM,GAAG,sEAAsE,UAAU,sBAAsB,CAAA;IACrH,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACjE,OAAO,CAAC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAA;AACtE,CAAC","sourcesContent":["import * as childProcess from \"child_process\"\nimport { createWriteStream } from \"node:fs\"\nimport { Executables } from \"builder-util\"\n\nexport interface StreamSpawnResult {\n /** The child's exit code (null if it was killed by a signal). */\n code: number | null\n /** Everything the child wrote to stderr, accumulated. */\n stderr: string\n}\n\n/**\n * Spawns a command and streams its stdout to a file, returning the exit code and captured stderr.\n *\n * stdout is piped straight to `outputFile` (never buffered in memory), so arbitrarily large output —\n * a full dependency tree, a verbose `install` log — costs no heap. stderr is small by comparison and\n * is accumulated so the caller can surface it on failure.\n *\n * On Windows the package-manager command is typically a `.cmd` shim (npm.cmd/pnpm.cmd/yarn.cmd),\n * which Node can no longer spawn directly (CVE-2024-27980). Rather than spawn with `shell: true` —\n * which emits the DEP0190 \"args with shell\" deprecation warning and forces manual metacharacter\n * escaping — wrap the invocation in a single PowerShell `-EncodedCommand`. The base64 (UTF-16LE)\n * payload sidesteps every shell-quoting layer, and `powershell.exe` is a real executable we spawn\n * directly with no shell, by its absolute path (`toolsets.executables.powershell` or its default location;\n * never looked up in the current directory or on PATH).\n * See buildPowerShellEncodedArgs for the UTF-8 / exit-code handling. This\n * also avoids the cmd.exe \"The batch file cannot be found.\" re-open race that plagues `.cmd` shims.\n *\n * Resolves with `{ code, stderr }` for ANY exit code — interpreting a non-zero code is the caller's\n * job (e.g. `npm list` returns 1 in expected scenarios). Only genuine infrastructure failures —\n * spawn errors and write-stream errors — reject.\n *\n * @param command - The command to execute\n * @param args - Array of command-line arguments\n * @param cwd - The working directory to execute the command in\n * @param outputFile - The path to the file where stdout will be streamed\n * @param env - The environment for the child process (callers are responsible for stripping secrets)\n */\nexport function streamSpawnToFile(command: string, args: string[], cwd: string, outputFile: string, env: NodeJS.ProcessEnv): Promise<StreamSpawnResult> {\n return new Promise<StreamSpawnResult>((resolve, reject) => {\n // inside the executor, so a SystemRoot that cannot locate PowerShell rejects like any other spawn failure\n const [spawnCommand, spawnArgs] =\n process.platform === \"win32\" ? ([Executables.resolve(\"powershell\"), buildPowerShellEncodedArgs(command, args)] as const) : ([command, args] as const)\n const outStream = createWriteStream(outputFile)\n\n const child = childProcess.spawn(spawnCommand, spawnArgs, { cwd, env })\n\n let stderr = \"\"\n // The process can close before all piped stdout has been flushed to disk. Resolving on the\n // child's \"close\" alone races the write stream and lets the caller read a TRUNCATED file\n // (manifesting as \"No JSON content found in output\"). Gate the settle on BOTH the child exit\n // (for the code/stderr) and the write stream's \"finish\" (all bytes flushed).\n let exitCode: number | null = null\n let childClosed = false\n let streamFinished = false\n let settled = false\n\n // `pipe` ends `outStream` when stdout EOFs, which triggers its \"finish\" once flushed.\n child.stdout.pipe(outStream)\n child.stderr.on(\"data\", chunk => {\n stderr += chunk.toString()\n })\n\n const fail = (err: Error) => {\n if (settled) {\n return\n }\n settled = true\n // Best-effort cleanup: stop the child and close the stream so we don't\n // waste CPU writing to a broken fd after rejection.\n try {\n child.kill()\n } catch {\n // ignore\n }\n try {\n outStream.destroy()\n } catch {\n // ignore\n }\n reject(err)\n }\n\n const settle = () => {\n if (settled || !childClosed || !streamFinished) {\n return\n }\n settled = true\n resolve({ code: exitCode, stderr })\n }\n\n outStream.on(\"error\", err => fail(new Error(`Failed writing process output (${command}): ${err.message}`)))\n outStream.on(\"finish\", () => {\n streamFinished = true\n settle()\n })\n child.on(\"error\", err => {\n fail(new Error(`Process spawn (${command} ${JSON.stringify(args)}) failed: ${err.message}`))\n })\n child.on(\"close\", code => {\n exitCode = code\n childClosed = true\n settle()\n })\n })\n}\n\n/**\n * Build the argv for invoking a Windows command through `powershell.exe -EncodedCommand`.\n *\n * Each token is wrapped in a PowerShell single-quoted string (with embedded single quotes doubled),\n * so no character is interpreted by a shell. The script:\n * - pins `[Console]::OutputEncoding` to UTF-8 *without* a BOM so the JSON dependency tree is not\n * corrupted by the console's OEM code page (and no BOM is prepended to break `JSON.parse`),\n * - invokes the command via the call operator `&`,\n * - re-emits the command's own exit code via `exit $LASTEXITCODE` (e.g. `npm list` returns 1 in\n * expected scenarios, which the caller's shouldIgnore logic relies on).\n *\n * The whole script is base64-encoded as UTF-16LE per PowerShell's `-EncodedCommand` contract.\n */\nexport function buildPowerShellEncodedArgs(command: string, args: string[]): string[] {\n const psQuote = (value: string) => `'${value.replace(/'/g, \"''\")}'`\n const invocation = [\"&\", psQuote(command), ...args.map(psQuote)].join(\" \")\n const script = `[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new($false); ${invocation}; exit $LASTEXITCODE`\n const encoded = Buffer.from(script, \"utf16le\").toString(\"base64\")\n return [\"-NoProfile\", \"-NonInteractive\", \"-EncodedCommand\", encoded]\n}\n"]}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const PACKAGE_VERSION = "27.0.0-alpha.12";
1
+ export declare const PACKAGE_VERSION = "27.0.0-alpha.14";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const PACKAGE_VERSION = "27.0.0-alpha.12";
1
+ export const PACKAGE_VERSION = "27.0.0-alpha.14";
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"27.0.0-alpha.12\"\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"27.0.0-alpha.14\"\n"]}
@@ -1,10 +1,14 @@
1
1
  import { ExtraSpawnOptions } from "builder-util";
2
2
  import { ExecFileOptions, SpawnOptions } from "child_process";
3
3
  import { VmManager } from "./vm.js";
4
+ /** The same executables inside a Parallels Windows guest, at the locations of a default Windows installation. */
5
+ export declare const PARALLELS_GUEST_WINDOWS_POWERSHELL = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe";
6
+ export declare const PARALLELS_GUEST_PWSH = "C:\\Program Files\\PowerShell\\7\\pwsh.exe";
4
7
  export declare class ParallelsVmManager extends VmManager {
5
8
  private readonly vm;
6
9
  private startPromise;
7
10
  private isExitHookAdded;
11
+ private readonly prlctl;
8
12
  constructor(vm: ParallelsVm);
9
13
  get pathSep(): string;
10
14
  private handleExecuteError;
@@ -12,6 +16,12 @@ export declare class ParallelsVmManager extends VmManager {
12
16
  spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any>;
13
17
  private doStartVm;
14
18
  private ensureThatVmStarted;
19
+ protected windowsPowerShellPaths(): {
20
+ powershell: string;
21
+ pwsh: {
22
+ unavailable: string;
23
+ };
24
+ };
15
25
  toVmFile(file: string): string;
16
26
  }
17
27
  export declare function macPathToParallelsWindows(file: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"ParallelsVm.d.ts","sourceRoot":"","sources":["../../src/vm/ParallelsVm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,iBAAiB,EAA4D,MAAM,cAAc,CAAA;AACvH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAgB,MAAM,eAAe,CAAA;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAiCnC,qBAAa,kBAAmB,SAAQ,SAAS;IAKnC,OAAO,CAAC,QAAQ,CAAC,EAAE;IAJ/B,OAAO,CAAC,YAAY,CAAc;IAElC,OAAO,CAAC,eAAe,CAAQ;gBAEF,EAAE,EAAE,WAAW;IAM5C,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,OAAO,CAAC,kBAAkB;IASpB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAUnF,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC;YAKxG,SAAS;IAgCvB,OAAO,CAAC,mBAAmB;IAS3B,QAAQ,CAAC,IAAI,EAAE,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AAS;IAgCvB,OAAO,CAAC,mBAAmB;IAW3B,SAAS,CAAC,sBAAsB;;;;;;IAOhC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAI/B;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,UA4BrD;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,CAAA;IACjD,KAAK,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,CAAA;CAC3C"}
@@ -1,11 +1,16 @@
1
- import { exec, log, sanitizeDirPath, spawn, stripSensitiveEnvVars } from "builder-util";
1
+ import { Executables, exec, log, sanitizeDirPath, spawn, stripSensitiveEnvVars } from "builder-util";
2
2
  import { execFileSync } from "child_process";
3
3
  import { homedir } from "os";
4
4
  import { VmManager } from "./vm.js";
5
+ /** The same executables inside a Parallels Windows guest, at the locations of a default Windows installation. */
6
+ export const PARALLELS_GUEST_WINDOWS_POWERSHELL = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe";
7
+ export const PARALLELS_GUEST_PWSH = "C:\\Program Files\\PowerShell\\7\\pwsh.exe";
5
8
  /** @internal */
6
9
  export async function parseVmList(debugLogger) {
10
+ // prlctl by absolute path; when Parallels Desktop is not installed this throws, which callers treat as "no Parallels VM"
11
+ const prlctl = Executables.resolve("prlctl");
7
12
  // do not log output if debug - it is huge, logged using debugLogger
8
- let rawList = await exec("prlctl", ["list", "-i", "-s", "name"], undefined, false);
13
+ let rawList = await exec(prlctl, ["list", "-i", "-s", "name"], undefined, false);
9
14
  debugLogger.add("parallels.list", rawList);
10
15
  rawList = rawList.substring(rawList.indexOf("ID:"));
11
16
  // let match: Array<string> | null
@@ -34,6 +39,7 @@ export class ParallelsVmManager extends VmManager {
34
39
  super();
35
40
  this.vm = vm;
36
41
  this.isExitHookAdded = false;
42
+ this.prlctl = Executables.resolve("prlctl");
37
43
  this.startPromise = this.doStartVm();
38
44
  }
39
45
  get pathSep() {
@@ -48,14 +54,14 @@ export class ParallelsVmManager extends VmManager {
48
54
  }
49
55
  async exec(file, args, options) {
50
56
  await this.ensureThatVmStarted();
51
- // Merge caller-supplied env onto the base environment, so extra vars don't strip PATH and `prlctl` itself stays resolvable.
57
+ // Merge caller-supplied env onto the base environment, so extra vars don't strip the variables `prlctl` relies on (HOME, etc.).
52
58
  const mergedOptions = options?.env != null ? { ...options, env: { ...stripSensitiveEnvVars(process.env), ...options.env } } : options;
53
59
  // it is important to use "--current-user" to execute command under logged in user - to access certs.
54
- return await exec("prlctl", ["exec", this.vm.id, "--current-user", file.startsWith("/") ? macPathToParallelsWindows(file) : file].concat(args), mergedOptions).catch(error => this.handleExecuteError(error));
60
+ return await exec(this.prlctl, ["exec", this.vm.id, "--current-user", file.startsWith("/") ? macPathToParallelsWindows(file) : file].concat(args), mergedOptions).catch(error => this.handleExecuteError(error));
55
61
  }
56
62
  async spawn(file, args, options, extraOptions) {
57
63
  await this.ensureThatVmStarted();
58
- return await spawn("prlctl", ["exec", this.vm.id, file].concat(args), options, extraOptions).catch(error => this.handleExecuteError(error));
64
+ return await spawn(this.prlctl, ["exec", this.vm.id, file].concat(args), options, extraOptions).catch(error => this.handleExecuteError(error));
59
65
  }
60
66
  async doStartVm() {
61
67
  const vmId = this.vm.id;
@@ -69,10 +75,10 @@ export class ParallelsVmManager extends VmManager {
69
75
  // Suspend the VM on normal exit and on termination signals.
70
76
  // SIGTERM/SIGINT use async exec(); the synchronous 'exit' fallback fires
71
77
  // after all async callbacks have already resolved, so execFileSync is safe.
72
- const suspendAsync = () => exec("prlctl", stopArgs).catch(() => { });
78
+ const suspendAsync = () => exec(this.prlctl, stopArgs).catch(() => { });
73
79
  const suspendSync = () => {
74
80
  try {
75
- execFileSync("prlctl", stopArgs);
81
+ execFileSync(this.prlctl, stopArgs);
76
82
  }
77
83
  catch {
78
84
  /* best-effort */
@@ -86,7 +92,7 @@ export class ParallelsVmManager extends VmManager {
86
92
  });
87
93
  process.once("exit", suspendSync);
88
94
  }
89
- await exec("prlctl", ["start", vmId]);
95
+ await exec(this.prlctl, ["start", vmId]);
90
96
  }
91
97
  ensureThatVmStarted() {
92
98
  let startPromise = this.startPromise;
@@ -96,6 +102,14 @@ export class ParallelsVmManager extends VmManager {
96
102
  }
97
103
  return startPromise;
98
104
  }
105
+ // The guest's environment is not visible from the host, so the location of a default Windows installation is used. PowerShell 7
106
+ // is not: `prlctl exec` passes its arguments to the guest without quoting, so a path containing a space cannot be started.
107
+ windowsPowerShellPaths() {
108
+ return {
109
+ powershell: PARALLELS_GUEST_WINDOWS_POWERSHELL,
110
+ pwsh: { unavailable: `PowerShell 7 (${PARALLELS_GUEST_PWSH}) is not used in a Parallels VM, because prlctl exec cannot start a path that contains a space` },
111
+ };
112
+ }
99
113
  toVmFile(file) {
100
114
  // https://stackoverflow.com/questions/4742992/cannot-access-network-drive-in-powershell-running-as-administrator
101
115
  return macPathToParallelsWindows(file);
@@ -1 +1 @@
1
- {"version":3,"file":"ParallelsVm.js","sourceRoot":"","sources":["../../src/vm/ParallelsVm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,IAAI,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AACvH,OAAO,EAAiC,YAAY,EAAE,MAAM,eAAe,CAAA;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,WAAwB;IACxD,oEAAoE;IACpE,IAAI,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;IACl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EAAE,CAAA;IACtB,6SAA6S;IAC7S,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,GAAG,GAAG,CAAC;QAC9C,CAAC,CAAC,iBAAiB,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;QAC/E,CAAC,CAAC,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACtD,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import { DebugLogger, ExtraSpawnOptions, exec, log, sanitizeDirPath, spawn, stripSensitiveEnvVars } from \"builder-util\"\nimport { ExecFileOptions, SpawnOptions, execFileSync } from \"child_process\"\nimport { homedir } from \"os\"\nimport { VmManager } from \"./vm.js\"\n\n/** @internal */\nexport async function parseVmList(debugLogger: DebugLogger) {\n // do not log output if debug - it is huge, logged using debugLogger\n let rawList = await exec(\"prlctl\", [\"list\", \"-i\", \"-s\", \"name\"], undefined, false)\n debugLogger.add(\"parallels.list\", rawList)\n\n rawList = rawList.substring(rawList.indexOf(\"ID:\"))\n\n // let match: Array<string> | null\n const result: Array<ParallelsVm> = []\n for (const info of rawList\n .split(\"\\n\\n\")\n .map(it => it.trim())\n .filter(it => it.length > 0)) {\n const vm: any = {}\n for (const line of info.split(\"\\n\")) {\n const meta = /^([^:(\"]+): (.*)$/.exec(line)\n if (meta == null) {\n continue\n }\n\n const key = meta[1].toLowerCase()\n if (key === \"id\" || key === \"os\" || key === \"name\" || key === \"state\" || key === \"name\") {\n vm[key] = meta[2].trim()\n }\n }\n result.push(vm)\n }\n return result\n}\n\nexport class ParallelsVmManager extends VmManager {\n private startPromise: Promise<any>\n\n private isExitHookAdded = false\n\n constructor(private readonly vm: ParallelsVm) {\n super()\n\n this.startPromise = this.doStartVm()\n }\n\n get pathSep(): string {\n return \"/\"\n }\n\n private handleExecuteError(error: Error): any {\n if (error.message.includes(\"Unable to open new session in this virtual machine\")) {\n throw new Error(`Please ensure that your are logged in \"${this.vm.name}\" parallels virtual machine. In the future please do not stop VM, but suspend.\\n\\n${error.message}`)\n }\n\n log.warn(\"ensure that 'Share folders' is set to 'All Disks', see https://goo.gl/E6XphP\")\n throw error\n }\n\n async exec(file: string, args: Array<string>, options?: ExecFileOptions): Promise<string> {\n await this.ensureThatVmStarted()\n // Merge caller-supplied env onto the base environment, so extra vars don't strip PATH and `prlctl` itself stays resolvable.\n const mergedOptions = options?.env != null ? { ...options, env: { ...stripSensitiveEnvVars(process.env), ...options.env } } : options\n // it is important to use \"--current-user\" to execute command under logged in user - to access certs.\n return await exec(\"prlctl\", [\"exec\", this.vm.id, \"--current-user\", file.startsWith(\"/\") ? macPathToParallelsWindows(file) : file].concat(args), mergedOptions).catch(error =>\n this.handleExecuteError(error)\n )\n }\n\n async spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any> {\n await this.ensureThatVmStarted()\n return await spawn(\"prlctl\", [\"exec\", this.vm.id, file].concat(args), options, extraOptions).catch(error => this.handleExecuteError(error))\n }\n\n private async doStartVm() {\n const vmId = this.vm.id\n const state = this.vm.state\n if (state === \"running\") {\n return\n }\n\n if (!this.isExitHookAdded) {\n this.isExitHookAdded = true\n const stopArgs = [\"suspend\", vmId]\n // Suspend the VM on normal exit and on termination signals.\n // SIGTERM/SIGINT use async exec(); the synchronous 'exit' fallback fires\n // after all async callbacks have already resolved, so execFileSync is safe.\n const suspendAsync = () => exec(\"prlctl\", stopArgs).catch(() => {})\n const suspendSync = () => {\n try {\n execFileSync(\"prlctl\", stopArgs)\n } catch {\n /* best-effort */\n }\n }\n process.once(\"SIGTERM\", () => {\n void suspendAsync()\n })\n process.once(\"SIGINT\", () => {\n void suspendAsync()\n })\n process.once(\"exit\", suspendSync)\n }\n await exec(\"prlctl\", [\"start\", vmId])\n }\n\n private ensureThatVmStarted() {\n let startPromise = this.startPromise\n if (startPromise == null) {\n startPromise = this.doStartVm()\n this.startPromise = startPromise\n }\n return startPromise\n }\n\n toVmFile(file: string): string {\n // https://stackoverflow.com/questions/4742992/cannot-access-network-drive-in-powershell-running-as-administrator\n return macPathToParallelsWindows(file)\n }\n}\n\nexport function macPathToParallelsWindows(file: string) {\n if (file.startsWith(\"C:\\\\\")) {\n return file\n }\n if (!file.startsWith(\"/\")) {\n throw new Error(`Invalid path for Parallels VM execution: \"${file}\"`)\n }\n // Validate the raw host path up-front and reject control bytes plus shell/UNC-significant\n // metacharacters BEFORE it is concatenated into the \\\\Mac\\... path passed to `prlctl exec`. The\n // `/`→`\\` conversion below only adds backslashes (not in the deny-set), so validating the input here\n // is the single sanitizing barrier for the value that reaches the command.\n // (CodeQL js/shell-command-constructed-from-input — sanitize the tainted input at the source.)\n // eslint-disable-next-line no-control-regex\n if (/[\\x00-\\x1F\\x7F\"*?<>|]/.test(file)) {\n throw new Error(`Invalid path for Parallels VM execution: \"${file}\"`)\n }\n // sanitizeDirPath additionally rejects null/newline and resolves the path; the input is already\n // validated above, so the resulting UNC path is safe to hand to prlctl.\n const sanitized = sanitizeDirPath(file)\n // \\\\Mac\\Home maps to the current user's home directory and is always accessible\n // in both --current-user and SYSTEM exec contexts (unlike \\\\Mac\\Host which requires\n // \"All Disks\" sharing to be enabled in Parallels preferences).\n const home = homedir()\n // codeql[js/shell-command-constructed-from-input] - `file` is validated above (control bytes + shell/UNC metacharacters rejected) and resolved via sanitizeDirPath; the resulting UNC path is passed to prlctl as a discrete execFile argv element (array args, no shell), so no shell interpretation occurs\n const uncPath = sanitized.startsWith(home + \"/\")\n ? \"\\\\\\\\Mac\\\\Home\\\\\" + sanitized.substring(home.length + 1).replace(/\\//g, \"\\\\\")\n : \"\\\\\\\\Mac\\\\Host\\\\\" + sanitized.replace(/\\//g, \"\\\\\")\n return uncPath\n}\n\nexport interface ParallelsVm {\n id: string\n name: string\n os: \"win-10\" | \"win-11\" | \"ubuntu\" | \"elementary\"\n state: \"running\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,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;QAC/E,CAAC,CAAC,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACtD,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import { DebugLogger, Executables, ExtraSpawnOptions, exec, log, sanitizeDirPath, spawn, stripSensitiveEnvVars } from \"builder-util\"\nimport { ExecFileOptions, SpawnOptions, execFileSync } from \"child_process\"\nimport { homedir } from \"os\"\nimport { VmManager } from \"./vm.js\"\n\n/** The same executables inside a Parallels Windows guest, at the locations of a default Windows installation. */\nexport const PARALLELS_GUEST_WINDOWS_POWERSHELL = \"C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe\"\nexport const PARALLELS_GUEST_PWSH = \"C:\\\\Program Files\\\\PowerShell\\\\7\\\\pwsh.exe\"\n\n/** @internal */\nexport async function parseVmList(debugLogger: DebugLogger) {\n // prlctl by absolute path; when Parallels Desktop is not installed this throws, which callers treat as \"no Parallels VM\"\n const prlctl = Executables.resolve(\"prlctl\")\n // do not log output if debug - it is huge, logged using debugLogger\n let rawList = await exec(prlctl, [\"list\", \"-i\", \"-s\", \"name\"], undefined, false)\n debugLogger.add(\"parallels.list\", rawList)\n\n rawList = rawList.substring(rawList.indexOf(\"ID:\"))\n\n // let match: Array<string> | null\n const result: Array<ParallelsVm> = []\n for (const info of rawList\n .split(\"\\n\\n\")\n .map(it => it.trim())\n .filter(it => it.length > 0)) {\n const vm: any = {}\n for (const line of info.split(\"\\n\")) {\n const meta = /^([^:(\"]+): (.*)$/.exec(line)\n if (meta == null) {\n continue\n }\n\n const key = meta[1].toLowerCase()\n if (key === \"id\" || key === \"os\" || key === \"name\" || key === \"state\" || key === \"name\") {\n vm[key] = meta[2].trim()\n }\n }\n result.push(vm)\n }\n return result\n}\n\nexport class ParallelsVmManager extends VmManager {\n private startPromise: Promise<any>\n\n private isExitHookAdded = false\n\n private readonly prlctl: string\n\n constructor(private readonly vm: ParallelsVm) {\n super()\n this.prlctl = Executables.resolve(\"prlctl\")\n\n this.startPromise = this.doStartVm()\n }\n\n get pathSep(): string {\n return \"/\"\n }\n\n private handleExecuteError(error: Error): any {\n if (error.message.includes(\"Unable to open new session in this virtual machine\")) {\n throw new Error(`Please ensure that your are logged in \"${this.vm.name}\" parallels virtual machine. In the future please do not stop VM, but suspend.\\n\\n${error.message}`)\n }\n\n log.warn(\"ensure that 'Share folders' is set to 'All Disks', see https://goo.gl/E6XphP\")\n throw error\n }\n\n async exec(file: string, args: Array<string>, options?: ExecFileOptions): Promise<string> {\n await this.ensureThatVmStarted()\n // Merge caller-supplied env onto the base environment, so extra vars don't strip the variables `prlctl` relies on (HOME, etc.).\n const mergedOptions = options?.env != null ? { ...options, env: { ...stripSensitiveEnvVars(process.env), ...options.env } } : options\n // it is important to use \"--current-user\" to execute command under logged in user - to access certs.\n return await exec(this.prlctl, [\"exec\", this.vm.id, \"--current-user\", file.startsWith(\"/\") ? macPathToParallelsWindows(file) : file].concat(args), mergedOptions).catch(error =>\n this.handleExecuteError(error)\n )\n }\n\n async spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any> {\n await this.ensureThatVmStarted()\n return await spawn(this.prlctl, [\"exec\", this.vm.id, file].concat(args), options, extraOptions).catch(error => this.handleExecuteError(error))\n }\n\n private async doStartVm() {\n const vmId = this.vm.id\n const state = this.vm.state\n if (state === \"running\") {\n return\n }\n\n if (!this.isExitHookAdded) {\n this.isExitHookAdded = true\n const stopArgs = [\"suspend\", vmId]\n // Suspend the VM on normal exit and on termination signals.\n // SIGTERM/SIGINT use async exec(); the synchronous 'exit' fallback fires\n // after all async callbacks have already resolved, so execFileSync is safe.\n const suspendAsync = () => exec(this.prlctl, stopArgs).catch(() => {})\n const suspendSync = () => {\n try {\n execFileSync(this.prlctl, stopArgs)\n } catch {\n /* best-effort */\n }\n }\n process.once(\"SIGTERM\", () => {\n void suspendAsync()\n })\n process.once(\"SIGINT\", () => {\n void suspendAsync()\n })\n process.once(\"exit\", suspendSync)\n }\n await exec(this.prlctl, [\"start\", vmId])\n }\n\n private ensureThatVmStarted() {\n let startPromise = this.startPromise\n if (startPromise == null) {\n startPromise = this.doStartVm()\n this.startPromise = startPromise\n }\n return startPromise\n }\n\n // The guest's environment is not visible from the host, so the location of a default Windows installation is used. PowerShell 7\n // is not: `prlctl exec` passes its arguments to the guest without quoting, so a path containing a space cannot be started.\n protected windowsPowerShellPaths() {\n return {\n powershell: PARALLELS_GUEST_WINDOWS_POWERSHELL,\n pwsh: { unavailable: `PowerShell 7 (${PARALLELS_GUEST_PWSH}) is not used in a Parallels VM, because prlctl exec cannot start a path that contains a space` },\n }\n }\n\n toVmFile(file: string): string {\n // https://stackoverflow.com/questions/4742992/cannot-access-network-drive-in-powershell-running-as-administrator\n return macPathToParallelsWindows(file)\n }\n}\n\nexport function macPathToParallelsWindows(file: string) {\n if (file.startsWith(\"C:\\\\\")) {\n return file\n }\n if (!file.startsWith(\"/\")) {\n throw new Error(`Invalid path for Parallels VM execution: \"${file}\"`)\n }\n // Validate the raw host path up-front and reject control bytes plus shell/UNC-significant\n // metacharacters BEFORE it is concatenated into the \\\\Mac\\... path passed to `prlctl exec`. The\n // `/`→`\\` conversion below only adds backslashes (not in the deny-set), so validating the input here\n // is the single sanitizing barrier for the value that reaches the command.\n // (CodeQL js/shell-command-constructed-from-input — sanitize the tainted input at the source.)\n // eslint-disable-next-line no-control-regex\n if (/[\\x00-\\x1F\\x7F\"*?<>|]/.test(file)) {\n throw new Error(`Invalid path for Parallels VM execution: \"${file}\"`)\n }\n // sanitizeDirPath additionally rejects null/newline and resolves the path; the input is already\n // validated above, so the resulting UNC path is safe to hand to prlctl.\n const sanitized = sanitizeDirPath(file)\n // \\\\Mac\\Home maps to the current user's home directory and is always accessible\n // in both --current-user and SYSTEM exec contexts (unlike \\\\Mac\\Host which requires\n // \"All Disks\" sharing to be enabled in Parallels preferences).\n const home = homedir()\n // codeql[js/shell-command-constructed-from-input] - `file` is validated above (control bytes + shell/UNC metacharacters rejected) and resolved via sanitizeDirPath; the resulting UNC path is passed to prlctl as a discrete execFile argv element (array args, no shell), so no shell interpretation occurs\n const uncPath = sanitized.startsWith(home + \"/\")\n ? \"\\\\\\\\Mac\\\\Home\\\\\" + sanitized.substring(home.length + 1).replace(/\\//g, \"\\\\\")\n : \"\\\\\\\\Mac\\\\Host\\\\\" + sanitized.replace(/\\//g, \"\\\\\")\n return uncPath\n}\n\nexport interface ParallelsVm {\n id: string\n name: string\n os: \"win-10\" | \"win-11\" | \"ubuntu\" | \"elementary\"\n state: \"running\" | \"suspended\" | \"stopped\"\n}\n"]}
@@ -1,7 +1,6 @@
1
1
  import { Lazy } from "lazy-val";
2
2
  import { VmManager } from "./vm.js";
3
3
  export declare class PwshVmManager extends VmManager {
4
- constructor();
5
4
  readonly powershellCommand: Lazy<string>;
6
5
  }
7
6
  //# sourceMappingURL=PwshVm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PwshVm.d.ts","sourceRoot":"","sources":["../../src/vm/PwshVm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAmB,SAAS,EAAE,MAAM,SAAS,CAAA;AAEpD,qBAAa,aAAc,SAAQ,SAAS;;IAK1C,QAAQ,CAAC,iBAAiB,eAcxB;CACH"}
1
+ {"version":3,"file":"PwshVm.d.ts","sourceRoot":"","sources":["../../src/vm/PwshVm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,qBAAa,aAAc,SAAQ,SAAS;IAG1C,QAAQ,CAAC,iBAAiB,eAMzB;CACF"}
package/dist/vm/PwshVm.js CHANGED
@@ -1,21 +1,16 @@
1
- import { log } from "builder-util";
1
+ import { Executables, log } from "builder-util";
2
2
  import { Lazy } from "lazy-val";
3
- import { isPwshAvailable, VmManager } from "./vm.js";
3
+ import { VmManager } from "./vm.js";
4
4
  export class PwshVmManager extends VmManager {
5
5
  constructor() {
6
- super();
7
- this.powershellCommand = new Lazy(async () => {
8
- log.info(null, "checking for `pwsh` for powershell");
9
- if (await isPwshAvailable.value) {
10
- return "pwsh";
11
- }
12
- const errorMessage = `unable to find \`pwsh\`, please install per instructions linked in logs`;
13
- log.error({
14
- mac: "https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-macos",
15
- linux: "https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux",
16
- }, errorMessage);
17
- throw new Error(errorMessage);
18
- });
6
+ super(...arguments);
7
+ // pwsh by absolute path (toolsets.executables.pwsh or its default install location), never looked up on PATH
8
+ // (a configuration error rejects the promise, like any other failure to find PowerShell)
9
+ this.powershellCommand = new Lazy(() => Promise.resolve().then(() => {
10
+ const pwsh = Executables.resolve("pwsh");
11
+ log.info({ path: pwsh }, "using PowerShell 7");
12
+ return pwsh;
13
+ }));
19
14
  }
20
15
  }
21
16
  //# sourceMappingURL=PwshVm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PwshVm.js","sourceRoot":"","sources":["../../src/vm/PwshVm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEpD,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C;QACE,KAAK,EAAE,CAAA;QAGA,sBAAiB,GAAG,IAAI,IAAI,CAAS,KAAK,IAAI,EAAE;YACvD,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,oCAAoC,CAAC,CAAA;YACpD,IAAI,MAAM,eAAe,CAAC,KAAK,EAAE,CAAC;gBAChC,OAAO,MAAM,CAAA;YACf,CAAC;YACD,MAAM,YAAY,GAAG,yEAAyE,CAAA;YAC9F,GAAG,CAAC,KAAK,CACP;gBACE,GAAG,EAAE,+FAA+F;gBACpG,KAAK,EAAE,+FAA+F;aACvG,EACD,YAAY,CACb,CAAA;YACD,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;QAC/B,CAAC,CAAC,CAAA;IAhBF,CAAC;CAiBF","sourcesContent":["import { log } from \"builder-util\"\nimport { Lazy } from \"lazy-val\"\nimport { isPwshAvailable, VmManager } from \"./vm.js\"\n\nexport class PwshVmManager extends VmManager {\n constructor() {\n super()\n }\n\n readonly powershellCommand = new Lazy<string>(async () => {\n log.info(null, \"checking for `pwsh` for powershell\")\n if (await isPwshAvailable.value) {\n return \"pwsh\"\n }\n const errorMessage = `unable to find \\`pwsh\\`, please install per instructions linked in logs`\n log.error(\n {\n mac: \"https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-macos\",\n linux: \"https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux\",\n },\n errorMessage\n )\n throw new Error(errorMessage)\n })\n}\n"]}
1
+ {"version":3,"file":"PwshVm.js","sourceRoot":"","sources":["../../src/vm/PwshVm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,MAAM,OAAO,aAAc,SAAQ,SAAS;IAA5C;;QACE,6GAA6G;QAC7G,yFAAyF;QAChF,sBAAiB,GAAG,IAAI,IAAI,CAAS,GAAG,EAAE,CACjD,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC1B,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACxC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,oBAAoB,CAAC,CAAA;YAC9C,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CACH,CAAA;IACH,CAAC;CAAA","sourcesContent":["import { Executables, log } from \"builder-util\"\nimport { Lazy } from \"lazy-val\"\nimport { VmManager } from \"./vm.js\"\n\nexport class PwshVmManager extends VmManager {\n // pwsh by absolute path (toolsets.executables.pwsh or its default install location), never looked up on PATH\n // (a configuration error rejects the promise, like any other failure to find PowerShell)\n readonly powershellCommand = new Lazy<string>(() =>\n Promise.resolve().then(() => {\n const pwsh = Executables.resolve(\"pwsh\")\n log.info({ path: pwsh }, \"using PowerShell 7\")\n return pwsh\n })\n )\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WineVm.d.ts","sourceRoot":"","sources":["../../src/vm/WineVm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEtD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AASnC,qBAAa,aAAc,SAAQ,SAAS;IAExC,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBADjB,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,EAClC,iBAAiB,EAAE,MAAM;IAK5C,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe,EAAE,gBAAgB,UAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAK5G,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC;IAIhH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;YAIhB,QAAQ;CAavB"}
1
+ {"version":3,"file":"WineVm.d.ts","sourceRoot":"","sources":["../../src/vm/WineVm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,iBAAiB,EAAyB,MAAM,cAAc,CAAA;AAE7E,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AASnC,qBAAa,aAAc,SAAQ,SAAS;IAExC,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBADjB,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,EAClC,iBAAiB,EAAE,MAAM;IAK5C,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe,EAAE,gBAAgB,UAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAK5G,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC;IAIhH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;YAIhB,QAAQ;CAavB"}
package/dist/vm/WineVm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { exec } from "builder-util";
1
+ import { exec, stripSensitiveEnvVars } from "builder-util";
2
2
  import * as path from "path";
3
3
  import { getWineToolset } from "../toolsets/wine.js";
4
4
  import { VmManager } from "./vm.js";
@@ -27,9 +27,9 @@ export class WineVmManager extends VmManager {
27
27
  return exec(target, appArgs, options);
28
28
  }
29
29
  const { execPath: wineExe, env: wineEnv } = await getWineToolset(toolset, this.buildResourcesDir);
30
- // Preserve the base process environment (PATH, HOME, TMPDIR, etc.) so Wine and child
31
- // tools start correctly. Wine env vars override the base; caller options.env wins last.
32
- return exec(wineExe, [target, ...appArgs], { ...options, env: { ...process.env, ...wineEnv, ...options.env } });
30
+ // Preserve the base process environment (PATH, HOME, TMPDIR, etc.) so Wine and child tools start correctly, without credentials:
31
+ // a caller passes those it needs. Wine env vars override the base; caller options.env wins last.
32
+ return exec(wineExe, [target, ...appArgs], { ...options, env: { ...stripSensitiveEnvVars(process.env), ...wineEnv, ...options.env } });
33
33
  }
34
34
  }
35
35
  //# sourceMappingURL=WineVm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WineVm.js","sourceRoot":"","sources":["../../src/vm/WineVm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAqB,MAAM,cAAc,CAAA;AAGtD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AASnC,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,YACmB,WAAkC,EAClC,iBAAyB;QAE1C,KAAK,EAAE,CAAA;QAHU,gBAAW,GAAX,WAAW,CAAuB;QAClC,sBAAiB,GAAjB,iBAAiB,CAAQ;IAG5C,CAAC;IAED,IAAI,CAAC,IAAY,EAAE,IAAmB,EAAE,OAAyB,EAAE,gBAAgB,GAAG,IAAI;QACxF,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;IACnF,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,IAAY,EAAE,IAAmB,EAAE,OAAsB,EAAE,YAAgC;QAC/F,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;IAChC,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACpC,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,OAAO,EAAe;QACvF,IAAI,OAAO,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;YAC5B,YAAY;YACZ,OAAO,CAAC,OAAO,GAAG,GAAG,GAAG,IAAI,CAAA;QAC9B,CAAC;QACD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACvC,CAAC;QACD,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAA;QACjG,qFAAqF;QACrF,wFAAwF;QACxF,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IACjH,CAAC;CACF","sourcesContent":["import { exec, ExtraSpawnOptions } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { ExecFileOptions, SpawnOptions } from \"child_process\"\nimport * as path from \"path\"\nimport { ToolsetConfig } from \"../configuration.js\"\nimport { getWineToolset } from \"../toolsets/wine.js\"\nimport { VmManager } from \"./vm.js\"\n\ntype WineOptions = {\n file: string\n appArgs?: Array<string>\n options?: ExecFileOptions\n toolset: ToolsetConfig[\"wine\"] | Nullish\n}\n\nexport class WineVmManager extends VmManager {\n constructor(\n private readonly wineToolset: ToolsetConfig[\"wine\"],\n private readonly buildResourcesDir: string\n ) {\n super()\n }\n\n exec(file: string, args: Array<string>, options?: ExecFileOptions, _isLogOutIfDebug = true): Promise<string> {\n return this.execWine({ file, appArgs: args, options, toolset: this.wineToolset })\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any> {\n throw new Error(\"Unsupported\")\n }\n\n toVmFile(file: string): string {\n return path.win32.join(\"Z:\", file)\n }\n\n private async execWine({ file: target, appArgs = [], options = {}, toolset }: WineOptions): Promise<string> {\n if (options.timeout == null) {\n // 2 minutes\n options.timeout = 120 * 1000\n }\n if (process.platform === \"win32\") {\n return exec(target, appArgs, options)\n }\n const { execPath: wineExe, env: wineEnv } = await getWineToolset(toolset, this.buildResourcesDir)\n // Preserve the base process environment (PATH, HOME, TMPDIR, etc.) so Wine and child\n // tools start correctly. Wine env vars override the base; caller options.env wins last.\n return exec(wineExe, [target, ...appArgs], { ...options, env: { ...process.env, ...wineEnv, ...options.env } })\n }\n}\n"]}
1
+ {"version":3,"file":"WineVm.js","sourceRoot":"","sources":["../../src/vm/WineVm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAqB,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAG7E,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AASnC,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,YACmB,WAAkC,EAClC,iBAAyB;QAE1C,KAAK,EAAE,CAAA;QAHU,gBAAW,GAAX,WAAW,CAAuB;QAClC,sBAAiB,GAAjB,iBAAiB,CAAQ;IAG5C,CAAC;IAED,IAAI,CA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,EAAE,EAAE,CAAC,CAAA;IACxI,CAAC;CACF","sourcesContent":["import { exec, ExtraSpawnOptions, stripSensitiveEnvVars } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { ExecFileOptions, SpawnOptions } from \"child_process\"\nimport * as path from \"path\"\nimport { ToolsetConfig } from \"../configuration.js\"\nimport { getWineToolset } from \"../toolsets/wine.js\"\nimport { VmManager } from \"./vm.js\"\n\ntype WineOptions = {\n file: string\n appArgs?: Array<string>\n options?: ExecFileOptions\n toolset: ToolsetConfig[\"wine\"] | Nullish\n}\n\nexport class WineVmManager extends VmManager {\n constructor(\n private readonly wineToolset: ToolsetConfig[\"wine\"],\n private readonly buildResourcesDir: string\n ) {\n super()\n }\n\n exec(file: string, args: Array<string>, options?: ExecFileOptions, _isLogOutIfDebug = true): Promise<string> {\n return this.execWine({ file, appArgs: args, options, toolset: this.wineToolset })\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any> {\n throw new Error(\"Unsupported\")\n }\n\n toVmFile(file: string): string {\n return path.win32.join(\"Z:\", file)\n }\n\n private async execWine({ file: target, appArgs = [], options = {}, toolset }: WineOptions): Promise<string> {\n if (options.timeout == null) {\n // 2 minutes\n options.timeout = 120 * 1000\n }\n if (process.platform === \"win32\") {\n return exec(target, appArgs, options)\n }\n const { execPath: wineExe, env: wineEnv } = await getWineToolset(toolset, this.buildResourcesDir)\n // Preserve the base process environment (PATH, HOME, TMPDIR, etc.) so Wine and child tools start correctly, without credentials:\n // a caller passes those it needs. Wine env vars override the base; caller options.env wins last.\n return exec(wineExe, [target, ...appArgs], { ...options, env: { ...stripSensitiveEnvVars(process.env), ...wineEnv, ...options.env } })\n }\n}\n"]}
package/dist/vm/vm.d.ts CHANGED
@@ -7,11 +7,17 @@ export declare class VmManager {
7
7
  exec(file: string, args: Array<string>, options?: ExecFileOptions, isLogOutIfDebug?: boolean): Promise<string>;
8
8
  spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any>;
9
9
  toVmFile(file: string): string;
10
+ protected windowsPowerShellPaths(): {
11
+ powershell: string;
12
+ pwsh: {
13
+ path: string;
14
+ } | {
15
+ unavailable: string;
16
+ };
17
+ };
10
18
  readonly powershellCommand: Lazy<string>;
11
19
  }
12
- export declare function getWindowsVm(debugLogger: DebugLogger): Promise<VmManager>;
20
+ export declare function getWindowsVm(debugLogger: DebugLogger, wineToolset?: ToolsetConfig["wine"]): Promise<VmManager>;
13
21
  export declare function getWindowsExecVm(debugLogger: DebugLogger, wineToolset: ToolsetConfig["wine"], buildResourcesDir: string): Promise<VmManager>;
14
22
  export declare function getLinuxVm(debugLogger: DebugLogger): Promise<VmManager | undefined>;
15
- export declare const isPwshAvailable: Lazy<boolean>;
16
- export declare const isCommandAvailable: (command: string, args: string[]) => Promise<boolean>;
17
23
  //# sourceMappingURL=vm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vm.d.ts","sourceRoot":"","sources":["../../src/vm/vm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAQ,iBAAiB,EAAyC,MAAM,cAAc,CAAA;AAC1G,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,qBAAa,SAAS;IACpB,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe,EAAE,eAAe,UAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAO3G,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CA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