feat: add --export_ordered flag to produce stable JSON exports#1335
feat: add --export_ordered flag to produce stable JSON exports#1335zariok wants to merge 5 commits intoauth0:masterfrom
Conversation
Auth0's API returns resource attributes in inconsistent order, causing noisy diffs in version control even when nothing has changed. Adds `--sort-keys` / `-s` CLI flag and `AUTH0_SORT_JSON_KEYS` config key to sort all exported JSON keys alphabetically at write time. Implemented in `dumpJSON()` — the shared write utility used by all directory-format handlers — so every resource type gets the behavior automatically with no call-site changes. Key fix: yargs normalizes `--sort-keys` to `sortKeys` (camelCase) in the parsed argv, so the export command destructures `sortKeys` rather than `sort_keys`.
|
Thank you for submitting this PR! We'll review it shortly. |
|
Manually tested via a node ~/github.com/auth0-deploy-cli/lib/index.js export -f directory -o export-sorted --sort-keys
diff <(jq --sort-keys . ./export-sorted/connections/myconnection.json) ./export-sorted/connections/myconnection.json |
|
Hi, @zariok , |
Let me iterate. I hit the dumpJSON. I'll update the PR when I get YAML sorted. |
|
@kushalshit27 Ready for review again |
kushalshit27
left a comment
There was a problem hiding this comment.
Please update the documentation with relevant information.
export_ordered instead of sort_keys simplify sortedKeysReplacer() add docs for this functionality
Done. |
|
|
||
| A url for proxying requests. Only set this if you are behind a proxy. | ||
|
|
||
| ### `--sort-keys` |
There was a problem hiding this comment.
This should be export_ordered
kushalshit27
left a comment
There was a problem hiding this comment.
Please update the PR description to reflect current changes.
Auth0's API returns resource attributes in inconsistent order, causing noisy diffs in version control even when nothing has changed.
🔧 Changes
Adds
--sort-keys/-sCLI flag andAUTH0_SORT_JSON_KEYSconfig key to sort all exported JSON keys alphabetically at write time.Implemented in
dumpJSON()— the shared write utility used by all directory-format handlers — so every resource type gets the behavior automatically with no call-site changes.📚 References
Resolves: #1186
🔬 Testing
npm run buildpasses with no TypeScript errorsnpm testpasses--sort-keysproduces files wherediff <(jq --sort-keys . file.json) file.jsonis empty--sort-keysis unchanged from current behaviorAUTH0_SORT_JSON_KEYS=truein config file produces the same result as the CLI flag📝 Checklist