Skip to content

Emit info and warning alerts as JSON diagnostics - #8792

Open
gonzaloriestra wants to merge 3 commits into
mainfrom
gonzalo/json-alert-diagnostics
Open

gonzaloriestra wants to merge 3 commits into
mainfrom
gonzalo/json-alert-diagnostics

Conversation

@gonzaloriestra

@gonzaloriestra gonzaloriestra commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

renderInfo and renderWarning currently print terminal banners when --json is enabled. Callers must choose a different output helper to produce JSON diagnostics.

Example:

    if (format === 'json') outputWarn(`${warning.headline} ${warning.body}`)
    else renderWarning(warning)

WHAT is this pull request doing?

Make both helpers emit diagnostic events on stderr in JSON mode, while preserving banners in text mode. Preserve alert details and URLs, reuse the JSON error formatter, and update the guidance. Simplify bulk-operation diagnostics, app-log notices, and the multiple-installation notice to use the shared helpers without format branches.

How to manually test your changes?

pnpm shopify store bulk status --store your-store.myshopify.com
pnpm shopify store bulk status --store your-store.myshopify.com --json | jq .

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset

@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/node/multiple-installation-warning.d.ts
@@ -1,6 +1,6 @@
 /**
  * Shows a warning if there are two Shopify CLI installations found (global and local).
- * Won't show anything if the user included the --json flag.
+ * Emits a diagnostic on stderr in JSON mode.
  *
  * @param directory - The directory of the project.
  * @param dependencies - The dependencies of the project.
packages/cli-kit/dist/private/node/ui/alert.d.ts
@@ -3,4 +3,4 @@ import { RenderOptions } from 'ink';
 export interface AlertOptions extends AlertProps {
     renderOptions?: RenderOptions;
 }
-export declare function alert({ type, headline, body, nextSteps, reference, link, customSections, orderedNextSteps, renderOptions, }: AlertOptions): string | undefined;
\ No newline at end of file
+export declare function alert(options: AlertOptions): string | undefined;
\ No newline at end of file
packages/cli-kit/dist/private/node/ui/components/token-item.d.ts
@@ -35,4 +35,6 @@ export type Token = string | {
 export type InlineToken = Exclude<Token, ListToken>;
 export type TokenItem<T extends Token = Token> = T | T[];
 export declare function tokenItemToString(token: TokenItem): string;
-export declare function appendToTokenItem(token: TokenItem, suffix: string): TokenItem;
\ No newline at end of file
+export declare function appendToTokenItem(token: TokenItem, suffix: string): TokenItem;
+/** Converts tokens to JSON message text, retaining link URLs and list titles. */
+export declare function tokenItemToJsonString(token: TokenItem): string;
\ No newline at end of file

@gonzaloriestra

Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm.

Built from 6f4f4ee93ff4068c8a5a05c01013091d4033a3c7. Workflow run.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261006120211

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@gonzaloriestra
gonzaloriestra marked this pull request as ready for review October 6, 2026 12:14
@gonzaloriestra
gonzaloriestra requested a review from a team as a code owner October 6, 2026 12:14

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant