Repository navigation
Add yamledit package and preserve wordpress_sites.yml formatting - #748
Open
swalkinshaw wants to merge 2 commits into
Open
swalkinshaw wants to merge 2 commits into
swalkinshaw wants to merge 2 commits into
Conversation
Adds trellis/yamledit, a small wrapper around go.yaml.in/yaml/v3's Node API for making targeted edits to YAML files while preserving comments, key order, quoting style, and blank lines (which yaml.v3 normally drops). `trellis new` now uses it to update wordpress_sites.yml in place instead of round-tripping it through the Site struct with yaml.v2. Previously this stripped Trellis' inline comments and silently dropped any site options the struct doesn't model (such as `xmlrpc`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Adds
trellis/yamledit, a small wrapper aroundgo.yaml.in/yaml/v3'sNodeAPI for making targeted edits to YAML files without losing formatting. This is groundwork fortrellis vault generate(#426), which is stacked on top of this PR.yamleditLoad/Parse,Lookup,Decode,Set,Delete,RenameKey,SetHeadComment,Savevault_users.0.salt). Keys containing dots likeexample.comwork fine."generateme"stays double-quoted)go.yaml.in/yaml/v3is the maintained fork of the archivedgopkg.in/yaml.v3and was already ingo.sumthrough testify. goccy/go-yaml was also considered: it round-trips well, but its path lookups don't handle dotted keys and renaming or inserting keys produced broken output.trellis new: fixeswordpress_sites.ymlbeing rewrittenPreviously
newround-trippedwordpress_sites.ymlthrough theSitestruct with yaml.v2, which:# replace with your Git repo URL, etc.)xmlrpc.It now edits the file in place. Compared with upstream, the only differences are the site name, the hosts, and a
# Created by trellis-cliheader line.yaml.v2is still used for read-only parsing and the update-check state file; moving those over is optional and left out of this PR.Testing
yamledit, including round-tripping every fixtureUpdateDefaultConfigexpectations kept asUpdateDefaultSiteFiletests, plus a full-file formatting testtrellis newlocally and diffed the generatedwordpress_sites.ymlagainst upstream v1.31.1🤖 Generated with Claude Code