@decocms/parity 0.33.64 → 0.33.66
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 +742 -579
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -58994,10 +58994,161 @@ function printResult(result, meta) {
|
|
|
58994
58994
|
}
|
|
58995
58995
|
}
|
|
58996
58996
|
|
|
58997
|
+
// src/commands/content-freshness.ts
|
|
58998
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
58999
|
+
import { isDeepStrictEqual } from "node:util";
|
|
59000
|
+
import chalk10 from "chalk";
|
|
59001
|
+
function compareDecofiles(main, served) {
|
|
59002
|
+
const missing = [];
|
|
59003
|
+
const differing = [];
|
|
59004
|
+
const claimed = new Set;
|
|
59005
|
+
for (const [id, files] of main) {
|
|
59006
|
+
const servedKey = [...files.map((f) => f.name), id].find((k) => Object.hasOwn(served, k));
|
|
59007
|
+
if (servedKey === undefined) {
|
|
59008
|
+
missing.push(id);
|
|
59009
|
+
continue;
|
|
59010
|
+
}
|
|
59011
|
+
claimed.add(servedKey);
|
|
59012
|
+
if (!files.some((f) => isDeepStrictEqual(f.value, served[servedKey])))
|
|
59013
|
+
differing.push(id);
|
|
59014
|
+
}
|
|
59015
|
+
const servedOnly = Object.keys(served).filter((k) => !claimed.has(k));
|
|
59016
|
+
return { missing: missing.sort(), differing: differing.sort(), servedOnly: servedOnly.sort() };
|
|
59017
|
+
}
|
|
59018
|
+
function decodeOnce(s) {
|
|
59019
|
+
try {
|
|
59020
|
+
return decodeURIComponent(s);
|
|
59021
|
+
} catch {
|
|
59022
|
+
return s;
|
|
59023
|
+
}
|
|
59024
|
+
}
|
|
59025
|
+
function decodeFully(s) {
|
|
59026
|
+
let cur = s;
|
|
59027
|
+
for (let next = decodeOnce(cur);next !== cur; next = decodeOnce(cur))
|
|
59028
|
+
cur = next;
|
|
59029
|
+
return cur;
|
|
59030
|
+
}
|
|
59031
|
+
function readMainBlocks(repo, ref) {
|
|
59032
|
+
const git = (args, input) => execFileSync3("git", ["-C", repo, ...args], {
|
|
59033
|
+
input,
|
|
59034
|
+
maxBuffer: 512 * 1024 * 1024,
|
|
59035
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
59036
|
+
});
|
|
59037
|
+
const files = git(["ls-tree", "-z", "--name-only", `${ref}:.deco/blocks`]).toString("utf8").split("\x00").filter((f) => f.endsWith(".json"));
|
|
59038
|
+
const blocks = new Map;
|
|
59039
|
+
if (files.length === 0)
|
|
59040
|
+
return blocks;
|
|
59041
|
+
const out = git(["cat-file", "--batch"], files.map((f) => `${ref}:.deco/blocks/${f}
|
|
59042
|
+
`).join(""));
|
|
59043
|
+
let pos = 0;
|
|
59044
|
+
for (const file of files) {
|
|
59045
|
+
const nl = out.indexOf(10, pos);
|
|
59046
|
+
const header = out.subarray(pos, nl).toString("utf8");
|
|
59047
|
+
const size = Number(header.split(" ")[2]);
|
|
59048
|
+
const body = out.subarray(nl + 1, nl + 1 + size).toString("utf8");
|
|
59049
|
+
pos = nl + 1 + size + 1;
|
|
59050
|
+
let parsed;
|
|
59051
|
+
try {
|
|
59052
|
+
parsed = JSON.parse(body);
|
|
59053
|
+
} catch {
|
|
59054
|
+
continue;
|
|
59055
|
+
}
|
|
59056
|
+
const stem = file.replace(/\.json$/, "");
|
|
59057
|
+
const id = decodeFully(stem);
|
|
59058
|
+
blocks.set(id, [...blocks.get(id) ?? [], { name: decodeOnce(stem), value: parsed }]);
|
|
59059
|
+
}
|
|
59060
|
+
return blocks;
|
|
59061
|
+
}
|
|
59062
|
+
async function contentFreshness(opts) {
|
|
59063
|
+
const base = {
|
|
59064
|
+
status: "inconclusive",
|
|
59065
|
+
cand: opts.cand,
|
|
59066
|
+
ref: opts.ref,
|
|
59067
|
+
servedRevision: null,
|
|
59068
|
+
mainCount: 0,
|
|
59069
|
+
servedCount: 0,
|
|
59070
|
+
missing: [],
|
|
59071
|
+
differing: [],
|
|
59072
|
+
servedOnly: []
|
|
59073
|
+
};
|
|
59074
|
+
const inconclusive = (reason) => ({ ...base, reason });
|
|
59075
|
+
let main;
|
|
59076
|
+
try {
|
|
59077
|
+
main = readMainBlocks(opts.repo, opts.ref);
|
|
59078
|
+
} catch (err) {
|
|
59079
|
+
const stderr = err.stderr?.toString().trim();
|
|
59080
|
+
return inconclusive(`could not read ${opts.ref} in ${opts.repo}: ${stderr || err.message}`);
|
|
59081
|
+
}
|
|
59082
|
+
base.mainCount = main.size;
|
|
59083
|
+
if (main.size === 0)
|
|
59084
|
+
return inconclusive(`no .deco/blocks/*.json on ${opts.ref}`);
|
|
59085
|
+
const url = new URL("/.decofile", opts.cand).toString();
|
|
59086
|
+
let res;
|
|
59087
|
+
try {
|
|
59088
|
+
res = await fetch(url, {
|
|
59089
|
+
headers: { accept: "application/json" },
|
|
59090
|
+
signal: AbortSignal.timeout(opts.timeoutMs ?? 20000)
|
|
59091
|
+
});
|
|
59092
|
+
} catch (err) {
|
|
59093
|
+
return inconclusive(`GET ${url} failed: ${err.message}`);
|
|
59094
|
+
}
|
|
59095
|
+
if (!res.ok) {
|
|
59096
|
+
return inconclusive(`GET ${url} returned ${res.status} — the candidate does not expose its decofile (admin routes not wired, or behind auth)`);
|
|
59097
|
+
}
|
|
59098
|
+
let served;
|
|
59099
|
+
try {
|
|
59100
|
+
served = await res.json();
|
|
59101
|
+
} catch {
|
|
59102
|
+
return inconclusive(`GET ${url} did not return JSON (${res.headers.get("content-type") ?? "no content-type"})`);
|
|
59103
|
+
}
|
|
59104
|
+
if (!served || typeof served !== "object" || Array.isArray(served)) {
|
|
59105
|
+
return inconclusive(`GET ${url} returned JSON that is not a decofile object`);
|
|
59106
|
+
}
|
|
59107
|
+
const etag = res.headers.get("etag");
|
|
59108
|
+
const diff = compareDecofiles(main, served);
|
|
59109
|
+
return {
|
|
59110
|
+
...base,
|
|
59111
|
+
...diff,
|
|
59112
|
+
servedRevision: etag ? etag.replace(/^W\//, "").replace(/"/g, "") : null,
|
|
59113
|
+
servedCount: Object.keys(served).length,
|
|
59114
|
+
status: diff.missing.length + diff.differing.length > 0 ? "stale" : "fresh"
|
|
59115
|
+
};
|
|
59116
|
+
}
|
|
59117
|
+
var LIST_LIMIT = 20;
|
|
59118
|
+
function printList(label, keys) {
|
|
59119
|
+
if (keys.length === 0)
|
|
59120
|
+
return;
|
|
59121
|
+
console.log(`
|
|
59122
|
+
${label} (${keys.length}):`);
|
|
59123
|
+
for (const k of keys.slice(0, LIST_LIMIT))
|
|
59124
|
+
console.log(` - ${k}`);
|
|
59125
|
+
if (keys.length > LIST_LIMIT)
|
|
59126
|
+
console.log(chalk10.dim(` … ${keys.length - LIST_LIMIT} more (--json for all)`));
|
|
59127
|
+
}
|
|
59128
|
+
async function contentFreshnessCommand(opts) {
|
|
59129
|
+
const r = await contentFreshness(opts);
|
|
59130
|
+
if (opts.json) {
|
|
59131
|
+
console.log(JSON.stringify(r));
|
|
59132
|
+
} else {
|
|
59133
|
+
const color = r.status === "fresh" ? chalk10.green : r.status === "stale" ? chalk10.red : chalk10.yellow;
|
|
59134
|
+
console.log(chalk10.bold(`
|
|
59135
|
+
content-freshness`));
|
|
59136
|
+
console.log(chalk10.dim(` ${opts.repo} @ ${r.ref} ↔ ${r.cand}/.decofile`));
|
|
59137
|
+
console.log(`
|
|
59138
|
+
status: ${color(r.status)} · main ${r.mainCount} blocks · served ${r.servedCount} · revision ${r.servedRevision ?? "(not exposed)"}`);
|
|
59139
|
+
if (r.reason)
|
|
59140
|
+
console.log(chalk10.yellow(` ${r.reason}`));
|
|
59141
|
+
printList("on main, not served", r.missing);
|
|
59142
|
+
printList("served with different content", r.differing);
|
|
59143
|
+
printList(chalk10.dim("served, not on main (build-generated blocks land here too)"), r.servedOnly);
|
|
59144
|
+
}
|
|
59145
|
+
return r.status === "fresh" ? 0 : r.status === "stale" ? 1 : 2;
|
|
59146
|
+
}
|
|
59147
|
+
|
|
58997
59148
|
// src/commands/css-modules.ts
|
|
58998
59149
|
import { readFileSync as readFileSync16, readdirSync as readdirSync3 } from "node:fs";
|
|
58999
59150
|
import { basename as basename2, dirname as dirname4, join as join19, resolve as resolve3 } from "node:path";
|
|
59000
|
-
import
|
|
59151
|
+
import chalk11 from "chalk";
|
|
59001
59152
|
var SKIP_DIRS = new Set(["node_modules", ".git", ".next", ".faststore", "dist", "build"]);
|
|
59002
59153
|
var MODULE_RE = /\.module\.(scss|sass|css)$/;
|
|
59003
59154
|
var COMPONENT_RE = /\.(tsx|jsx|ts|js)$/;
|
|
@@ -59061,59 +59212,59 @@ function cssModulesCommand(opts) {
|
|
|
59061
59212
|
console.log(JSON.stringify(scan));
|
|
59062
59213
|
else {
|
|
59063
59214
|
for (const f of scan.findings)
|
|
59064
|
-
console.log(`${
|
|
59065
|
-
console.log(
|
|
59215
|
+
console.log(`${chalk11.red("✗")} ${f.file}:${f.line} "${f.className}" is declared in ${f.module} — use styles["${f.className}"]`);
|
|
59216
|
+
console.log(chalk11.dim(`${scan.modules} modules, ${scan.components} components, ${scan.findings.length} dead literals`));
|
|
59066
59217
|
}
|
|
59067
59218
|
if (scan.components === 0) {
|
|
59068
59219
|
if (!opts.json)
|
|
59069
|
-
console.error(
|
|
59220
|
+
console.error(chalk11.yellow("nothing scanned — no component imports a CSS module here"));
|
|
59070
59221
|
return 2;
|
|
59071
59222
|
}
|
|
59072
59223
|
return scan.findings.length > 0 ? 1 : 0;
|
|
59073
59224
|
}
|
|
59074
59225
|
|
|
59075
59226
|
// src/commands/compare.ts
|
|
59076
|
-
import
|
|
59227
|
+
import chalk12 from "chalk";
|
|
59077
59228
|
function compareCommand(runId, baselineName, output) {
|
|
59078
59229
|
try {
|
|
59079
59230
|
const run = loadRun(output, runId);
|
|
59080
59231
|
const baseline = loadBaseline(baselineName);
|
|
59081
59232
|
const delta = compareToBaseline(run, baseline);
|
|
59082
|
-
console.log(
|
|
59233
|
+
console.log(chalk12.bold(`
|
|
59083
59234
|
Delta ${runId} vs baseline "${baselineName}"`));
|
|
59084
|
-
console.log(` ${
|
|
59085
|
-
console.log(` ${
|
|
59086
|
-
console.log(` ${
|
|
59235
|
+
console.log(` ${chalk12.green("✓ resolved")}: ${delta.resolved.length}`);
|
|
59236
|
+
console.log(` ${chalk12.yellow("+ new")}: ${delta.new.length}`);
|
|
59237
|
+
console.log(` ${chalk12.red("⚠ regressed")}: ${delta.regressions.length}`);
|
|
59087
59238
|
if (delta.new.length > 0) {
|
|
59088
|
-
console.log(
|
|
59239
|
+
console.log(chalk12.bold(`
|
|
59089
59240
|
Novos issue ids:`));
|
|
59090
59241
|
for (const id of delta.new)
|
|
59091
59242
|
console.log(` - ${id}`);
|
|
59092
59243
|
}
|
|
59093
59244
|
if (delta.regressions.length > 0) {
|
|
59094
|
-
console.log(
|
|
59245
|
+
console.log(chalk12.bold(`
|
|
59095
59246
|
Regressões (severity piorou):`));
|
|
59096
59247
|
for (const id of delta.regressions)
|
|
59097
59248
|
console.log(` - ${id}`);
|
|
59098
59249
|
}
|
|
59099
59250
|
return 0;
|
|
59100
59251
|
} catch (err) {
|
|
59101
|
-
console.error(
|
|
59252
|
+
console.error(chalk12.red(`✖ ${err.message}`));
|
|
59102
59253
|
return 1;
|
|
59103
59254
|
}
|
|
59104
59255
|
}
|
|
59105
59256
|
|
|
59106
59257
|
// src/commands/console.ts
|
|
59107
|
-
import
|
|
59258
|
+
import chalk13 from "chalk";
|
|
59108
59259
|
async function consoleCommand(opts) {
|
|
59109
59260
|
const viewport = parseViewport2(opts.viewport);
|
|
59110
59261
|
if (!viewport) {
|
|
59111
|
-
console.error(
|
|
59262
|
+
console.error(chalk13.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
|
|
59112
59263
|
return 2;
|
|
59113
59264
|
}
|
|
59114
59265
|
const waitMs = Number.parseInt(opts.wait, 10);
|
|
59115
59266
|
if (!Number.isFinite(waitMs) || waitMs < 0) {
|
|
59116
|
-
console.error(
|
|
59267
|
+
console.error(chalk13.red(`--wait inválido: ${opts.wait}`));
|
|
59117
59268
|
return 2;
|
|
59118
59269
|
}
|
|
59119
59270
|
const filter = parseFilter(opts.filter);
|
|
@@ -59121,7 +59272,7 @@ async function consoleCommand(opts) {
|
|
|
59121
59272
|
try {
|
|
59122
59273
|
url = new URL(opts.url);
|
|
59123
59274
|
} catch {
|
|
59124
|
-
console.error(
|
|
59275
|
+
console.error(chalk13.red(`--url inválido: ${opts.url}`));
|
|
59125
59276
|
return 2;
|
|
59126
59277
|
}
|
|
59127
59278
|
const browser = await launchBrowser({ headless: true });
|
|
@@ -59170,24 +59321,24 @@ function printResults(entries, meta) {
|
|
|
59170
59321
|
return;
|
|
59171
59322
|
}
|
|
59172
59323
|
if (entries.length === 0) {
|
|
59173
|
-
console.log(
|
|
59324
|
+
console.log(chalk13.dim(` ${meta.viewport} · ${meta.url}
|
|
59174
59325
|
nenhuma entrada de console nos filtros pedidos`));
|
|
59175
59326
|
return;
|
|
59176
59327
|
}
|
|
59177
|
-
console.log(
|
|
59328
|
+
console.log(chalk13.bold(`
|
|
59178
59329
|
${meta.viewport} · ${meta.url}`));
|
|
59179
|
-
console.log(
|
|
59330
|
+
console.log(chalk13.dim(` ${entries.length} entrada(s)
|
|
59180
59331
|
`));
|
|
59181
59332
|
for (const e of entries) {
|
|
59182
|
-
const tag = e.type === "error" ?
|
|
59183
|
-
const loc = e.location ?
|
|
59333
|
+
const tag = e.type === "error" ? chalk13.red("[error ]") : e.type === "warning" ? chalk13.yellow("[warn ]") : chalk13.dim(`[${e.type.padEnd(7)}]`);
|
|
59334
|
+
const loc = e.location ? chalk13.dim(` ← ${e.location}`) : "";
|
|
59184
59335
|
const text = e.text.length > 400 ? `${e.text.slice(0, 397)}...` : e.text;
|
|
59185
59336
|
console.log(` ${tag} ${text}${loc}`);
|
|
59186
59337
|
}
|
|
59187
59338
|
}
|
|
59188
59339
|
|
|
59189
59340
|
// src/commands/css-trace.ts
|
|
59190
|
-
import
|
|
59341
|
+
import chalk14 from "chalk";
|
|
59191
59342
|
async function tracePage(page, url, selector, settleMs) {
|
|
59192
59343
|
await page.goto(url, { waitUntil: "domcontentloaded", timeout: 30000 });
|
|
59193
59344
|
await page.waitForLoadState("load", { timeout: 12000 }).catch(() => {
|
|
@@ -59298,35 +59449,35 @@ function applyFilter(result, filter) {
|
|
|
59298
59449
|
return { ...result, computed, rules };
|
|
59299
59450
|
}
|
|
59300
59451
|
function printResult2(result, header) {
|
|
59301
|
-
console.log(
|
|
59452
|
+
console.log(chalk14.bold(`
|
|
59302
59453
|
${header}`));
|
|
59303
|
-
console.log(
|
|
59304
|
-
console.log(
|
|
59454
|
+
console.log(chalk14.dim(`URL: ${result.url}`));
|
|
59455
|
+
console.log(chalk14.dim(`Selector: ${result.selector}`));
|
|
59305
59456
|
if (!result.found) {
|
|
59306
|
-
console.log(
|
|
59457
|
+
console.log(chalk14.red("✖ Element not found"));
|
|
59307
59458
|
return;
|
|
59308
59459
|
}
|
|
59309
59460
|
const computedKeys = Object.keys(result.computed);
|
|
59310
59461
|
if (computedKeys.length > 0) {
|
|
59311
|
-
console.log(
|
|
59462
|
+
console.log(chalk14.bold(`
|
|
59312
59463
|
Computed:`));
|
|
59313
59464
|
for (const k of computedKeys) {
|
|
59314
|
-
console.log(` ${
|
|
59465
|
+
console.log(` ${chalk14.cyan(k)}: ${result.computed[k]}`);
|
|
59315
59466
|
}
|
|
59316
59467
|
}
|
|
59317
59468
|
if (result.rules.length === 0) {
|
|
59318
|
-
console.log(
|
|
59469
|
+
console.log(chalk14.yellow(`
|
|
59319
59470
|
No matching rules after filter.`));
|
|
59320
59471
|
return;
|
|
59321
59472
|
}
|
|
59322
|
-
console.log(
|
|
59473
|
+
console.log(chalk14.bold(`
|
|
59323
59474
|
Rules (ordered by CDP — most specific last):`));
|
|
59324
59475
|
for (const r of result.rules) {
|
|
59325
|
-
const inheritLabel = r.inheritedFromDistance !== undefined ?
|
|
59326
|
-
console.log(` ${
|
|
59327
|
-
console.log(` ${
|
|
59476
|
+
const inheritLabel = r.inheritedFromDistance !== undefined ? chalk14.yellow(` ↑ inherited from ancestor (${r.inheritedFromDistance})`) : "";
|
|
59477
|
+
console.log(` ${chalk14.magenta(r.source)}${inheritLabel}`);
|
|
59478
|
+
console.log(` ${chalk14.green(r.selector)} {`);
|
|
59328
59479
|
for (const p of r.properties) {
|
|
59329
|
-
const bang = p.important ?
|
|
59480
|
+
const bang = p.important ? chalk14.red(" !important") : "";
|
|
59330
59481
|
console.log(` ${p.name}: ${p.value}${bang};`);
|
|
59331
59482
|
}
|
|
59332
59483
|
console.log(" }");
|
|
@@ -59347,38 +59498,38 @@ function printComparison(prod, cand) {
|
|
|
59347
59498
|
printResult2(prod, "── PROD ──────────────────────────────────────────────");
|
|
59348
59499
|
printResult2(cand, "── CAND ──────────────────────────────────────────────");
|
|
59349
59500
|
const diffs = diffComputed(prod, cand);
|
|
59350
|
-
console.log(
|
|
59501
|
+
console.log(chalk14.bold(`
|
|
59351
59502
|
── DIFF (computed) ───────────────────────────────────`));
|
|
59352
59503
|
if (diffs.length === 0) {
|
|
59353
|
-
console.log(
|
|
59504
|
+
console.log(chalk14.green(" No computed-style differences in the filtered set."));
|
|
59354
59505
|
return;
|
|
59355
59506
|
}
|
|
59356
59507
|
for (const d of diffs) {
|
|
59357
|
-
console.log(` ${
|
|
59358
|
-
console.log(` prod: ${
|
|
59359
|
-
console.log(` cand: ${
|
|
59508
|
+
console.log(` ${chalk14.cyan(d.property)}`);
|
|
59509
|
+
console.log(` prod: ${chalk14.green(d.prod ?? "(unset)")}`);
|
|
59510
|
+
console.log(` cand: ${chalk14.red(d.cand ?? "(unset)")}`);
|
|
59360
59511
|
}
|
|
59361
59512
|
}
|
|
59362
59513
|
async function cssTraceCommand(opts) {
|
|
59363
59514
|
const viewport = opts.viewport ?? "desktop";
|
|
59364
59515
|
const settleMs = opts.settleMs ?? 1500;
|
|
59365
59516
|
if (!opts.selector) {
|
|
59366
|
-
console.error(
|
|
59517
|
+
console.error(chalk14.red("--selector is required"));
|
|
59367
59518
|
return 1;
|
|
59368
59519
|
}
|
|
59369
59520
|
const hasUrl = !!opts.url;
|
|
59370
59521
|
const hasProd = !!opts.prod;
|
|
59371
59522
|
const hasCand = !!opts.cand;
|
|
59372
59523
|
if (hasUrl && (hasProd || hasCand)) {
|
|
59373
|
-
console.error(
|
|
59524
|
+
console.error(chalk14.red("--url is mutually exclusive with --prod / --cand. Pass one mode only."));
|
|
59374
59525
|
return 1;
|
|
59375
59526
|
}
|
|
59376
59527
|
if (hasProd && !hasCand || !hasProd && hasCand) {
|
|
59377
|
-
console.error(
|
|
59528
|
+
console.error(chalk14.red("Comparison mode needs both --prod and --cand (got only one)."));
|
|
59378
59529
|
return 1;
|
|
59379
59530
|
}
|
|
59380
59531
|
if (!hasUrl && !hasProd && !hasCand) {
|
|
59381
|
-
console.error(
|
|
59532
|
+
console.error(chalk14.red("Provide either --url or both --prod and --cand."));
|
|
59382
59533
|
return 1;
|
|
59383
59534
|
}
|
|
59384
59535
|
const isCompare = hasProd && hasCand;
|
|
@@ -59429,7 +59580,7 @@ async function cssTraceCommand(opts) {
|
|
|
59429
59580
|
}
|
|
59430
59581
|
return 0;
|
|
59431
59582
|
} catch (err) {
|
|
59432
|
-
console.error(
|
|
59583
|
+
console.error(chalk14.red(`Error: ${err.message}`));
|
|
59433
59584
|
return 1;
|
|
59434
59585
|
} finally {
|
|
59435
59586
|
await browser?.close().catch(() => {
|
|
@@ -59441,7 +59592,7 @@ async function cssTraceCommand(opts) {
|
|
|
59441
59592
|
// src/commands/e2e.ts
|
|
59442
59593
|
import { writeFileSync as writeFileSync16 } from "node:fs";
|
|
59443
59594
|
import { spawn as spawn2 } from "node:child_process";
|
|
59444
|
-
import
|
|
59595
|
+
import chalk15 from "chalk";
|
|
59445
59596
|
import ora6 from "ora";
|
|
59446
59597
|
|
|
59447
59598
|
// src/engine/flows/cart-interactions.ts
|
|
@@ -61510,19 +61661,19 @@ function formatWatchdogMessage(timeoutMs, graceMs) {
|
|
|
61510
61661
|
async function e2eCommand(opts) {
|
|
61511
61662
|
const viewports = parseViewports(opts.viewports);
|
|
61512
61663
|
if (viewports.length === 0) {
|
|
61513
|
-
console.error(
|
|
61664
|
+
console.error(chalk15.red(`--viewports inválido: ${opts.viewports} (use mobile,desktop,tablet)`));
|
|
61514
61665
|
return 2;
|
|
61515
61666
|
}
|
|
61516
61667
|
let baseUrl;
|
|
61517
61668
|
try {
|
|
61518
61669
|
baseUrl = new URL(opts.url);
|
|
61519
61670
|
} catch {
|
|
61520
|
-
console.error(
|
|
61671
|
+
console.error(chalk15.red(`--url inválido: ${opts.url}`));
|
|
61521
61672
|
return 2;
|
|
61522
61673
|
}
|
|
61523
61674
|
const flows = parseFlows(opts.flows);
|
|
61524
61675
|
if (flows.length === 0) {
|
|
61525
|
-
console.error(
|
|
61676
|
+
console.error(chalk15.red(`--flows inválido: ${opts.flows}`));
|
|
61526
61677
|
return 2;
|
|
61527
61678
|
}
|
|
61528
61679
|
const rc = loadParityRc();
|
|
@@ -61553,12 +61704,12 @@ async function e2eCommand(opts) {
|
|
|
61553
61704
|
const paths = createRunDir(opts.output, runId);
|
|
61554
61705
|
const startedAt = Date.now();
|
|
61555
61706
|
if (!opts.json) {
|
|
61556
|
-
console.log(
|
|
61707
|
+
console.log(chalk15.bold(`
|
|
61557
61708
|
parity e2e ${runId}`));
|
|
61558
|
-
console.log(
|
|
61559
|
-
console.log(
|
|
61560
|
-
console.log(
|
|
61561
|
-
console.log(
|
|
61709
|
+
console.log(chalk15.dim(` url: ${opts.url}`));
|
|
61710
|
+
console.log(chalk15.dim(` flows: ${flows.join(", ")}`));
|
|
61711
|
+
console.log(chalk15.dim(` viewports: ${viewports.join(", ")}`));
|
|
61712
|
+
console.log(chalk15.dim(` cep: ${rc.cep}
|
|
61562
61713
|
`));
|
|
61563
61714
|
}
|
|
61564
61715
|
let platform = "custom";
|
|
@@ -61566,7 +61717,7 @@ async function e2eCommand(opts) {
|
|
|
61566
61717
|
if (homeHtml) {
|
|
61567
61718
|
platform = detectPlatform({ url: opts.url, html: homeHtml });
|
|
61568
61719
|
if (platform !== "custom" && !opts.json) {
|
|
61569
|
-
console.log(
|
|
61720
|
+
console.log(chalk15.dim(` Detected platform: ${platform}`));
|
|
61570
61721
|
}
|
|
61571
61722
|
}
|
|
61572
61723
|
const wantsAutoSelectors = opts.autoSelectors !== false && isLlmAvailable();
|
|
@@ -61606,7 +61757,7 @@ async function e2eCommand(opts) {
|
|
|
61606
61757
|
watchdogTimedOut = true;
|
|
61607
61758
|
if (spinner)
|
|
61608
61759
|
spinner.stop();
|
|
61609
|
-
console.error(
|
|
61760
|
+
console.error(chalk15.red(`
|
|
61610
61761
|
${formatWatchdogMessage(E2E_TIMEOUT_MS, WATCHDOG_GRACE_MS)}`));
|
|
61611
61762
|
};
|
|
61612
61763
|
process.once("SIGUSR2", onWatchdogFired);
|
|
@@ -61674,14 +61825,14 @@ async function e2eCommand(opts) {
|
|
|
61674
61825
|
});
|
|
61675
61826
|
}
|
|
61676
61827
|
if (watchdogTimedOut && !opts.json) {
|
|
61677
|
-
console.log(
|
|
61828
|
+
console.log(chalk15.yellow(`
|
|
61678
61829
|
⚠ relatório parcial — o watchdog encerrou o run antes de todos os fluxos/viewports terminarem.`));
|
|
61679
61830
|
}
|
|
61680
61831
|
if (opts.learn !== false && JSON.stringify(learned) !== learnedBefore) {
|
|
61681
61832
|
saveLearned(learned);
|
|
61682
61833
|
}
|
|
61683
61834
|
if (allPages.length === 0) {
|
|
61684
|
-
console.error(
|
|
61835
|
+
console.error(chalk15.red(`
|
|
61685
61836
|
✖ nenhuma captura completada`));
|
|
61686
61837
|
return 2;
|
|
61687
61838
|
}
|
|
@@ -61804,17 +61955,17 @@ function parseFlows(raw) {
|
|
|
61804
61955
|
}
|
|
61805
61956
|
function printSummary5(result, reportPath) {
|
|
61806
61957
|
const { totals } = result;
|
|
61807
|
-
const verdict = totals.critical > 0 ?
|
|
61958
|
+
const verdict = totals.critical > 0 ? chalk15.red.bold("✖ FAIL") : totals.high > 0 ? chalk15.red("✖ FAIL") : totals.issues > 0 ? chalk15.yellow("⚠ WARN") : chalk15.green.bold("✓ PASS");
|
|
61808
61959
|
console.log(`
|
|
61809
61960
|
${verdict}`);
|
|
61810
61961
|
console.log(` ${totals.pages} página(s) · ${totals.issues} issue(s)`);
|
|
61811
|
-
console.log(` ${
|
|
61962
|
+
console.log(` ${chalk15.red(`${totals.critical} critical`)} · ${chalk15.red(`${totals.high} high`)} · ${chalk15.yellow(`${totals.medium} medium`)} · ${chalk15.dim(`${totals.low} low`)}`);
|
|
61812
61963
|
const top = result.allIssues.slice(0, 5);
|
|
61813
61964
|
if (top.length > 0) {
|
|
61814
61965
|
console.log(`
|
|
61815
61966
|
Top issues:`);
|
|
61816
61967
|
for (const issue of top) {
|
|
61817
|
-
const sevTag = issue.severity === "critical" ?
|
|
61968
|
+
const sevTag = issue.severity === "critical" ? chalk15.red.bold("[critical]") : issue.severity === "high" ? chalk15.red("[high] ") : issue.severity === "medium" ? chalk15.yellow("[medium] ") : chalk15.dim("[low] ");
|
|
61818
61969
|
console.log(` ${sevTag} ${issue.summary.slice(0, 200)}`);
|
|
61819
61970
|
}
|
|
61820
61971
|
}
|
|
@@ -61830,7 +61981,7 @@ async function openReport2(path) {
|
|
|
61830
61981
|
|
|
61831
61982
|
// src/commands/explain.ts
|
|
61832
61983
|
init_client();
|
|
61833
|
-
import
|
|
61984
|
+
import chalk16 from "chalk";
|
|
61834
61985
|
|
|
61835
61986
|
// src/llm/system-prompt.ts
|
|
61836
61987
|
var ISSUE_AGGREGATOR_SYSTEM_PROMPT = `
|
|
@@ -61915,17 +62066,17 @@ Cada issue tem:
|
|
|
61915
62066
|
// src/commands/explain.ts
|
|
61916
62067
|
async function explainCommand(runId, issueId, output) {
|
|
61917
62068
|
if (!isLlmAvailable()) {
|
|
61918
|
-
console.error(
|
|
62069
|
+
console.error(chalk16.red("Nenhuma API key de LLM encontrada — set ANTHROPIC_API_KEY ou OPENROUTER_API_KEY."));
|
|
61919
62070
|
return 1;
|
|
61920
62071
|
}
|
|
61921
62072
|
const run = loadRun(output, runId);
|
|
61922
62073
|
const issue = run.issues.find((i) => i.id === issueId) || run.topIssues.find((i) => i.id === issueId);
|
|
61923
62074
|
if (!issue) {
|
|
61924
|
-
console.error(
|
|
62075
|
+
console.error(chalk16.red(`Issue não encontrada: ${issueId}`));
|
|
61925
62076
|
return 1;
|
|
61926
62077
|
}
|
|
61927
62078
|
const checks = run.checks.filter((c) => c.issues.some((i) => i.id === issueId || i.check === issue.check));
|
|
61928
|
-
console.log(
|
|
62079
|
+
console.log(chalk16.dim(`Consultando LLM…
|
|
61929
62080
|
`));
|
|
61930
62081
|
const text = await callMessage({
|
|
61931
62082
|
feature: "explain",
|
|
@@ -61947,7 +62098,7 @@ ${JSON.stringify(checks.map((c) => ({ name: c.name, status: c.status, summary: c
|
|
|
61947
62098
|
// src/commands/extract.ts
|
|
61948
62099
|
import { mkdirSync as mkdirSync14 } from "node:fs";
|
|
61949
62100
|
import { resolve as resolve5 } from "node:path";
|
|
61950
|
-
import
|
|
62101
|
+
import chalk18 from "chalk";
|
|
61951
62102
|
|
|
61952
62103
|
// src/llm/section-understanding.ts
|
|
61953
62104
|
init_client();
|
|
@@ -63131,7 +63282,7 @@ function viewportDeltas(primary, others) {
|
|
|
63131
63282
|
// src/commands/section.ts
|
|
63132
63283
|
import { mkdirSync as mkdirSync13 } from "node:fs";
|
|
63133
63284
|
import { resolve as resolve4 } from "node:path";
|
|
63134
|
-
import
|
|
63285
|
+
import chalk17 from "chalk";
|
|
63135
63286
|
import * as diff from "diff";
|
|
63136
63287
|
import prettier from "prettier";
|
|
63137
63288
|
|
|
@@ -64733,20 +64884,20 @@ function formatBoxTreeDiff(diff, opts = {}) {
|
|
|
64733
64884
|
async function sectionCommand(opts) {
|
|
64734
64885
|
const viewport = parseViewport3(opts.viewport);
|
|
64735
64886
|
if (!viewport) {
|
|
64736
|
-
console.error(
|
|
64887
|
+
console.error(chalk17.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
|
|
64737
64888
|
return 2;
|
|
64738
64889
|
}
|
|
64739
64890
|
const waitMs = Number.parseInt(opts.wait, 10);
|
|
64740
64891
|
if (!Number.isFinite(waitMs) || waitMs < 0) {
|
|
64741
|
-
console.error(
|
|
64892
|
+
console.error(chalk17.red(`--wait inválido: ${opts.wait}`));
|
|
64742
64893
|
return 2;
|
|
64743
64894
|
}
|
|
64744
64895
|
if (!opts.selector || opts.selector.trim().length === 0) {
|
|
64745
|
-
console.error(
|
|
64896
|
+
console.error(chalk17.red("--selector é obrigatório"));
|
|
64746
64897
|
return 2;
|
|
64747
64898
|
}
|
|
64748
64899
|
if (!isValidUrl(opts.prod) || !isValidUrl(opts.cand)) {
|
|
64749
|
-
console.error(
|
|
64900
|
+
console.error(chalk17.red("--prod ou --cand inválido"));
|
|
64750
64901
|
return 2;
|
|
64751
64902
|
}
|
|
64752
64903
|
const candSelector = opts.candSelector?.trim() || opts.selector;
|
|
@@ -64773,7 +64924,7 @@ async function sectionCommand(opts) {
|
|
|
64773
64924
|
const heatmapPath = resolve4(opts.outDir, `${filePrefix}-heatmap.png`);
|
|
64774
64925
|
const { aliases, note: aliasNote } = resolveAliases(opts.planDir);
|
|
64775
64926
|
if (aliasNote)
|
|
64776
|
-
console.log(
|
|
64927
|
+
console.log(chalk17.dim(` ${aliasNote}`));
|
|
64777
64928
|
const browser = await launchBrowser({ headless: true });
|
|
64778
64929
|
try {
|
|
64779
64930
|
const [prodSide, candSide] = await Promise.all([
|
|
@@ -64855,7 +65006,7 @@ async function sectionCommand(opts) {
|
|
|
64855
65006
|
]) {
|
|
64856
65007
|
const caveat = data.settle && formatSettleCaveat(side, data.settle);
|
|
64857
65008
|
if (caveat)
|
|
64858
|
-
console.log(
|
|
65009
|
+
console.log(chalk17.yellow(` ${caveat}`));
|
|
64859
65010
|
}
|
|
64860
65011
|
if (heatmap)
|
|
64861
65012
|
printHeatmap(heatmap, heatmapPath);
|
|
@@ -64883,9 +65034,9 @@ function computeBoxTreeDiff(prodSide, candSide, aliases) {
|
|
|
64883
65034
|
}
|
|
64884
65035
|
function printBoxTree(result) {
|
|
64885
65036
|
console.log("");
|
|
64886
|
-
console.log(
|
|
65037
|
+
console.log(chalk17.bold(" Box tree"));
|
|
64887
65038
|
if ("error" in result) {
|
|
64888
|
-
console.log(
|
|
65039
|
+
console.log(chalk17.yellow(` não foi possível comparar — ${result.error}`));
|
|
64889
65040
|
return;
|
|
64890
65041
|
}
|
|
64891
65042
|
for (const line of formatBoxTreeDiff(result).split(`
|
|
@@ -65000,17 +65151,17 @@ function verdict(prod, cand) {
|
|
|
65000
65151
|
async function printResults2(args) {
|
|
65001
65152
|
const { opts, viewport, candSelector, prodSide, candSide, screenshotPaths, want } = args;
|
|
65002
65153
|
const crossSelector = candSelector !== opts.selector;
|
|
65003
|
-
console.log(
|
|
65154
|
+
console.log(chalk17.bold(`
|
|
65004
65155
|
parity section`));
|
|
65005
65156
|
if (crossSelector) {
|
|
65006
|
-
console.log(
|
|
65007
|
-
console.log(
|
|
65157
|
+
console.log(chalk17.dim(` selector: ${opts.selector} (prod)`));
|
|
65158
|
+
console.log(chalk17.dim(` ${candSelector} (cand)`));
|
|
65008
65159
|
} else {
|
|
65009
|
-
console.log(
|
|
65160
|
+
console.log(chalk17.dim(` selector: ${opts.selector}`));
|
|
65010
65161
|
}
|
|
65011
|
-
console.log(
|
|
65012
|
-
console.log(
|
|
65013
|
-
console.log(
|
|
65162
|
+
console.log(chalk17.dim(` viewport: ${viewport}`));
|
|
65163
|
+
console.log(chalk17.dim(` prod: ${opts.prod}`));
|
|
65164
|
+
console.log(chalk17.dim(` cand: ${opts.cand}`));
|
|
65014
65165
|
console.log("");
|
|
65015
65166
|
if (want.html) {
|
|
65016
65167
|
await printHtmlDiff(prodSide, candSide, crossSelector ? `${opts.selector} → ${candSelector}` : opts.selector);
|
|
@@ -65021,22 +65172,22 @@ async function printResults2(args) {
|
|
|
65021
65172
|
printScreenshotPaths(prodSide, candSide, screenshotPaths);
|
|
65022
65173
|
}
|
|
65023
65174
|
async function printHtmlDiff(prod, cand, selector) {
|
|
65024
|
-
console.log(
|
|
65175
|
+
console.log(chalk17.bold(" HTML diff"));
|
|
65025
65176
|
if (prod.htmlError) {
|
|
65026
|
-
console.log(
|
|
65177
|
+
console.log(chalk17.red(` prod: ${prod.htmlError}`));
|
|
65027
65178
|
return;
|
|
65028
65179
|
}
|
|
65029
65180
|
if (cand.htmlError) {
|
|
65030
|
-
console.log(
|
|
65181
|
+
console.log(chalk17.red(` cand: ${cand.htmlError}`));
|
|
65031
65182
|
return;
|
|
65032
65183
|
}
|
|
65033
65184
|
if (!prod.html || !cand.html) {
|
|
65034
|
-
console.log(
|
|
65185
|
+
console.log(chalk17.dim(" (nenhum lado tem HTML disponível)"));
|
|
65035
65186
|
return;
|
|
65036
65187
|
}
|
|
65037
65188
|
const [prodFmt, candFmt] = await Promise.all([formatHtml(prod.html), formatHtml(cand.html)]);
|
|
65038
65189
|
if (prodFmt === candFmt) {
|
|
65039
|
-
console.log(
|
|
65190
|
+
console.log(chalk17.green(" ✓ idêntico após pretty-print"));
|
|
65040
65191
|
console.log("");
|
|
65041
65192
|
return;
|
|
65042
65193
|
}
|
|
@@ -65045,17 +65196,17 @@ async function printHtmlDiff(prod, cand, selector) {
|
|
|
65045
65196
|
console.log("");
|
|
65046
65197
|
}
|
|
65047
65198
|
function printStylesDiff(prod, cand) {
|
|
65048
|
-
console.log(
|
|
65199
|
+
console.log(chalk17.bold(" Computed styles diff"));
|
|
65049
65200
|
if (!prod.styles || !cand.styles) {
|
|
65050
|
-
console.log(
|
|
65201
|
+
console.log(chalk17.dim(" (styles não foram coletados)"));
|
|
65051
65202
|
return;
|
|
65052
65203
|
}
|
|
65053
65204
|
if (!prod.styles.found) {
|
|
65054
|
-
console.log(
|
|
65205
|
+
console.log(chalk17.red(` prod: ${prod.styles.error}`));
|
|
65055
65206
|
return;
|
|
65056
65207
|
}
|
|
65057
65208
|
if (!cand.styles.found) {
|
|
65058
|
-
console.log(
|
|
65209
|
+
console.log(chalk17.red(` cand: ${cand.styles.error}`));
|
|
65059
65210
|
return;
|
|
65060
65211
|
}
|
|
65061
65212
|
const rows = [];
|
|
@@ -65082,27 +65233,27 @@ function printStylesDiff(prod, cand) {
|
|
|
65082
65233
|
});
|
|
65083
65234
|
}
|
|
65084
65235
|
if (rows.length === 0) {
|
|
65085
|
-
console.log(
|
|
65236
|
+
console.log(chalk17.green(" ✓ todos os SECTION_STYLE_KEYS são iguais"));
|
|
65086
65237
|
console.log("");
|
|
65087
65238
|
return;
|
|
65088
65239
|
}
|
|
65089
65240
|
const keyWidth = Math.max(...rows.map((r) => r.key.length));
|
|
65090
65241
|
for (const r of rows) {
|
|
65091
|
-
console.log(` ${
|
|
65242
|
+
console.log(` ${chalk17.cyan(r.key.padEnd(keyWidth))} ${chalk17.red(`prod=${r.prod || "(vazio)"}`)} ${chalk17.green(`cand=${r.cand || "(vazio)"}`)}`);
|
|
65092
65243
|
}
|
|
65093
65244
|
console.log("");
|
|
65094
65245
|
}
|
|
65095
65246
|
function printScreenshotPaths(prod, cand, paths) {
|
|
65096
|
-
console.log(
|
|
65247
|
+
console.log(chalk17.bold(" Screenshots"));
|
|
65097
65248
|
if (prod.screenshotError) {
|
|
65098
|
-
console.log(
|
|
65249
|
+
console.log(chalk17.red(` prod: ${prod.screenshotError}`));
|
|
65099
65250
|
} else if (prod.screenshotTaken) {
|
|
65100
|
-
console.log(` prod: ${
|
|
65251
|
+
console.log(` prod: ${chalk17.dim(paths.prod)}`);
|
|
65101
65252
|
}
|
|
65102
65253
|
if (cand.screenshotError) {
|
|
65103
|
-
console.log(
|
|
65254
|
+
console.log(chalk17.red(` cand: ${cand.screenshotError}`));
|
|
65104
65255
|
} else if (cand.screenshotTaken) {
|
|
65105
|
-
console.log(` cand: ${
|
|
65256
|
+
console.log(` cand: ${chalk17.dim(paths.cand)}`);
|
|
65106
65257
|
}
|
|
65107
65258
|
console.log("");
|
|
65108
65259
|
}
|
|
@@ -65125,13 +65276,13 @@ function colorPatch(patch) {
|
|
|
65125
65276
|
if (line.startsWith("Index:") || line.startsWith("==="))
|
|
65126
65277
|
continue;
|
|
65127
65278
|
if (line.startsWith("---") || line.startsWith("+++"))
|
|
65128
|
-
out.push(
|
|
65279
|
+
out.push(chalk17.dim(line));
|
|
65129
65280
|
else if (line.startsWith("@@"))
|
|
65130
|
-
out.push(
|
|
65281
|
+
out.push(chalk17.cyan(line));
|
|
65131
65282
|
else if (line.startsWith("+"))
|
|
65132
|
-
out.push(
|
|
65283
|
+
out.push(chalk17.green(line));
|
|
65133
65284
|
else if (line.startsWith("-"))
|
|
65134
|
-
out.push(
|
|
65285
|
+
out.push(chalk17.red(line));
|
|
65135
65286
|
else
|
|
65136
65287
|
out.push(line);
|
|
65137
65288
|
}
|
|
@@ -65200,7 +65351,7 @@ async function buildPromptBundle(args) {
|
|
|
65200
65351
|
}
|
|
65201
65352
|
async function maybeRunLlmSummary(args) {
|
|
65202
65353
|
if (!isUnderstandingAvailable()) {
|
|
65203
|
-
console.warn(
|
|
65354
|
+
console.warn(chalk17.yellow(" --llm-summary pulado: nenhum ANTHROPIC_API_KEY ou OPENROUTER_API_KEY configurado."));
|
|
65204
65355
|
return null;
|
|
65205
65356
|
}
|
|
65206
65357
|
const result = await invokeUnderstandingSummary({
|
|
@@ -65212,42 +65363,42 @@ async function maybeRunLlmSummary(args) {
|
|
|
65212
65363
|
return result?.summary ?? null;
|
|
65213
65364
|
}
|
|
65214
65365
|
function printHeatmap(state, heatmapPath) {
|
|
65215
|
-
console.log(
|
|
65366
|
+
console.log(chalk17.bold(" Heatmap"));
|
|
65216
65367
|
if (state.error) {
|
|
65217
|
-
console.log(
|
|
65368
|
+
console.log(chalk17.yellow(` ${state.error}`));
|
|
65218
65369
|
console.log("");
|
|
65219
65370
|
return;
|
|
65220
65371
|
}
|
|
65221
65372
|
if (!state.analysis) {
|
|
65222
|
-
console.log(
|
|
65373
|
+
console.log(chalk17.dim(" (sem dados de heatmap)"));
|
|
65223
65374
|
console.log("");
|
|
65224
65375
|
return;
|
|
65225
65376
|
}
|
|
65226
65377
|
const a = state.analysis;
|
|
65227
65378
|
const pct = (a.pctDiff * 100).toFixed(2);
|
|
65228
|
-
console.log(` ${
|
|
65379
|
+
console.log(` ${chalk17.cyan("diffPixels")}: ${a.diffPixels} (${pct}%)`);
|
|
65229
65380
|
if (a.boundingBox) {
|
|
65230
65381
|
const bb = a.boundingBox;
|
|
65231
|
-
console.log(` ${
|
|
65382
|
+
console.log(` ${chalk17.cyan("boundingBox")}: x=${bb.x} y=${bb.y} w=${bb.width} h=${bb.height}`);
|
|
65232
65383
|
}
|
|
65233
65384
|
if (a.hotspots.length > 0) {
|
|
65234
|
-
console.log(` ${
|
|
65385
|
+
console.log(` ${chalk17.cyan("hotspots")}:`);
|
|
65235
65386
|
for (const h of a.hotspots.slice(0, 5)) {
|
|
65236
65387
|
console.log(` (${h.x}, ${h.y}) ${h.width}×${h.height} — ${h.pixelCount} px`);
|
|
65237
65388
|
}
|
|
65238
65389
|
}
|
|
65239
|
-
console.log(` ${
|
|
65390
|
+
console.log(` ${chalk17.dim(`heatmap: ${heatmapPath}`)}`);
|
|
65240
65391
|
console.log("");
|
|
65241
65392
|
}
|
|
65242
65393
|
function printBundlePaths(b) {
|
|
65243
|
-
console.log(
|
|
65244
|
-
console.log(` ${
|
|
65245
|
-
console.log(` ${
|
|
65246
|
-
console.log(` ${
|
|
65394
|
+
console.log(chalk17.bold(" Bundle"));
|
|
65395
|
+
console.log(` ${chalk17.cyan("summary")}: ${b.summary}`);
|
|
65396
|
+
console.log(` ${chalk17.cyan("json")}: ${chalk17.dim(b.jsonPath)}`);
|
|
65397
|
+
console.log(` ${chalk17.cyan("prompt")}: ${chalk17.dim(b.markdownPath)}`);
|
|
65247
65398
|
console.log("");
|
|
65248
65399
|
}
|
|
65249
65400
|
function printLlmSummary(summary) {
|
|
65250
|
-
console.log(
|
|
65401
|
+
console.log(chalk17.bold(" What the LLM understood"));
|
|
65251
65402
|
console.log(` ${summary.split(`
|
|
65252
65403
|
`).join(`
|
|
65253
65404
|
`)}`);
|
|
@@ -65262,16 +65413,16 @@ function planExtractComponents(detected, signatures) {
|
|
|
65262
65413
|
async function extractCommand(opts) {
|
|
65263
65414
|
const viewport = parseViewport3(opts.viewport);
|
|
65264
65415
|
if (!viewport) {
|
|
65265
|
-
console.error(
|
|
65416
|
+
console.error(chalk18.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
|
|
65266
65417
|
return 2;
|
|
65267
65418
|
}
|
|
65268
65419
|
if (!isValidUrl2(opts.url)) {
|
|
65269
|
-
console.error(
|
|
65420
|
+
console.error(chalk18.red(`--url inválido: ${opts.url}`));
|
|
65270
65421
|
return 2;
|
|
65271
65422
|
}
|
|
65272
65423
|
const format = normalizeFormat(opts.format);
|
|
65273
65424
|
if (!format) {
|
|
65274
|
-
console.error(
|
|
65425
|
+
console.error(chalk18.red(`--format inválido: ${opts.format} (use md|json|both)`));
|
|
65275
65426
|
return 2;
|
|
65276
65427
|
}
|
|
65277
65428
|
const allowlist = parseAllowlist(opts.components);
|
|
@@ -65284,14 +65435,14 @@ async function extractCommand(opts) {
|
|
|
65284
65435
|
try {
|
|
65285
65436
|
pageTokens = parsePageList(opts.pages, { tokens: PLP_PDP_AUTO_TOKENS, fallback: ["/"] });
|
|
65286
65437
|
} catch (err) {
|
|
65287
|
-
console.error(
|
|
65438
|
+
console.error(chalk18.red(err.message));
|
|
65288
65439
|
return 2;
|
|
65289
65440
|
}
|
|
65290
65441
|
const browser = await launchBrowser({ headless: true });
|
|
65291
65442
|
try {
|
|
65292
65443
|
const resolvedPages = await resolvePages(opts.url, pageTokens);
|
|
65293
65444
|
if (resolvedPages.length === 0) {
|
|
65294
|
-
console.error(
|
|
65445
|
+
console.error(chalk18.red("nenhuma página resolvida a partir de --pages"));
|
|
65295
65446
|
return 1;
|
|
65296
65447
|
}
|
|
65297
65448
|
let globalIndex = 0;
|
|
@@ -65385,17 +65536,17 @@ async function extractCommand(opts) {
|
|
|
65385
65536
|
}
|
|
65386
65537
|
}
|
|
65387
65538
|
function printResults3(runDir, bundle) {
|
|
65388
|
-
console.log(
|
|
65539
|
+
console.log(chalk18.bold(`
|
|
65389
65540
|
parity extract`));
|
|
65390
|
-
console.log(
|
|
65391
|
-
console.log(
|
|
65392
|
-
console.log(
|
|
65393
|
-
console.log(
|
|
65541
|
+
console.log(chalk18.dim(` url: ${bundle.url}`));
|
|
65542
|
+
console.log(chalk18.dim(` viewport: ${bundle.viewport}`));
|
|
65543
|
+
console.log(chalk18.dim(` pages: ${bundle.pages?.length ?? 0}`));
|
|
65544
|
+
console.log(chalk18.dim(` out: ${runDir}`));
|
|
65394
65545
|
console.log("");
|
|
65395
|
-
console.log(
|
|
65546
|
+
console.log(chalk18.bold(` ${bundle.components.length} component(s) detected:`));
|
|
65396
65547
|
for (const c of bundle.components) {
|
|
65397
|
-
const repeated = c.repeated && c.repeated > 1 ?
|
|
65398
|
-
console.log(` ${
|
|
65548
|
+
const repeated = c.repeated && c.repeated > 1 ? chalk18.dim(` ×${c.repeated}`) : "";
|
|
65549
|
+
console.log(` ${chalk18.cyan(c.role.padEnd(24))} ${chalk18.dim(c.selector)}${repeated}`);
|
|
65399
65550
|
}
|
|
65400
65551
|
console.log("");
|
|
65401
65552
|
}
|
|
@@ -65507,23 +65658,23 @@ async function fixCommand(opts) {
|
|
|
65507
65658
|
|
|
65508
65659
|
// src/commands/html.ts
|
|
65509
65660
|
init_esm10();
|
|
65510
|
-
import
|
|
65661
|
+
import chalk19 from "chalk";
|
|
65511
65662
|
import * as diff2 from "diff";
|
|
65512
65663
|
import prettier2 from "prettier";
|
|
65513
65664
|
async function htmlCommand(opts) {
|
|
65514
65665
|
const viewport = parseViewport4(opts.viewport);
|
|
65515
65666
|
if (!viewport) {
|
|
65516
|
-
console.error(
|
|
65667
|
+
console.error(chalk19.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
|
|
65517
65668
|
return 2;
|
|
65518
65669
|
}
|
|
65519
65670
|
const waitMs = parseWaitMs(opts.wait);
|
|
65520
65671
|
if (waitMs === null) {
|
|
65521
|
-
console.error(
|
|
65672
|
+
console.error(chalk19.red(`--wait inválido: ${opts.wait} (precisa ser inteiro >= 0)`));
|
|
65522
65673
|
return 2;
|
|
65523
65674
|
}
|
|
65524
65675
|
const mode = resolveMode(opts);
|
|
65525
65676
|
if (mode.kind === "error") {
|
|
65526
|
-
console.error(
|
|
65677
|
+
console.error(chalk19.red(mode.message));
|
|
65527
65678
|
return 2;
|
|
65528
65679
|
}
|
|
65529
65680
|
const browser = await launchBrowser({ headless: true });
|
|
@@ -65532,11 +65683,11 @@ async function htmlCommand(opts) {
|
|
|
65532
65683
|
const html = await fetchSnapshot(browser, mode.url, viewport, waitMs);
|
|
65533
65684
|
const piece = extractSelector(html, opts.selector);
|
|
65534
65685
|
if (piece.error) {
|
|
65535
|
-
console.error(
|
|
65686
|
+
console.error(chalk19.red(piece.error));
|
|
65536
65687
|
return 2;
|
|
65537
65688
|
}
|
|
65538
65689
|
if (piece.warning)
|
|
65539
|
-
console.error(
|
|
65690
|
+
console.error(chalk19.yellow(` ⚠ ${piece.warning}`));
|
|
65540
65691
|
const finalText = await maybePretty(piece.html, opts.pretty === true);
|
|
65541
65692
|
if (opts.json) {
|
|
65542
65693
|
console.log(JSON.stringify({
|
|
@@ -65557,17 +65708,17 @@ async function htmlCommand(opts) {
|
|
|
65557
65708
|
const prodPiece = extractSelector(prodHtml, opts.selector);
|
|
65558
65709
|
const candPiece = extractSelector(candHtml, opts.selector);
|
|
65559
65710
|
if (prodPiece.error) {
|
|
65560
|
-
console.error(
|
|
65711
|
+
console.error(chalk19.red(`prod: ${prodPiece.error}`));
|
|
65561
65712
|
return 2;
|
|
65562
65713
|
}
|
|
65563
65714
|
if (candPiece.error) {
|
|
65564
|
-
console.error(
|
|
65715
|
+
console.error(chalk19.red(`cand: ${candPiece.error}`));
|
|
65565
65716
|
return 2;
|
|
65566
65717
|
}
|
|
65567
65718
|
if (prodPiece.warning)
|
|
65568
|
-
console.error(
|
|
65719
|
+
console.error(chalk19.yellow(` ⚠ prod: ${prodPiece.warning}`));
|
|
65569
65720
|
if (candPiece.warning)
|
|
65570
|
-
console.error(
|
|
65721
|
+
console.error(chalk19.yellow(` ⚠ cand: ${candPiece.warning}`));
|
|
65571
65722
|
const [prodFmt, candFmt] = await Promise.all([
|
|
65572
65723
|
maybePretty(prodPiece.html, opts.pretty !== false),
|
|
65573
65724
|
maybePretty(candPiece.html, opts.pretty !== false)
|
|
@@ -65715,19 +65866,19 @@ function formatPatch(patch) {
|
|
|
65715
65866
|
if (line.startsWith("Index:") || line.startsWith("==="))
|
|
65716
65867
|
continue;
|
|
65717
65868
|
if (line.startsWith("---") || line.startsWith("+++")) {
|
|
65718
|
-
out.push(
|
|
65869
|
+
out.push(chalk19.dim(line));
|
|
65719
65870
|
continue;
|
|
65720
65871
|
}
|
|
65721
65872
|
if (line.startsWith("@@")) {
|
|
65722
|
-
out.push(
|
|
65873
|
+
out.push(chalk19.cyan(line));
|
|
65723
65874
|
continue;
|
|
65724
65875
|
}
|
|
65725
65876
|
if (line.startsWith("+")) {
|
|
65726
|
-
out.push(
|
|
65877
|
+
out.push(chalk19.green(line));
|
|
65727
65878
|
continue;
|
|
65728
65879
|
}
|
|
65729
65880
|
if (line.startsWith("-")) {
|
|
65730
|
-
out.push(
|
|
65881
|
+
out.push(chalk19.red(line));
|
|
65731
65882
|
continue;
|
|
65732
65883
|
}
|
|
65733
65884
|
out.push(line);
|
|
@@ -65739,13 +65890,13 @@ function formatPatch(patch) {
|
|
|
65739
65890
|
// src/commands/journey.ts
|
|
65740
65891
|
import { writeFileSync as writeFileSync22 } from "node:fs";
|
|
65741
65892
|
import { join as join25 } from "node:path";
|
|
65742
|
-
import
|
|
65893
|
+
import chalk20 from "chalk";
|
|
65743
65894
|
import ora7 from "ora";
|
|
65744
65895
|
init_client();
|
|
65745
65896
|
async function journeyCommand(opts) {
|
|
65746
65897
|
const viewports = opts.viewports.split(",").map((s) => s.trim()).filter((s) => s === "mobile" || s === "desktop");
|
|
65747
65898
|
if (viewports.length === 0) {
|
|
65748
|
-
console.error(
|
|
65899
|
+
console.error(chalk20.red("Nenhum viewport válido (use mobile,desktop)"));
|
|
65749
65900
|
return 2;
|
|
65750
65901
|
}
|
|
65751
65902
|
const rc = loadParityRc();
|
|
@@ -65755,13 +65906,13 @@ async function journeyCommand(opts) {
|
|
|
65755
65906
|
const runId = newRunId();
|
|
65756
65907
|
const paths = createRunDir(opts.output, runId);
|
|
65757
65908
|
if (!opts.json) {
|
|
65758
|
-
console.log(
|
|
65909
|
+
console.log(chalk20.bold(`
|
|
65759
65910
|
parity journey ${runId}`));
|
|
65760
|
-
console.log(
|
|
65761
|
-
console.log(
|
|
65762
|
-
console.log(
|
|
65911
|
+
console.log(chalk20.dim(` prod: ${opts.prod}`));
|
|
65912
|
+
console.log(chalk20.dim(` cand: ${opts.cand}`));
|
|
65913
|
+
console.log(chalk20.dim(` viewports: ${viewports.join(", ")} · CEP: ${rc.cep}`));
|
|
65763
65914
|
if (isLlmAvailable())
|
|
65764
|
-
console.log(
|
|
65915
|
+
console.log(chalk20.dim(` llm: ${providerLabel()}`));
|
|
65765
65916
|
console.log("");
|
|
65766
65917
|
}
|
|
65767
65918
|
let platform = "custom";
|
|
@@ -65795,15 +65946,15 @@ async function journeyCommand(opts) {
|
|
|
65795
65946
|
const onStepFor = (viewport, side) => (event) => {
|
|
65796
65947
|
if (opts.json)
|
|
65797
65948
|
return;
|
|
65798
|
-
const sideTag = side === "prod" ?
|
|
65799
|
-
const prefix = ` ${
|
|
65949
|
+
const sideTag = side === "prod" ? chalk20.cyan("prod") : chalk20.magenta("cand");
|
|
65950
|
+
const prefix = ` ${chalk20.dim(`[${viewport}/`)}${sideTag}${chalk20.dim("]")}`;
|
|
65800
65951
|
if (event.phase === "start") {
|
|
65801
|
-
console.log(`${prefix} ${
|
|
65952
|
+
console.log(`${prefix} ${chalk20.dim(`${event.index}/${event.total}`)} ▶ ${chalk20.bold(stepLabel(event.name))}`);
|
|
65802
65953
|
} else {
|
|
65803
|
-
const glyph = event.status === "ok" ?
|
|
65804
|
-
const noteText = event.note ?
|
|
65805
|
-
const time =
|
|
65806
|
-
console.log(`${prefix} ${
|
|
65954
|
+
const glyph = event.status === "ok" ? chalk20.green("✓") : event.status === "skipped" ? chalk20.yellow("○") : chalk20.red("✗");
|
|
65955
|
+
const noteText = event.note ? chalk20.dim(` (${event.note})`) : "";
|
|
65956
|
+
const time = chalk20.dim(`${(event.durationMs / 1000).toFixed(1)}s`);
|
|
65957
|
+
console.log(`${prefix} ${chalk20.dim(`${event.index}/${event.total}`)} ${glyph} ${stepLabel(event.name)} ${time}${noteText}`);
|
|
65807
65958
|
}
|
|
65808
65959
|
};
|
|
65809
65960
|
async function runOneSide(browserInstance, viewport, side) {
|
|
@@ -65842,7 +65993,7 @@ async function journeyCommand(opts) {
|
|
|
65842
65993
|
spinner?.succeed("Browser pronto");
|
|
65843
65994
|
for (const viewport of viewports) {
|
|
65844
65995
|
if (!opts.json)
|
|
65845
|
-
console.log(
|
|
65996
|
+
console.log(chalk20.bold(`
|
|
65846
65997
|
── ${viewport} ─────────────────────────────────────────────`));
|
|
65847
65998
|
const [prodCap, candCap] = await Promise.all([
|
|
65848
65999
|
runOneSide(browser, viewport, "prod"),
|
|
@@ -65877,11 +66028,11 @@ async function journeyCommand(opts) {
|
|
|
65877
66028
|
if (totalDeprecated > 0)
|
|
65878
66029
|
bits.push(`${totalDeprecated} depreciado(s)`);
|
|
65879
66030
|
if (bits.length > 0)
|
|
65880
|
-
console.log(
|
|
66031
|
+
console.log(chalk20.dim(` learned-selectors atualizado: ${bits.join(", ")}`));
|
|
65881
66032
|
}
|
|
65882
66033
|
} catch (err) {
|
|
65883
66034
|
if (!opts.json) {
|
|
65884
|
-
console.warn(
|
|
66035
|
+
console.warn(chalk20.yellow(` warn: failed to persist learned-selectors: ${err.message}`));
|
|
65885
66036
|
}
|
|
65886
66037
|
}
|
|
65887
66038
|
}
|
|
@@ -65902,7 +66053,7 @@ async function journeyCommand(opts) {
|
|
|
65902
66053
|
if (opts.junit) {
|
|
65903
66054
|
writeFileSync22(opts.junit, buildJUnit(rows, failures), "utf8");
|
|
65904
66055
|
if (!opts.json)
|
|
65905
|
-
console.log(
|
|
66056
|
+
console.log(chalk20.dim(` → JUnit XML: ${opts.junit}`));
|
|
65906
66057
|
}
|
|
65907
66058
|
return failures.some((f) => f.critical) ? 1 : 0;
|
|
65908
66059
|
} catch (err) {
|
|
@@ -65967,14 +66118,14 @@ function collectFailures(rows) {
|
|
|
65967
66118
|
function printTable(viewports, rows) {
|
|
65968
66119
|
console.log("");
|
|
65969
66120
|
for (const viewport of viewports) {
|
|
65970
|
-
console.log(
|
|
66121
|
+
console.log(chalk20.bold(` [${viewport}]`));
|
|
65971
66122
|
const vrows = rows.filter((r) => r.viewport === viewport);
|
|
65972
66123
|
for (const r of vrows) {
|
|
65973
66124
|
const label = PJ_STEP_LABELS_NUMBERED[r.name] ?? r.name;
|
|
65974
66125
|
const p = statusGlyph(r.prod?.status);
|
|
65975
66126
|
const c = statusGlyph(r.cand?.status);
|
|
65976
|
-
const status = r.prod?.status === "ok" && r.cand?.status !== "ok" ?
|
|
65977
|
-
const note = r.cand?.status === "failed" || r.cand?.status === "skipped" ?
|
|
66127
|
+
const status = r.prod?.status === "ok" && r.cand?.status !== "ok" ? chalk20.red("FAILED") : "";
|
|
66128
|
+
const note = r.cand?.status === "failed" || r.cand?.status === "skipped" ? chalk20.dim(`(${r.cand?.note ?? r.cand?.status})`) : "";
|
|
65978
66129
|
console.log(` ${label.padEnd(24)} prod ${p} cand ${c} ${status} ${note}`);
|
|
65979
66130
|
}
|
|
65980
66131
|
console.log("");
|
|
@@ -65982,12 +66133,12 @@ function printTable(viewports, rows) {
|
|
|
65982
66133
|
}
|
|
65983
66134
|
function statusGlyph(status) {
|
|
65984
66135
|
if (!status)
|
|
65985
|
-
return
|
|
66136
|
+
return chalk20.dim("—");
|
|
65986
66137
|
if (status === "ok")
|
|
65987
|
-
return
|
|
66138
|
+
return chalk20.green("✓");
|
|
65988
66139
|
if (status === "skipped")
|
|
65989
|
-
return
|
|
65990
|
-
return
|
|
66140
|
+
return chalk20.yellow("○");
|
|
66141
|
+
return chalk20.red("✗");
|
|
65991
66142
|
}
|
|
65992
66143
|
function printSummary6(rows, failures, htmlPath) {
|
|
65993
66144
|
const byViewport = new Map;
|
|
@@ -65998,25 +66149,25 @@ function printSummary6(rows, failures, htmlPath) {
|
|
|
65998
66149
|
v.passed++;
|
|
65999
66150
|
byViewport.set(r.viewport, v);
|
|
66000
66151
|
}
|
|
66001
|
-
console.log(
|
|
66152
|
+
console.log(chalk20.bold(" Summary:"));
|
|
66002
66153
|
for (const [vp, { passed, total }] of byViewport) {
|
|
66003
|
-
const stat = passed === total ?
|
|
66154
|
+
const stat = passed === total ? chalk20.green("✓") : chalk20.yellow(`${passed}/${total}`);
|
|
66004
66155
|
console.log(` ${vp.padEnd(8)} ${stat} steps em cand`);
|
|
66005
66156
|
}
|
|
66006
66157
|
if (failures.length > 0) {
|
|
66007
66158
|
const crit = failures.filter((f) => f.critical).length;
|
|
66008
66159
|
console.log("");
|
|
66009
|
-
console.log(
|
|
66160
|
+
console.log(chalk20.red(` ✗ ${failures.length} step(s) divergent(es) (${crit} crítico)`));
|
|
66010
66161
|
for (const f of failures) {
|
|
66011
|
-
const tag = f.critical ?
|
|
66162
|
+
const tag = f.critical ? chalk20.red("[critical]") : chalk20.yellow("[warn]");
|
|
66012
66163
|
console.log(` ${tag} [${f.viewport}] ${f.step}: ${f.reason}`);
|
|
66013
66164
|
}
|
|
66014
66165
|
} else {
|
|
66015
66166
|
console.log("");
|
|
66016
|
-
console.log(
|
|
66167
|
+
console.log(chalk20.green(" ✓ jornada completa em cand"));
|
|
66017
66168
|
}
|
|
66018
66169
|
console.log("");
|
|
66019
|
-
console.log(
|
|
66170
|
+
console.log(chalk20.dim(` → ${htmlPath}`));
|
|
66020
66171
|
console.log("");
|
|
66021
66172
|
}
|
|
66022
66173
|
function emitGithubAnnotations(failures) {
|
|
@@ -66251,26 +66402,26 @@ function safeHost5(url) {
|
|
|
66251
66402
|
}
|
|
66252
66403
|
|
|
66253
66404
|
// src/commands/learned.ts
|
|
66254
|
-
import
|
|
66405
|
+
import chalk21 from "chalk";
|
|
66255
66406
|
init_client();
|
|
66256
66407
|
function learnedStats() {
|
|
66257
66408
|
const lib = loadLearned();
|
|
66258
66409
|
const stats = statsFromLib(lib);
|
|
66259
66410
|
if (stats.platforms.length === 0) {
|
|
66260
|
-
console.log(
|
|
66261
|
-
console.log(
|
|
66411
|
+
console.log(chalk21.dim(`Biblioteca vazia: ${LEARNED_PATH}`));
|
|
66412
|
+
console.log(chalk21.dim("Rode `parity run ...` em algum site para começar a popular."));
|
|
66262
66413
|
return 0;
|
|
66263
66414
|
}
|
|
66264
|
-
console.log(
|
|
66415
|
+
console.log(chalk21.bold(`
|
|
66265
66416
|
learned-selectors stats (${LEARNED_PATH})
|
|
66266
66417
|
`));
|
|
66267
66418
|
for (const p of stats.platforms) {
|
|
66268
|
-
const staleNote = p.staleSelectors > 0 ? ` · ${
|
|
66269
|
-
console.log(`${
|
|
66419
|
+
const staleNote = p.staleSelectors > 0 ? ` · ${chalk21.yellow(`${p.staleSelectors} stale`)}` : "";
|
|
66420
|
+
console.log(`${chalk21.cyan(p.platform)}: ${p.activeSelectors} active (${p.verifiedSelectors} verified, ${p.llmGuessSelectors} llm-guess) · ${chalk21.dim(`${p.deprecatedSelectors} deprecated`)}${staleNote}`);
|
|
66270
66421
|
for (const top of p.topByKey) {
|
|
66271
66422
|
const sr = `${(top.successRate * 100).toFixed(0)}%`;
|
|
66272
|
-
const originTag = top.origin === "llm-guess" ?
|
|
66273
|
-
console.log(` ${
|
|
66423
|
+
const originTag = top.origin === "llm-guess" ? chalk21.yellow(" [guess]") : "";
|
|
66424
|
+
console.log(` ${chalk21.dim(top.key.padEnd(18))} ${chalk21.green(sr.padStart(4))} ${chalk21.dim(`(${top.hosts} hosts)`)} ${top.selector}${originTag}`);
|
|
66274
66425
|
}
|
|
66275
66426
|
console.log("");
|
|
66276
66427
|
}
|
|
@@ -66278,10 +66429,10 @@ learned-selectors stats (${LEARNED_PATH})
|
|
|
66278
66429
|
}
|
|
66279
66430
|
async function learnedValidate(url) {
|
|
66280
66431
|
if (!isLlmAvailable()) {
|
|
66281
|
-
console.error(
|
|
66432
|
+
console.error(chalk21.red(" ✖ nenhuma chave de LLM configurada (ANTHROPIC_API_KEY / OPENROUTER_API_KEY) — discovery precisa do LLM"));
|
|
66282
66433
|
return 2;
|
|
66283
66434
|
}
|
|
66284
|
-
console.log(
|
|
66435
|
+
console.log(chalk21.dim(` Baixando home de ${url}…`));
|
|
66285
66436
|
let html;
|
|
66286
66437
|
try {
|
|
66287
66438
|
const res = await fetch(url, {
|
|
@@ -66290,20 +66441,20 @@ async function learnedValidate(url) {
|
|
|
66290
66441
|
});
|
|
66291
66442
|
html = res.ok ? await res.text() : null;
|
|
66292
66443
|
} catch (err) {
|
|
66293
|
-
console.error(
|
|
66444
|
+
console.error(chalk21.red(` ✖ falha ao baixar ${url}: ${err.message}`));
|
|
66294
66445
|
return 2;
|
|
66295
66446
|
}
|
|
66296
66447
|
if (!html) {
|
|
66297
|
-
console.error(
|
|
66448
|
+
console.error(chalk21.red(` ✖ falha ao baixar ${url} (HTTP não-2xx ou erro de rede)`));
|
|
66298
66449
|
return 2;
|
|
66299
66450
|
}
|
|
66300
|
-
console.log(
|
|
66451
|
+
console.log(chalk21.dim(" Descobrindo seletores via LLM…"));
|
|
66301
66452
|
const discovered = await discoverSelectorsFromUrl(url, html, { noCache: true });
|
|
66302
66453
|
if (!discovered) {
|
|
66303
|
-
console.error(
|
|
66454
|
+
console.error(chalk21.red(" ✖ LLM não retornou seletores"));
|
|
66304
66455
|
return 2;
|
|
66305
66456
|
}
|
|
66306
|
-
console.log(
|
|
66457
|
+
console.log(chalk21.dim(" Validando ao vivo (browser headless)…"));
|
|
66307
66458
|
let browser = null;
|
|
66308
66459
|
try {
|
|
66309
66460
|
browser = await launchBrowser({ headless: true });
|
|
@@ -66313,7 +66464,7 @@ async function learnedValidate(url) {
|
|
|
66313
66464
|
const { validated } = await validateSelectors(page, discovered);
|
|
66314
66465
|
await ctx.close();
|
|
66315
66466
|
const lowConfidence = new Set(discovered.lowConfidenceKeys ?? []);
|
|
66316
|
-
console.log(
|
|
66467
|
+
console.log(chalk21.bold(`
|
|
66317
66468
|
learned validate — ${url}
|
|
66318
66469
|
`));
|
|
66319
66470
|
for (const key of Object.keys(discovered)) {
|
|
@@ -66321,17 +66472,17 @@ learned validate — ${url}
|
|
|
66321
66472
|
continue;
|
|
66322
66473
|
const selector = discovered[key];
|
|
66323
66474
|
if (!selector) {
|
|
66324
|
-
console.log(` ${
|
|
66475
|
+
console.log(` ${chalk21.dim(key.padEnd(20))} ${chalk21.dim("(vazio — LLM não detectou)")}`);
|
|
66325
66476
|
continue;
|
|
66326
66477
|
}
|
|
66327
|
-
const state = validated[key] === true ?
|
|
66328
|
-
const guessTag = lowConfidence.has(key) ?
|
|
66478
|
+
const state = validated[key] === true ? chalk21.green("validated") : validated[key] === false ? chalk21.red("not-validated") : chalk21.yellow("not-checked");
|
|
66479
|
+
const guessTag = lowConfidence.has(key) ? chalk21.yellow(" [low-confidence]") : "";
|
|
66329
66480
|
console.log(` ${key.padEnd(20)} ${state.padEnd(22)} ${selector}${guessTag}`);
|
|
66330
66481
|
}
|
|
66331
66482
|
console.log("");
|
|
66332
66483
|
return 0;
|
|
66333
66484
|
} catch (err) {
|
|
66334
|
-
console.error(
|
|
66485
|
+
console.error(chalk21.red(` ✖ validação ao vivo falhou: ${err.message}`));
|
|
66335
66486
|
return 2;
|
|
66336
66487
|
} finally {
|
|
66337
66488
|
if (browser)
|
|
@@ -66340,20 +66491,20 @@ learned validate — ${url}
|
|
|
66340
66491
|
}
|
|
66341
66492
|
|
|
66342
66493
|
// src/commands/list.ts
|
|
66343
|
-
import
|
|
66494
|
+
import chalk22 from "chalk";
|
|
66344
66495
|
function listModulesCommand(json) {
|
|
66345
66496
|
if (json) {
|
|
66346
66497
|
console.log(JSON.stringify(MODULES, null, 2));
|
|
66347
66498
|
return 0;
|
|
66348
66499
|
}
|
|
66349
66500
|
for (const mod of Object.values(MODULES)) {
|
|
66350
|
-
console.log(` ${
|
|
66501
|
+
console.log(` ${chalk22.bold(mod.name)} ${chalk22.dim(mod.description)}`);
|
|
66351
66502
|
console.log(` checks: ${mod.checks.join(", ")}`);
|
|
66352
66503
|
console.log(` flows: ${mod.flows.join(", ")}`);
|
|
66353
66504
|
if (mod.needsSitemapPages)
|
|
66354
|
-
console.log(
|
|
66505
|
+
console.log(chalk22.dim(" needs sitemap-page crawling"));
|
|
66355
66506
|
if (mod.needsLlm)
|
|
66356
|
-
console.log(
|
|
66507
|
+
console.log(chalk22.dim(" needs an LLM pass for full value"));
|
|
66357
66508
|
console.log("");
|
|
66358
66509
|
}
|
|
66359
66510
|
return 0;
|
|
@@ -66361,18 +66512,18 @@ function listModulesCommand(json) {
|
|
|
66361
66512
|
function listCommand(output) {
|
|
66362
66513
|
const runs = listRuns(output);
|
|
66363
66514
|
if (runs.length === 0) {
|
|
66364
|
-
console.log(
|
|
66515
|
+
console.log(chalk22.dim(`Nenhum run salvo em ${output}`));
|
|
66365
66516
|
return 0;
|
|
66366
66517
|
}
|
|
66367
66518
|
for (const r of runs) {
|
|
66368
66519
|
try {
|
|
66369
66520
|
const run = loadRun(output, r.id);
|
|
66370
66521
|
const v = run.verdict;
|
|
66371
|
-
const status = v.status === "inconclusive" ?
|
|
66522
|
+
const status = v.status === "inconclusive" ? chalk22.dim(v.status) : v.status === "pass" ? chalk22.green(v.status) : v.status === "warn" ? chalk22.yellow(v.status) : chalk22.red(v.status);
|
|
66372
66523
|
const score = v.status === "inconclusive" ? "—" : v.score;
|
|
66373
|
-
console.log(` ${
|
|
66524
|
+
console.log(` ${chalk22.bold(r.id)} ${status} score=${score} critical=${v.critical} high=${v.high} ${chalk22.dim(r.timestamp)}`);
|
|
66374
66525
|
} catch {
|
|
66375
|
-
console.log(` ${
|
|
66526
|
+
console.log(` ${chalk22.bold(r.id)} ${chalk22.dim("(report.json ausente)")}`);
|
|
66376
66527
|
}
|
|
66377
66528
|
}
|
|
66378
66529
|
return 0;
|
|
@@ -66380,7 +66531,7 @@ function listCommand(output) {
|
|
|
66380
66531
|
|
|
66381
66532
|
// src/commands/loadtest.ts
|
|
66382
66533
|
import { existsSync as existsSync15, readFileSync as readFileSync21 } from "node:fs";
|
|
66383
|
-
import
|
|
66534
|
+
import chalk23 from "chalk";
|
|
66384
66535
|
var MAX_RPS = 100;
|
|
66385
66536
|
var MAX_DURATION_SEC = 900;
|
|
66386
66537
|
var MAX_IN_FLIGHT = 512;
|
|
@@ -66520,7 +66671,7 @@ async function runLoad(args) {
|
|
|
66520
66671
|
var round = (n) => Math.round(n * 100) / 100;
|
|
66521
66672
|
async function loadtestCommand(opts) {
|
|
66522
66673
|
const refuse = (msg) => {
|
|
66523
|
-
console.error(
|
|
66674
|
+
console.error(chalk23.red(`parity loadtest: ${msg}`));
|
|
66524
66675
|
return 2;
|
|
66525
66676
|
};
|
|
66526
66677
|
if (!Number.isFinite(opts.rps) || opts.rps <= 0 || opts.rps > MAX_RPS)
|
|
@@ -66550,7 +66701,7 @@ async function loadtestCommand(opts) {
|
|
|
66550
66701
|
if (paths.length === 0)
|
|
66551
66702
|
return refuse("no paths to load — sitemap empty/unreachable or --paths empty. Nothing measured.");
|
|
66552
66703
|
if (!opts.json)
|
|
66553
|
-
console.error(
|
|
66704
|
+
console.error(chalk23.dim(`loadtest ${opts.url}: ${opts.rps} rps × ${opts.duration}s over ${paths.length} paths × ${devices.join("/")}`));
|
|
66554
66705
|
const r = await runLoad({
|
|
66555
66706
|
baseUrl: opts.url,
|
|
66556
66707
|
paths,
|
|
@@ -66584,7 +66735,7 @@ function printSummary7(r) {
|
|
|
66584
66735
|
const line = (label, s) => ` ${label.padEnd(28)} ${String(s.requests).padStart(6)} req p50 ${s.p50Ms ?? "-"} p95 ${s.p95Ms ?? "-"} p99 ${s.p99Ms ?? "-"} ms hit ${pct(s.hitRate)} ${Object.entries(s.status).map(([k, n]) => `${k}:${n}`).join(" ")}`;
|
|
66585
66736
|
console.log(`Throughput: requested ${r.requestedRps} rps · sent ${r.sentRps} rps · completed ${r.completedRps} rps · coverage ${pct(r.coverage)} of path×device`);
|
|
66586
66737
|
if (r.clientLimited)
|
|
66587
|
-
console.log(
|
|
66738
|
+
console.log(chalk23.yellow(` CLIENT-LIMITED — the generator, not the site, capped the rate: ${r.clientLimitedWhy}`));
|
|
66588
66739
|
console.log(line("overall", r.overall));
|
|
66589
66740
|
console.log("By segment (x-cache-segment):");
|
|
66590
66741
|
for (const [k, s] of Object.entries(r.bySegment))
|
|
@@ -66600,7 +66751,7 @@ function printSummary7(r) {
|
|
|
66600
66751
|
// src/commands/migrate.ts
|
|
66601
66752
|
import { existsSync as existsSync20, mkdirSync as mkdirSync16, readFileSync as readFileSync26, rmSync, writeFileSync as writeFileSync26 } from "node:fs";
|
|
66602
66753
|
import { relative as relative5, resolve as resolve7 } from "node:path";
|
|
66603
|
-
import
|
|
66754
|
+
import chalk24 from "chalk";
|
|
66604
66755
|
import open from "open";
|
|
66605
66756
|
|
|
66606
66757
|
// src/migrate/pdp-discovery.ts
|
|
@@ -68486,25 +68637,25 @@ async function captureInteractions(page, selector) {
|
|
|
68486
68637
|
async function migrateCommand(opts) {
|
|
68487
68638
|
const viewport = parseViewport3(opts.viewport);
|
|
68488
68639
|
if (!viewport) {
|
|
68489
|
-
console.error(
|
|
68640
|
+
console.error(chalk24.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
|
|
68490
68641
|
return 2;
|
|
68491
68642
|
}
|
|
68492
68643
|
const viewports = (opts.viewports ? opts.viewports.split(",") : [opts.viewport]).map((v) => parseViewport3(v.trim())).filter((v) => Boolean(v));
|
|
68493
68644
|
if (viewports.length === 0) {
|
|
68494
|
-
console.error(
|
|
68645
|
+
console.error(chalk24.red(`--viewports inválido: ${opts.viewports}`));
|
|
68495
68646
|
return 2;
|
|
68496
68647
|
}
|
|
68497
68648
|
const primaryViewport = viewports[0];
|
|
68498
68649
|
if (opts.componentViewports && viewports.length < 2) {
|
|
68499
|
-
console.warn(
|
|
68650
|
+
console.warn(chalk24.yellow(" ! --component-viewports needs a second viewport in --viewports; ignored."));
|
|
68500
68651
|
}
|
|
68501
68652
|
if (!isValidUrl4(opts.url)) {
|
|
68502
|
-
console.error(
|
|
68653
|
+
console.error(chalk24.red(`--url inválido: ${opts.url}`));
|
|
68503
68654
|
return 2;
|
|
68504
68655
|
}
|
|
68505
68656
|
const format = normalizeFormat2(opts.format);
|
|
68506
68657
|
if (!format) {
|
|
68507
|
-
console.error(
|
|
68658
|
+
console.error(chalk24.red(`--format inválido: ${opts.format} (use md|json|both)`));
|
|
68508
68659
|
return 2;
|
|
68509
68660
|
}
|
|
68510
68661
|
let pageTokens;
|
|
@@ -68514,14 +68665,14 @@ async function migrateCommand(opts) {
|
|
|
68514
68665
|
fallback: ["/", "category-auto", "pdp-auto"]
|
|
68515
68666
|
});
|
|
68516
68667
|
} catch (err) {
|
|
68517
|
-
console.error(
|
|
68668
|
+
console.error(chalk24.red(err.message));
|
|
68518
68669
|
return 2;
|
|
68519
68670
|
}
|
|
68520
68671
|
let playbook;
|
|
68521
68672
|
if (opts.target) {
|
|
68522
68673
|
playbook = getTargetPlaybook(opts.target);
|
|
68523
68674
|
if (!playbook) {
|
|
68524
|
-
console.error(
|
|
68675
|
+
console.error(chalk24.red(`--target inválido: ${opts.target} (disponíveis: ${TARGET_NAMES.join(", ")})`));
|
|
68525
68676
|
return 2;
|
|
68526
68677
|
}
|
|
68527
68678
|
}
|
|
@@ -68531,7 +68682,7 @@ async function migrateCommand(opts) {
|
|
|
68531
68682
|
if (opts.sourceKind) {
|
|
68532
68683
|
const s = getSource(opts.sourceKind);
|
|
68533
68684
|
if (!s) {
|
|
68534
|
-
console.error(
|
|
68685
|
+
console.error(chalk24.red(`--source-kind inválido: ${opts.sourceKind} (disponíveis: ${SOURCE_KINDS.join(", ")})`));
|
|
68535
68686
|
return 2;
|
|
68536
68687
|
}
|
|
68537
68688
|
source = s;
|
|
@@ -68540,23 +68691,23 @@ async function migrateCommand(opts) {
|
|
|
68540
68691
|
let sourceProject = null;
|
|
68541
68692
|
if (opts.source) {
|
|
68542
68693
|
if (!existsSync20(opts.source)) {
|
|
68543
|
-
console.error(
|
|
68694
|
+
console.error(chalk24.red(`--source não encontrado: ${opts.source}`));
|
|
68544
68695
|
return 2;
|
|
68545
68696
|
}
|
|
68546
68697
|
if (!opts.sourceKind)
|
|
68547
68698
|
source = detectSource(opts.source);
|
|
68548
68699
|
sourceInventory = source.inventory(opts.source);
|
|
68549
|
-
console.log(
|
|
68700
|
+
console.log(chalk24.dim(` source: ${source.label} — ${sourceInventory.components.length} component(s) from code`));
|
|
68550
68701
|
sourceProject = readSourceProject(opts.source, sourceInventory.components);
|
|
68551
68702
|
for (const note of sourceProject.notes)
|
|
68552
|
-
console.log(
|
|
68703
|
+
console.log(chalk24.dim(` ${note}`));
|
|
68553
68704
|
} else if (!opts.noSourceHunt) {
|
|
68554
68705
|
sourceHunt = findSourceCandidates({
|
|
68555
68706
|
url: opts.url,
|
|
68556
68707
|
roots: defaultSearchRoots()
|
|
68557
68708
|
});
|
|
68558
68709
|
const message = formatSourceHunt(sourceHunt);
|
|
68559
|
-
console.log(sourceHunt.candidates.length > 0 ?
|
|
68710
|
+
console.log(sourceHunt.candidates.length > 0 ? chalk24.yellow(message) : chalk24.dim(message));
|
|
68560
68711
|
}
|
|
68561
68712
|
const host = safeHost6(opts.url);
|
|
68562
68713
|
const runDir = resolve7(opts.outDir, host);
|
|
@@ -68581,9 +68732,9 @@ async function migrateCommand(opts) {
|
|
|
68581
68732
|
stack = meta.stack ?? null;
|
|
68582
68733
|
assets = meta.assets;
|
|
68583
68734
|
screenshots = meta.screenshots ?? [];
|
|
68584
|
-
console.log(
|
|
68735
|
+
console.log(chalk24.dim(" phase 1 theme+assets: cached"));
|
|
68585
68736
|
} else {
|
|
68586
|
-
console.log(
|
|
68737
|
+
console.log(chalk24.dim(` phase 1 theme+assets: scraping (${viewports.join(", ")})…`));
|
|
68587
68738
|
mkdirSync16(resolve7(runDir, "screenshots"), { recursive: true });
|
|
68588
68739
|
const samples = [];
|
|
68589
68740
|
screenshots = [];
|
|
@@ -68608,9 +68759,9 @@ async function migrateCommand(opts) {
|
|
|
68608
68759
|
platformSeen = detectPlatform({ url: opts.url, html: pageHtml });
|
|
68609
68760
|
const cookieNames = await ctx.cookies().then((cs) => cs.map((c) => c.name).join("; ")).catch(() => "");
|
|
68610
68761
|
stack = classifyLiveStack(pageHtml, cookieNames);
|
|
68611
|
-
console.log(
|
|
68762
|
+
console.log(chalk24.dim(` stack: ${describeStack(stack)}`));
|
|
68612
68763
|
if (!opts.source && stack.frontend !== "unknown") {
|
|
68613
|
-
console.warn(
|
|
68764
|
+
console.warn(chalk24.red(` ! live-only capture, but the live HTML is ${stack.frontend} (${stack.evidence.join(", ")}) — a source repo exists.
|
|
68614
68765
|
Re-run with --source <repo> for structural porting (real class strings, not measured pixels).`));
|
|
68615
68766
|
}
|
|
68616
68767
|
const rawAssets = await collectSiteAssets(page);
|
|
@@ -68646,9 +68797,9 @@ async function migrateCommand(opts) {
|
|
|
68646
68797
|
let resolvedPages;
|
|
68647
68798
|
if (!opts.refresh && existsSync20(sitemapPath)) {
|
|
68648
68799
|
resolvedPages = readJson(sitemapPath).pages;
|
|
68649
|
-
console.log(
|
|
68800
|
+
console.log(chalk24.dim(` phase 2 sitemap: cached (${resolvedPages.length} page(s))`));
|
|
68650
68801
|
} else {
|
|
68651
|
-
console.log(
|
|
68802
|
+
console.log(chalk24.dim(" phase 2 sitemap: resolving pages…"));
|
|
68652
68803
|
const ctx = await newContext(browser, { viewport: primaryViewport, ...auth });
|
|
68653
68804
|
const page = await ctx.newPage();
|
|
68654
68805
|
let sitemapUrls = [];
|
|
@@ -68676,13 +68827,13 @@ async function migrateCommand(opts) {
|
|
|
68676
68827
|
a[p.kind] = (a[p.kind] ?? 0) + 1;
|
|
68677
68828
|
return a;
|
|
68678
68829
|
}, {});
|
|
68679
|
-
console.log(
|
|
68830
|
+
console.log(chalk24.dim(` phase 2 sitemap: +${sampled.length} sampled (${Object.entries(byKind).map(([k, n]) => `${n} ${k}`).join(", ")})`));
|
|
68680
68831
|
}
|
|
68681
68832
|
writeFileSync26(sitemapPath, `${JSON.stringify({ pages: resolvedPages, sitemapUrls: classified }, null, 2)}
|
|
68682
68833
|
`, "utf8");
|
|
68683
68834
|
}
|
|
68684
68835
|
if (resolvedPages.length === 0) {
|
|
68685
|
-
console.error(
|
|
68836
|
+
console.error(chalk24.red("nenhuma página resolvida a partir de --pages"));
|
|
68686
68837
|
return 1;
|
|
68687
68838
|
}
|
|
68688
68839
|
const capturePath = resolve7(runDir, "capture.json");
|
|
@@ -68694,9 +68845,9 @@ async function migrateCommand(opts) {
|
|
|
68694
68845
|
components = cached.components;
|
|
68695
68846
|
vtexBlocks = cached.vtexBlocks ?? null;
|
|
68696
68847
|
contentMap = cached.contentMap ?? {};
|
|
68697
|
-
console.log(
|
|
68848
|
+
console.log(chalk24.dim(` phase 3 components: cached (${components.length})`));
|
|
68698
68849
|
} else {
|
|
68699
|
-
console.log(
|
|
68850
|
+
console.log(chalk24.dim(" phase 3 components: capturing…"));
|
|
68700
68851
|
({ pages, components, vtexBlocks, contentMap } = await capturePages(browser, primaryViewport, resolvedPages, theme, {
|
|
68701
68852
|
allowlist,
|
|
68702
68853
|
llm: !opts.noLlm,
|
|
@@ -68762,13 +68913,13 @@ async function migrateCommand(opts) {
|
|
|
68762
68913
|
const projectPath = resolve7(runDir, "source-project.json");
|
|
68763
68914
|
writeFileSync26(projectPath, `${JSON.stringify(sourceProject, null, 2)}
|
|
68764
68915
|
`, "utf8");
|
|
68765
|
-
console.log(
|
|
68916
|
+
console.log(chalk24.dim(` source-project.json — ${sourceProject.totals.components} component detail(s), ${sourceProject.totals.pages} CMS page(s), ${sourceProject.tokenFiles.length} token file(s)`));
|
|
68766
68917
|
}
|
|
68767
68918
|
if (merged.carried.length) {
|
|
68768
|
-
console.log(
|
|
68919
|
+
console.log(chalk24.gray(` plan: carried ${merged.carried.length} recorded decision(s) forward`));
|
|
68769
68920
|
}
|
|
68770
68921
|
if (merged.keptUncaptured.length) {
|
|
68771
|
-
console.log(
|
|
68922
|
+
console.log(chalk24.yellow(` plan: ${merged.keptUncaptured.length} row(s) kept although this capture no longer sees them — ${merged.keptUncaptured.join(", ")}. They carry a decision or were added by hand; the capture owns the captured row set, not rows it cannot see.`));
|
|
68772
68923
|
}
|
|
68773
68924
|
bundle.components.push(...syntheticSourceComponents(plan));
|
|
68774
68925
|
if (format === "json" || format === "both")
|
|
@@ -68915,9 +69066,9 @@ async function capturePages(browser, viewport, resolvedPages, theme, cfg) {
|
|
|
68915
69066
|
if (imageBudget) {
|
|
68916
69067
|
const unsaved = [...imageBudget.byUrl.values()].filter((f) => !f.path).length;
|
|
68917
69068
|
const failed = unsaved - imageBudget.capped;
|
|
68918
|
-
console.log(
|
|
69069
|
+
console.log(chalk24.dim(` phase 3 components: ${imageBudget.files} component image(s) saved (${(imageBudget.bytes / 1024 / 1024).toFixed(1)} MB, ${failed} failed) in ${(imageMs / 1000).toFixed(1)}s`));
|
|
68919
69070
|
if (imageBudget.capped)
|
|
68920
|
-
console.log(
|
|
69071
|
+
console.log(chalk24.yellow(` ⚠ component images: per-run cap hit (${imageBudget.maxFiles} files / ${Math.round(imageBudget.maxBytes / 1024 / 1024)} MB) — ${imageBudget.capped} URL(s) NOT saved, listed per component in imageFiles[].error`));
|
|
68921
69072
|
}
|
|
68922
69073
|
return {
|
|
68923
69074
|
pages,
|
|
@@ -68969,7 +69120,7 @@ async function captureViewportVariants(browser, url, extraViewports, captured, r
|
|
|
68969
69120
|
} catch (err) {
|
|
68970
69121
|
const reason = `${vp} load failed: ${err.message.split(`
|
|
68971
69122
|
`)[0]}`;
|
|
68972
|
-
console.warn(
|
|
69123
|
+
console.warn(chalk24.yellow(` ! --component-viewports: ${url} — ${reason}; skipped`));
|
|
68973
69124
|
for (let i = done;i < captured.length; i++) {
|
|
68974
69125
|
perComponent[i].push({ viewport: vp, status: "failed", reason });
|
|
68975
69126
|
}
|
|
@@ -69017,12 +69168,12 @@ async function resolvePages2(page, baseUrl, tokens, homeHtml, platform) {
|
|
|
69017
69168
|
if (plp)
|
|
69018
69169
|
out.push({ path: token, url: plp, kind: "plp" });
|
|
69019
69170
|
else
|
|
69020
|
-
console.warn(
|
|
69171
|
+
console.warn(chalk24.yellow(" ⚠ category-auto: nenhuma PLP descoberta na home"));
|
|
69021
69172
|
continue;
|
|
69022
69173
|
}
|
|
69023
69174
|
if (token === "pdp-auto") {
|
|
69024
69175
|
if (!plp) {
|
|
69025
|
-
console.warn(
|
|
69176
|
+
console.warn(chalk24.yellow(" ⚠ pdp-auto: sem PLP pra derivar PDP"));
|
|
69026
69177
|
continue;
|
|
69027
69178
|
}
|
|
69028
69179
|
let html = null;
|
|
@@ -69039,7 +69190,7 @@ async function resolvePages2(page, baseUrl, tokens, homeHtml, platform) {
|
|
|
69039
69190
|
if (pdp)
|
|
69040
69191
|
out.push({ path: token, url: pdp, kind: "pdp" });
|
|
69041
69192
|
else
|
|
69042
|
-
console.warn(
|
|
69193
|
+
console.warn(chalk24.yellow(" ⚠ pdp-auto: nenhum produto encontrado na PLP"));
|
|
69043
69194
|
continue;
|
|
69044
69195
|
}
|
|
69045
69196
|
try {
|
|
@@ -69133,25 +69284,25 @@ function kindOf(url) {
|
|
|
69133
69284
|
}
|
|
69134
69285
|
}
|
|
69135
69286
|
function printResults4(runDir, bundle) {
|
|
69136
|
-
console.log(
|
|
69287
|
+
console.log(chalk24.bold(`
|
|
69137
69288
|
parity migrate`));
|
|
69138
|
-
console.log(
|
|
69139
|
-
console.log(
|
|
69140
|
-
console.log(
|
|
69141
|
-
console.log(
|
|
69142
|
-
console.log(
|
|
69289
|
+
console.log(chalk24.dim(` url: ${bundle.url}`));
|
|
69290
|
+
console.log(chalk24.dim(` platform: ${bundle.platform}${bundle.target ? ` → ${bundle.target}` : ""}`));
|
|
69291
|
+
console.log(chalk24.dim(` viewports:${(bundle.viewports ?? [bundle.viewport]).join(", ")}`));
|
|
69292
|
+
console.log(chalk24.dim(` theme: primary=${bundle.theme.colors.primary ?? "—"} text=${bundle.theme.colors.text ?? "—"}`));
|
|
69293
|
+
console.log(chalk24.dim(` assets: logo=${bundle.assets.logo ? "✓" : "✗"} favicon=${bundle.assets.favicon ? "✓" : "✗"} icons=${bundle.assets.icons.length} fonts=${bundle.assets.fontFiles.length}`));
|
|
69143
69294
|
if (bundle.vtex) {
|
|
69144
69295
|
const mapped = bundle.vtex.map.filter((m) => m.strategy === "mapped").length;
|
|
69145
69296
|
const withContent = bundle.vtex.blocks.filter((x) => x.props).length;
|
|
69146
69297
|
const contentImgs = countContentImages(bundle.vtex.blocks);
|
|
69147
|
-
console.log(
|
|
69298
|
+
console.log(chalk24.dim(` vtex io: ${bundle.vtex.blocks.length} blocks (${withContent} with CMS content, ${contentImgs} content images local) · ${mapped}/${bundle.vtex.map.length} mapped`));
|
|
69148
69299
|
}
|
|
69149
|
-
console.log(
|
|
69150
|
-
console.log(
|
|
69300
|
+
console.log(chalk24.dim(` pages: ${bundle.pages.map((p) => p.kind).join(", ") || "—"}`));
|
|
69301
|
+
console.log(chalk24.dim(` out: ${runDir}`));
|
|
69151
69302
|
console.log("");
|
|
69152
|
-
console.log(
|
|
69303
|
+
console.log(chalk24.bold(` ${bundle.components.length} component(s):`));
|
|
69153
69304
|
for (const c of bundle.components) {
|
|
69154
|
-
console.log(` ${
|
|
69305
|
+
console.log(` ${chalk24.cyan(`${c.scope}/${c.role}`.padEnd(28))} ${chalk24.dim(`${c.tailwind.length} tw · ${c.interactions.length} interactions`)}`);
|
|
69155
69306
|
}
|
|
69156
69307
|
console.log("");
|
|
69157
69308
|
}
|
|
@@ -69201,7 +69352,7 @@ function isValidUrl4(s) {
|
|
|
69201
69352
|
|
|
69202
69353
|
// src/commands/plan.ts
|
|
69203
69354
|
import { readFileSync as readFileSync27 } from "node:fs";
|
|
69204
|
-
import
|
|
69355
|
+
import chalk25 from "chalk";
|
|
69205
69356
|
var STATUSES = [
|
|
69206
69357
|
"pending",
|
|
69207
69358
|
"partial",
|
|
@@ -69214,12 +69365,12 @@ var STATUSES = [
|
|
|
69214
69365
|
var PAGE_STATUSES = ["pending", "code", "done", "skipped"];
|
|
69215
69366
|
function planSetStatusCommand(dir, name, status, opts = {}) {
|
|
69216
69367
|
if (!STATUSES.includes(status)) {
|
|
69217
|
-
console.error(
|
|
69368
|
+
console.error(chalk25.red(`Invalid status "${status}". Use one of: ${STATUSES.join(", ")}`));
|
|
69218
69369
|
return 1;
|
|
69219
69370
|
}
|
|
69220
69371
|
const plan = loadPlan(dir);
|
|
69221
69372
|
if (!plan) {
|
|
69222
|
-
console.error(
|
|
69373
|
+
console.error(chalk25.red(`No migration-plan.json found in ${dir}`));
|
|
69223
69374
|
return 1;
|
|
69224
69375
|
}
|
|
69225
69376
|
const existed = plan.components.length;
|
|
@@ -69230,54 +69381,54 @@ function planSetStatusCommand(dir, name, status, opts = {}) {
|
|
|
69230
69381
|
note: opts.note
|
|
69231
69382
|
});
|
|
69232
69383
|
} catch (err) {
|
|
69233
|
-
console.error(
|
|
69384
|
+
console.error(chalk25.red(err.message));
|
|
69234
69385
|
return 1;
|
|
69235
69386
|
}
|
|
69236
69387
|
if (!component) {
|
|
69237
|
-
console.error(
|
|
69238
|
-
console.error(
|
|
69388
|
+
console.error(chalk25.red(`No component matching "${name}" in the plan`));
|
|
69389
|
+
console.error(chalk25.yellow("A capture can miss a component that exists — a zero-height overlay header, a portal-rendered panel. Add it with --create global|page if this is one of those, so the plan can hold a decision about it."));
|
|
69239
69390
|
return 1;
|
|
69240
69391
|
}
|
|
69241
69392
|
if (plan.components.length > existed) {
|
|
69242
|
-
console.log(
|
|
69393
|
+
console.log(chalk25.yellow(` + created ${component.name} (${opts.create}, origin: manual) — not from the capture`));
|
|
69243
69394
|
}
|
|
69244
69395
|
savePlan(dir, plan);
|
|
69245
|
-
console.log(`${
|
|
69396
|
+
console.log(`${chalk25.green("✓")} ${component.name} → ${status}`);
|
|
69246
69397
|
if ((status === "upgrade" || status === "as-is") && !component.reference) {
|
|
69247
|
-
console.log(
|
|
69398
|
+
console.log(chalk25.yellow(` no reason recorded — run \`parity plan set-reference ${component.name} --note "<why>"${status === "upgrade" ? " --url <reference site>" : ""}\``));
|
|
69248
69399
|
}
|
|
69249
69400
|
return 0;
|
|
69250
69401
|
}
|
|
69251
69402
|
function planSetPageStatusCommand(dir, path, status) {
|
|
69252
69403
|
if (!PAGE_STATUSES.includes(status)) {
|
|
69253
|
-
console.error(
|
|
69404
|
+
console.error(chalk25.red(`Invalid status "${status}". Use one of: ${PAGE_STATUSES.join(", ")}`));
|
|
69254
69405
|
return 1;
|
|
69255
69406
|
}
|
|
69256
69407
|
const plan = loadPlan(dir);
|
|
69257
69408
|
if (!plan) {
|
|
69258
|
-
console.error(
|
|
69409
|
+
console.error(chalk25.red(`No migration-plan.json found in ${dir}`));
|
|
69259
69410
|
return 1;
|
|
69260
69411
|
}
|
|
69261
69412
|
const page = setPageStatus(plan, path, status);
|
|
69262
69413
|
if (!page) {
|
|
69263
|
-
console.error(
|
|
69414
|
+
console.error(chalk25.red(`No page matching "${path}" in the plan`));
|
|
69264
69415
|
return 1;
|
|
69265
69416
|
}
|
|
69266
69417
|
savePlan(dir, plan);
|
|
69267
|
-
console.log(`${
|
|
69418
|
+
console.log(`${chalk25.green("✓")} ${page.path} → ${status}`);
|
|
69268
69419
|
return 0;
|
|
69269
69420
|
}
|
|
69270
69421
|
var DISPOSITION_STYLE = {
|
|
69271
|
-
build:
|
|
69272
|
-
validate:
|
|
69273
|
-
upgrade:
|
|
69274
|
-
"as-is":
|
|
69275
|
-
settled:
|
|
69422
|
+
build: chalk25.red,
|
|
69423
|
+
validate: chalk25.yellow,
|
|
69424
|
+
upgrade: chalk25.cyan,
|
|
69425
|
+
"as-is": chalk25.gray,
|
|
69426
|
+
settled: chalk25.green
|
|
69276
69427
|
};
|
|
69277
69428
|
function planSetReferenceCommand(dir, name, opts) {
|
|
69278
69429
|
const plan = loadPlan(dir);
|
|
69279
69430
|
if (!plan) {
|
|
69280
|
-
console.error(
|
|
69431
|
+
console.error(chalk25.red(`No migration-plan.json found in ${dir}`));
|
|
69281
69432
|
return 1;
|
|
69282
69433
|
}
|
|
69283
69434
|
const component = setComponentReference(plan, name, {
|
|
@@ -69286,76 +69437,76 @@ function planSetReferenceCommand(dir, name, opts) {
|
|
|
69286
69437
|
note: opts.note
|
|
69287
69438
|
});
|
|
69288
69439
|
if (!component) {
|
|
69289
|
-
console.error(
|
|
69440
|
+
console.error(chalk25.red(`No component matching "${name}" in the plan`));
|
|
69290
69441
|
return 1;
|
|
69291
69442
|
}
|
|
69292
69443
|
savePlan(dir, plan);
|
|
69293
|
-
console.log(`${
|
|
69444
|
+
console.log(`${chalk25.green("✓")} ${component.name} → reference ${component.reference?.url}`);
|
|
69294
69445
|
return 0;
|
|
69295
69446
|
}
|
|
69296
69447
|
function planVerifyCommand(dir, name, verdict, opts) {
|
|
69297
69448
|
if (verdict !== "pass" && verdict !== "fail" && verdict !== "inconclusive") {
|
|
69298
|
-
console.error(
|
|
69449
|
+
console.error(chalk25.red(`Invalid verdict "${verdict}". Use pass, fail or inconclusive.`));
|
|
69299
69450
|
return 1;
|
|
69300
69451
|
}
|
|
69301
69452
|
const plan = loadPlan(dir);
|
|
69302
69453
|
if (!plan) {
|
|
69303
|
-
console.error(
|
|
69454
|
+
console.error(chalk25.red(`No migration-plan.json found in ${dir}`));
|
|
69304
69455
|
return 1;
|
|
69305
69456
|
}
|
|
69306
69457
|
const component = setComponentVerified(plan, name, verdict, opts.at ?? new Date().toISOString(), opts.note);
|
|
69307
69458
|
if (!component) {
|
|
69308
|
-
console.error(
|
|
69459
|
+
console.error(chalk25.red(`No component matching "${name}" in the plan`));
|
|
69309
69460
|
return 1;
|
|
69310
69461
|
}
|
|
69311
69462
|
savePlan(dir, plan);
|
|
69312
|
-
const mark = verdict === "pass" ?
|
|
69463
|
+
const mark = verdict === "pass" ? chalk25.green("✓") : verdict === "inconclusive" ? chalk25.yellow("?") : chalk25.red("✗");
|
|
69313
69464
|
console.log(`${mark} ${component.name} → ${verdict} (against ${component.verified?.against})`);
|
|
69314
69465
|
return 0;
|
|
69315
69466
|
}
|
|
69316
69467
|
function planMergeCommand(dir, sourceDir) {
|
|
69317
69468
|
const fresh = loadPlan(sourceDir);
|
|
69318
69469
|
if (!fresh) {
|
|
69319
|
-
console.error(
|
|
69470
|
+
console.error(chalk25.red(`No migration-plan.json found in ${sourceDir}`));
|
|
69320
69471
|
return 1;
|
|
69321
69472
|
}
|
|
69322
69473
|
const existing = loadPlan(dir);
|
|
69323
69474
|
const { plan, carried, keptUncaptured } = mergePlanDecisions(fresh, existing);
|
|
69324
69475
|
savePlan(dir, plan);
|
|
69325
69476
|
if (!existing) {
|
|
69326
|
-
console.log(`${
|
|
69477
|
+
console.log(`${chalk25.green("✓")} plan written to ${dir} (nothing to merge)`);
|
|
69327
69478
|
return 0;
|
|
69328
69479
|
}
|
|
69329
|
-
console.log(`${
|
|
69480
|
+
console.log(`${chalk25.green("✓")} merged into ${dir} — ${carried.length} decision(s) kept`);
|
|
69330
69481
|
if (keptUncaptured.length) {
|
|
69331
|
-
console.log(
|
|
69482
|
+
console.log(chalk25.yellow(` kept although no longer in the capture: ${keptUncaptured.join(", ")}`));
|
|
69332
69483
|
}
|
|
69333
69484
|
return 0;
|
|
69334
69485
|
}
|
|
69335
69486
|
function planPageCommand(dir, path, opts) {
|
|
69336
69487
|
const plan = loadPlan(dir);
|
|
69337
69488
|
if (!plan) {
|
|
69338
|
-
console.error(
|
|
69489
|
+
console.error(chalk25.red(`No migration-plan.json found in ${dir}`));
|
|
69339
69490
|
return 1;
|
|
69340
69491
|
}
|
|
69341
69492
|
const page = pagePlan(plan, path, opts.cand);
|
|
69342
69493
|
if (!page) {
|
|
69343
|
-
console.error(
|
|
69344
|
-
console.error(
|
|
69494
|
+
console.error(chalk25.red(`No page matching "${path}" in the plan`));
|
|
69495
|
+
console.error(chalk25.gray(` known pages: ${plan.pages.map((p) => p.path).join(", ")}`));
|
|
69345
69496
|
return 1;
|
|
69346
69497
|
}
|
|
69347
69498
|
if (opts.json) {
|
|
69348
69499
|
console.log(JSON.stringify(page, null, 2));
|
|
69349
69500
|
return 0;
|
|
69350
69501
|
}
|
|
69351
|
-
console.log(
|
|
69352
|
-
${page.path} ${
|
|
69502
|
+
console.log(chalk25.bold(`
|
|
69503
|
+
${page.path} ${chalk25.gray(`(${page.kind})`)} — ${page.status}`) + (page.ready ? chalk25.green(" ready") : ""));
|
|
69353
69504
|
if (page.tasks === null) {
|
|
69354
|
-
console.log(
|
|
69505
|
+
console.log(chalk25.yellow("\n This plan has no page/component edges — it predates them. Re-run `parity migrate` to get per-page work.\n"));
|
|
69355
69506
|
return 0;
|
|
69356
69507
|
}
|
|
69357
69508
|
if (page.tasks.length === 0) {
|
|
69358
|
-
console.log(
|
|
69509
|
+
console.log(chalk25.gray(`
|
|
69359
69510
|
The capture saw no components on this page.
|
|
69360
69511
|
`));
|
|
69361
69512
|
return 0;
|
|
@@ -69366,22 +69517,22 @@ ${page.path} ${chalk24.gray(`(${page.kind})`)} — ${page.status}`) + (page.read
|
|
|
69366
69517
|
if (!rows.length)
|
|
69367
69518
|
continue;
|
|
69368
69519
|
console.log(`
|
|
69369
|
-
${DISPOSITION_STYLE[d](
|
|
69520
|
+
${DISPOSITION_STYLE[d](chalk25.bold(d))} (${rows.length})`);
|
|
69370
69521
|
for (const t of rows) {
|
|
69371
|
-
console.log(` ${t.name} ${
|
|
69522
|
+
console.log(` ${t.name} ${chalk25.gray(`(${t.scope}, ${t.origin}, ${t.status})`)}`);
|
|
69372
69523
|
if (t.note)
|
|
69373
|
-
console.log(
|
|
69524
|
+
console.log(chalk25.gray(` why: ${t.note}`));
|
|
69374
69525
|
if (t.against?.kind === "reference") {
|
|
69375
|
-
console.log(
|
|
69526
|
+
console.log(chalk25.cyan(` reference: ${t.against.url}`));
|
|
69376
69527
|
}
|
|
69377
69528
|
if (t.source)
|
|
69378
|
-
console.log(
|
|
69529
|
+
console.log(chalk25.green(` source: ${t.source}`));
|
|
69379
69530
|
if (t.command)
|
|
69380
|
-
console.log(
|
|
69531
|
+
console.log(chalk25.gray(` $ ${t.command}`));
|
|
69381
69532
|
}
|
|
69382
69533
|
}
|
|
69383
69534
|
if (page.counts.validate > 0 && !opts.cand) {
|
|
69384
|
-
console.log(
|
|
69535
|
+
console.log(chalk25.yellow("\n Pass --cand <url> to get runnable `parity section` commands."));
|
|
69385
69536
|
}
|
|
69386
69537
|
console.log("");
|
|
69387
69538
|
return 0;
|
|
@@ -69389,8 +69540,8 @@ ${DISPOSITION_STYLE[d](chalk24.bold(d))} (${rows.length})`);
|
|
|
69389
69540
|
function planStatusCommand(dir, asJson) {
|
|
69390
69541
|
const plan = loadPlan(dir);
|
|
69391
69542
|
if (!plan) {
|
|
69392
|
-
console.error(
|
|
69393
|
-
console.error(
|
|
69543
|
+
console.error(chalk25.red(`No migration-plan.json found in ${dir}`));
|
|
69544
|
+
console.error(chalk25.yellow("Run `parity migrate --url <prod>` first — without a plan there is no inventory."));
|
|
69394
69545
|
return 1;
|
|
69395
69546
|
}
|
|
69396
69547
|
const p = planProgress(plan);
|
|
@@ -69401,57 +69552,57 @@ function planStatusCommand(dir, asJson) {
|
|
|
69401
69552
|
return 0;
|
|
69402
69553
|
}
|
|
69403
69554
|
const c = p.components;
|
|
69404
|
-
console.log(
|
|
69555
|
+
console.log(chalk25.bold(`
|
|
69405
69556
|
Migration plan — ${plan.url}${plan.target.name ? ` → ${plan.target.name}` : ""}`));
|
|
69406
|
-
const vanished = c.byStatus.vanished ? `, ${
|
|
69557
|
+
const vanished = c.byStatus.vanished ? `, ${chalk25.gray(`${c.byStatus.vanished} vanished`)}` : "";
|
|
69407
69558
|
console.log(`
|
|
69408
|
-
${
|
|
69559
|
+
${chalk25.bold("Components")} (${c.total}): ` + `${chalk25.green(`${c.byStatus.done} done`)}, ` + `${chalk25.yellow(`${c.byStatus.partial} partial`)}, ` + `${chalk25.red(`${c.byStatus.pending} pending`)}, ` + `${chalk25.cyan(`${c.byStatus.upgrade} upgrade`)}, ` + `${chalk25.gray(`${c.byStatus["as-is"]} as-is`)}, ` + `${chalk25.gray(`${c.byStatus.skipped} skipped`)}${vanished}`);
|
|
69409
69560
|
if (c.accepted.upgrade.length) {
|
|
69410
|
-
console.log(
|
|
69561
|
+
console.log(chalk25.cyan(` deliberately ahead of prod: ${c.accepted.upgrade.join(", ")}`));
|
|
69411
69562
|
}
|
|
69412
69563
|
if (c.accepted.asIs.length) {
|
|
69413
|
-
console.log(
|
|
69564
|
+
console.log(chalk25.gray(` divergence accepted: ${c.accepted.asIs.join(", ")}`));
|
|
69414
69565
|
}
|
|
69415
69566
|
if (provenance.library > 0 || provenance.built > 0) {
|
|
69416
|
-
const unrecorded = provenance.unrecorded > 0 ?
|
|
69417
|
-
console.log(` reuse: ${
|
|
69567
|
+
const unrecorded = provenance.unrecorded > 0 ? chalk25.dim(`, ${provenance.unrecorded} unrecorded`) : "";
|
|
69568
|
+
console.log(` reuse: ${chalk25.green(`${provenance.library} from the library`)}, ${provenance.built} written here${unrecorded}`);
|
|
69418
69569
|
}
|
|
69419
69570
|
if (touches > 0) {
|
|
69420
|
-
console.log(
|
|
69571
|
+
console.log(chalk25.dim(` human touches: ${touches} across this migration`));
|
|
69421
69572
|
}
|
|
69422
69573
|
if (c.settledByStatus.done.length) {
|
|
69423
|
-
console.log(
|
|
69574
|
+
console.log(chalk25.green(` ported and validated: ${c.settledByStatus.done.join(", ")}`));
|
|
69424
69575
|
}
|
|
69425
69576
|
if (c.settledByStatus.skipped.length) {
|
|
69426
|
-
console.log(
|
|
69577
|
+
console.log(chalk25.gray(` skipped: ${c.settledByStatus.skipped.join(", ")}`));
|
|
69427
69578
|
}
|
|
69428
69579
|
if (c.settledByStatus.vanished.length) {
|
|
69429
|
-
console.log(
|
|
69580
|
+
console.log(chalk25.gray(` gone from prod, shipped disabled: ${c.settledByStatus.vanished.join(", ")}`));
|
|
69430
69581
|
}
|
|
69431
69582
|
for (const r of c.remaining) {
|
|
69432
|
-
const tag = r.status === "partial" ?
|
|
69433
|
-
console.log(` ${tag} ${r.name} ${
|
|
69583
|
+
const tag = r.status === "partial" ? chalk25.yellow("partial") : chalk25.red("pending");
|
|
69584
|
+
console.log(` ${tag} ${r.name} ${chalk25.gray(`(${r.scope}, ${r.origin})`)}`);
|
|
69434
69585
|
}
|
|
69435
69586
|
const pg = p.pages;
|
|
69436
69587
|
console.log(`
|
|
69437
|
-
${
|
|
69588
|
+
${chalk25.bold("Pages")} (${pg.total}): ` + `${chalk25.green(`${pg.byStatus.done} done`)}, ` + `${chalk25.yellow(`${pg.byStatus.code} code-only`)}, ` + `${chalk25.red(`${pg.byStatus.pending} pending`)}, ` + `${chalk25.gray(`${pg.byStatus.skipped} skipped`)}`);
|
|
69438
69589
|
if (pg.awaitingContent.length) {
|
|
69439
|
-
console.log(
|
|
69590
|
+
console.log(chalk25.yellow(` awaiting CMS content: ${pg.awaitingContent.join(", ")}`));
|
|
69440
69591
|
}
|
|
69441
69592
|
for (const r of pg.remaining.filter((r) => r.status === "pending")) {
|
|
69442
|
-
console.log(` ${
|
|
69593
|
+
console.log(` ${chalk25.red("pending")} ${r.path} ${chalk25.gray(`(${r.kind})`)}`);
|
|
69443
69594
|
}
|
|
69444
69595
|
console.log("");
|
|
69445
69596
|
return 0;
|
|
69446
69597
|
}
|
|
69447
69598
|
var COLUMN_ORDER = ["triage", "backlog", "building", "review", "done"];
|
|
69448
69599
|
var COLUMN_STYLE = {
|
|
69449
|
-
triage:
|
|
69450
|
-
backlog:
|
|
69451
|
-
building:
|
|
69452
|
-
review:
|
|
69453
|
-
done:
|
|
69454
|
-
skipped:
|
|
69600
|
+
triage: chalk25.magenta,
|
|
69601
|
+
backlog: chalk25.red,
|
|
69602
|
+
building: chalk25.yellow,
|
|
69603
|
+
review: chalk25.cyan,
|
|
69604
|
+
done: chalk25.green,
|
|
69605
|
+
skipped: chalk25.gray
|
|
69455
69606
|
};
|
|
69456
69607
|
async function planBoardCommand(dirs, opts) {
|
|
69457
69608
|
const list = typeof dirs === "string" ? [dirs] : dirs;
|
|
@@ -69459,8 +69610,8 @@ async function planBoardCommand(dirs, opts) {
|
|
|
69459
69610
|
for (const scope of list) {
|
|
69460
69611
|
const plan = loadPlan(scope);
|
|
69461
69612
|
if (!plan) {
|
|
69462
|
-
console.error(
|
|
69463
|
-
console.error(
|
|
69613
|
+
console.error(chalk25.red(`No migration-plan.json found in ${scope}`));
|
|
69614
|
+
console.error(chalk25.yellow("Run `parity migrate --url <prod>` first — no plan, no board."));
|
|
69464
69615
|
return 1;
|
|
69465
69616
|
}
|
|
69466
69617
|
scoped.push({ scope, plan });
|
|
@@ -69472,54 +69623,54 @@ async function planBoardCommand(dirs, opts) {
|
|
|
69472
69623
|
console.log(JSON.stringify(board, null, 2));
|
|
69473
69624
|
return 0;
|
|
69474
69625
|
}
|
|
69475
|
-
console.log(
|
|
69626
|
+
console.log(chalk25.bold(`
|
|
69476
69627
|
Board — ${board.url}`));
|
|
69477
|
-
console.log(
|
|
69628
|
+
console.log(chalk25.gray(`${board.sampled} sampled page(s) — the capture's sample, not every URL on the site.`));
|
|
69478
69629
|
if (board.shell.length) {
|
|
69479
69630
|
console.log(`
|
|
69480
|
-
${
|
|
69631
|
+
${chalk25.bold("shell")} ${chalk25.gray("(global — blocks every page)")}: ${chalk25.yellow(board.shell.join(", "))}`);
|
|
69481
69632
|
}
|
|
69482
69633
|
for (const column of COLUMN_ORDER) {
|
|
69483
69634
|
const cards = board.columns[column];
|
|
69484
69635
|
if (!cards.length)
|
|
69485
69636
|
continue;
|
|
69486
69637
|
console.log(`
|
|
69487
|
-
${COLUMN_STYLE[column](
|
|
69638
|
+
${COLUMN_STYLE[column](chalk25.bold(column))} (${cards.length})`);
|
|
69488
69639
|
for (const card of cards) {
|
|
69489
|
-
const scope = card.scope ?
|
|
69490
|
-
console.log(` ${scope}${card.path} ${
|
|
69640
|
+
const scope = card.scope ? chalk25.cyan(`[${card.scope}] `) : "";
|
|
69641
|
+
console.log(` ${scope}${card.path} ${chalk25.gray(`(${card.kind})`)}`);
|
|
69491
69642
|
if (card.blockers.length) {
|
|
69492
|
-
console.log(
|
|
69643
|
+
console.log(chalk25.gray(` blocked by: ${card.blockers.join(", ")}`));
|
|
69493
69644
|
}
|
|
69494
69645
|
}
|
|
69495
69646
|
}
|
|
69496
69647
|
const skipped = board.columns.skipped;
|
|
69497
69648
|
if (skipped.length) {
|
|
69498
69649
|
console.log(`
|
|
69499
|
-
${
|
|
69650
|
+
${chalk25.gray(`skipped (${skipped.length}): ${skipped.map((c) => c.scope ? `[${c.scope}] ${c.path}` : c.path).join(", ")}`)}`);
|
|
69500
69651
|
}
|
|
69501
69652
|
if (board.conflicts?.length) {
|
|
69502
69653
|
console.log(`
|
|
69503
|
-
${
|
|
69654
|
+
${chalk25.red.bold("conflicts")} ${chalk25.gray("(same component, different state per scope — settle by hand)")}`);
|
|
69504
69655
|
for (const c of board.conflicts) {
|
|
69505
69656
|
console.log(` ${c.component}: ${c.rows.map((r) => `[${r.scope}] ${r.status} (${r.disposition})`).join(" vs ")}`);
|
|
69506
69657
|
}
|
|
69507
69658
|
}
|
|
69508
69659
|
if (board.unassigned.length) {
|
|
69509
69660
|
console.log(`
|
|
69510
|
-
${
|
|
69511
|
-
${
|
|
69661
|
+
${chalk25.bold("no page")} ${chalk25.gray("(in the code, not seen on any sampled page)")}
|
|
69662
|
+
${chalk25.gray(board.unassigned.join(", "))}`);
|
|
69512
69663
|
}
|
|
69513
69664
|
console.log("");
|
|
69514
69665
|
if (opts.board === "studio" && scoped.length > 1) {
|
|
69515
|
-
console.log(
|
|
69666
|
+
console.log(chalk25.yellow(`Studio board skipped — push one --dir at a time.
|
|
69516
69667
|
`));
|
|
69517
69668
|
return 0;
|
|
69518
69669
|
}
|
|
69519
69670
|
if (opts.board === "studio") {
|
|
69520
69671
|
const cfg = studioConfigFromEnv();
|
|
69521
69672
|
if (!cfg) {
|
|
69522
|
-
console.log(
|
|
69673
|
+
console.log(chalk25.yellow(`Studio board skipped — ${STUDIO_LOGIN_HINT}. Showing the terminal board instead.
|
|
69523
69674
|
`));
|
|
69524
69675
|
return 0;
|
|
69525
69676
|
}
|
|
@@ -69533,10 +69684,10 @@ ${chalk24.bold("no page")} ${chalk24.gray("(in the code, not seen on any sampled
|
|
|
69533
69684
|
}
|
|
69534
69685
|
if (stored)
|
|
69535
69686
|
savePlan(dir, plan);
|
|
69536
|
-
console.log(
|
|
69687
|
+
console.log(chalk25.green(`Studio board synced — ${synced.created} created, ${synced.updated} updated, ${synced.skipped} skipped.
|
|
69537
69688
|
`));
|
|
69538
69689
|
} catch (err) {
|
|
69539
|
-
console.log(
|
|
69690
|
+
console.log(chalk25.yellow(`Studio board unavailable (${err instanceof Error ? err.message : String(err)}). Showing the terminal board instead.
|
|
69540
69691
|
`));
|
|
69541
69692
|
}
|
|
69542
69693
|
}
|
|
@@ -69545,27 +69696,27 @@ ${chalk24.bold("no page")} ${chalk24.gray("(in the code, not seen on any sampled
|
|
|
69545
69696
|
async function planNotesCommand(dir, opts) {
|
|
69546
69697
|
const plan = loadPlan(dir);
|
|
69547
69698
|
if (!plan) {
|
|
69548
|
-
console.error(
|
|
69699
|
+
console.error(chalk25.red(`No migration-plan.json found in ${dir}`));
|
|
69549
69700
|
return 1;
|
|
69550
69701
|
}
|
|
69551
69702
|
const cfg = studioConfigFromEnv();
|
|
69552
69703
|
if (!cfg) {
|
|
69553
|
-
console.error(
|
|
69704
|
+
console.error(chalk25.yellow(`Studio not configured — ${STUDIO_LOGIN_HINT}.`));
|
|
69554
69705
|
return 1;
|
|
69555
69706
|
}
|
|
69556
69707
|
if (opts.post) {
|
|
69557
69708
|
const page = plan.pages.find((p) => p.path === opts.page);
|
|
69558
69709
|
if (!page?.boardItemId) {
|
|
69559
|
-
console.error(
|
|
69710
|
+
console.error(chalk25.red(`No synced card for page "${opts.page}" — run \`parity plan board --board studio\` first`));
|
|
69560
69711
|
return 1;
|
|
69561
69712
|
}
|
|
69562
69713
|
await postParityComment(page.boardItemId, opts.post, cfg);
|
|
69563
|
-
console.log(`${
|
|
69714
|
+
console.log(`${chalk25.green("✓")} comment posted on ${page.path}`);
|
|
69564
69715
|
return 0;
|
|
69565
69716
|
}
|
|
69566
69717
|
const pages = plan.pages.filter((p) => p.boardItemId).filter((p) => !opts.page || p.path === opts.page).map((p) => ({ path: p.path, boardItemId: p.boardItemId }));
|
|
69567
69718
|
if (!pages.length) {
|
|
69568
|
-
console.error(
|
|
69719
|
+
console.error(chalk25.yellow("No page has a synced card yet — run `parity plan board --board studio` first."));
|
|
69569
69720
|
return 1;
|
|
69570
69721
|
}
|
|
69571
69722
|
const notes = await fetchClientNotes(pages, cfg);
|
|
@@ -69574,47 +69725,47 @@ async function planNotesCommand(dir, opts) {
|
|
|
69574
69725
|
return 0;
|
|
69575
69726
|
}
|
|
69576
69727
|
if (!notes.length) {
|
|
69577
|
-
console.log(
|
|
69728
|
+
console.log(chalk25.gray(`
|
|
69578
69729
|
No open client notes.
|
|
69579
69730
|
`));
|
|
69580
69731
|
return 0;
|
|
69581
69732
|
}
|
|
69582
|
-
console.log(
|
|
69733
|
+
console.log(chalk25.bold(`
|
|
69583
69734
|
Client notes (${notes.length})`));
|
|
69584
69735
|
for (const n of notes) {
|
|
69585
69736
|
console.log(`
|
|
69586
|
-
${
|
|
69737
|
+
${chalk25.cyan(n.path)} ${chalk25.gray(n.createdAt)}`);
|
|
69587
69738
|
for (const line of n.body.split(`
|
|
69588
69739
|
`))
|
|
69589
69740
|
console.log(` ${line}`);
|
|
69590
69741
|
}
|
|
69591
|
-
console.log(
|
|
69742
|
+
console.log(chalk25.gray('\nThese are PROPOSALS. Apply with `parity plan set-reference` / `set-status`, then confirm with `parity plan notes --page <path> --post "<what you did>"`.\n'));
|
|
69592
69743
|
return 0;
|
|
69593
69744
|
}
|
|
69594
69745
|
var PROVENANCES = ["library", "built"];
|
|
69595
69746
|
function planSetProvenanceCommand(dir, name, provenance) {
|
|
69596
69747
|
if (!PROVENANCES.includes(provenance)) {
|
|
69597
|
-
console.error(
|
|
69748
|
+
console.error(chalk25.red(`Invalid provenance "${provenance}". Use one of: ${PROVENANCES.join(", ")}`));
|
|
69598
69749
|
return 1;
|
|
69599
69750
|
}
|
|
69600
69751
|
const plan = loadPlan(dir);
|
|
69601
69752
|
if (!plan) {
|
|
69602
|
-
console.error(
|
|
69753
|
+
console.error(chalk25.red(`No migration-plan.json found in ${dir}`));
|
|
69603
69754
|
return 1;
|
|
69604
69755
|
}
|
|
69605
69756
|
const component = setComponentProvenance(plan, name, provenance);
|
|
69606
69757
|
if (!component) {
|
|
69607
|
-
console.error(
|
|
69758
|
+
console.error(chalk25.red(`No component matching "${name}" in the plan`));
|
|
69608
69759
|
return 1;
|
|
69609
69760
|
}
|
|
69610
69761
|
savePlan(dir, plan);
|
|
69611
|
-
console.log(`${
|
|
69762
|
+
console.log(`${chalk25.green("✓")} ${component.name} → ${provenance}`);
|
|
69612
69763
|
return 0;
|
|
69613
69764
|
}
|
|
69614
69765
|
function planTouchCommand(dir, page, opts) {
|
|
69615
69766
|
const plan = loadPlan(dir);
|
|
69616
69767
|
if (!plan) {
|
|
69617
|
-
console.error(
|
|
69768
|
+
console.error(chalk25.red(`No migration-plan.json found in ${dir}`));
|
|
69618
69769
|
return 1;
|
|
69619
69770
|
}
|
|
69620
69771
|
const count = recordTouch(plan, page);
|
|
@@ -69622,7 +69773,7 @@ function planTouchCommand(dir, page, opts) {
|
|
|
69622
69773
|
if (opts.json) {
|
|
69623
69774
|
console.log(JSON.stringify({ page, touches: count, total: totalTouches(plan) }));
|
|
69624
69775
|
} else {
|
|
69625
|
-
console.log(`${
|
|
69776
|
+
console.log(`${chalk25.green("✓")} ${page} → ${count} human touch(es); ${totalTouches(plan)} in this migration`);
|
|
69626
69777
|
}
|
|
69627
69778
|
return 0;
|
|
69628
69779
|
}
|
|
@@ -69630,12 +69781,12 @@ function planTouchCommand(dir, page, opts) {
|
|
|
69630
69781
|
// src/commands/pr.ts
|
|
69631
69782
|
import { existsSync as existsSync24, readFileSync as readFileSync30, writeFileSync as writeFileSync27 } from "node:fs";
|
|
69632
69783
|
import { join as join36 } from "node:path";
|
|
69633
|
-
import
|
|
69784
|
+
import chalk28 from "chalk";
|
|
69634
69785
|
|
|
69635
69786
|
// src/commands/run.ts
|
|
69636
69787
|
import { existsSync as existsSync23, readFileSync as readFileSync29, unlinkSync as unlinkSync3 } from "node:fs";
|
|
69637
69788
|
import { join as join35 } from "node:path";
|
|
69638
|
-
import
|
|
69789
|
+
import chalk27 from "chalk";
|
|
69639
69790
|
import ora8 from "ora";
|
|
69640
69791
|
|
|
69641
69792
|
// src/diff/score-band.ts
|
|
@@ -70224,7 +70375,7 @@ function formatMs(ms) {
|
|
|
70224
70375
|
|
|
70225
70376
|
// src/commands/serve.ts
|
|
70226
70377
|
import { existsSync as existsSync22 } from "node:fs";
|
|
70227
|
-
import
|
|
70378
|
+
import chalk26 from "chalk";
|
|
70228
70379
|
|
|
70229
70380
|
// src/server/proxy-server.ts
|
|
70230
70381
|
import { existsSync as existsSync21, readFileSync as readFileSync28, statSync as statSync2 } from "node:fs";
|
|
@@ -70497,16 +70648,16 @@ async function serveRunAndBlock(runDir, opts = {}) {
|
|
|
70497
70648
|
try {
|
|
70498
70649
|
handle = await startProxyServer(runDir, { port: opts.port });
|
|
70499
70650
|
} catch (err) {
|
|
70500
|
-
console.error(
|
|
70651
|
+
console.error(chalk26.red(` ✖ Falha ao iniciar servidor: ${err.message}`));
|
|
70501
70652
|
return 2;
|
|
70502
70653
|
}
|
|
70503
70654
|
const label = opts.label ?? "parity serve";
|
|
70504
70655
|
console.log("");
|
|
70505
|
-
console.log(
|
|
70506
|
-
console.log(` ${
|
|
70507
|
-
console.log(
|
|
70508
|
-
console.log(
|
|
70509
|
-
console.log(
|
|
70656
|
+
console.log(chalk26.bold(` ${label}`));
|
|
70657
|
+
console.log(` ${chalk26.green("●")} ${handle.url}`);
|
|
70658
|
+
console.log(chalk26.dim(` Servindo: ${runDir}`));
|
|
70659
|
+
console.log(chalk26.dim(` Proxy de iframes: ${handle.url}proxy?url=<encoded>`));
|
|
70660
|
+
console.log(chalk26.dim(` Ctrl+C pra parar (2x pra forçar saída).
|
|
70510
70661
|
`));
|
|
70511
70662
|
if (opts.open !== false) {
|
|
70512
70663
|
const { default: open } = await import("open");
|
|
@@ -70539,11 +70690,11 @@ async function serveRunAndBlock(runDir, opts = {}) {
|
|
|
70539
70690
|
async function serveCommand(runId, opts) {
|
|
70540
70691
|
const paths = getRunPaths(opts.output, runId);
|
|
70541
70692
|
if (!existsSync22(paths.runDir)) {
|
|
70542
|
-
console.error(
|
|
70693
|
+
console.error(chalk26.red(`✖ Run não encontrado: ${runId} (em ${opts.output})`));
|
|
70543
70694
|
return 1;
|
|
70544
70695
|
}
|
|
70545
70696
|
if (!existsSync22(paths.reportHtml)) {
|
|
70546
|
-
console.error(
|
|
70697
|
+
console.error(chalk26.red(`✖ report.html não existe em ${paths.runDir}`));
|
|
70547
70698
|
return 1;
|
|
70548
70699
|
}
|
|
70549
70700
|
return serveRunAndBlock(paths.runDir, {
|
|
@@ -70719,14 +70870,14 @@ function readRunChecks(reportPath) {
|
|
|
70719
70870
|
async function runCommand(rawOpts) {
|
|
70720
70871
|
if (!rawOpts.prod) {
|
|
70721
70872
|
const target = rawOpts.cand ?? "<url>";
|
|
70722
|
-
console.error(`${
|
|
70723
|
-
For one site, use: ${
|
|
70873
|
+
console.error(`${chalk27.yellow("Single-site run?")} \`parity run\` compares two URLs (prod↔cand).
|
|
70874
|
+
For one site, use: ${chalk27.cyan(`parity e2e --url ${target}`)}
|
|
70724
70875
|
(runs the functional flows + all checks in single-site mode — no prod baseline needed).`);
|
|
70725
70876
|
return 2;
|
|
70726
70877
|
}
|
|
70727
70878
|
let opts = applyPreset(rawOpts);
|
|
70728
70879
|
if (rawOpts.preset) {
|
|
70729
|
-
console.log(
|
|
70880
|
+
console.log(chalk27.dim(` preset: ${rawOpts.preset}`));
|
|
70730
70881
|
}
|
|
70731
70882
|
if (opts.pt)
|
|
70732
70883
|
setLlmLanguage("pt");
|
|
@@ -70734,14 +70885,14 @@ async function runCommand(rawOpts) {
|
|
|
70734
70885
|
disableInteractive();
|
|
70735
70886
|
const llmCfgErr = applyLlmOptions(opts);
|
|
70736
70887
|
if (llmCfgErr) {
|
|
70737
|
-
console.error(
|
|
70888
|
+
console.error(chalk27.red(` ${llmCfgErr}`));
|
|
70738
70889
|
return 2;
|
|
70739
70890
|
}
|
|
70740
70891
|
const llmStillAvailable = isLlmAvailable();
|
|
70741
70892
|
const preSmart = opts;
|
|
70742
70893
|
opts = applySmartDefaults(opts, llmStillAvailable);
|
|
70743
70894
|
if (!llmStillAvailable && opts.visualPages !== preSmart.visualPages) {
|
|
70744
|
-
console.log(
|
|
70895
|
+
console.log(chalk27.dim(" visual-pages auto-set to 0 (no LLM available — analysis layer would be skipped; opt in with --visual-pages N)"));
|
|
70745
70896
|
}
|
|
70746
70897
|
let interactivePromptShown = false;
|
|
70747
70898
|
if (!opts.only && !opts.skip && !rawOpts.preset) {
|
|
@@ -70767,14 +70918,14 @@ async function runCommand(rawOpts) {
|
|
|
70767
70918
|
if (isContentProfile && !opts.only && !opts.skip) {
|
|
70768
70919
|
opts.only = "seo,visual,vitals,cache,console,html,network";
|
|
70769
70920
|
moduleDropReason = "profile: content → e2e module dropped (commerce purchase-journey/cart make no sense on a content site); pass --profile commerce to force";
|
|
70770
|
-
console.log(
|
|
70921
|
+
console.log(chalk27.yellow(` INCONCLUSIVE: ${moduleDropReason}`));
|
|
70771
70922
|
}
|
|
70772
70923
|
const selection = resolveSelection({ only: opts.only, skip: opts.skip });
|
|
70773
70924
|
if (selection.errors.length > 0) {
|
|
70774
|
-
console.error(
|
|
70925
|
+
console.error(chalk27.red(" --only/--skip: invalid value(s):"));
|
|
70775
70926
|
for (const e of selection.errors)
|
|
70776
|
-
console.error(
|
|
70777
|
-
console.error(
|
|
70927
|
+
console.error(chalk27.red(` - ${e}`));
|
|
70928
|
+
console.error(chalk27.dim(`
|
|
70778
70929
|
valid modules: ${Object.keys(MODULES).join(", ")}`));
|
|
70779
70930
|
return 2;
|
|
70780
70931
|
}
|
|
@@ -70786,14 +70937,14 @@ async function runCommand(rawOpts) {
|
|
|
70786
70937
|
const explicitFlows = userSetFlows ? opts.flows.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
70787
70938
|
const scoped = resolveScopedFlows({ explicitFlows, selectionFlows: selection.flows });
|
|
70788
70939
|
flows = scoped.flows;
|
|
70789
|
-
console.log(
|
|
70940
|
+
console.log(chalk27.dim(` modules: ${selection.modules.join(", ") || "(none)"} → flows: ${flows.join(",")}${explicitFlows.length > 0 ? " (scoped by --flows)" : ""}`));
|
|
70790
70941
|
if (scoped.starved.length > 0) {
|
|
70791
|
-
console.log(
|
|
70942
|
+
console.log(chalk27.yellow(` ! --flows leaves out ${scoped.starved.join(",")}, which the selected modules capture from — those checks may have nothing to analyze`));
|
|
70792
70943
|
}
|
|
70793
70944
|
} else {
|
|
70794
70945
|
flows = opts.flows.split(",").map((s) => s.trim());
|
|
70795
70946
|
if (!interactivePromptShown) {
|
|
70796
|
-
console.log(
|
|
70947
|
+
console.log(chalk27.dim(" no --only/--skip given — running ALL modules; pass --only to scope the run for a lighter/faster result"));
|
|
70797
70948
|
}
|
|
70798
70949
|
}
|
|
70799
70950
|
if (isContentProfile) {
|
|
@@ -70802,16 +70953,16 @@ async function runCommand(rawOpts) {
|
|
|
70802
70953
|
if (!flows.includes("homepage"))
|
|
70803
70954
|
flows.unshift("homepage");
|
|
70804
70955
|
if (before !== flows.join(",")) {
|
|
70805
|
-
console.log(
|
|
70956
|
+
console.log(chalk27.dim(` profile: content → flows scoped to ${flows.join(",")} (dropped plp/pdp; was: ${before}); CEP skipped`));
|
|
70806
70957
|
}
|
|
70807
70958
|
}
|
|
70808
70959
|
const pagesScopeWarning = pagesFlowsScopeWarning(opts, flows);
|
|
70809
70960
|
if (pagesScopeWarning) {
|
|
70810
|
-
console.log(
|
|
70961
|
+
console.log(chalk27.dim(` ${pagesScopeWarning}`));
|
|
70811
70962
|
}
|
|
70812
70963
|
if (hasSelection) {
|
|
70813
70964
|
for (const note of applySelectionDefaults(opts, selection.modules)) {
|
|
70814
|
-
console.log(
|
|
70965
|
+
console.log(chalk27.dim(` ${note}`));
|
|
70815
70966
|
}
|
|
70816
70967
|
}
|
|
70817
70968
|
const viewports = opts.viewports.split(",").map((s) => s.trim());
|
|
@@ -70828,34 +70979,34 @@ async function runCommand(rawOpts) {
|
|
|
70828
70979
|
if (existsSync23(cacheFile)) {
|
|
70829
70980
|
try {
|
|
70830
70981
|
unlinkSync3(cacheFile);
|
|
70831
|
-
console.log(
|
|
70982
|
+
console.log(chalk27.dim(` cache wiped: ${cacheFile}`));
|
|
70832
70983
|
} catch (err) {
|
|
70833
|
-
console.log(
|
|
70984
|
+
console.log(chalk27.yellow(` cache wipe falhou: ${err.message}`));
|
|
70834
70985
|
}
|
|
70835
70986
|
}
|
|
70836
70987
|
}
|
|
70837
70988
|
const llmTimeoutRaw = opts.llmTimeout ?? 60;
|
|
70838
70989
|
if (!Number.isFinite(llmTimeoutRaw)) {
|
|
70839
|
-
console.error(
|
|
70990
|
+
console.error(chalk27.red(` --llm-timeout inválido: "${opts.llmTimeout}" não é um número`));
|
|
70840
70991
|
return 2;
|
|
70841
70992
|
}
|
|
70842
70993
|
const llmTimeoutSec = Math.max(5, Math.floor(llmTimeoutRaw));
|
|
70843
70994
|
if (isLlmAvailable()) {
|
|
70844
|
-
console.log(
|
|
70995
|
+
console.log(chalk27.dim(` llm: ${providerLabel()} (timeout=${llmTimeoutSec}s)`));
|
|
70845
70996
|
} else {
|
|
70846
|
-
console.log(
|
|
70997
|
+
console.log(chalk27.dim(" llm: offline (LLM keys ausentes — agregação heurística)"));
|
|
70847
70998
|
}
|
|
70848
70999
|
if (isInteractiveMode()) {
|
|
70849
|
-
console.log(
|
|
71000
|
+
console.log(chalk27.dim(" interactive: enabled — TTY + no LLM. Missing selectors will pause to prompt (disable with --no-interactive). Issue #72."));
|
|
70850
71001
|
}
|
|
70851
71002
|
const primaryViewport = viewports[0] ?? "mobile";
|
|
70852
71003
|
const preflight = await preflightCheck(opts.prod, opts.cand, primaryViewport);
|
|
70853
71004
|
if (!preflight.ok) {
|
|
70854
|
-
console.error(
|
|
71005
|
+
console.error(chalk27.red(`
|
|
70855
71006
|
✖ pre-flight falhou:`));
|
|
70856
71007
|
for (const err of preflight.errors)
|
|
70857
|
-
console.error(
|
|
70858
|
-
console.error(
|
|
71008
|
+
console.error(chalk27.red(` - ${err}`));
|
|
71009
|
+
console.error(chalk27.dim(`
|
|
70859
71010
|
dica: verifique se as URLs estão corretas e acessíveis`));
|
|
70860
71011
|
return 2;
|
|
70861
71012
|
}
|
|
@@ -70866,7 +71017,7 @@ async function runCommand(rawOpts) {
|
|
|
70866
71017
|
if (prodHomeHtml) {
|
|
70867
71018
|
platform = detectPlatform({ url: opts.prod, html: prodHomeHtml });
|
|
70868
71019
|
if (platform !== "custom") {
|
|
70869
|
-
console.log(
|
|
71020
|
+
console.log(chalk27.dim(` Detected platform: ${platform}`));
|
|
70870
71021
|
}
|
|
70871
71022
|
}
|
|
70872
71023
|
const prodHost = hostOf3(opts.prod);
|
|
@@ -70901,11 +71052,11 @@ async function runCommand(rawOpts) {
|
|
|
70901
71052
|
viewports,
|
|
70902
71053
|
timestamp
|
|
70903
71054
|
});
|
|
70904
|
-
console.log(
|
|
71055
|
+
console.log(chalk27.bold(`
|
|
70905
71056
|
parity run ${runId}`));
|
|
70906
|
-
console.log(
|
|
70907
|
-
console.log(
|
|
70908
|
-
console.log(
|
|
71057
|
+
console.log(chalk27.dim(` prod: ${opts.prod}`));
|
|
71058
|
+
console.log(chalk27.dim(` cand: ${opts.cand}`));
|
|
71059
|
+
console.log(chalk27.dim(` profile: ${profile} · flows: ${flows.join(", ")} · viewports: ${viewports.join(", ")}${rc.cep ? ` · CEP: ${rc.cep}` : ""}
|
|
70909
71060
|
`));
|
|
70910
71061
|
const spinner = ora8("Launching browser…").start();
|
|
70911
71062
|
let browser = null;
|
|
@@ -70917,7 +71068,7 @@ async function runCommand(rawOpts) {
|
|
|
70917
71068
|
const min = Math.floor(elapsedSec / 60);
|
|
70918
71069
|
const sec = elapsedSec % 60;
|
|
70919
71070
|
const mmss = `${min.toString().padStart(2, "0")}:${sec.toString().padStart(2, "0")}`;
|
|
70920
|
-
spinner.text = `${
|
|
71071
|
+
spinner.text = `${chalk27.dim(`⏱ ${mmss} ·`)} ${currentSpinnerLabel}`;
|
|
70921
71072
|
};
|
|
70922
71073
|
const setSpinnerLabel = (label) => {
|
|
70923
71074
|
currentSpinnerLabel = label;
|
|
@@ -71037,8 +71188,8 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
71037
71188
|
for (const flow of flows) {
|
|
71038
71189
|
const flowStart = Date.now();
|
|
71039
71190
|
let lastStepTotal = 0;
|
|
71040
|
-
const sideTag = side === "prod" ?
|
|
71041
|
-
const prefix = `${
|
|
71191
|
+
const sideTag = side === "prod" ? chalk27.cyan("prod") : chalk27.magenta("cand");
|
|
71192
|
+
const prefix = `${chalk27.dim(`[${viewport}/`)}${sideTag}${chalk27.dim("]")}`;
|
|
71042
71193
|
setSpinnerLabel(`${prefix} ${flow}: starting…`);
|
|
71043
71194
|
const cap = await runFlow(flow, {
|
|
71044
71195
|
baseUrl,
|
|
@@ -71055,7 +71206,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
71055
71206
|
onStep: (event) => {
|
|
71056
71207
|
if (event.phase === "start") {
|
|
71057
71208
|
lastStepTotal = event.total;
|
|
71058
|
-
setSpinnerLabel(`${prefix} ${flow} ${
|
|
71209
|
+
setSpinnerLabel(`${prefix} ${flow} ${chalk27.dim(`${event.index}/${event.total}`)} ${event.name}…`);
|
|
71059
71210
|
}
|
|
71060
71211
|
}
|
|
71061
71212
|
});
|
|
@@ -71064,18 +71215,18 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
71064
71215
|
const target = lastStepTotal || recorded;
|
|
71065
71216
|
const failed = cap.steps?.find((s) => s.status === "failed");
|
|
71066
71217
|
const lastStep = cap.steps?.[cap.steps.length - 1];
|
|
71067
|
-
const elapsedDim =
|
|
71068
|
-
const counts = target > 0 ?
|
|
71218
|
+
const elapsedDim = chalk27.dim(`${((Date.now() - flowStart) / 1000).toFixed(1)}s`);
|
|
71219
|
+
const counts = target > 0 ? chalk27.dim(`${okSteps}/${target}`) : "";
|
|
71069
71220
|
let glyph;
|
|
71070
71221
|
let detail;
|
|
71071
71222
|
if (failed) {
|
|
71072
|
-
glyph =
|
|
71073
|
-
detail = `stopped at ${
|
|
71223
|
+
glyph = chalk27.red("✗");
|
|
71224
|
+
detail = `stopped at ${chalk27.yellow(failed.name)}`;
|
|
71074
71225
|
} else if (target > 0 && okSteps < target) {
|
|
71075
|
-
glyph =
|
|
71076
|
-
detail = lastStep ? `ended at ${
|
|
71226
|
+
glyph = chalk27.yellow("▴");
|
|
71227
|
+
detail = lastStep ? `ended at ${chalk27.dim(lastStep.name)}` : "incomplete";
|
|
71077
71228
|
} else {
|
|
71078
|
-
glyph =
|
|
71229
|
+
glyph = chalk27.green("✓");
|
|
71079
71230
|
detail = "";
|
|
71080
71231
|
}
|
|
71081
71232
|
const summary = `${glyph} ${prefix} ${flow} ${counts} ${detail} ${elapsedDim}`.replace(/\s+/g, " ").trim();
|
|
@@ -71137,7 +71288,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
71137
71288
|
const vitalsPagesLimit = opts.vitalsPages ?? vitalsPagesDefault;
|
|
71138
71289
|
const vitalsRuns = Math.max(1, Number.parseInt(opts.runs, 10) || 1);
|
|
71139
71290
|
if (candIsDevServer && vitalsPagesLimit > 0) {
|
|
71140
|
-
console.log(
|
|
71291
|
+
console.log(chalk27.dim(` cand=localhost detectado — vitals-pages=${vitalsPagesLimit}, networkidle desabilitado (issue #55)`));
|
|
71141
71292
|
}
|
|
71142
71293
|
if (browser && vitalsPagesLimit > 0) {
|
|
71143
71294
|
currentPhase = "vitals-pages";
|
|
@@ -71515,13 +71666,13 @@ ${formatTimingsSummary(runTimings, buildFlowBreakdown(allFlowCaptures))}`);
|
|
|
71515
71666
|
${formatPagePairTable(pagePairs)}`);
|
|
71516
71667
|
const missed = pagePairs.filter((p) => !p.match).length;
|
|
71517
71668
|
if (missed > 0) {
|
|
71518
|
-
console.log(
|
|
71669
|
+
console.log(chalk27.red(`
|
|
71519
71670
|
✖ ${missed}/${pagePairs.length} requested page pair(s) were not measured as requested — this report describes other pages; fix the URLs or the capture`));
|
|
71520
71671
|
}
|
|
71521
71672
|
}
|
|
71522
71673
|
const failOnGate = evaluateFailOnGate(remainingIssues, failOn, verdict.status);
|
|
71523
71674
|
if (failOnGate.exitCode === 1) {
|
|
71524
|
-
console.log(
|
|
71675
|
+
console.log(chalk27.red(failOnGate.message));
|
|
71525
71676
|
return 1;
|
|
71526
71677
|
}
|
|
71527
71678
|
if (opts.open) {
|
|
@@ -71812,10 +71963,10 @@ function hostOf3(url) {
|
|
|
71812
71963
|
function printSummary8(run, htmlPath, meta) {
|
|
71813
71964
|
const { verdict } = run;
|
|
71814
71965
|
const inconclusive = verdict.status === "inconclusive";
|
|
71815
|
-
const emoji = inconclusive ?
|
|
71816
|
-
const score = inconclusive ?
|
|
71966
|
+
const emoji = inconclusive ? chalk27.dim("○") : verdict.status === "pass" ? chalk27.green("✔") : verdict.status === "warn" ? chalk27.yellow("⚠") : chalk27.red("✖");
|
|
71967
|
+
const score = inconclusive ? chalk27.dim("—") : verdict.status === "pass" ? chalk27.green(verdict.score) : verdict.status === "warn" ? chalk27.yellow(verdict.score) : chalk27.red(verdict.score);
|
|
71817
71968
|
const prev = run.previousRun;
|
|
71818
|
-
const scoreDelta = !prev ?
|
|
71969
|
+
const scoreDelta = !prev ? chalk27.dim(" (sem run anterior comparável)") : prev.scoreDelta > 0 ? chalk27.green(` (+${prev.scoreDelta} vs run anterior: ${prev.score})`) : prev.scoreDelta < 0 ? chalk27.red(` (${prev.scoreDelta} vs run anterior: ${prev.score})`) : chalk27.dim(` (= run anterior: ${prev.score})`);
|
|
71819
71970
|
console.log("");
|
|
71820
71971
|
if (inconclusive) {
|
|
71821
71972
|
const why = run.pagePairs?.some((p) => !p.match) ? "the requested --pages were not measured (table below)" : "nothing was measured (0 checks ran)";
|
|
@@ -71825,52 +71976,52 @@ function printSummary8(run, htmlPath, meta) {
|
|
|
71825
71976
|
console.log(` ${emoji} parity ${verdict.status.toUpperCase()} · score ${score}/100${accepted}${scoreDelta}`);
|
|
71826
71977
|
}
|
|
71827
71978
|
for (const e of run.acceptedFindings?.stale ?? []) {
|
|
71828
|
-
console.log(` ${
|
|
71979
|
+
console.log(` ${chalk27.yellow("⚠")} stale acceptance (matched nothing — \`parity accept remove\`): ${[e.check, e.id, e.page, e.match].filter(Boolean).join(" · ")} — ${e.note}`);
|
|
71829
71980
|
}
|
|
71830
|
-
console.log(` checks: ${
|
|
71831
|
-
console.log(` issues: ${
|
|
71981
|
+
console.log(` checks: ${chalk27.green(verdict.checksPassed)} pass · ${chalk27.red(verdict.checksFailed)} fail · ${chalk27.dim(`${verdict.checksSkipped} skipped`)}`);
|
|
71982
|
+
console.log(` issues: ${chalk27.red(verdict.critical)} critical · ${chalk27.yellow(verdict.high)} high · ${verdict.medium} medium · ${chalk27.dim(`${verdict.low} low`)}`);
|
|
71832
71983
|
const band = run.scoreBand;
|
|
71833
71984
|
const bandLine = band ? formatScoreBand(band) : null;
|
|
71834
71985
|
if (band && bandLine) {
|
|
71835
|
-
console.log(` ${
|
|
71986
|
+
console.log(` ${chalk27.dim(bandLine)}`);
|
|
71836
71987
|
const caveat = scoreBandCaveat(band);
|
|
71837
71988
|
if (caveat)
|
|
71838
|
-
console.log(` ${
|
|
71989
|
+
console.log(` ${chalk27.yellow("⚠")} ${caveat}`);
|
|
71839
71990
|
}
|
|
71840
71991
|
for (const c of run.caveats ?? []) {
|
|
71841
|
-
const mark = c.level === "warn" ?
|
|
71992
|
+
const mark = c.level === "warn" ? chalk27.yellow("⚠") : chalk27.dim("ℹ");
|
|
71842
71993
|
console.log(` ${mark} ${c.summary}`);
|
|
71843
71994
|
}
|
|
71844
71995
|
if (run.moduleVerdicts && run.moduleVerdicts.length > 0) {
|
|
71845
71996
|
const perModule = run.moduleVerdicts.map((mv) => {
|
|
71846
|
-
const colored = mv.status === "pass" ?
|
|
71997
|
+
const colored = mv.status === "pass" ? chalk27.green(mv.score) : mv.status === "warn" ? chalk27.yellow(mv.score) : chalk27.red(mv.score);
|
|
71847
71998
|
return `${mv.module} ${colored}`;
|
|
71848
71999
|
}).join(" · ");
|
|
71849
72000
|
console.log(` modules: ${perModule} → composite ${score}`);
|
|
71850
72001
|
}
|
|
71851
72002
|
if (run.visualDiff) {
|
|
71852
72003
|
const vd = run.visualDiff;
|
|
71853
|
-
const parityIcon = vd.parityOk ?
|
|
71854
|
-
const parityLabel = vd.parityOk ?
|
|
71855
|
-
const cacheNote = vd.pagesFromCache > 0 ?
|
|
71856
|
-
console.log(` visual: ${parityIcon} parityOk=${parityLabel} · ${vd.pagesChecked} pages · ${
|
|
72004
|
+
const parityIcon = vd.parityOk ? chalk27.green("✔") : chalk27.red("✖");
|
|
72005
|
+
const parityLabel = vd.parityOk ? chalk27.green("OK") : chalk27.red("DIFFS");
|
|
72006
|
+
const cacheNote = vd.pagesFromCache > 0 ? chalk27.dim(` · ${vd.pagesFromCache} cached`) : "";
|
|
72007
|
+
console.log(` visual: ${parityIcon} parityOk=${parityLabel} · ${vd.pagesChecked} pages · ${chalk27.red(vd.pagesWithDiffs)} diffs · ${chalk27.green(vd.pagesPassed)} pass${cacheNote}`);
|
|
71857
72008
|
}
|
|
71858
72009
|
if (run.topIssues.length > 0) {
|
|
71859
72010
|
console.log("");
|
|
71860
|
-
console.log(
|
|
72011
|
+
console.log(chalk27.bold(" Top issues:"));
|
|
71861
72012
|
for (const g of groupIssues(run.topIssues).slice(0, 5)) {
|
|
71862
72013
|
const i = g.sample;
|
|
71863
|
-
const sev = i.severity === "critical" ?
|
|
71864
|
-
const pagesNote = g.pages.length > 1 ?
|
|
72014
|
+
const sev = i.severity === "critical" ? chalk27.red(`[${i.severity}]`) : i.severity === "high" ? chalk27.yellow(`[${i.severity}]`) : chalk27.dim(`[${i.severity}]`);
|
|
72015
|
+
const pagesNote = g.pages.length > 1 ? chalk27.dim(` (${g.pages.length} páginas)`) : "";
|
|
71865
72016
|
console.log(` ${sev} ${i.summary}${pagesNote}`);
|
|
71866
72017
|
}
|
|
71867
72018
|
}
|
|
71868
72019
|
if (meta.promotedCount > 0 || meta.deprecatedCount > 0) {
|
|
71869
72020
|
console.log("");
|
|
71870
|
-
console.log(
|
|
72021
|
+
console.log(chalk27.dim(` \uD83D\uDCDA learned-selectors [${meta.platform}]: ${chalk27.green(`+${meta.promotedCount}`)} promoted · ${chalk27.yellow(meta.deprecatedCount)} deprecated`));
|
|
71871
72022
|
}
|
|
71872
72023
|
console.log("");
|
|
71873
|
-
console.log(
|
|
72024
|
+
console.log(chalk27.dim(` → ${htmlPath}`));
|
|
71874
72025
|
console.log("");
|
|
71875
72026
|
}
|
|
71876
72027
|
|
|
@@ -71894,26 +72045,26 @@ async function prCommand(opts) {
|
|
|
71894
72045
|
preset: opts.preset ?? "ci",
|
|
71895
72046
|
open: false
|
|
71896
72047
|
};
|
|
71897
|
-
console.log(
|
|
71898
|
-
console.log(
|
|
72048
|
+
console.log(chalk28.dim(` prod : ${opts.prod}`));
|
|
72049
|
+
console.log(chalk28.dim(` preview : ${opts.preview}`));
|
|
71899
72050
|
console.log("");
|
|
71900
72051
|
const runCode = await runCommand(runOpts);
|
|
71901
72052
|
const runs = listRuns(opts.output);
|
|
71902
72053
|
if (runs.length === 0) {
|
|
71903
|
-
console.error(
|
|
72054
|
+
console.error(chalk28.red("no run was produced — cannot build PR comment"));
|
|
71904
72055
|
return runCode || 1;
|
|
71905
72056
|
}
|
|
71906
72057
|
const latest = runs[0];
|
|
71907
72058
|
const reportJsonPath = join36(opts.output, "runs", latest.id, "report.json");
|
|
71908
72059
|
if (!existsSync24(reportJsonPath)) {
|
|
71909
|
-
console.error(
|
|
72060
|
+
console.error(chalk28.red(`report.json not found at ${reportJsonPath}`));
|
|
71910
72061
|
return runCode || 1;
|
|
71911
72062
|
}
|
|
71912
72063
|
const run = JSON.parse(readFileSync30(reportJsonPath, "utf8"));
|
|
71913
72064
|
const markdown = buildPrComment(run, opts);
|
|
71914
72065
|
if (opts.out) {
|
|
71915
72066
|
writeFileSync27(opts.out, markdown, "utf8");
|
|
71916
|
-
console.log(
|
|
72067
|
+
console.log(chalk28.dim(` wrote PR comment: ${opts.out}`));
|
|
71917
72068
|
} else {
|
|
71918
72069
|
process.stdout.write(`
|
|
71919
72070
|
${markdown}
|
|
@@ -71923,7 +72074,7 @@ ${markdown}
|
|
|
71923
72074
|
try {
|
|
71924
72075
|
writeFileSync27(process.env.GITHUB_STEP_SUMMARY, markdown, { flag: "a" });
|
|
71925
72076
|
} catch (err) {
|
|
71926
|
-
console.error(
|
|
72077
|
+
console.error(chalk28.yellow(`failed to write GITHUB_STEP_SUMMARY: ${err.message}`));
|
|
71927
72078
|
}
|
|
71928
72079
|
}
|
|
71929
72080
|
return runCode;
|
|
@@ -71984,13 +72135,13 @@ function buildPrComment(run, opts) {
|
|
|
71984
72135
|
|
|
71985
72136
|
// src/commands/prompt.ts
|
|
71986
72137
|
import { existsSync as existsSync25, writeFileSync as writeFileSync28 } from "node:fs";
|
|
71987
|
-
import
|
|
72138
|
+
import chalk29 from "chalk";
|
|
71988
72139
|
function promptCommand(runId, opts) {
|
|
71989
72140
|
let run;
|
|
71990
72141
|
try {
|
|
71991
72142
|
run = loadRun(opts.output, runId);
|
|
71992
72143
|
} catch (err) {
|
|
71993
|
-
console.error(
|
|
72144
|
+
console.error(chalk29.red(`✖ ${err.message}`));
|
|
71994
72145
|
return 1;
|
|
71995
72146
|
}
|
|
71996
72147
|
const md = buildLlmPrompt(run, {
|
|
@@ -71999,10 +72150,10 @@ function promptCommand(runId, opts) {
|
|
|
71999
72150
|
});
|
|
72000
72151
|
if (opts.out) {
|
|
72001
72152
|
writeFileSync28(opts.out, md, "utf8");
|
|
72002
|
-
console.log(
|
|
72153
|
+
console.log(chalk29.green(`✔ prompt salvo em ${opts.out}`));
|
|
72003
72154
|
if (existsSync25(opts.out)) {
|
|
72004
72155
|
const sizeKb = (md.length / 1024).toFixed(1);
|
|
72005
|
-
console.log(
|
|
72156
|
+
console.log(chalk29.dim(` ${md.length} chars (${sizeKb} KB)`));
|
|
72006
72157
|
}
|
|
72007
72158
|
} else {
|
|
72008
72159
|
process.stdout.write(md);
|
|
@@ -72013,7 +72164,7 @@ function promptCommand(runId, opts) {
|
|
|
72013
72164
|
// src/commands/report.ts
|
|
72014
72165
|
import { existsSync as existsSync26, readFileSync as readFileSync31, writeFileSync as writeFileSync29 } from "node:fs";
|
|
72015
72166
|
import { join as join37 } from "node:path";
|
|
72016
|
-
import
|
|
72167
|
+
import chalk30 from "chalk";
|
|
72017
72168
|
import open2 from "open";
|
|
72018
72169
|
|
|
72019
72170
|
// src/report/deck-template.ts
|
|
@@ -72694,7 +72845,7 @@ async function reportCommand(runId, opts) {
|
|
|
72694
72845
|
try {
|
|
72695
72846
|
run = loadRun(opts.output, runId);
|
|
72696
72847
|
} catch (err) {
|
|
72697
|
-
console.error(
|
|
72848
|
+
console.error(chalk30.red(`failed to load run: ${err.message}`));
|
|
72698
72849
|
return 1;
|
|
72699
72850
|
}
|
|
72700
72851
|
let plan = null;
|
|
@@ -72702,29 +72853,29 @@ async function reportCommand(runId, opts) {
|
|
|
72702
72853
|
try {
|
|
72703
72854
|
plan = loadPlan(opts.planDir);
|
|
72704
72855
|
} catch (err) {
|
|
72705
|
-
console.error(
|
|
72856
|
+
console.error(chalk30.red(`failed to read migration-plan.json: ${err.message}`));
|
|
72706
72857
|
return 1;
|
|
72707
72858
|
}
|
|
72708
72859
|
if (!plan) {
|
|
72709
|
-
console.error(
|
|
72860
|
+
console.error(chalk30.red(`no migration-plan.json in ${opts.planDir}`));
|
|
72710
72861
|
return 1;
|
|
72711
72862
|
}
|
|
72712
72863
|
}
|
|
72713
72864
|
const html = renderDeckHtml(buildDeckModel(run, plan), opts.lang ?? "en");
|
|
72714
72865
|
const dest = opts.out ?? join37(paths.runDir, "deck.html");
|
|
72715
72866
|
writeFileSync29(dest, html, "utf8");
|
|
72716
|
-
console.log(`${
|
|
72867
|
+
console.log(`${chalk30.green("✓")} deck → ${dest}`);
|
|
72717
72868
|
if (opts.open) {
|
|
72718
72869
|
await open2(dest).catch((err) => {
|
|
72719
|
-
console.error(
|
|
72870
|
+
console.error(chalk30.red(`failed to open: ${err.message}`));
|
|
72720
72871
|
});
|
|
72721
72872
|
}
|
|
72722
72873
|
return 0;
|
|
72723
72874
|
}
|
|
72724
72875
|
if (opts.section) {
|
|
72725
72876
|
if (!ALL_REPORT_SECTIONS.includes(opts.section)) {
|
|
72726
|
-
console.error(
|
|
72727
|
-
console.error(
|
|
72877
|
+
console.error(chalk30.red(`unknown section "${opts.section}"`));
|
|
72878
|
+
console.error(chalk30.gray(` valid: ${ALL_REPORT_SECTIONS.join(", ")}`));
|
|
72728
72879
|
return 1;
|
|
72729
72880
|
}
|
|
72730
72881
|
if (opts.json) {
|
|
@@ -72732,40 +72883,40 @@ async function reportCommand(runId, opts) {
|
|
|
72732
72883
|
const run = loadRun(opts.output, runId);
|
|
72733
72884
|
const payload = extractReportSection({ kind: "json", section: opts.section, run });
|
|
72734
72885
|
if (payload === null) {
|
|
72735
|
-
console.error(
|
|
72886
|
+
console.error(chalk30.red(`section "${opts.section}" not present in this run`));
|
|
72736
72887
|
return 1;
|
|
72737
72888
|
}
|
|
72738
72889
|
process.stdout.write(`${JSON.stringify(payload, null, 2)}
|
|
72739
72890
|
`);
|
|
72740
72891
|
return 0;
|
|
72741
72892
|
} catch (err) {
|
|
72742
|
-
console.error(
|
|
72893
|
+
console.error(chalk30.red(`failed to load run: ${err.message}`));
|
|
72743
72894
|
return 1;
|
|
72744
72895
|
}
|
|
72745
72896
|
}
|
|
72746
72897
|
if (!existsSync26(paths.reportHtml)) {
|
|
72747
|
-
console.error(
|
|
72898
|
+
console.error(chalk30.red(`report.html not found at ${paths.reportHtml}`));
|
|
72748
72899
|
return 1;
|
|
72749
72900
|
}
|
|
72750
72901
|
const html = readFileSync31(paths.reportHtml, "utf8");
|
|
72751
72902
|
const slice = extractReportSection({ kind: "html", section: opts.section, html });
|
|
72752
72903
|
if (slice === null) {
|
|
72753
|
-
console.error(
|
|
72904
|
+
console.error(chalk30.red(`section "${opts.section}" not present in this report`));
|
|
72754
72905
|
return 1;
|
|
72755
72906
|
}
|
|
72756
72907
|
process.stdout.write(slice);
|
|
72757
72908
|
return 0;
|
|
72758
72909
|
}
|
|
72759
|
-
console.log(
|
|
72910
|
+
console.log(chalk30.dim(`opening ${paths.reportHtml}`));
|
|
72760
72911
|
await open2(paths.reportHtml).catch((err) => {
|
|
72761
|
-
console.error(
|
|
72912
|
+
console.error(chalk30.red(`failed to open: ${err.message}`));
|
|
72762
72913
|
});
|
|
72763
72914
|
return 0;
|
|
72764
72915
|
}
|
|
72765
72916
|
|
|
72766
72917
|
// src/commands/event.ts
|
|
72767
72918
|
import { resolve as resolve9 } from "node:path";
|
|
72768
|
-
import
|
|
72919
|
+
import chalk31 from "chalk";
|
|
72769
72920
|
|
|
72770
72921
|
// src/events.ts
|
|
72771
72922
|
import { appendFileSync, mkdirSync as mkdirSync17 } from "node:fs";
|
|
@@ -72789,24 +72940,24 @@ function eventCommand(type, opts) {
|
|
|
72789
72940
|
if (parsed && typeof parsed === "object")
|
|
72790
72941
|
data = parsed;
|
|
72791
72942
|
else {
|
|
72792
|
-
console.error(
|
|
72943
|
+
console.error(chalk31.red("--data must be a JSON object"));
|
|
72793
72944
|
return 1;
|
|
72794
72945
|
}
|
|
72795
72946
|
} catch {
|
|
72796
|
-
console.error(
|
|
72947
|
+
console.error(chalk31.red(`--data is not valid JSON: ${opts.data}`));
|
|
72797
72948
|
return 1;
|
|
72798
72949
|
}
|
|
72799
72950
|
}
|
|
72800
72951
|
const dir = resolve9(opts.dir);
|
|
72801
72952
|
emitEvent(dir, type, data);
|
|
72802
|
-
console.log(`${
|
|
72953
|
+
console.log(`${chalk31.green("✓")} ${type} → ${dir}/events.jsonl`);
|
|
72803
72954
|
return 0;
|
|
72804
72955
|
}
|
|
72805
72956
|
|
|
72806
72957
|
// src/commands/bench.ts
|
|
72807
72958
|
import { existsSync as existsSync27, mkdirSync as mkdirSync18, readFileSync as readFileSync32, writeFileSync as writeFileSync30 } from "node:fs";
|
|
72808
72959
|
import { resolve as resolve10 } from "node:path";
|
|
72809
|
-
import
|
|
72960
|
+
import chalk32 from "chalk";
|
|
72810
72961
|
|
|
72811
72962
|
// src/diff/motion.ts
|
|
72812
72963
|
var WEIGHT = {
|
|
@@ -73237,20 +73388,20 @@ async function gatherBenchSide(browser, opts) {
|
|
|
73237
73388
|
async function benchCommand(opts) {
|
|
73238
73389
|
const viewport = parseViewport3(opts.viewport);
|
|
73239
73390
|
if (!viewport) {
|
|
73240
|
-
console.error(
|
|
73391
|
+
console.error(chalk32.red(`--viewport inválido: ${opts.viewport}`));
|
|
73241
73392
|
return 2;
|
|
73242
73393
|
}
|
|
73243
73394
|
const waitMs = Number.parseInt(opts.wait, 10) || 0;
|
|
73244
73395
|
let props;
|
|
73245
73396
|
if (opts.props) {
|
|
73246
73397
|
if (!existsSync27(opts.props)) {
|
|
73247
|
-
console.error(
|
|
73398
|
+
console.error(chalk32.red(`--props não encontrado: ${opts.props}`));
|
|
73248
73399
|
return 2;
|
|
73249
73400
|
}
|
|
73250
73401
|
try {
|
|
73251
73402
|
props = JSON.parse(readFileSync32(opts.props, "utf8"));
|
|
73252
73403
|
} catch (err) {
|
|
73253
|
-
console.error(
|
|
73404
|
+
console.error(chalk32.red(`--props não é JSON válido: ${err.message}`));
|
|
73254
73405
|
return 2;
|
|
73255
73406
|
}
|
|
73256
73407
|
}
|
|
@@ -73265,7 +73416,7 @@ async function benchCommand(opts) {
|
|
|
73265
73416
|
const prefix = `bench-${slug}-${viewport}`;
|
|
73266
73417
|
const { aliases, note: aliasNote } = resolveAliases(opts.planDir);
|
|
73267
73418
|
if (aliasNote)
|
|
73268
|
-
console.log(
|
|
73419
|
+
console.log(chalk32.dim(` ${aliasNote}`));
|
|
73269
73420
|
const browser = await launchBrowser({ headless: true });
|
|
73270
73421
|
try {
|
|
73271
73422
|
const [prodSide, candSide] = await Promise.all([
|
|
@@ -73290,7 +73441,7 @@ async function benchCommand(opts) {
|
|
|
73290
73441
|
if (opts.json)
|
|
73291
73442
|
console.log(JSON.stringify(payload));
|
|
73292
73443
|
else
|
|
73293
|
-
console.error(
|
|
73444
|
+
console.error(chalk32.red(` bench falhou — ${readErr}`));
|
|
73294
73445
|
return 2;
|
|
73295
73446
|
}
|
|
73296
73447
|
const geometry = diffBoxTrees(prodSide.boxNodes.nodes, candSide.boxNodes.nodes, {
|
|
@@ -73320,9 +73471,9 @@ async function benchCommand(opts) {
|
|
|
73320
73471
|
console.log(JSON.stringify(result));
|
|
73321
73472
|
} else {
|
|
73322
73473
|
console.log("");
|
|
73323
|
-
console.log(
|
|
73324
|
-
console.log(
|
|
73325
|
-
console.log(
|
|
73474
|
+
console.log(chalk32.bold(` ${opts.component} — isolated (${viewport})`));
|
|
73475
|
+
console.log(chalk32.dim(` prod ${prodUrl}`));
|
|
73476
|
+
console.log(chalk32.dim(` cand ${candUrl}`));
|
|
73326
73477
|
console.log("");
|
|
73327
73478
|
for (const line of formatBoxTreeDiff(geometry).split(`
|
|
73328
73479
|
`))
|
|
@@ -73333,7 +73484,7 @@ async function benchCommand(opts) {
|
|
|
73333
73484
|
]) {
|
|
73334
73485
|
const caveat = data.settle && formatSettleCaveat(name, data.settle);
|
|
73335
73486
|
if (caveat)
|
|
73336
|
-
console.log(
|
|
73487
|
+
console.log(chalk32.yellow(` ${caveat}`));
|
|
73337
73488
|
}
|
|
73338
73489
|
if (motion) {
|
|
73339
73490
|
console.log("");
|
|
@@ -73342,7 +73493,7 @@ async function benchCommand(opts) {
|
|
|
73342
73493
|
console.log(` ${line}`);
|
|
73343
73494
|
}
|
|
73344
73495
|
console.log("");
|
|
73345
|
-
console.log(
|
|
73496
|
+
console.log(chalk32.dim(` ${resultPath}`));
|
|
73346
73497
|
}
|
|
73347
73498
|
return clean || !opts.failOnDiff ? 0 : 1;
|
|
73348
73499
|
} finally {
|
|
@@ -73353,7 +73504,7 @@ async function benchCommand(opts) {
|
|
|
73353
73504
|
}
|
|
73354
73505
|
|
|
73355
73506
|
// src/commands/locate.ts
|
|
73356
|
-
import
|
|
73507
|
+
import chalk33 from "chalk";
|
|
73357
73508
|
var hitOf = (n, nodes) => ({
|
|
73358
73509
|
key: n.key,
|
|
73359
73510
|
label: n.label,
|
|
@@ -73478,22 +73629,22 @@ function printResult3(r) {
|
|
|
73478
73629
|
const side = (name, a) => {
|
|
73479
73630
|
if (a.found) {
|
|
73480
73631
|
console.log(` ${name.padEnd(5)} ${a.hit.tag.padEnd(8)} ${formatHit(a.hit)}`);
|
|
73481
|
-
console.log(
|
|
73632
|
+
console.log(chalk33.dim(` node: ${a.hit.key}${a.hit.label ? ` (${a.hit.label})` : ""}`));
|
|
73482
73633
|
return;
|
|
73483
73634
|
}
|
|
73484
|
-
console.log(
|
|
73635
|
+
console.log(chalk33.yellow(` ${name.padEnd(5)} ${a.reason}`));
|
|
73485
73636
|
for (const c of a.candidates ?? [])
|
|
73486
|
-
console.log(
|
|
73637
|
+
console.log(chalk33.dim(` candidate: ${c}`));
|
|
73487
73638
|
};
|
|
73488
73639
|
console.log("");
|
|
73489
|
-
console.log(
|
|
73640
|
+
console.log(chalk33.bold(` ${r.label} — ${r.viewport}`));
|
|
73490
73641
|
side("prod", r.prod);
|
|
73491
73642
|
side("cand", r.cand);
|
|
73492
73643
|
if (r.prod.found && r.cand.found) {
|
|
73493
73644
|
const delta = formatDelta(r.prod.hit, r.cand.hit);
|
|
73494
73645
|
console.log(` ${"diff".padEnd(5)} ${delta ?? "identical box and type"}`);
|
|
73495
73646
|
for (const note of pairingNotes(r.prod.hit, r.cand.hit)) {
|
|
73496
|
-
console.log(
|
|
73647
|
+
console.log(chalk33.yellow(` note ${note}`));
|
|
73497
73648
|
}
|
|
73498
73649
|
}
|
|
73499
73650
|
}
|
|
@@ -73501,22 +73652,22 @@ async function locateCommand(opts) {
|
|
|
73501
73652
|
const selector = opts.selector ?? "body";
|
|
73502
73653
|
const waitMs = Number.parseInt(opts.wait, 10);
|
|
73503
73654
|
if (!Number.isFinite(waitMs) || waitMs < 0) {
|
|
73504
|
-
console.error(
|
|
73655
|
+
console.error(chalk33.red(`--wait inválido: ${opts.wait}`));
|
|
73505
73656
|
return 2;
|
|
73506
73657
|
}
|
|
73507
73658
|
if (opts.labels.length === 0) {
|
|
73508
|
-
console.error(
|
|
73659
|
+
console.error(chalk33.red("nenhum --label passado — o comando procura por label, não por seletor"));
|
|
73509
73660
|
return 2;
|
|
73510
73661
|
}
|
|
73511
73662
|
const viewports = opts.viewports.split(",").map((v) => v.trim());
|
|
73512
73663
|
const bad = viewports.find((v) => parseViewport3(v) === null);
|
|
73513
73664
|
if (bad) {
|
|
73514
|
-
console.error(
|
|
73665
|
+
console.error(chalk33.red(`viewport inválido: ${bad} (mobile | tablet | desktop)`));
|
|
73515
73666
|
return 2;
|
|
73516
73667
|
}
|
|
73517
73668
|
const { aliases, note } = resolveAliases(opts.planDir);
|
|
73518
73669
|
if (note && !opts.json)
|
|
73519
|
-
console.log(
|
|
73670
|
+
console.log(chalk33.dim(` ${note}`));
|
|
73520
73671
|
const results = [];
|
|
73521
73672
|
const caveats = [];
|
|
73522
73673
|
const browser = await launchBrowser({ headless: true });
|
|
@@ -73571,19 +73722,19 @@ async function locateCommand(opts) {
|
|
|
73571
73722
|
for (const r of results)
|
|
73572
73723
|
printResult3(r);
|
|
73573
73724
|
for (const c of caveats)
|
|
73574
|
-
console.log(
|
|
73725
|
+
console.log(chalk33.yellow(` ${c}`));
|
|
73575
73726
|
console.log("");
|
|
73576
73727
|
if (unresolved.length > 0) {
|
|
73577
|
-
console.log(
|
|
73728
|
+
console.log(chalk33.yellow(` ${unresolved.length} of ${results.length} label×viewport pair${results.length === 1 ? "" : "s"} unresolved — those rows are not a measurement`));
|
|
73578
73729
|
} else {
|
|
73579
|
-
console.log(
|
|
73730
|
+
console.log(chalk33.green(` ${results.length} label×viewport pair${results.length === 1 ? "" : "s"} located on both sides`));
|
|
73580
73731
|
}
|
|
73581
73732
|
return unresolved.length > 0 ? 1 : 0;
|
|
73582
73733
|
}
|
|
73583
73734
|
|
|
73584
73735
|
// src/commands/cockpit.ts
|
|
73585
73736
|
import { resolve as resolve15 } from "node:path";
|
|
73586
|
-
import
|
|
73737
|
+
import chalk34 from "chalk";
|
|
73587
73738
|
|
|
73588
73739
|
// src/server/cockpit.ts
|
|
73589
73740
|
import { readFileSync as readFileSync37 } from "node:fs";
|
|
@@ -73596,7 +73747,7 @@ import { existsSync as existsSync29, mkdirSync as mkdirSync20, readFileSync as r
|
|
|
73596
73747
|
import { join as join40, resolve as resolve12 } from "node:path";
|
|
73597
73748
|
|
|
73598
73749
|
// src/server/cockpit-settings.ts
|
|
73599
|
-
import { execFileSync as
|
|
73750
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
73600
73751
|
import { chmodSync, existsSync as existsSync28, mkdirSync as mkdirSync19, readFileSync as readFileSync33, writeFileSync as writeFileSync31 } from "node:fs";
|
|
73601
73752
|
import { homedir as homedir3 } from "node:os";
|
|
73602
73753
|
import { join as join39, resolve as resolve11 } from "node:path";
|
|
@@ -73631,7 +73782,7 @@ function saveSettings(planDir, next) {
|
|
|
73631
73782
|
}
|
|
73632
73783
|
var run = (cmd, args, env) => {
|
|
73633
73784
|
try {
|
|
73634
|
-
return
|
|
73785
|
+
return execFileSync4(cmd, args, {
|
|
73635
73786
|
encoding: "utf8",
|
|
73636
73787
|
timeout: 20000,
|
|
73637
73788
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -74622,7 +74773,7 @@ async function loadRun() {
|
|
|
74622
74773
|
`;
|
|
74623
74774
|
|
|
74624
74775
|
// src/server/cockpit-tasks.ts
|
|
74625
|
-
import { execFileSync as
|
|
74776
|
+
import { execFileSync as execFileSync5, spawn as spawn4 } from "node:child_process";
|
|
74626
74777
|
import { randomUUID } from "node:crypto";
|
|
74627
74778
|
import {
|
|
74628
74779
|
appendFileSync as appendFileSync2,
|
|
@@ -74931,7 +75082,7 @@ function prompt(task, planDir, dir) {
|
|
|
74931
75082
|
}
|
|
74932
75083
|
function prepareWorktree(task, planDir, dir, branch = `cockpit/${task.id}`) {
|
|
74933
75084
|
const repo = targetDir(planDir);
|
|
74934
|
-
const git = (...a) =>
|
|
75085
|
+
const git = (...a) => execFileSync5("git", ["-C", repo, ...a], { encoding: "utf8", timeout: 90000 }).trim();
|
|
74935
75086
|
try {
|
|
74936
75087
|
try {
|
|
74937
75088
|
git("fetch", "origin", "--quiet");
|
|
@@ -74950,7 +75101,7 @@ function prepareWorktree(task, planDir, dir, branch = `cockpit/${task.id}`) {
|
|
|
74950
75101
|
const locks = ["package.json", "yarn.lock", "bun.lock", "package-lock.json", "pnpm-lock.yaml"];
|
|
74951
75102
|
const sameDeps = (() => {
|
|
74952
75103
|
try {
|
|
74953
|
-
|
|
75104
|
+
execFileSync5("git", ["-C", repo, "diff", "--quiet", "HEAD", sha, "--", ...locks], {
|
|
74954
75105
|
timeout: 1e4
|
|
74955
75106
|
});
|
|
74956
75107
|
return true;
|
|
@@ -75103,7 +75254,7 @@ function taskProcesses(worktree) {
|
|
|
75103
75254
|
return hit.list;
|
|
75104
75255
|
const pids = [];
|
|
75105
75256
|
try {
|
|
75106
|
-
const out =
|
|
75257
|
+
const out = execFileSync5("lsof", ["-d", "cwd", "-Fpn"], {
|
|
75107
75258
|
encoding: "utf8",
|
|
75108
75259
|
timeout: 5000,
|
|
75109
75260
|
maxBuffer: 33554432
|
|
@@ -75120,7 +75271,7 @@ function taskProcesses(worktree) {
|
|
|
75120
75271
|
const list = [];
|
|
75121
75272
|
for (const pid of [...new Set(pids)]) {
|
|
75122
75273
|
try {
|
|
75123
|
-
const [rss, ...cmd] =
|
|
75274
|
+
const [rss, ...cmd] = execFileSync5("ps", ["-o", "rss=,command=", "-p", String(pid)], {
|
|
75124
75275
|
encoding: "utf8"
|
|
75125
75276
|
}).trim().split(/\s+/);
|
|
75126
75277
|
list.push({
|
|
@@ -75218,7 +75369,7 @@ function prPlan(planDir, id, baseOverride) {
|
|
|
75218
75369
|
const cut = task.base?.sha ?? null;
|
|
75219
75370
|
const git = (...a) => {
|
|
75220
75371
|
try {
|
|
75221
|
-
return
|
|
75372
|
+
return execFileSync5("git", ["-C", task.worktree, ...a], {
|
|
75222
75373
|
encoding: "utf8",
|
|
75223
75374
|
timeout: 1e4
|
|
75224
75375
|
}).trim();
|
|
@@ -75253,7 +75404,7 @@ function openPr(planDir, id, baseOverride) {
|
|
|
75253
75404
|
const task = JSON.parse(readFileSync36(join42(dir, "task.json"), "utf8"));
|
|
75254
75405
|
const wt = task.worktree;
|
|
75255
75406
|
const env = { ...process.env, ...ghEnv(plan.account ?? undefined) };
|
|
75256
|
-
const git = (...a) =>
|
|
75407
|
+
const git = (...a) => execFileSync5("git", ["-C", wt, ...a], { encoding: "utf8", timeout: 120000, env }).trim();
|
|
75257
75408
|
git("fetch", "origin", plan.base);
|
|
75258
75409
|
if (task.base?.sha && plan.rebase) {
|
|
75259
75410
|
try {
|
|
@@ -75287,7 +75438,7 @@ function openPr(planDir, id, baseOverride) {
|
|
|
75287
75438
|
`);
|
|
75288
75439
|
const bodyFile = join42(dir, "pr-body.md");
|
|
75289
75440
|
writeFileSync33(bodyFile, body);
|
|
75290
|
-
const out =
|
|
75441
|
+
const out = execFileSync5("gh", [
|
|
75291
75442
|
"pr",
|
|
75292
75443
|
"create",
|
|
75293
75444
|
"--repo",
|
|
@@ -75367,7 +75518,7 @@ function failingSpecsFromLog(log) {
|
|
|
75367
75518
|
function baselineWaiver(repo, prNumber, base, check, env) {
|
|
75368
75519
|
const gh = (...a) => {
|
|
75369
75520
|
try {
|
|
75370
|
-
return
|
|
75521
|
+
return execFileSync5("gh", a, {
|
|
75371
75522
|
encoding: "utf8",
|
|
75372
75523
|
timeout: 60000,
|
|
75373
75524
|
env,
|
|
@@ -75434,14 +75585,14 @@ function autoMergePrs(planDir) {
|
|
|
75434
75585
|
...waivers.map((w) => `- ${w.why}`)
|
|
75435
75586
|
].join(`
|
|
75436
75587
|
`);
|
|
75437
|
-
|
|
75588
|
+
execFileSync5("gh", ["pr", "comment", String(pr.number), "--body", body], {
|
|
75438
75589
|
cwd: wt,
|
|
75439
75590
|
encoding: "utf8",
|
|
75440
75591
|
timeout: 60000,
|
|
75441
75592
|
env
|
|
75442
75593
|
});
|
|
75443
75594
|
}
|
|
75444
|
-
|
|
75595
|
+
execFileSync5("gh", ["pr", "merge", String(pr.number), `--${s.mergeMethod ?? "merge"}`], {
|
|
75445
75596
|
cwd: wt,
|
|
75446
75597
|
encoding: "utf8",
|
|
75447
75598
|
timeout: 60000,
|
|
@@ -75470,7 +75621,7 @@ function prInfo(branch, repo, dir, ended, fresh = false) {
|
|
|
75470
75621
|
} catch {}
|
|
75471
75622
|
let info = null;
|
|
75472
75623
|
try {
|
|
75473
|
-
const out =
|
|
75624
|
+
const out = execFileSync5("gh", ["pr", "view", branch, "--json", "url,number,state,mergeable,statusCheckRollup"], {
|
|
75474
75625
|
cwd: repo,
|
|
75475
75626
|
encoding: "utf8",
|
|
75476
75627
|
timeout: 1e4,
|
|
@@ -75673,7 +75824,7 @@ function readTask(planDir, id) {
|
|
|
75673
75824
|
const baseSha = task.base?.sha ?? fr.base;
|
|
75674
75825
|
const git = (...a) => {
|
|
75675
75826
|
try {
|
|
75676
|
-
return
|
|
75827
|
+
return execFileSync5("git", ["-C", repo, ...a], { encoding: "utf8", timeout: 3000 }).trim();
|
|
75677
75828
|
} catch {
|
|
75678
75829
|
return "";
|
|
75679
75830
|
}
|
|
@@ -76043,19 +76194,19 @@ async function cockpitCommand(opts) {
|
|
|
76043
76194
|
host: opts.host
|
|
76044
76195
|
});
|
|
76045
76196
|
} catch (err) {
|
|
76046
|
-
console.error(
|
|
76197
|
+
console.error(chalk34.red(` ✖ could not start the cockpit: ${err.message}`));
|
|
76047
76198
|
return 2;
|
|
76048
76199
|
}
|
|
76049
76200
|
console.log("");
|
|
76050
|
-
console.log(
|
|
76051
|
-
console.log(` ${
|
|
76052
|
-
console.log(
|
|
76053
|
-
console.log(
|
|
76054
|
-
console.log(
|
|
76201
|
+
console.log(chalk34.bold(" parity cockpit"));
|
|
76202
|
+
console.log(` ${chalk34.green("●")} ${handle.url}`);
|
|
76203
|
+
console.log(chalk34.dim(` plan ${ctx.planDir}`));
|
|
76204
|
+
console.log(chalk34.dim(` runs ${ctx.output}`));
|
|
76205
|
+
console.log(chalk34.dim(` bench ${ctx.benchDir}`));
|
|
76055
76206
|
if (opts.host && opts.host !== "127.0.0.1" && opts.host !== "localhost") {
|
|
76056
|
-
console.log(
|
|
76207
|
+
console.log(chalk34.yellow(` ⚠ bound to ${opts.host} — this server is unauthenticated, reads the repo, and proxies arbitrary URLs`));
|
|
76057
76208
|
}
|
|
76058
|
-
console.log(
|
|
76209
|
+
console.log(chalk34.dim(` Ctrl+C to stop.
|
|
76059
76210
|
`));
|
|
76060
76211
|
if (opts.open !== false) {
|
|
76061
76212
|
const { default: openUrl } = await import("open");
|
|
@@ -76074,16 +76225,16 @@ async function cockpitCommand(opts) {
|
|
|
76074
76225
|
}
|
|
76075
76226
|
|
|
76076
76227
|
// src/commands/ios.ts
|
|
76077
|
-
import { execFileSync as
|
|
76228
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
76078
76229
|
import { existsSync as existsSync33, mkdirSync as mkdirSync22, readFileSync as readFileSync39, rmSync as rmSync3, writeFileSync as writeFileSync34 } from "node:fs";
|
|
76079
76230
|
import { homedir as homedir4, tmpdir as tmpdir2 } from "node:os";
|
|
76080
76231
|
import { join as join45, resolve as resolve16 } from "node:path";
|
|
76081
|
-
import
|
|
76232
|
+
import chalk36 from "chalk";
|
|
76082
76233
|
|
|
76083
76234
|
// src/commands/pair.ts
|
|
76084
76235
|
import { existsSync as existsSync32, readFileSync as readFileSync38 } from "node:fs";
|
|
76085
76236
|
import { join as join44 } from "node:path";
|
|
76086
|
-
import
|
|
76237
|
+
import chalk35 from "chalk";
|
|
76087
76238
|
|
|
76088
76239
|
// src/engine/pair.ts
|
|
76089
76240
|
function signatureOf(target, doc = document) {
|
|
@@ -76283,7 +76434,7 @@ async function open3(browser, url, viewport, waitMs) {
|
|
|
76283
76434
|
async function pairCommand(opts) {
|
|
76284
76435
|
const viewport = parseViewport3(opts.viewport);
|
|
76285
76436
|
if (!viewport) {
|
|
76286
|
-
console.error(
|
|
76437
|
+
console.error(chalk35.red(`invalid viewport: ${opts.viewport} (use mobile|tablet|desktop)`));
|
|
76287
76438
|
return 2;
|
|
76288
76439
|
}
|
|
76289
76440
|
const from = opts.side;
|
|
@@ -76325,16 +76476,16 @@ function report(opts, from, source, match, problem) {
|
|
|
76325
76476
|
ambiguous: match?.ambiguous ?? 0
|
|
76326
76477
|
}));
|
|
76327
76478
|
} else {
|
|
76328
|
-
const box = (s) => s ?
|
|
76479
|
+
const box = (s) => s ? chalk35.dim(`${s.rect.width}×${s.rect.height} at (${s.rect.x}, ${s.rect.y})`) : "";
|
|
76329
76480
|
if (source)
|
|
76330
76481
|
console.log(`${from} ${source.selector} ${box(source)}`);
|
|
76331
76482
|
if (match) {
|
|
76332
|
-
console.log(`${to} ${match.snapshot.selector} ${box(match.snapshot)} ${
|
|
76483
|
+
console.log(`${to} ${match.snapshot.selector} ${box(match.snapshot)} ${chalk35.dim(`by ${match.by}`)}`);
|
|
76333
76484
|
}
|
|
76334
76485
|
if (problem)
|
|
76335
|
-
console.log(
|
|
76486
|
+
console.log(chalk35.yellow(problem));
|
|
76336
76487
|
else if (match?.by === "position") {
|
|
76337
|
-
console.log(
|
|
76488
|
+
console.log(chalk35.yellow("matched by position only — verify it is the same element"));
|
|
76338
76489
|
}
|
|
76339
76490
|
}
|
|
76340
76491
|
return problem ? 2 : 0;
|
|
@@ -76366,7 +76517,7 @@ function sectionArgsFromTask(taskDir) {
|
|
|
76366
76517
|
// src/commands/ios.ts
|
|
76367
76518
|
var LOCK = join45(homedir4(), ".parity", "ios.lock");
|
|
76368
76519
|
function simctl(...args) {
|
|
76369
|
-
return
|
|
76520
|
+
return execFileSync6("xcrun", ["simctl", ...args], { encoding: "utf8", timeout: 180000 }).trim();
|
|
76370
76521
|
}
|
|
76371
76522
|
function alive2(pid) {
|
|
76372
76523
|
try {
|
|
@@ -76399,9 +76550,9 @@ function findDevice(name) {
|
|
|
76399
76550
|
}
|
|
76400
76551
|
async function iosCommand(opts) {
|
|
76401
76552
|
try {
|
|
76402
|
-
|
|
76553
|
+
execFileSync6("xcrun", ["simctl", "help"], { stdio: "ignore" });
|
|
76403
76554
|
} catch {
|
|
76404
|
-
console.error(
|
|
76555
|
+
console.error(chalk36.yellow("xcrun simctl is not available — install Xcode to test on iOS Safari. Nothing was measured."));
|
|
76405
76556
|
return 2;
|
|
76406
76557
|
}
|
|
76407
76558
|
let { prod, cand, selector, candSelector } = opts;
|
|
@@ -76476,11 +76627,11 @@ async function iosCommand(opts) {
|
|
|
76476
76627
|
if (opts.json)
|
|
76477
76628
|
console.log(JSON.stringify(report));
|
|
76478
76629
|
else {
|
|
76479
|
-
console.log(`${
|
|
76630
|
+
console.log(`${chalk36.bold("iOS Safari")} · ${device.name}`);
|
|
76480
76631
|
for (const [k, v] of Object.entries(shots))
|
|
76481
76632
|
console.log(` ${k.padEnd(5)} ${v}`);
|
|
76482
76633
|
for (const side of missing) {
|
|
76483
|
-
console.log(
|
|
76634
|
+
console.log(chalk36.yellow(` ${side}: the element was ${found[side] === false ? "not found" : "not reported"} in Safari — no diff (pass a selector that holds, e.g. from \`parity pair\`)`));
|
|
76484
76635
|
}
|
|
76485
76636
|
if (diff)
|
|
76486
76637
|
console.log(` diff ${(diff.pctDiff * 100).toFixed(2)}% (${diff.diffPixels} px) → ${diff.heatmapPath}`);
|
|
@@ -76890,7 +77041,7 @@ async function mcpCommand(opts) {
|
|
|
76890
77041
|
}
|
|
76891
77042
|
|
|
76892
77043
|
// src/commands/ab-detect.ts
|
|
76893
|
-
import
|
|
77044
|
+
import chalk37 from "chalk";
|
|
76894
77045
|
async function abDetectCommand(opts) {
|
|
76895
77046
|
const n = Math.max(2, Number.parseInt(opts.sessions, 10) || 3);
|
|
76896
77047
|
const waitMs = Number.parseInt(opts.wait, 10) || 0;
|
|
@@ -76915,14 +77066,14 @@ async function abDetectCommand(opts) {
|
|
|
76915
77066
|
if (opts.json)
|
|
76916
77067
|
console.log(JSON.stringify(report));
|
|
76917
77068
|
else {
|
|
76918
|
-
const color = report.verdict === "ab-detected" || report.verdict === "possible" ?
|
|
77069
|
+
const color = report.verdict === "ab-detected" || report.verdict === "possible" ? chalk37.yellow : report.verdict === "none" ? chalk37.green : chalk37.red;
|
|
76919
77070
|
console.log(color(` ${report.message}`));
|
|
76920
77071
|
for (const s of sessions) {
|
|
76921
77072
|
if (s.signature === null)
|
|
76922
|
-
console.log(
|
|
77073
|
+
console.log(chalk37.dim(` session ${s.index}: not read — ${s.error ?? "unknown"}`));
|
|
76923
77074
|
}
|
|
76924
77075
|
if (report.verdict === "ab-detected" || report.verdict === "possible") {
|
|
76925
|
-
console.log(
|
|
77076
|
+
console.log(chalk37.dim(" Pin one variant with --prod-cookie name=value (or --prod-storage-state) on section/heatmap."));
|
|
76926
77077
|
}
|
|
76927
77078
|
}
|
|
76928
77079
|
return report.verdict === "none" ? 0 : report.verdict === "inconclusive" ? 2 : 1;
|
|
@@ -76931,7 +77082,7 @@ async function abDetectCommand(opts) {
|
|
|
76931
77082
|
// src/commands/heatmap.ts
|
|
76932
77083
|
import { mkdirSync as mkdirSync23 } from "node:fs";
|
|
76933
77084
|
import { resolve as resolve19 } from "node:path";
|
|
76934
|
-
import
|
|
77085
|
+
import chalk38 from "chalk";
|
|
76935
77086
|
|
|
76936
77087
|
// src/diff/hotspot-findings.ts
|
|
76937
77088
|
var TYPOGRAPHY_PROPS = /^(font-family|font-weight|font-size|font-style|line-height|letter-spacing|text-transform)$/;
|
|
@@ -77345,16 +77496,16 @@ function exitCodeFor(verdict) {
|
|
|
77345
77496
|
async function heatmapCommand(opts) {
|
|
77346
77497
|
const specs = parseViewports2(opts.viewports);
|
|
77347
77498
|
if (typeof specs === "string") {
|
|
77348
|
-
console.error(
|
|
77499
|
+
console.error(chalk38.red(specs));
|
|
77349
77500
|
return EXIT_INCONCLUSIVE;
|
|
77350
77501
|
}
|
|
77351
77502
|
const waitMs = Number.parseInt(opts.wait, 10);
|
|
77352
77503
|
if (!Number.isFinite(waitMs) || waitMs < 0) {
|
|
77353
|
-
console.error(
|
|
77504
|
+
console.error(chalk38.red(`--wait inválido: ${opts.wait}`));
|
|
77354
77505
|
return EXIT_INCONCLUSIVE;
|
|
77355
77506
|
}
|
|
77356
77507
|
if (!isValidUrl5(opts.prod) || !isValidUrl5(opts.cand)) {
|
|
77357
|
-
console.error(
|
|
77508
|
+
console.error(chalk38.red("--prod ou --cand inválido"));
|
|
77358
77509
|
return EXIT_INCONCLUSIVE;
|
|
77359
77510
|
}
|
|
77360
77511
|
const selector = opts.selector?.trim() || null;
|
|
@@ -77396,7 +77547,7 @@ async function heatmapCommand(opts) {
|
|
|
77396
77547
|
};
|
|
77397
77548
|
if (opts.pr) {
|
|
77398
77549
|
await postQaComment({ report, pr: opts.pr, repo: opts.repo }).catch((err) => {
|
|
77399
|
-
console.error(
|
|
77550
|
+
console.error(chalk38.yellow(` aviso: não foi possível publicar no PR — ${err.message}`));
|
|
77400
77551
|
});
|
|
77401
77552
|
}
|
|
77402
77553
|
if (opts.json)
|
|
@@ -77911,21 +78062,21 @@ function isValidUrl5(s) {
|
|
|
77911
78062
|
}
|
|
77912
78063
|
}
|
|
77913
78064
|
var MARK = {
|
|
77914
|
-
identical:
|
|
77915
|
-
differs:
|
|
77916
|
-
inconclusive:
|
|
78065
|
+
identical: chalk38.green("✓"),
|
|
78066
|
+
differs: chalk38.red("✗"),
|
|
78067
|
+
inconclusive: chalk38.yellow("?")
|
|
77917
78068
|
};
|
|
77918
78069
|
function printReport(report) {
|
|
77919
78070
|
console.log("");
|
|
77920
|
-
console.log(
|
|
77921
|
-
console.log(
|
|
77922
|
-
console.log(
|
|
78071
|
+
console.log(chalk38.bold(` parity heatmap — ${report.mode}`));
|
|
78072
|
+
console.log(chalk38.dim(` prod: ${report.prodUrl}`));
|
|
78073
|
+
console.log(chalk38.dim(` cand: ${report.candUrl}`));
|
|
77923
78074
|
console.log("");
|
|
77924
78075
|
for (const v of report.viewports) {
|
|
77925
|
-
const detail = v.verdict === "identical" ?
|
|
78076
|
+
const detail = v.verdict === "identical" ? chalk38.dim("0 pixels") : v.reason ?? chalk38.dim("no detail");
|
|
77926
78077
|
console.log(` ${MARK[v.verdict]} ${v.label.padEnd(12)} ${detail}`);
|
|
77927
78078
|
if (v.maskedCoverage != null && v.maskedCoverage > 0) {
|
|
77928
|
-
console.log(
|
|
78079
|
+
console.log(chalk38.dim(` ${(v.maskedCoverage * 100).toFixed(1)}% of the frame excluded: prod does not reproduce those pixels`));
|
|
77929
78080
|
}
|
|
77930
78081
|
if (!v.findings.some((f) => f.type === "horizontal-overflow")) {
|
|
77931
78082
|
for (const [name, s] of [
|
|
@@ -77934,23 +78085,23 @@ function printReport(report) {
|
|
|
77934
78085
|
]) {
|
|
77935
78086
|
const o = s.horizontalOverflow;
|
|
77936
78087
|
if (o) {
|
|
77937
|
-
console.log(
|
|
78088
|
+
console.log(chalk38.yellow(` ${name} overflows sideways by ${o.px}px${o.widest ? ` (\`${o.widest.selector}\`)` : ""}`));
|
|
77938
78089
|
}
|
|
77939
78090
|
}
|
|
77940
78091
|
}
|
|
77941
78092
|
for (const f of v.findings.slice(0, 5)) {
|
|
77942
|
-
console.log(
|
|
78093
|
+
console.log(chalk38.dim(` [${f.type}] ${f.summary}`));
|
|
77943
78094
|
}
|
|
77944
78095
|
if (v.heatmapPath && v.verdict === "differs") {
|
|
77945
|
-
console.log(
|
|
78096
|
+
console.log(chalk38.dim(` ${v.heatmapPath}`));
|
|
77946
78097
|
}
|
|
77947
78098
|
const hosts = imageHostDelta(v.prod.imageHosts, v.cand.imageHosts);
|
|
77948
78099
|
if (hosts.onlyProd.length > 0 || hosts.onlyCand.length > 0) {
|
|
77949
|
-
console.log(
|
|
78100
|
+
console.log(chalk38.yellow(` image hosts diverge — ${formatHostDelta(hosts)}`));
|
|
77950
78101
|
}
|
|
77951
78102
|
}
|
|
77952
78103
|
console.log("");
|
|
77953
|
-
console.log(` ${MARK[report.verdict]} ${
|
|
78104
|
+
console.log(` ${MARK[report.verdict]} ${chalk38.bold(report.verdict)}${report.reason ? ` — ${report.reason}` : ""}`);
|
|
77954
78105
|
console.log("");
|
|
77955
78106
|
}
|
|
77956
78107
|
function imageHostDelta(prod, cand) {
|
|
@@ -77971,7 +78122,7 @@ function formatHostDelta(d) {
|
|
|
77971
78122
|
}
|
|
77972
78123
|
|
|
77973
78124
|
// src/commands/overlay.ts
|
|
77974
|
-
import
|
|
78125
|
+
import chalk39 from "chalk";
|
|
77975
78126
|
var SUBPIXEL_TOLERANCE = 0.5;
|
|
77976
78127
|
var MIN_GUTTER_PX = 2;
|
|
77977
78128
|
function judgeOverlay(rest, open, closed) {
|
|
@@ -78090,7 +78241,7 @@ async function measureTrigger(page, url, trigger, opts) {
|
|
|
78090
78241
|
async function overlayCommand(opts) {
|
|
78091
78242
|
const viewport = parseViewport3(opts.viewport);
|
|
78092
78243
|
if (!viewport) {
|
|
78093
|
-
console.error(
|
|
78244
|
+
console.error(chalk39.red(`invalid --viewport: ${opts.viewport}`));
|
|
78094
78245
|
return 2;
|
|
78095
78246
|
}
|
|
78096
78247
|
const waitMs = Math.max(0, Number.parseInt(opts.wait, 10) || 0);
|
|
@@ -78131,32 +78282,32 @@ async function overlayCommand(opts) {
|
|
|
78131
78282
|
return code;
|
|
78132
78283
|
}
|
|
78133
78284
|
for (const { url, results } of pages) {
|
|
78134
|
-
console.log(
|
|
78285
|
+
console.log(chalk39.bold(`
|
|
78135
78286
|
${url}`));
|
|
78136
78287
|
for (const r of results) {
|
|
78137
78288
|
if (r.status === "clean") {
|
|
78138
78289
|
const anchorNote = r.rest?.anchorX === null ? ` (anchor ${opts.anchor} not found — width only)` : "";
|
|
78139
78290
|
console.log(` clean ${r.trigger}${anchorNote}`);
|
|
78140
78291
|
} else if (r.status === "inconclusive") {
|
|
78141
|
-
console.log(
|
|
78292
|
+
console.log(chalk39.yellow(` INCONCLUSIVE ${r.trigger} — ${r.reason}`));
|
|
78142
78293
|
} else {
|
|
78143
|
-
console.log(
|
|
78294
|
+
console.log(chalk39.red(` overlay-layout-shift ${r.trigger}`));
|
|
78144
78295
|
for (const s of r.shifts) {
|
|
78145
|
-
console.log(
|
|
78296
|
+
console.log(chalk39.red(` ${s.phase.padEnd(6)} ${s.metric} ${s.from} → ${s.to} (${s.to - s.from > 0 ? "+" : ""}${Math.round((s.to - s.from) * 100) / 100}px)`));
|
|
78146
78297
|
}
|
|
78147
78298
|
if (r.closed === null)
|
|
78148
|
-
console.log(
|
|
78299
|
+
console.log(chalk39.dim(" (overlay did not close; close leg unmeasured)"));
|
|
78149
78300
|
}
|
|
78150
78301
|
}
|
|
78151
78302
|
}
|
|
78152
78303
|
if (code === 1) {
|
|
78153
|
-
console.log(
|
|
78304
|
+
console.log(chalk39.dim("\n The scroll lock removes the scrollbar and the page widens. Fix: have the scroll lock set `scrollbar-gutter: stable` on `html` while it is active (not permanently — a global gutter narrows pages whose scrollbar is overlay/hidden), or pad the lock by the scrollbar width."));
|
|
78154
78305
|
}
|
|
78155
78306
|
return code;
|
|
78156
78307
|
}
|
|
78157
78308
|
|
|
78158
78309
|
// src/commands/states.ts
|
|
78159
|
-
import
|
|
78310
|
+
import chalk40 from "chalk";
|
|
78160
78311
|
var ROOT_ATTR = "data-parity-states";
|
|
78161
78312
|
var rootSelector = (i) => `[${ROOT_ATTR}="${i}"]`;
|
|
78162
78313
|
function resolveStateRoots(args) {
|
|
@@ -78465,7 +78616,7 @@ function statesVerdict(counts) {
|
|
|
78465
78616
|
async function statesCommand(opts) {
|
|
78466
78617
|
const viewport = parseViewport3(opts.viewport);
|
|
78467
78618
|
if (!viewport) {
|
|
78468
|
-
console.error(
|
|
78619
|
+
console.error(chalk40.red(`--viewport inválido: ${opts.viewport}`));
|
|
78469
78620
|
return 2;
|
|
78470
78621
|
}
|
|
78471
78622
|
const waitMs = Number.parseInt(opts.wait, 10) || 0;
|
|
@@ -78475,12 +78626,12 @@ async function statesCommand(opts) {
|
|
|
78475
78626
|
const prodSelector = opts.prodSelector?.trim() || opts.selector?.trim();
|
|
78476
78627
|
const candSelector = opts.candSelector?.trim() || opts.selector?.trim();
|
|
78477
78628
|
if (!prodSelector || !candSelector) {
|
|
78478
|
-
console.error(
|
|
78629
|
+
console.error(chalk40.red(" informe --selector (ambos os lados) ou --prod-selector e --cand-selector"));
|
|
78479
78630
|
return 2;
|
|
78480
78631
|
}
|
|
78481
78632
|
const { aliases, note: aliasNote } = resolveAliases(opts.planDir);
|
|
78482
78633
|
if (aliasNote)
|
|
78483
|
-
console.log(
|
|
78634
|
+
console.log(chalk40.dim(` ${aliasNote}`));
|
|
78484
78635
|
const browser = await launchBrowser({ headless: true });
|
|
78485
78636
|
try {
|
|
78486
78637
|
const [prodSide, candSide] = await Promise.all([
|
|
@@ -78505,7 +78656,7 @@ async function statesCommand(opts) {
|
|
|
78505
78656
|
]);
|
|
78506
78657
|
if (prodSide.baseError || candSide.baseError) {
|
|
78507
78658
|
const which = prodSide.baseError ? `prod: ${prodSide.baseError}` : `cand: ${candSide.baseError}`;
|
|
78508
|
-
console.error(
|
|
78659
|
+
console.error(chalk40.red(` não foi possível ler o componente — ${which}`));
|
|
78509
78660
|
return 2;
|
|
78510
78661
|
}
|
|
78511
78662
|
for (const [name, side, sel] of [
|
|
@@ -78514,13 +78665,13 @@ async function statesCommand(opts) {
|
|
|
78514
78665
|
]) {
|
|
78515
78666
|
const r = side.resolution;
|
|
78516
78667
|
if (r?.kind === "ambiguous") {
|
|
78517
|
-
console.error(
|
|
78668
|
+
console.error(chalk40.red(` ${name}: ${sel} matches ${r.total} visible elements and none looks like a product card (image + link + price). Narrow it to one:`));
|
|
78518
78669
|
for (const sample of r.samples)
|
|
78519
|
-
console.error(
|
|
78670
|
+
console.error(chalk40.dim(` ${sample}`));
|
|
78520
78671
|
return 2;
|
|
78521
78672
|
}
|
|
78522
78673
|
if (!r || r.kind === "none") {
|
|
78523
|
-
console.error(
|
|
78674
|
+
console.error(chalk40.red(` ${name}: ${sel} matches no visible element${r?.error ? ` — ${r.error}` : ""}`));
|
|
78524
78675
|
return 2;
|
|
78525
78676
|
}
|
|
78526
78677
|
}
|
|
@@ -78602,21 +78753,21 @@ async function statesCommand(opts) {
|
|
|
78602
78753
|
]) {
|
|
78603
78754
|
const caveat = data.settle && formatSettleCaveat(name, data.settle);
|
|
78604
78755
|
if (caveat)
|
|
78605
|
-
console.log(
|
|
78756
|
+
console.log(chalk40.yellow(` ${caveat}`));
|
|
78606
78757
|
}
|
|
78607
78758
|
if (cardMode) {
|
|
78608
78759
|
console.log("");
|
|
78609
|
-
console.log(
|
|
78760
|
+
console.log(chalk40.bold(` Product cards: ${pairing.pairs.length} pair(s) — ${pairing.pairs.map(([p, c]) => `prod #${p + 1} ↔ cand #${c + 1}`).join(", ") || "none"}`));
|
|
78610
78761
|
for (const [name, side] of [
|
|
78611
78762
|
["prod", prodSide],
|
|
78612
78763
|
["cand", candSide]
|
|
78613
78764
|
]) {
|
|
78614
78765
|
const r = side.resolution;
|
|
78615
78766
|
if (r?.kind === "cards" && r.ignored > 0) {
|
|
78616
|
-
console.log(
|
|
78767
|
+
console.log(chalk40.dim(` ${name}: ${r.ignored} matched element(s) are not product cards and were ignored`));
|
|
78617
78768
|
}
|
|
78618
78769
|
if (r?.kind === "single" && !r.isCard) {
|
|
78619
|
-
console.log(
|
|
78770
|
+
console.log(chalk40.yellow(` ${name}: the selector names one element that is not a product card; it is never paired with a card`));
|
|
78620
78771
|
}
|
|
78621
78772
|
}
|
|
78622
78773
|
const unpaired = [
|
|
@@ -78624,65 +78775,65 @@ async function statesCommand(opts) {
|
|
|
78624
78775
|
...pairing.unpairedCand.map((i) => `cand #${i + 1}`)
|
|
78625
78776
|
];
|
|
78626
78777
|
if (unpaired.length)
|
|
78627
|
-
console.log(
|
|
78778
|
+
console.log(chalk40.dim(` UNPAIRED cards: ${unpaired.join(", ")} — not compared`));
|
|
78628
78779
|
if (pairing.pairs.length === 0) {
|
|
78629
|
-
console.log(
|
|
78780
|
+
console.log(chalk40.yellow(" INCONCLUSIVE — no card paired, so nothing was compared."));
|
|
78630
78781
|
}
|
|
78631
78782
|
}
|
|
78632
78783
|
console.log("");
|
|
78633
|
-
console.log(
|
|
78784
|
+
console.log(chalk40.bold(" Declared motion"));
|
|
78634
78785
|
if (!motion) {
|
|
78635
78786
|
const err = prodFlat.motionError ?? candFlat.motionError ?? "nothing paired";
|
|
78636
|
-
console.log(
|
|
78787
|
+
console.log(chalk40.yellow(` não foi possível comparar — ${err}`));
|
|
78637
78788
|
} else {
|
|
78638
78789
|
for (const line of formatMotionDiff(motion).split(`
|
|
78639
78790
|
`))
|
|
78640
78791
|
console.log(` ${line}`);
|
|
78641
78792
|
}
|
|
78642
78793
|
console.log("");
|
|
78643
|
-
console.log(
|
|
78794
|
+
console.log(chalk40.bold(` Hover effects (${prodFlat.effects.length} prod / ${candFlat.effects.length} cand)`));
|
|
78644
78795
|
const nothing = effects.lost.length === 0 && effects.changed.length === 0 && effects.added.length === 0 && effects.unpaired.length === 0;
|
|
78645
78796
|
if (nothing && !exercised) {
|
|
78646
|
-
console.log(
|
|
78797
|
+
console.log(chalk40.yellow(" INCONCLUSIVE — no hover changed anything on either side, so nothing was exercised. Check the selector holds an interactive element."));
|
|
78647
78798
|
} else if (nothing) {
|
|
78648
78799
|
console.log(" clean — every hover that changes something in prod changes the same in cand");
|
|
78649
78800
|
}
|
|
78650
78801
|
for (const e of effects.lost) {
|
|
78651
|
-
console.log(
|
|
78802
|
+
console.log(chalk40.red(` LOST ${e.target}${e.label ? ` (${e.label})` : ""} — prod moves [${e.properties.join(", ")}]; cand's element was hovered and moved nothing`));
|
|
78652
78803
|
}
|
|
78653
78804
|
for (const { prod, extra, notComparable, onElement } of effects.changed) {
|
|
78654
78805
|
console.log(` DIFFERS ${prod.target}${prod.label ? ` (${prod.label})` : ""}`);
|
|
78655
78806
|
if (onElement.length) {
|
|
78656
|
-
console.log(
|
|
78807
|
+
console.log(chalk40.yellow(` prod also moves [${onElement.join(", ")}] on the element itself`));
|
|
78657
78808
|
}
|
|
78658
78809
|
if (extra.length)
|
|
78659
78810
|
console.log(` cand also moves [${extra.join(", ")}]`);
|
|
78660
78811
|
if (notComparable.length) {
|
|
78661
|
-
console.log(
|
|
78812
|
+
console.log(chalk40.dim(` not comparable: [${notComparable.join(", ")}] — prod's hover renumbered ${prod.renumberedNodes} of the changed paths, so these were read on elements that are not the same ones before and after. Bench the component, or pick a selector whose subtree the hover does not restructure.`));
|
|
78662
78813
|
}
|
|
78663
78814
|
if (onElement.length === 0 && extra.length === 0) {
|
|
78664
|
-
console.log(
|
|
78815
|
+
console.log(chalk40.dim(" nothing comparable differs."));
|
|
78665
78816
|
}
|
|
78666
78817
|
}
|
|
78667
78818
|
for (const e of effects.unpaired) {
|
|
78668
|
-
console.log(
|
|
78819
|
+
console.log(chalk40.dim(` UNPAIRED ${e.target}${e.label ? ` (${e.label})` : ""} — prod moves [${e.properties.join(", ")}]; no matching element found on the cand side (not a defect — the port may have changed the element, or it is outside --selector)`));
|
|
78669
78820
|
}
|
|
78670
78821
|
for (const e of effects.added) {
|
|
78671
78822
|
console.log(` ADDED ${e.target} — cand moves [${e.properties.join(", ")}]; prod does not`);
|
|
78672
78823
|
}
|
|
78673
78824
|
if (effects.unpaired.length > 0 && effects.lost.length === 0 && effects.changed.length === 0) {
|
|
78674
78825
|
console.log("");
|
|
78675
|
-
console.log(
|
|
78826
|
+
console.log(chalk40.yellow(` ${effects.unpaired.length} prod effect(s) had no counterpart and NOTHING paired. That is a pairing failure, not a set of defects — check --selector contains the same component on both sides, and that ported roots carry data-section.`));
|
|
78676
78827
|
}
|
|
78677
78828
|
const prodAmbient = prodSide.roots.reduce((n, r) => n + r.ambient, 0);
|
|
78678
78829
|
const candAmbient = candSide.roots.reduce((n, r) => n + r.ambient, 0);
|
|
78679
78830
|
if (prodAmbient > 0 || candAmbient > 0) {
|
|
78680
|
-
console.log(
|
|
78831
|
+
console.log(chalk40.dim(` ${prodAmbient} prod / ${candAmbient} cand node+property pair(s) were moving with no interaction (carousel, autoplaying video, anything on a timer) and were subtracted. A large count means --selector contains something animating on its own; narrow it.`));
|
|
78681
78832
|
}
|
|
78682
78833
|
for (const cap of caps)
|
|
78683
|
-
console.log(
|
|
78834
|
+
console.log(chalk40.yellow(` CAPPED — ${cap}; absence of a finding is not proof`));
|
|
78684
78835
|
if (truncated) {
|
|
78685
|
-
console.log(
|
|
78836
|
+
console.log(chalk40.dim(" TRUNCATED — box-tree or motion node cap hit; absence of a finding is not proof"));
|
|
78686
78837
|
}
|
|
78687
78838
|
return inconclusive || effects.lost.length > 0 || (motion?.findings.length ?? 0) > 0 ? 1 : 0;
|
|
78688
78839
|
} finally {
|
|
@@ -78693,7 +78844,7 @@ async function statesCommand(opts) {
|
|
|
78693
78844
|
}
|
|
78694
78845
|
|
|
78695
78846
|
// src/commands/variance.ts
|
|
78696
|
-
import
|
|
78847
|
+
import chalk41 from "chalk";
|
|
78697
78848
|
|
|
78698
78849
|
// src/diff/variance.ts
|
|
78699
78850
|
var uniq2 = (xs) => [...new Set(xs)];
|
|
@@ -78797,7 +78948,7 @@ function formatVariance(report, opts = {}) {
|
|
|
78797
78948
|
// src/commands/variance.ts
|
|
78798
78949
|
function varianceCommand(opts) {
|
|
78799
78950
|
if (opts.runIds.length < 2) {
|
|
78800
|
-
console.error(
|
|
78951
|
+
console.error(chalk41.red(" informe pelo menos 2 runs: parity variance <runIdA> <runIdB> [...]"));
|
|
78801
78952
|
return 2;
|
|
78802
78953
|
}
|
|
78803
78954
|
const budget = Number.parseFloat(opts.scoreBudget ?? "1");
|
|
@@ -78806,7 +78957,7 @@ function varianceCommand(opts) {
|
|
|
78806
78957
|
try {
|
|
78807
78958
|
runs.push(loadRun(opts.output, id));
|
|
78808
78959
|
} catch (err) {
|
|
78809
|
-
console.error(
|
|
78960
|
+
console.error(chalk41.red(` ✖ ${err.message}`));
|
|
78810
78961
|
return 2;
|
|
78811
78962
|
}
|
|
78812
78963
|
}
|
|
@@ -78815,7 +78966,7 @@ function varianceCommand(opts) {
|
|
|
78815
78966
|
console.log(JSON.stringify({ ...report, stable: isStable(report, budget), scoreBudget: budget }));
|
|
78816
78967
|
} else {
|
|
78817
78968
|
console.log("");
|
|
78818
|
-
console.log(
|
|
78969
|
+
console.log(chalk41.bold(" Score variance"));
|
|
78819
78970
|
for (const line of formatVariance(report, { scoreBudget: budget }).split(`
|
|
78820
78971
|
`)) {
|
|
78821
78972
|
console.log(` ${line}`);
|
|
@@ -78830,7 +78981,7 @@ function varianceCommand(opts) {
|
|
|
78830
78981
|
import { existsSync as existsSync35, readFileSync as readFileSync43, writeFileSync as writeFileSync36 } from "node:fs";
|
|
78831
78982
|
import { availableParallelism } from "node:os";
|
|
78832
78983
|
import { join as join47 } from "node:path";
|
|
78833
|
-
import
|
|
78984
|
+
import chalk42 from "chalk";
|
|
78834
78985
|
import ora9 from "ora";
|
|
78835
78986
|
|
|
78836
78987
|
// src/checks/agentic-nav.ts
|
|
@@ -79128,10 +79279,10 @@ async function vitalsCommand(opts) {
|
|
|
79128
79279
|
const runId = newRunId();
|
|
79129
79280
|
const paths = createRunDir(opts.output, runId);
|
|
79130
79281
|
const t0 = Date.now();
|
|
79131
|
-
console.log(
|
|
79282
|
+
console.log(chalk42.bold(`
|
|
79132
79283
|
parity vitals ${runId}`));
|
|
79133
|
-
console.log(
|
|
79134
|
-
console.log(
|
|
79284
|
+
console.log(chalk42.dim(` prod: ${opts.prod}`));
|
|
79285
|
+
console.log(chalk42.dim(` cand: ${opts.cand}`));
|
|
79135
79286
|
const discoverSpinner = ora9("Descobrindo páginas…").start();
|
|
79136
79287
|
const pagePaths = await discoverPagePaths2(opts.prod, opts);
|
|
79137
79288
|
if (pagePaths.length === 0) {
|
|
@@ -79163,7 +79314,7 @@ async function vitalsCommand(opts) {
|
|
|
79163
79314
|
completed++;
|
|
79164
79315
|
const elapsed = ((Date.now() - t0) / 1000).toFixed(0);
|
|
79165
79316
|
const etaSec = completed > 0 ? Math.round((Date.now() - t0) / completed * (total - completed) / 1000) : 0;
|
|
79166
|
-
progress.text = `${completed}/${total} · ${elapsed}s · ETA ${etaSec}s · ${task.side === "prod" ?
|
|
79317
|
+
progress.text = `${completed}/${total} · ${elapsed}s · ETA ${etaSec}s · ${task.side === "prod" ? chalk42.cyan("prod") : chalk42.magenta("cand")} ${task.path} (${task.viewport})`;
|
|
79167
79318
|
}
|
|
79168
79319
|
});
|
|
79169
79320
|
progress.succeed(`${total} capture(s) em ${((Date.now() - t0) / 1000).toFixed(1)}s`);
|
|
@@ -79192,7 +79343,7 @@ async function vitalsCommand(opts) {
|
|
|
79192
79343
|
}
|
|
79193
79344
|
lhCompleted++;
|
|
79194
79345
|
const elapsed = ((Date.now() - lhT0) / 1000).toFixed(0);
|
|
79195
|
-
lhProgress.text = `Lighthouse ${lhCompleted}/${done.length} · ${elapsed}s · ${task.side === "prod" ?
|
|
79346
|
+
lhProgress.text = `Lighthouse ${lhCompleted}/${done.length} · ${elapsed}s · ${task.side === "prod" ? chalk42.cyan("prod") : chalk42.magenta("cand")} ${task.path} (${task.viewport})`;
|
|
79196
79347
|
});
|
|
79197
79348
|
lhProgress.succeed(`Lighthouse ${done.length} página(s) em ${((Date.now() - lhT0) / 1000).toFixed(1)}s`);
|
|
79198
79349
|
}
|
|
@@ -79270,8 +79421,8 @@ async function vitalsCommand(opts) {
|
|
|
79270
79421
|
`, "utf8");
|
|
79271
79422
|
printSummary9(vitalsResult, cacheResult, scoresResult, oppsResult, agenticResult);
|
|
79272
79423
|
console.log("");
|
|
79273
|
-
console.log(
|
|
79274
|
-
console.log(
|
|
79424
|
+
console.log(chalk42.dim(` → ${paths.reportHtml}`));
|
|
79425
|
+
console.log(chalk42.dim(` \uD83D\uDCA1 use 'parity serve ${runId}' pra preview iframe`));
|
|
79275
79426
|
console.log("");
|
|
79276
79427
|
if (opts.open) {
|
|
79277
79428
|
const { default: open } = await import("open");
|
|
@@ -79371,7 +79522,7 @@ function parseUrlList(input) {
|
|
|
79371
79522
|
}
|
|
79372
79523
|
function printSummary9(vitals, cache, scores, opportunities, agentic) {
|
|
79373
79524
|
console.log("");
|
|
79374
|
-
console.log(
|
|
79525
|
+
console.log(chalk42.bold(" Summary:"));
|
|
79375
79526
|
console.log(` ${vitals.summary}`);
|
|
79376
79527
|
console.log(` ${cache.summary}`);
|
|
79377
79528
|
if (scores.status !== "skipped")
|
|
@@ -79627,7 +79778,19 @@ program.command("console").description("Single-page console capture. Boots Playw
|
|
|
79627
79778
|
program.command("html").description("Dump page HTML or diff prod vs cand HTML for a section. No LLM, no checks — sub-10s debug loop (issue #31).").option("--url <url>", "Single-side mode: dump HTML of this URL").option("--prod <url>", "Diff mode: prod URL (use together with --cand --diff)").option("--cand <url>", "Diff mode: cand URL (use together with --prod --diff)").option("--selector <sel>", "Narrow output to a CSS selector (outer HTML of first match)").option("--pretty", "Format HTML with prettier", false).option("--diff", "Diff mode (required with --prod/--cand). Prints unified diff", false).option("--viewport <viewport>", "mobile | desktop | tablet", "mobile").option("--wait <ms>", "Extra ms after networkidle so SSR/hydration settles", (v) => Number(v), 2000).option("--json", "Emit one-line JSON instead of pretty text", false).action(async (opts) => {
|
|
79628
79779
|
process.exit(await htmlCommand(opts));
|
|
79629
79780
|
});
|
|
79630
|
-
program.command("check").argument("<name>", "check name (kebab-case, e.g. console-errors-baseline)").description("Run a single check against a prod×cand pair on one page. Skips sitemap discovery, the other 13 checks, and the LLM aggregation. Sub-10s loop for verifying a single fix (issue #31).").
|
|
79781
|
+
program.command("check").argument("<name>", "check name (kebab-case, e.g. console-errors-baseline)").description("Run a single check against a prod×cand pair on one page. Skips sitemap discovery, the other 13 checks, and the LLM aggregation. Sub-10s loop for verifying a single fix (issue #31). `content-freshness` is the exception: no prod, no browser — it compares the CMS content the candidate serves (/.decofile) with .deco/blocks at --ref in --repo. Run it instead of a deploy or `sync:kv` (issue #484).").option("--prod <url>", "Production URL (base). Required by every check but content-freshness").requiredOption("--cand <url>", "Candidate URL (base)").option("--viewports <list>", "Comma-separated mobile,desktop,tablet", "mobile").option("--page <path>", "Pathname to capture (e.g. /bota-tudao-2025)", "/").option("--repo <dir>", "content-freshness: target repo (read via git, never checked out)", ".").option("--ref <ref>", "content-freshness: git ref holding the expected .deco/blocks", "origin/main").option("--json", "Emit one-line JSON instead of pretty text", false).action(async (name, opts) => {
|
|
79782
|
+
if (name === "content-freshness") {
|
|
79783
|
+
process.exit(await contentFreshnessCommand({
|
|
79784
|
+
cand: opts.cand,
|
|
79785
|
+
repo: opts.repo,
|
|
79786
|
+
ref: opts.ref,
|
|
79787
|
+
json: opts.json
|
|
79788
|
+
}));
|
|
79789
|
+
}
|
|
79790
|
+
if (!opts.prod) {
|
|
79791
|
+
console.error(`error: required option '--prod <url>' not specified for check '${name}'`);
|
|
79792
|
+
process.exit(2);
|
|
79793
|
+
}
|
|
79631
79794
|
process.exit(await checkCommand({
|
|
79632
79795
|
name,
|
|
79633
79796
|
prod: opts.prod,
|