From 3a4c11a24bc929fec6bfb89a90e82dcaea00a22d Mon Sep 17 00:00:00 2001 From: Jiawen Geng Date: Tue, 31 Jan 2023 07:55:33 +0000 Subject: [PATCH] feat: support quickjs arm64 for linux and macOS --- README.md | 2 +- package-lock.json | 63 ++++++++++++++++++++---------------------- src/engines/quickjs.js | 15 ++++++++-- 3 files changed, 44 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 9b6d913..ea879f5 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ installing engines to make eshost automatically find the installed engines. | [Hermes][] | `hermes` | ✅ | | | | | | ✅ | | [LibJS][] | `serenity-js` | ✅ | ✅ | | ✅ | | | | | [JavaScriptCore][] | `jsc`, `javascriptcore` | ✅ | ✅ | | ✅ | | | ✅ | -| [QuickJS][] | `quickjs`, `quickjs-run-test262` | ✅ | | ✅ | ✅ | | ✅ | ✅ | +| [QuickJS][] | `quickjs`, `quickjs-run-test262` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [SpiderMonkey][] | `sm`, `spidermonkey` | ✅ | ✅ | ✅ | ✅ | | ✅ | ✅ | | [V8][] | `v8` | ✅ | ✅ | ✅ | ✅ | | ✅ | ✅ | | [XS][] | `xs` | ✅ | ✅ | | ✅ | ✅ | | ✅ | diff --git a/package-lock.json b/package-lock.json index 2264254..4a9a93c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "esvu", - "version": "1.2.5", + "version": "1.2.11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "esvu", - "version": "1.2.5", + "version": "1.2.11", "license": "MIT", "dependencies": { "chalk": "^3.0.0", @@ -96,13 +96,10 @@ } }, "node_modules/@babel/core/node_modules/json5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true, - "dependencies": { - "minimist": "^1.2.5" - }, "bin": { "json5": "lib/cli.js" }, @@ -2107,9 +2104,9 @@ "dev": true }, "node_modules/json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "dependencies": { "minimist": "^1.2.0" @@ -2236,9 +2233,9 @@ } }, "node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dependencies": { "brace-expansion": "^1.1.7" }, @@ -2247,9 +2244,12 @@ } }, "node_modules/minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", + "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/minipass": { "version": "3.1.3", @@ -3212,13 +3212,10 @@ }, "dependencies": { "json5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true } } }, @@ -4703,9 +4700,9 @@ "dev": true }, "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "requires": { "minimist": "^1.2.0" @@ -4807,17 +4804,17 @@ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", + "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==" }, "minipass": { "version": "3.1.3", diff --git a/src/engines/quickjs.js b/src/engines/quickjs.js index aa9765b..56356e9 100644 --- a/src/engines/quickjs.js +++ b/src/engines/quickjs.js @@ -16,6 +16,8 @@ function getFilename() { return 'win-i686'; case 'win32-x64': return 'win-x86_64'; + case 'linux-arm64': + return 'linux-aarch64'; default: throw new Error(`No QuickJS builds available for ${platform}`); } @@ -29,6 +31,9 @@ class QuickJSInstaller extends Installer { } static resolveVersion(version) { + if (['darwin-arm64', 'darwin-x64', 'linux-arm64'].includes(platform)) { + return '6.0.0'; + } if (version === 'latest') { return fetch('https://bellard.org/quickjs/binary_releases/LATEST.json') .then((r) => r.json()) @@ -38,8 +43,14 @@ class QuickJSInstaller extends Installer { } getDownloadURL(version) { + if (platform === 'darwin-arm64') { + return `https://github.com/napi-bindings/quickjs-build/releases/download/${version}/qjs-macOS-arm64.zip`; + } if (platform === 'darwin-x64') { - return 'https://github.com/napi-bindings/quickjs-build/releases/download/5.2.0/qjs-macOS.zip'; + return `https://github.com/napi-bindings/quickjs-build/releases/download/${version}/qjs-macOS.zip`; + } + if (platform === 'linux-arm64') { + return `https://github.com/napi-bindings/quickjs-build/releases/download/${version}/qjs-linux-arm64.zip`; } return `https://bellard.org/quickjs/binary_releases/quickjs-${getFilename()}-${version}.zip`; } @@ -49,7 +60,7 @@ class QuickJSInstaller extends Installer { } async install() { - if (platform === 'darwin-x64') { + if (platform === 'darwin-x64' || platform === 'darwin-arm64' || platform === 'linux-arm64') { this.binPath = await this.registerBinary('quickjs'); await this.registerBinary('run-test262', 'quickjs-run-test262'); } else if (platform.startsWith('win')) {