feat(tpagectl): add export command #627
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/thwap-pagesd!627
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/tpagectl-export"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Implements Phase 10
exportcommand (roadmap #316).siteconfig.Write— new shared writer for the declared site-config document (YAML default, indented JSON), complementing the existingLoadFile. This is the apply-compatible format (#315— marked done as format-ready; a futureapplyconsumes these files viaLoadFile).internal/tpagectl/export—tpagectl export SITE:GET /api/v1/sites/{name}, builds theSiteConfig(name, owner, visibility, custom_domain, preview_enabled), and writes it to<SITE>.yaml(or<SITE>.jsonwith--format json;--outputoverrides, creating parent dirs), printingExported site "<name>" to <path>.--formatvalidation → exit 5; site resolved positionally or via--sitewith the interactive picker on a terminal; 404 → friendly not-found error.Why
Roadmap task #316.
Testing
siteconfig:Write→LoadFileround-trip for YAML and JSON; unsupported format errorexport: e2e vs fake daemon — defaultblog.yamlcontents,--format json→blog.json,--outputcustom path (parent dir created), invalid--format→ validation error, 404 → friendly not-foundexport --helpwiring via the root command; root-help golden + docs regeneratedgo test -race ./...passes (35 packages);make coverage= 84.8% (≥80% gate)golangci-lint runclean; pre-commit hooks passBreaking Changes
None. Adds an
exportcommand and asiteconfig.Writehelper.Notes
No
thwap-actionsaction applies (CLI feature).#315(apply, explicitly future) is closed as format-ready: the exported YAML/JSON document is exactly what a futureapplywill read viasiteconfig.LoadFile.Closes #314
Closes #315
Closes #316
Clean, minimal
exportcommand. Site resolution (positional/--site/interactive), format validation (exit 5), the friendly 404 path, parent-dir creation, and thesiteconfig.Write/LoadFileround-trip for YAML and JSON are all correct, andomitemptykeeps empty custom domains out of the document. Approving; one data-loss risk filed.Suggestions
internal/tpagectl/export/export.go:119–os.Createsilently overwrites an existing<SITE>.yaml(or--outputtarget). Since exported documents are meant to be edited and later applied, a re-export clobbers user edits. Refuse to overwrite, or require--force. Filed as #628.Notes
yaml.Marshalfor its trailing newline; the JSON path explicitly appends\n, so a YAML file may not be POSIX-text — minor inconsistency worth checking.--output blog.jsonwithout--format jsonwrites YAML content into a.jsonfile (format drives content, extension only matters when--outputis unset) — minor UX.os.Create(no temp+rename) can leave a partial file on a crash mid-write — regenerable, low risk.Praise
siteconfig.Writecleanly centralizes the declared-document encoding, keepingexportthin and the apply-compatible format consistent withdiff/futureapply.KindConfig(exit 2), and success output is styled viaui.Success.