@decocms/parity 0.33.20 → 0.33.21
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 +110 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -57602,6 +57602,41 @@ async function getContentTypes(cfg, call = callCms) {
|
|
|
57602
57602
|
async function getSchemaMeta(cfg, call = callCms) {
|
|
57603
57603
|
return call(cfg, { path: `${SCHEMAS}/${cfg.account}.${cfg.store}` });
|
|
57604
57604
|
}
|
|
57605
|
+
var REGISTRY_BASE = "https://api.vtexcommercestable.com.br/api/content-platform/schemas";
|
|
57606
|
+
var callRegistry = async (cfg, path, init = {}) => {
|
|
57607
|
+
const method = init.method ?? "GET";
|
|
57608
|
+
const res = await fetch(`${REGISTRY_BASE}/${path}`, {
|
|
57609
|
+
method,
|
|
57610
|
+
headers: {
|
|
57611
|
+
authorization: `Bearer ${cfg.token}`,
|
|
57612
|
+
accept: "application/json",
|
|
57613
|
+
...init.body === undefined ? {} : { "content-type": "application/json" }
|
|
57614
|
+
},
|
|
57615
|
+
...init.body === undefined ? {} : { body: JSON.stringify(init.body) }
|
|
57616
|
+
});
|
|
57617
|
+
const text = await res.text().catch(() => "");
|
|
57618
|
+
if (!res.ok) {
|
|
57619
|
+
throw new Error(`${method} ${path}: HTTP ${res.status} ${text.slice(0, 300)}`);
|
|
57620
|
+
}
|
|
57621
|
+
return text ? JSON.parse(text) : {};
|
|
57622
|
+
};
|
|
57623
|
+
async function listSchemaVersions(cfg, call = callRegistry) {
|
|
57624
|
+
try {
|
|
57625
|
+
const rows = await call(cfg, `${cfg.account}.${cfg.store}/versions`);
|
|
57626
|
+
return Array.isArray(rows) ? rows : [];
|
|
57627
|
+
} catch (err) {
|
|
57628
|
+
if (err instanceof Error && /HTTP 404/.test(err.message))
|
|
57629
|
+
return [];
|
|
57630
|
+
throw err;
|
|
57631
|
+
}
|
|
57632
|
+
}
|
|
57633
|
+
async function publishSchema(cfg, schema, call = callRegistry) {
|
|
57634
|
+
const id = typeof schema.$id === "string" ? schema.$id : "";
|
|
57635
|
+
if (!id.includes("@")) {
|
|
57636
|
+
throw new Error("publishSchema: schema.$id must include an explicit version (account.store@1.0.0).");
|
|
57637
|
+
}
|
|
57638
|
+
await call(cfg, id, { method: "PUT", body: schema });
|
|
57639
|
+
}
|
|
57605
57640
|
|
|
57606
57641
|
// src/cms/authoring.ts
|
|
57607
57642
|
function unwrapValue(node) {
|
|
@@ -57881,6 +57916,22 @@ function propertyDrift(published, repoDir) {
|
|
|
57881
57916
|
}
|
|
57882
57917
|
return drift;
|
|
57883
57918
|
}
|
|
57919
|
+
var SEMVER = /^(\d+)\.(\d+)\.(\d+)$/;
|
|
57920
|
+
function suggestNextSchemaVersion(versions) {
|
|
57921
|
+
let best = null;
|
|
57922
|
+
for (const row of versions) {
|
|
57923
|
+
const parsed = typeof row.version === "string" ? SEMVER.exec(row.version.split("-")[0] ?? "") : null;
|
|
57924
|
+
const tuple = parsed ? { major: Number(parsed[1]), minor: Number(parsed[2]), patch: Number(parsed[3]) } : row.major !== undefined && row.minor !== undefined && row.patch !== undefined ? { major: row.major, minor: row.minor, patch: row.patch } : null;
|
|
57925
|
+
if (!tuple)
|
|
57926
|
+
continue;
|
|
57927
|
+
if (!best || tuple.major > best.major || tuple.major === best.major && tuple.minor > best.minor || tuple.major === best.major && tuple.minor === best.minor && tuple.patch > best.patch) {
|
|
57928
|
+
best = tuple;
|
|
57929
|
+
}
|
|
57930
|
+
}
|
|
57931
|
+
if (!best)
|
|
57932
|
+
return "1.0.0";
|
|
57933
|
+
return `${best.major}.${best.minor + 1}.0`;
|
|
57934
|
+
}
|
|
57884
57935
|
|
|
57885
57936
|
// src/commands/cms.ts
|
|
57886
57937
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -58013,6 +58064,57 @@ async function cmsDoctorCommand(opts, call = callCms) {
|
|
|
58013
58064
|
return fail(err);
|
|
58014
58065
|
}
|
|
58015
58066
|
}
|
|
58067
|
+
async function cmsSchemaPushCommand(opts, call = callCms, registryCall = callRegistry) {
|
|
58068
|
+
const cfg = config();
|
|
58069
|
+
if (!cfg)
|
|
58070
|
+
return 1;
|
|
58071
|
+
const schemaPath = join19(opts.repo, "cms", "faststore", "schema.json");
|
|
58072
|
+
if (!existsSync14(schemaPath)) {
|
|
58073
|
+
return fail(new Error(`No such file: ${schemaPath}. Generate it first (\`vtex content generate-schema\`).`));
|
|
58074
|
+
}
|
|
58075
|
+
let schema;
|
|
58076
|
+
try {
|
|
58077
|
+
schema = parseJsonc(readFileSync17(schemaPath, "utf8"));
|
|
58078
|
+
} catch (err) {
|
|
58079
|
+
return fail(new Error(`${schemaPath} is not valid JSON: ${err instanceof Error ? err.message : err}`));
|
|
58080
|
+
}
|
|
58081
|
+
try {
|
|
58082
|
+
const baseSchemaId = `${cfg.account}.${cfg.store}`;
|
|
58083
|
+
const [types, versions] = await Promise.all([
|
|
58084
|
+
getContentTypes(cfg, call),
|
|
58085
|
+
listSchemaVersions(cfg, registryCall)
|
|
58086
|
+
]);
|
|
58087
|
+
const drift = schemaDrift(types, opts.repo);
|
|
58088
|
+
const propDrift = propertyDrift(types, opts.repo);
|
|
58089
|
+
const version = opts.version ?? suggestNextSchemaVersion(versions);
|
|
58090
|
+
const targetId = `${baseSchemaId}@${version}`;
|
|
58091
|
+
if (opts.json) {
|
|
58092
|
+
console.log(JSON.stringify({ targetId, drift, propDrift }, null, 2));
|
|
58093
|
+
} else {
|
|
58094
|
+
console.log(chalk7.dim(` target: ${targetId}`));
|
|
58095
|
+
for (const d of drift.filter((x) => x.missingOnAccount.length > 0)) {
|
|
58096
|
+
console.log(` + ${d.contentType}: ${d.missingOnAccount.join(", ")}`);
|
|
58097
|
+
}
|
|
58098
|
+
for (const d of propDrift) {
|
|
58099
|
+
if (d.missingProps.length > 0)
|
|
58100
|
+
console.log(` + ${d.contentType}: ${d.componentKey} — ${d.missingProps.join(", ")}`);
|
|
58101
|
+
}
|
|
58102
|
+
if (drift.every((x) => x.missingOnAccount.length === 0) && propDrift.length === 0) {
|
|
58103
|
+
console.log(chalk7.dim(" no drift found by doctor's own check — uploading anyway publishes this exact schema as a new version"));
|
|
58104
|
+
}
|
|
58105
|
+
}
|
|
58106
|
+
if (!opts.yes) {
|
|
58107
|
+
console.log(chalk7.yellow("dry run — nothing uploaded. Pass --yes to publish."));
|
|
58108
|
+
return 0;
|
|
58109
|
+
}
|
|
58110
|
+
schema.$id = targetId;
|
|
58111
|
+
await publishSchema(cfg, schema, registryCall);
|
|
58112
|
+
console.log(`${chalk7.green("✓")} published ${targetId}`);
|
|
58113
|
+
return 0;
|
|
58114
|
+
} catch (err) {
|
|
58115
|
+
return fail(err);
|
|
58116
|
+
}
|
|
58117
|
+
}
|
|
58016
58118
|
async function cmsLsCommand(opts, call = callCms) {
|
|
58017
58119
|
const cfg = config();
|
|
58018
58120
|
if (!cfg)
|
|
@@ -70872,7 +70974,14 @@ program.command("plan").description("Inspect/update the migration-plan.json comp
|
|
|
70872
70974
|
}));
|
|
70873
70975
|
program.command("cms").description("Read and write VTEX Content Platform entries — the CMS behind FastStore v4. Every write is a commit on a branch carrying the baseHash it was read at, so a concurrent edit fails the commit instead of silently winning. Needs PARITY_CMS_ACCOUNT + PARITY_CMS_STORE and a `vtex login` session (or PARITY_CMS_TOKEN).").addCommand(new Command("doctor").description("Compare the sections the repo declares against the ones published on the account. A section that exists in code but was never uploaded commits fine and renders nothing — this is the check that catches it.").option("--repo <path>", "Repo holding cms/faststore/pages/", ".").option("--json", "Emit structured JSON instead of human-readable text", false).action(async (opts) => {
|
|
70874
70976
|
process.exit(await cmsDoctorCommand({ repo: opts.repo, json: Boolean(opts.json) }));
|
|
70875
|
-
})).addCommand(new Command("
|
|
70977
|
+
})).addCommand(new Command("schema").description("Manage the published schema registry.").addCommand(new Command("push").description("Upload cms/faststore/schema.json to the registry as a new version. Dry run unless --yes; never deletes the local file.").option("--repo <path>", "Repo holding cms/faststore/schema.json", ".").option("--version <semver>", "Version to publish (default: next minor bump)").option("--yes", "Actually publish. Without it, this is a dry run.", false).option("--json", "Emit structured JSON instead of human-readable text", false).action(async (opts) => {
|
|
70978
|
+
process.exit(await cmsSchemaPushCommand({
|
|
70979
|
+
repo: opts.repo,
|
|
70980
|
+
version: opts.version,
|
|
70981
|
+
yes: Boolean(opts.yes),
|
|
70982
|
+
json: Boolean(opts.json)
|
|
70983
|
+
}));
|
|
70984
|
+
}))).addCommand(new Command("ls").description("List entries, or branches with --branches. Branch ids are what every write needs.").option("--content-type <name>", "Filter by content type (home, landingPage, plp, ...)").option("--branches", "List branches instead of entries", false).option("--json", "Emit structured JSON instead of human-readable text", false).action(async (opts) => {
|
|
70876
70985
|
process.exit(await cmsLsCommand({
|
|
70877
70986
|
contentType: opts.contentType,
|
|
70878
70987
|
branches: Boolean(opts.branches),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/parity",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.21",
|
|
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",
|