@decocms/parity 0.19.0 → 0.20.0
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/CHANGELOG.md +13 -0
- package/dist/cli.js +245 -40
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.20.0] — 2026-08-17
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
* **`parity migrate` now captures the VTEX CMS content + all its images.** Each block's `props` (the merchant's registered content — banner images, texts, links, shelf config) is kept in `blocks.json`; content-image references (site-relative `/arquivos/ids/…`, `/img/…`) are resolved to absolute URLs, and the images — from block props **and** the Apollo `__STATE__` (product/catalog imagery) — are downloaded to `assets/content/` with a `content-assets.json` url→file map (up to 150/run). (#209, #211)
|
|
15
|
+
* **Quality pass:** robust logo capture (screenshots the element, so sprite `<use>` logos aren't blank), web-font download from `@font-face` (`assets/fonts/`), scroll-before-screenshot (lazy footers render), and a self-contained **`report.html`** (every image inlined) to share as a single link. (#209)
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
* **Header/footer are now detected on sites without semantic tags** (e.g. VTEX IO, which renders both as plain `<div>`s) via a geometry/anchor fallback that only fires when no `<header>`/`<footer>` matched. Shared by `extract` + `migrate`. (#212)
|
|
20
|
+
* **Theme election cleanups:** primary skips translucent overlays and considers opaque colors across all usages; breakpoints kept by frequency (real tiers, not 100+ media-query one-offs); background falls back to the most frequent opaque color; implausible motion durations dropped. (#209)
|
|
21
|
+
* Ignore `parity-migrate/` / `parity-extract/` output dirs so scraped store data can't be committed. (#210)
|
|
22
|
+
|
|
10
23
|
## [0.19.0] — 2026-08-17
|
|
11
24
|
|
|
12
25
|
### Added
|
package/dist/cli.js
CHANGED
|
@@ -56006,6 +56006,48 @@ function collectCandidatesInPage() {
|
|
|
56006
56006
|
}
|
|
56007
56007
|
}
|
|
56008
56008
|
}
|
|
56009
|
+
const docHeight = Math.max(document.documentElement.scrollHeight, document.body?.scrollHeight ?? 0);
|
|
56010
|
+
function widest(els) {
|
|
56011
|
+
let best = null;
|
|
56012
|
+
let bestArea = 0;
|
|
56013
|
+
for (const el of els) {
|
|
56014
|
+
const r = rectOf(el);
|
|
56015
|
+
if (r.width < viewportWidth * 0.85)
|
|
56016
|
+
continue;
|
|
56017
|
+
const area = r.width * r.height;
|
|
56018
|
+
if (area > bestArea && area > 0) {
|
|
56019
|
+
best = el;
|
|
56020
|
+
bestArea = area;
|
|
56021
|
+
}
|
|
56022
|
+
}
|
|
56023
|
+
return best;
|
|
56024
|
+
}
|
|
56025
|
+
if (!out.some((c) => c.role === "header")) {
|
|
56026
|
+
let header = null;
|
|
56027
|
+
const anchor = document.querySelector("nav, [class*='logo' i], [class*='search' i]");
|
|
56028
|
+
let el = anchor;
|
|
56029
|
+
while (el?.parentElement) {
|
|
56030
|
+
const r = rectOf(el.parentElement);
|
|
56031
|
+
if (r.y <= 5 && r.width >= viewportWidth * 0.85 && r.height < window.innerHeight * 1.5) {
|
|
56032
|
+
header = el.parentElement;
|
|
56033
|
+
}
|
|
56034
|
+
el = el.parentElement;
|
|
56035
|
+
}
|
|
56036
|
+
header ??= widest(Array.from(document.querySelectorAll("[class*='header' i]")).filter((e) => rectOf(e).y < 200));
|
|
56037
|
+
if (header)
|
|
56038
|
+
push("header", header);
|
|
56039
|
+
}
|
|
56040
|
+
if (!out.some((c) => c.role === "footer")) {
|
|
56041
|
+
const footer = widest(Array.from(document.querySelectorAll("[class*='footer' i]")).filter((e) => {
|
|
56042
|
+
const r = rectOf(e);
|
|
56043
|
+
return r.y + r.height > docHeight - window.innerHeight && e.querySelectorAll("a").length >= 4;
|
|
56044
|
+
})) ?? widest(Array.from(document.querySelectorAll("div, section")).filter((e) => {
|
|
56045
|
+
const r = rectOf(e);
|
|
56046
|
+
return r.y + r.height > docHeight - window.innerHeight * 0.6 && r.y > docHeight * 0.5 && e.querySelectorAll("a").length >= 6;
|
|
56047
|
+
}));
|
|
56048
|
+
if (footer)
|
|
56049
|
+
push("footer", footer);
|
|
56050
|
+
}
|
|
56009
56051
|
return out;
|
|
56010
56052
|
}
|
|
56011
56053
|
|
|
@@ -58417,7 +58459,7 @@ function listCommand(output) {
|
|
|
58417
58459
|
}
|
|
58418
58460
|
|
|
58419
58461
|
// src/commands/migrate.ts
|
|
58420
|
-
import { existsSync as existsSync11, mkdirSync as
|
|
58462
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync15, readFileSync as readFileSync14, writeFileSync as writeFileSync21 } from "node:fs";
|
|
58421
58463
|
import { resolve as resolve3 } from "node:path";
|
|
58422
58464
|
import chalk16 from "chalk";
|
|
58423
58465
|
import open from "open";
|
|
@@ -59086,8 +59128,138 @@ var jsonExporter2 = {
|
|
|
59086
59128
|
};
|
|
59087
59129
|
|
|
59088
59130
|
// src/migrate/exporters/markdown.ts
|
|
59131
|
+
import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync19 } from "node:fs";
|
|
59132
|
+
import { join as join20 } from "node:path";
|
|
59133
|
+
|
|
59134
|
+
// src/migrate/vtex/content-assets.ts
|
|
59089
59135
|
import { mkdirSync as mkdirSync13, writeFileSync as writeFileSync18 } from "node:fs";
|
|
59090
59136
|
import { join as join19 } from "node:path";
|
|
59137
|
+
var MAX_IMAGES = 150;
|
|
59138
|
+
var IMG_EXT = /\.(jpe?g|png|webp|gif|svg|avif)(\?|#|$)/i;
|
|
59139
|
+
var VTEX_ASSET = /vtexassets\.com|vteximg\.com\.br|\/arquivos\/(ids|assets)\//i;
|
|
59140
|
+
function isImageUrl(s) {
|
|
59141
|
+
if (typeof s !== "string")
|
|
59142
|
+
return false;
|
|
59143
|
+
const v = s.trim();
|
|
59144
|
+
if (!/^(https?:)?\/\//i.test(v))
|
|
59145
|
+
return false;
|
|
59146
|
+
return IMG_EXT.test(v) || VTEX_ASSET.test(v);
|
|
59147
|
+
}
|
|
59148
|
+
function isImageRef(s) {
|
|
59149
|
+
if (typeof s !== "string")
|
|
59150
|
+
return false;
|
|
59151
|
+
const v = s.trim();
|
|
59152
|
+
if (isImageUrl(v))
|
|
59153
|
+
return true;
|
|
59154
|
+
return v.startsWith("/") && !v.startsWith("//") && (IMG_EXT.test(v) || VTEX_ASSET.test(v) || v.startsWith("/img/"));
|
|
59155
|
+
}
|
|
59156
|
+
function resolveRef(ref, baseUrl) {
|
|
59157
|
+
const v = ref.trim();
|
|
59158
|
+
try {
|
|
59159
|
+
if (v.startsWith("//"))
|
|
59160
|
+
return `https:${v}`;
|
|
59161
|
+
return new URL(v, baseUrl).toString();
|
|
59162
|
+
} catch {
|
|
59163
|
+
return null;
|
|
59164
|
+
}
|
|
59165
|
+
}
|
|
59166
|
+
function collectImageRefs(blocks, baseUrl) {
|
|
59167
|
+
const out = {};
|
|
59168
|
+
const walk = (v) => {
|
|
59169
|
+
if (typeof v === "string") {
|
|
59170
|
+
const s = v.trim();
|
|
59171
|
+
if (isImageRef(s) && !(s in out)) {
|
|
59172
|
+
const abs = resolveRef(s, baseUrl);
|
|
59173
|
+
if (abs)
|
|
59174
|
+
out[s] = abs;
|
|
59175
|
+
}
|
|
59176
|
+
} else if (Array.isArray(v)) {
|
|
59177
|
+
for (const x of v)
|
|
59178
|
+
walk(x);
|
|
59179
|
+
} else if (v && typeof v === "object") {
|
|
59180
|
+
for (const x of Object.values(v))
|
|
59181
|
+
walk(x);
|
|
59182
|
+
}
|
|
59183
|
+
};
|
|
59184
|
+
for (const b of blocks)
|
|
59185
|
+
if (b.props)
|
|
59186
|
+
walk(b.props);
|
|
59187
|
+
return out;
|
|
59188
|
+
}
|
|
59189
|
+
function countContentImages(blocks) {
|
|
59190
|
+
const urls = new Set;
|
|
59191
|
+
const walk = (v) => {
|
|
59192
|
+
if (typeof v === "string") {
|
|
59193
|
+
if (isImageUrl(v.trim()))
|
|
59194
|
+
urls.add(v.trim());
|
|
59195
|
+
} else if (Array.isArray(v)) {
|
|
59196
|
+
for (const x of v)
|
|
59197
|
+
walk(x);
|
|
59198
|
+
} else if (v && typeof v === "object") {
|
|
59199
|
+
for (const x of Object.values(v))
|
|
59200
|
+
walk(x);
|
|
59201
|
+
}
|
|
59202
|
+
};
|
|
59203
|
+
for (const b of blocks)
|
|
59204
|
+
if (b.props)
|
|
59205
|
+
walk(b.props);
|
|
59206
|
+
return urls.size;
|
|
59207
|
+
}
|
|
59208
|
+
function rewriteBlockUrls(blocks, urlToPath) {
|
|
59209
|
+
const replace = (v) => {
|
|
59210
|
+
if (typeof v === "string")
|
|
59211
|
+
return urlToPath[v.trim()] ?? v;
|
|
59212
|
+
if (Array.isArray(v))
|
|
59213
|
+
return v.map(replace);
|
|
59214
|
+
if (v && typeof v === "object") {
|
|
59215
|
+
const out = {};
|
|
59216
|
+
for (const [k, val2] of Object.entries(v))
|
|
59217
|
+
out[k] = replace(val2);
|
|
59218
|
+
return out;
|
|
59219
|
+
}
|
|
59220
|
+
return v;
|
|
59221
|
+
};
|
|
59222
|
+
return blocks.map((b) => ({
|
|
59223
|
+
...b,
|
|
59224
|
+
props: b.props ? replace(b.props) : b.props
|
|
59225
|
+
}));
|
|
59226
|
+
}
|
|
59227
|
+
function contentImageName(url, index2, used) {
|
|
59228
|
+
let base = "img";
|
|
59229
|
+
try {
|
|
59230
|
+
base = new URL(url, "https://x").pathname.split("/").filter(Boolean).pop() ?? "img";
|
|
59231
|
+
} catch {}
|
|
59232
|
+
base = base.split("?")[0].replace(/[^\w.-]/g, "_").slice(-60) || "img";
|
|
59233
|
+
if (!/\.(jpe?g|png|webp|gif|svg|avif)$/i.test(base))
|
|
59234
|
+
base += ".img";
|
|
59235
|
+
let name = base;
|
|
59236
|
+
if (used.has(name))
|
|
59237
|
+
name = `${index2}-${base}`;
|
|
59238
|
+
used.add(name);
|
|
59239
|
+
return name;
|
|
59240
|
+
}
|
|
59241
|
+
async function downloadContentImages(urls, runDir, fetchBytes) {
|
|
59242
|
+
const map2 = {};
|
|
59243
|
+
if (urls.length === 0)
|
|
59244
|
+
return { map: map2, downloaded: 0, skipped: 0 };
|
|
59245
|
+
const dir = join19(runDir, "assets", "content");
|
|
59246
|
+
mkdirSync13(dir, { recursive: true });
|
|
59247
|
+
const used = new Set;
|
|
59248
|
+
const take = urls.slice(0, MAX_IMAGES);
|
|
59249
|
+
let downloaded = 0;
|
|
59250
|
+
for (const [i, url] of take.entries()) {
|
|
59251
|
+
const got = await fetchBytes(url.startsWith("//") ? `https:${url}` : url);
|
|
59252
|
+
if (!got)
|
|
59253
|
+
continue;
|
|
59254
|
+
const name = contentImageName(url, i, used);
|
|
59255
|
+
writeFileSync18(join19(dir, name), got.buf);
|
|
59256
|
+
map2[url] = `assets/content/${name}`;
|
|
59257
|
+
downloaded++;
|
|
59258
|
+
}
|
|
59259
|
+
return { map: map2, downloaded, skipped: Math.max(0, urls.length - take.length) };
|
|
59260
|
+
}
|
|
59261
|
+
|
|
59262
|
+
// src/migrate/exporters/markdown.ts
|
|
59091
59263
|
var markdownExporter2 = {
|
|
59092
59264
|
name: "markdown",
|
|
59093
59265
|
async export(bundle, outDir) {
|
|
@@ -59095,16 +59267,16 @@ var markdownExporter2 = {
|
|
|
59095
59267
|
const notes = [];
|
|
59096
59268
|
bundle.components.forEach((component, i) => {
|
|
59097
59269
|
const dirName = dirNames[i];
|
|
59098
|
-
const componentDir =
|
|
59099
|
-
|
|
59270
|
+
const componentDir = join20(outDir, "components", dirName);
|
|
59271
|
+
mkdirSync14(componentDir, { recursive: true });
|
|
59100
59272
|
const compact = compactComponentHtml(component.html);
|
|
59101
59273
|
if (compact.collapsed > 0)
|
|
59102
59274
|
notes.push(`\`${dirName}\`: collapsed ${compact.collapsed} repeated child element(s)`);
|
|
59103
59275
|
if (compact.truncated)
|
|
59104
59276
|
notes.push(`\`${dirName}\`: HTML truncated to fit the per-component token ceiling`);
|
|
59105
|
-
|
|
59277
|
+
writeFileSync19(join20(componentDir, "README.md"), renderComponentReadme2(bundle.url, component, compact.html), "utf8");
|
|
59106
59278
|
});
|
|
59107
|
-
|
|
59279
|
+
writeFileSync19(join20(outDir, "index.md"), renderIndex2(bundle, dirNames, notes), "utf8");
|
|
59108
59280
|
}
|
|
59109
59281
|
};
|
|
59110
59282
|
function renderIndex2(bundle, dirNames, notes) {
|
|
@@ -59137,7 +59309,7 @@ function renderIndex2(bundle, dirNames, notes) {
|
|
|
59137
59309
|
if (bundle.vtex) {
|
|
59138
59310
|
md("## VTEX IO → FastStore blocks");
|
|
59139
59311
|
md("");
|
|
59140
|
-
md(`_${bundle.vtex.blocks.length} block instances
|
|
59312
|
+
md(`_${bundle.vtex.blocks.length} block instances · ${bundle.vtex.blocks.filter((x) => x.props).length} carry CMS content (props), ${countContentImages(bundle.vtex.blocks)} content images downloaded to \`assets/content/\` (URLs rewritten in \`blocks.json\`). \`confidence\` (0–1) = mapper certainty; \`custom-component\` = build from captured DOM/CSS._`);
|
|
59141
59313
|
md("");
|
|
59142
59314
|
md("| VTEX block | → FastStore | confidence | count |");
|
|
59143
59315
|
md("|---|---|---|---|");
|
|
@@ -59275,14 +59447,14 @@ function escapePipes2(s) {
|
|
|
59275
59447
|
}
|
|
59276
59448
|
|
|
59277
59449
|
// src/migrate/exporters/html.ts
|
|
59278
|
-
import { readFileSync as readFileSync13, writeFileSync as
|
|
59279
|
-
import { join as
|
|
59450
|
+
import { readFileSync as readFileSync13, writeFileSync as writeFileSync20 } from "node:fs";
|
|
59451
|
+
import { join as join21 } from "node:path";
|
|
59280
59452
|
var htmlExporter = {
|
|
59281
59453
|
name: "html",
|
|
59282
59454
|
async export(bundle, outDir) {
|
|
59283
|
-
|
|
59284
|
-
const inline = (p) => p ? dataUri(
|
|
59285
|
-
|
|
59455
|
+
writeFileSync20(join21(outDir, "index.html"), renderHtml(bundle, (p) => p ?? null), "utf8");
|
|
59456
|
+
const inline = (p) => p ? dataUri(join21(outDir, p)) ?? p : null;
|
|
59457
|
+
writeFileSync20(join21(outDir, "report.html"), renderHtml(bundle, inline), "utf8");
|
|
59286
59458
|
}
|
|
59287
59459
|
};
|
|
59288
59460
|
var MIME = {
|
|
@@ -59411,7 +59583,7 @@ function renderHtml(b, embed) {
|
|
|
59411
59583
|
${iconRows ? `<table style="margin-top:16px"><tr><th>kind</th><th>id</th><th>count</th></tr>${iconRows}</table>` : ""}
|
|
59412
59584
|
</section>
|
|
59413
59585
|
|
|
59414
|
-
${b.vtex ? `<section class="card"><h2>VTEX IO → FastStore blocks</h2><p class="dim">${b.vtex.blocks.length} block instances from the store runtime · ${b.vtex.blocks.filter((x) => x.props).length} carry CMS content (props)
|
|
59586
|
+
${b.vtex ? `<section class="card"><h2>VTEX IO → FastStore blocks</h2><p class="dim">${b.vtex.blocks.length} block instances from the store runtime · ${b.vtex.blocks.filter((x) => x.props).length} carry CMS content (props), ${countContentImages(b.vtex.blocks)} content images downloaded to <code>assets/content/</code> (URLs rewritten in <code>blocks.json</code>). <b>confidence</b> = how sure the deterministic mapper is (0–1).</p><table><tr><th>VTEX block</th><th>→ FastStore</th><th>confidence</th><th>count</th></tr>${vtexRows}</table></section>` : ""}
|
|
59415
59587
|
|
|
59416
59588
|
<section class="card">
|
|
59417
59589
|
<h2>Components (${b.components.length})</h2>
|
|
@@ -59885,6 +60057,26 @@ function parentTreePath(treePath) {
|
|
|
59885
60057
|
const i = treePath.lastIndexOf("/");
|
|
59886
60058
|
return i > 0 ? treePath.slice(0, i) : null;
|
|
59887
60059
|
}
|
|
60060
|
+
async function readVtexStateImages(page) {
|
|
60061
|
+
try {
|
|
60062
|
+
return await page.evaluate(() => {
|
|
60063
|
+
const w = window;
|
|
60064
|
+
const st = w.__STATE__ ?? w.__APOLLO_STATE__;
|
|
60065
|
+
if (!st)
|
|
60066
|
+
return [];
|
|
60067
|
+
let s;
|
|
60068
|
+
try {
|
|
60069
|
+
s = JSON.stringify(st);
|
|
60070
|
+
} catch {
|
|
60071
|
+
return [];
|
|
60072
|
+
}
|
|
60073
|
+
const re = /https?:\/\/[^"'\\ ]*(?:vtexassets\.com|vteximg\.com\.br)[^"'\\ ]*\.(?:jpe?g|png|webp|gif|avif)/gi;
|
|
60074
|
+
return [...new Set(s.match(re) ?? [])].slice(0, 300);
|
|
60075
|
+
});
|
|
60076
|
+
} catch {
|
|
60077
|
+
return [];
|
|
60078
|
+
}
|
|
60079
|
+
}
|
|
59888
60080
|
async function readVtexBlockTree(page) {
|
|
59889
60081
|
let paths;
|
|
59890
60082
|
try {
|
|
@@ -60091,7 +60283,7 @@ async function migrateCommand(opts) {
|
|
|
60091
60283
|
const allowlist = parseAllowlist2(opts.components);
|
|
60092
60284
|
const host = safeHost5(opts.url);
|
|
60093
60285
|
const runDir = resolve3(opts.outDir, host);
|
|
60094
|
-
|
|
60286
|
+
mkdirSync15(runDir, { recursive: true });
|
|
60095
60287
|
const browser = await launchBrowser({ headless: true });
|
|
60096
60288
|
try {
|
|
60097
60289
|
const themePath = resolve3(runDir, "theme.json");
|
|
@@ -60113,7 +60305,7 @@ async function migrateCommand(opts) {
|
|
|
60113
60305
|
console.log(chalk16.dim(" phase 1 theme+assets: cached"));
|
|
60114
60306
|
} else {
|
|
60115
60307
|
console.log(chalk16.dim(` phase 1 theme+assets: scraping (${viewports.join(", ")})…`));
|
|
60116
|
-
|
|
60308
|
+
mkdirSync15(resolve3(runDir, "screenshots"), { recursive: true });
|
|
60117
60309
|
const samples = [];
|
|
60118
60310
|
screenshots = [];
|
|
60119
60311
|
let platformSeen = null;
|
|
@@ -60157,6 +60349,18 @@ async function migrateCommand(opts) {
|
|
|
60157
60349
|
}
|
|
60158
60350
|
}
|
|
60159
60351
|
vtexBlocks = await readVtexBlockTree(page);
|
|
60352
|
+
if (vtexBlocks) {
|
|
60353
|
+
const refMap = collectImageRefs(vtexBlocks, opts.url);
|
|
60354
|
+
vtexBlocks = rewriteBlockUrls(vtexBlocks, refMap);
|
|
60355
|
+
const stateImages = await readVtexStateImages(page);
|
|
60356
|
+
const absUrls = [...new Set([...Object.values(refMap), ...stateImages])];
|
|
60357
|
+
const { map: map2, downloaded, skipped } = await downloadContentImages(absUrls, runDir, fetchBytes);
|
|
60358
|
+
if (Object.keys(map2).length)
|
|
60359
|
+
writeFileSync21(resolve3(runDir, "content-assets.json"), `${JSON.stringify(map2, null, 2)}
|
|
60360
|
+
`, "utf8");
|
|
60361
|
+
if (absUrls.length)
|
|
60362
|
+
console.log(chalk16.dim(` vtex content: ${absUrls.length} image URLs (${Object.keys(refMap).length} CMS + ${stateImages.length} catalog) · ${downloaded} downloaded${skipped ? ` (${skipped} over cap skipped)` : ""}`));
|
|
60363
|
+
}
|
|
60160
60364
|
}
|
|
60161
60365
|
} finally {
|
|
60162
60366
|
await page.close().catch(() => {
|
|
@@ -60170,12 +60374,12 @@ async function migrateCommand(opts) {
|
|
|
60170
60374
|
theme = aggregateTheme(mergeRawThemeSamples(samples));
|
|
60171
60375
|
platform = platformSeen ?? "custom";
|
|
60172
60376
|
assets = assetsResolved;
|
|
60173
|
-
|
|
60377
|
+
writeFileSync21(themePath, `${JSON.stringify(theme, null, 2)}
|
|
60174
60378
|
`, "utf8");
|
|
60175
|
-
|
|
60379
|
+
writeFileSync21(assetsPath, `${JSON.stringify({ platform, assets, screenshots }, null, 2)}
|
|
60176
60380
|
`, "utf8");
|
|
60177
60381
|
if (vtexBlocks) {
|
|
60178
|
-
|
|
60382
|
+
writeFileSync21(blocksPath, `${JSON.stringify(vtexBlocks, null, 2)}
|
|
60179
60383
|
`, "utf8");
|
|
60180
60384
|
console.log(chalk16.dim(` vtex io: ${vtexBlocks.length} blocks read from runtime`));
|
|
60181
60385
|
}
|
|
@@ -60207,7 +60411,7 @@ async function migrateCommand(opts) {
|
|
|
60207
60411
|
});
|
|
60208
60412
|
}
|
|
60209
60413
|
const classified = sitemapUrls.slice(0, 500).map((u) => ({ url: u, kind: kindOf(u) }));
|
|
60210
|
-
|
|
60414
|
+
writeFileSync21(sitemapPath, `${JSON.stringify({ pages: resolvedPages, sitemapUrls: classified }, null, 2)}
|
|
60211
60415
|
`, "utf8");
|
|
60212
60416
|
}
|
|
60213
60417
|
if (resolvedPages.length === 0) {
|
|
@@ -60229,7 +60433,7 @@ async function migrateCommand(opts) {
|
|
|
60229
60433
|
llm: !opts.noLlm,
|
|
60230
60434
|
runDir
|
|
60231
60435
|
}));
|
|
60232
|
-
|
|
60436
|
+
writeFileSync21(capturePath, `${JSON.stringify({ pages, components }, null, 2)}
|
|
60233
60437
|
`, "utf8");
|
|
60234
60438
|
}
|
|
60235
60439
|
const bundle = {
|
|
@@ -60251,13 +60455,13 @@ async function migrateCommand(opts) {
|
|
|
60251
60455
|
if (format === "md" || format === "both") {
|
|
60252
60456
|
await markdownExporter2.export(bundle, runDir);
|
|
60253
60457
|
await htmlExporter.export(bundle, runDir);
|
|
60254
|
-
|
|
60458
|
+
writeFileSync21(resolve3(runDir, "MIGRATION_PROMPT.md"), buildMigrationPrompt(bundle, playbook), "utf8");
|
|
60255
60459
|
}
|
|
60256
60460
|
if (opts.target === "faststore") {
|
|
60257
|
-
|
|
60461
|
+
writeFileSync21(resolve3(runDir, "custom-theme.scss"), buildFastStoreTheme(theme), "utf8");
|
|
60258
60462
|
}
|
|
60259
60463
|
if (bundle.vtex) {
|
|
60260
|
-
|
|
60464
|
+
writeFileSync21(resolve3(runDir, "component-map.json"), `${JSON.stringify(bundle.vtex.map, null, 2)}
|
|
60261
60465
|
`, "utf8");
|
|
60262
60466
|
}
|
|
60263
60467
|
if (opts.json) {
|
|
@@ -60443,7 +60647,8 @@ function printResults4(runDir, bundle) {
|
|
|
60443
60647
|
if (bundle.vtex) {
|
|
60444
60648
|
const mapped = bundle.vtex.map.filter((m) => m.strategy === "mapped").length;
|
|
60445
60649
|
const withContent = bundle.vtex.blocks.filter((x) => x.props).length;
|
|
60446
|
-
|
|
60650
|
+
const contentImgs = countContentImages(bundle.vtex.blocks);
|
|
60651
|
+
console.log(chalk16.dim(` vtex io: ${bundle.vtex.blocks.length} blocks (${withContent} with CMS content, ${contentImgs} content images local) · ${mapped}/${bundle.vtex.map.length} mapped`));
|
|
60447
60652
|
}
|
|
60448
60653
|
console.log(chalk16.dim(` pages: ${bundle.pages.map((p) => p.kind).join(", ") || "—"}`));
|
|
60449
60654
|
console.log(chalk16.dim(` out: ${runDir}`));
|
|
@@ -60502,13 +60707,13 @@ function sleep2(ms) {
|
|
|
60502
60707
|
}
|
|
60503
60708
|
|
|
60504
60709
|
// src/commands/pr.ts
|
|
60505
|
-
import { existsSync as existsSync15, readFileSync as readFileSync17, writeFileSync as
|
|
60506
|
-
import { join as
|
|
60710
|
+
import { existsSync as existsSync15, readFileSync as readFileSync17, writeFileSync as writeFileSync22 } from "node:fs";
|
|
60711
|
+
import { join as join24 } from "node:path";
|
|
60507
60712
|
import chalk19 from "chalk";
|
|
60508
60713
|
|
|
60509
60714
|
// src/commands/run.ts
|
|
60510
60715
|
import { existsSync as existsSync14, readFileSync as readFileSync16, unlinkSync as unlinkSync3 } from "node:fs";
|
|
60511
|
-
import { join as
|
|
60716
|
+
import { join as join23 } from "node:path";
|
|
60512
60717
|
import chalk18 from "chalk";
|
|
60513
60718
|
import ora6 from "ora";
|
|
60514
60719
|
|
|
@@ -60990,7 +61195,7 @@ import chalk17 from "chalk";
|
|
|
60990
61195
|
// src/server/proxy-server.ts
|
|
60991
61196
|
import { existsSync as existsSync12, readFileSync as readFileSync15, statSync } from "node:fs";
|
|
60992
61197
|
import { createServer } from "node:http";
|
|
60993
|
-
import { extname, join as
|
|
61198
|
+
import { extname, join as join22, normalize as normalize3, resolve as resolve4, sep } from "node:path";
|
|
60994
61199
|
var MIME2 = {
|
|
60995
61200
|
".html": "text/html; charset=utf-8",
|
|
60996
61201
|
".css": "text/css; charset=utf-8",
|
|
@@ -61084,7 +61289,7 @@ async function handleRequest(req, res, runDir) {
|
|
|
61084
61289
|
return serveStatic(res, runDir, path);
|
|
61085
61290
|
}
|
|
61086
61291
|
function serveReportHtml(res, runDir) {
|
|
61087
|
-
const filePath =
|
|
61292
|
+
const filePath = join22(runDir, "report.html");
|
|
61088
61293
|
if (!existsSync12(filePath)) {
|
|
61089
61294
|
res.statusCode = 404;
|
|
61090
61295
|
res.end("report.html not found");
|
|
@@ -61481,7 +61686,7 @@ async function runCommand(rawOpts) {
|
|
|
61481
61686
|
}
|
|
61482
61687
|
const ignore = loadParityIgnore();
|
|
61483
61688
|
if (opts.clearCache) {
|
|
61484
|
-
const cacheFile =
|
|
61689
|
+
const cacheFile = join23(opts.output, "cache", "verdicts.json");
|
|
61485
61690
|
if (existsSync14(cacheFile)) {
|
|
61486
61691
|
try {
|
|
61487
61692
|
unlinkSync3(cacheFile);
|
|
@@ -61678,8 +61883,8 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
61678
61883
|
const traceEnabled = process.env.PARITY_TRACE === "1";
|
|
61679
61884
|
const runOneSide = async (viewport, side) => {
|
|
61680
61885
|
const baseUrl = side === "prod" ? opts.prod : opts.cand;
|
|
61681
|
-
const harPath =
|
|
61682
|
-
const tracePath = traceEnabled ?
|
|
61886
|
+
const harPath = join23(paths.harDir, `${viewport}-${side}.har`);
|
|
61887
|
+
const tracePath = traceEnabled ? join23(paths.tracesDir, `${viewport}-${side}.zip`) : null;
|
|
61683
61888
|
const ctx = await newContext(browser, {
|
|
61684
61889
|
viewport,
|
|
61685
61890
|
harPath,
|
|
@@ -61995,7 +62200,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
61995
62200
|
setSpinnerLabel("Rodando checks…");
|
|
61996
62201
|
spinner.start();
|
|
61997
62202
|
const checksHb = attachSpinnerHeartbeat(spinner, { baseText: "Rodando checks…" });
|
|
61998
|
-
const cacheDir =
|
|
62203
|
+
const cacheDir = join23(opts.output, "cache");
|
|
61999
62204
|
const checkCtx = {
|
|
62000
62205
|
prodPages: allPageCaptures.filter((p) => p.side === "prod"),
|
|
62001
62206
|
candPages: allPageCaptures.filter((p) => p.side === "cand"),
|
|
@@ -62402,7 +62607,7 @@ async function prCommand(opts) {
|
|
|
62402
62607
|
return runCode || 1;
|
|
62403
62608
|
}
|
|
62404
62609
|
const latest = runs[0];
|
|
62405
|
-
const reportJsonPath =
|
|
62610
|
+
const reportJsonPath = join24(opts.output, "runs", latest.id, "report.json");
|
|
62406
62611
|
if (!existsSync15(reportJsonPath)) {
|
|
62407
62612
|
console.error(chalk19.red(`report.json not found at ${reportJsonPath}`));
|
|
62408
62613
|
return runCode || 1;
|
|
@@ -62410,7 +62615,7 @@ async function prCommand(opts) {
|
|
|
62410
62615
|
const run = JSON.parse(readFileSync17(reportJsonPath, "utf8"));
|
|
62411
62616
|
const markdown = buildPrComment(run, opts);
|
|
62412
62617
|
if (opts.out) {
|
|
62413
|
-
|
|
62618
|
+
writeFileSync22(opts.out, markdown, "utf8");
|
|
62414
62619
|
console.log(chalk19.dim(` wrote PR comment: ${opts.out}`));
|
|
62415
62620
|
} else {
|
|
62416
62621
|
process.stdout.write(`
|
|
@@ -62419,7 +62624,7 @@ ${markdown}
|
|
|
62419
62624
|
}
|
|
62420
62625
|
if (opts.github && process.env.GITHUB_STEP_SUMMARY) {
|
|
62421
62626
|
try {
|
|
62422
|
-
|
|
62627
|
+
writeFileSync22(process.env.GITHUB_STEP_SUMMARY, markdown, { flag: "a" });
|
|
62423
62628
|
} catch (err) {
|
|
62424
62629
|
console.error(chalk19.yellow(`failed to write GITHUB_STEP_SUMMARY: ${err.message}`));
|
|
62425
62630
|
}
|
|
@@ -62480,7 +62685,7 @@ function buildPrComment(run, opts) {
|
|
|
62480
62685
|
}
|
|
62481
62686
|
|
|
62482
62687
|
// src/commands/prompt.ts
|
|
62483
|
-
import { existsSync as existsSync16, writeFileSync as
|
|
62688
|
+
import { existsSync as existsSync16, writeFileSync as writeFileSync23 } from "node:fs";
|
|
62484
62689
|
import chalk20 from "chalk";
|
|
62485
62690
|
function promptCommand(runId, opts) {
|
|
62486
62691
|
let run;
|
|
@@ -62495,7 +62700,7 @@ function promptCommand(runId, opts) {
|
|
|
62495
62700
|
limit: opts.limit
|
|
62496
62701
|
});
|
|
62497
62702
|
if (opts.out) {
|
|
62498
|
-
|
|
62703
|
+
writeFileSync23(opts.out, md, "utf8");
|
|
62499
62704
|
console.log(chalk20.green(`✔ prompt salvo em ${opts.out}`));
|
|
62500
62705
|
if (existsSync16(opts.out)) {
|
|
62501
62706
|
const sizeKb = (md.length / 1024).toFixed(1);
|
|
@@ -62690,8 +62895,8 @@ async function reportCommand(runId, opts) {
|
|
|
62690
62895
|
}
|
|
62691
62896
|
|
|
62692
62897
|
// src/commands/vitals.ts
|
|
62693
|
-
import { existsSync as existsSync18, readFileSync as readFileSync19, writeFileSync as
|
|
62694
|
-
import { join as
|
|
62898
|
+
import { existsSync as existsSync18, readFileSync as readFileSync19, writeFileSync as writeFileSync24 } from "node:fs";
|
|
62899
|
+
import { join as join25 } from "node:path";
|
|
62695
62900
|
import chalk22 from "chalk";
|
|
62696
62901
|
import ora7 from "ora";
|
|
62697
62902
|
async function vitalsCommand(opts) {
|
|
@@ -62799,7 +63004,7 @@ async function vitalsCommand(opts) {
|
|
|
62799
63004
|
writeRunReportJson(paths.runDir, run);
|
|
62800
63005
|
const html3 = renderHtmlReport(run, paths.runDir);
|
|
62801
63006
|
writeRunReportHtml(paths.runDir, html3);
|
|
62802
|
-
|
|
63007
|
+
writeFileSync24(join25(paths.runDir, "vitals.json"), `${JSON.stringify({
|
|
62803
63008
|
schemaVersion: "0.1",
|
|
62804
63009
|
prodUrl: opts.prod,
|
|
62805
63010
|
candUrl: opts.cand,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/parity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
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",
|