Skip to content

Commit 5386860

Browse files
authored
fix some engines (#52)
1 parent f5b6067 commit 5386860

File tree

6 files changed

+63
-48
lines changed

6 files changed

+63
-48
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ installing engines to make eshost automatically find the installed engines.
3939
| [Chakra][] | `ch`, `chakra` || | || |||
4040
| [engine262][] | `engine262` ||||||||
4141
| [GraalJS][] | `graaljs` ||| ||| ||
42-
| [Hermes][] | `hermes` || | | | | ||
42+
| [Hermes][] | `hermes` || | | | | ||
4343
| [LibJS][] | `serenity-js` ||| || | | |
4444
| [JavaScriptCore][] | `jsc`, `javascriptcore` ||| || | ||
4545
| [QuickJS][] | `quickjs`, `quickjs-run-test262` || ||| |||

package-lock.json

Lines changed: 19 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"extract-zip": "^2.0.1",
1111
"glob": "^7.1.6",
1212
"inquirer": "^7.3.3",
13+
"macos-release": "^3.2.0",
1314
"node-fetch": "^2.6.1",
1415
"ora": "^4.1.1",
1516
"rimraf": "^3.0.2",

src/engines/hermes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function getFilename() {
1414
case 'linux-x64':
1515
return 'linux';
1616
case 'darwin-x64':
17+
case 'darwin-arm64':
1718
return 'darwin';
1819
case 'win32-x64':
1920
return 'windows';

src/engines/javascriptcore.js

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,26 @@ const execa = require('execa');
2121
const Installer = require('../installer');
2222
const { platform, unzip } = require('../common');
2323

24-
function buildURL(builder) {
25-
return `https://build.webkit.org/api/v2/builders/${builder}/builds?limit=1&order=-number&property=got_revision&complete=true`;
24+
async function macName() {
25+
const { default: macosRelease } = await import('macos-release');
26+
return macosRelease().name.toLowerCase();
27+
}
28+
29+
async function getVersionFromBuilder(builder) {
30+
const url = `https://build.webkit.org/api/v2/builders/${builder}/builds?limit=1&order=-number&property=archive_revision&complete=true`;
31+
const body = await fetch(url).then((r) => r.json());
32+
return body.builds[0].properties.archive_revision[0].split('@')[0];
33+
}
34+
35+
async function getMacBuilder() {
36+
switch (await macName()) {
37+
case 'ventura':
38+
return 706;
39+
case 'monterey':
40+
return 368;
41+
default:
42+
throw new Error(`Unknown macOS release: ${macName()}`);
43+
}
2644
}
2745

2846
class JavaScriptCoreInstaller extends Installer {
@@ -44,40 +62,33 @@ class JavaScriptCoreInstaller extends Installer {
4462
if (version === 'latest') {
4563
switch (platform) {
4664
case 'linux-x64':
65+
case 'linux-ia32':
4766
return fetch('https://webkitgtk.org/jsc-built-products/x86_64/release/LAST-IS')
4867
.then((r) => r.text())
49-
.then((n) => n.trim().replace('.zip', ''));
50-
case 'win32-x64': {
51-
const body = await fetch(buildURL(27)).then((r) => r.json());
52-
return body.builds[0].properties.got_revision[0];
53-
}
54-
case 'darwin-x64': {
55-
const body = await fetch(buildURL(54)).then((r) => r.json());
56-
return body.builds[0].properties.got_revision[0];
57-
}
58-
case 'darwin-arm64': {
59-
const body = await fetch(buildURL(29)).then((r) => r.json());
60-
return body.builds[0].properties.got_revision[0];
61-
}
68+
.then((n) => n.trim().replace('.zip', '').split('@')[0]);
69+
case 'win32-x64':
70+
return getVersionFromBuilder(27);
71+
case 'darwin-x64':
72+
case 'darwin-arm64':
73+
return getVersionFromBuilder(await getMacBuilder());
6274
default:
6375
throw new RangeError(`Unknown platform ${platform}`);
6476
}
6577
}
6678
return version;
6779
}
6880

69-
getDownloadURL(version) {
81+
async getDownloadURL(version) {
7082
switch (platform) {
7183
case 'darwin-x64':
72-
return `https://s3-us-west-2.amazonaws.com/minified-archives.webkit.org/mac-catalina-x86_64-release/${version}.zip`;
7384
case 'darwin-arm64':
74-
return `https://s3-us-west-2.amazonaws.com/minified-archives.webkit.org/mac-bigsur-x86_64%20arm64-release/${version}.zip`;
85+
return `https://s3-us-west-2.amazonaws.com/minified-archives.webkit.org/mac-${await macName()}-x86_64%20arm64-release/${version}@main.zip`;
7586
case 'linux-ia32':
76-
return `https://webkitgtk.org/jsc-built-products/x86_32/release/${version}.zip`;
87+
return `https://webkitgtk.org/jsc-built-products/x86_32/release/${version}@main.zip`;
7788
case 'linux-x64':
78-
return `https://webkitgtk.org/jsc-built-products/x86_64/release/${version}.zip`;
89+
return `https://webkitgtk.org/jsc-built-products/x86_64/release/${version}@main.zip`;
7990
case 'win32-x64':
80-
return `https://s3-us-west-2.amazonaws.com/archives.webkit.org/wincairo-x86_64-release/${version}.zip`;
91+
return `https://s3-us-west-2.amazonaws.com/archives.webkit.org/wincairo-x86_64-release/${version}@main.zip`;
8192
default:
8293
throw new RangeError(`Unknown platform ${platform}`);
8394
}

src/engines/spidermonkey.js

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,15 @@ class SpiderMonkeyInstaller extends Installer {
3333

3434
static async resolveVersion(version) {
3535
if (version === 'latest') {
36-
// Build a request for buildhub2: https://buildhub2.readthedocs.io/en/latest/project.html
37-
const body = {
38-
size: 1,
39-
sort: { 'build.id': 'desc' },
40-
query: {
41-
bool: {
42-
must: [
43-
{ term: { 'source.product': 'firefox' } },
44-
{ term: { 'source.tree': 'mozilla-central' } },
45-
{ term: { 'target.channel': 'nightly' } },
46-
{ term: { 'target.platform': getFilename() } },
47-
],
48-
},
49-
},
50-
};
51-
52-
const data = await fetch('https://buildhub.moz.tools/api/search', {
53-
method: 'post',
54-
body: JSON.stringify(body),
55-
}).then((r) => r.json());
56-
57-
const source = data.hits.hits[0]._source;
58-
59-
return `${source.target.version}#${source.build.id}`;
36+
const result = await fetch('https://product-details.mozilla.org/1.0/firefox_history_development_releases.json')
37+
.then((r) => r.json());
38+
const entries = Object.entries(result);
39+
entries.sort(([, a], [, b]) => {
40+
const aTime = new Date(a).getTime();
41+
const bTime = new Date(b).getTime();
42+
return bTime - aTime;
43+
});
44+
return entries[0][0];
6045
}
6146
return version;
6247
}

0 commit comments

Comments
 (0)