Skip to content

--json -j should not use color#7069

Merged
dmerand merged 1 commit intomainfrom
dlm-json-force-no-color
Mar 26, 2026
Merged

--json -j should not use color#7069
dmerand merged 1 commit intomainfrom
dlm-json-force-no-color

Conversation

@dmerand
Copy link
Contributor

@dmerand dmerand commented Mar 20, 2026

What

Disable color output automatically when a command runs in JSON mode.

This makes --json and -j behave like --no-color at CLI bootstrap.

Why

Machine-readable output should not depend on terminal styling.

Without this, ANSI escape sequences can leak into JSON string values unless callers also remember to pass --no-color.

How

Treat --json, -j, and SHOPIFY_FLAG_JSON as no-color signals when the CLI sets up its environment.

Testing

Run any command that supports --json and confirm the JSON output does not contain ANSI escape sequences without also passing --no-color.

On this stack, shopify app config validate --json ... works once the next PR lands.

Copy link
Contributor Author

dmerand commented Mar 20, 2026

@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2026

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 82.23% 15042/18293
🟡 Branches 74.79% 7418/9919
🟢 Functions 81.3% 3791/4663
🟢 Lines 82.62% 14222/17214

Test suite run success

3973 tests passing in 1524 suites.

Report generated by 🧪jest coverage report action from 28a0c2a

@dmerand dmerand force-pushed the dlm-json-force-no-color branch 2 times, most recently from 83a7548 to 7eff2a7 Compare March 23, 2026 21:28
@dmerand dmerand force-pushed the dlm-json-force-no-color branch 2 times, most recently from da7fb1e to c953d80 Compare March 25, 2026 15:50
@dmerand dmerand force-pushed the dlm-json-force-no-color branch from c953d80 to 085ad44 Compare March 26, 2026 01:11
@dmerand dmerand marked this pull request as ready for review March 26, 2026 01:12
@dmerand dmerand requested review from a team as code owners March 26, 2026 01:12
Copilot AI review requested due to automatic review settings March 26, 2026 01:12
@github-actions
Copy link
Contributor

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Disables ANSI color output automatically when the CLI is invoked in JSON output mode, to prevent escape sequences from leaking into machine-readable JSON.

Changes:

  • Treat --json / -j as “no-color” signals during CLI bootstrap (sets FORCE_COLOR=0).
  • Update --json flag descriptions across the CLI manifest/README and generated docs.
  • Add unit tests ensuring --json / -j trigger no-color mode.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/cli/oclif.manifest.json Updates --json flag descriptions to note color is disabled.
packages/cli/README.md Updates command flag help text for --json to mention no-color behavior.
packages/cli-kit/src/public/node/cli.ts Implements no-color forcing when --json / -j is present.
packages/cli-kit/src/public/node/cli.test.ts Adds tests for --json / -j disabling color.
docs-shopify.dev/generated/generated_docs_data.json Regenerates docs data reflecting updated --json description.
docs-shopify.dev/commands/interfaces/theme-push.interface.ts Updates --json flag docstring to mention no-color behavior.
docs-shopify.dev/commands/interfaces/theme-profile.interface.ts Updates --json flag docstring to mention no-color behavior.
docs-shopify.dev/commands/interfaces/theme-list.interface.ts Updates --json flag docstring to mention no-color behavior.
docs-shopify.dev/commands/interfaces/theme-info.interface.ts Updates --json flag docstring to mention no-color behavior.
docs-shopify.dev/commands/interfaces/theme-duplicate.interface.ts Updates --json flag docstring to mention no-color behavior.
docs-shopify.dev/commands/interfaces/organization-list.interface.ts Updates --json flag docstring to mention no-color behavior.
docs-shopify.dev/commands/interfaces/app-versions-list.interface.ts Updates --json flag docstring to mention no-color behavior.
docs-shopify.dev/commands/interfaces/app-logs.interface.ts Updates --json flag docstring to mention no-color behavior.
docs-shopify.dev/commands/interfaces/app-info.interface.ts Updates --json flag docstring to mention no-color behavior.
docs-shopify.dev/commands/interfaces/app-function-run.interface.ts Updates --json flag docstring to mention no-color behavior.
docs-shopify.dev/commands/interfaces/app-function-replay.interface.ts Updates --json flag docstring to mention no-color behavior.
docs-shopify.dev/commands/interfaces/app-function-info.interface.ts Updates --json flag docstring to mention no-color behavior.
docs-shopify.dev/commands/interfaces/app-config-validate.interface.ts Adds generated interface docs for app config validate (no JSON flag listed).
docs-shopify.dev/commands/examples/app-config-validate.example.sh Adds generated example snippet for app config validate.
docs-shopify.dev/commands/app-config-validate.doc.ts Adds generated docs entity for app config validate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dmerand dmerand force-pushed the dlm-json-force-no-color branch from 085ad44 to 28a0c2a Compare March 26, 2026 01:23
@dmerand dmerand added this pull request to the merge queue Mar 26, 2026
Merged via the queue into main with commit ecc2096 Mar 26, 2026
31 checks passed
@dmerand dmerand deleted the dlm-json-force-no-color branch March 26, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants