@decocms/parity 0.28.1 → 0.28.3

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 +55 -59
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -45797,7 +45797,7 @@ async function validateAddToCart(page, ctx, cartCountBefore, beforeUrl) {
45797
45797
  // src/engine/lighthouse.ts
45798
45798
  import { spawn } from "node:child_process";
45799
45799
  import { mkdirSync as mkdirSync5, readFileSync as readFileSync5 } from "node:fs";
45800
- import { join as join7 } from "node:path";
45800
+ import { join as join7, resolve as resolve2 } from "node:path";
45801
45801
  var AGENT_A11Y_AUDIT_IDS = [
45802
45802
  "button-name",
45803
45803
  "link-name",
@@ -45886,7 +45886,7 @@ async function measureLighthouseOnce(url, opts, attempt) {
45886
45886
  const formFactor = opts.formFactor ?? "mobile";
45887
45887
  mkdirSync5(opts.outDir, { recursive: true });
45888
45888
  const outPath = join7(opts.outDir, `${opts.id}-a${attempt}.json`);
45889
- const runTemp = join7(opts.outDir, `.tmp-${opts.id}-a${attempt}`);
45889
+ const runTemp = resolve2(opts.outDir, `.tmp-${opts.id}-a${attempt}`);
45890
45890
  mkdirSync5(runTemp, { recursive: true });
45891
45891
  const args = [
45892
45892
  "--yes",
@@ -45907,7 +45907,7 @@ async function measureLighthouseOnce(url, opts, attempt) {
45907
45907
  "--quiet",
45908
45908
  "--max-wait-for-load=90000"
45909
45909
  ];
45910
- const { code, stderr } = await new Promise((resolve2) => {
45910
+ const { code, stderr } = await new Promise((resolve3) => {
45911
45911
  const proc = spawn("npx", args, {
45912
45912
  shell: true,
45913
45913
  stdio: ["ignore", "ignore", "pipe"],
@@ -45917,8 +45917,8 @@ async function measureLighthouseOnce(url, opts, attempt) {
45917
45917
  proc.stderr.on("data", (chunk) => {
45918
45918
  stderrBuf += chunk.toString();
45919
45919
  });
45920
- proc.on("close", (exitCode) => resolve2({ code: exitCode ?? 1, stderr: stderrBuf }));
45921
- proc.on("error", (err) => resolve2({ code: 1, stderr: err.message }));
45920
+ proc.on("close", (exitCode) => resolve3({ code: exitCode ?? 1, stderr: stderrBuf }));
45921
+ proc.on("error", (err) => resolve3({ code: 1, stderr: err.message }));
45922
45922
  });
45923
45923
  let report;
45924
45924
  try {
@@ -46873,11 +46873,9 @@ async function runSideBenchmark(opts) {
46873
46873
  id: `${opts.side}-${opts.viewport}-${id}`,
46874
46874
  formFactor: ff
46875
46875
  });
46876
- const [home, plp, pdp] = await Promise.all([
46877
- lh("home", opts.base),
46878
- lh("plp", targets.category),
46879
- lh("pdp", targets.product)
46880
- ]);
46876
+ const home = await lh("home", opts.base);
46877
+ const plp = await lh("plp", targets.category);
46878
+ const pdp = await lh("pdp", targets.product);
46881
46879
  vitals = { home, plp, pdp };
46882
46880
  }
46883
46881
  return {
@@ -47129,11 +47127,9 @@ async function runSideBenchmarkContent(opts) {
47129
47127
  id: `${opts.side}-${opts.viewport}-${id}`,
47130
47128
  formFactor: ff
47131
47129
  });
47132
- const [home, plp, pdp] = await Promise.all([
47133
- lh("home", opts.base),
47134
- lh("page1", new URL(opts.contentPaths.pageA, opts.base).toString()),
47135
- lh("page2", new URL(opts.contentPaths.pageB, opts.base).toString())
47136
- ]);
47130
+ const home = await lh("home", opts.base);
47131
+ const plp = await lh("page1", new URL(opts.contentPaths.pageA, opts.base).toString());
47132
+ const pdp = await lh("page2", new URL(opts.contentPaths.pageB, opts.base).toString());
47137
47133
  vitals = { home, plp, pdp };
47138
47134
  }
47139
47135
  return {
@@ -47763,7 +47759,7 @@ function speedup(prodMs, candMs) {
47763
47759
  function deltaTone(prodMs, candMs) {
47764
47760
  if (prodMs <= 0 || candMs <= 0)
47765
47761
  return DECK.muted;
47766
- if (candMs < prodMs * 0.95)
47762
+ if (candMs < prodMs)
47767
47763
  return DECK.soft;
47768
47764
  if (candMs > prodMs * 1.05)
47769
47765
  return DECK.bad;
@@ -47774,7 +47770,7 @@ function pctChange(prodMs, candMs) {
47774
47770
  return "—";
47775
47771
  const change = (candMs - prodMs) / prodMs * 100;
47776
47772
  const sign = change > 0 ? "+" : "";
47777
- return `${sign}${change.toFixed(0)}%`;
47773
+ return `${sign}${change.toFixed(Math.abs(change) < 1 ? 1 : 0)}%`;
47778
47774
  }
47779
47775
  function figure(path, labelHtml, tone, href, scroll = false) {
47780
47776
  const uri = dataUri(path);
@@ -58687,10 +58683,10 @@ async function runFlow(flow, ctx) {
58687
58683
  });
58688
58684
  let timer;
58689
58685
  let cleanup = Promise.resolve();
58690
- const timeoutPromise = new Promise((resolve2) => {
58686
+ const timeoutPromise = new Promise((resolve3) => {
58691
58687
  timer = setTimeout(() => {
58692
58688
  const pages = ctx.ctx.pages();
58693
- resolve2(finalize(flow, ctx, [], [
58689
+ resolve3(finalize(flow, ctx, [], [
58694
58690
  {
58695
58691
  step: 0,
58696
58692
  name: "flow-timeout",
@@ -58739,7 +58735,7 @@ var PROBE_TIMEOUT_MS = 2000;
58739
58735
  function withTimeout(p, capMs, fallback) {
58740
58736
  return Promise.race([
58741
58737
  p.catch(() => fallback),
58742
- new Promise((resolve2) => setTimeout(() => resolve2(fallback), capMs))
58738
+ new Promise((resolve3) => setTimeout(() => resolve3(fallback), capMs))
58743
58739
  ]);
58744
58740
  }
58745
58741
  function selectorKeysOf(selectors) {
@@ -59421,7 +59417,7 @@ ${JSON.stringify(checks.map((c) => ({ name: c.name, status: c.status, summary: c
59421
59417
 
59422
59418
  // src/commands/extract.ts
59423
59419
  import { mkdirSync as mkdirSync13 } from "node:fs";
59424
- import { resolve as resolve3 } from "node:path";
59420
+ import { resolve as resolve4 } from "node:path";
59425
59421
  import chalk12 from "chalk";
59426
59422
 
59427
59423
  // src/llm/section-understanding.ts
@@ -60244,7 +60240,7 @@ function capLinks(links, max) {
60244
60240
 
60245
60241
  // src/commands/section.ts
60246
60242
  import { mkdirSync as mkdirSync12 } from "node:fs";
60247
- import { resolve as resolve2 } from "node:path";
60243
+ import { resolve as resolve3 } from "node:path";
60248
60244
  import chalk11 from "chalk";
60249
60245
  import * as diff from "diff";
60250
60246
  import prettier from "prettier";
@@ -60634,10 +60630,10 @@ async function sectionCommand(opts) {
60634
60630
  const hash2 = hashSelector(opts.selector);
60635
60631
  const filePrefix = `section-${hash2}-${viewport}`;
60636
60632
  const screenshotPaths = {
60637
- prod: resolve2(opts.outDir, `${filePrefix}-prod.png`),
60638
- cand: resolve2(opts.outDir, `${filePrefix}-cand.png`)
60633
+ prod: resolve3(opts.outDir, `${filePrefix}-prod.png`),
60634
+ cand: resolve3(opts.outDir, `${filePrefix}-cand.png`)
60639
60635
  };
60640
- const heatmapPath = resolve2(opts.outDir, `${filePrefix}-heatmap.png`);
60636
+ const heatmapPath = resolve3(opts.outDir, `${filePrefix}-heatmap.png`);
60641
60637
  const browser = await launchBrowser({ headless: true });
60642
60638
  try {
60643
60639
  const [prodSide, candSide] = await Promise.all([
@@ -60734,7 +60730,7 @@ async function gatherSide(browser, opts) {
60734
60730
  stabilizeCarousels(page).catch(() => {
60735
60731
  return;
60736
60732
  }),
60737
- new Promise((resolve3) => setTimeout(resolve3, 3000))
60733
+ new Promise((resolve4) => setTimeout(resolve4, 3000))
60738
60734
  ]);
60739
60735
  if (opts.wantScreenshot) {
60740
60736
  const scrollBudget = 30000;
@@ -60742,13 +60738,13 @@ async function gatherSide(browser, opts) {
60742
60738
  scrollFullPage(page, scrollBudget).catch(() => {
60743
60739
  return;
60744
60740
  }),
60745
- new Promise((resolve3) => setTimeout(resolve3, scrollBudget + 2000))
60741
+ new Promise((resolve4) => setTimeout(resolve4, scrollBudget + 2000))
60746
60742
  ]);
60747
60743
  await Promise.race([
60748
60744
  waitForSkeletonsToResolve(page, 5000).catch(() => {
60749
60745
  return;
60750
60746
  }),
60751
- new Promise((resolve3) => setTimeout(resolve3, 5000))
60747
+ new Promise((resolve4) => setTimeout(resolve4, 5000))
60752
60748
  ]);
60753
60749
  }
60754
60750
  const artifacts = await captureSectionArtifacts(page, {
@@ -61104,7 +61100,7 @@ async function extractCommand(opts) {
61104
61100
  const host = safeHost4(opts.url);
61105
61101
  const timestamp = new Date().toISOString();
61106
61102
  const runDirTimestamp = timestamp.replace(/[:.]/g, "-");
61107
- const runDir = resolve3(opts.outDir, host, runDirTimestamp);
61103
+ const runDir = resolve4(opts.outDir, host, runDirTimestamp);
61108
61104
  mkdirSync13(runDir, { recursive: true });
61109
61105
  const browser = await launchBrowser({ headless: true });
61110
61106
  try {
@@ -61151,7 +61147,7 @@ async function extractCommand(opts) {
61151
61147
  for (const component of detected) {
61152
61148
  globalIndex++;
61153
61149
  const dirName = componentDirName(component.role, globalIndex);
61154
- const componentDir = resolve3(runDir, "components", dirName);
61150
+ const componentDir = resolve4(runDir, "components", dirName);
61155
61151
  const extracted = await extractComponent(page, component, {
61156
61152
  outDir: componentDir,
61157
61153
  index: globalIndex,
@@ -62188,7 +62184,7 @@ function listCommand(output) {
62188
62184
 
62189
62185
  // src/commands/migrate.ts
62190
62186
  import { existsSync as existsSync15, mkdirSync as mkdirSync16, readFileSync as readFileSync20, writeFileSync as writeFileSync24 } from "node:fs";
62191
- import { resolve as resolve4 } from "node:path";
62187
+ import { resolve as resolve5 } from "node:path";
62192
62188
  import chalk17 from "chalk";
62193
62189
  import open from "open";
62194
62190
 
@@ -64702,13 +64698,13 @@ async function migrateCommand(opts) {
64702
64698
  console.log(chalk17.dim(` source: ${source.label} — ${sourceInventory.components.length} component(s) from code`));
64703
64699
  }
64704
64700
  const host = safeHost6(opts.url);
64705
- const runDir = resolve4(opts.outDir, host);
64701
+ const runDir = resolve5(opts.outDir, host);
64706
64702
  mkdirSync16(runDir, { recursive: true });
64707
64703
  const browser = await launchBrowser({ headless: true });
64708
64704
  try {
64709
- const themePath = resolve4(runDir, "theme.json");
64710
- const assetsPath = resolve4(runDir, "assets.json");
64711
- const blocksPath = resolve4(runDir, "blocks.json");
64705
+ const themePath = resolve5(runDir, "theme.json");
64706
+ const assetsPath = resolve5(runDir, "assets.json");
64707
+ const blocksPath = resolve5(runDir, "blocks.json");
64712
64708
  let theme;
64713
64709
  let platform;
64714
64710
  let stack = null;
@@ -64726,7 +64722,7 @@ async function migrateCommand(opts) {
64726
64722
  console.log(chalk17.dim(" phase 1 theme+assets: cached"));
64727
64723
  } else {
64728
64724
  console.log(chalk17.dim(` phase 1 theme+assets: scraping (${viewports.join(", ")})…`));
64729
- mkdirSync16(resolve4(runDir, "screenshots"), { recursive: true });
64725
+ mkdirSync16(resolve5(runDir, "screenshots"), { recursive: true });
64730
64726
  const samples = [];
64731
64727
  screenshots = [];
64732
64728
  let platformSeen = null;
@@ -64752,7 +64748,7 @@ async function migrateCommand(opts) {
64752
64748
  sleep2(5000)
64753
64749
  ]);
64754
64750
  samples.push(await scrapeThemeSamples(page));
64755
- const shot = resolve4(runDir, "screenshots", `${vp}.png`);
64751
+ const shot = resolve5(runDir, "screenshots", `${vp}.png`);
64756
64752
  await page.screenshot({ path: shot, fullPage: true, animations: "disabled", timeout: 15000 }).then(() => screenshots.push({ viewport: vp, path: `screenshots/${vp}.png` })).catch(() => {
64757
64753
  return;
64758
64754
  });
@@ -64766,7 +64762,7 @@ async function migrateCommand(opts) {
64766
64762
  const fetchBytes = async (url) => await browserFetchBytes(page, url) ?? await nodeFetchBytes(url);
64767
64763
  assetsResolved = await downloadSiteAssets(rawAssets, runDir, fetchBytes);
64768
64764
  if (rawAssets.logo?.type === "svg" || rawAssets.logo && !assetsResolved.logo) {
64769
- const logoPng = resolve4(runDir, "assets", "logo.png");
64765
+ const logoPng = resolve5(runDir, "assets", "logo.png");
64770
64766
  const ok = await page.locator("[data-parity-logo]").first().screenshot({ path: logoPng, timeout: 8000 }).then(() => true).catch(() => false);
64771
64767
  if (ok) {
64772
64768
  assetsResolved.logo = "assets/logo.png";
@@ -64791,7 +64787,7 @@ async function migrateCommand(opts) {
64791
64787
  writeFileSync24(assetsPath, `${JSON.stringify({ platform, stack, assets, screenshots }, null, 2)}
64792
64788
  `, "utf8");
64793
64789
  }
64794
- const sitemapPath = resolve4(runDir, "sitemap.json");
64790
+ const sitemapPath = resolve5(runDir, "sitemap.json");
64795
64791
  let resolvedPages;
64796
64792
  if (!opts.refresh && existsSync15(sitemapPath)) {
64797
64793
  resolvedPages = readJson(sitemapPath).pages;
@@ -64834,7 +64830,7 @@ async function migrateCommand(opts) {
64834
64830
  console.error(chalk17.red("nenhuma página resolvida a partir de --pages"));
64835
64831
  return 1;
64836
64832
  }
64837
- const capturePath = resolve4(runDir, "capture.json");
64833
+ const capturePath = resolve5(runDir, "capture.json");
64838
64834
  let pages;
64839
64835
  let components;
64840
64836
  if (!opts.refresh && existsSync15(capturePath)) {
@@ -64860,7 +64856,7 @@ async function migrateCommand(opts) {
64860
64856
  writeFileSync24(blocksPath, `${JSON.stringify(vtexBlocks, null, 2)}
64861
64857
  `, "utf8");
64862
64858
  if (Object.keys(contentMap).length)
64863
- writeFileSync24(resolve4(runDir, "content-assets.json"), `${JSON.stringify(contentMap, null, 2)}
64859
+ writeFileSync24(resolve5(runDir, "content-assets.json"), `${JSON.stringify(contentMap, null, 2)}
64864
64860
  `, "utf8");
64865
64861
  const bundle = {
64866
64862
  url: opts.url,
@@ -64897,17 +64893,17 @@ async function migrateCommand(opts) {
64897
64893
  if (format === "md" || format === "both") {
64898
64894
  await markdownExporter2.export(bundle, runDir);
64899
64895
  await htmlExporter.export(bundle, runDir);
64900
- writeFileSync24(resolve4(runDir, "MIGRATION_PROMPT.md"), buildMigrationPrompt(bundle, playbook, {
64896
+ writeFileSync24(resolve5(runDir, "MIGRATION_PROMPT.md"), buildMigrationPrompt(bundle, playbook, {
64901
64897
  playbook: source.playbook,
64902
64898
  notes: sourceInventory.notes
64903
64899
  }), "utf8");
64904
64900
  }
64905
64901
  const targetTheme = opts.target ? getTargetTheme(opts.target) : null;
64906
64902
  if (targetTheme) {
64907
- writeFileSync24(resolve4(runDir, targetTheme.filename), targetTheme.build(theme), "utf8");
64903
+ writeFileSync24(resolve5(runDir, targetTheme.filename), targetTheme.build(theme), "utf8");
64908
64904
  }
64909
64905
  if (bundle.vtex) {
64910
- writeFileSync24(resolve4(runDir, "component-map.json"), `${JSON.stringify(bundle.vtex.map, null, 2)}
64906
+ writeFileSync24(resolve5(runDir, "component-map.json"), `${JSON.stringify(bundle.vtex.map, null, 2)}
64911
64907
  `, "utf8");
64912
64908
  }
64913
64909
  if (opts.json) {
@@ -64916,7 +64912,7 @@ async function migrateCommand(opts) {
64916
64912
  }
64917
64913
  printResults4(runDir, bundle);
64918
64914
  if (opts.open && format !== "json") {
64919
- await open(resolve4(runDir, "report.html")).catch(() => {
64915
+ await open(resolve5(runDir, "report.html")).catch(() => {
64920
64916
  return;
64921
64917
  });
64922
64918
  }
@@ -64971,7 +64967,7 @@ async function capturePages(browser, viewport, resolvedPages, theme, cfg) {
64971
64967
  if (global)
64972
64968
  seenGlobalRoles.add(component.role);
64973
64969
  const idx = components.length + 1;
64974
- const componentDir = resolve4(cfg.runDir, "components", componentDirName(component.role, idx));
64970
+ const componentDir = resolve5(cfg.runDir, "components", componentDirName(component.role, idx));
64975
64971
  const extracted = await extractComponent(page, component, {
64976
64972
  outDir: componentDir,
64977
64973
  index: idx,
@@ -66271,7 +66267,7 @@ import chalk19 from "chalk";
66271
66267
  // src/server/proxy-server.ts
66272
66268
  import { existsSync as existsSync16, readFileSync as readFileSync22, statSync } from "node:fs";
66273
66269
  import { createServer } from "node:http";
66274
- import { extname, join as join28, normalize as normalize3, resolve as resolve5, sep } from "node:path";
66270
+ import { extname, join as join28, normalize as normalize3, resolve as resolve6, sep } from "node:path";
66275
66271
  var MIME3 = {
66276
66272
  ".html": "text/html; charset=utf-8",
66277
66273
  ".css": "text/css; charset=utf-8",
@@ -66307,7 +66303,7 @@ var STRIPPED_REQUEST_HEADERS = new Set([
66307
66303
  "origin"
66308
66304
  ]);
66309
66305
  async function startProxyServer(runDir, opts = {}) {
66310
- const absRunDir = resolve5(runDir);
66306
+ const absRunDir = resolve6(runDir);
66311
66307
  if (!existsSync16(absRunDir)) {
66312
66308
  throw new Error(`Run directory not found: ${runDir}`);
66313
66309
  }
@@ -66319,9 +66315,9 @@ async function startProxyServer(runDir, opts = {}) {
66319
66315
  } catch {}
66320
66316
  });
66321
66317
  });
66322
- await new Promise((resolve6, reject) => {
66318
+ await new Promise((resolve7, reject) => {
66323
66319
  server.once("error", reject);
66324
- server.listen(opts.port ?? 0, opts.host ?? "127.0.0.1", () => resolve6());
66320
+ server.listen(opts.port ?? 0, opts.host ?? "127.0.0.1", () => resolve7());
66325
66321
  });
66326
66322
  const addr = server.address();
66327
66323
  const port = typeof addr === "object" && addr ? addr.port : 0;
@@ -66329,13 +66325,13 @@ async function startProxyServer(runDir, opts = {}) {
66329
66325
  return {
66330
66326
  port,
66331
66327
  url: `http://${host}:${port}/`,
66332
- close: () => new Promise((resolve6) => {
66328
+ close: () => new Promise((resolve7) => {
66333
66329
  try {
66334
66330
  server.closeAllConnections?.();
66335
66331
  server.closeIdleConnections?.();
66336
66332
  } catch {}
66337
- server.close(() => resolve6());
66338
- setTimeout(() => resolve6(), 1000);
66333
+ server.close(() => resolve7());
66334
+ setTimeout(() => resolve7(), 1000);
66339
66335
  })
66340
66336
  };
66341
66337
  }
@@ -66381,7 +66377,7 @@ function serveReportHtml(res, runDir) {
66381
66377
  }
66382
66378
  function serveStatic(res, runDir, path) {
66383
66379
  const safePath3 = normalize3(path).replace(/^[/\\]+/, "");
66384
- const filePath = resolve5(runDir, safePath3);
66380
+ const filePath = resolve6(runDir, safePath3);
66385
66381
  if (!filePath.startsWith(runDir + sep) && filePath !== runDir) {
66386
66382
  res.statusCode = 403;
66387
66383
  res.end("forbidden");
@@ -66910,7 +66906,7 @@ async function runCommand(rawOpts) {
66910
66906
  b.close().catch(() => {
66911
66907
  return;
66912
66908
  }),
66913
- new Promise((resolve6) => setTimeout(resolve6, capMs))
66909
+ new Promise((resolve7) => setTimeout(resolve7, capMs))
66914
66910
  ]);
66915
66911
  };
66916
66912
  const shutdown = async (reason) => {
@@ -67186,8 +67182,8 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
67186
67182
  noNetworkIdle: targetIsDevServer,
67187
67183
  runs: vitalsRuns
67188
67184
  }),
67189
- new Promise((resolve6) => {
67190
- const t = setTimeout(() => resolve6(null), PER_TASK_WALLCLOCK_MS);
67185
+ new Promise((resolve7) => {
67186
+ const t = setTimeout(() => resolve7(null), PER_TASK_WALLCLOCK_MS);
67191
67187
  t.unref?.();
67192
67188
  })
67193
67189
  ]);
@@ -69064,14 +69060,14 @@ function printSummary7(vitals, cache, scores, opportunities, agentic) {
69064
69060
 
69065
69061
  // src/util/version.ts
69066
69062
  import { readFileSync as readFileSync27 } from "node:fs";
69067
- import { dirname as dirname5, resolve as resolve6 } from "node:path";
69063
+ import { dirname as dirname5, resolve as resolve7 } from "node:path";
69068
69064
  import { fileURLToPath } from "node:url";
69069
69065
  function getPackageVersion() {
69070
69066
  try {
69071
69067
  const here = dirname5(fileURLToPath(import.meta.url));
69072
69068
  for (const up of ["..", "../..", "../../.."]) {
69073
69069
  try {
69074
- const pkgPath = resolve6(here, up, "package.json");
69070
+ const pkgPath = resolve7(here, up, "package.json");
69075
69071
  const raw = readFileSync27(pkgPath, "utf8");
69076
69072
  const parsed = JSON.parse(raw);
69077
69073
  if (parsed.name === "@decocms/parity" && typeof parsed.version === "string") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.28.1",
3
+ "version": "0.28.3",
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",