Repository navigation
feat(cli): write refs in the short form in export and fmt - #212
Conversation
Signed-off-by: Erik Nilsen <enilsen16@live.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR SummaryLow Risk Overview
The CLI README documents this canonical output. Unit tests cover short-form export and the long-form fallback case. Reviewed by Cursor Bugbot for commit 02a492b. Bugbot is set up for automated code reviews on this repo. Configure here. |
Problem
The manifest parser accepts
slug,ns/slugorns/slug@versionwherever an Id, Ref, Edge or Example goes. Buttrogon-atlas exportandtrogon-atlas fmtwrite the long form ({id: {namespace, slug, version}}). Agents copy that output and write the long form too.Change
This PR changes the default output format of
exportandfmt. If you prefer to keep the long form as the canonical form, you can decline this PR.entity_to_manifestnow writes each Id, Ref, Edge and Example wrapper as the shortest string that the parser reads back to the same value:slugin the manifest's namespace,ns/slugin a different namespace, and@versiononly when the version is not 1.idstrings,Anyvalues and map fields do not change.doc, orEntityRef.kind). It also stays when a string would not read back as the same Id (for example a slug with@or/, or an empty namespace).exportandfmtwrite the short form.This PR does not change the files in
examples/manifests. If you accept this change, a second PR regenerates them withtrogon-atlas fmt examples/manifests --write.Test
export.rs. One test makes sure that a command-slice ref exports ascommand: add-item-to-cart, a ref in a different namespace exports asns/slug@2, and an edge with adocstays a mapping. The other test makes sure that an Id whose slug contains@stays in the long form.fmt_integration.rsalready checksparse(fmt(x)) == parse(x)andfmt(fmt(x)) == fmt(x)for every example manifest. It passes with the new output.cargo test -p trogon-atlas-client,cargo test -p trogon-atlas-cli, and clippy with-D warningson both crates pass.Closes #85
Need help on this PR? Tag
@codesmith-botwith what you need.