@mui/internal-code-infra 0.0.4-canary.63 → 0.0.4-canary.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/brokenLinksChecker/index.mjs +46 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-code-infra",
|
|
3
|
-
"version": "0.0.4-canary.
|
|
3
|
+
"version": "0.0.4-canary.64",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "Infra scripts and configs to be used across MUI repos.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
"publishConfig": {
|
|
193
193
|
"access": "public"
|
|
194
194
|
},
|
|
195
|
-
"gitSha": "
|
|
195
|
+
"gitSha": "42ab800dc8926bfe1c6ea3020a013565143f1bd6",
|
|
196
196
|
"scripts": {
|
|
197
197
|
"build": "tsgo -p tsconfig.build.json",
|
|
198
198
|
"typescript": "tsgo -noEmit",
|
|
@@ -9,6 +9,7 @@ import { Transform } from 'node:stream';
|
|
|
9
9
|
import { Worker } from 'node:worker_threads';
|
|
10
10
|
|
|
11
11
|
const DEFAULT_CONCURRENCY = 4;
|
|
12
|
+
const SERVER_START_TIMEOUT = 10000;
|
|
12
13
|
|
|
13
14
|
const crawlWorkerUrl = new URL('./crawlWorker.mjs', import.meta.url);
|
|
14
15
|
|
|
@@ -620,30 +621,56 @@ export async function crawl(rawOptions) {
|
|
|
620
621
|
|
|
621
622
|
/** @type {AbortController | null} */
|
|
622
623
|
let controller = null;
|
|
623
|
-
if (options.startCommand) {
|
|
624
|
-
console.log(chalk.blue(`Starting server with "${options.startCommand}"...`));
|
|
625
|
-
controller = new AbortController();
|
|
626
|
-
const appProcess = execaCommand(options.startCommand, {
|
|
627
|
-
stdout: 'pipe',
|
|
628
|
-
stderr: 'pipe',
|
|
629
|
-
cancelSignal: controller.signal,
|
|
630
|
-
env: {
|
|
631
|
-
FORCE_COLOR: '1',
|
|
632
|
-
...process.env,
|
|
633
|
-
},
|
|
634
|
-
});
|
|
635
624
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
625
|
+
try {
|
|
626
|
+
if (options.startCommand) {
|
|
627
|
+
console.log(chalk.blue(`Starting server with "${options.startCommand}"...`));
|
|
628
|
+
controller = new AbortController();
|
|
629
|
+
const appProcess = execaCommand(options.startCommand, {
|
|
630
|
+
stdout: 'pipe',
|
|
631
|
+
stderr: 'pipe',
|
|
632
|
+
cancelSignal: controller.signal,
|
|
633
|
+
env: {
|
|
634
|
+
FORCE_COLOR: '1',
|
|
635
|
+
...process.env,
|
|
636
|
+
},
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
// Prefix server logs
|
|
640
|
+
const serverPrefix = chalk.gray('server: ');
|
|
641
|
+
appProcess.stdout.pipe(prefixLines(serverPrefix)).pipe(process.stdout);
|
|
642
|
+
appProcess.stderr.pipe(prefixLines(serverPrefix)).pipe(process.stderr);
|
|
643
|
+
appProcess.catch(() => {});
|
|
641
644
|
|
|
642
|
-
|
|
645
|
+
// Poll the first page we are about to crawl (resolved against host) so we
|
|
646
|
+
// wait for the actual entry point to be serveable rather than the
|
|
647
|
+
// homepage, which may be a different (slower) page.
|
|
648
|
+
const healthcheckUrl = new URL(options.seedUrls[0] ?? '/', options.host).href;
|
|
649
|
+
await pollUrl(healthcheckUrl, SERVER_START_TIMEOUT);
|
|
643
650
|
|
|
644
|
-
|
|
651
|
+
console.log(`Server started on ${chalk.underline(options.host)}`);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
return await runCrawl(options, startTime);
|
|
655
|
+
} finally {
|
|
656
|
+
// Always stop the server, even when startup or crawling throws. Without
|
|
657
|
+
// this, a failed healthcheck (or any error) would leave the dev server
|
|
658
|
+
// running, which on slow environments (e.g. Netlify) leads to orphaned
|
|
659
|
+
// servers piling up across retries.
|
|
660
|
+
if (controller) {
|
|
661
|
+
console.log(chalk.blue('Stopping server...'));
|
|
662
|
+
controller.abort();
|
|
663
|
+
}
|
|
645
664
|
}
|
|
665
|
+
}
|
|
646
666
|
|
|
667
|
+
/**
|
|
668
|
+
* Runs the crawl against an already-running server.
|
|
669
|
+
* @param {ResolvedCrawlOptions} options - Fully resolved crawl options
|
|
670
|
+
* @param {number} startTime - Timestamp (ms) when the crawl began, for duration reporting
|
|
671
|
+
* @returns {Promise<CrawlResult>} Crawl results including all links, pages, and issues found
|
|
672
|
+
*/
|
|
673
|
+
async function runCrawl(options, startTime) {
|
|
647
674
|
const knownTargets = await resolveKnownTargets(options);
|
|
648
675
|
|
|
649
676
|
/** @type {Map<string, Promise<PageData>>} */
|
|
@@ -733,11 +760,6 @@ export async function crawl(rawOptions) {
|
|
|
733
760
|
|
|
734
761
|
await queue.waitAll();
|
|
735
762
|
|
|
736
|
-
if (controller) {
|
|
737
|
-
console.log(chalk.blue('Stopping server...'));
|
|
738
|
-
controller.abort();
|
|
739
|
-
}
|
|
740
|
-
|
|
741
763
|
const results = new Map(
|
|
742
764
|
await Promise.all(
|
|
743
765
|
Array.from(crawledPages.entries(), async ([a, b]) => /** @type {const} */ ([a, await b])),
|