chore: fetch Firefox from JSON source instead of RegExp (#5864)
Fetch Firefox from https://product-details.mozilla.org/1.0/firefox_versions.json. Fixes #5742.
This commit is contained in:
parent
69c38fc2d0
commit
b510c354c7
25
install.js
25
install.js
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
const compileTypeScriptIfRequired = require('./typescript-if-required');
|
const compileTypeScriptIfRequired = require('./typescript-if-required');
|
||||||
|
|
||||||
|
const firefoxVersions =
|
||||||
|
'https://product-details.mozilla.org/1.0/firefox_versions.json';
|
||||||
const supportedProducts = {
|
const supportedProducts = {
|
||||||
chrome: 'Chromium',
|
chrome: 'Chromium',
|
||||||
firefox: 'Firefox Nightly',
|
firefox: 'Firefox Nightly',
|
||||||
@ -160,27 +162,22 @@ async function download() {
|
|||||||
let data = '';
|
let data = '';
|
||||||
logPolitely(`Requesting latest Firefox Nightly version from ${host}`);
|
logPolitely(`Requesting latest Firefox Nightly version from ${host}`);
|
||||||
https
|
https
|
||||||
.get(host + '/', (r) => {
|
.get(firefoxVersions, (r) => {
|
||||||
if (r.statusCode >= 400)
|
if (r.statusCode >= 400)
|
||||||
return reject(new Error(`Got status code ${r.statusCode}`));
|
return reject(new Error(`Got status code ${r.statusCode}`));
|
||||||
r.on('data', (chunk) => {
|
r.on('data', (chunk) => {
|
||||||
data += chunk;
|
data += chunk;
|
||||||
});
|
});
|
||||||
r.on('end', parseVersion);
|
r.on('end', () => {
|
||||||
|
try {
|
||||||
|
const versions = JSON.parse(data);
|
||||||
|
return resolve(versions.FIREFOX_NIGHTLY);
|
||||||
|
} catch {
|
||||||
|
return reject(new Error('Firefox version not found'));
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.on('error', reject);
|
.on('error', reject);
|
||||||
|
|
||||||
function parseVersion() {
|
|
||||||
const regex = /firefox\-(?<version>\d\d)\..*/gm;
|
|
||||||
let result = 0;
|
|
||||||
let match;
|
|
||||||
while ((match = regex.exec(data)) !== null) {
|
|
||||||
const version = parseInt(match.groups.version, 10);
|
|
||||||
if (version > result) result = version;
|
|
||||||
}
|
|
||||||
if (result) resolve(result.toString());
|
|
||||||
else reject(new Error('Firefox version not found'));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,10 @@ const downloadURLs = {
|
|||||||
win64: '%s/chromium-browser-snapshots/Win_x64/%d/%s.zip',
|
win64: '%s/chromium-browser-snapshots/Win_x64/%d/%s.zip',
|
||||||
},
|
},
|
||||||
firefox: {
|
firefox: {
|
||||||
linux: '%s/firefox-%s.0a1.en-US.%s-x86_64.tar.bz2',
|
linux: '%s/firefox-%s.en-US.%s-x86_64.tar.bz2',
|
||||||
mac: '%s/firefox-%s.0a1.en-US.%s.dmg',
|
mac: '%s/firefox-%s.en-US.%s.dmg',
|
||||||
win32: '%s/firefox-%s.0a1.en-US.%s.zip',
|
win32: '%s/firefox-%s.en-US.%s.zip',
|
||||||
win64: '%s/firefox-%s.0a1.en-US.%s.zip',
|
win64: '%s/firefox-%s.en-US.%s.zip',
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ describe('Launcher specs', function () {
|
|||||||
host: server.PREFIX,
|
host: server.PREFIX,
|
||||||
product: 'firefox',
|
product: 'firefox',
|
||||||
});
|
});
|
||||||
const expectedVersion = '75';
|
const expectedVersion = '75.0a1';
|
||||||
let revisionInfo = browserFetcher.revisionInfo(expectedVersion);
|
let revisionInfo = browserFetcher.revisionInfo(expectedVersion);
|
||||||
server.setRoute(
|
server.setRoute(
|
||||||
revisionInfo.url.substring(server.PREFIX.length),
|
revisionInfo.url.substring(server.PREFIX.length),
|
||||||
@ -89,7 +89,7 @@ describe('Launcher specs', function () {
|
|||||||
server.serveFile(
|
server.serveFile(
|
||||||
req,
|
req,
|
||||||
res,
|
res,
|
||||||
`/firefox-${expectedVersion}.0a1.en-US.linux-x86_64.tar.bz2`
|
`/firefox-${expectedVersion}.en-US.linux-x86_64.tar.bz2`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user