@decocms/parity 0.33.15 → 0.33.16
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 +78 -9
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -57812,6 +57812,13 @@ function fail(err) {
|
|
|
57812
57812
|
console.error(chalk7.red(err instanceof Error ? err.message : String(err)));
|
|
57813
57813
|
return 1;
|
|
57814
57814
|
}
|
|
57815
|
+
function writeBackup(version) {
|
|
57816
|
+
const backup = join19("parity-output", "cms-backups", `${version.entryId}-${version.baseHash.slice(0, 12)}.json`);
|
|
57817
|
+
mkdirSync9(dirname4(backup), { recursive: true });
|
|
57818
|
+
writeFileSync13(backup, `${JSON.stringify(version, null, 2)}
|
|
57819
|
+
`);
|
|
57820
|
+
return backup;
|
|
57821
|
+
}
|
|
57815
57822
|
function resolveAuthor(explicit) {
|
|
57816
57823
|
const author = explicit ?? readVtexSession()?.login;
|
|
57817
57824
|
if (!author) {
|
|
@@ -58002,10 +58009,7 @@ async function cmsPushCommand(opts, call = callCms) {
|
|
|
58002
58009
|
const author = resolveAuthor(opts.author);
|
|
58003
58010
|
if (author instanceof Error)
|
|
58004
58011
|
return fail(author);
|
|
58005
|
-
const backup =
|
|
58006
|
-
mkdirSync9(dirname4(backup), { recursive: true });
|
|
58007
|
-
writeFileSync13(backup, `${JSON.stringify(remote, null, 2)}
|
|
58008
|
-
`);
|
|
58012
|
+
const backup = writeBackup(remote);
|
|
58009
58013
|
const commit = await commitEntry(cfg, {
|
|
58010
58014
|
branchId: branch,
|
|
58011
58015
|
contentTypeId: local.contentType,
|
|
@@ -58023,13 +58027,57 @@ async function cmsPushCommand(opts, call = callCms) {
|
|
|
58023
58027
|
return 0;
|
|
58024
58028
|
}
|
|
58025
58029
|
console.log(`${chalk7.green("✓")} commit ${commit.id} on ${branch}`);
|
|
58026
|
-
console.log(chalk7.dim(` rollback: parity cms
|
|
58030
|
+
console.log(chalk7.dim(` rollback: parity cms restore --file ${backup} --branch ${branch}${branch === "main" ? " --allow-main" : ""} --yes`));
|
|
58027
58031
|
console.log(chalk7.dim(` backup: ${backup}`));
|
|
58028
58032
|
return 0;
|
|
58029
58033
|
} catch (err) {
|
|
58030
58034
|
return fail(err);
|
|
58031
58035
|
}
|
|
58032
58036
|
}
|
|
58037
|
+
async function cmsRestoreCommand(opts, call = callCms) {
|
|
58038
|
+
const cfg = config();
|
|
58039
|
+
if (!cfg)
|
|
58040
|
+
return 1;
|
|
58041
|
+
const backup = readPulled(opts.file);
|
|
58042
|
+
if (backup instanceof Error)
|
|
58043
|
+
return fail(backup);
|
|
58044
|
+
const branch = resolveBranch(opts.branch ?? backup.branchId, Boolean(opts.allowMain));
|
|
58045
|
+
if (branch instanceof Error)
|
|
58046
|
+
return fail(branch);
|
|
58047
|
+
try {
|
|
58048
|
+
const head = await getLastVersion(cfg, { contentType: backup.contentType, entryId: backup.entryId, branchId: branch }, call);
|
|
58049
|
+
if (!opts.yes) {
|
|
58050
|
+
console.log(chalk7.yellow("dry run — nothing written. Pass --yes to restore."));
|
|
58051
|
+
for (const line of summarizeSections(backup.data))
|
|
58052
|
+
console.log(` ${line}`);
|
|
58053
|
+
console.log(chalk7.dim(` branch ${branch} · entry ${backup.entryId} · ${backup.contentType}`));
|
|
58054
|
+
return 0;
|
|
58055
|
+
}
|
|
58056
|
+
const author = resolveAuthor(opts.author);
|
|
58057
|
+
if (author instanceof Error)
|
|
58058
|
+
return fail(author);
|
|
58059
|
+
const commit = await commitEntry(cfg, {
|
|
58060
|
+
branchId: branch,
|
|
58061
|
+
contentTypeId: backup.contentType,
|
|
58062
|
+
entryId: backup.entryId,
|
|
58063
|
+
entryName: backup.entryName,
|
|
58064
|
+
baseHash: head.baseHash,
|
|
58065
|
+
data: backup.data,
|
|
58066
|
+
message: opts.message ?? `parity cms restore ${opts.file}`,
|
|
58067
|
+
author,
|
|
58068
|
+
identifierKeys: backup.identifierKeys,
|
|
58069
|
+
searchKeywords: backup.searchKeywords
|
|
58070
|
+
}, call);
|
|
58071
|
+
if (opts.json) {
|
|
58072
|
+
console.log(JSON.stringify({ commit }, null, 2));
|
|
58073
|
+
return 0;
|
|
58074
|
+
}
|
|
58075
|
+
console.log(`${chalk7.green("✓")} ${backup.entryId} restored from ${opts.file}, commit ${commit.id} on ${branch}`);
|
|
58076
|
+
return 0;
|
|
58077
|
+
} catch (err) {
|
|
58078
|
+
return fail(err);
|
|
58079
|
+
}
|
|
58080
|
+
}
|
|
58033
58081
|
async function cmsUndoCommand(opts, call = callCms) {
|
|
58034
58082
|
const cfg = config();
|
|
58035
58083
|
if (!cfg)
|
|
@@ -58038,12 +58086,21 @@ async function cmsUndoCommand(opts, call = callCms) {
|
|
|
58038
58086
|
if (branch instanceof Error)
|
|
58039
58087
|
return fail(branch);
|
|
58040
58088
|
if (!opts.yes) {
|
|
58041
|
-
console.log(chalk7.yellow(`dry run —
|
|
58089
|
+
console.log(chalk7.yellow(`dry run — this DELETES ${opts.entry} (every version, this branch and any other) rather than reverting it. Pass --allow-delete --yes to actually run it.`));
|
|
58042
58090
|
return 0;
|
|
58043
58091
|
}
|
|
58092
|
+
if (!opts.allowDelete) {
|
|
58093
|
+
return fail(new Error("cms undo destroys the entry, it does not revert it — pass --allow-delete to confirm, or use `parity cms restore` for a non-destructive rollback."));
|
|
58094
|
+
}
|
|
58044
58095
|
try {
|
|
58096
|
+
const contentType = opts.contentType ?? (await listEntries(cfg, {}, call)).find((e) => e.id === opts.entry)?.contentTypeId;
|
|
58097
|
+
if (contentType) {
|
|
58098
|
+
const current = await getLastVersion(cfg, { contentType, entryId: opts.entry, branchId: branch }, call).catch(() => null);
|
|
58099
|
+
if (current)
|
|
58100
|
+
console.log(chalk7.dim(` backup: ${writeBackup(current)}`));
|
|
58101
|
+
}
|
|
58045
58102
|
await undoEntry(cfg, { branchId: branch, entryId: opts.entry }, call);
|
|
58046
|
-
console.log(`${chalk7.green("✓")} ${opts.entry}
|
|
58103
|
+
console.log(`${chalk7.green("✓")} ${opts.entry} deleted on ${branch}`);
|
|
58047
58104
|
return 0;
|
|
58048
58105
|
} catch (err) {
|
|
58049
58106
|
return fail(err);
|
|
@@ -70707,12 +70764,24 @@ program.command("cms").description("Read and write VTEX Content Platform entries
|
|
|
70707
70764
|
}));
|
|
70708
70765
|
})).addCommand(new Command("rm").description("Destroy an entry and every version of it, on every branch. Dry run unless --yes.").requiredOption("--entry <id>", "Entry id").option("--yes", "Actually delete. Without it, this is a dry run.", false).action(async (opts) => {
|
|
70709
70766
|
process.exit(await cmsRmCommand({ entry: opts.entry, yes: Boolean(opts.yes) }));
|
|
70710
|
-
})).addCommand(new Command("undo").description("
|
|
70767
|
+
})).addCommand(new Command("undo").description("Delete an entry outright via the platform's `undo` endpoint — NOT a revert, since an entry with one version (every entry `create` makes) has nothing to drop but itself. Use `restore` for a non-destructive rollback. Dry run unless --yes and --allow-delete.").requiredOption("--entry <id>", "Entry id").requiredOption("--branch <id>", "Branch id").option("--content-type <name>", "Skip the entry lookup used to back it up before deleting").option("--yes", "Actually delete. Without it, this is a dry run.", false).option("--allow-main", "Permit deleting on main", false).option("--allow-delete", "Confirm this destroys the entry, it does not revert it", false).action(async (opts) => {
|
|
70711
70768
|
process.exit(await cmsUndoCommand({
|
|
70712
70769
|
entry: opts.entry,
|
|
70713
70770
|
branch: opts.branch,
|
|
70771
|
+
contentType: opts.contentType,
|
|
70772
|
+
yes: Boolean(opts.yes),
|
|
70773
|
+
allowMain: Boolean(opts.allowMain),
|
|
70774
|
+
allowDelete: Boolean(opts.allowDelete)
|
|
70775
|
+
}));
|
|
70776
|
+
})).addCommand(new Command("restore").description("Re-commit a backup file (from `push` or `undo`, in parity-output/cms-backups/) against the entry's current head — the actual non-destructive rollback. Dry run unless --yes.").requiredOption("--file <path>", "Backup file written by `push` or `undo`").option("--branch <id>", "Target branch (default: the branch in the file)").option("--message <text>", "Commit message").option("--author <email>", "Commit author (default: the logged-in VTEX user)").option("--yes", "Actually write. Without it, this is a dry run.", false).option("--allow-main", "Permit committing straight to main", false).option("--json", "Emit structured JSON instead of human-readable text", false).action(async (opts) => {
|
|
70777
|
+
process.exit(await cmsRestoreCommand({
|
|
70778
|
+
file: opts.file,
|
|
70779
|
+
branch: opts.branch,
|
|
70780
|
+
message: opts.message,
|
|
70781
|
+
author: opts.author,
|
|
70714
70782
|
yes: Boolean(opts.yes),
|
|
70715
|
-
allowMain: Boolean(opts.allowMain)
|
|
70783
|
+
allowMain: Boolean(opts.allowMain),
|
|
70784
|
+
json: Boolean(opts.json)
|
|
70716
70785
|
}));
|
|
70717
70786
|
}));
|
|
70718
70787
|
program.command("serve").argument("<runId>", "Run ID to serve").description("Spawns a local HTTP server that serves the report and proxies external iframes (strips X-Frame-Options/CSP), making the Side-by-side tab functional for any site.").option("--output <dir>", "Output directory where runs live", "./parity-output").option("--port <n>", "Fixed port (default: auto-pick free port)", (v) => Number(v)).option("--no-open", "Don't open the browser automatically").action(async (runId, opts) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/parity",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.16",
|
|
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",
|