Skip to content

Add sc theme diff to preview local-vs-server theme changes#5

Closed
mikel wants to merge 1 commit into
feature/theme-assets-and-changesfrom
feature/theme-diff
Closed

Add sc theme diff to preview local-vs-server theme changes#5
mikel wants to merge 1 commit into
feature/theme-assets-and-changesfrom
feature/theme-diff

Conversation

@mikel

@mikel mikel commented Jun 15, 2026

Copy link
Copy Markdown

Dependencies & PR Stack

This is a chain of PRs on the CLI:

develop
└ feature/content-api-alignment (#3)
  └ feature/theme-assets-and-changes (#4)
    └ feature/theme-diff (#5) (this PR)

Server side (core-gem): consumes the Store Management REST API from the gem chain, https://github.com/GetStoreConnect/core-gem/pull/8062 through #8072.


Summary

Stacked on #4. Adds sc theme diff THEME — the read-only sibling of sc theme push. It shows how a local theme diverges from the server's copy (templates and asset binaries) without pushing anything.

Two audiences:

  • Interactive: "what would sc theme push actually change?" before pushing.
  • CI / automation: --exit-code exits 9 on any difference, so a pipeline can gate on a committed theme being in sync with what's deployed:
    sc theme diff my-theme --exit-code || echo "theme has undeployed changes"
    Exit 9 is distinct from the error codes (auth/not-found/etc.), so automation can tell drift from a genuine failure.

How it works

  • Reuses the SHA-256 asset-hash contract from Sync theme asset binaries and list content changes #4 (ReadLocalAssets + the hash the server returns on GET /themes/:id), so an unchanged binary is never flagged — the diff matches exactly what push would upload.
  • Templates compared by key (content differs → modified); assets by key + hash. Local-only = added (+), both-differ = modified (~), server-only = removed (-).
  • The summary distinguishes to push (added + modified) from only on server (removed) — push never deletes server content, so that distinction is honest about what a subsequent push would and wouldn't reconcile.

Output

  • Human: colour-coded +/~/- grouped by templates/assets, or "in sync" when clean.
  • --json: {templates:{added,modified,removed}, assets:{...}, has_changes, pushable, server_only}.

Tests

ComputeDiff is a pure function with table-test coverage (added/modified/removed × templates + assets, in-sync, empty-server, count roll-ups). Full make test green; gofmt and go vet clean. (golangci-lint runs in CI.)

The read-only sibling of `sc theme push`: it reports which templates and
asset binaries have been added, modified, or only exist on the server,
without pushing anything. Reuses the same SHA-256 asset-hash contract as
push, so an unchanged binary is never flagged.

`--exit-code` exits 9 on any difference, so CI can gate on a committed
theme being in sync with what is deployed. Exit 9 is distinct from the
error codes so automation can tell drift from a genuine failure.

ComputeDiff is a pure function with full table-test coverage.
@mikel

mikel commented Jun 22, 2026

Copy link
Copy Markdown
Author

Superseded by #6 — the CLI agent-platform work collapsed into one PR off develop. Reopen if anything was missed.

@mikel mikel closed this Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant