feat(cli): add --json output mode to release and release-react#43
Merged
Conversation
When --json is passed to release or release-react, the CLI emits a single-line JSON object describing the released package as the last line of stdout and routes all progress messages to stderr. Pipes like `aether release ... --json | jq` work without filtering. Schema mirrors what the server returns: label, packageHash, size, appVersion, blobUrl, manifestBlobUrl, description, releasedBy, releaseMethod, uploadTime, rollout, isMandatory, isDisabled. Undefined fields are dropped from the JSON. On error the CLI follows UNIX convention: stderr human message, exit non-zero, no JSON on stdout. Errors keep the existing handler path. The flag is scoped to release and release-react. promote and patch stay unchanged for now; the formatter helper lives in script/utils/release-json.ts and is reusable when those need wiring.
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
Adds a
--jsonflag toreleaseandrelease-react. When set, the CLI emits a single-line JSON object describing the released package as the last line of stdout; all progress messages route to stderr. The motivation is the upcomingaetherpush/deploy-actionGitHub Action, which needs structured outputs (label, package hash, size, etc.) to chain post-release steps without parsing prose with regex.Behavior
With
--json:Uploading release package..., hermes/signing notices, success line).aether release MyApp ./bundle.js 1.0.0 --json | jq .label.Without
--json: zero change from current behavior.Schema
The JSON object reuses the
Packagereturned by the server (already typedPromise<Package>on the SDK), so it reflects the post-upload truth — label assigned, hash computed, size measured, description with the[ci=...]bracket already injected by Phase 4's--ci-metadata.Fields:
label,packageHash,size,appVersion,blobUrl,manifestBlobUrl,description,releasedBy,releaseMethod,uploadTime,rollout,isMandatory,isDisabled. Undefined fields are dropped from the JSON.Design notes
The flag is scoped to
releaseandrelease-react(declared per-builder, not inaddCommonConfiguration). It does not autoset--non-interactiveor vice versa — the two flags are orthogonal.releaseReactalready delegates toreleaseat the end of its bundle/hermes/sign chain, so a single JSON emit point inrelease()covers both commands. The sharedprogressLog(command, message)helper routes 7 progress sites in the two functions to stderr whencommand.jsonis set.The formatter lives in a small
script/utils/release-json.tsmodule.promoteandpatchare out of scope for this PR but can adopt the same formatter in roughly three lines each when needed.Tests
__tests__/utils/release-json.test.ts: shape with a full package, dropping of undefined fields, single-line guarantee.__tests__/command-parser.test.ts:--jsonabsent leaves the field undefined, present sets it true on bothreleaseandrelease-react.__tests__/command-executor.test.ts: with--json, the last stdout line parses as JSON and matches schema while the upload notice goes to stderr; without--json, the upload notice stays on stdout and no JSON line appears.Coverage on
release-json.ts: 100% across statements, branches, functions, lines. Suite total 392 tests, all passing.Type of change
Checklist
npm run build)