Skip to content

Commit

Permalink
fix jsc and sm
Browse files Browse the repository at this point in the history
  • Loading branch information
devsnek committed Oct 27, 2023
1 parent f5b6067 commit cf80d08
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 34 deletions.
21 changes: 19 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 20 additions & 8 deletions src/engines/javascriptcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ 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()[0].toLowerCase();
}

async function getMacBuildId() {
switch (await macName()) {
case 'ventura':
return 706;
case 'monterey':
return 368;
default:
throw new Error(`Unknown macOS release: ${macName()}`);
}
}

class JavaScriptCoreInstaller extends Installer {
constructor(...args) {
super(...args);
Expand All @@ -51,12 +67,9 @@ class JavaScriptCoreInstaller extends Installer {
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-x64':
case 'darwin-arm64': {
const body = await fetch(buildURL(29)).then((r) => r.json());
const body = await fetch(buildURL(await getMacBuildId())).then((r) => r.json());
return body.builds[0].properties.got_revision[0];
}
default:
Expand All @@ -66,12 +79,11 @@ 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`;
case 'linux-x64':
Expand Down
33 changes: 9 additions & 24 deletions src/engines/spidermonkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit cf80d08

Please sign in to comment.