docs: fix browser version generation script (#4797)
This commit is contained in:
parent
ff2a1f1bd0
commit
a7f4c69a60
|
|
@ -213,6 +213,7 @@ async function run() {
|
||||||
libversion: VERSION,
|
libversion: VERSION,
|
||||||
chromiumVersion: browserVersions.chromium,
|
chromiumVersion: browserVersions.chromium,
|
||||||
firefoxVersion: browserVersions.firefox,
|
firefoxVersion: browserVersions.firefox,
|
||||||
|
webkitVersion: browserVersions.webkit,
|
||||||
})));
|
})));
|
||||||
|
|
||||||
messages.push(...preprocessor.autocorrectInvalidLinks(PROJECT_DIR, mdSources, getRepositoryFiles()));
|
messages.push(...preprocessor.autocorrectInvalidLinks(PROJECT_DIR, mdSources, getRepositoryFiles()));
|
||||||
|
|
@ -266,27 +267,14 @@ async function run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getBrowserVersions() {
|
async function getBrowserVersions() {
|
||||||
const [chromium, firefox] = await Promise.all([
|
const names = ['chromium', 'firefox', 'webkit'];
|
||||||
getChromeVersion(),
|
const browsers = await Promise.all(names.map(name => playwright[name].launch()));
|
||||||
getFirefoxVersion(),
|
const result = {};
|
||||||
])
|
for (let i = 0; i < names.length; i++) {
|
||||||
return {
|
result[names[i]] = browsers[i].version();
|
||||||
chromium,
|
|
||||||
firefox,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getChromeVersion() {
|
|
||||||
if (os.platform() === 'win32' || os.platform() === 'cygwin') {
|
|
||||||
const browser = await playwright.chromium.launch();
|
|
||||||
const page = await browser.newPage();
|
|
||||||
const userAgent = await page.evaluate('navigator.userAgent');
|
|
||||||
const [type] = userAgent.split(' ').filter(str => str.includes('Chrome'));
|
|
||||||
await browser.close();
|
|
||||||
return type.split('/')[1];
|
|
||||||
}
|
}
|
||||||
const version = spawnSync(playwright.chromium.executablePath(), ['--version'], undefined).stdout.toString();
|
await Promise.all(browsers.map(browser => browser.close()));
|
||||||
return version.trim().split(' ').pop();
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRepositoryFiles() {
|
function getRepositoryFiles() {
|
||||||
|
|
@ -294,10 +282,3 @@ function getRepositoryFiles() {
|
||||||
const files = out.stdout.toString().trim().split('\n').filter(f => !f.startsWith('docs-src'));
|
const files = out.stdout.toString().trim().split('\n').filter(f => !f.startsWith('docs-src'));
|
||||||
return files.map(file => path.join(PROJECT_DIR, file));
|
return files.map(file => path.join(PROJECT_DIR, file));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getFirefoxVersion() {
|
|
||||||
const isWin = os.platform() === 'win32' || os.platform() === 'cygwin';
|
|
||||||
const out = spawnSync(playwright.firefox.executablePath(), [isWin ? '/version' : '--version'], undefined);
|
|
||||||
const version = out.stdout.toString();
|
|
||||||
return version.trim().split(' ').pop();
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const Message = require('../Message');
|
const Message = require('../Message');
|
||||||
|
|
||||||
function runCommands(sources, {libversion, chromiumVersion, firefoxVersion}) {
|
function runCommands(sources, {libversion, chromiumVersion, firefoxVersion, webkitVersion}) {
|
||||||
// Release version is everything that doesn't include "-".
|
// Release version is everything that doesn't include "-".
|
||||||
const isReleaseVersion = !libversion.includes('-');
|
const isReleaseVersion = !libversion.includes('-');
|
||||||
|
|
||||||
|
|
@ -47,6 +47,8 @@ function runCommands(sources, {libversion, chromiumVersion, firefoxVersion}) {
|
||||||
newText = chromiumVersion;
|
newText = chromiumVersion;
|
||||||
else if (commandName === 'firefox-version')
|
else if (commandName === 'firefox-version')
|
||||||
newText = firefoxVersion;
|
newText = firefoxVersion;
|
||||||
|
else if (commandName === 'webkit-version')
|
||||||
|
newText = webkitVersion;
|
||||||
else if (commandName === 'chromium-version-badge')
|
else if (commandName === 'chromium-version-badge')
|
||||||
newText = `[](https://www.chromium.org/Home)`;
|
newText = `[](https://www.chromium.org/Home)`;
|
||||||
else if (commandName === 'firefox-version-badge')
|
else if (commandName === 'firefox-version-badge')
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,16 @@
|
||||||
const pw = require('..');
|
const pw = require('..');
|
||||||
const child_process = require('child_process');
|
const child_process = require('child_process');
|
||||||
|
|
||||||
for (const browserType of [pw.chromium, pw.firefox]) {
|
|
||||||
const executablePath = browserType.executablePath();
|
async function browserVersion(browserType) {
|
||||||
const version = child_process.execSync(executablePath + ' --version').toString().trim();
|
const browser = await browserType.launch();
|
||||||
console.log('- ' + version);
|
const result = browser.version();
|
||||||
|
await browser.close();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
console.log('- WebKit 14.1');
|
|
||||||
|
(async () => {
|
||||||
|
console.log('- Chromium ' + await browserVersion(pw.chromium));
|
||||||
|
console.log('- Mozilla Firefox ' + await browserVersion(pw.firefox));
|
||||||
|
console.log('- WebKit ' + await browserVersion(pw.webkit));
|
||||||
|
})();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue