@decocms/parity 0.33.18 → 0.33.20

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 +43 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -57599,6 +57599,9 @@ async function getContentTypes(cfg, call = callCms) {
57599
57599
  path: `${SCHEMAS}/${cfg.account}.${cfg.store}/content-types`
57600
57600
  });
57601
57601
  }
57602
+ async function getSchemaMeta(cfg, call = callCms) {
57603
+ return call(cfg, { path: `${SCHEMAS}/${cfg.account}.${cfg.store}` });
57604
+ }
57602
57605
 
57603
57606
  // src/cms/authoring.ts
57604
57607
  function unwrapValue(node) {
@@ -57916,6 +57919,21 @@ function writeBackup(version) {
57916
57919
  `);
57917
57920
  return backup;
57918
57921
  }
57922
+ function richTextCombinationRisk(usedKeys) {
57923
+ if (usedKeys.includes("RichText") && usedKeys.length > 1) {
57924
+ return "sections include RichText alongside another section — that combination is known to answer VALIDATION_ERROR on some accounts (see #348). If the commit below fails with an unexplained VALIDATION_ERROR, this is the first thing to bisect.";
57925
+ }
57926
+ return null;
57927
+ }
57928
+ function explainCommitError(err, usedKeys) {
57929
+ if (!(err instanceof Error) || !err.message.includes("VALIDATION_ERROR"))
57930
+ return err;
57931
+ const risk = richTextCombinationRisk(usedKeys);
57932
+ if (!risk)
57933
+ return err;
57934
+ return new Error(`${err.message}
57935
+ ${risk}`);
57936
+ }
57919
57937
  function resolveAuthor(explicit) {
57920
57938
  const author = explicit ?? readVtexSession()?.login;
57921
57939
  if (!author) {
@@ -57944,18 +57962,34 @@ async function cmsDoctorCommand(opts, call = callCms) {
57944
57962
  const session = describeSession(sessionState(process.env.PARITY_CMS_ACCOUNT));
57945
57963
  const pluginAdvice = vtexContentPluginAdvice();
57946
57964
  try {
57965
+ const entries = await listEntries(cfg, {}, call);
57966
+ const storesInUse = [...new Set(entries.map((e) => e.storeId).filter(Boolean))];
57967
+ const storeMismatch = storesInUse.length > 0 && !storesInUse.includes(cfg.store) ? `PARITY_CMS_STORE is "${cfg.store}", but entries on this account use ${storesInUse.map((s) => `"${s}"`).join(", ")}. A wrong store id answers 200 with empty results instead of an error.` : null;
57968
+ const schema = await getSchemaMeta(cfg, call).catch(() => null);
57947
57969
  const types = await getContentTypes(cfg, call);
57948
57970
  const drift = schemaDrift(types, opts.repo);
57949
57971
  const propDrift = propertyDrift(types, opts.repo);
57950
57972
  const blockingProps = propDrift.filter((d) => d.missingProps.length > 0);
57951
57973
  if (opts.json) {
57952
- console.log(JSON.stringify({ session, contentPlugin: pluginAdvice, contentTypes: Object.keys(types), drift, propDrift }, null, 2));
57953
- return drift.some((d) => d.missingOnAccount.length > 0) || blockingProps.length > 0 ? 1 : 0;
57974
+ console.log(JSON.stringify({
57975
+ session,
57976
+ contentPlugin: pluginAdvice,
57977
+ storeMismatch,
57978
+ schemaId: schema?.$id ?? null,
57979
+ contentTypes: Object.keys(types),
57980
+ drift,
57981
+ propDrift
57982
+ }, null, 2));
57983
+ return drift.some((d) => d.missingOnAccount.length > 0) || blockingProps.length > 0 || Boolean(storeMismatch) ? 1 : 0;
57954
57984
  }
57955
57985
  if (session)
57956
57986
  console.log(`${chalk7.green("✓")} ${session}`);
57957
57987
  if (pluginAdvice)
57958
57988
  console.log(`${chalk7.yellow("!")} ${pluginAdvice}`);
57989
+ if (storeMismatch)
57990
+ console.log(`${chalk7.red("✗")} ${storeMismatch}`);
57991
+ if (schema?.$id)
57992
+ console.log(chalk7.dim(` published schema: ${schema.$id}`));
57959
57993
  const blocking = drift.filter((d) => d.missingOnAccount.length > 0);
57960
57994
  if (blocking.length === 0 && propDrift.length === 0) {
57961
57995
  console.log(`${chalk7.green("✓")} every section the repo declares is published on the account`);
@@ -57974,7 +58008,7 @@ async function cmsDoctorCommand(opts, call = callCms) {
57974
58008
  for (const d of drift.filter((x) => x.missingInRepo.length > 0)) {
57975
58009
  console.log(`${chalk7.gray("·")} ${d.contentType}: ${d.missingInRepo.length} section(s) published but not in the repo ${chalk7.dim("(usually core components the repo never overrode)")}`);
57976
58010
  }
57977
- return blocking.length > 0 || blockingProps.length > 0 ? 1 : 0;
58011
+ return blocking.length > 0 || blockingProps.length > 0 || Boolean(storeMismatch) ? 1 : 0;
57978
58012
  } catch (err) {
57979
58013
  return fail(err);
57980
58014
  }
@@ -58109,6 +58143,9 @@ async function cmsPushCommand(opts, call = callCms) {
58109
58143
  if (remote.baseHash !== local.baseHash) {
58110
58144
  return fail(new Error(`Stale: pulled at ${local.baseHash.slice(0, 12)}, remote is at ${remote.baseHash.slice(0, 12)}. Pull again.`));
58111
58145
  }
58146
+ const richTextRisk = richTextCombinationRisk(used);
58147
+ if (richTextRisk)
58148
+ console.log(`${chalk7.yellow("!")} ${richTextRisk}`);
58112
58149
  if (!opts.yes) {
58113
58150
  console.log(chalk7.yellow("dry run — nothing written. Pass --yes to commit."));
58114
58151
  for (const line of summarizeSections(local.data))
@@ -58131,7 +58168,9 @@ async function cmsPushCommand(opts, call = callCms) {
58131
58168
  author,
58132
58169
  identifierKeys: local.identifierKeys,
58133
58170
  searchKeywords: local.searchKeywords
58134
- }, call);
58171
+ }, call).catch((err) => {
58172
+ throw explainCommitError(err, used);
58173
+ });
58135
58174
  if (opts.json) {
58136
58175
  console.log(JSON.stringify({ commit, backup }, null, 2));
58137
58176
  return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.33.18",
3
+ "version": "0.33.20",
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",