Skip to content

Commit 4e43d8c

Browse files
committed
Support Boa nightly version
You can get nightly releases from https://github.com/boa-dev/boa/releases/tag/nightly This adds support for installing them when you don't specify a version for Boa. The filenames are somewhat different and we tag the version internally with the updated_at string so that different nightlies aren't considered to be the same version.
1 parent 9bcf523 commit 4e43d8c

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

src/engines/boa.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,27 @@ const { platform } = require('../common');
1010

1111
const binaryName = platform.startsWith('win') ? 'boa.exe' : 'boa';
1212

13-
function getFilename() {
13+
function isNightly(version) {
14+
return version.startsWith('nightly');
15+
}
16+
17+
function getReleaseTag(version) {
18+
return isNightly(version) ? 'nightly' : version;
19+
}
20+
21+
function getFilename(version) {
1422
switch (platform) {
1523
case 'darwin-x64':
16-
return 'boa-macos-amd64';
24+
return isNightly(version) ? 'boa-x86_64-apple-darwin' : 'boa-macos-amd64';
1725
case 'linux-x64':
18-
return 'boa-linux-amd64';
26+
return isNightly(version) ? 'boa-x86_64-unknown-linux-gnu' : 'boa-linux-amd64';
1927
case 'win32-x64':
20-
return 'boa-windows-amd64.exe';
28+
return isNightly(version) ? 'boa-x86_64-pc-windows-msvc.exe' : 'boa-windows-amd64.exe';
29+
case 'darwin-arm64':
30+
if (isNightly(version)) {
31+
return 'boa-aarch64-apple-darwin';
32+
}
33+
// fall through
2134
default:
2235
throw new Error(`No Boa builds available for ${platform}`);
2336
}
@@ -31,15 +44,18 @@ class BoaInstaller extends Installer {
3144

3245
static resolveVersion(version) {
3346
if (version === 'latest') {
34-
return fetch('https://api.github.com/repos/boa-dev/boa/releases/latest')
47+
// Boa has nightly releases under the 'nightly' tag on GitHub, which are
48+
// updated instead of making a new release for each one. Tag the version
49+
// with the time the tag was last updated.
50+
return fetch('https://api.github.com/repos/boa-dev/boa/releases/tags/nightly')
3551
.then((r) => r.json())
36-
.then((r) => r.tag_name);
52+
.then((r) => `nightly-${r.updated_at}`);
3753
}
3854
return version;
3955
}
4056

4157
getDownloadURL(version) {
42-
return `https://github.com/boa-dev/boa/releases/download/${version}/${getFilename()}`;
58+
return `https://github.com/boa-dev/boa/releases/download/${getReleaseTag(version)}/${getFilename(version)}`;
4359
}
4460

4561
async extract() {
@@ -75,6 +91,7 @@ BoaInstaller.config = {
7591
'linux-x64',
7692
'win32-x64',
7793
'darwin-x64',
94+
'darwin-arm64',
7895
],
7996
};
8097

0 commit comments

Comments
 (0)