chore: remove jobs (#11136)
This commit is contained in:
parent
3171115085
commit
8a2b9f1280
93
Herebyfile.mjs
Normal file
93
Herebyfile.mjs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import {copyFile, readFile, writeFile} from 'fs/promises';
|
||||||
|
|
||||||
|
import {execa} from 'execa';
|
||||||
|
import {task} from 'hereby';
|
||||||
|
import semver from 'semver';
|
||||||
|
|
||||||
|
import {docgen, spliceIntoSection} from '@puppeteer/docgen';
|
||||||
|
|
||||||
|
export const docsNgSchematicsTask = task({
|
||||||
|
name: 'docs:ng-schematics',
|
||||||
|
run: async () => {
|
||||||
|
const readme = await readFile('packages/ng-schematics/README.md', 'utf-8');
|
||||||
|
const index = await readFile('docs/integrations/ng-schematics.md', 'utf-8');
|
||||||
|
await writeFile(
|
||||||
|
'docs/integrations/ng-schematics.md',
|
||||||
|
index.replace('# API Reference\n', readme)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This logic should match the one in `website/docusaurus.config.js`.
|
||||||
|
*/
|
||||||
|
function getApiUrl(version) {
|
||||||
|
if (semver.gte(version, '19.3.0')) {
|
||||||
|
return `https://github.com/puppeteer/puppeteer/blob/puppeteer-${version}/docs/api/index.md`;
|
||||||
|
} else if (semver.gte(version, '15.3.0')) {
|
||||||
|
return `https://github.com/puppeteer/puppeteer/blob/${version}/docs/api/index.md`;
|
||||||
|
} else {
|
||||||
|
return `https://github.com/puppeteer/puppeteer/blob/${version}/docs/api.md`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const docsChromiumSupportTask = task({
|
||||||
|
name: 'docs:chromium-support',
|
||||||
|
run: async () => {
|
||||||
|
const content = await readFile('docs/chromium-support.md', {
|
||||||
|
encoding: 'utf8',
|
||||||
|
});
|
||||||
|
const {versionsPerRelease} = await import('./versions.js');
|
||||||
|
const buffer = [];
|
||||||
|
for (const [chromiumVersion, puppeteerVersion] of versionsPerRelease) {
|
||||||
|
if (puppeteerVersion === 'NEXT') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (semver.gte(puppeteerVersion, '20.0.0')) {
|
||||||
|
buffer.push(
|
||||||
|
` * [Chrome for Testing](https://goo.gle/chrome-for-testing) ${chromiumVersion} - [Puppeteer ${puppeteerVersion}](${getApiUrl(
|
||||||
|
puppeteerVersion
|
||||||
|
)})`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
buffer.push(
|
||||||
|
` * Chromium ${chromiumVersion} - [Puppeteer ${puppeteerVersion}](${getApiUrl(
|
||||||
|
puppeteerVersion
|
||||||
|
)})`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await writeFile(
|
||||||
|
'docs/chromium-support.md',
|
||||||
|
spliceIntoSection('version', content, buffer.join('\n'))
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const docsTask = task({
|
||||||
|
name: 'docs',
|
||||||
|
dependencies: [docsNgSchematicsTask, docsChromiumSupportTask],
|
||||||
|
run: async () => {
|
||||||
|
// Copy main page.
|
||||||
|
await copyFile('README.md', 'docs/index.md');
|
||||||
|
|
||||||
|
// Generate documentation
|
||||||
|
for (const [name, folder] of [
|
||||||
|
['browsers', 'browsers-api'],
|
||||||
|
['puppeteer', 'api'],
|
||||||
|
]) {
|
||||||
|
docgen(`docs/${name}.api.json`, `docs/${folder}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update main @puppeteer/browsers page.
|
||||||
|
const readme = await readFile('packages/browsers/README.md', 'utf-8');
|
||||||
|
const index = await readFile('docs/browsers-api/index.md', 'utf-8');
|
||||||
|
await writeFile(
|
||||||
|
'docs/browsers-api/index.md',
|
||||||
|
index.replace('# API Reference', readme)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Format everything.
|
||||||
|
await execa('prettier', ['--ignore-path', 'none', '--write', 'docs']);
|
||||||
|
},
|
||||||
|
});
|
@ -4,26 +4,26 @@ The following versions of Chromium are supported, mapped to Puppeteer version:
|
|||||||
|
|
||||||
<!-- version-start -->
|
<!-- version-start -->
|
||||||
|
|
||||||
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 117.0.5938.149 - [Puppeteer v21.3.7](https://pptr.dev/21.3.7)
|
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 117.0.5938.149 - [Puppeteer v21.3.7](https://github.com/puppeteer/puppeteer/blob/puppeteer-v21.3.7/docs/api/index.md)
|
||||||
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 117.0.5938.92 - [Puppeteer v21.3.2](https://pptr.dev/21.3.2)
|
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 117.0.5938.92 - [Puppeteer v21.3.2](https://github.com/puppeteer/puppeteer/blob/puppeteer-v21.3.2/docs/api/index.md)
|
||||||
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 117.0.5938.62 - [Puppeteer v21.3.0](https://pptr.dev/21.3.0)
|
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 117.0.5938.62 - [Puppeteer v21.3.0](https://github.com/puppeteer/puppeteer/blob/puppeteer-v21.3.0/docs/api/index.md)
|
||||||
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 116.0.5845.96 - [Puppeteer v21.1.0](https://pptr.dev/21.1.0)
|
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 116.0.5845.96 - [Puppeteer v21.1.0](https://github.com/puppeteer/puppeteer/blob/puppeteer-v21.1.0/docs/api/index.md)
|
||||||
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 115.0.5790.170 - [Puppeteer v21.0.2](https://pptr.dev/21.0.2)
|
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 115.0.5790.170 - [Puppeteer v21.0.2](https://github.com/puppeteer/puppeteer/blob/puppeteer-v21.0.2/docs/api/index.md)
|
||||||
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 115.0.5790.102 - [Puppeteer v21.0.0](https://pptr.dev/21.0.0)
|
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 115.0.5790.102 - [Puppeteer v21.0.0](https://github.com/puppeteer/puppeteer/blob/puppeteer-v21.0.0/docs/api/index.md)
|
||||||
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 115.0.5790.98 - [Puppeteer v20.9.0](https://pptr.dev/20.9.0)
|
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 115.0.5790.98 - [Puppeteer v20.9.0](https://github.com/puppeteer/puppeteer/blob/puppeteer-v20.9.0/docs/api/index.md)
|
||||||
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 114.0.5735.133 - [Puppeteer v20.7.2](https://pptr.dev/20.7.2)
|
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 114.0.5735.133 - [Puppeteer v20.7.2](https://github.com/puppeteer/puppeteer/blob/puppeteer-v20.7.2/docs/api/index.md)
|
||||||
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 114.0.5735.90 - [Puppeteer v20.6.0](https://pptr.dev/20.6.0)
|
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 114.0.5735.90 - [Puppeteer v20.6.0](https://github.com/puppeteer/puppeteer/blob/puppeteer-v20.6.0/docs/api/index.md)
|
||||||
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 113.0.5672.63 - [Puppeteer v20.1.0](https://pptr.dev/20.1.0)
|
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 113.0.5672.63 - [Puppeteer v20.1.0](https://github.com/puppeteer/puppeteer/blob/puppeteer-v20.1.0/docs/api/index.md)
|
||||||
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 112.0.5615.121 - [Puppeteer v20.0.0](https://pptr.dev/20.0.0)
|
- [Chrome for Testing](https://goo.gle/chrome-for-testing) 112.0.5615.121 - [Puppeteer v20.0.0](https://github.com/puppeteer/puppeteer/blob/puppeteer-v20.0.0/docs/api/index.md)
|
||||||
- Chromium 112.0.5614.0 - [Puppeteer v19.8.0](https://github.com/puppeteer/puppeteer/blob/v19.8.0/docs/api/index.md)
|
- Chromium 112.0.5614.0 - [Puppeteer v19.8.0](https://github.com/puppeteer/puppeteer/blob/puppeteer-v19.8.0/docs/api/index.md)
|
||||||
- Chromium 111.0.5556.0 - [Puppeteer v19.7.0](https://github.com/puppeteer/puppeteer/blob/v19.7.0/docs/api/index.md)
|
- Chromium 111.0.5556.0 - [Puppeteer v19.7.0](https://github.com/puppeteer/puppeteer/blob/puppeteer-v19.7.0/docs/api/index.md)
|
||||||
- Chromium 110.0.5479.0 - [Puppeteer v19.6.0](https://github.com/puppeteer/puppeteer/blob/v19.6.0/docs/api/index.md)
|
- Chromium 110.0.5479.0 - [Puppeteer v19.6.0](https://github.com/puppeteer/puppeteer/blob/puppeteer-v19.6.0/docs/api/index.md)
|
||||||
- Chromium 109.0.5412.0 - [Puppeteer v19.4.0](https://github.com/puppeteer/puppeteer/blob/v19.4.0/docs/api/index.md)
|
- Chromium 109.0.5412.0 - [Puppeteer v19.4.0](https://github.com/puppeteer/puppeteer/blob/puppeteer-v19.4.0/docs/api/index.md)
|
||||||
- Chromium 108.0.5351.0 - [Puppeteer v19.2.0](https://github.com/puppeteer/puppeteer/blob/v19.2.0/docs/api/index.md)
|
- Chromium 108.0.5351.0 - [Puppeteer v19.2.0](https://github.com/puppeteer/puppeteer/blob/v19.2.0/docs/api/index.md)
|
||||||
- Chromium 107.0.5296.0 - [Puppeteer v18.1.0](https://github.com/puppeteer/puppeteer/blob/v18.1.0/docs/api/index.md)
|
- Chromium 107.0.5296.0 - [Puppeteer v18.1.0](https://github.com/puppeteer/puppeteer/blob/v18.1.0/docs/api/index.md)
|
||||||
- Chromium 106.0.5249.0 - [Puppeteer v17.1.0](https://github.com/puppeteer/puppeteer/blob/v17.1.0/docs/api/index.md)
|
- Chromium 106.0.5249.0 - [Puppeteer v17.1.0](https://github.com/puppeteer/puppeteer/blob/v17.1.0/docs/api/index.md)
|
||||||
- Chromium 105.0.5173.0 - [Puppeteer v15.5.0](https://github.com/puppeteer/puppeteer/blob/v15.5.0/docs/api/index.md)
|
- Chromium 105.0.5173.0 - [Puppeteer v15.5.0](https://github.com/puppeteer/puppeteer/blob/v15.5.0/docs/api/index.md)
|
||||||
- Chromium 104.0.5109.0 - Puppeteer v15.1.0
|
- Chromium 104.0.5109.0 - [Puppeteer v15.1.0](https://github.com/puppeteer/puppeteer/blob/v15.1.0/docs/api.md)
|
||||||
- Chromium 103.0.5059.0 - [Puppeteer v14.2.0](https://github.com/puppeteer/puppeteer/blob/v14.2.0/docs/api.md)
|
- Chromium 103.0.5059.0 - [Puppeteer v14.2.0](https://github.com/puppeteer/puppeteer/blob/v14.2.0/docs/api.md)
|
||||||
- Chromium 102.0.5002.0 - [Puppeteer v14.0.0](https://github.com/puppeteer/puppeteer/blob/v14.0.0/docs/api.md)
|
- Chromium 102.0.5002.0 - [Puppeteer v14.0.0](https://github.com/puppeteer/puppeteer/blob/v14.0.0/docs/api.md)
|
||||||
- Chromium 101.0.4950.0 - [Puppeteer v13.6.0](https://github.com/puppeteer/puppeteer/blob/v13.6.0/docs/api.md)
|
- Chromium 101.0.4950.0 - [Puppeteer v13.6.0](https://github.com/puppeteer/puppeteer/blob/v13.6.0/docs/api.md)
|
||||||
|
990
package-lock.json
generated
990
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
15
package.json
15
package.json
@ -7,12 +7,11 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "wireit",
|
"build": "wireit",
|
||||||
"build:docs": "wireit",
|
|
||||||
"check:pinned-deps": "tsx tools/ensure-pinned-deps",
|
"check:pinned-deps": "tsx tools/ensure-pinned-deps",
|
||||||
"check": "npm run check --workspaces --if-present && run-p check:*",
|
"check": "npm run check --workspaces --if-present && run-p check:*",
|
||||||
"clean": "npm run clean --workspaces --if-present",
|
"clean": "npm run clean --workspaces --if-present",
|
||||||
"debug": "mocha --inspect-brk",
|
"debug": "mocha --inspect-brk",
|
||||||
"docs": "run-s build:docs generate:markdown",
|
"docs": "wireit",
|
||||||
"format:eslint": "eslint --ext js --ext ts --fix .",
|
"format:eslint": "eslint --ext js --ext ts --fix .",
|
||||||
"format:prettier": "prettier --write .",
|
"format:prettier": "prettier --write .",
|
||||||
"format:expectations": "node tools/sort-test-expectations.js",
|
"format:expectations": "node tools/sort-test-expectations.js",
|
||||||
@ -52,11 +51,13 @@
|
|||||||
"./test/installation:build"
|
"./test/installation:build"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"build:docs": {
|
"docs": {
|
||||||
|
"command": "hereby docs",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"./packages/browsers:build:docs",
|
"./packages/browsers:build:docs",
|
||||||
"./packages/puppeteer:build:docs",
|
"./packages/puppeteer:build:docs",
|
||||||
"./packages/puppeteer-core:build:docs"
|
"./packages/puppeteer-core:build:docs",
|
||||||
|
"./tools/docgen:build"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"doctest": {
|
"doctest": {
|
||||||
@ -115,10 +116,9 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@actions/core": "1.10.1",
|
"@actions/core": "1.10.1",
|
||||||
"@microsoft/api-documenter": "7.23.9",
|
|
||||||
"@microsoft/api-extractor": "7.38.0",
|
"@microsoft/api-extractor": "7.38.0",
|
||||||
"@microsoft/api-extractor-model": "7.28.2",
|
|
||||||
"@pptr/testserver": "file:packages/testserver",
|
"@pptr/testserver": "file:packages/testserver",
|
||||||
|
"@puppeteer/docgen": "file:tools/docgen",
|
||||||
"@prettier/sync": "0.3.0",
|
"@prettier/sync": "0.3.0",
|
||||||
"@types/debug": "4.1.9",
|
"@types/debug": "4.1.9",
|
||||||
"@types/diff": "5.0.5",
|
"@types/diff": "5.0.5",
|
||||||
@ -147,6 +147,8 @@
|
|||||||
"eslint-import-resolver-typescript": "3.6.1",
|
"eslint-import-resolver-typescript": "3.6.1",
|
||||||
"eslint-plugin-import": "2.28.1",
|
"eslint-plugin-import": "2.28.1",
|
||||||
"eslint-plugin-mocha": "10.2.0",
|
"eslint-plugin-mocha": "10.2.0",
|
||||||
|
"execa": "8.0.1",
|
||||||
|
"hereby": "1.8.7",
|
||||||
"eslint-plugin-prettier": "5.0.1",
|
"eslint-plugin-prettier": "5.0.1",
|
||||||
"eslint-plugin-rulesdir": "0.2.2",
|
"eslint-plugin-rulesdir": "0.2.2",
|
||||||
"eslint-plugin-tsdoc": "0.2.17",
|
"eslint-plugin-tsdoc": "0.2.17",
|
||||||
@ -188,6 +190,7 @@
|
|||||||
"test/installation",
|
"test/installation",
|
||||||
"tools/eslint",
|
"tools/eslint",
|
||||||
"tools/doctest",
|
"tools/doctest",
|
||||||
|
"tools/docgen",
|
||||||
"tools/mocha-runner"
|
"tools/mocha-runner"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import {mkdir, readFile, writeFile} from 'fs/promises';
|
import {mkdir, readFile, readdir, writeFile} from 'fs/promises';
|
||||||
|
import {join} from 'path/posix';
|
||||||
|
|
||||||
import esbuild from 'esbuild';
|
import esbuild from 'esbuild';
|
||||||
import {execa} from 'execa';
|
import {execa} from 'execa';
|
||||||
@ -38,7 +39,7 @@ export const generateInjectedTask = task({
|
|||||||
entryPoints: ['src/injected/injected.ts'],
|
entryPoints: ['src/injected/injected.ts'],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
format: 'cjs',
|
format: 'cjs',
|
||||||
target: 'chrome117',
|
target: ['chrome117', 'firefox118'],
|
||||||
minify: true,
|
minify: true,
|
||||||
write: false,
|
write: false,
|
||||||
});
|
});
|
||||||
@ -80,16 +81,23 @@ export const buildTask = task({
|
|||||||
name: 'build',
|
name: 'build',
|
||||||
dependencies: [buildTscTask],
|
dependencies: [buildTscTask],
|
||||||
run: async () => {
|
run: async () => {
|
||||||
const packages = ['mitt', 'rxjs'];
|
|
||||||
const formats = ['esm', 'cjs'];
|
const formats = ['esm', 'cjs'];
|
||||||
|
const packages = (await readdir('third_party', {withFileTypes: true}))
|
||||||
|
.filter(dirent => {
|
||||||
|
return dirent.isDirectory();
|
||||||
|
})
|
||||||
|
.map(({name}) => {
|
||||||
|
return name;
|
||||||
|
});
|
||||||
const builders = [];
|
const builders = [];
|
||||||
for (const name of packages) {
|
|
||||||
for (const format of formats) {
|
for (const format of formats) {
|
||||||
const filePath = `lib/${format}/third_party/${name}/${name}.js`;
|
const folder = join('lib', format, 'third_party');
|
||||||
|
for (const name of packages) {
|
||||||
|
const path = join(folder, name, `${name}.js`);
|
||||||
builders.push(
|
builders.push(
|
||||||
await esbuild.build({
|
await esbuild.build({
|
||||||
entryPoints: [filePath],
|
entryPoints: [path],
|
||||||
outfile: filePath,
|
outfile: path,
|
||||||
bundle: true,
|
bundle: true,
|
||||||
allowOverwrite: true,
|
allowOverwrite: true,
|
||||||
format,
|
format,
|
||||||
|
@ -126,8 +126,6 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "18.17.15",
|
"@types/node": "18.17.15",
|
||||||
"execa": "8.0.1",
|
|
||||||
"hereby": "1.8.7",
|
|
||||||
"mitt": "3.0.1",
|
"mitt": "3.0.1",
|
||||||
"parsel-js": "1.1.2",
|
"parsel-js": "1.1.2",
|
||||||
"rxjs": "7.8.1"
|
"rxjs": "7.8.1"
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
|
|
||||||
import {writeFile, mkdir, copyFile} from 'fs/promises';
|
import {writeFile, mkdir, copyFile} from 'fs/promises';
|
||||||
import {dirname, join} from 'path';
|
import {dirname, join} from 'path';
|
||||||
import semver from 'semver';
|
|
||||||
import {fileURLToPath} from 'url';
|
import {fileURLToPath} from 'url';
|
||||||
|
|
||||||
import core from '@actions/core';
|
import core from '@actions/core';
|
||||||
|
import semver from 'semver';
|
||||||
|
|
||||||
import packageJson from '../packages/puppeteer-core/package.json' assert {type: 'json'};
|
import packageJson from '../packages/puppeteer-core/package.json' assert {type: 'json'};
|
||||||
|
|
||||||
const codifyAndJoinValues = values => {
|
const codifyAndJoinValues = values => {
|
||||||
@ -79,7 +81,6 @@ This issue has an invalid Puppeteer version: \`${value}\`. Versions must follow
|
|||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
let input = '';
|
let input = '';
|
||||||
// @ts-expect-error: `iterator` is new and experimental.
|
|
||||||
for await (const chunk of process.stdin.iterator({
|
for await (const chunk of process.stdin.iterator({
|
||||||
destroyOnReturn: false,
|
destroyOnReturn: false,
|
||||||
})) {
|
})) {
|
||||||
|
@ -19,7 +19,6 @@ import fs from 'fs';
|
|||||||
/**
|
/**
|
||||||
* Calls chmod with the mode in argv[2] on paths in argv[3...length-1].
|
* Calls chmod with the mode in argv[2] on paths in argv[3...length-1].
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const mode = process.argv[2];
|
const mode = process.argv[2];
|
||||||
|
|
||||||
for (let i = 3; i < process.argv.length; i++) {
|
for (let i = 3; i < process.argv.length; i++) {
|
||||||
|
32
tools/docgen/package.json
Normal file
32
tools/docgen/package.json
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"name": "@puppeteer/docgen",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"type": "module",
|
||||||
|
"private": true,
|
||||||
|
"main": "./lib/docgen.js",
|
||||||
|
"description": "Documentation generator for Puppeteer",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"scripts": {
|
||||||
|
"build": "wireit",
|
||||||
|
"clean": "../clean.js"
|
||||||
|
},
|
||||||
|
"wireit": {
|
||||||
|
"build": {
|
||||||
|
"command": "tsc -b",
|
||||||
|
"clean": "if-file-deleted",
|
||||||
|
"files": [
|
||||||
|
"src/**"
|
||||||
|
],
|
||||||
|
"output": [
|
||||||
|
"lib/**",
|
||||||
|
"tsconfig.tsbuildinfo"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@microsoft/api-documenter": "7.23.9",
|
||||||
|
"@microsoft/api-extractor-model": "7.28.2",
|
||||||
|
"@microsoft/tsdoc": "0.14.2",
|
||||||
|
"@rushstack/node-core-library": "3.61.0"
|
||||||
|
}
|
||||||
|
}
|
@ -23,22 +23,22 @@
|
|||||||
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
import type {DocumenterConfig} from '@microsoft/api-documenter/lib/documenters/DocumenterConfig';
|
import type {DocumenterConfig} from '@microsoft/api-documenter/lib/documenters/DocumenterConfig.js';
|
||||||
import {CustomMarkdownEmitter} from '@microsoft/api-documenter/lib/markdown/CustomMarkdownEmitter';
|
import {CustomMarkdownEmitter} from '@microsoft/api-documenter/lib/markdown/CustomMarkdownEmitter.js';
|
||||||
import {CustomDocNodes} from '@microsoft/api-documenter/lib/nodes/CustomDocNodeKind';
|
import {CustomDocNodes} from '@microsoft/api-documenter/lib/nodes/CustomDocNodeKind.js';
|
||||||
import {DocEmphasisSpan} from '@microsoft/api-documenter/lib/nodes/DocEmphasisSpan';
|
import {DocEmphasisSpan} from '@microsoft/api-documenter/lib/nodes/DocEmphasisSpan.js';
|
||||||
import {DocHeading} from '@microsoft/api-documenter/lib/nodes/DocHeading';
|
import {DocHeading} from '@microsoft/api-documenter/lib/nodes/DocHeading.js';
|
||||||
import {DocNoteBox} from '@microsoft/api-documenter/lib/nodes/DocNoteBox';
|
import {DocNoteBox} from '@microsoft/api-documenter/lib/nodes/DocNoteBox.js';
|
||||||
import {DocTable} from '@microsoft/api-documenter/lib/nodes/DocTable';
|
import {DocTable} from '@microsoft/api-documenter/lib/nodes/DocTable.js';
|
||||||
import {DocTableCell} from '@microsoft/api-documenter/lib/nodes/DocTableCell';
|
import {DocTableCell} from '@microsoft/api-documenter/lib/nodes/DocTableCell.js';
|
||||||
import {DocTableRow} from '@microsoft/api-documenter/lib/nodes/DocTableRow';
|
import {DocTableRow} from '@microsoft/api-documenter/lib/nodes/DocTableRow.js';
|
||||||
import {MarkdownDocumenterAccessor} from '@microsoft/api-documenter/lib/plugin/MarkdownDocumenterAccessor';
|
import {MarkdownDocumenterAccessor} from '@microsoft/api-documenter/lib/plugin/MarkdownDocumenterAccessor.js';
|
||||||
import {
|
import {
|
||||||
type IMarkdownDocumenterFeatureOnBeforeWritePageArgs,
|
type IMarkdownDocumenterFeatureOnBeforeWritePageArgs,
|
||||||
MarkdownDocumenterFeatureContext,
|
MarkdownDocumenterFeatureContext,
|
||||||
} from '@microsoft/api-documenter/lib/plugin/MarkdownDocumenterFeature';
|
} from '@microsoft/api-documenter/lib/plugin/MarkdownDocumenterFeature.js';
|
||||||
import {PluginLoader} from '@microsoft/api-documenter/lib/plugin/PluginLoader';
|
import {PluginLoader} from '@microsoft/api-documenter/lib/plugin/PluginLoader.js';
|
||||||
import {Utilities} from '@microsoft/api-documenter/lib/utils/Utilities';
|
import {Utilities} from '@microsoft/api-documenter/lib/utils/Utilities.js';
|
||||||
import {
|
import {
|
||||||
ApiClass,
|
ApiClass,
|
||||||
ApiDeclaredItem,
|
ApiDeclaredItem,
|
@ -18,7 +18,7 @@ import {ApiModel} from '@microsoft/api-extractor-model';
|
|||||||
|
|
||||||
import {MarkdownDocumenter} from './custom_markdown_documenter.js';
|
import {MarkdownDocumenter} from './custom_markdown_documenter.js';
|
||||||
|
|
||||||
export const generateDocs = (jsonPath: string, outputDir: string): void => {
|
export function docgen(jsonPath: string, outputDir: string): void {
|
||||||
const apiModel = new ApiModel();
|
const apiModel = new ApiModel();
|
||||||
apiModel.loadPackage(jsonPath);
|
apiModel.loadPackage(jsonPath);
|
||||||
|
|
||||||
@ -28,4 +28,21 @@ export const generateDocs = (jsonPath: string, outputDir: string): void => {
|
|||||||
outputFolder: outputDir,
|
outputFolder: outputDir,
|
||||||
});
|
});
|
||||||
markdownDocumenter.generateFiles();
|
markdownDocumenter.generateFiles();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export function spliceIntoSection(
|
||||||
|
sectionName: string,
|
||||||
|
content: string,
|
||||||
|
sectionContent: string
|
||||||
|
): string {
|
||||||
|
const lines = content.split('\n');
|
||||||
|
const offset =
|
||||||
|
lines.findIndex(line => {
|
||||||
|
return line.includes(`<!-- ${sectionName}-start -->`);
|
||||||
|
}) + 1;
|
||||||
|
const limit = lines.slice(offset).findIndex(line => {
|
||||||
|
return line.includes(`<!-- ${sectionName}-end -->`);
|
||||||
|
});
|
||||||
|
lines.splice(offset, limit, ...sectionContent.split('\n'));
|
||||||
|
return lines.join('\n');
|
||||||
|
}
|
11
tools/docgen/tsconfig.json
Normal file
11
tools/docgen/tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"rootDir": "./src",
|
||||||
|
"outDir": "./lib",
|
||||||
|
"sourceMap": true,
|
||||||
|
"declaration": false,
|
||||||
|
"declarationMap": false,
|
||||||
|
"composite": false
|
||||||
|
}
|
||||||
|
}
|
@ -31,6 +31,7 @@ import {readFile} from 'node:fs/promises';
|
|||||||
import {createRequire} from 'node:module';
|
import {createRequire} from 'node:module';
|
||||||
|
|
||||||
import actions from '@actions/core';
|
import actions from '@actions/core';
|
||||||
|
|
||||||
import {computeExecutablePath, install} from '@puppeteer/browsers';
|
import {computeExecutablePath, install} from '@puppeteer/browsers';
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
|
@ -34,6 +34,9 @@ const allDeps = {...devDependencies};
|
|||||||
const invalidDeps = new Map<string, string>();
|
const invalidDeps = new Map<string, string>();
|
||||||
|
|
||||||
for (const [depKey, depValue] of Object.entries(allDeps)) {
|
for (const [depKey, depValue] of Object.entries(allDeps)) {
|
||||||
|
if (depValue.startsWith('file:')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (LOCAL_PACKAGE_NAMES.includes(depKey)) {
|
if (LOCAL_PACKAGE_NAMES.includes(depKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1,174 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2022 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import {copyFile, readFile, rm, writeFile} from 'fs/promises';
|
|
||||||
import {join, resolve} from 'path';
|
|
||||||
import {chdir} from 'process';
|
|
||||||
|
|
||||||
import semver from 'semver';
|
|
||||||
|
|
||||||
import {generateDocs} from './internal/custom_markdown_action.js';
|
|
||||||
import {job} from './internal/job.js';
|
|
||||||
import {spawnAndLog} from './internal/util.js';
|
|
||||||
|
|
||||||
chdir(resolve(join(__dirname, '..')));
|
|
||||||
|
|
||||||
function getOffsetAndLimit(
|
|
||||||
sectionName: string,
|
|
||||||
lines: string[]
|
|
||||||
): [offset: number, limit: number] {
|
|
||||||
const offset =
|
|
||||||
lines.findIndex(line => {
|
|
||||||
return line.includes(`<!-- ${sectionName}-start -->`);
|
|
||||||
}) + 1;
|
|
||||||
const limit = lines.slice(offset).findIndex(line => {
|
|
||||||
return line.includes(`<!-- ${sectionName}-end -->`);
|
|
||||||
});
|
|
||||||
return [offset, limit];
|
|
||||||
}
|
|
||||||
|
|
||||||
function spliceIntoSection(
|
|
||||||
sectionName: string,
|
|
||||||
content: string,
|
|
||||||
sectionContent: string
|
|
||||||
): string {
|
|
||||||
const lines = content.split('\n');
|
|
||||||
const [offset, limit] = getOffsetAndLimit(sectionName, lines);
|
|
||||||
lines.splice(offset, limit, ...sectionContent.split('\n'));
|
|
||||||
return lines.join('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
const copyMain = job('Copy main page', async ({inputs, outputs}) => {
|
|
||||||
await copyFile(inputs[0]!, outputs[0]!);
|
|
||||||
})
|
|
||||||
.inputs(['README.md'])
|
|
||||||
.outputs(['docs/index.md'])
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Chrome Versions
|
|
||||||
const updateSupportedList = job(
|
|
||||||
'Update the Chrome supported list',
|
|
||||||
async ({inputs, outputs}) => {
|
|
||||||
let content = await readFile(inputs[2]!, {encoding: 'utf8'});
|
|
||||||
const versionModulePath = join('..', inputs[0]!);
|
|
||||||
const {versionsPerRelease} = await import(versionModulePath);
|
|
||||||
const versionsArchived = JSON.parse(await readFile(inputs[1]!, 'utf8'));
|
|
||||||
|
|
||||||
// Generate versions
|
|
||||||
const buffer: string[] = [];
|
|
||||||
for (const [chromiumVersion, puppeteerVersion] of versionsPerRelease) {
|
|
||||||
if (puppeteerVersion === 'NEXT') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (versionsArchived.includes(puppeteerVersion.substring(1))) {
|
|
||||||
if (semver.gte(puppeteerVersion, '20.0.0')) {
|
|
||||||
buffer.push(
|
|
||||||
` * [Chrome for Testing](https://goo.gle/chrome-for-testing) ${chromiumVersion} - [Puppeteer ${puppeteerVersion}](https://pptr.dev/${puppeteerVersion.slice(
|
|
||||||
1
|
|
||||||
)})`
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
buffer.push(
|
|
||||||
` * Chromium ${chromiumVersion} - [Puppeteer ${puppeteerVersion}](https://github.com/puppeteer/puppeteer/blob/${puppeteerVersion}/docs/api/index.md)`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else if (semver.lt(puppeteerVersion, '15.0.0')) {
|
|
||||||
buffer.push(
|
|
||||||
` * Chromium ${chromiumVersion} - [Puppeteer ${puppeteerVersion}](https://github.com/puppeteer/puppeteer/blob/${puppeteerVersion}/docs/api.md)`
|
|
||||||
);
|
|
||||||
} else if (semver.gte(puppeteerVersion, '15.3.0')) {
|
|
||||||
buffer.push(
|
|
||||||
` * [Chrome for Testing](https://goo.gle/chrome-for-testing) ${chromiumVersion} - [Puppeteer ${puppeteerVersion}](https://pptr.dev/${puppeteerVersion.slice(
|
|
||||||
1
|
|
||||||
)})`
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
buffer.push(
|
|
||||||
` * Chromium ${chromiumVersion} - Puppeteer ${puppeteerVersion}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
content = spliceIntoSection('version', content, buffer.join('\n'));
|
|
||||||
|
|
||||||
await writeFile(outputs[0]!, content);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.inputs([
|
|
||||||
'versions.js',
|
|
||||||
'website/versionsArchived.json',
|
|
||||||
'docs/chromium-support.md',
|
|
||||||
])
|
|
||||||
.outputs(['docs/chromium-support.md'])
|
|
||||||
.build();
|
|
||||||
|
|
||||||
const copyNgSchematics = job(
|
|
||||||
'Copy @puppeteer/ng-schematics main page',
|
|
||||||
async ({inputs, outputs}) => {
|
|
||||||
await copyFile(inputs[0]!, outputs[0]!);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.inputs(['packages/ng-schematics/README.md'])
|
|
||||||
.outputs(['docs/integrations/ng-schematics.md'])
|
|
||||||
.build();
|
|
||||||
|
|
||||||
await Promise.all([copyMain, updateSupportedList, copyNgSchematics]);
|
|
||||||
|
|
||||||
// Generate documentation
|
|
||||||
const puppeteerDocs = job(
|
|
||||||
'Generate Puppeteer API markdown',
|
|
||||||
async ({inputs, outputs}) => {
|
|
||||||
await rm(outputs[0]!, {recursive: true, force: true});
|
|
||||||
generateDocs(inputs[0]!, outputs[0]!);
|
|
||||||
spawnAndLog('prettier', '--ignore-path', 'none', '--write', 'docs');
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.inputs([
|
|
||||||
'docs/puppeteer.api.json',
|
|
||||||
'tools/internal/custom_markdown_documenter.ts',
|
|
||||||
])
|
|
||||||
.outputs(['docs/api'])
|
|
||||||
.build();
|
|
||||||
|
|
||||||
const browsersDocs = job(
|
|
||||||
'Generate @puppeteer/browsers API markdown',
|
|
||||||
async ({inputs, outputs}) => {
|
|
||||||
await rm(outputs[0]!, {recursive: true, force: true});
|
|
||||||
generateDocs(inputs[0]!, outputs[0]!);
|
|
||||||
spawnAndLog('prettier', '--ignore-path', 'none', '--write', 'docs');
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.inputs([
|
|
||||||
'docs/browsers.api.json',
|
|
||||||
'tools/internal/custom_markdown_documenter.ts',
|
|
||||||
])
|
|
||||||
.outputs(['docs/browsers-api'])
|
|
||||||
.build();
|
|
||||||
|
|
||||||
await Promise.all([puppeteerDocs, browsersDocs]);
|
|
||||||
|
|
||||||
await job(
|
|
||||||
'Update main @puppeteer/browsers page',
|
|
||||||
async ({inputs, outputs}) => {
|
|
||||||
const readme = await readFile(inputs[1]!, 'utf-8');
|
|
||||||
const index = await readFile(inputs[0]!, 'utf-8');
|
|
||||||
await writeFile(outputs[0]!, index.replace('# API Reference\n', readme));
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.inputs(['docs/browsers-api/index.md', 'packages/browsers/README.md'])
|
|
||||||
.outputs(['docs/browsers-api/index.md'])
|
|
||||||
.build();
|
|
||||||
})();
|
|
@ -21,6 +21,5 @@ import {dirname} from 'path';
|
|||||||
* Outputs the dummy package.json file to the path specified
|
* Outputs the dummy package.json file to the path specified
|
||||||
* by the first argument.
|
* by the first argument.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mkdirSync(dirname(process.argv[2]), {recursive: true});
|
mkdirSync(dirname(process.argv[2]), {recursive: true});
|
||||||
writeFileSync(process.argv[2], `{"type": "module"}`);
|
writeFileSync(process.argv[2], `{"type": "module"}`);
|
||||||
|
@ -1,153 +0,0 @@
|
|||||||
import {createHash} from 'crypto';
|
|
||||||
import {existsSync, type Stats} from 'fs';
|
|
||||||
import {mkdir, readFile, stat, writeFile} from 'fs/promises';
|
|
||||||
import {tmpdir} from 'os';
|
|
||||||
import {dirname, join} from 'path';
|
|
||||||
|
|
||||||
import {hasMagic, globSync} from 'glob';
|
|
||||||
|
|
||||||
interface JobContext {
|
|
||||||
name: string;
|
|
||||||
inputs: string[];
|
|
||||||
outputs: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
class JobBuilder {
|
|
||||||
#inputs: string[] = [];
|
|
||||||
#outputs: string[] = [];
|
|
||||||
#callback: (ctx: JobContext) => Promise<void>;
|
|
||||||
#name: string;
|
|
||||||
#value = '';
|
|
||||||
#force = false;
|
|
||||||
|
|
||||||
constructor(name: string, callback: (ctx: JobContext) => Promise<void>) {
|
|
||||||
this.#name = name;
|
|
||||||
this.#callback = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
get jobHash(): string {
|
|
||||||
return createHash('sha256').update(this.#name).digest('hex');
|
|
||||||
}
|
|
||||||
|
|
||||||
force() {
|
|
||||||
this.#force = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
value(value: string) {
|
|
||||||
this.#value = value;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
inputs(inputs: string[]): JobBuilder {
|
|
||||||
this.#inputs = inputs.flatMap(value => {
|
|
||||||
if (hasMagic(value)) {
|
|
||||||
return globSync(value);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
});
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
outputs(outputs: string[]): JobBuilder {
|
|
||||||
if (!this.#name) {
|
|
||||||
this.#name = outputs.join(' and ');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.#outputs = outputs;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
async build(): Promise<void> {
|
|
||||||
console.log(`Running job ${this.#name}...`);
|
|
||||||
// For debugging.
|
|
||||||
if (this.#force) {
|
|
||||||
return await this.#run();
|
|
||||||
}
|
|
||||||
// In case we deleted an output file on purpose.
|
|
||||||
if (!this.getOutputStats()) {
|
|
||||||
return await this.#run();
|
|
||||||
}
|
|
||||||
// Run if the job has a value, but it changes.
|
|
||||||
if (this.#value) {
|
|
||||||
if (!(await this.isValueDifferent())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return await this.#run();
|
|
||||||
}
|
|
||||||
// Always run when there is no output.
|
|
||||||
if (!this.#outputs.length) {
|
|
||||||
return await this.#run();
|
|
||||||
}
|
|
||||||
// Make-like comparator.
|
|
||||||
if (!(await this.areInputsNewer())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return await this.#run();
|
|
||||||
}
|
|
||||||
|
|
||||||
async isValueDifferent(): Promise<boolean> {
|
|
||||||
const file = join(tmpdir(), `puppeteer/${this.jobHash}.txt`);
|
|
||||||
await mkdir(dirname(file), {recursive: true});
|
|
||||||
if (!existsSync(file)) {
|
|
||||||
await writeFile(file, this.#value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return this.#value !== (await readFile(file, 'utf8'));
|
|
||||||
}
|
|
||||||
|
|
||||||
#outputStats?: Stats[];
|
|
||||||
async getOutputStats(): Promise<Stats[] | undefined> {
|
|
||||||
if (this.#outputStats) {
|
|
||||||
return this.#outputStats;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
this.#outputStats = await Promise.all(
|
|
||||||
this.#outputs.map(output => {
|
|
||||||
return stat(output);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
} catch {}
|
|
||||||
return this.#outputStats;
|
|
||||||
}
|
|
||||||
|
|
||||||
async areInputsNewer(): Promise<boolean> {
|
|
||||||
const inputStats = await Promise.all(
|
|
||||||
this.#inputs.map(input => {
|
|
||||||
return stat(input);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
const outputStats = await this.getOutputStats();
|
|
||||||
if (
|
|
||||||
outputStats &&
|
|
||||||
outputStats.reduce(reduceMinTime, Infinity) >
|
|
||||||
inputStats.reduce(reduceMaxTime, 0)
|
|
||||||
) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#run(): Promise<void> {
|
|
||||||
return this.#callback({
|
|
||||||
name: this.#name,
|
|
||||||
inputs: this.#inputs,
|
|
||||||
outputs: this.#outputs,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const job = (
|
|
||||||
name: string,
|
|
||||||
callback: (ctx: JobContext) => Promise<void>
|
|
||||||
): JobBuilder => {
|
|
||||||
return new JobBuilder(name, callback);
|
|
||||||
};
|
|
||||||
|
|
||||||
const reduceMaxTime = (time: number, stat: Stats) => {
|
|
||||||
return time < stat.mtimeMs ? stat.mtimeMs : time;
|
|
||||||
};
|
|
||||||
|
|
||||||
const reduceMinTime = (time: number, stat: Stats) => {
|
|
||||||
return time > stat.mtimeMs ? stat.mtimeMs : time;
|
|
||||||
};
|
|
@ -1,14 +0,0 @@
|
|||||||
import {spawnSync} from 'child_process';
|
|
||||||
|
|
||||||
export const spawnAndLog = (...args: string[]): void => {
|
|
||||||
const {stdout, stderr} = spawnSync(args[0]!, args.slice(1), {
|
|
||||||
encoding: 'utf-8',
|
|
||||||
shell: true,
|
|
||||||
});
|
|
||||||
if (stdout) {
|
|
||||||
console.log(stdout);
|
|
||||||
}
|
|
||||||
if (stderr) {
|
|
||||||
console.error(stderr);
|
|
||||||
}
|
|
||||||
};
|
|
@ -19,12 +19,13 @@ import {writeFile, readFile} from 'fs/promises';
|
|||||||
import {promisify} from 'util';
|
import {promisify} from 'util';
|
||||||
|
|
||||||
import actions from '@actions/core';
|
import actions from '@actions/core';
|
||||||
import {PUPPETEER_REVISIONS} from 'puppeteer-core/internal/revisions.js';
|
|
||||||
import {SemVer} from 'semver';
|
import {SemVer} from 'semver';
|
||||||
|
|
||||||
import packageJson from '../packages/puppeteer-core/package.json' assert {type: 'json'};
|
import packageJson from '../packages/puppeteer-core/package.json' assert {type: 'json'};
|
||||||
import {versionsPerRelease, lastMaintainedChromeVersion} from '../versions.js';
|
import {versionsPerRelease, lastMaintainedChromeVersion} from '../versions.js';
|
||||||
|
|
||||||
|
import {PUPPETEER_REVISIONS} from 'puppeteer-core/internal/revisions.js';
|
||||||
|
|
||||||
const execAsync = promisify(exec);
|
const execAsync = promisify(exec);
|
||||||
|
|
||||||
const CHROME_CURRENT_VERSION = PUPPETEER_REVISIONS.chrome;
|
const CHROME_CURRENT_VERSION = PUPPETEER_REVISIONS.chrome;
|
||||||
|
@ -21,12 +21,26 @@ const assert = require('assert');
|
|||||||
|
|
||||||
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
|
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
|
||||||
const lightCodeTheme = require('prism-react-renderer/themes/github');
|
const lightCodeTheme = require('prism-react-renderer/themes/github');
|
||||||
|
const semver = require('semver');
|
||||||
|
|
||||||
const archivedVersions = require('./versionsArchived.json');
|
const archivedVersions = require('./versionsArchived.json');
|
||||||
|
|
||||||
const DOC_ROUTE_BASE_PATH = '/';
|
const DOC_ROUTE_BASE_PATH = '/';
|
||||||
const DOC_PATH = '../docs';
|
const DOC_PATH = '../docs';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This logic should match the one in `Herebyfile.mjs`.
|
||||||
|
*/
|
||||||
|
function getApiUrl(version) {
|
||||||
|
if (semver.gte(version, '19.3.0')) {
|
||||||
|
return `https://github.com/puppeteer/puppeteer/blob/puppeteer-${version}/docs/api/index.md`;
|
||||||
|
} else if (semver.gte(version, '15.3.0')) {
|
||||||
|
return `https://github.com/puppeteer/puppeteer/blob/${version}/docs/api/index.md`;
|
||||||
|
} else {
|
||||||
|
return `https://github.com/puppeteer/puppeteer/blob/${version}/docs/api.md`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** @type {import('@docusaurus/types').Config} */
|
/** @type {import('@docusaurus/types').Config} */
|
||||||
const config = {
|
const config = {
|
||||||
title: 'Puppeteer',
|
title: 'Puppeteer',
|
||||||
@ -283,18 +297,9 @@ const config = {
|
|||||||
value: '<b>Archived versions</b>',
|
value: '<b>Archived versions</b>',
|
||||||
},
|
},
|
||||||
...archivedVersions.map(version => {
|
...archivedVersions.map(version => {
|
||||||
const parts = version.split('.').map(item => {
|
|
||||||
return Number(item);
|
|
||||||
});
|
|
||||||
if (parts[0] <= 19 && parts[1] <= 2 && parts[2] <= 2) {
|
|
||||||
return {
|
return {
|
||||||
label: version,
|
label: version,
|
||||||
href: `https://github.com/puppeteer/puppeteer/blob/v${version}/docs/api/index.md`,
|
href: getApiUrl(`v${version}`),
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
label: version,
|
|
||||||
href: `https://github.com/puppeteer/puppeteer/blob/puppeteer-v${version}/docs/api/index.md`,
|
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
"@mdx-js/react": "1.6.22",
|
"@mdx-js/react": "1.6.22",
|
||||||
"clsx": "1.2.1",
|
"clsx": "1.2.1",
|
||||||
"prism-react-renderer": "1.3.5",
|
"prism-react-renderer": "1.3.5",
|
||||||
|
"semver": "7.5.4",
|
||||||
"react": "17.0.2",
|
"react": "17.0.2",
|
||||||
"react-dom": "17.0.2"
|
"react-dom": "17.0.2"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user