Repository: electron/electron-packager (js)

Issue:
Building for Linux arm64 with a beta version of Electron doesn't work
### Preflight Checklist
<!-- Please ensure you've completed the following steps by replacing [ ] with [x]-->

* [x] I have read the [contribution documentation](https://github.com/electron/electron-packager/blob/master/CONTRIBUTING.md) for this project.
* [x] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project follows, as appropriate.
* [x] I have searched the issue tracker for a bug that matches the one I want to file, without success.

### Issue Details

* **Electron Packager Version:** 15.1.0
* **Electron Version:** 11.0.0-beta.22
* **Operating System:** Ubuntu 20.04
* **Last Known Working Electron Packager version:**:

I'm trying to create a Linux Arm64 package for Electron 11.0.0-beta.22, but when I call electron-packager from my build script, it returns immediately with an empty paths array, and I get the following error:
```
WARNING: official linux/arm64 support only exists in Electron >=1.8.0
```
Even though I'm using an Electron version greater than that.

Looking through the code, I think this is ultimately an issue in [officialBuildExists](https://github.com/electron/electron-packager/blob/master/src/targets.js#L81-L83), which is returning false in this case when it shouldn't. If I try calling semver:
```
semver.satisfies('11.0.0-beta.22', '>= 1.8.0')
```
I get `false`, which seems wrong. (If I test it with "11.0.0", it works correctly). That causes the packager script to assume that no builds are available and return early without actually packaging anything.

I'm not sure what the right fix is here - is this an issue with the `semver` package? Or is there a different check that's supposed to be used here? But if you have an idea what the right fix should be, I'd be happy to make a PR for it.

Pull request:
fix(targets): allow checking official builds against prerelease versions
<!--
Thanks for filing a pull request!
Please check off all of the steps as they are completed by replacing [ ] with [x].
-->

* [x] I have read the [contribution documentation](https://github.com/electron/electron-packager/blob/master/CONTRIBUTING.md) for this project.
* [x] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project follows, as appropriate.
* [x] The changes are appropriately documented (if applicable).
* [x] The changes have sufficient test coverage (if applicable).
* [x] The testsuite passes successfully on my local machine (if applicable).

**Summarize your changes:**

Fixes #1190 

The behavior exhibited by semver in that issue is apparently [intended behavior](https://github.com/npm/node-semver#prerelease-tags), but I don't think it makes much sense in this context, so I've set the option to disable it, which allows ARM64 builds to work as intended.

Patch:
diff --git a/src/targets.js b/src/targets.js
index edb36d1..5a5cc3c 100644
--- a/src/targets.js
+++ b/src/targets.js
@@ -79,7 +79,7 @@ function validOfficialPlatformArch (opts, platform, arch) {
 }
 
 function officialBuildExists (opts, buildVersion) {
-  return semver.satisfies(opts.electronVersion, buildVersion)
+  return semver.satisfies(opts.electronVersion, buildVersion, { includePrerelease: true })
 }
 
 function allPlatformsOrArchsSpecified (opts) {


Test patch:
diff --git a/test/targets.js b/test/targets.js
index 541f20e..f750762 100644
--- a/test/targets.js
+++ b/test/targets.js
@@ -103,6 +103,7 @@ test('fails with invalid platform', util.invalidOptionTest({
 test('invalid official combination', testMultiTarget({ arch: 'ia32', platform: 'darwin' }, 0, 'Package should not be generated for invalid official combination'))
 
 test('platform=linux and arch=arm64 with a supported official Electron version', testMultiTarget({ arch: 'arm64', platform: 'linux', electronVersion: '1.8.0' }, 1, 'Package should be generated for linux/arm64'))
+test('platform=linux and arch=arm64 with a supported official Electron version (11.0.0-beta.22)', testMultiTarget({ arch: 'arm64', platform: 'linux', electronVersion: '11.0.0-beta.22' }, 1, 'Package should be generated for linux/arm64'))
 test('platform=linux and arch=arm64 with an unsupported official Electron version', testMultiTarget({ arch: 'arm64', platform: 'linux' }, 0, 'Package should not be generated for linux/arm64'))
 
 test('platform=linux and arch=mips64el with a supported official Electron version', testMultiTarget({ arch: 'mips64el', platform: 'linux', electronVersion: '1.8.2-beta.5' }, 1, 'Package should be generated for mips64el'))