Better structure monorepo and publish JS files for react-openapi and react-math (#2392)

This commit is contained in:
Samy Pessé
2024-07-22 15:02:04 +02:00
committed by GitHub
parent 8e8b73fbd9
commit de747b7b33
342 changed files with 337 additions and 142 deletions
@@ -0,0 +1,38 @@
import psi from 'psi';
import { getContentTestURL, getTargetURL } from './utils';
interface Test {
url: string;
strategy: 'mobile' | 'desktop';
threshold: number;
}
const tests: Array<Test> = [
{
url: 'https://docs.gitbook.com',
strategy: 'desktop',
threshold: 90,
},
{
url: 'https://docs.gitbook.com',
strategy: 'mobile',
threshold: 80,
},
];
console.log(`Starting PageSpeed testing with ${getTargetURL()}...`);
for (const test of tests) {
const url = getContentTestURL(test.url);
console.log(`Testing ${url} on ${test.strategy}...`);
await psi.output(url, {
strategy: test.strategy,
threshold: test.threshold,
key: process.env.PAGESPEED_API_KEY,
});
console.log('');
}
+30
View File
@@ -0,0 +1,30 @@
/**
* Get the target URL from the command line arguments.
*/
export function getTargetURL() {
const targetUrl = Bun.argv[2];
if (!targetUrl) {
console.error('No target URL provided');
process.exit(1);
}
return targetUrl;
}
export function getContentPathName(input: string): string {
const contentUrl = new URL(input);
return `${contentUrl.host}${contentUrl.pathname}`;
}
/**
* Get the URL to load for a content
*/
export function getContentTestURL(input: string, baseUrl: string = getTargetURL()): string {
const url = new URL(baseUrl);
const contentUrl = new URL(input);
url.pathname = `${contentUrl.host}${contentUrl.pathname}`;
url.search = contentUrl.search;
return url.toString();
}