chore(utils): change utils/check_availability.js to fetch last revisions (#2635)
This patch changes `utils/check_availability.js` to fetch last revisions per platform when ran without any arguments.
This commit is contained in:
parent
14b5144923
commit
0ad0096e21
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
const puppeteer = require('..');
|
const puppeteer = require('..');
|
||||||
const https = require('https');
|
const https = require('https');
|
||||||
const OMAHA_PROXY = 'https://omahaproxy.appspot.com/all.json';
|
|
||||||
const SUPPORTER_PLATFORMS = ['linux', 'mac', 'win32', 'win64'];
|
const SUPPORTER_PLATFORMS = ['linux', 'mac', 'win32', 'win64'];
|
||||||
|
|
||||||
const fetchers = SUPPORTER_PLATFORMS.map(platform => puppeteer.createBrowserFetcher({platform}));
|
const fetchers = SUPPORTER_PLATFORMS.map(platform => puppeteer.createBrowserFetcher({platform}));
|
||||||
@ -67,27 +66,14 @@ const toRevision = parseInt(process.argv[3], 10);
|
|||||||
checkRangeAvailability(fromRevision, toRevision);
|
checkRangeAvailability(fromRevision, toRevision);
|
||||||
|
|
||||||
async function checkOmahaProxyAvailability() {
|
async function checkOmahaProxyAvailability() {
|
||||||
console.log('Fetching revisions from ' + OMAHA_PROXY);
|
const lastchanged = (await Promise.all([
|
||||||
const platforms = await loadJSON(OMAHA_PROXY);
|
fetch('https://storage.googleapis.com/chromium-browser-snapshots/Mac/LAST_CHANGE'),
|
||||||
if (!platforms) {
|
fetch('https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/LAST_CHANGE'),
|
||||||
console.error('ERROR: failed to fetch chromium revisions from omahaproxy.');
|
fetch('https://storage.googleapis.com/chromium-browser-snapshots/Win/LAST_CHANGE'),
|
||||||
return;
|
fetch('https://storage.googleapis.com/chromium-browser-snapshots/Win_x64/LAST_CHANGE'),
|
||||||
}
|
])).map(s => parseInt(s, 10));
|
||||||
const table = new Table([27, 7, 7, 7, 7]);
|
const from = Math.max(...lastchanged);
|
||||||
table.drawRow([''].concat(SUPPORTER_PLATFORMS));
|
checkRangeAvailability(from, 0);
|
||||||
for (const platform of platforms) {
|
|
||||||
// Trust only to the main platforms.
|
|
||||||
if (platform.os !== 'mac' && platform.os !== 'win' && platform.os !== 'win64' && platform.os !== 'linux')
|
|
||||||
continue;
|
|
||||||
const osName = platform.os === 'win' ? 'win32' : platform.os;
|
|
||||||
for (const version of platform.versions) {
|
|
||||||
if (version.channel !== 'dev' && version.channel !== 'beta' && version.channel !== 'canary' && version.channel !== 'stable')
|
|
||||||
continue;
|
|
||||||
const revisionName = padLeft('[' + osName + ' ' + version.channel + ']', 15);
|
|
||||||
const revision = parseInt(version.branch_base_position, 10);
|
|
||||||
await checkAndDrawRevisionAvailability(table, revisionName, revision);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,9 +108,9 @@ async function checkAndDrawRevisionAvailability(table, name, revision) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @return {!Promise<?Object>}
|
* @return {!Promise<?string>}
|
||||||
*/
|
*/
|
||||||
function loadJSON(url) {
|
function fetch(url) {
|
||||||
let resolve;
|
let resolve;
|
||||||
const promise = new Promise(x => resolve = x);
|
const promise = new Promise(x => resolve = x);
|
||||||
https.get(url, response => {
|
https.get(url, response => {
|
||||||
@ -137,8 +123,7 @@ function loadJSON(url) {
|
|||||||
body += chunk;
|
body += chunk;
|
||||||
});
|
});
|
||||||
response.on('end', function(){
|
response.on('end', function(){
|
||||||
const json = JSON.parse(body);
|
resolve(body);
|
||||||
resolve(json);
|
|
||||||
});
|
});
|
||||||
}).on('error', function(e){
|
}).on('error', function(e){
|
||||||
console.error('Error fetching json: ' + e);
|
console.error('Error fetching json: ' + e);
|
||||||
@ -167,16 +152,6 @@ function filterOutColors(text) {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} text
|
|
||||||
* @param {number} length
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
function padLeft(text, length) {
|
|
||||||
const printableCharacters = filterOutColors(text);
|
|
||||||
return printableCharacters.length >= length ? text : spaceString(length - text.length) + text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} text
|
* @param {string} text
|
||||||
* @param {number} length
|
* @param {number} length
|
||||||
|
Loading…
Reference in New Issue
Block a user