@decocms/parity 0.11.16 → 0.11.17

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 +36 -8
  2. package/package.json +13 -4
package/dist/cli.js CHANGED
@@ -55796,13 +55796,29 @@ async function preflightCheck(prodUrl, candUrl, viewport) {
55796
55796
  const spinner = ora5("Pre-flight: verificando URLs…").start();
55797
55797
  const errors2 = [];
55798
55798
  const ua = userAgentFor(viewport);
55799
- async function probe(label, url) {
55799
+ const browser = await launchBrowser({ headless: true }).catch(() => null);
55800
+ async function probeWithBrowser(label, url) {
55801
+ const ctx = await browser.newContext({
55802
+ userAgent: ua,
55803
+ ignoreHTTPSErrors: true
55804
+ });
55805
+ const page = await ctx.newPage();
55800
55806
  try {
55801
- new URL(url);
55802
- } catch {
55803
- errors2.push(`${label}: URL inválida (${url})`);
55804
- return;
55807
+ const res = await page.goto(url, { waitUntil: "commit", timeout: 30000 });
55808
+ const status = res?.status() ?? 0;
55809
+ if (status >= 500)
55810
+ errors2.push(`${label}: HTTP ${status} (${url})`);
55811
+ else if (status >= 400)
55812
+ errors2.push(`${label}: HTTP ${status} (${url})`);
55813
+ } catch (err) {
55814
+ const e = err;
55815
+ errors2.push(`${label}: ${e.message.split(`
55816
+ `)[0]} (${url})`);
55817
+ } finally {
55818
+ await ctx.close().catch(() => {});
55805
55819
  }
55820
+ }
55821
+ async function probeWithFetch(label, url) {
55806
55822
  const PREFLIGHT_TIMEOUT_MS = 30000;
55807
55823
  const controller = new AbortController;
55808
55824
  const t = setTimeout(() => controller.abort(), PREFLIGHT_TIMEOUT_MS);
@@ -55811,9 +55827,7 @@ async function preflightCheck(prodUrl, candUrl, viewport) {
55811
55827
  method: "GET",
55812
55828
  redirect: "follow",
55813
55829
  signal: controller.signal,
55814
- headers: {
55815
- "User-Agent": ua
55816
- }
55830
+ headers: { "User-Agent": ua }
55817
55831
  });
55818
55832
  if (res.status >= 500)
55819
55833
  errors2.push(`${label}: HTTP ${res.status} ${res.statusText} (${url})`);
@@ -55827,7 +55841,21 @@ async function preflightCheck(prodUrl, candUrl, viewport) {
55827
55841
  clearTimeout(t);
55828
55842
  }
55829
55843
  }
55844
+ async function probe(label, url) {
55845
+ try {
55846
+ new URL(url);
55847
+ } catch {
55848
+ errors2.push(`${label}: URL inválida (${url})`);
55849
+ return;
55850
+ }
55851
+ if (browser) {
55852
+ await probeWithBrowser(label, url);
55853
+ } else {
55854
+ await probeWithFetch(label, url);
55855
+ }
55856
+ }
55830
55857
  await Promise.all([probe("prod", prodUrl), probe("cand", candUrl)]);
55858
+ await browser?.close().catch(() => {});
55831
55859
  if (errors2.length > 0) {
55832
55860
  spinner.fail("Pre-flight falhou");
55833
55861
  return { ok: false, errors: errors2 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.11.16",
3
+ "version": "0.11.17",
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",
@@ -32,7 +32,14 @@
32
32
  "bin": {
33
33
  "parity": "dist/cli.js"
34
34
  },
35
- "files": ["dist", "scripts/postinstall.cjs", "README.md", "AGENTS.md", "CHANGELOG.md", "LICENSE"],
35
+ "files": [
36
+ "dist",
37
+ "scripts/postinstall.cjs",
38
+ "README.md",
39
+ "AGENTS.md",
40
+ "CHANGELOG.md",
41
+ "LICENSE"
42
+ ],
36
43
  "scripts": {
37
44
  "dev": "bun run --hot src/cli.ts",
38
45
  "build": "bun build src/cli.ts --target=node --outfile=dist/cli.js --external @anthropic-ai/claude-agent-sdk --external @anthropic-ai/sdk --external chalk --external commander --external diff --external open --external ora --external pixelmatch --external playwright --external pngjs --external prettier --external zod && bun run scripts/postbuild.ts",
@@ -83,5 +90,7 @@
83
90
  "publishConfig": {
84
91
  "access": "public"
85
92
  },
86
- "trustedDependencies": ["@biomejs/biome"]
87
- }
93
+ "trustedDependencies": [
94
+ "@biomejs/biome"
95
+ ]
96
+ }