diff --git a/README.md b/README.md index 9b6d913..969367c 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ installing engines to make eshost automatically find the installed engines. | [Chakra][] | `ch`, `chakra` | ✅ | | | ✅ | | ✅ | ✅ | | [engine262][] | `engine262` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [GraalJS][] | `graaljs` | ✅ | ✅ | | ✅ | ✅ | | ✅ | -| [Hermes][] | `hermes` | ✅ | | | | | | ✅ | +| [Hermes][] | `hermes` | ✅ | ✅ | | | | | ✅ | | [LibJS][] | `serenity-js` | ✅ | ✅ | | ✅ | | | | | [JavaScriptCore][] | `jsc`, `javascriptcore` | ✅ | ✅ | | ✅ | | | ✅ | | [QuickJS][] | `quickjs`, `quickjs-run-test262` | ✅ | | ✅ | ✅ | | ✅ | ✅ | diff --git a/package-lock.json b/package-lock.json index 2264254..32bca87 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "esvu", - "version": "1.2.5", + "version": "1.2.12", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "esvu", - "version": "1.2.5", + "version": "1.2.12", "license": "MIT", "dependencies": { "chalk": "^3.0.0", @@ -15,6 +15,7 @@ "extract-zip": "^2.0.1", "glob": "^7.1.6", "inquirer": "^7.3.3", + "macos-release": "^3.2.0", "node-fetch": "^2.6.1", "ora": "^4.1.1", "rimraf": "^3.0.2", @@ -2222,6 +2223,17 @@ "node": ">=4" } }, + "node_modules/macos-release": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/macos-release/-/macos-release-3.2.0.tgz", + "integrity": "sha512-fSErXALFNsnowREYZ49XCdOHF8wOPWuFOGQrAhP7x5J/BqQv+B02cNsTykGpDgRVx43EKg++6ANmTaGTtW+hUA==", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -4796,6 +4808,11 @@ } } }, + "macos-release": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/macos-release/-/macos-release-3.2.0.tgz", + "integrity": "sha512-fSErXALFNsnowREYZ49XCdOHF8wOPWuFOGQrAhP7x5J/BqQv+B02cNsTykGpDgRVx43EKg++6ANmTaGTtW+hUA==" + }, "merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", diff --git a/package.json b/package.json index d14aa74..4105850 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "extract-zip": "^2.0.1", "glob": "^7.1.6", "inquirer": "^7.3.3", + "macos-release": "^3.2.0", "node-fetch": "^2.6.1", "ora": "^4.1.1", "rimraf": "^3.0.2", diff --git a/src/engines/hermes.js b/src/engines/hermes.js index f9fea67..2e1bcec 100644 --- a/src/engines/hermes.js +++ b/src/engines/hermes.js @@ -14,6 +14,7 @@ function getFilename() { case 'linux-x64': return 'linux'; case 'darwin-x64': + case 'darwin-arm64': return 'darwin'; case 'win32-x64': return 'windows'; diff --git a/src/engines/javascriptcore.js b/src/engines/javascriptcore.js index c15591f..13cf6e8 100644 --- a/src/engines/javascriptcore.js +++ b/src/engines/javascriptcore.js @@ -21,8 +21,26 @@ const execa = require('execa'); const Installer = require('../installer'); const { platform, unzip } = require('../common'); -function buildURL(builder) { - return `https://build.webkit.org/api/v2/builders/${builder}/builds?limit=1&order=-number&property=got_revision&complete=true`; +async function macName() { + const { default: macosRelease } = await import('macos-release'); + return macosRelease().name.toLowerCase(); +} + +async function getVersionFromBuilder(builder) { + const url = `https://build.webkit.org/api/v2/builders/${builder}/builds?limit=1&order=-number&property=archive_revision&complete=true`; + const body = await fetch(url).then((r) => r.json()); + return body.builds[0].properties.archive_revision[0].split('@')[0]; +} + +async function getMacBuilder() { + switch (await macName()) { + case 'ventura': + return 706; + case 'monterey': + return 368; + default: + throw new Error(`Unknown macOS release: ${macName()}`); + } } class JavaScriptCoreInstaller extends Installer { @@ -44,21 +62,15 @@ class JavaScriptCoreInstaller extends Installer { if (version === 'latest') { switch (platform) { case 'linux-x64': + case 'linux-ia32': return fetch('https://webkitgtk.org/jsc-built-products/x86_64/release/LAST-IS') .then((r) => r.text()) - .then((n) => n.trim().replace('.zip', '')); - case 'win32-x64': { - const body = await fetch(buildURL(27)).then((r) => r.json()); - return body.builds[0].properties.got_revision[0]; - } - case 'darwin-x64': { - const body = await fetch(buildURL(54)).then((r) => r.json()); - return body.builds[0].properties.got_revision[0]; - } - case 'darwin-arm64': { - const body = await fetch(buildURL(29)).then((r) => r.json()); - return body.builds[0].properties.got_revision[0]; - } + .then((n) => n.trim().replace('.zip', '').split('@')[0]); + case 'win32-x64': + return getVersionFromBuilder(27); + case 'darwin-x64': + case 'darwin-arm64': + return getVersionFromBuilder(await getMacBuilder()); default: throw new RangeError(`Unknown platform ${platform}`); } @@ -66,18 +78,17 @@ class JavaScriptCoreInstaller extends Installer { return version; } - getDownloadURL(version) { + async getDownloadURL(version) { switch (platform) { case 'darwin-x64': - return `https://s3-us-west-2.amazonaws.com/minified-archives.webkit.org/mac-catalina-x86_64-release/${version}.zip`; case 'darwin-arm64': - return `https://s3-us-west-2.amazonaws.com/minified-archives.webkit.org/mac-bigsur-x86_64%20arm64-release/${version}.zip`; + return `https://s3-us-west-2.amazonaws.com/minified-archives.webkit.org/mac-${await macName()}-x86_64%20arm64-release/${version}@main.zip`; case 'linux-ia32': - return `https://webkitgtk.org/jsc-built-products/x86_32/release/${version}.zip`; + return `https://webkitgtk.org/jsc-built-products/x86_32/release/${version}@main.zip`; case 'linux-x64': - return `https://webkitgtk.org/jsc-built-products/x86_64/release/${version}.zip`; + return `https://webkitgtk.org/jsc-built-products/x86_64/release/${version}@main.zip`; case 'win32-x64': - return `https://s3-us-west-2.amazonaws.com/archives.webkit.org/wincairo-x86_64-release/${version}.zip`; + return `https://s3-us-west-2.amazonaws.com/archives.webkit.org/wincairo-x86_64-release/${version}@main.zip`; default: throw new RangeError(`Unknown platform ${platform}`); } diff --git a/src/engines/spidermonkey.js b/src/engines/spidermonkey.js index 0c5d44f..a9bd4ca 100644 --- a/src/engines/spidermonkey.js +++ b/src/engines/spidermonkey.js @@ -33,30 +33,15 @@ class SpiderMonkeyInstaller extends Installer { static async resolveVersion(version) { if (version === 'latest') { - // Build a request for buildhub2: https://buildhub2.readthedocs.io/en/latest/project.html - const body = { - size: 1, - sort: { 'build.id': 'desc' }, - query: { - bool: { - must: [ - { term: { 'source.product': 'firefox' } }, - { term: { 'source.tree': 'mozilla-central' } }, - { term: { 'target.channel': 'nightly' } }, - { term: { 'target.platform': getFilename() } }, - ], - }, - }, - }; - - const data = await fetch('https://buildhub.moz.tools/api/search', { - method: 'post', - body: JSON.stringify(body), - }).then((r) => r.json()); - - const source = data.hits.hits[0]._source; - - return `${source.target.version}#${source.build.id}`; + const result = await fetch('https://product-details.mozilla.org/1.0/firefox_history_development_releases.json') + .then((r) => r.json()); + const entries = Object.entries(result); + entries.sort(([, a], [, b]) => { + const aTime = new Date(a).getTime(); + const bTime = new Date(b).getTime(); + return bTime - aTime; + }); + return entries[0][0]; } return version; }