@decocms/parity 0.33.17 → 0.33.19

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 +46 -3
  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) {
@@ -57662,6 +57665,7 @@ function localeSwitch(value) {
57662
57665
  }
57663
57666
 
57664
57667
  // src/cms/session.ts
57668
+ import { execFileSync } from "node:child_process";
57665
57669
  import { existsSync as existsSync12, readFileSync as readFileSync15 } from "node:fs";
57666
57670
  import { homedir as homedir3 } from "node:os";
57667
57671
  import { delimiter, join as join17 } from "node:path";
@@ -57700,6 +57704,26 @@ function vtexCliInstalled(env = process.env) {
57700
57704
  const dirs = (env.PATH ?? "").split(delimiter).filter(Boolean);
57701
57705
  return dirs.some((dir) => existsSync12(join17(dir, "vtex")));
57702
57706
  }
57707
+ function vtexContentPluginAdvice(run = (cmd, args) => execFileSync(cmd, args, { stdio: "pipe" })) {
57708
+ try {
57709
+ run("vtex", ["content", "--help"]);
57710
+ return null;
57711
+ } catch (err) {
57712
+ const output = [
57713
+ err?.stdout,
57714
+ err?.stderr,
57715
+ err instanceof Error ? err.message : ""
57716
+ ].map((v) => v?.toString() ?? "").join(`
57717
+ `);
57718
+ if (!/Cannot find module ['"]vtex['"]/.test(output))
57719
+ return null;
57720
+ return [
57721
+ "`vtex content` cannot load — the content plugin resolves `vtex` from the wrong node_modules root (breaks under nvm-managed installs).",
57722
+ ' ln -sfn "$(npm root -g)/vtex" ~/.local/share/vtex/node_modules/vtex'
57723
+ ].join(`
57724
+ `);
57725
+ }
57726
+ }
57703
57727
  function sessionState(expectedAccount, env = process.env, home = homedir3(), now = Date.now()) {
57704
57728
  if (env.PARITY_CMS_TOKEN)
57705
57729
  return { status: "env-token" };
@@ -57921,17 +57945,36 @@ async function cmsDoctorCommand(opts, call = callCms) {
57921
57945
  if (!cfg)
57922
57946
  return 1;
57923
57947
  const session = describeSession(sessionState(process.env.PARITY_CMS_ACCOUNT));
57948
+ const pluginAdvice = vtexContentPluginAdvice();
57924
57949
  try {
57950
+ const entries = await listEntries(cfg, {}, call);
57951
+ const storesInUse = [...new Set(entries.map((e) => e.storeId).filter(Boolean))];
57952
+ 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;
57953
+ const schema = await getSchemaMeta(cfg, call).catch(() => null);
57925
57954
  const types = await getContentTypes(cfg, call);
57926
57955
  const drift = schemaDrift(types, opts.repo);
57927
57956
  const propDrift = propertyDrift(types, opts.repo);
57928
57957
  const blockingProps = propDrift.filter((d) => d.missingProps.length > 0);
57929
57958
  if (opts.json) {
57930
- console.log(JSON.stringify({ session, contentTypes: Object.keys(types), drift, propDrift }, null, 2));
57931
- return drift.some((d) => d.missingOnAccount.length > 0) || blockingProps.length > 0 ? 1 : 0;
57959
+ console.log(JSON.stringify({
57960
+ session,
57961
+ contentPlugin: pluginAdvice,
57962
+ storeMismatch,
57963
+ schemaId: schema?.$id ?? null,
57964
+ contentTypes: Object.keys(types),
57965
+ drift,
57966
+ propDrift
57967
+ }, null, 2));
57968
+ return drift.some((d) => d.missingOnAccount.length > 0) || blockingProps.length > 0 || Boolean(storeMismatch) ? 1 : 0;
57932
57969
  }
57933
57970
  if (session)
57934
57971
  console.log(`${chalk7.green("✓")} ${session}`);
57972
+ if (pluginAdvice)
57973
+ console.log(`${chalk7.yellow("!")} ${pluginAdvice}`);
57974
+ if (storeMismatch)
57975
+ console.log(`${chalk7.red("✗")} ${storeMismatch}`);
57976
+ if (schema?.$id)
57977
+ console.log(chalk7.dim(` published schema: ${schema.$id}`));
57935
57978
  const blocking = drift.filter((d) => d.missingOnAccount.length > 0);
57936
57979
  if (blocking.length === 0 && propDrift.length === 0) {
57937
57980
  console.log(`${chalk7.green("✓")} every section the repo declares is published on the account`);
@@ -57950,7 +57993,7 @@ async function cmsDoctorCommand(opts, call = callCms) {
57950
57993
  for (const d of drift.filter((x) => x.missingInRepo.length > 0)) {
57951
57994
  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)")}`);
57952
57995
  }
57953
- return blocking.length > 0 || blockingProps.length > 0 ? 1 : 0;
57996
+ return blocking.length > 0 || blockingProps.length > 0 || Boolean(storeMismatch) ? 1 : 0;
57954
57997
  } catch (err) {
57955
57998
  return fail(err);
57956
57999
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.33.17",
3
+ "version": "0.33.19",
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",