Skip to content

Commit b9c1b66

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 eed7e3a commit b9c1b66

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/engines/boa.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,25 @@ 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)) return 'boa-aarch64-apple-darwin';
31+
// fall through
2132
default:
2233
throw new Error(`No Boa builds available for ${platform}`);
2334
}
@@ -31,15 +42,18 @@ class BoaInstaller extends Installer {
3142

3243
static resolveVersion(version) {
3344
if (version === 'latest') {
34-
return fetch('https://api.github.com/repos/boa-dev/boa/releases/latest')
45+
// Boa has nightly releases under the 'nightly' tag on GitHub, which are
46+
// updated instead of making a new release for each one. Tag the version
47+
// with the time the tag was last updated.
48+
return fetch('https://api.github.com/repos/boa-dev/boa/releases/tags/nightly')
3549
.then((r) => r.json())
36-
.then((r) => r.tag_name);
50+
.then((r) => `nightly-${r.updated_at}`);
3751
}
3852
return version;
3953
}
4054

4155
getDownloadURL(version) {
42-
return `https://github.com/boa-dev/boa/releases/download/${version}/${getFilename()}`;
56+
return `https://github.com/boa-dev/boa/releases/download/${getReleaseTag(version)}/${getFilename(version)}`;
4357
}
4458

4559
async extract() {
@@ -75,6 +89,7 @@ BoaInstaller.config = {
7589
'linux-x64',
7690
'win32-x64',
7791
'darwin-x64',
92+
'darwin-arm64'
7893
],
7994
};
8095

0 commit comments

Comments
 (0)