From 87a1527e28ea8a24ebc9ff61fc19a42e6f399b23 Mon Sep 17 00:00:00 2001 From: Leszek Swirski Date: Wed, 4 Dec 2024 13:35:55 +0100 Subject: [PATCH] Support GraalJS v23+ native standalone binary (#154) --- engines/graaljs/extract.js | 5 ++++- engines/graaljs/get-latest-version.js | 2 +- engines/graaljs/predict-url.js | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/engines/graaljs/extract.js b/engines/graaljs/extract.js index 595f380..c1b888b 100644 --- a/engines/graaljs/extract.js +++ b/engines/graaljs/extract.js @@ -44,7 +44,10 @@ const extract = ({ filePath, binary, alias, os }) => { case 'linux64': { const directoryName = fs.readdirSync(tmpPath).find(file => file.startsWith('graaljs')); const executableName = `${directoryName}/bin/js`; - installer.installBinary({ [executableName]: binary }); + installer.installBinary(executableName, { symlink: false }); + installer.installLibraryGlob(`${directoryName}/lib/*.so`); + installer.installLibraryGlob(`${directoryName}/modules/*.jar`); + installer.installBinarySymlink({ [executableName]: binary }); break; } case 'win64': { diff --git a/engines/graaljs/get-latest-version.js b/engines/graaljs/get-latest-version.js index 0f6acc1..a5c7c0a 100644 --- a/engines/graaljs/get-latest-version.js +++ b/engines/graaljs/get-latest-version.js @@ -21,7 +21,7 @@ const getLatestVersion = async () => { json: true, }); const data = response.body; - const version = data.tag_name.slice(3); // Strip `vm-` prefix. + const version = data.tag_name.replace(/^(vm-|graal-)/, ''); // Strip prefix. return version; }; diff --git a/engines/graaljs/predict-url.js b/engines/graaljs/predict-url.js index 628b436..c549be8 100644 --- a/engines/graaljs/predict-url.js +++ b/engines/graaljs/predict-url.js @@ -35,7 +35,9 @@ const predictFileName = (os) => { const predictUrl = (version, os) => { const fileName = predictFileName(os); const ext = os.startsWith('win') ? 'zip' : 'tar.gz'; - const url = `https://github.com/oracle/graaljs/releases/download/vm-${version}/graaljs-${version}-${fileName}-amd64.${ext}`; + const majorVersion = parseInt(version.split('.')[0]); + const prefix = majorVersion >= 23 ? 'graal-' : 'vm-'; + const url = `https://github.com/oracle/graaljs/releases/download/${prefix}${version}/graaljs-${version}-${fileName}-amd64.${ext}`; return url; };