@decocms/parity 0.26.18 → 0.26.19
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/dist/cli.js +330 -214
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -42155,7 +42155,7 @@ function baselineUnset(name) {
|
|
|
42155
42155
|
}
|
|
42156
42156
|
|
|
42157
42157
|
// src/commands/benchmark.ts
|
|
42158
|
-
import { writeFileSync as
|
|
42158
|
+
import { writeFileSync as writeFileSync8 } from "node:fs";
|
|
42159
42159
|
import { join as join10 } from "node:path";
|
|
42160
42160
|
import chalk3 from "chalk";
|
|
42161
42161
|
import ora2 from "ora";
|
|
@@ -42531,6 +42531,110 @@ function isLocalhost(rawUrl) {
|
|
|
42531
42531
|
}
|
|
42532
42532
|
}
|
|
42533
42533
|
|
|
42534
|
+
// src/engine/interactive-selector-prompt.ts
|
|
42535
|
+
init_client();
|
|
42536
|
+
import { execSync } from "node:child_process";
|
|
42537
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync5 } from "node:fs";
|
|
42538
|
+
import { resolve } from "node:path";
|
|
42539
|
+
import { createInterface } from "node:readline";
|
|
42540
|
+
var forceDisabled = false;
|
|
42541
|
+
function disableInteractive() {
|
|
42542
|
+
forceDisabled = true;
|
|
42543
|
+
}
|
|
42544
|
+
function isInteractiveMode() {
|
|
42545
|
+
if (forceDisabled)
|
|
42546
|
+
return false;
|
|
42547
|
+
if (!process.stdout.isTTY || !process.stdin.isTTY)
|
|
42548
|
+
return false;
|
|
42549
|
+
if (isLlmAvailable())
|
|
42550
|
+
return false;
|
|
42551
|
+
return true;
|
|
42552
|
+
}
|
|
42553
|
+
var PARITYRC_FILENAME = ".parityrc.json";
|
|
42554
|
+
async function promptForSelector(input) {
|
|
42555
|
+
const cwd = input.cwd ?? process.cwd();
|
|
42556
|
+
printContextHeader(input);
|
|
42557
|
+
const selector = await readLine("Selector for this step (or blank to skip): ");
|
|
42558
|
+
if (!selector?.trim()) {
|
|
42559
|
+
console.log(" (no selector entered — continuing without override)");
|
|
42560
|
+
return null;
|
|
42561
|
+
}
|
|
42562
|
+
const trimmed = selector.trim();
|
|
42563
|
+
const rcPath = resolve(cwd, PARITYRC_FILENAME);
|
|
42564
|
+
writeSelectorOverride(rcPath, input.selectorKey, trimmed);
|
|
42565
|
+
console.log(` ✓ wrote selectors.${input.selectorKey} = ${trimmed} → ${rcPath}`);
|
|
42566
|
+
tryOpenInEditor(rcPath);
|
|
42567
|
+
return trimmed;
|
|
42568
|
+
}
|
|
42569
|
+
function buildStructuredError(input) {
|
|
42570
|
+
return {
|
|
42571
|
+
kind: "missing-selector",
|
|
42572
|
+
selectorKey: input.selectorKey,
|
|
42573
|
+
intendedAction: input.intendedAction,
|
|
42574
|
+
alreadyTried: input.alreadyTried,
|
|
42575
|
+
pageUrl: input.pageUrl,
|
|
42576
|
+
htmlSnapshot: input.htmlSnapshot.slice(0, 2000),
|
|
42577
|
+
suggestedRcPath: resolve(input.cwd ?? process.cwd(), PARITYRC_FILENAME)
|
|
42578
|
+
};
|
|
42579
|
+
}
|
|
42580
|
+
function printContextHeader(input) {
|
|
42581
|
+
const bar = "─".repeat(60);
|
|
42582
|
+
console.log("");
|
|
42583
|
+
console.log(bar);
|
|
42584
|
+
console.log(`⚠ Selector missing: ${input.selectorKey}`);
|
|
42585
|
+
console.log(bar);
|
|
42586
|
+
console.log(` step: ${input.intendedAction}`);
|
|
42587
|
+
console.log(` page: ${input.pageUrl}`);
|
|
42588
|
+
if (input.alreadyTried.length > 0) {
|
|
42589
|
+
console.log(` tried: ${input.alreadyTried.slice(0, 5).join(", ")}`);
|
|
42590
|
+
}
|
|
42591
|
+
console.log("");
|
|
42592
|
+
console.log(" HTML snapshot (top of page):");
|
|
42593
|
+
const lines = input.htmlSnapshot.split(`
|
|
42594
|
+
`).slice(0, 25);
|
|
42595
|
+
for (const ln of lines)
|
|
42596
|
+
console.log(` | ${ln}`);
|
|
42597
|
+
if (input.htmlSnapshot.split(`
|
|
42598
|
+
`).length > 25)
|
|
42599
|
+
console.log(" | … (truncated)");
|
|
42600
|
+
console.log("");
|
|
42601
|
+
}
|
|
42602
|
+
function readLine(prompt) {
|
|
42603
|
+
return new Promise((resolveLine) => {
|
|
42604
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
42605
|
+
rl.question(prompt, (answer) => {
|
|
42606
|
+
rl.close();
|
|
42607
|
+
resolveLine(answer);
|
|
42608
|
+
});
|
|
42609
|
+
rl.on("SIGINT", () => {
|
|
42610
|
+
rl.close();
|
|
42611
|
+
resolveLine(null);
|
|
42612
|
+
});
|
|
42613
|
+
});
|
|
42614
|
+
}
|
|
42615
|
+
function writeSelectorOverride(rcPath, key, value) {
|
|
42616
|
+
let current = {};
|
|
42617
|
+
if (existsSync4(rcPath)) {
|
|
42618
|
+
try {
|
|
42619
|
+
const parsed = JSON.parse(readFileSync3(rcPath, "utf8"));
|
|
42620
|
+
if (parsed && typeof parsed === "object")
|
|
42621
|
+
current = parsed;
|
|
42622
|
+
} catch {
|
|
42623
|
+
console.log(` ⚠ existing ${PARITYRC_FILENAME} was not valid JSON; overwriting.`);
|
|
42624
|
+
}
|
|
42625
|
+
}
|
|
42626
|
+
current.selectors = { ...current.selectors ?? {}, [key]: value };
|
|
42627
|
+
writeFileSync5(rcPath, `${JSON.stringify(current, null, 2)}
|
|
42628
|
+
`, "utf8");
|
|
42629
|
+
}
|
|
42630
|
+
function tryOpenInEditor(rcPath) {
|
|
42631
|
+
if (process.platform !== "darwin")
|
|
42632
|
+
return;
|
|
42633
|
+
try {
|
|
42634
|
+
execSync(`open ${JSON.stringify(rcPath)}`, { stdio: "ignore" });
|
|
42635
|
+
} catch {}
|
|
42636
|
+
}
|
|
42637
|
+
|
|
42534
42638
|
// src/llm/pick-plp.ts
|
|
42535
42639
|
init_client();
|
|
42536
42640
|
var PATH_BLOCKLIST = [
|
|
@@ -42606,7 +42710,7 @@ ${candidates.map((c, i) => `${i}. "${c.text}" → ${c.href}`).join(`
|
|
|
42606
42710
|
}
|
|
42607
42711
|
|
|
42608
42712
|
// src/learned/repo.ts
|
|
42609
|
-
import { existsSync as
|
|
42713
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync4, renameSync, writeFileSync as writeFileSync6 } from "node:fs";
|
|
42610
42714
|
import { dirname as dirname2 } from "node:path";
|
|
42611
42715
|
import { z as z2 } from "zod";
|
|
42612
42716
|
var SelectorKey = z2.enum([
|
|
@@ -42679,10 +42783,10 @@ function emptyLib() {
|
|
|
42679
42783
|
return { schemaVersion: "0.1", platforms: {} };
|
|
42680
42784
|
}
|
|
42681
42785
|
function loadLearned(path = DEFAULT_PATH) {
|
|
42682
|
-
if (!
|
|
42786
|
+
if (!existsSync5(path))
|
|
42683
42787
|
return emptyLib();
|
|
42684
42788
|
try {
|
|
42685
|
-
const raw = JSON.parse(
|
|
42789
|
+
const raw = JSON.parse(readFileSync4(path, "utf8"));
|
|
42686
42790
|
return LearnedSelectors.parse(raw);
|
|
42687
42791
|
} catch (err) {
|
|
42688
42792
|
console.warn(`[learned] failed to parse ${path}: ${err.message}, starting fresh`);
|
|
@@ -42691,10 +42795,10 @@ function loadLearned(path = DEFAULT_PATH) {
|
|
|
42691
42795
|
}
|
|
42692
42796
|
function saveLearned(lib, path = DEFAULT_PATH) {
|
|
42693
42797
|
const dir = dirname2(path);
|
|
42694
|
-
if (dir && dir !== "." && !
|
|
42798
|
+
if (dir && dir !== "." && !existsSync5(dir))
|
|
42695
42799
|
mkdirSync4(dir, { recursive: true });
|
|
42696
42800
|
const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;
|
|
42697
|
-
|
|
42801
|
+
writeFileSync6(tmp, `${JSON.stringify(lib, null, 2)}
|
|
42698
42802
|
`, "utf8");
|
|
42699
42803
|
renameSync(tmp, path);
|
|
42700
42804
|
}
|
|
@@ -43223,7 +43327,7 @@ async function screenshotStable(page, opts) {
|
|
|
43223
43327
|
stabilizeCarousels(page).catch(() => {
|
|
43224
43328
|
return;
|
|
43225
43329
|
}),
|
|
43226
|
-
new Promise((
|
|
43330
|
+
new Promise((resolve2) => setTimeout(resolve2, 3000))
|
|
43227
43331
|
]);
|
|
43228
43332
|
const isJpeg = /\.jpe?g$/i.test(opts.path);
|
|
43229
43333
|
await page.screenshot({
|
|
@@ -43246,7 +43350,7 @@ function dlog2(ctx, msg) {
|
|
|
43246
43350
|
function withCap(p, capMs, fallback) {
|
|
43247
43351
|
return Promise.race([
|
|
43248
43352
|
p.catch(() => fallback),
|
|
43249
|
-
new Promise((
|
|
43353
|
+
new Promise((resolve2) => setTimeout(() => resolve2(fallback), capMs))
|
|
43250
43354
|
]);
|
|
43251
43355
|
}
|
|
43252
43356
|
var VARIANT_REQUIRED_TEXT_PATTERNS = [
|
|
@@ -43467,6 +43571,34 @@ async function findElement(page, ctx, opts) {
|
|
|
43467
43571
|
return { ...recovered, recoveredByLlm: true };
|
|
43468
43572
|
}
|
|
43469
43573
|
}
|
|
43574
|
+
if (opts.key) {
|
|
43575
|
+
const supplied = await resolveMissingSelector(page, opts.key, opts.intent, tried);
|
|
43576
|
+
if (supplied) {
|
|
43577
|
+
const el = page.locator(supplied).first();
|
|
43578
|
+
if (await el.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
43579
|
+
return { locator: el, selector: supplied, recoveredByLlm: false };
|
|
43580
|
+
}
|
|
43581
|
+
}
|
|
43582
|
+
}
|
|
43583
|
+
return null;
|
|
43584
|
+
}
|
|
43585
|
+
var reportedMissing = new Set;
|
|
43586
|
+
async function resolveMissingSelector(page, key, intent, tried) {
|
|
43587
|
+
const input = {
|
|
43588
|
+
selectorKey: key,
|
|
43589
|
+
intendedAction: intent,
|
|
43590
|
+
alreadyTried: tried,
|
|
43591
|
+
pageUrl: page.url(),
|
|
43592
|
+
htmlSnapshot: await page.content().catch(() => "")
|
|
43593
|
+
};
|
|
43594
|
+
if (isInteractiveMode()) {
|
|
43595
|
+
return await promptForSelector(input).catch(() => null);
|
|
43596
|
+
}
|
|
43597
|
+
if (reportedMissing.has(key))
|
|
43598
|
+
return null;
|
|
43599
|
+
reportedMissing.add(key);
|
|
43600
|
+
process.stderr.write(`${JSON.stringify(buildStructuredError(input))}
|
|
43601
|
+
`);
|
|
43470
43602
|
return null;
|
|
43471
43603
|
}
|
|
43472
43604
|
async function attemptRecovery(page, _ctx, stepName, intendedAction, alreadyTried, diagnostics) {
|
|
@@ -43902,7 +44034,7 @@ async function detectCartRevealMode(page, trigger, drawerAlreadyOpen, viewport)
|
|
|
43902
44034
|
if (viewport === "desktop") {
|
|
43903
44035
|
try {
|
|
43904
44036
|
const observedHoverDrawer = await page.evaluate(async () => {
|
|
43905
|
-
return await new Promise((
|
|
44037
|
+
return await new Promise((resolve2) => {
|
|
43906
44038
|
const selectorMatch = (el) => {
|
|
43907
44039
|
if (!(el instanceof HTMLElement))
|
|
43908
44040
|
return false;
|
|
@@ -43916,13 +44048,13 @@ async function detectCartRevealMode(page, trigger, drawerAlreadyOpen, viewport)
|
|
|
43916
44048
|
for (const n of Array.from(m.addedNodes)) {
|
|
43917
44049
|
if (n instanceof Element && selectorMatch(n)) {
|
|
43918
44050
|
observer.disconnect();
|
|
43919
|
-
|
|
44051
|
+
resolve2(true);
|
|
43920
44052
|
return;
|
|
43921
44053
|
}
|
|
43922
44054
|
}
|
|
43923
44055
|
if (m.type === "attributes" && m.target instanceof Element && selectorMatch(m.target)) {
|
|
43924
44056
|
observer.disconnect();
|
|
43925
|
-
|
|
44057
|
+
resolve2(true);
|
|
43926
44058
|
return;
|
|
43927
44059
|
}
|
|
43928
44060
|
}
|
|
@@ -43935,7 +44067,7 @@ async function detectCartRevealMode(page, trigger, drawerAlreadyOpen, viewport)
|
|
|
43935
44067
|
});
|
|
43936
44068
|
setTimeout(() => {
|
|
43937
44069
|
observer.disconnect();
|
|
43938
|
-
|
|
44070
|
+
resolve2(false);
|
|
43939
44071
|
}, 600);
|
|
43940
44072
|
});
|
|
43941
44073
|
});
|
|
@@ -44065,7 +44197,7 @@ async function openMinicart(page, trigger, ctx, expectedProductTitle) {
|
|
|
44065
44197
|
dlog2(ctx, ` openMinicart: starting — trigger=${trigger.selector} title=${expectedProductTitle?.slice(0, 40) ?? "none"} revealBudget=${revealBudget}ms`);
|
|
44066
44198
|
await Promise.race([
|
|
44067
44199
|
dismissOverlays(page, ctx),
|
|
44068
|
-
new Promise((
|
|
44200
|
+
new Promise((resolve2) => setTimeout(resolve2, 4000))
|
|
44069
44201
|
]);
|
|
44070
44202
|
dlog2(ctx, " openMinicart: dismissOverlays done — checking alreadyOpen…");
|
|
44071
44203
|
await page.waitForTimeout(800);
|
|
@@ -44416,10 +44548,10 @@ async function waitForCartMutation(page, ctx, predicate, capMs = 2500) {
|
|
|
44416
44548
|
if (predicate(totals))
|
|
44417
44549
|
return totals;
|
|
44418
44550
|
if (responseSeen) {
|
|
44419
|
-
await new Promise((
|
|
44551
|
+
await new Promise((resolve2) => setTimeout(resolve2, 300));
|
|
44420
44552
|
return await parseCartTotals(page, ctx);
|
|
44421
44553
|
}
|
|
44422
|
-
await new Promise((
|
|
44554
|
+
await new Promise((resolve2) => setTimeout(resolve2, 250));
|
|
44423
44555
|
totals = await parseCartTotals(page, ctx);
|
|
44424
44556
|
}
|
|
44425
44557
|
return totals;
|
|
@@ -45341,7 +45473,7 @@ async function flowPurchaseJourney(ctx) {
|
|
|
45341
45473
|
await screenshotStable(page, { path: spBefore9, fullPage: false });
|
|
45342
45474
|
await Promise.race([
|
|
45343
45475
|
dismissOverlays(page, ctx),
|
|
45344
|
-
new Promise((
|
|
45476
|
+
new Promise((resolve2) => setTimeout(resolve2, 4000))
|
|
45345
45477
|
]);
|
|
45346
45478
|
let usedSelector = checkoutHit.selector;
|
|
45347
45479
|
let clickedText = await checkoutHit.locator.innerText().catch(() => "");
|
|
@@ -45681,7 +45813,7 @@ async function validateAddToCart(page, ctx, cartCountBefore, beforeUrl) {
|
|
|
45681
45813
|
|
|
45682
45814
|
// src/engine/lighthouse.ts
|
|
45683
45815
|
import { spawn } from "node:child_process";
|
|
45684
|
-
import { mkdirSync as mkdirSync5, readFileSync as
|
|
45816
|
+
import { mkdirSync as mkdirSync5, readFileSync as readFileSync5 } from "node:fs";
|
|
45685
45817
|
import { join as join7 } from "node:path";
|
|
45686
45818
|
var AGENT_A11Y_AUDIT_IDS = [
|
|
45687
45819
|
"button-name",
|
|
@@ -45792,7 +45924,7 @@ async function measureLighthouseOnce(url, opts, attempt) {
|
|
|
45792
45924
|
"--quiet",
|
|
45793
45925
|
"--max-wait-for-load=90000"
|
|
45794
45926
|
];
|
|
45795
|
-
const { code, stderr } = await new Promise((
|
|
45927
|
+
const { code, stderr } = await new Promise((resolve2) => {
|
|
45796
45928
|
const proc = spawn("npx", args, {
|
|
45797
45929
|
shell: true,
|
|
45798
45930
|
stdio: ["ignore", "ignore", "pipe"],
|
|
@@ -45802,12 +45934,12 @@ async function measureLighthouseOnce(url, opts, attempt) {
|
|
|
45802
45934
|
proc.stderr.on("data", (chunk) => {
|
|
45803
45935
|
stderrBuf += chunk.toString();
|
|
45804
45936
|
});
|
|
45805
|
-
proc.on("close", (exitCode) =>
|
|
45806
|
-
proc.on("error", (err) =>
|
|
45937
|
+
proc.on("close", (exitCode) => resolve2({ code: exitCode ?? 1, stderr: stderrBuf }));
|
|
45938
|
+
proc.on("error", (err) => resolve2({ code: 1, stderr: err.message }));
|
|
45807
45939
|
});
|
|
45808
45940
|
let report;
|
|
45809
45941
|
try {
|
|
45810
|
-
report = JSON.parse(
|
|
45942
|
+
report = JSON.parse(readFileSync5(outPath, "utf-8"));
|
|
45811
45943
|
} catch (err) {
|
|
45812
45944
|
return {
|
|
45813
45945
|
error: code !== 0 ? `lighthouse exit ${code}: ${stderr.slice(0, 200)}` : `parse failed: ${err.message}`
|
|
@@ -47035,14 +47167,14 @@ async function runSideBenchmarkContent(opts) {
|
|
|
47035
47167
|
}
|
|
47036
47168
|
|
|
47037
47169
|
// src/ignore/parser.ts
|
|
47038
|
-
import { existsSync as
|
|
47170
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6 } from "node:fs";
|
|
47039
47171
|
import { join as join8 } from "node:path";
|
|
47040
47172
|
function loadParityRc(cwd = process.cwd()) {
|
|
47041
47173
|
const path = join8(cwd, ".parityrc.json");
|
|
47042
|
-
if (!
|
|
47174
|
+
if (!existsSync6(path))
|
|
47043
47175
|
return ParityRc.parse({});
|
|
47044
47176
|
try {
|
|
47045
|
-
const raw = JSON.parse(
|
|
47177
|
+
const raw = JSON.parse(readFileSync6(path, "utf8"));
|
|
47046
47178
|
return ParityRc.parse(raw);
|
|
47047
47179
|
} catch (err) {
|
|
47048
47180
|
console.warn(`[parity] failed to parse ${path}: ${err.message}`);
|
|
@@ -47051,10 +47183,10 @@ function loadParityRc(cwd = process.cwd()) {
|
|
|
47051
47183
|
}
|
|
47052
47184
|
function loadParityIgnore(cwd = process.cwd()) {
|
|
47053
47185
|
const path = join8(cwd, ".parityignore");
|
|
47054
|
-
if (!
|
|
47186
|
+
if (!existsSync6(path))
|
|
47055
47187
|
return ParityIgnore.parse({});
|
|
47056
47188
|
try {
|
|
47057
|
-
const raw = JSON.parse(
|
|
47189
|
+
const raw = JSON.parse(readFileSync6(path, "utf8"));
|
|
47058
47190
|
return ParityIgnore.parse(raw);
|
|
47059
47191
|
} catch (err) {
|
|
47060
47192
|
console.warn(`[parity] failed to parse ${path}: ${err.message}`);
|
|
@@ -47165,7 +47297,7 @@ init_client();
|
|
|
47165
47297
|
init_client();
|
|
47166
47298
|
init_html_compact();
|
|
47167
47299
|
init_html_compact();
|
|
47168
|
-
import { existsSync as
|
|
47300
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync7, unlinkSync as unlinkSync2, writeFileSync as writeFileSync7 } from "node:fs";
|
|
47169
47301
|
import { join as join9 } from "node:path";
|
|
47170
47302
|
import { z as z3 } from "zod";
|
|
47171
47303
|
var CACHE_DIR = ".parity-cache";
|
|
@@ -47435,7 +47567,7 @@ async function discoverSelectors(urls, html3, opts = {}) {
|
|
|
47435
47567
|
const cacheDir = opts.cacheDir ?? CACHE_DIR;
|
|
47436
47568
|
const cachePath = join9(cacheDir, `selectors-${host}.json`);
|
|
47437
47569
|
const fingerprint = computeHtmlFingerprint(html3.home);
|
|
47438
|
-
if (!opts.noCache &&
|
|
47570
|
+
if (!opts.noCache && existsSync7(cachePath)) {
|
|
47439
47571
|
const cached = readCacheEntry(cachePath, fingerprint);
|
|
47440
47572
|
if (cached)
|
|
47441
47573
|
return cached.selectors;
|
|
@@ -47484,7 +47616,7 @@ ${compactHtmlForSelectors(html3.pdp, PDP_MAX_CHARS)}
|
|
|
47484
47616
|
console.warn(`[discover-selectors] checkout_button == minicart_trigger (\`${selectors.checkoutButton}\`); dropping to avoid step-9 misclick`);
|
|
47485
47617
|
selectors.checkoutButton = undefined;
|
|
47486
47618
|
}
|
|
47487
|
-
if (!
|
|
47619
|
+
if (!existsSync7(cacheDir))
|
|
47488
47620
|
mkdirSync6(cacheDir, { recursive: true });
|
|
47489
47621
|
const entry = {
|
|
47490
47622
|
schemaVersion: CACHE_SCHEMA_VERSION,
|
|
@@ -47492,7 +47624,7 @@ ${compactHtmlForSelectors(html3.pdp, PDP_MAX_CHARS)}
|
|
|
47492
47624
|
htmlFingerprint: fingerprint,
|
|
47493
47625
|
selectors
|
|
47494
47626
|
};
|
|
47495
|
-
|
|
47627
|
+
writeFileSync7(cachePath, `${JSON.stringify(entry, null, 2)}
|
|
47496
47628
|
`, "utf8");
|
|
47497
47629
|
return selectors;
|
|
47498
47630
|
}
|
|
@@ -47506,7 +47638,7 @@ function cacheTtlMs() {
|
|
|
47506
47638
|
function readCacheEntry(cachePath, currentFingerprint) {
|
|
47507
47639
|
let parsed;
|
|
47508
47640
|
try {
|
|
47509
|
-
parsed = JSON.parse(
|
|
47641
|
+
parsed = JSON.parse(readFileSync7(cachePath, "utf8"));
|
|
47510
47642
|
} catch {
|
|
47511
47643
|
console.warn(`[discover-selectors] cache corrompido em ${cachePath}; redescubrindo`);
|
|
47512
47644
|
try {
|
|
@@ -47533,14 +47665,14 @@ function readCacheEntry(cachePath, currentFingerprint) {
|
|
|
47533
47665
|
function persistSelectorValidation(homeUrl, validated, cacheDir = CACHE_DIR) {
|
|
47534
47666
|
const host = safeHost(homeUrl);
|
|
47535
47667
|
const cachePath = join9(cacheDir, `selectors-${host}.json`);
|
|
47536
|
-
if (!
|
|
47668
|
+
if (!existsSync7(cachePath))
|
|
47537
47669
|
return;
|
|
47538
47670
|
try {
|
|
47539
|
-
const parsed = SelectorCacheEntrySchema.safeParse(JSON.parse(
|
|
47671
|
+
const parsed = SelectorCacheEntrySchema.safeParse(JSON.parse(readFileSync7(cachePath, "utf8")));
|
|
47540
47672
|
if (!parsed.success)
|
|
47541
47673
|
return;
|
|
47542
47674
|
const entry = { ...parsed.data, validated };
|
|
47543
|
-
|
|
47675
|
+
writeFileSync7(cachePath, `${JSON.stringify(entry, null, 2)}
|
|
47544
47676
|
`, "utf8");
|
|
47545
47677
|
} catch {}
|
|
47546
47678
|
}
|
|
@@ -47577,7 +47709,7 @@ function safeHost(url) {
|
|
|
47577
47709
|
}
|
|
47578
47710
|
|
|
47579
47711
|
// src/report/benchmark-html.ts
|
|
47580
|
-
import { readFileSync as
|
|
47712
|
+
import { readFileSync as readFileSync8 } from "node:fs";
|
|
47581
47713
|
var MIME = {
|
|
47582
47714
|
".png": "image/png",
|
|
47583
47715
|
".jpg": "image/jpeg",
|
|
@@ -47592,7 +47724,7 @@ function dataUri(absPath) {
|
|
|
47592
47724
|
const mime = MIME[ext];
|
|
47593
47725
|
if (!mime)
|
|
47594
47726
|
return null;
|
|
47595
|
-
return `data:${mime};base64,${
|
|
47727
|
+
return `data:${mime};base64,${readFileSync8(absPath).toString("base64")}`;
|
|
47596
47728
|
} catch {
|
|
47597
47729
|
return null;
|
|
47598
47730
|
}
|
|
@@ -48283,10 +48415,10 @@ async function benchmarkCommand(opts) {
|
|
|
48283
48415
|
logo,
|
|
48284
48416
|
sides
|
|
48285
48417
|
};
|
|
48286
|
-
|
|
48418
|
+
writeFileSync8(paths.reportJson, `${JSON.stringify(report, null, 2)}
|
|
48287
48419
|
`, "utf8");
|
|
48288
48420
|
const html3 = renderBenchmarkHtml(report, { lang });
|
|
48289
|
-
|
|
48421
|
+
writeFileSync8(paths.reportHtml, html3, "utf8");
|
|
48290
48422
|
printSummary2(report);
|
|
48291
48423
|
console.log(chalk3.dim(` → ${paths.reportHtml}`));
|
|
48292
48424
|
console.log(chalk3.dim(` → HAR: ${paths.harDir}/user-navigation-benchmark-*.har`));
|
|
@@ -48326,7 +48458,7 @@ function printSummary2(report) {
|
|
|
48326
48458
|
}
|
|
48327
48459
|
|
|
48328
48460
|
// src/commands/cache.ts
|
|
48329
|
-
import { existsSync as
|
|
48461
|
+
import { existsSync as existsSync10, readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "node:fs";
|
|
48330
48462
|
import { join as join13 } from "node:path";
|
|
48331
48463
|
import chalk4 from "chalk";
|
|
48332
48464
|
import ora3 from "ora";
|
|
@@ -52970,11 +53102,11 @@ function skip6(start, summary) {
|
|
|
52970
53102
|
}
|
|
52971
53103
|
|
|
52972
53104
|
// src/checks/visual-regression.ts
|
|
52973
|
-
import { existsSync as
|
|
53105
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync8 } from "node:fs";
|
|
52974
53106
|
import { basename, join as join12 } from "node:path";
|
|
52975
53107
|
|
|
52976
53108
|
// src/diff/visual.ts
|
|
52977
|
-
import { readFileSync as
|
|
53109
|
+
import { readFileSync as readFileSync9, writeFileSync as writeFileSync9 } from "node:fs";
|
|
52978
53110
|
import pixelmatch from "pixelmatch";
|
|
52979
53111
|
import { PNG } from "pngjs";
|
|
52980
53112
|
var DEFAULTS = {
|
|
@@ -52983,8 +53115,8 @@ var DEFAULTS = {
|
|
|
52983
53115
|
};
|
|
52984
53116
|
function diffScreenshots(prodPath, candPath, heatmapPath, opts = {}) {
|
|
52985
53117
|
const cfg = { ...DEFAULTS, ...opts };
|
|
52986
|
-
const prod = PNG.sync.read(
|
|
52987
|
-
const cand = PNG.sync.read(
|
|
53118
|
+
const prod = PNG.sync.read(readFileSync9(prodPath));
|
|
53119
|
+
const cand = PNG.sync.read(readFileSync9(candPath));
|
|
52988
53120
|
const width = Math.min(prod.width, cand.width);
|
|
52989
53121
|
const height = Math.min(prod.height, cand.height);
|
|
52990
53122
|
const prodCropped = cropPng(prod, width, height);
|
|
@@ -52993,7 +53125,7 @@ function diffScreenshots(prodPath, candPath, heatmapPath, opts = {}) {
|
|
|
52993
53125
|
const diffPixels = pixelmatch(prodCropped.data, candCropped.data, diff.data, width, height, {
|
|
52994
53126
|
threshold: cfg.threshold
|
|
52995
53127
|
});
|
|
52996
|
-
|
|
53128
|
+
writeFileSync9(heatmapPath, PNG.sync.write(diff));
|
|
52997
53129
|
const totalPixels = width * height;
|
|
52998
53130
|
const pctDiff = totalPixels > 0 ? diffPixels / totalPixels : 0;
|
|
52999
53131
|
const passed = pctDiff <= cfg.maxPctDiff;
|
|
@@ -53025,7 +53157,7 @@ init_client();
|
|
|
53025
53157
|
|
|
53026
53158
|
// src/llm/visual-semantic-diff.ts
|
|
53027
53159
|
init_client();
|
|
53028
|
-
import { readFileSync as
|
|
53160
|
+
import { readFileSync as readFileSync10 } from "node:fs";
|
|
53029
53161
|
import { PNG as PNG2 } from "pngjs";
|
|
53030
53162
|
var MAX_HEIGHT = 8000;
|
|
53031
53163
|
var LLM_PROMPT_VERSION = "v4-text-caution";
|
|
@@ -53170,7 +53302,7 @@ Se NÃO houver diferenças relevantes (só ruído), retorne differences: []. Nã
|
|
|
53170
53302
|
Cap 8 diferenças por análise — só as que mais importam.
|
|
53171
53303
|
`.trim();
|
|
53172
53304
|
function loadCroppedPngBase64(path, maxHeight = MAX_HEIGHT) {
|
|
53173
|
-
const png = PNG2.sync.read(
|
|
53305
|
+
const png = PNG2.sync.read(readFileSync10(path));
|
|
53174
53306
|
if (png.height <= maxHeight) {
|
|
53175
53307
|
return PNG2.sync.write(png).toString("base64");
|
|
53176
53308
|
}
|
|
@@ -53289,13 +53421,13 @@ function partitionExpectedSections(sections, expected) {
|
|
|
53289
53421
|
|
|
53290
53422
|
// src/checks/lib/parity-cache.ts
|
|
53291
53423
|
import { createHash as createHash2 } from "node:crypto";
|
|
53292
|
-
import { existsSync as
|
|
53424
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "node:fs";
|
|
53293
53425
|
import { dirname as dirname3, join as join11 } from "node:path";
|
|
53294
53426
|
function hashScreenshotPair(prodPath, candPath, promptVersion) {
|
|
53295
53427
|
const h = createHash2("sha256");
|
|
53296
|
-
h.update(
|
|
53428
|
+
h.update(readFileSync11(prodPath));
|
|
53297
53429
|
h.update("|");
|
|
53298
|
-
h.update(
|
|
53430
|
+
h.update(readFileSync11(candPath));
|
|
53299
53431
|
h.update("|");
|
|
53300
53432
|
h.update(promptVersion);
|
|
53301
53433
|
return h.digest("hex");
|
|
@@ -53305,10 +53437,10 @@ function cacheFilePath(cacheDir) {
|
|
|
53305
53437
|
}
|
|
53306
53438
|
function readCache(cacheDir) {
|
|
53307
53439
|
const file = cacheFilePath(cacheDir);
|
|
53308
|
-
if (!
|
|
53440
|
+
if (!existsSync8(file))
|
|
53309
53441
|
return {};
|
|
53310
53442
|
try {
|
|
53311
|
-
const raw =
|
|
53443
|
+
const raw = readFileSync11(file, "utf-8");
|
|
53312
53444
|
const parsed = JSON.parse(raw);
|
|
53313
53445
|
if (parsed && typeof parsed === "object")
|
|
53314
53446
|
return parsed;
|
|
@@ -53320,7 +53452,7 @@ function readCache(cacheDir) {
|
|
|
53320
53452
|
function writeCache(cacheDir, cache) {
|
|
53321
53453
|
const file = cacheFilePath(cacheDir);
|
|
53322
53454
|
mkdirSync7(dirname3(file), { recursive: true });
|
|
53323
|
-
|
|
53455
|
+
writeFileSync10(file, JSON.stringify(cache, null, 2));
|
|
53324
53456
|
}
|
|
53325
53457
|
function getCacheEntry(cache, hash2, currentPromptVersion) {
|
|
53326
53458
|
const entry = cache[hash2];
|
|
@@ -53433,7 +53565,7 @@ async function visualRegressionKeyframes(ctx) {
|
|
|
53433
53565
|
const { pairs } = pairCaptures(ctx.prodPages, ctx.candPages);
|
|
53434
53566
|
const issues = [];
|
|
53435
53567
|
const diffDir = join12(ctx.outDir, "screenshots");
|
|
53436
|
-
if (!
|
|
53568
|
+
if (!existsSync9(diffDir))
|
|
53437
53569
|
mkdirSync8(diffDir, { recursive: true });
|
|
53438
53570
|
const expectedDivergences = ctx.ignore.expectedDivergences ?? [];
|
|
53439
53571
|
const useLlm = isLlmAvailable();
|
|
@@ -53442,7 +53574,7 @@ async function visualRegressionKeyframes(ctx) {
|
|
|
53442
53574
|
const cache = ctx.cacheDir && !ctx.noCache ? readCache(ctx.cacheDir) : {};
|
|
53443
53575
|
const prepared = [];
|
|
53444
53576
|
for (const pair of pairs) {
|
|
53445
|
-
if (!
|
|
53577
|
+
if (!existsSync9(pair.prod.screenshotPath) || !existsSync9(pair.cand.screenshotPath)) {
|
|
53446
53578
|
continue;
|
|
53447
53579
|
}
|
|
53448
53580
|
const heatmapName = `diff-${pair.viewport}-${basename(pair.key.replace(/[/:]/g, "_"))}.png`;
|
|
@@ -56171,7 +56303,7 @@ async function cacheCommand(opts) {
|
|
|
56171
56303
|
writeRunReportJson(paths.runDir, run);
|
|
56172
56304
|
const html3 = renderHtmlReport(run, paths.runDir);
|
|
56173
56305
|
writeRunReportHtml(paths.runDir, html3);
|
|
56174
|
-
|
|
56306
|
+
writeFileSync11(join13(paths.runDir, "cache.json"), `${JSON.stringify({
|
|
56175
56307
|
schemaVersion: "0.1",
|
|
56176
56308
|
prodUrl: opts.prod,
|
|
56177
56309
|
candUrl: opts.cand,
|
|
@@ -56231,8 +56363,8 @@ async function discoverPagePaths(prodUrl, opts, limit) {
|
|
|
56231
56363
|
if (opts.urls) {
|
|
56232
56364
|
if (opts.urls.endsWith(".txt") || opts.urls.endsWith(".list") || opts.urls.startsWith("file:")) {
|
|
56233
56365
|
const path = opts.urls.replace(/^file:\/\//, "");
|
|
56234
|
-
if (
|
|
56235
|
-
return
|
|
56366
|
+
if (existsSync10(path)) {
|
|
56367
|
+
return readFileSync12(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
|
|
56236
56368
|
}
|
|
56237
56369
|
}
|
|
56238
56370
|
return opts.urls.split(",").map((s) => s.trim()).filter(Boolean).map((s) => s.startsWith("/") || s.startsWith("http") ? s : `/${s}`);
|
|
@@ -56836,7 +56968,7 @@ async function cssTraceCommand(opts) {
|
|
|
56836
56968
|
}
|
|
56837
56969
|
|
|
56838
56970
|
// src/commands/e2e.ts
|
|
56839
|
-
import { writeFileSync as
|
|
56971
|
+
import { writeFileSync as writeFileSync13 } from "node:fs";
|
|
56840
56972
|
import { spawn as spawn2 } from "node:child_process";
|
|
56841
56973
|
import chalk9 from "chalk";
|
|
56842
56974
|
import ora5 from "ora";
|
|
@@ -57788,7 +57920,7 @@ async function flowLogin(ctx) {
|
|
|
57788
57920
|
|
|
57789
57921
|
// src/llm/resolve-search-terms.ts
|
|
57790
57922
|
init_client();
|
|
57791
|
-
import { existsSync as
|
|
57923
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync13, writeFileSync as writeFileSync12 } from "node:fs";
|
|
57792
57924
|
import { join as join15 } from "node:path";
|
|
57793
57925
|
var CACHE_DIR2 = ".parity-cache";
|
|
57794
57926
|
var FALLBACK_TERMS = ["produto", "preto", "promocao"];
|
|
@@ -57870,9 +58002,9 @@ async function resolveSearchTerms(url, html3, opts = {}) {
|
|
|
57870
58002
|
const host = safeHost3(url);
|
|
57871
58003
|
const cacheDir = opts.cacheDir ?? CACHE_DIR2;
|
|
57872
58004
|
const cachePath = join15(cacheDir, `search-terms-${host}.json`);
|
|
57873
|
-
if (!opts.noCache &&
|
|
58005
|
+
if (!opts.noCache && existsSync11(cachePath)) {
|
|
57874
58006
|
try {
|
|
57875
|
-
const cached = JSON.parse(
|
|
58007
|
+
const cached = JSON.parse(readFileSync13(cachePath, "utf8"));
|
|
57876
58008
|
if (cached.withResults?.trim()) {
|
|
57877
58009
|
return { withResults: cached.withResults.trim(), noResults };
|
|
57878
58010
|
}
|
|
@@ -57880,9 +58012,9 @@ async function resolveSearchTerms(url, html3, opts = {}) {
|
|
|
57880
58012
|
}
|
|
57881
58013
|
const suggested = await suggestTermViaLlm(url, html3);
|
|
57882
58014
|
if (suggested) {
|
|
57883
|
-
if (!
|
|
58015
|
+
if (!existsSync11(cacheDir))
|
|
57884
58016
|
mkdirSync9(cacheDir, { recursive: true });
|
|
57885
|
-
|
|
58017
|
+
writeFileSync12(cachePath, `${JSON.stringify({ withResults: suggested, source: "llm" }, null, 2)}
|
|
57886
58018
|
`, "utf8");
|
|
57887
58019
|
return { withResults: suggested, noResults };
|
|
57888
58020
|
}
|
|
@@ -58573,10 +58705,10 @@ async function runFlow(flow, ctx) {
|
|
|
58573
58705
|
});
|
|
58574
58706
|
let timer;
|
|
58575
58707
|
let cleanup = Promise.resolve();
|
|
58576
|
-
const timeoutPromise = new Promise((
|
|
58708
|
+
const timeoutPromise = new Promise((resolve2) => {
|
|
58577
58709
|
timer = setTimeout(() => {
|
|
58578
58710
|
const pages = ctx.ctx.pages();
|
|
58579
|
-
|
|
58711
|
+
resolve2(finalize(flow, ctx, [], [
|
|
58580
58712
|
{
|
|
58581
58713
|
step: 0,
|
|
58582
58714
|
name: "flow-timeout",
|
|
@@ -58625,7 +58757,7 @@ var PROBE_TIMEOUT_MS = 2000;
|
|
|
58625
58757
|
function withTimeout(p, capMs, fallback) {
|
|
58626
58758
|
return Promise.race([
|
|
58627
58759
|
p.catch(() => fallback),
|
|
58628
|
-
new Promise((
|
|
58760
|
+
new Promise((resolve2) => setTimeout(() => resolve2(fallback), capMs))
|
|
58629
58761
|
]);
|
|
58630
58762
|
}
|
|
58631
58763
|
function selectorKeysOf(selectors) {
|
|
@@ -59100,8 +59232,8 @@ async function e2eCommand(opts) {
|
|
|
59100
59232
|
generatedAt: new Date().toISOString(),
|
|
59101
59233
|
durationMs
|
|
59102
59234
|
});
|
|
59103
|
-
|
|
59104
|
-
|
|
59235
|
+
writeFileSync13(paths.reportHtml, html3, "utf8");
|
|
59236
|
+
writeFileSync13(paths.reportJson, `${JSON.stringify({
|
|
59105
59237
|
runId,
|
|
59106
59238
|
mode: "e2e",
|
|
59107
59239
|
url: opts.url,
|
|
@@ -59307,12 +59439,12 @@ ${JSON.stringify(checks.map((c) => ({ name: c.name, status: c.status, summary: c
|
|
|
59307
59439
|
|
|
59308
59440
|
// src/commands/extract.ts
|
|
59309
59441
|
import { mkdirSync as mkdirSync13 } from "node:fs";
|
|
59310
|
-
import { resolve as
|
|
59442
|
+
import { resolve as resolve3 } from "node:path";
|
|
59311
59443
|
import chalk12 from "chalk";
|
|
59312
59444
|
|
|
59313
59445
|
// src/llm/section-understanding.ts
|
|
59314
59446
|
init_client();
|
|
59315
|
-
import { readFileSync as
|
|
59447
|
+
import { readFileSync as readFileSync14 } from "node:fs";
|
|
59316
59448
|
var SUMMARIZE_TOOL = {
|
|
59317
59449
|
name: "summarize_understanding",
|
|
59318
59450
|
description: "Return a single paragraph describing what you understood from the section diff signals. NO code — only diagnosis.",
|
|
@@ -59350,7 +59482,7 @@ async function invokeUnderstandingSummary(input) {
|
|
|
59350
59482
|
return null;
|
|
59351
59483
|
let markdown;
|
|
59352
59484
|
try {
|
|
59353
|
-
markdown =
|
|
59485
|
+
markdown = readFileSync14(input.markdownPath, "utf8");
|
|
59354
59486
|
} catch (err) {
|
|
59355
59487
|
console.error(`[section-understanding] failed to read markdown: ${err.message}`);
|
|
59356
59488
|
return null;
|
|
@@ -59360,7 +59492,7 @@ async function invokeUnderstandingSummary(input) {
|
|
|
59360
59492
|
if (!p)
|
|
59361
59493
|
continue;
|
|
59362
59494
|
try {
|
|
59363
|
-
const buf =
|
|
59495
|
+
const buf = readFileSync14(p);
|
|
59364
59496
|
images.push({ base64: buf.toString("base64"), mediaType: "image/png" });
|
|
59365
59497
|
} catch (err) {
|
|
59366
59498
|
console.error(`[section-understanding] skipping image ${p}: ${err.message}`);
|
|
@@ -59637,19 +59769,19 @@ function collectCandidatesInPage() {
|
|
|
59637
59769
|
}
|
|
59638
59770
|
|
|
59639
59771
|
// src/extract/exporters/json.ts
|
|
59640
|
-
import { writeFileSync as
|
|
59772
|
+
import { writeFileSync as writeFileSync14 } from "node:fs";
|
|
59641
59773
|
import { join as join16 } from "node:path";
|
|
59642
59774
|
var jsonExporter = {
|
|
59643
59775
|
name: "json",
|
|
59644
59776
|
async export(bundle, outDir) {
|
|
59645
59777
|
const path = join16(outDir, "manifest.json");
|
|
59646
|
-
|
|
59778
|
+
writeFileSync14(path, `${JSON.stringify(bundle, null, 2)}
|
|
59647
59779
|
`, "utf8");
|
|
59648
59780
|
}
|
|
59649
59781
|
};
|
|
59650
59782
|
|
|
59651
59783
|
// src/extract/exporters/markdown.ts
|
|
59652
|
-
import { mkdirSync as mkdirSync10, writeFileSync as
|
|
59784
|
+
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync15 } from "node:fs";
|
|
59653
59785
|
import { join as join17 } from "node:path";
|
|
59654
59786
|
|
|
59655
59787
|
// src/extract/naming.ts
|
|
@@ -59664,13 +59796,13 @@ var markdownExporter = {
|
|
|
59664
59796
|
async export(bundle, outDir) {
|
|
59665
59797
|
const dirNames = bundle.components.map((c, i) => componentDirName(c.role, i + 1));
|
|
59666
59798
|
const indexMd = renderIndex(bundle, dirNames);
|
|
59667
|
-
|
|
59799
|
+
writeFileSync15(join17(outDir, "index.md"), indexMd, "utf8");
|
|
59668
59800
|
bundle.components.forEach((component, i) => {
|
|
59669
59801
|
const dirName = dirNames[i];
|
|
59670
59802
|
const componentDir = join17(outDir, "components", dirName);
|
|
59671
59803
|
mkdirSync10(componentDir, { recursive: true });
|
|
59672
59804
|
const readme = renderComponentReadme(bundle, component);
|
|
59673
|
-
|
|
59805
|
+
writeFileSync15(join17(componentDir, "README.md"), readme, "utf8");
|
|
59674
59806
|
});
|
|
59675
59807
|
}
|
|
59676
59808
|
};
|
|
@@ -59777,7 +59909,7 @@ function truncateHtml(html3, max) {
|
|
|
59777
59909
|
}
|
|
59778
59910
|
|
|
59779
59911
|
// src/extract/extract-component.ts
|
|
59780
|
-
import { mkdirSync as mkdirSync11, writeFileSync as
|
|
59912
|
+
import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync16 } from "node:fs";
|
|
59781
59913
|
|
|
59782
59914
|
// src/engine/section-capture.ts
|
|
59783
59915
|
init_esm10();
|
|
@@ -60040,8 +60172,8 @@ async function extractComponent(page, component, opts) {
|
|
|
60040
60172
|
links: capLinks(links, LINK_CAP),
|
|
60041
60173
|
textContent: textContent2
|
|
60042
60174
|
};
|
|
60043
|
-
|
|
60044
|
-
|
|
60175
|
+
writeFileSync16(`${opts.outDir}/component.html`, extracted.html, "utf8");
|
|
60176
|
+
writeFileSync16(`${opts.outDir}/styles.json`, `${JSON.stringify(computedStyles ?? {}, null, 2)}
|
|
60045
60177
|
`, "utf8");
|
|
60046
60178
|
return extracted;
|
|
60047
60179
|
}
|
|
@@ -60130,18 +60262,18 @@ function capLinks(links, max) {
|
|
|
60130
60262
|
|
|
60131
60263
|
// src/commands/section.ts
|
|
60132
60264
|
import { mkdirSync as mkdirSync12 } from "node:fs";
|
|
60133
|
-
import { resolve } from "node:path";
|
|
60265
|
+
import { resolve as resolve2 } from "node:path";
|
|
60134
60266
|
import chalk11 from "chalk";
|
|
60135
60267
|
import * as diff from "diff";
|
|
60136
60268
|
import prettier from "prettier";
|
|
60137
60269
|
|
|
60138
60270
|
// src/diff/heatmap-regions.ts
|
|
60139
|
-
import { readFileSync as
|
|
60271
|
+
import { readFileSync as readFileSync15 } from "node:fs";
|
|
60140
60272
|
import { PNG as PNG4 } from "pngjs";
|
|
60141
60273
|
var DEFAULT_MAX_HOTSPOTS = 5;
|
|
60142
60274
|
var DEFAULT_MIN_COMPONENT_PIXELS = 50;
|
|
60143
60275
|
function analyzeHeatmapRegions(pngPath, opts = {}) {
|
|
60144
|
-
const png = PNG4.sync.read(
|
|
60276
|
+
const png = PNG4.sync.read(readFileSync15(pngPath));
|
|
60145
60277
|
return analyzeHeatmapBuffer(png.data, png.width, png.height, opts);
|
|
60146
60278
|
}
|
|
60147
60279
|
function analyzeHeatmapBuffer(data2, width, height, opts = {}) {
|
|
@@ -60254,7 +60386,7 @@ function analyzeHeatmapBuffer(data2, width, height, opts = {}) {
|
|
|
60254
60386
|
}
|
|
60255
60387
|
|
|
60256
60388
|
// src/diff/section-bundle.ts
|
|
60257
|
-
import { writeFileSync as
|
|
60389
|
+
import { writeFileSync as writeFileSync17 } from "node:fs";
|
|
60258
60390
|
import { basename as basename2, dirname as dirname4, join as join18, relative as relative3 } from "node:path";
|
|
60259
60391
|
function buildStyleDeltas(input) {
|
|
60260
60392
|
const cs = input.computedStyles;
|
|
@@ -60300,11 +60432,11 @@ function assembleSectionDiffBundle(input) {
|
|
|
60300
60432
|
styleDeltas
|
|
60301
60433
|
};
|
|
60302
60434
|
const jsonPath = join18(input.outDir, `${input.filePrefix}-bundle.json`);
|
|
60303
|
-
|
|
60435
|
+
writeFileSync17(jsonPath, `${JSON.stringify(json, mapReplacer, 2)}
|
|
60304
60436
|
`, "utf8");
|
|
60305
60437
|
const markdown = renderMarkdownBundle(input, styleDeltas);
|
|
60306
60438
|
const markdownPath = join18(input.outDir, `${input.filePrefix}-prompt.md`);
|
|
60307
|
-
|
|
60439
|
+
writeFileSync17(markdownPath, markdown, "utf8");
|
|
60308
60440
|
const summary = oneLineSummary(input, styleDeltas);
|
|
60309
60441
|
return { jsonPath, markdownPath, summary };
|
|
60310
60442
|
}
|
|
@@ -60520,10 +60652,10 @@ async function sectionCommand(opts) {
|
|
|
60520
60652
|
const hash2 = hashSelector(opts.selector);
|
|
60521
60653
|
const filePrefix = `section-${hash2}-${viewport}`;
|
|
60522
60654
|
const screenshotPaths = {
|
|
60523
|
-
prod:
|
|
60524
|
-
cand:
|
|
60655
|
+
prod: resolve2(opts.outDir, `${filePrefix}-prod.png`),
|
|
60656
|
+
cand: resolve2(opts.outDir, `${filePrefix}-cand.png`)
|
|
60525
60657
|
};
|
|
60526
|
-
const heatmapPath =
|
|
60658
|
+
const heatmapPath = resolve2(opts.outDir, `${filePrefix}-heatmap.png`);
|
|
60527
60659
|
const browser = await launchBrowser({ headless: true });
|
|
60528
60660
|
try {
|
|
60529
60661
|
const [prodSide, candSide] = await Promise.all([
|
|
@@ -60620,7 +60752,7 @@ async function gatherSide(browser, opts) {
|
|
|
60620
60752
|
stabilizeCarousels(page).catch(() => {
|
|
60621
60753
|
return;
|
|
60622
60754
|
}),
|
|
60623
|
-
new Promise((
|
|
60755
|
+
new Promise((resolve3) => setTimeout(resolve3, 3000))
|
|
60624
60756
|
]);
|
|
60625
60757
|
if (opts.wantScreenshot) {
|
|
60626
60758
|
const scrollBudget = 30000;
|
|
@@ -60628,13 +60760,13 @@ async function gatherSide(browser, opts) {
|
|
|
60628
60760
|
scrollFullPage(page, scrollBudget).catch(() => {
|
|
60629
60761
|
return;
|
|
60630
60762
|
}),
|
|
60631
|
-
new Promise((
|
|
60763
|
+
new Promise((resolve3) => setTimeout(resolve3, scrollBudget + 2000))
|
|
60632
60764
|
]);
|
|
60633
60765
|
await Promise.race([
|
|
60634
60766
|
waitForSkeletonsToResolve(page, 5000).catch(() => {
|
|
60635
60767
|
return;
|
|
60636
60768
|
}),
|
|
60637
|
-
new Promise((
|
|
60769
|
+
new Promise((resolve3) => setTimeout(resolve3, 5000))
|
|
60638
60770
|
]);
|
|
60639
60771
|
}
|
|
60640
60772
|
const artifacts = await captureSectionArtifacts(page, {
|
|
@@ -60990,7 +61122,7 @@ async function extractCommand(opts) {
|
|
|
60990
61122
|
const host = safeHost4(opts.url);
|
|
60991
61123
|
const timestamp = new Date().toISOString();
|
|
60992
61124
|
const runDirTimestamp = timestamp.replace(/[:.]/g, "-");
|
|
60993
|
-
const runDir =
|
|
61125
|
+
const runDir = resolve3(opts.outDir, host, runDirTimestamp);
|
|
60994
61126
|
mkdirSync13(runDir, { recursive: true });
|
|
60995
61127
|
const browser = await launchBrowser({ headless: true });
|
|
60996
61128
|
try {
|
|
@@ -61037,7 +61169,7 @@ async function extractCommand(opts) {
|
|
|
61037
61169
|
for (const component of detected) {
|
|
61038
61170
|
globalIndex++;
|
|
61039
61171
|
const dirName = componentDirName(component.role, globalIndex);
|
|
61040
|
-
const componentDir =
|
|
61172
|
+
const componentDir = resolve3(runDir, "components", dirName);
|
|
61041
61173
|
const extracted = await extractComponent(page, component, {
|
|
61042
61174
|
outDir: componentDir,
|
|
61043
61175
|
index: globalIndex,
|
|
@@ -61432,7 +61564,7 @@ function formatPatch(patch) {
|
|
|
61432
61564
|
}
|
|
61433
61565
|
|
|
61434
61566
|
// src/commands/journey.ts
|
|
61435
|
-
import { writeFileSync as
|
|
61567
|
+
import { writeFileSync as writeFileSync18 } from "node:fs";
|
|
61436
61568
|
import { join as join19 } from "node:path";
|
|
61437
61569
|
import chalk14 from "chalk";
|
|
61438
61570
|
import ora6 from "ora";
|
|
@@ -61595,7 +61727,7 @@ async function journeyCommand(opts) {
|
|
|
61595
61727
|
if (opts.github)
|
|
61596
61728
|
emitGithubAnnotations(failures);
|
|
61597
61729
|
if (opts.junit) {
|
|
61598
|
-
|
|
61730
|
+
writeFileSync18(opts.junit, buildJUnit(rows, failures), "utf8");
|
|
61599
61731
|
if (!opts.json)
|
|
61600
61732
|
console.log(chalk14.dim(` → JUnit XML: ${opts.junit}`));
|
|
61601
61733
|
}
|
|
@@ -62073,8 +62205,8 @@ function listCommand(output) {
|
|
|
62073
62205
|
}
|
|
62074
62206
|
|
|
62075
62207
|
// src/commands/migrate.ts
|
|
62076
|
-
import { existsSync as
|
|
62077
|
-
import { resolve as
|
|
62208
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync16, readFileSync as readFileSync20, writeFileSync as writeFileSync24 } from "node:fs";
|
|
62209
|
+
import { resolve as resolve4 } from "node:path";
|
|
62078
62210
|
import chalk17 from "chalk";
|
|
62079
62211
|
import open from "open";
|
|
62080
62212
|
|
|
@@ -62519,22 +62651,22 @@ function compactComponentHtml(html3, maxChars = COMPONENT_HTML_MAX_CHARS) {
|
|
|
62519
62651
|
}
|
|
62520
62652
|
|
|
62521
62653
|
// src/migrate/exporters/json.ts
|
|
62522
|
-
import { writeFileSync as
|
|
62654
|
+
import { writeFileSync as writeFileSync19 } from "node:fs";
|
|
62523
62655
|
import { join as join20 } from "node:path";
|
|
62524
62656
|
var jsonExporter2 = {
|
|
62525
62657
|
name: "json",
|
|
62526
62658
|
async export(bundle, outDir) {
|
|
62527
|
-
|
|
62659
|
+
writeFileSync19(join20(outDir, "manifest.json"), `${JSON.stringify(bundle, null, 2)}
|
|
62528
62660
|
`, "utf8");
|
|
62529
62661
|
}
|
|
62530
62662
|
};
|
|
62531
62663
|
|
|
62532
62664
|
// src/migrate/exporters/markdown.ts
|
|
62533
|
-
import { mkdirSync as mkdirSync15, writeFileSync as
|
|
62665
|
+
import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync21 } from "node:fs";
|
|
62534
62666
|
import { join as join22 } from "node:path";
|
|
62535
62667
|
|
|
62536
62668
|
// src/migrate/vtex/content-assets.ts
|
|
62537
|
-
import { mkdirSync as mkdirSync14, writeFileSync as
|
|
62669
|
+
import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync20 } from "node:fs";
|
|
62538
62670
|
import { join as join21 } from "node:path";
|
|
62539
62671
|
var MAX_IMAGES = 150;
|
|
62540
62672
|
var IMG_EXT = /\.(jpe?g|png|webp|gif|svg|avif)(\?|#|$)/i;
|
|
@@ -62654,7 +62786,7 @@ async function downloadContentImages(urls, runDir, fetchBytes) {
|
|
|
62654
62786
|
if (!got)
|
|
62655
62787
|
continue;
|
|
62656
62788
|
const name = contentImageName(url, i, used);
|
|
62657
|
-
|
|
62789
|
+
writeFileSync20(join21(dir, name), got.buf);
|
|
62658
62790
|
map2[url] = `assets/content/${name}`;
|
|
62659
62791
|
downloaded++;
|
|
62660
62792
|
}
|
|
@@ -62676,9 +62808,9 @@ var markdownExporter2 = {
|
|
|
62676
62808
|
notes.push(`\`${dirName}\`: collapsed ${compact.collapsed} repeated child element(s)`);
|
|
62677
62809
|
if (compact.truncated)
|
|
62678
62810
|
notes.push(`\`${dirName}\`: HTML truncated to fit the per-component token ceiling`);
|
|
62679
|
-
|
|
62811
|
+
writeFileSync21(join22(componentDir, "README.md"), renderComponentReadme2(bundle.url, component, compact.html), "utf8");
|
|
62680
62812
|
});
|
|
62681
|
-
|
|
62813
|
+
writeFileSync21(join22(outDir, "index.md"), renderIndex2(bundle, notes), "utf8");
|
|
62682
62814
|
}
|
|
62683
62815
|
};
|
|
62684
62816
|
function renderIndex2(bundle, notes) {
|
|
@@ -62880,7 +63012,7 @@ function escapePipes2(s) {
|
|
|
62880
63012
|
}
|
|
62881
63013
|
|
|
62882
63014
|
// src/migrate/exporters/html.ts
|
|
62883
|
-
import { readFileSync as
|
|
63015
|
+
import { readFileSync as readFileSync16, writeFileSync as writeFileSync22 } from "node:fs";
|
|
62884
63016
|
import { join as join23 } from "node:path";
|
|
62885
63017
|
|
|
62886
63018
|
// src/migrate/targets/faststore-v4.ts
|
|
@@ -63201,9 +63333,9 @@ var TARGET_NAMES = Object.keys(TARGETS);
|
|
|
63201
63333
|
var htmlExporter = {
|
|
63202
63334
|
name: "html",
|
|
63203
63335
|
async export(bundle, outDir) {
|
|
63204
|
-
|
|
63336
|
+
writeFileSync22(join23(outDir, "index.html"), renderHtml(bundle, (p) => p ?? null), "utf8");
|
|
63205
63337
|
const inline = (p) => p ? dataUri2(join23(outDir, p)) ?? p : null;
|
|
63206
|
-
|
|
63338
|
+
writeFileSync22(join23(outDir, "report.html"), renderHtml(bundle, inline), "utf8");
|
|
63207
63339
|
}
|
|
63208
63340
|
};
|
|
63209
63341
|
var MIME2 = {
|
|
@@ -63221,7 +63353,7 @@ function dataUri2(absPath) {
|
|
|
63221
63353
|
const mime = MIME2[ext];
|
|
63222
63354
|
if (!mime)
|
|
63223
63355
|
return null;
|
|
63224
|
-
return `data:${mime};base64,${
|
|
63356
|
+
return `data:${mime};base64,${readFileSync16(absPath).toString("base64")}`;
|
|
63225
63357
|
} catch {
|
|
63226
63358
|
return null;
|
|
63227
63359
|
}
|
|
@@ -63525,7 +63657,7 @@ function buildMigrationPrompt(bundle, playbook, source) {
|
|
|
63525
63657
|
}
|
|
63526
63658
|
|
|
63527
63659
|
// src/migrate/plan.ts
|
|
63528
|
-
import { existsSync as
|
|
63660
|
+
import { existsSync as existsSync12, readFileSync as readFileSync17, writeFileSync as writeFileSync23 } from "node:fs";
|
|
63529
63661
|
import { join as join24 } from "node:path";
|
|
63530
63662
|
function dedupe(names) {
|
|
63531
63663
|
return [...new Set(names)];
|
|
@@ -63617,12 +63749,12 @@ var PLAN_FILE = "migration-plan.json";
|
|
|
63617
63749
|
var SETTLED = new Set(["done", "as-is", "upgrade", "skipped"]);
|
|
63618
63750
|
function loadPlan(dir) {
|
|
63619
63751
|
const p = join24(dir, PLAN_FILE);
|
|
63620
|
-
if (!
|
|
63752
|
+
if (!existsSync12(p))
|
|
63621
63753
|
return null;
|
|
63622
|
-
return JSON.parse(
|
|
63754
|
+
return JSON.parse(readFileSync17(p, "utf8"));
|
|
63623
63755
|
}
|
|
63624
63756
|
function savePlan(dir, plan) {
|
|
63625
|
-
|
|
63757
|
+
writeFileSync23(join24(dir, PLAN_FILE), `${JSON.stringify(plan, null, 2)}
|
|
63626
63758
|
`, "utf8");
|
|
63627
63759
|
}
|
|
63628
63760
|
function setComponentStatus(plan, name, status) {
|
|
@@ -63801,7 +63933,7 @@ function syntheticSourceComponents(plan) {
|
|
|
63801
63933
|
}
|
|
63802
63934
|
|
|
63803
63935
|
// src/migrate/sources/deco-fresh.ts
|
|
63804
|
-
import { existsSync as
|
|
63936
|
+
import { existsSync as existsSync13, readFileSync as readFileSync18 } from "node:fs";
|
|
63805
63937
|
import { join as join26 } from "node:path";
|
|
63806
63938
|
|
|
63807
63939
|
// src/migrate/sources/walk.ts
|
|
@@ -63847,13 +63979,13 @@ function walkFiles(dir, exts) {
|
|
|
63847
63979
|
function isDecoFresh(repoDir) {
|
|
63848
63980
|
const denoJson = join26(repoDir, "deno.json");
|
|
63849
63981
|
const denoJsonc = join26(repoDir, "deno.jsonc");
|
|
63850
|
-
const file =
|
|
63982
|
+
const file = existsSync13(denoJson) ? denoJson : existsSync13(denoJsonc) ? denoJsonc : null;
|
|
63851
63983
|
if (!file)
|
|
63852
63984
|
return false;
|
|
63853
|
-
if (!
|
|
63985
|
+
if (!existsSync13(join26(repoDir, "fresh.gen.ts")))
|
|
63854
63986
|
return false;
|
|
63855
63987
|
try {
|
|
63856
|
-
return
|
|
63988
|
+
return readFileSync18(file, "utf8").includes("@deco/deco");
|
|
63857
63989
|
} catch {
|
|
63858
63990
|
return false;
|
|
63859
63991
|
}
|
|
@@ -63862,7 +63994,7 @@ var GLOBAL_HINT = /\b(header|footer|navbar|menu|topbar)\b/i;
|
|
|
63862
63994
|
function inventory(repoDir) {
|
|
63863
63995
|
const components = [];
|
|
63864
63996
|
const sectionsDir = join26(repoDir, "sections");
|
|
63865
|
-
if (
|
|
63997
|
+
if (existsSync13(sectionsDir)) {
|
|
63866
63998
|
for (const rel of walkFiles(sectionsDir, [".tsx"])) {
|
|
63867
63999
|
const key2 = rel.replace(/\.tsx$/, "");
|
|
63868
64000
|
components.push({
|
|
@@ -63876,9 +64008,9 @@ function inventory(repoDir) {
|
|
|
63876
64008
|
const notes = [
|
|
63877
64009
|
"Source: Deco on Fresh/Deno (Preact + signals, JSX). Sections are the CMS unit."
|
|
63878
64010
|
];
|
|
63879
|
-
if (
|
|
64011
|
+
if (existsSync13(join26(repoDir, "islands")))
|
|
63880
64012
|
notes.push("Has islands/ — client-interactive components.");
|
|
63881
|
-
if (
|
|
64013
|
+
if (existsSync13(join26(repoDir, "loaders")))
|
|
63882
64014
|
notes.push("Has loaders/ — server data functions to port.");
|
|
63883
64015
|
return { components, notes };
|
|
63884
64016
|
}
|
|
@@ -63918,14 +64050,14 @@ captured HTML/computed-styles as the source of truth for structure and styling.`
|
|
|
63918
64050
|
};
|
|
63919
64051
|
|
|
63920
64052
|
// src/migrate/sources/vtex-io.ts
|
|
63921
|
-
import { existsSync as
|
|
64053
|
+
import { existsSync as existsSync14, readFileSync as readFileSync19 } from "node:fs";
|
|
63922
64054
|
import { join as join27 } from "node:path";
|
|
63923
64055
|
function readManifest(repoDir) {
|
|
63924
64056
|
const file = join27(repoDir, "manifest.json");
|
|
63925
|
-
if (!
|
|
64057
|
+
if (!existsSync14(file))
|
|
63926
64058
|
return null;
|
|
63927
64059
|
try {
|
|
63928
|
-
return JSON.parse(
|
|
64060
|
+
return JSON.parse(readFileSync19(file, "utf8"));
|
|
63929
64061
|
} catch {
|
|
63930
64062
|
return null;
|
|
63931
64063
|
}
|
|
@@ -63948,12 +64080,12 @@ var GLOBAL_HINT2 = /header|footer|menu|minicart|navbar/i;
|
|
|
63948
64080
|
function inventory2(repoDir) {
|
|
63949
64081
|
const blocksDir = join27(repoDir, "store", "blocks");
|
|
63950
64082
|
const seen = new Map;
|
|
63951
|
-
if (
|
|
64083
|
+
if (existsSync14(blocksDir)) {
|
|
63952
64084
|
for (const rel of walkFiles(blocksDir, [".json", ".jsonc"])) {
|
|
63953
64085
|
const abs = join27(blocksDir, rel);
|
|
63954
64086
|
let parsed;
|
|
63955
64087
|
try {
|
|
63956
|
-
parsed = JSON.parse(stripJsonc(
|
|
64088
|
+
parsed = JSON.parse(stripJsonc(readFileSync19(abs, "utf8")));
|
|
63957
64089
|
} catch {
|
|
63958
64090
|
continue;
|
|
63959
64091
|
}
|
|
@@ -64520,7 +64652,7 @@ async function migrateCommand(opts) {
|
|
|
64520
64652
|
source = s;
|
|
64521
64653
|
}
|
|
64522
64654
|
if (opts.source) {
|
|
64523
|
-
if (!
|
|
64655
|
+
if (!existsSync15(opts.source)) {
|
|
64524
64656
|
console.error(chalk17.red(`--source não encontrado: ${opts.source}`));
|
|
64525
64657
|
return 2;
|
|
64526
64658
|
}
|
|
@@ -64530,13 +64662,13 @@ async function migrateCommand(opts) {
|
|
|
64530
64662
|
console.log(chalk17.dim(` source: ${source.label} — ${sourceInventory.components.length} component(s) from code`));
|
|
64531
64663
|
}
|
|
64532
64664
|
const host = safeHost6(opts.url);
|
|
64533
|
-
const runDir =
|
|
64665
|
+
const runDir = resolve4(opts.outDir, host);
|
|
64534
64666
|
mkdirSync16(runDir, { recursive: true });
|
|
64535
64667
|
const browser = await launchBrowser({ headless: true });
|
|
64536
64668
|
try {
|
|
64537
|
-
const themePath =
|
|
64538
|
-
const assetsPath =
|
|
64539
|
-
const blocksPath =
|
|
64669
|
+
const themePath = resolve4(runDir, "theme.json");
|
|
64670
|
+
const assetsPath = resolve4(runDir, "assets.json");
|
|
64671
|
+
const blocksPath = resolve4(runDir, "blocks.json");
|
|
64540
64672
|
let theme;
|
|
64541
64673
|
let platform;
|
|
64542
64674
|
let stack = null;
|
|
@@ -64544,7 +64676,7 @@ async function migrateCommand(opts) {
|
|
|
64544
64676
|
let screenshots;
|
|
64545
64677
|
let vtexBlocks = null;
|
|
64546
64678
|
let contentMap = {};
|
|
64547
|
-
if (!opts.refresh &&
|
|
64679
|
+
if (!opts.refresh && existsSync15(themePath) && existsSync15(assetsPath)) {
|
|
64548
64680
|
theme = readJson(themePath);
|
|
64549
64681
|
const meta = readJson(assetsPath);
|
|
64550
64682
|
platform = meta.platform;
|
|
@@ -64554,7 +64686,7 @@ async function migrateCommand(opts) {
|
|
|
64554
64686
|
console.log(chalk17.dim(" phase 1 theme+assets: cached"));
|
|
64555
64687
|
} else {
|
|
64556
64688
|
console.log(chalk17.dim(` phase 1 theme+assets: scraping (${viewports.join(", ")})…`));
|
|
64557
|
-
mkdirSync16(
|
|
64689
|
+
mkdirSync16(resolve4(runDir, "screenshots"), { recursive: true });
|
|
64558
64690
|
const samples = [];
|
|
64559
64691
|
screenshots = [];
|
|
64560
64692
|
let platformSeen = null;
|
|
@@ -64580,7 +64712,7 @@ async function migrateCommand(opts) {
|
|
|
64580
64712
|
sleep2(5000)
|
|
64581
64713
|
]);
|
|
64582
64714
|
samples.push(await scrapeThemeSamples(page));
|
|
64583
|
-
const shot =
|
|
64715
|
+
const shot = resolve4(runDir, "screenshots", `${vp}.png`);
|
|
64584
64716
|
await page.screenshot({ path: shot, fullPage: true, animations: "disabled", timeout: 15000 }).then(() => screenshots.push({ viewport: vp, path: `screenshots/${vp}.png` })).catch(() => {
|
|
64585
64717
|
return;
|
|
64586
64718
|
});
|
|
@@ -64594,7 +64726,7 @@ async function migrateCommand(opts) {
|
|
|
64594
64726
|
const fetchBytes = async (url) => await browserFetchBytes(page, url) ?? await nodeFetchBytes(url);
|
|
64595
64727
|
assetsResolved = await downloadSiteAssets(rawAssets, runDir, fetchBytes);
|
|
64596
64728
|
if (rawAssets.logo?.type === "svg" || rawAssets.logo && !assetsResolved.logo) {
|
|
64597
|
-
const logoPng =
|
|
64729
|
+
const logoPng = resolve4(runDir, "assets", "logo.png");
|
|
64598
64730
|
const ok = await page.locator("[data-parity-logo]").first().screenshot({ path: logoPng, timeout: 8000 }).then(() => true).catch(() => false);
|
|
64599
64731
|
if (ok) {
|
|
64600
64732
|
assetsResolved.logo = "assets/logo.png";
|
|
@@ -64614,14 +64746,14 @@ async function migrateCommand(opts) {
|
|
|
64614
64746
|
theme = aggregateTheme(mergeRawThemeSamples(samples));
|
|
64615
64747
|
platform = platformSeen ?? "custom";
|
|
64616
64748
|
assets = assetsResolved;
|
|
64617
|
-
|
|
64749
|
+
writeFileSync24(themePath, `${JSON.stringify(theme, null, 2)}
|
|
64618
64750
|
`, "utf8");
|
|
64619
|
-
|
|
64751
|
+
writeFileSync24(assetsPath, `${JSON.stringify({ platform, stack, assets, screenshots }, null, 2)}
|
|
64620
64752
|
`, "utf8");
|
|
64621
64753
|
}
|
|
64622
|
-
const sitemapPath =
|
|
64754
|
+
const sitemapPath = resolve4(runDir, "sitemap.json");
|
|
64623
64755
|
let resolvedPages;
|
|
64624
|
-
if (!opts.refresh &&
|
|
64756
|
+
if (!opts.refresh && existsSync15(sitemapPath)) {
|
|
64625
64757
|
resolvedPages = readJson(sitemapPath).pages;
|
|
64626
64758
|
console.log(chalk17.dim(` phase 2 sitemap: cached (${resolvedPages.length} page(s))`));
|
|
64627
64759
|
} else {
|
|
@@ -64655,17 +64787,17 @@ async function migrateCommand(opts) {
|
|
|
64655
64787
|
}, {});
|
|
64656
64788
|
console.log(chalk17.dim(` phase 2 sitemap: +${sampled.length} sampled (${Object.entries(byKind).map(([k, n]) => `${n} ${k}`).join(", ")})`));
|
|
64657
64789
|
}
|
|
64658
|
-
|
|
64790
|
+
writeFileSync24(sitemapPath, `${JSON.stringify({ pages: resolvedPages, sitemapUrls: classified }, null, 2)}
|
|
64659
64791
|
`, "utf8");
|
|
64660
64792
|
}
|
|
64661
64793
|
if (resolvedPages.length === 0) {
|
|
64662
64794
|
console.error(chalk17.red("nenhuma página resolvida a partir de --pages"));
|
|
64663
64795
|
return 1;
|
|
64664
64796
|
}
|
|
64665
|
-
const capturePath =
|
|
64797
|
+
const capturePath = resolve4(runDir, "capture.json");
|
|
64666
64798
|
let pages;
|
|
64667
64799
|
let components;
|
|
64668
|
-
if (!opts.refresh &&
|
|
64800
|
+
if (!opts.refresh && existsSync15(capturePath)) {
|
|
64669
64801
|
const cached = readJson(capturePath);
|
|
64670
64802
|
pages = cached.pages;
|
|
64671
64803
|
components = cached.components;
|
|
@@ -64681,14 +64813,14 @@ async function migrateCommand(opts) {
|
|
|
64681
64813
|
baseUrl: opts.url,
|
|
64682
64814
|
vtexScrape: opts.source ? source.kind === "vtex-io" : true
|
|
64683
64815
|
}));
|
|
64684
|
-
|
|
64816
|
+
writeFileSync24(capturePath, `${JSON.stringify({ pages, components, vtexBlocks, contentMap }, null, 2)}
|
|
64685
64817
|
`, "utf8");
|
|
64686
64818
|
}
|
|
64687
64819
|
if (vtexBlocks)
|
|
64688
|
-
|
|
64820
|
+
writeFileSync24(blocksPath, `${JSON.stringify(vtexBlocks, null, 2)}
|
|
64689
64821
|
`, "utf8");
|
|
64690
64822
|
if (Object.keys(contentMap).length)
|
|
64691
|
-
|
|
64823
|
+
writeFileSync24(resolve4(runDir, "content-assets.json"), `${JSON.stringify(contentMap, null, 2)}
|
|
64692
64824
|
`, "utf8");
|
|
64693
64825
|
const bundle = {
|
|
64694
64826
|
url: opts.url,
|
|
@@ -64725,17 +64857,17 @@ async function migrateCommand(opts) {
|
|
|
64725
64857
|
if (format === "md" || format === "both") {
|
|
64726
64858
|
await markdownExporter2.export(bundle, runDir);
|
|
64727
64859
|
await htmlExporter.export(bundle, runDir);
|
|
64728
|
-
|
|
64860
|
+
writeFileSync24(resolve4(runDir, "MIGRATION_PROMPT.md"), buildMigrationPrompt(bundle, playbook, {
|
|
64729
64861
|
playbook: source.playbook,
|
|
64730
64862
|
notes: sourceInventory.notes
|
|
64731
64863
|
}), "utf8");
|
|
64732
64864
|
}
|
|
64733
64865
|
const targetTheme = opts.target ? getTargetTheme(opts.target) : null;
|
|
64734
64866
|
if (targetTheme) {
|
|
64735
|
-
|
|
64867
|
+
writeFileSync24(resolve4(runDir, targetTheme.filename), targetTheme.build(theme), "utf8");
|
|
64736
64868
|
}
|
|
64737
64869
|
if (bundle.vtex) {
|
|
64738
|
-
|
|
64870
|
+
writeFileSync24(resolve4(runDir, "component-map.json"), `${JSON.stringify(bundle.vtex.map, null, 2)}
|
|
64739
64871
|
`, "utf8");
|
|
64740
64872
|
}
|
|
64741
64873
|
if (opts.json) {
|
|
@@ -64744,7 +64876,7 @@ async function migrateCommand(opts) {
|
|
|
64744
64876
|
}
|
|
64745
64877
|
printResults4(runDir, bundle);
|
|
64746
64878
|
if (opts.open && format !== "json") {
|
|
64747
|
-
await open(
|
|
64879
|
+
await open(resolve4(runDir, "report.html")).catch(() => {
|
|
64748
64880
|
return;
|
|
64749
64881
|
});
|
|
64750
64882
|
}
|
|
@@ -64799,7 +64931,7 @@ async function capturePages(browser, viewport, resolvedPages, theme, cfg) {
|
|
|
64799
64931
|
if (global)
|
|
64800
64932
|
seenGlobalRoles.add(component.role);
|
|
64801
64933
|
const idx = components.length + 1;
|
|
64802
|
-
const componentDir =
|
|
64934
|
+
const componentDir = resolve4(cfg.runDir, "components", componentDirName(component.role, idx));
|
|
64803
64935
|
const extracted = await extractComponent(page, component, {
|
|
64804
64936
|
outDir: componentDir,
|
|
64805
64937
|
index: idx,
|
|
@@ -65013,7 +65145,7 @@ function printResults4(runDir, bundle) {
|
|
|
65013
65145
|
}
|
|
65014
65146
|
function readJson(path) {
|
|
65015
65147
|
try {
|
|
65016
|
-
return JSON.parse(
|
|
65148
|
+
return JSON.parse(readFileSync20(path, "utf8"));
|
|
65017
65149
|
} catch {
|
|
65018
65150
|
return null;
|
|
65019
65151
|
}
|
|
@@ -65264,18 +65396,18 @@ ${chalk18.bold("Pages")} (${pg.total}): ` + `${chalk18.green(`${pg.byStatus.done
|
|
|
65264
65396
|
}
|
|
65265
65397
|
|
|
65266
65398
|
// src/commands/pr.ts
|
|
65267
|
-
import { existsSync as
|
|
65399
|
+
import { existsSync as existsSync19, readFileSync as readFileSync23, writeFileSync as writeFileSync25 } from "node:fs";
|
|
65268
65400
|
import { join as join30 } from "node:path";
|
|
65269
65401
|
import chalk21 from "chalk";
|
|
65270
65402
|
|
|
65271
65403
|
// src/commands/run.ts
|
|
65272
|
-
import { existsSync as
|
|
65404
|
+
import { existsSync as existsSync18, readFileSync as readFileSync22, unlinkSync as unlinkSync3 } from "node:fs";
|
|
65273
65405
|
import { join as join29 } from "node:path";
|
|
65274
65406
|
import chalk20 from "chalk";
|
|
65275
65407
|
import ora7 from "ora";
|
|
65276
65408
|
|
|
65277
65409
|
// src/engine/interactive-module-prompt.ts
|
|
65278
|
-
import { createInterface } from "node:readline";
|
|
65410
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
65279
65411
|
var ALL_MODULE_NAMES2 = Object.keys(MODULES);
|
|
65280
65412
|
async function promptForModuleSelection() {
|
|
65281
65413
|
console.log("");
|
|
@@ -65286,7 +65418,7 @@ async function promptForModuleSelection() {
|
|
|
65286
65418
|
console.log(` [x] ${i + 1}. ${name.padEnd(8)} — ${def.description}`);
|
|
65287
65419
|
});
|
|
65288
65420
|
console.log("");
|
|
65289
|
-
const answer = await
|
|
65421
|
+
const answer = await readLine2(" Type numbers to UNCHECK (comma-separated), or press Enter to run all: ");
|
|
65290
65422
|
if (answer === null) {
|
|
65291
65423
|
console.log(" (aborted — running all modules)");
|
|
65292
65424
|
return ALL_MODULE_NAMES2;
|
|
@@ -65303,9 +65435,9 @@ async function promptForModuleSelection() {
|
|
|
65303
65435
|
console.log(` running: ${selected.join(", ")}`);
|
|
65304
65436
|
return selected;
|
|
65305
65437
|
}
|
|
65306
|
-
function
|
|
65438
|
+
function readLine2(prompt) {
|
|
65307
65439
|
return new Promise((resolveLine) => {
|
|
65308
|
-
const rl =
|
|
65440
|
+
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
65309
65441
|
rl.question(prompt, (ans) => {
|
|
65310
65442
|
rl.close();
|
|
65311
65443
|
resolveLine(ans);
|
|
@@ -65317,22 +65449,6 @@ function readLine(prompt) {
|
|
|
65317
65449
|
});
|
|
65318
65450
|
}
|
|
65319
65451
|
|
|
65320
|
-
// src/engine/interactive-selector-prompt.ts
|
|
65321
|
-
init_client();
|
|
65322
|
-
var forceDisabled = false;
|
|
65323
|
-
function disableInteractive() {
|
|
65324
|
-
forceDisabled = true;
|
|
65325
|
-
}
|
|
65326
|
-
function isInteractiveMode() {
|
|
65327
|
-
if (forceDisabled)
|
|
65328
|
-
return false;
|
|
65329
|
-
if (!process.stdout.isTTY || !process.stdin.isTTY)
|
|
65330
|
-
return false;
|
|
65331
|
-
if (isLlmAvailable())
|
|
65332
|
-
return false;
|
|
65333
|
-
return true;
|
|
65334
|
-
}
|
|
65335
|
-
|
|
65336
65452
|
// src/llm/aggregate-issues.ts
|
|
65337
65453
|
init_client();
|
|
65338
65454
|
var REPORT_ISSUES_TOOL = {
|
|
@@ -65824,13 +65940,13 @@ function formatMs(ms) {
|
|
|
65824
65940
|
}
|
|
65825
65941
|
|
|
65826
65942
|
// src/commands/serve.ts
|
|
65827
|
-
import { existsSync as
|
|
65943
|
+
import { existsSync as existsSync17 } from "node:fs";
|
|
65828
65944
|
import chalk19 from "chalk";
|
|
65829
65945
|
|
|
65830
65946
|
// src/server/proxy-server.ts
|
|
65831
|
-
import { existsSync as
|
|
65947
|
+
import { existsSync as existsSync16, readFileSync as readFileSync21, statSync } from "node:fs";
|
|
65832
65948
|
import { createServer } from "node:http";
|
|
65833
|
-
import { extname, join as join28, normalize as normalize3, resolve as
|
|
65949
|
+
import { extname, join as join28, normalize as normalize3, resolve as resolve5, sep } from "node:path";
|
|
65834
65950
|
var MIME3 = {
|
|
65835
65951
|
".html": "text/html; charset=utf-8",
|
|
65836
65952
|
".css": "text/css; charset=utf-8",
|
|
@@ -65866,8 +65982,8 @@ var STRIPPED_REQUEST_HEADERS = new Set([
|
|
|
65866
65982
|
"origin"
|
|
65867
65983
|
]);
|
|
65868
65984
|
async function startProxyServer(runDir, opts = {}) {
|
|
65869
|
-
const absRunDir =
|
|
65870
|
-
if (!
|
|
65985
|
+
const absRunDir = resolve5(runDir);
|
|
65986
|
+
if (!existsSync16(absRunDir)) {
|
|
65871
65987
|
throw new Error(`Run directory not found: ${runDir}`);
|
|
65872
65988
|
}
|
|
65873
65989
|
const server = createServer((req, res) => {
|
|
@@ -65878,9 +65994,9 @@ async function startProxyServer(runDir, opts = {}) {
|
|
|
65878
65994
|
} catch {}
|
|
65879
65995
|
});
|
|
65880
65996
|
});
|
|
65881
|
-
await new Promise((
|
|
65997
|
+
await new Promise((resolve6, reject) => {
|
|
65882
65998
|
server.once("error", reject);
|
|
65883
|
-
server.listen(opts.port ?? 0, opts.host ?? "127.0.0.1", () =>
|
|
65999
|
+
server.listen(opts.port ?? 0, opts.host ?? "127.0.0.1", () => resolve6());
|
|
65884
66000
|
});
|
|
65885
66001
|
const addr = server.address();
|
|
65886
66002
|
const port = typeof addr === "object" && addr ? addr.port : 0;
|
|
@@ -65888,13 +66004,13 @@ async function startProxyServer(runDir, opts = {}) {
|
|
|
65888
66004
|
return {
|
|
65889
66005
|
port,
|
|
65890
66006
|
url: `http://${host}:${port}/`,
|
|
65891
|
-
close: () => new Promise((
|
|
66007
|
+
close: () => new Promise((resolve6) => {
|
|
65892
66008
|
try {
|
|
65893
66009
|
server.closeAllConnections?.();
|
|
65894
66010
|
server.closeIdleConnections?.();
|
|
65895
66011
|
} catch {}
|
|
65896
|
-
server.close(() =>
|
|
65897
|
-
setTimeout(() =>
|
|
66012
|
+
server.close(() => resolve6());
|
|
66013
|
+
setTimeout(() => resolve6(), 1000);
|
|
65898
66014
|
})
|
|
65899
66015
|
};
|
|
65900
66016
|
}
|
|
@@ -65925,12 +66041,12 @@ async function handleRequest(req, res, runDir) {
|
|
|
65925
66041
|
}
|
|
65926
66042
|
function serveReportHtml(res, runDir) {
|
|
65927
66043
|
const filePath = join28(runDir, "report.html");
|
|
65928
|
-
if (!
|
|
66044
|
+
if (!existsSync16(filePath)) {
|
|
65929
66045
|
res.statusCode = 404;
|
|
65930
66046
|
res.end("report.html not found");
|
|
65931
66047
|
return;
|
|
65932
66048
|
}
|
|
65933
|
-
const html3 =
|
|
66049
|
+
const html3 = readFileSync21(filePath, "utf8");
|
|
65934
66050
|
const inject = `<script>window.__parity_proxy = "/proxy?url=";</script>`;
|
|
65935
66051
|
const out = html3.includes("</head>") ? html3.replace("</head>", `${inject}</head>`) : `${inject}${html3}`;
|
|
65936
66052
|
res.statusCode = 200;
|
|
@@ -65940,13 +66056,13 @@ function serveReportHtml(res, runDir) {
|
|
|
65940
66056
|
}
|
|
65941
66057
|
function serveStatic(res, runDir, path) {
|
|
65942
66058
|
const safePath3 = normalize3(path).replace(/^[/\\]+/, "");
|
|
65943
|
-
const filePath =
|
|
66059
|
+
const filePath = resolve5(runDir, safePath3);
|
|
65944
66060
|
if (!filePath.startsWith(runDir + sep) && filePath !== runDir) {
|
|
65945
66061
|
res.statusCode = 403;
|
|
65946
66062
|
res.end("forbidden");
|
|
65947
66063
|
return;
|
|
65948
66064
|
}
|
|
65949
|
-
if (!
|
|
66065
|
+
if (!existsSync16(filePath)) {
|
|
65950
66066
|
res.statusCode = 404;
|
|
65951
66067
|
res.end("not found");
|
|
65952
66068
|
return;
|
|
@@ -65961,7 +66077,7 @@ function serveStatic(res, runDir, path) {
|
|
|
65961
66077
|
res.statusCode = 200;
|
|
65962
66078
|
res.setHeader("content-type", MIME3[ext] ?? "application/octet-stream");
|
|
65963
66079
|
res.setHeader("cache-control", "no-store");
|
|
65964
|
-
res.end(
|
|
66080
|
+
res.end(readFileSync21(filePath));
|
|
65965
66081
|
}
|
|
65966
66082
|
async function proxyRequest(req, res, targetUrl, opts = {}) {
|
|
65967
66083
|
let target;
|
|
@@ -66100,11 +66216,11 @@ async function serveRunAndBlock(runDir, opts = {}) {
|
|
|
66100
66216
|
}
|
|
66101
66217
|
async function serveCommand(runId, opts) {
|
|
66102
66218
|
const paths = getRunPaths(opts.output, runId);
|
|
66103
|
-
if (!
|
|
66219
|
+
if (!existsSync17(paths.runDir)) {
|
|
66104
66220
|
console.error(chalk19.red(`✖ Run não encontrado: ${runId} (em ${opts.output})`));
|
|
66105
66221
|
return 1;
|
|
66106
66222
|
}
|
|
66107
|
-
if (!
|
|
66223
|
+
if (!existsSync17(paths.reportHtml)) {
|
|
66108
66224
|
console.error(chalk19.red(`✖ report.html não existe em ${paths.runDir}`));
|
|
66109
66225
|
return 1;
|
|
66110
66226
|
}
|
|
@@ -66352,7 +66468,7 @@ async function runCommand(rawOpts) {
|
|
|
66352
66468
|
const ignore = loadParityIgnore();
|
|
66353
66469
|
if (opts.clearCache) {
|
|
66354
66470
|
const cacheFile = join29(opts.output, "cache", "verdicts.json");
|
|
66355
|
-
if (
|
|
66471
|
+
if (existsSync18(cacheFile)) {
|
|
66356
66472
|
try {
|
|
66357
66473
|
unlinkSync3(cacheFile);
|
|
66358
66474
|
console.log(chalk20.dim(` cache wiped: ${cacheFile}`));
|
|
@@ -66469,7 +66585,7 @@ async function runCommand(rawOpts) {
|
|
|
66469
66585
|
b.close().catch(() => {
|
|
66470
66586
|
return;
|
|
66471
66587
|
}),
|
|
66472
|
-
new Promise((
|
|
66588
|
+
new Promise((resolve6) => setTimeout(resolve6, capMs))
|
|
66473
66589
|
]);
|
|
66474
66590
|
};
|
|
66475
66591
|
const shutdown = async (reason) => {
|
|
@@ -66745,8 +66861,8 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
66745
66861
|
noNetworkIdle: targetIsDevServer,
|
|
66746
66862
|
runs: vitalsRuns
|
|
66747
66863
|
}),
|
|
66748
|
-
new Promise((
|
|
66749
|
-
const t = setTimeout(() =>
|
|
66864
|
+
new Promise((resolve6) => {
|
|
66865
|
+
const t = setTimeout(() => resolve6(null), PER_TASK_WALLCLOCK_MS);
|
|
66750
66866
|
t.unref?.();
|
|
66751
66867
|
})
|
|
66752
66868
|
]);
|
|
@@ -67071,10 +67187,10 @@ function parsePagePair(entry) {
|
|
|
67071
67187
|
}
|
|
67072
67188
|
function resolveExplicitPages(pagesFile, pagesList) {
|
|
67073
67189
|
if (pagesFile) {
|
|
67074
|
-
if (!
|
|
67190
|
+
if (!existsSync18(pagesFile)) {
|
|
67075
67191
|
throw new Error(`--pages-file não encontrado: ${pagesFile}`);
|
|
67076
67192
|
}
|
|
67077
|
-
const raw =
|
|
67193
|
+
const raw = readFileSync22(pagesFile, "utf-8");
|
|
67078
67194
|
const lines = raw.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#"));
|
|
67079
67195
|
return lines.map(parsePagePair);
|
|
67080
67196
|
}
|
|
@@ -67301,14 +67417,14 @@ async function prCommand(opts) {
|
|
|
67301
67417
|
}
|
|
67302
67418
|
const latest = runs[0];
|
|
67303
67419
|
const reportJsonPath = join30(opts.output, "runs", latest.id, "report.json");
|
|
67304
|
-
if (!
|
|
67420
|
+
if (!existsSync19(reportJsonPath)) {
|
|
67305
67421
|
console.error(chalk21.red(`report.json not found at ${reportJsonPath}`));
|
|
67306
67422
|
return runCode || 1;
|
|
67307
67423
|
}
|
|
67308
|
-
const run = JSON.parse(
|
|
67424
|
+
const run = JSON.parse(readFileSync23(reportJsonPath, "utf8"));
|
|
67309
67425
|
const markdown = buildPrComment(run, opts);
|
|
67310
67426
|
if (opts.out) {
|
|
67311
|
-
|
|
67427
|
+
writeFileSync25(opts.out, markdown, "utf8");
|
|
67312
67428
|
console.log(chalk21.dim(` wrote PR comment: ${opts.out}`));
|
|
67313
67429
|
} else {
|
|
67314
67430
|
process.stdout.write(`
|
|
@@ -67317,7 +67433,7 @@ ${markdown}
|
|
|
67317
67433
|
}
|
|
67318
67434
|
if (opts.github && process.env.GITHUB_STEP_SUMMARY) {
|
|
67319
67435
|
try {
|
|
67320
|
-
|
|
67436
|
+
writeFileSync25(process.env.GITHUB_STEP_SUMMARY, markdown, { flag: "a" });
|
|
67321
67437
|
} catch (err) {
|
|
67322
67438
|
console.error(chalk21.yellow(`failed to write GITHUB_STEP_SUMMARY: ${err.message}`));
|
|
67323
67439
|
}
|
|
@@ -67378,7 +67494,7 @@ function buildPrComment(run, opts) {
|
|
|
67378
67494
|
}
|
|
67379
67495
|
|
|
67380
67496
|
// src/commands/prompt.ts
|
|
67381
|
-
import { existsSync as
|
|
67497
|
+
import { existsSync as existsSync20, writeFileSync as writeFileSync26 } from "node:fs";
|
|
67382
67498
|
import chalk22 from "chalk";
|
|
67383
67499
|
function promptCommand(runId, opts) {
|
|
67384
67500
|
let run;
|
|
@@ -67393,9 +67509,9 @@ function promptCommand(runId, opts) {
|
|
|
67393
67509
|
limit: opts.limit
|
|
67394
67510
|
});
|
|
67395
67511
|
if (opts.out) {
|
|
67396
|
-
|
|
67512
|
+
writeFileSync26(opts.out, md, "utf8");
|
|
67397
67513
|
console.log(chalk22.green(`✔ prompt salvo em ${opts.out}`));
|
|
67398
|
-
if (
|
|
67514
|
+
if (existsSync20(opts.out)) {
|
|
67399
67515
|
const sizeKb = (md.length / 1024).toFixed(1);
|
|
67400
67516
|
console.log(chalk22.dim(` ${md.length} chars (${sizeKb} KB)`));
|
|
67401
67517
|
}
|
|
@@ -67406,7 +67522,7 @@ function promptCommand(runId, opts) {
|
|
|
67406
67522
|
}
|
|
67407
67523
|
|
|
67408
67524
|
// src/commands/report.ts
|
|
67409
|
-
import { existsSync as
|
|
67525
|
+
import { existsSync as existsSync21, readFileSync as readFileSync24, writeFileSync as writeFileSync27 } from "node:fs";
|
|
67410
67526
|
import { join as join31 } from "node:path";
|
|
67411
67527
|
import chalk23 from "chalk";
|
|
67412
67528
|
import open2 from "open";
|
|
@@ -67988,7 +68104,7 @@ async function reportCommand(runId, opts) {
|
|
|
67988
68104
|
}
|
|
67989
68105
|
const html3 = renderDeckHtml(buildDeckModel(run), opts.lang ?? "en");
|
|
67990
68106
|
const dest = opts.out ?? join31(paths.runDir, "deck.html");
|
|
67991
|
-
|
|
68107
|
+
writeFileSync27(dest, html3, "utf8");
|
|
67992
68108
|
console.log(`${chalk23.green("✓")} deck → ${dest}`);
|
|
67993
68109
|
if (opts.open) {
|
|
67994
68110
|
await open2(dest).catch((err) => {
|
|
@@ -68014,11 +68130,11 @@ async function reportCommand(runId, opts) {
|
|
|
68014
68130
|
return 1;
|
|
68015
68131
|
}
|
|
68016
68132
|
}
|
|
68017
|
-
if (!
|
|
68133
|
+
if (!existsSync21(paths.reportHtml)) {
|
|
68018
68134
|
console.error(chalk23.red(`report.html not found at ${paths.reportHtml}`));
|
|
68019
68135
|
return 1;
|
|
68020
68136
|
}
|
|
68021
|
-
const html3 =
|
|
68137
|
+
const html3 = readFileSync24(paths.reportHtml, "utf8");
|
|
68022
68138
|
const slice2 = extractReportSection({ kind: "html", section: opts.section, html: html3 });
|
|
68023
68139
|
if (slice2 === null) {
|
|
68024
68140
|
console.error(chalk23.red(`section "${opts.section}" not present in this report`));
|
|
@@ -68035,7 +68151,7 @@ async function reportCommand(runId, opts) {
|
|
|
68035
68151
|
}
|
|
68036
68152
|
|
|
68037
68153
|
// src/commands/vitals.ts
|
|
68038
|
-
import { existsSync as
|
|
68154
|
+
import { existsSync as existsSync22, readFileSync as readFileSync25, writeFileSync as writeFileSync28 } from "node:fs";
|
|
68039
68155
|
import { availableParallelism } from "node:os";
|
|
68040
68156
|
import { join as join32 } from "node:path";
|
|
68041
68157
|
import chalk24 from "chalk";
|
|
@@ -68467,7 +68583,7 @@ async function vitalsCommand(opts) {
|
|
|
68467
68583
|
writeRunReportJson(paths.runDir, run);
|
|
68468
68584
|
const html3 = renderHtmlReport(run, paths.runDir);
|
|
68469
68585
|
writeRunReportHtml(paths.runDir, html3);
|
|
68470
|
-
|
|
68586
|
+
writeFileSync28(join32(paths.runDir, "vitals.json"), `${JSON.stringify({
|
|
68471
68587
|
schemaVersion: "0.1",
|
|
68472
68588
|
prodUrl: opts.prod,
|
|
68473
68589
|
candUrl: opts.cand,
|
|
@@ -68571,8 +68687,8 @@ async function discoverPagePaths2(prodUrl, opts) {
|
|
|
68571
68687
|
function parseUrlList(input) {
|
|
68572
68688
|
if (input.startsWith("file:") || input.endsWith(".txt") || input.endsWith(".list")) {
|
|
68573
68689
|
const path = input.replace(/^file:\/\//, "");
|
|
68574
|
-
if (
|
|
68575
|
-
return
|
|
68690
|
+
if (existsSync22(path)) {
|
|
68691
|
+
return readFileSync25(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
|
|
68576
68692
|
}
|
|
68577
68693
|
}
|
|
68578
68694
|
return input.split(",").map((s) => s.trim()).filter(Boolean).map((s) => s.startsWith("/") || s.startsWith("http") ? s : `/${s}`);
|
|
@@ -68602,16 +68718,16 @@ function printSummary7(vitals, cache, scores, opportunities, agentic) {
|
|
|
68602
68718
|
}
|
|
68603
68719
|
|
|
68604
68720
|
// src/util/version.ts
|
|
68605
|
-
import { readFileSync as
|
|
68606
|
-
import { dirname as dirname5, resolve as
|
|
68721
|
+
import { readFileSync as readFileSync26 } from "node:fs";
|
|
68722
|
+
import { dirname as dirname5, resolve as resolve6 } from "node:path";
|
|
68607
68723
|
import { fileURLToPath } from "node:url";
|
|
68608
68724
|
function getPackageVersion() {
|
|
68609
68725
|
try {
|
|
68610
68726
|
const here = dirname5(fileURLToPath(import.meta.url));
|
|
68611
68727
|
for (const up of ["..", "../..", "../../.."]) {
|
|
68612
68728
|
try {
|
|
68613
|
-
const pkgPath =
|
|
68614
|
-
const raw =
|
|
68729
|
+
const pkgPath = resolve6(here, up, "package.json");
|
|
68730
|
+
const raw = readFileSync26(pkgPath, "utf8");
|
|
68615
68731
|
const parsed = JSON.parse(raw);
|
|
68616
68732
|
if (parsed.name === "@decocms/parity" && typeof parsed.version === "string") {
|
|
68617
68733
|
return parsed.version;
|