feat(cli): add schema diff command with unified diff model - #667
Draft
maoberlehner wants to merge 6 commits into
Draft
feat(cli): add schema diff command with unified diff model#667maoberlehner wants to merge 6 commits into
maoberlehner wants to merge 6 commits into
Conversation
@storyblok/angular
@storyblok/astro
@storyblok/api-client
storyblok
@storyblok/experiments
@storyblok/js
storyblok-js-client
@storyblok/lint-config
@storyblok/live-preview
@storyblok/management-api-client
@storyblok/migrations
@storyblok/nuxt
@storyblok/react
@storyblok/region-helper
@storyblok/richtext
@storyblok/schema
@storyblok/svelte
@storyblok/vue
commit: |
maoberlehner
force-pushed
the
feat/WDX-469-schema-diff
branch
from
July 3, 2026 08:09
5c9a05b to
6ce183b
Compare
maoberlehner
force-pushed
the
feat/WDX-469-schema-diff
branch
from
July 3, 2026 08:10
6ce183b to
8ea7a9a
Compare
maoberlehner
force-pushed
the
feat/WDX-469-schema-diff
branch
from
July 8, 2026 12:38
8ea7a9a to
da527bd
Compare
maoberlehner
force-pushed
the
feat/WDX-469-schema-diff
branch
from
July 8, 2026 12:40
da527bd to
ee67e5f
Compare
maoberlehner
force-pushed
the
feat/WDX-469-schema-diff
branch
from
July 14, 2026 14:35
ee67e5f to
188567f
Compare
maoberlehner
force-pushed
the
alpha
branch
2 times, most recently
from
July 15, 2026 09:59
41afe89 to
0c36a25
Compare
maoberlehner
force-pushed
the
feat/WDX-469-schema-diff
branch
from
July 15, 2026 10:07
188567f to
af418c6
Compare
maoberlehner
force-pushed
the
feat/WDX-469-schema-diff
branch
from
July 17, 2026 06:53
af418c6 to
20758fe
Compare
maoberlehner
force-pushed
the
alpha
branch
4 times, most recently
from
July 21, 2026 11:34
060355b to
9f030c6
Compare
maoberlehner
force-pushed
the
feat/WDX-469-schema-diff
branch
from
August 11, 2026 10:22
20758fe to
195dee2
Compare
Add `storyblok schema diff --from <spaceId|file> --to <spaceId|file>`,
exposing the classification `schema push` computes internally as a
read-only command. Each side auto-resolves a numeric space ID (fetched
remotely) or a file path (loaded via jiti); authentication is required
only when a side is a space.
Unify the diff into a single structured model shared by both commands.
`diffSchema` is now symmetric over a NormalizedSchema (name-keyed maps)
and every EntityDiff carries field-level FieldChange[] (added/removed/
modified with before/after) plus raw before/after snapshots, replacing
the old text patch. `push` renders from this model via the shared
renderFieldChanges helper. Shared modules (diff-schema, load-schema)
move to the parent schema/ directory per the no-sibling-imports rule.
Human stdio is the default; the machine-readable diff rides the existing
reporter (addMeta('diff', ...) + addSummary), gated by --report-enabled,
so downstream space-to-space tooling reads meta.diff.
Fixes WDX-469
…formatter Address review findings on the schema diff command. - diffSchema now takes an explicit compareGroupUuid option (default false). Component group UUIDs are per-space identifiers, so comparing two spaces flagged every grouped block as changed with a spurious component_group_uuid diff that also polluted meta.diff. push opts in (target is the local DSL); the diff command only opts in for file-to-file comparisons. - Extract a shared formatDiff renderer taking label sets so schema push and schema diff share one layout instead of duplicating the scaffold. - Omit unchanged entities from the diff command's terminal output (kept in the summary count and meta.diff) to keep space-to-space comparisons readable. Fixes WDX-469
… listing Address QA follow-ups on the schema diff command. - resolveSource now names the failing side (--from/--to) and whether it was a file or space, so opaque "Cannot find module" / "Not Found" errors become actionable. The file-side hint also covers the module-resolution expectation (run it where the schema package is installed). - reports list no longer prints space "undefined" when invoked without --space; it drops the space clause and surfaces space-less reports (e.g. file-to-file schema diff) from the base reports directory. - Document the machine-readable meta.diff enums in the diff README, since the entity action vocabulary (create/update/stale/unchanged) differs from the human wording (added/changed/removed). Fixes WDX-469
…nsion Reports are written as .json (the reporter default), but reports list and reports prune passed .jsonl (the logger extension), so both matched nothing: list always reported no files and prune deleted none, for every space. Drop the explicit .jsonl argument so both fall back to the reporter's .json default, and correct the test fixtures from .jsonl to .json so the tests exercise the real code path instead of passing against the wrong extension.
Rebase fallout: main moved the CLI's UI module from src/utils/ui to src/lib/ui and routes ui.info through console.error, and this branch moved load-schema up to the schema command directory. - schema diff imports getUI from ../../../lib/ui, which unblocks the build - the reports list assertions target console.error, the stream ui.info writes to - the schema push test imports load-schema from ../load-schema
maoberlehner
force-pushed
the
feat/WDX-469-schema-diff
branch
from
August 11, 2026 10:45
195dee2 to
fb4e12d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
storyblok schema diff --from <spaceId|file> --to <spaceId|file>, a read-only command that exposes the schema classificationschema pushcomputes internally. Each side auto-resolves a numeric space ID (fetched remotely) or a file path (loaded via jiti); authentication is required only when a side is a space.The driving use case is translating schema changes between spaces: compute what changed, then run downstream operations from that diff.
How
diffSchemais now symmetric over a newNormalizedSchema(name-keyed maps) that both a space and a local file resolve to. EveryEntityDiffcarries field-levelFieldChange[](added/removed/modified with before/after) plus raw before/after snapshots, replacing the old text patch. This single model backs bothpushand the new command.pushrenders from the structured model.formatDiffOutputuses the sharedrenderFieldChangeshelper instead ofcreateTwoFilesPatch; push wording and behavior are preserved. Thecreate|update|unchanged|staleaction vocabulary is kept internally somigrations/analyze.tsand changeset code need no change.diff-schema.tsandload-schema.tsmove frompush/up to the parentschema/directory.cleanComponent/cleanDatasourceare extracted inserialize.tsso diffing reuses the exact push normalization.--to, with per-entity field changes). The full structured diff rides the existing reporter viaaddMeta('diff', ...)+addSummary, gated by the global--report-enabledflag, so downstream space-to-space tooling readsmeta.diff. No bespoke--format/--outputflags.Testing
diffSchema(create/update/unchanged/stale + field-change added/removed/modified, defaults, group escape hatch),isSpaceRef,buildDiffReport,formatSchemaDiff.schema diffspace↔space, file↔space, and themeta.diffreport payload.push/migrations tests remain green (guards theformatDiffOutputrefactor).pnpm run test:types,pnpm run lint:fix, and fullvitest runall pass.Fixes WDX-469