chore(artifacts): reconcile captured main and preserve iNES history
This commit is contained in:
@@ -8,14 +8,17 @@ import { spawnOwnedProviderProcess } from "../../dist/process/ProviderProcess.js
|
||||
import { createSystemProcessOwnershipHost } from "../../dist/process/ProcessOwnershipObservation.js";
|
||||
import { liveProcesses } from "../../dist/process/ProcessOwnershipProcessTree.js";
|
||||
import { CdpConnection } from "../../dist/browser/CdpConnection.js";
|
||||
import { waitForBrowserDevtoolsPort } from "../../dist/browser/BrowserProcessStartup.js";
|
||||
import {
|
||||
BROWSER_DEVTOOLS_STARTUP_TIMEOUT_MS,
|
||||
waitForBrowserDevtoolsPort,
|
||||
} from "../../dist/browser/BrowserProcessStartup.js";
|
||||
import { discoverCdpEndpoint } from "../../dist/browser/CdpEndpoint.js";
|
||||
import { BrowserObservationError } from "../../dist/domain/browserObservationError.js";
|
||||
|
||||
/** Admit the owned fixture only after CDP serves its requested page. */
|
||||
export async function startRuntimeFixtureBrowser(executable, origin) {
|
||||
const profile = await mkdtemp(join(tmpdir(), "rea-real-web-runtime-"));
|
||||
const deadline = performance.now() + 60_000;
|
||||
const deadline = performance.now() + BROWSER_DEVTOOLS_STARTUP_TIMEOUT_MS;
|
||||
let owned;
|
||||
try {
|
||||
owned = await spawnOwnedProviderProcess({
|
||||
|
||||
+58
-11
@@ -1,13 +1,41 @@
|
||||
import { readFile, readdir, stat } from "node:fs/promises";
|
||||
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
||||
|
||||
const readmeLinkTargets = (content, language = "en") =>
|
||||
[...content.matchAll(/\]\(([^)\s]+)\)/gu)]
|
||||
.map((match) => match[1] ?? "")
|
||||
const repoRelative = (root, from, target) => {
|
||||
const index = target.search(/[#?]/u);
|
||||
const pathPart = index === -1 ? target : target.slice(0, index);
|
||||
const suffix = index === -1 ? "" : target.slice(index);
|
||||
if (pathPart.length === 0 || /^[a-z][a-z0-9+.-]*:/iu.test(pathPart))
|
||||
return target;
|
||||
const absolute = resolve(root, dirname(from), pathPart);
|
||||
const withinRepo = relative(root, absolute);
|
||||
if (
|
||||
withinRepo === ".." ||
|
||||
withinRepo.startsWith(`..${sep}`) ||
|
||||
isAbsolute(withinRepo)
|
||||
)
|
||||
return target;
|
||||
return `${withinRepo.split(sep).join("/")}${suffix}`;
|
||||
};
|
||||
|
||||
const isLanguageNavigation = (target) => {
|
||||
const path = target.split(/[#?]/u)[0];
|
||||
return (
|
||||
path === "README.md" ||
|
||||
/^docs\/readme\/README_[A-Za-z0-9-]+\.md$/u.test(path)
|
||||
);
|
||||
};
|
||||
|
||||
const readmeDestinations = (content) => [
|
||||
...content.matchAll(/\]\(([^)\s]+)\)/gu),
|
||||
...content.matchAll(/\b(?:src|href)="([^"]+)"/gu),
|
||||
];
|
||||
|
||||
const readmeLinkTargets = (root, from, content, language = "en") =>
|
||||
readmeDestinations(content)
|
||||
.map((match) => repoRelative(root, from, match[1] ?? ""))
|
||||
.filter(
|
||||
(target) =>
|
||||
!target.startsWith("#") &&
|
||||
!/^README(?:_[A-Za-z0-9-]+)?\.md$/u.test(target),
|
||||
(target) => !target.startsWith("#") && !isLanguageNavigation(target),
|
||||
)
|
||||
.map((target) => {
|
||||
if (language === "en" || !URL.canParse(target)) return target;
|
||||
@@ -70,9 +98,19 @@ export const documentationFactIssues = async (root, catalog) => {
|
||||
const issues = await skillReferenceIssues(
|
||||
join(root, "skills/reverse-engineer-anything"),
|
||||
);
|
||||
const readmePaths = (await readdir(root))
|
||||
.filter((path) => /^README(?:_[A-Za-z0-9-]+)?\.md$/u.test(path))
|
||||
.sort();
|
||||
const translatedFolder = join(root, "docs/readme");
|
||||
let translatedNames = [];
|
||||
try {
|
||||
translatedNames = await readdir(translatedFolder);
|
||||
} catch (cause) {
|
||||
if (cause?.code !== "ENOENT") throw cause;
|
||||
}
|
||||
const readmePaths = [
|
||||
"README.md",
|
||||
...translatedNames
|
||||
.filter((name) => /^README_[A-Za-z0-9-]+\.md$/u.test(name))
|
||||
.map((name) => `docs/readme/${name}`),
|
||||
].sort();
|
||||
const readmes = new Map();
|
||||
for (const path of readmePaths) {
|
||||
const content = await readFile(join(root, path), "utf8");
|
||||
@@ -94,7 +132,11 @@ export const documentationFactIssues = async (root, catalog) => {
|
||||
);
|
||||
}
|
||||
}
|
||||
const canonicalLinks = readmeLinkTargets(readmes.get("README.md") ?? "");
|
||||
const canonicalLinks = readmeLinkTargets(
|
||||
root,
|
||||
"README.md",
|
||||
readmes.get("README.md") ?? "",
|
||||
);
|
||||
const languageInventory = JSON.parse(
|
||||
await readFile(join(root, "website/locales/languages.json"), "utf8"),
|
||||
);
|
||||
@@ -104,7 +146,12 @@ export const documentationFactIssues = async (root, catalog) => {
|
||||
for (const path of readmePaths.filter((path) => path !== "README.md"))
|
||||
if (
|
||||
JSON.stringify(
|
||||
readmeLinkTargets(readmes.get(path) ?? "", readmeLanguages.get(path)),
|
||||
readmeLinkTargets(
|
||||
root,
|
||||
path,
|
||||
readmes.get(path) ?? "",
|
||||
readmeLanguages.get(path),
|
||||
),
|
||||
) !== JSON.stringify(canonicalLinks)
|
||||
)
|
||||
issues.push(`${path}: documentation links differ from README.md`);
|
||||
|
||||
Reference in New Issue
Block a user