Skip to content

Commit

Permalink
Support newer versions of hermes (#155)
Browse files Browse the repository at this point in the history
The npm hermes-engine appears to be behind the actual hermes releases (as of writing, stuck on v11 where v13 is available). Switch the hermes downloader to look up the version via the github releases API, and fix up the URL predictor to support a change in the download URL format.
  • Loading branch information
LeszekSwirski authored Dec 4, 2024
1 parent f47bce3 commit aa81f01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
20 changes: 7 additions & 13 deletions engines/hermes/get-latest-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,14 @@

const get = require('../../shared/get.js');

const getLatestVersion = (os) => {
const url = 'https://registry.npmjs.org/hermes-engine';
return new Promise(async (resolve, reject) => {
try {
const response = await get(url, {
json: true,
});
const data = response.body;
const version = data['dist-tags'].latest;
resolve(version);
} catch (error) {
reject(error);
}
const getLatestVersion = async (os) => {
const url = 'https://api.github.com/repos/facebook/hermes/releases/latest';
const response = await get(url, {
json: true,
});
const data = response.body;
const version = data.tag_name.replace(/^v/, ''); // Strip prefix.
return version;
};

module.exports = getLatestVersion;
5 changes: 4 additions & 1 deletion engines/hermes/predict-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ const predictFileName = (os) => {

const predictUrl = (version, os) => {
const fileName = predictFileName(os);
const url = `https://github.com/facebook/hermes/releases/download/v${version}/hermes-cli-${fileName}-v${version}.tar.gz`;
const majorVersion = parseInt(version.split('.')[0]);
const minorVersion = parseInt(version.split('.')[1]);
const suffix = majorVersion > 0 || minorVersion >= 13 ? '' : `-v${version}`;
const url = `https://github.com/facebook/hermes/releases/download/v${version}/hermes-cli-${fileName}${suffix}.tar.gz`;
return url;
};

Expand Down

0 comments on commit aa81f01

Please sign in to comment.