@decocms/parity 0.26.7 → 0.26.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +58 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -63175,6 +63175,34 @@ function buildMigrationPlan(input) {
63175
63175
  components
63176
63176
  };
63177
63177
  }
63178
+ function mergePlanDecisions(fresh, previous) {
63179
+ if (!previous)
63180
+ return { plan: fresh, carried: [], droppedWithDecisions: [] };
63181
+ const prevByKey = new Map(previous.components.map((c) => [key(c.name), c]));
63182
+ const carried = [];
63183
+ for (const row of fresh.components) {
63184
+ const prev2 = prevByKey.get(key(row.name));
63185
+ if (!prev2)
63186
+ continue;
63187
+ if (prev2.status !== "pending")
63188
+ row.status = prev2.status;
63189
+ if (prev2.reference)
63190
+ row.reference = prev2.reference;
63191
+ if (prev2.verified)
63192
+ row.verified = prev2.verified;
63193
+ if (prev2.status !== "pending" || prev2.reference || prev2.verified)
63194
+ carried.push(row.name);
63195
+ }
63196
+ const freshKeys = new Set(fresh.components.map((c) => key(c.name)));
63197
+ const droppedWithDecisions = previous.components.filter((c) => !freshKeys.has(key(c.name))).filter((c) => c.status !== "pending" || Boolean(c.reference) || Boolean(c.verified)).map((c) => c.name);
63198
+ const prevPages = new Map(previous.pages.map((p) => [p.path, p]));
63199
+ for (const page of fresh.pages) {
63200
+ const prev2 = prevPages.get(page.path);
63201
+ if (prev2?.status && prev2.status !== "pending")
63202
+ page.status = prev2.status;
63203
+ }
63204
+ return { plan: fresh, carried, droppedWithDecisions };
63205
+ }
63178
63206
  var PLAN_FILE = "migration-plan.json";
63179
63207
  var SETTLED = new Set(["done", "as-is", "upgrade", "skipped"]);
63180
63208
  function loadPlan(dir) {
@@ -64524,12 +64552,19 @@ async function migrateCommand(opts) {
64524
64552
  pages,
64525
64553
  components
64526
64554
  };
64527
- const plan = buildMigrationPlan({
64555
+ const merged = mergePlanDecisions(buildMigrationPlan({
64528
64556
  bundle,
64529
64557
  source: { kind: source.kind, label: source.label, dir: opts.source ?? null },
64530
64558
  inventory: sourceInventory
64531
- });
64559
+ }), loadPlan(runDir));
64560
+ const plan = merged.plan;
64532
64561
  savePlan(runDir, plan);
64562
+ if (merged.carried.length) {
64563
+ console.log(chalk17.gray(` plan: carried ${merged.carried.length} recorded decision(s) forward`));
64564
+ }
64565
+ if (merged.droppedWithDecisions.length) {
64566
+ console.log(chalk17.yellow(` plan: ${merged.droppedWithDecisions.length} component(s) with recorded decisions are no longer in the capture — ${merged.droppedWithDecisions.join(", ")}`));
64567
+ }
64533
64568
  bundle.components.push(...syntheticSourceComponents(plan));
64534
64569
  if (format === "json" || format === "both")
64535
64570
  await jsonExporter2.export(bundle, runDir);
@@ -64959,6 +64994,25 @@ function planVerifyCommand(dir, name, verdict2, opts) {
64959
64994
  console.log(`${mark} ${component.name} → ${verdict2} (against ${component.verified?.against})`);
64960
64995
  return 0;
64961
64996
  }
64997
+ function planMergeCommand(dir, sourceDir) {
64998
+ const fresh = loadPlan(sourceDir);
64999
+ if (!fresh) {
65000
+ console.error(chalk18.red(`No migration-plan.json found in ${sourceDir}`));
65001
+ return 1;
65002
+ }
65003
+ const existing = loadPlan(dir);
65004
+ const { plan, carried, droppedWithDecisions } = mergePlanDecisions(fresh, existing);
65005
+ savePlan(dir, plan);
65006
+ if (!existing) {
65007
+ console.log(`${chalk18.green("✓")} plan written to ${dir} (nothing to merge)`);
65008
+ return 0;
65009
+ }
65010
+ console.log(`${chalk18.green("✓")} merged into ${dir} — ${carried.length} decision(s) kept`);
65011
+ if (droppedWithDecisions.length) {
65012
+ console.log(chalk18.yellow(` no longer in the capture, decisions lost: ${droppedWithDecisions.join(", ")}`));
65013
+ }
65014
+ return 0;
65015
+ }
64962
65016
  function planPageCommand(dir, path, opts) {
64963
65017
  const plan = loadPlan(dir);
64964
65018
  if (!plan) {
@@ -67838,6 +67892,8 @@ program.command("plan").description("Inspect/update the migration-plan.json comp
67838
67892
  selector: opts.selector,
67839
67893
  note: opts.note
67840
67894
  }));
67895
+ })).addCommand(new Command("merge").description("Bring a freshly captured plan into the canonical one, keeping every recorded decision (ported / as-is / upgrade / verified). Use this instead of copying the file — a copy reverts the decisions.").argument("<source>", "Directory holding the freshly captured migration-plan.json").option("--dir <path>", "Destination directory holding the canonical migration-plan.json", ".parity").action((source, opts) => {
67896
+ process.exit(planMergeCommand(opts.dir, source));
67841
67897
  })).addCommand(new Command("verify").description("Record that a component was actually compared against its reference. A `done` row with no verification only means the code exists.").argument("<name>", "Component name (case- and separator-insensitive)").argument("<verdict>", "pass | fail").option("--note <text>", "What was seen").option("--at <iso>", "Timestamp (default: now)").option("--dir <path>", "Directory holding migration-plan.json (default: the target repo's .parity/)", ".parity").action((name, verdict2, opts) => {
67842
67898
  process.exit(planVerifyCommand(opts.dir, name, verdict2, { note: opts.note, at: opts.at }));
67843
67899
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.26.7",
3
+ "version": "0.26.8",
4
4
  "description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with an LLM-ranked HTML report.",
5
5
  "type": "module",
6
6
  "license": "MIT",