@decocms/parity 0.26.12 → 0.26.14

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.
Files changed (2) hide show
  1. package/dist/cli.js +145 -17
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -41598,6 +41598,12 @@ var ModuleVerdict = z.object({
41598
41598
  checksRun: z.number(),
41599
41599
  pagesAnalyzed: z.number()
41600
41600
  });
41601
+ var RunCaveat = z.object({
41602
+ id: z.string(),
41603
+ level: z.enum(["warn", "info"]),
41604
+ summary: z.string(),
41605
+ detail: z.string()
41606
+ });
41601
41607
  var Run = z.object({
41602
41608
  schemaVersion: z.literal("0.1"),
41603
41609
  id: z.string(),
@@ -41631,6 +41637,7 @@ var Run = z.object({
41631
41637
  }).optional(),
41632
41638
  partial: z.boolean().optional(),
41633
41639
  partialReason: z.string().optional(),
41640
+ caveats: z.array(RunCaveat).optional(),
41634
41641
  timings: z.object({
41635
41642
  totalMs: z.number(),
41636
41643
  phases: z.array(z.object({ phase: z.string(), durationMs: z.number() }))
@@ -44738,12 +44745,17 @@ var PRODUCT_CARD_HEURISTIC_SELECTORS = [
44738
44745
  ".product-card"
44739
44746
  ];
44740
44747
  async function countProductCards(page) {
44741
- for (const sel of PRODUCT_CARD_HEURISTIC_SELECTORS) {
44742
- const count = await withCap(page.locator(sel).count().catch(() => 0), 1500, 0);
44743
- if (count > 0)
44744
- return count;
44745
- }
44746
- return 0;
44748
+ return await measureProductCards(page) ?? 0;
44749
+ }
44750
+ async function measureProductCards(page) {
44751
+ return withCap(page.evaluate((selectors) => {
44752
+ for (const sel of selectors) {
44753
+ const n = document.querySelectorAll(sel).length;
44754
+ if (n > 0)
44755
+ return n;
44756
+ }
44757
+ return 0;
44758
+ }, PRODUCT_CARD_HEURISTIC_SELECTORS).catch(() => null), 2500, null);
44747
44759
  }
44748
44760
 
44749
44761
  // src/engine/flows/purchase-journey.ts
@@ -45858,9 +45870,12 @@ async function waitForCardGrowth(page, before2, capMs) {
45858
45870
  const deadline = Date.now() + capMs;
45859
45871
  let cur = before2;
45860
45872
  while (Date.now() < deadline) {
45861
- cur = await countProductCards(page).catch(() => cur);
45862
- if (cur > before2)
45863
- return cur;
45873
+ const measured = await measureProductCards(page).catch(() => null);
45874
+ if (measured !== null) {
45875
+ cur = measured;
45876
+ if (cur > before2)
45877
+ return cur;
45878
+ }
45864
45879
  await page.waitForTimeout(400);
45865
45880
  }
45866
45881
  return cur;
@@ -50521,6 +50536,10 @@ async function ssrNoJs(ctx) {
50521
50536
  }
50522
50537
  const prodHome = pickHome5(ctx.prodPages);
50523
50538
  const prodText = prodHome ? await fetchSsrText(prodHome.finalUrl) : null;
50539
+ const candIsDevServer = isLocalhost(candHome.finalUrl);
50540
+ const devServerNote = candIsDevServer ? `
50541
+
50542
+ ⚠ Medido contra um dev server, onde várias frameworks renderizam client-side por padrão. Reconfirme num build de produção antes de tratar isto como defeito.` : "";
50524
50543
  if (candText.length < 200) {
50525
50544
  issues.push({
50526
50545
  id: "ssr:blank",
@@ -50528,7 +50547,8 @@ async function ssrNoJs(ctx) {
50528
50547
  category: "functional",
50529
50548
  check: "ssr-no-js",
50530
50549
  summary: `SSR do candidato rende só ${candText.length} chars de texto — página em branco sem JS (CLS alto, SEO/acessibilidade quebrados)`,
50531
- details: "Todo o conteúdo carrega client-side. Marque seções above-the-fold com `export const neverDefer = true` ou adicione LoadingFallback."
50550
+ details: `Todo o conteúdo carrega client-side. Marque seções above-the-fold com \`export const neverDefer = true\` ou adicione LoadingFallback.${devServerNote}`,
50551
+ ...candIsDevServer ? { inconclusive: true } : {}
50532
50552
  });
50533
50553
  } else if (prodText !== null && prodText.length > 0 && candText.length < prodText.length * 0.3) {
50534
50554
  issues.push({
@@ -50536,10 +50556,11 @@ async function ssrNoJs(ctx) {
50536
50556
  severity: "high",
50537
50557
  category: "functional",
50538
50558
  check: "ssr-no-js",
50539
- summary: `SSR do candidato tem <30% do texto do prod (${candText.length} vs ${prodText.length} chars) — maioria do conteúdo é client-only`
50559
+ summary: `SSR do candidato tem <30% do texto do prod (${candText.length} vs ${prodText.length} chars) — maioria do conteúdo é client-only`,
50560
+ ...candIsDevServer ? { inconclusive: true, details: devServerNote.trim() } : {}
50540
50561
  });
50541
50562
  }
50542
- const status = issues.some((i) => i.severity === "critical") ? "fail" : issues.length > 0 ? "warn" : "pass";
50563
+ const status = issues.some((i) => i.severity === "critical" && !i.inconclusive) ? "fail" : issues.length > 0 ? "warn" : "pass";
50543
50564
  return {
50544
50565
  name: "ssr-no-js",
50545
50566
  status,
@@ -55876,6 +55897,7 @@ function renderHtmlReport(run, runDir) {
55876
55897
  </div>
55877
55898
  </header>
55878
55899
  ${run.partial ? `<div style="background:#7c2d12;color:#fed7aa;padding:12px 24px;border-bottom:2px solid #ea580c;font-weight:600">⚠ Partial run — interrupted${run.partialReason ? ` (${escapeHtml(run.partialReason)})` : ""}. Verdict, top-issues, and some sections may be incomplete.</div>` : ""}
55900
+ ${renderCaveats(run)}
55879
55901
  ${countHiddenLlmTabs(run) > 0 ? `<div class="llm-disabled-banner">LLM disabled — ${countHiddenLlmTabs(run)} tab${countHiddenLlmTabs(run) !== 1 ? "s" : ""} hidden (Visual Diff, LLM Prompt). Set <code>ANTHROPIC_API_KEY</code> or log in to the local <code>claude</code> CLI and re-run for semantic analysis.</div>` : ""}
55880
55902
  ${renderTimingsBar(run)}
55881
55903
  <main class="app-main">
@@ -55975,6 +55997,19 @@ function renderTimingsBar(run) {
55975
55997
  <div style="display:flex;flex-direction:column;gap:4px">${rows}</div>
55976
55998
  </div>`;
55977
55999
  }
56000
+ function renderCaveats(run) {
56001
+ const caveats = run.caveats ?? [];
56002
+ if (caveats.length === 0)
56003
+ return "";
56004
+ const rows = caveats.map((c) => {
56005
+ const warn = c.level === "warn";
56006
+ return `<li style="margin:4px 0"><b style="color:${warn ? "#fca5a5" : "#93c5fd"}">${warn ? "⚠" : "ℹ"} ${escapeHtml(c.summary)}</b> <span style="opacity:.85">— ${escapeHtml(c.detail)}</span></li>`;
56007
+ }).join("");
56008
+ return `<div style="background:#1c1917;color:#e7e5e4;padding:12px 24px;border-bottom:1px solid #44403c;font-size:13px">
56009
+ <div style="font-weight:600;margin-bottom:4px">Como ler este run</div>
56010
+ <ul style="margin:0;padding-left:18px;list-style:none">${rows}</ul>
56011
+ </div>`;
56012
+ }
55978
56013
 
55979
56014
  // src/commands/cache.ts
55980
56015
  async function cacheCommand(opts) {
@@ -65504,6 +65539,84 @@ function formatSecs(ms) {
65504
65539
  return `${min}m${sec.toString().padStart(2, "0")}s`;
65505
65540
  }
65506
65541
 
65542
+ // src/engine/run-context.ts
65543
+ function detectRunCaveats(input) {
65544
+ const out = [];
65545
+ if (isLocalhost(input.candUrl)) {
65546
+ out.push({
65547
+ id: "cand-dev-server",
65548
+ level: "warn",
65549
+ summary: "Candidato medido num dev server",
65550
+ detail: "Vitals, cache e bundle de um dev server não são representativos: sem minificação, sem cache de edge, HMR aberto. Reconfirme num build de produção antes de tratar qualquer número de performance como resultado."
65551
+ });
65552
+ }
65553
+ if (isLocalhost(input.prodUrl)) {
65554
+ out.push({
65555
+ id: "prod-dev-server",
65556
+ level: "warn",
65557
+ summary: "Referência (prod) medida num dev server",
65558
+ detail: "O lado de referência também é local, então a comparação mede duas máquinas de desenvolvimento — útil para regressão relativa, não para números absolutos."
65559
+ });
65560
+ }
65561
+ const mismatched = pairedPathMismatches(input.prodPages, input.candPages);
65562
+ if (mismatched.length > 0) {
65563
+ out.push({
65564
+ id: "paths-differ",
65565
+ level: "warn",
65566
+ summary: `${mismatched.length} página(s) comparadas em caminhos diferentes`,
65567
+ detail: `Os dois lados não estão no mesmo conteúdo (${mismatched.slice(0, 3).join(", ")}${mismatched.length > 3 ? "…" : ""}). O módulo visual vai apontar diferenças que são de produto, não de migração — leia estrutura e hierarquia, não conteúdo.`
65568
+ });
65569
+ }
65570
+ if (!input.llmEnabled) {
65571
+ out.push({
65572
+ id: "llm-disabled",
65573
+ level: "info",
65574
+ summary: "Sem provedor de LLM — módulos visuais não rodaram",
65575
+ detail: "Visual diff e ranking de issues dependem de LLM. Sem provedor configurado eles são pulados, então a ausência de achados visuais não significa paridade visual."
65576
+ });
65577
+ }
65578
+ const skipped = input.verdict?.checksSkipped ?? 0;
65579
+ if (skipped > 0) {
65580
+ out.push({
65581
+ id: "checks-skipped",
65582
+ level: "info",
65583
+ summary: `${skipped} de ${input.verdict?.checksRun ?? "?"} checks pulados`,
65584
+ detail: "Um check pulado não é um check que passou. Veja `checks[]` no report.json para quais e por quê."
65585
+ });
65586
+ }
65587
+ if (input.partial) {
65588
+ out.push({
65589
+ id: "partial-run",
65590
+ level: "warn",
65591
+ summary: "Run interrompido — veredito parcial",
65592
+ detail: input.partialReason ? `Parou em: ${input.partialReason}. O que não rodou não conta como aprovado.` : "O que não rodou não conta como aprovado."
65593
+ });
65594
+ }
65595
+ return out;
65596
+ }
65597
+ function pairedPathMismatches(prodPages, candPages) {
65598
+ const out = [];
65599
+ for (const cand of candPages) {
65600
+ if (!cand.pairKey)
65601
+ continue;
65602
+ const prod = prodPages.find((p) => p.pairKey === cand.pairKey);
65603
+ if (!prod)
65604
+ continue;
65605
+ const prodPath = pathOf5(prod.url);
65606
+ const candPath = pathOf5(cand.url);
65607
+ if (prodPath && candPath && prodPath !== candPath)
65608
+ out.push(`${prodPath} → ${candPath}`);
65609
+ }
65610
+ return [...new Set(out)];
65611
+ }
65612
+ function pathOf5(raw) {
65613
+ try {
65614
+ return new URL(raw).pathname;
65615
+ } catch {
65616
+ return null;
65617
+ }
65618
+ }
65619
+
65507
65620
  // src/util/timing.ts
65508
65621
  async function withTiming(fn) {
65509
65622
  const start = performance.now();
@@ -65913,6 +66026,9 @@ function pagesFlowsScopeWarning(opts, flows2) {
65913
66026
  return null;
65914
66027
  return `--pages/--pages-file only scope the visual-diff/vitals passes — the flows crawl (${flows2.join(",")}) discovers its own pages; use --flows or .parityrc.json *UrlHint overrides to scope that.`;
65915
66028
  }
66029
+ function caveatsOrUndefined(caveats) {
66030
+ return caveats.length > 0 ? caveats : undefined;
66031
+ }
65916
66032
  function applySmartDefaults(opts, llmAvailable) {
65917
66033
  if (llmAvailable)
65918
66034
  return opts;
@@ -66733,7 +66849,15 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
66733
66849
  baseline: baselineSection,
66734
66850
  timings: runTimings,
66735
66851
  selectionReason: opts.why,
66736
- moduleVerdicts: moduleVerdicts.length > 0 ? moduleVerdicts : undefined
66852
+ moduleVerdicts: moduleVerdicts.length > 0 ? moduleVerdicts : undefined,
66853
+ caveats: caveatsOrUndefined(detectRunCaveats({
66854
+ prodUrl: opts.prod,
66855
+ candUrl: opts.cand,
66856
+ prodPages: checkCtx.prodPages,
66857
+ candPages: checkCtx.candPages,
66858
+ verdict: verdict2,
66859
+ llmEnabled: llmStillAvailable
66860
+ }))
66737
66861
  };
66738
66862
  const reportStart = performance.now();
66739
66863
  writeRunReportJson(paths.runDir, run);
@@ -66989,6 +67113,10 @@ function printSummary6(run, htmlPath, meta) {
66989
67113
  console.log(` ${emoji} parity ${verdict2.status.toUpperCase()} · score ${score}/100${scoreDelta}`);
66990
67114
  console.log(` checks: ${chalk20.green(verdict2.checksPassed)} pass · ${chalk20.red(verdict2.checksFailed)} fail · ${chalk20.dim(`${verdict2.checksSkipped} skipped`)}`);
66991
67115
  console.log(` issues: ${chalk20.red(verdict2.critical)} critical · ${chalk20.yellow(verdict2.high)} high · ${verdict2.medium} medium · ${chalk20.dim(`${verdict2.low} low`)}`);
67116
+ for (const c of run.caveats ?? []) {
67117
+ const mark = c.level === "warn" ? chalk20.yellow("⚠") : chalk20.dim("ℹ");
67118
+ console.log(` ${mark} ${c.summary}`);
67119
+ }
66992
67120
  if (run.moduleVerdicts && run.moduleVerdicts.length > 0) {
66993
67121
  const perModule = run.moduleVerdicts.map((mv) => {
66994
67122
  const colored = mv.status === "pass" ? chalk20.green(mv.score) : mv.status === "warn" ? chalk20.yellow(mv.score) : chalk20.red(mv.score);
@@ -67232,7 +67360,7 @@ function extractVitalsSlice(run) {
67232
67360
  for (const p of fc.pages) {
67233
67361
  if (!p.vitals)
67234
67362
  continue;
67235
- const k = `${p.side}::${p.viewport}::${pathOf5(p.url)}`;
67363
+ const k = `${p.side}::${p.viewport}::${pathOf6(p.url)}`;
67236
67364
  out[k] = p.vitalsFullPage ? { ...p.vitals, fullPage: p.vitalsFullPage } : p.vitals;
67237
67365
  }
67238
67366
  }
@@ -67277,8 +67405,8 @@ function extractSideBySideSlice(run) {
67277
67405
  for (const p of fc.pages) {
67278
67406
  if (p.side !== "prod")
67279
67407
  continue;
67280
- const candPath = pathOf5(p.url);
67281
- const cand = fc.pages.find((q) => q.side === "cand" && pathOf5(q.url) === candPath && q.viewport === p.viewport);
67408
+ const candPath = pathOf6(p.url);
67409
+ const cand = fc.pages.find((q) => q.side === "cand" && pathOf6(q.url) === candPath && q.viewport === p.viewport);
67282
67410
  if (!cand)
67283
67411
  continue;
67284
67412
  pairs.push({
@@ -67291,7 +67419,7 @@ function extractSideBySideSlice(run) {
67291
67419
  }
67292
67420
  return pairs;
67293
67421
  }
67294
- function pathOf5(url) {
67422
+ function pathOf6(url) {
67295
67423
  try {
67296
67424
  return new URL(url).pathname || "/";
67297
67425
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.26.12",
3
+ "version": "0.26.14",
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",