Closed vaikas closed 1 year ago
Awesome idea! I love it.
Since yam
operates on YAML generically, we could have an implementation that's generic. Maybe something like "sort path expressions", similar to how today you can specify "gap path expressions", where matching YAML elements have their child elements gapped with empty lines.
E.g. given a file foo.yaml
:
name: ville
favorite-dans:
- luhring
- lorenc
You could run yam --sort '.favorite-dans' foo.yaml
(or the equivalent via a yam config file) to produce:
name: ville
favorite-dans:
- lorenc
- luhring
(Which would hurt my feelings, but at least sorted alphabetically...)
WDYT?
Yes! I was hoping to have ways of specifying that certain arrays need to be sorted indeed.
Closing per https://github.com/chainguard-dev/yam/pull/28 but lmk if there's more to this!
It would be nice to have packages alphabetized so it's easier to find if a particular package is there or not visually. Add verbiage saying this is the convention, update existing packages (this could be done lazily), add a presubmit check to enforce this.