feat: add --json output to mutation commands#205
Merged
Conversation
Extend the global --json flag to all write commands so their results (new page id/url, deletion confirmations, purge counts) are machine-readable for scripting and jq, completing --json coverage across the CLI. - create / create-child / update / move / delete / copy-tree - comment / comment-delete / property-delete - attachment-upload / attachment-delete / version-delete / versions-purge - destructive commands require --yes in --json mode (no interactive prompt) - progress and confirmation chatter is suppressed so stdout stays valid JSON Closes #203
…ped output process.exit() can terminate before a piped stdout write flushes, truncating the JSON failure payload from `copy-tree --json --fail-on-error`. Set process.exitCode and return so the event loop drains stdout first.
|
🎉 This PR is included in version 2.14.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Summary
Follow-up to #204. Extends the global
--jsonflag to all write/mutation commands, completing--jsoncoverage "across all commands" as requested in #203. Their results (new page id/url, deletion confirmations, purge counts) are now machine-readable for scripting andjq.What changed
--jsonadded to:create,create-child,update,move,delete,copy-tree,comment,comment-delete,property-delete,attachment-upload,attachment-delete,version-delete,versions-purge.JSON_COMMANDSallowlist so the--jsonpreAction guard (added in feat: add global --json flag and deprecate per-command --format json #204) permits them.--yesin--jsonmode — they refuse with a clear error instead of trying to prompt interactively (which would block a pipe and pollute stdout).--jsonmode (e.g.copy-tree's progress lines,versions-purge's per-version output), so stdout stays a single valid JSON document.--jsononly (viawantsJson()), never the per-command--formatflag — oncreate/update/commentthat--formatis the input content format and is left untouched.Notes
editis read-only (fetches content for editing),export/convert/initare local/file commands — these remain outside--jsonscope and reject it with the standard error.Testing
npm test— 744 passing (new tests cover a non-destructive mutation, a destructive--yessuccess, and the destructive guard).npm run lint— clean.Closes #203