chore: roll_browser to also update docs (#3088)

This commit is contained in:
Dmitry Gozman 2020-07-22 11:03:35 -07:00 committed by GitHub
parent ea5dfdbec7
commit 4db035dff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 15 deletions

View File

@ -35,6 +35,7 @@ run();
async function run() {
const startTime = Date.now();
const onlyBrowserVersions = process.argv.includes('--only-browser-versions');
/** @type {!Array<!Message>} */
const messages = [];
@ -54,18 +55,22 @@ async function run() {
libversion: VERSION,
chromiumVersion: browserVersions.chromium,
firefoxVersion: browserVersions.firefox,
onlyBrowserVersions,
})));
messages.push(...preprocessor.autocorrectInvalidLinks(PROJECT_DIR, mdSources, getRepositoryFiles()));
for (const source of mdSources.filter(source => source.hasUpdatedText()))
messages.push(Message.warning(`WARN: updated ${source.projectPath()}`));
const browser = await playwright.chromium.launch();
const page = await browser.newPage();
const checkPublicAPI = require('./check_public_api');
const rpcDir = path.join(PROJECT_DIR, 'src', 'rpc');
const jsSources = await Source.readdir(path.join(PROJECT_DIR, 'src'), '', [rpcDir]);
messages.push(...await checkPublicAPI(page, [api], jsSources));
await browser.close();
if (!onlyBrowserVersions) {
messages.push(...preprocessor.autocorrectInvalidLinks(PROJECT_DIR, mdSources, getRepositoryFiles()));
for (const source of mdSources.filter(source => source.hasUpdatedText()))
messages.push(Message.warning(`WARN: updated ${source.projectPath()}`));
const browser = await playwright.chromium.launch();
const page = await browser.newPage();
const checkPublicAPI = require('./check_public_api');
const rpcDir = path.join(PROJECT_DIR, 'src', 'rpc');
const jsSources = await Source.readdir(path.join(PROJECT_DIR, 'src'), '', [rpcDir]);
messages.push(...await checkPublicAPI(page, [api], jsSources));
await browser.close();
}
for (const source of mdSources) {
if (!source.hasUpdatedText())
@ -103,7 +108,7 @@ async function run() {
console.log(`${errors.length} failures, ${warnings.length} warnings.`);
const runningTime = Date.now() - startTime;
console.log(`DocLint Finished in ${runningTime / 1000} seconds`);
process.exit(clearExit ? 0 : 1);
process.exit(clearExit || onlyBrowserVersions ? 0 : 1);
}
async function getBrowserVersions() {

View File

@ -17,7 +17,7 @@
const path = require('path');
const Message = require('../Message');
function runCommands(sources, {libversion, chromiumVersion, firefoxVersion}) {
function runCommands(sources, {libversion, chromiumVersion, firefoxVersion, onlyBrowserVersions}) {
// Release version is everything that doesn't include "-".
const isReleaseVersion = !libversion.includes('-');
@ -43,9 +43,7 @@ function runCommands(sources, {libversion, chromiumVersion, firefoxVersion}) {
commandStartRegex.lastIndex = commandEndRegex.lastIndex;
let newText = null;
if (commandName === 'version')
newText = isReleaseVersion ? 'v' + libversion : 'Tip-Of-Tree';
else if (commandName === 'chromium-version')
if (commandName === 'chromium-version')
newText = chromiumVersion;
else if (commandName === 'firefox-version')
newText = firefoxVersion;
@ -53,6 +51,10 @@ function runCommands(sources, {libversion, chromiumVersion, firefoxVersion}) {
newText = `[![Chromium version](https://img.shields.io/badge/chromium-${chromiumVersion}-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)`;
else if (commandName === 'firefox-version-badge')
newText = `[![Firefox version](https://img.shields.io/badge/firefox-${firefoxVersion}-blue.svg?logo=mozilla-firefox)](https://www.mozilla.org/en-US/firefox/new/)`;
else if (onlyBrowserVersions)
continue;
else if (commandName === 'version')
newText = isReleaseVersion ? 'v' + libversion : 'Tip-Of-Tree';
else if (commandName === 'toc')
newText = generateTableOfContents(source.text(), to, false /* topLevelOnly */);
else if (commandName === 'toc-top-level')

View File

@ -19,6 +19,7 @@
const path = require('path');
const fs = require('fs');
const protocolGenerator = require('./protocol-types-generator');
const {execSync} = require('child_process');
const SCRIPT_NAME = path.basename(__filename);
const ROOT_PATH = path.resolve(path.join(__dirname, '..'));
@ -57,20 +58,33 @@ Example:
process.exit(1);
}
const revision = args[1];
console.log(`Rolling ${browserName} to ${revision}`);
// 2. Update browsers.json.
console.log('\nUpdating browsers.json...');
const browsersJSON = require(path.join(ROOT_PATH, 'browsers.json'));
browsersJSON.browsers.find(b => b.name === browserName).revision = String(revision);
fs.writeFileSync(path.join(ROOT_PATH, 'browsers.json'), JSON.stringify(browsersJSON, null, 2) + '\n');
// 3. Download new browser.
console.log('\nDownloading new browser...');
const { installBrowsersWithProgressBar } = require('../lib/install/installer');
await installBrowsersWithProgressBar(ROOT_PATH);
// 4. Generate types.
console.log('\nGenerating protocol types...');
const browser = { name: browserName, revision };
const browserPaths = require('../lib/install/browserPaths');
const browserDir = browserPaths.browserDirectory(browserPaths.browsersPath(ROOT_PATH), browser);
const executablePath = browserPaths.executablePath(browserDir, browser);
await protocolGenerator.generateProtocol(browserName, executablePath).catch(console.warn);
// 5. Update docs.
console.log('\nUpdating documentation...');
try {
process.stdout.write(execSync('npm run --silent doc -- --only-browser-versions'));
} catch (e) {
}
console.log(`\nRolled ${browserName} to ${revision}`);
})();