feat(tpagectl): add diff command #626

Merged
fuzzy merged 1 commit from feat/tpagectl-diff into main 2026-08-10 08:06:38 +00:00
Owner

What

Implements Phase 10 diff command (roadmap #313).

  • New internal/tpagectl/siteconfig — defines the declared site-config document (SiteConfig{Name, Owner, Visibility, CustomDomain, PreviewEnabled}, YAML/JSON). This is the format the future export command will write, so diff and export interop.
  • New internal/tpagectl/difftpagectl diff SITE:
    • #311 — compare declared vs actual — reads <SITE>.yaml (or --file), fetches GET /api/v1/sites/{name}, and compares visibility, custom_domain, preview_enabled, name, owner.
    • #312 — show drift — prints per-field field: declared -> actual lines (empty → -), mirroring the site update diff style; Site "…" is in sync. when clean; a 404 is reported as drift (site not deployed on the daemon).
    • --exit-code exits 1 on drift for scripting (like status); drift lines are colored yellow via ui; site is resolved positionally or via --site with the interactive picker on a terminal.

Why

Roadmap task #313.

Testing

  • siteconfig: YAML + JSON load, missing-file and parse errors
  • diff: drift unit tests (in-sync, per-field, name/owner); e2e in-sync, drift, 404-not-deployed, --exit-code (exit 1) vs a fake daemon; missing config file → config error
  • diff --help wiring via the root command; root-help golden + docs regenerated
  • go test -race ./... passes (34 packages); make coverage = 85.0% (≥80% gate)
  • golangci-lint run clean; pre-commit hooks pass

Breaking Changes

None. Adds a diff command and the shared siteconfig package.

Notes

No thwap-actions action applies (CLI feature). The declared-state file format introduced here is reused by the future export command (#316).

Closes #311
Closes #312
Closes #313

## What Implements Phase 10 `diff` command (roadmap #313). - **New `internal/tpagectl/siteconfig`** — defines the declared site-config document (`SiteConfig{Name, Owner, Visibility, CustomDomain, PreviewEnabled}`, YAML/JSON). This is the format the future `export` command will write, so `diff` and `export` interop. - **New `internal/tpagectl/diff`** — `tpagectl diff SITE`: - **#311 — compare declared vs actual** — reads `<SITE>.yaml` (or `--file`), fetches `GET /api/v1/sites/{name}`, and compares `visibility`, `custom_domain`, `preview_enabled`, `name`, `owner`. - **#312 — show drift** — prints per-field `field: declared -> actual` lines (empty → `-`), mirroring the `site update` diff style; `Site "…" is in sync.` when clean; a 404 is reported as drift (`site not deployed on the daemon`). - `--exit-code` exits 1 on drift for scripting (like `status`); drift lines are colored yellow via `ui`; site is resolved positionally or via `--site` with the interactive picker on a terminal. ## Why Roadmap task #313. ## Testing - [x] `siteconfig`: YAML + JSON load, missing-file and parse errors - [x] `diff`: `drift` unit tests (in-sync, per-field, name/owner); e2e in-sync, drift, 404-not-deployed, `--exit-code` (exit 1) vs a fake daemon; missing config file → config error - [x] `diff --help` wiring via the root command; root-help golden + docs regenerated - [x] `go test -race ./...` passes (34 packages); `make coverage` = 85.0% (≥80% gate) - [x] `golangci-lint run` clean; pre-commit hooks pass ## Breaking Changes None. Adds a `diff` command and the shared `siteconfig` package. ## Notes No `thwap-actions` action applies (CLI feature). The declared-state file format introduced here is reused by the future `export` command (#316). Closes #311 Closes #312 Closes #313
feat(tpagectl): add diff command
All checks were successful
CI / docker (pull_request) Successful in 3m9s
CI / build (pull_request) Successful in 6m17s
CI / test (pull_request) Successful in 11m58s
CI / lint (pull_request) Successful in 6m0s
CI / build (push) Successful in 8m33s
CI / test (push) Successful in 5m32s
CI / lint (push) Successful in 14m4s
CI / docker (push) Successful in 28m51s
c128fa5802
Add `tpagectl diff SITE` which compares a site's declared configuration
against the daemon's actual state and prints any drift:

- New internal/tpagectl/siteconfig package defines the declared
  site-config document (YAML/JSON); the future export command will write
  the same format.
- diff reads <SITE>.yaml (or --file), fetches GET /api/v1/sites/{name},
  and prints per-field `field: declared -> actual` lines for visibility,
  custom_domain, preview_enabled, name, and owner (empty -> "-"),
  mirroring the site update diff style.
- "Site ... is in sync." when no drift; a 404 is reported as drift
  (site not deployed); --exit-code exits 1 on drift for scripting.
- Site resolved positionally or via --site, with the interactive picker
  on a terminal; drift lines colored yellow via ui.

Documented in the README and regenerated command docs.

Closes #311
Closes #312
Closes #313
fuzzy merged commit c128fa5802 into main 2026-08-10 08:06:38 +00:00
fuzzy deleted branch feat/tpagectl-diff 2026-08-10 08:06:38 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/thwap-pagesd!626
No description provided.