@W-24232594 refactor(mrt): centralize --json log suppression in MrtCommand - #693
Merged
Merged
Conversation
Override MrtCommand.log() to no-op when --json is set, replacing the ~40 per-call-site `if (!this.jsonEnabled())` guards that wrapped pure this.log() progress/status output across the mrt commands. Guards that gate confirmation prompts, table/detail stdout payloads, and positive `if (this.jsonEnabled())` branches are kept. Also fixes `mrt env var push --json`, which leaked progress text onto stdout alongside the JSON result, and converts its human-only progress lines from ux.stdout to this.log to match sibling commands. Adds tests asserting log() is suppressed under --json while warn() and error diagnostics still surface.
kieran-sf
marked this pull request as ready for review
September 18, 2026 15:38
o-olaosebikan
approved these changes
Sep 18, 2026
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
MRT commands previously guarded every human-readable log line with
if (!this.jsonEnabled())so progress/status text wouldn't corrupt--jsonoutput. That was repetitive (~40 call sites) and easy to forget —mrt env var pushmissed the guards entirely and leaked progress text onto stdout in--jsonmode.This centralizes the behavior:
MrtCommand.log()override (SDK): returns early whenjsonEnabled(), sothis.log()is a no-op in--jsonmode.this.log()routes to the pino logger (stderr);warn()/error()are untouched and still surface.if (!this.jsonEnabled())wrappers around purethis.log()calls.!force && !jsonEnabled()),ux.stdouttable/detail blocks (the real stdout data payloads), positiveif (this.jsonEnabled())branches, and thetail-logsuseColorlogic guard.mrt env var push: fixed the--jsonstdout-pollution bug, and converted its human-only progress/summary lines fromux.stdouttothis.log(its real output is the returned{pushed, failed, skipped}object, matching siblingdeploy).Test plan
pnpm --filter @salesforce/b2c-tooling-sdk run test:agent— newlog() - suppressed in --json modeblock passes (suppressed under--json; emits without--json;warn()still surfaces under--json)pnpm --filter @salesforce/b2c-cli run test:agent— full CLI suite green (1525 passing)pnpm run typecheck:agent(SDK + CLI) cleanpnpm run lint:agentclean;prettierclean on all mrt command filesb2c mrt env var push -p <project> -e <env> --json— stdout is valid JSON only, no progress text interleaved--json— progress lines, per-var✓output, and summary still render--json(e.g.mrt project delete <slug> --json) — confirmation prompt is still skipped and JSON result is cleanNotes
@salesforce/b2c-cli+@salesforce/b2c-tooling-sdk, patch).--jsonoutput payloads are unchanged, only interleaved stderr/stdout noise is removed.