@decocms/parity 0.26.10 → 0.26.12
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 +112 -14
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -67481,6 +67481,112 @@ function assessLlmsTxt(body) {
|
|
|
67481
67481
|
};
|
|
67482
67482
|
}
|
|
67483
67483
|
|
|
67484
|
+
// src/diff/lighthouse.ts
|
|
67485
|
+
var HIGH_SAVINGS_MS = 500;
|
|
67486
|
+
var MEDIUM_SAVINGS_MS = 200;
|
|
67487
|
+
function opportunitySeverity(savingsMs) {
|
|
67488
|
+
if (savingsMs >= HIGH_SAVINGS_MS)
|
|
67489
|
+
return "high";
|
|
67490
|
+
if (savingsMs >= MEDIUM_SAVINGS_MS)
|
|
67491
|
+
return "medium";
|
|
67492
|
+
return "low";
|
|
67493
|
+
}
|
|
67494
|
+
function aggregateOpportunities(pages) {
|
|
67495
|
+
const byId = new Map;
|
|
67496
|
+
for (const p of pages) {
|
|
67497
|
+
for (const o of p.lhOpportunities ?? []) {
|
|
67498
|
+
const prev2 = byId.get(o.id);
|
|
67499
|
+
if (!prev2 || o.savingsMs > prev2.savingsMs)
|
|
67500
|
+
byId.set(o.id, o);
|
|
67501
|
+
}
|
|
67502
|
+
}
|
|
67503
|
+
return [...byId.values()].sort((a, b) => b.savingsMs - a.savingsMs || b.savingsBytes - a.savingsBytes);
|
|
67504
|
+
}
|
|
67505
|
+
var REGRESSION_DELTA_MS = 200;
|
|
67506
|
+
function diffOpportunities(prodPages, candPages) {
|
|
67507
|
+
const prodById = new Map(aggregateOpportunities(prodPages).map((o) => [o.id, o]));
|
|
67508
|
+
const singleSite = prodPages.length === 0;
|
|
67509
|
+
return aggregateOpportunities(candPages).map((cand) => {
|
|
67510
|
+
const prod = prodById.get(cand.id) ?? null;
|
|
67511
|
+
const deltaMs = cand.savingsMs - (prod?.savingsMs ?? 0);
|
|
67512
|
+
return {
|
|
67513
|
+
cand,
|
|
67514
|
+
prod,
|
|
67515
|
+
deltaMs,
|
|
67516
|
+
regression: singleSite ? false : !prod || deltaMs >= REGRESSION_DELTA_MS
|
|
67517
|
+
};
|
|
67518
|
+
});
|
|
67519
|
+
}
|
|
67520
|
+
|
|
67521
|
+
// src/checks/lighthouse-opportunities.ts
|
|
67522
|
+
function lighthouseOpportunities(ctx) {
|
|
67523
|
+
const start = Date.now();
|
|
67524
|
+
const name = "lighthouse-opportunities";
|
|
67525
|
+
const hasLighthouse = ctx.candPages.some((p) => p.lhOpportunities !== undefined);
|
|
67526
|
+
if (!hasLighthouse) {
|
|
67527
|
+
return {
|
|
67528
|
+
name,
|
|
67529
|
+
status: "skipped",
|
|
67530
|
+
severity: "medium",
|
|
67531
|
+
durationMs: Date.now() - start,
|
|
67532
|
+
summary: "Sem dados de Lighthouse em cand (capturados por `parity vitals`)",
|
|
67533
|
+
issues: []
|
|
67534
|
+
};
|
|
67535
|
+
}
|
|
67536
|
+
const deltas = diffOpportunities(ctx.prodPages, ctx.candPages);
|
|
67537
|
+
const reportable = deltas.filter((d) => opportunitySeverity(d.cand.savingsMs) !== "low");
|
|
67538
|
+
const issues = reportable.map((d) => {
|
|
67539
|
+
const sev = opportunitySeverity(d.cand.savingsMs);
|
|
67540
|
+
return {
|
|
67541
|
+
id: `lh:${d.cand.id}`,
|
|
67542
|
+
severity: d.regression && sev === "medium" ? "high" : sev,
|
|
67543
|
+
category: "performance",
|
|
67544
|
+
check: name,
|
|
67545
|
+
summary: `${d.cand.title} — ${fmtMs2(d.cand.savingsMs)} recuperáveis${d.regression ? " (regressão: prod não tem, ou tem bem menos)" : ""}`,
|
|
67546
|
+
details: buildDetails(d.cand, d.prod, d.regression)
|
|
67547
|
+
};
|
|
67548
|
+
});
|
|
67549
|
+
const dropped = deltas.length - reportable.length;
|
|
67550
|
+
const worst = reportable[0]?.cand;
|
|
67551
|
+
const summaryParts = [
|
|
67552
|
+
`${reportable.length} oportunidade(s) acima de 200ms`,
|
|
67553
|
+
reportable.filter((d) => d.regression).length > 0 ? `${reportable.filter((d) => d.regression).length} regressão(ões)` : null,
|
|
67554
|
+
worst ? `maior: ${worst.title} (${fmtMs2(worst.savingsMs)})` : null,
|
|
67555
|
+
dropped > 0 ? `${dropped} abaixo do limite, não reportada(s)` : null
|
|
67556
|
+
].filter(Boolean);
|
|
67557
|
+
return {
|
|
67558
|
+
name,
|
|
67559
|
+
status: issues.length > 0 ? "fail" : "pass",
|
|
67560
|
+
severity: "medium",
|
|
67561
|
+
durationMs: Date.now() - start,
|
|
67562
|
+
summary: summaryParts.join(", "),
|
|
67563
|
+
data: { total: deltas.length, reported: issues.length, belowThreshold: dropped },
|
|
67564
|
+
issues
|
|
67565
|
+
};
|
|
67566
|
+
}
|
|
67567
|
+
function buildDetails(cand, prod, regression) {
|
|
67568
|
+
const lines = [`audit: ${cand.id}`];
|
|
67569
|
+
if (cand.displayValue)
|
|
67570
|
+
lines.push(`cand: ${cand.displayValue}`);
|
|
67571
|
+
lines.push(`economia estimada: ${fmtMs2(cand.savingsMs)}${cand.savingsBytes > 0 ? `, ${fmtKb(cand.savingsBytes)}` : ""}`);
|
|
67572
|
+
if (prod) {
|
|
67573
|
+
lines.push(`prod: ${fmtMs2(prod.savingsMs)} na mesma audit`);
|
|
67574
|
+
} else {
|
|
67575
|
+
lines.push("prod: audit não acionada");
|
|
67576
|
+
}
|
|
67577
|
+
if (regression) {
|
|
67578
|
+
lines.push("→ introduzido (ou agravado) pela migração");
|
|
67579
|
+
}
|
|
67580
|
+
return lines.join(`
|
|
67581
|
+
`);
|
|
67582
|
+
}
|
|
67583
|
+
function fmtMs2(ms) {
|
|
67584
|
+
return ms >= 1000 ? `${(ms / 1000).toFixed(1)}s` : `${ms}ms`;
|
|
67585
|
+
}
|
|
67586
|
+
function fmtKb(bytes) {
|
|
67587
|
+
return `${(bytes / 1024).toFixed(0)} KB`;
|
|
67588
|
+
}
|
|
67589
|
+
|
|
67484
67590
|
// src/checks/lighthouse-scores.ts
|
|
67485
67591
|
var CATEGORIES = [
|
|
67486
67592
|
{ key: "performance", label: "Performance" },
|
|
@@ -67640,8 +67746,9 @@ async function vitalsCommand(opts) {
|
|
|
67640
67746
|
const vitalsResult = webVitalsMobile(checkCtx);
|
|
67641
67747
|
const cacheResult = cacheCoverage(checkCtx);
|
|
67642
67748
|
const scoresResult = lighthouseScores(checkCtx);
|
|
67749
|
+
const oppsResult = lighthouseOpportunities(checkCtx);
|
|
67643
67750
|
const agenticResult = await agenticNav(checkCtx);
|
|
67644
|
-
const checks = [vitalsResult, cacheResult, scoresResult, agenticResult];
|
|
67751
|
+
const checks = [vitalsResult, cacheResult, scoresResult, oppsResult, agenticResult];
|
|
67645
67752
|
const allIssues = checks.flatMap((c) => c.issues);
|
|
67646
67753
|
const verdict2 = computeVerdict(checks, allIssues, {
|
|
67647
67754
|
pagesAnalyzed: pairCaptures(checkCtx.prodPages, checkCtx.candPages).pairs.length
|
|
@@ -67676,7 +67783,7 @@ async function vitalsCommand(opts) {
|
|
|
67676
67783
|
opportunities: aggregateOpportunities(checkCtx.candPages)
|
|
67677
67784
|
}, null, 2)}
|
|
67678
67785
|
`, "utf8");
|
|
67679
|
-
printSummary7(vitalsResult, cacheResult, scoresResult, agenticResult);
|
|
67786
|
+
printSummary7(vitalsResult, cacheResult, scoresResult, oppsResult, agenticResult);
|
|
67680
67787
|
console.log("");
|
|
67681
67788
|
console.log(chalk24.dim(` → ${paths.reportHtml}`));
|
|
67682
67789
|
console.log(chalk24.dim(` \uD83D\uDCA1 use 'parity serve ${runId}' pra preview iframe`));
|
|
@@ -67729,17 +67836,6 @@ async function captureVitalsPage(browser, viewport, side, url, screenshotsDir, r
|
|
|
67729
67836
|
function lhToWebVitals(s) {
|
|
67730
67837
|
return { lcp: s.lcp, cls: s.cls, fcp: s.fcp, ttfb: s.ttfb, inp: null, tbt: s.tbt ?? null };
|
|
67731
67838
|
}
|
|
67732
|
-
function aggregateOpportunities(pages) {
|
|
67733
|
-
const byId = new Map;
|
|
67734
|
-
for (const p of pages) {
|
|
67735
|
-
for (const o of p.lhOpportunities ?? []) {
|
|
67736
|
-
const prev2 = byId.get(o.id);
|
|
67737
|
-
if (!prev2 || o.savingsMs > prev2.savingsMs)
|
|
67738
|
-
byId.set(o.id, o);
|
|
67739
|
-
}
|
|
67740
|
-
}
|
|
67741
|
-
return [...byId.values()].sort((a, b) => b.savingsMs - a.savingsMs || b.savingsBytes - a.savingsBytes);
|
|
67742
|
-
}
|
|
67743
67839
|
async function discoverPagePaths2(prodUrl, opts) {
|
|
67744
67840
|
if (opts.urls)
|
|
67745
67841
|
return parseUrlList(opts.urls);
|
|
@@ -67797,13 +67893,15 @@ async function runWithConcurrency3(items, workers, fn) {
|
|
|
67797
67893
|
}
|
|
67798
67894
|
}));
|
|
67799
67895
|
}
|
|
67800
|
-
function printSummary7(vitals, cache, scores, agentic) {
|
|
67896
|
+
function printSummary7(vitals, cache, scores, opportunities, agentic) {
|
|
67801
67897
|
console.log("");
|
|
67802
67898
|
console.log(chalk24.bold(" Summary:"));
|
|
67803
67899
|
console.log(` ${vitals.summary}`);
|
|
67804
67900
|
console.log(` ${cache.summary}`);
|
|
67805
67901
|
if (scores.status !== "skipped")
|
|
67806
67902
|
console.log(` ${scores.summary}`);
|
|
67903
|
+
if (opportunities.status !== "skipped")
|
|
67904
|
+
console.log(` ${opportunities.summary}`);
|
|
67807
67905
|
if (agentic.status !== "skipped")
|
|
67808
67906
|
console.log(` ${agentic.summary}`);
|
|
67809
67907
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/parity",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.12",
|
|
4
4
|
"description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with an LLM-ranked HTML report.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|