Skip to content

Add typed JSON output to Hydrogen setup commands - #4102

Draft
gonzaloriestra wants to merge 1 commit into
gonzalo/hydrogen-json-projectfrom
gonzalo/hydrogen-json-setup
Draft

gonzaloriestra wants to merge 1 commit into
gonzalo/hydrogen-json-projectfrom
gonzalo/hydrogen-json-setup

Conversation

@gonzaloriestra

@gonzaloriestra gonzaloriestra commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Setup commands need structured receipts describing what was configured and whether the operation completed.

WHAT is this pull request doing?

Add schemas and --json to setup, setup css, setup markets and setup vite. Preserve terminal presentation and return configured, built-in or cancelled results as applicable. Wait for setup tasks before emitting the final result.

Without --json, the existing terminal presentation remains. Example JSON result:

shopify hydrogen setup css --json
{"status":"built-in","directory":"/project","strategy":"css-modules","files":[],"dependenciesInstalled":false,"needsNpmReinstall":false}

HOW to test your changes?

pnpm --filter @shopify/cli-hydrogen test src/commands/hydrogen/setup/json-output.test.ts

Build and typecheck were checked at each layer. The full stack passed 498 tests (6 skipped), lint, and schema discovery for all 22 finite commands. Command-line smoke checks covered a successful unlink result, fatal project errors, watch-mode rejection and schema environment flags. Live authenticated Shopify operations have not been exercised.

Stack

Draft 8 of 9. Previous: #4101. Next: #4103. One changeset is included in #4103.

  1. Prepare Hydrogen commands for typed JSON output
  2. Add typed JSON output to Hydrogen build tooling
  3. Add typed JSON output to hydrogen customer-account-push
  4. Add typed JSON output to hydrogen deploy
  5. Add typed JSON output to Hydrogen environment commands
  6. Add typed JSON output to Hydrogen route generation
  7. Add typed JSON output to Hydrogen project and account commands
  8. Add typed JSON output to Hydrogen setup commands
  9. Add typed JSON output to Hydrogen maintenance commands

@shopify

shopify Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Oxygen deployed a preview of your gonzalo/hydrogen-json-setup branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment September 29, 2026 2:58 PM

Learn more about Hydrogen's GitHub integration.

@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-setup branch from b5e9444 to bccea70 Compare September 28, 2026 15:38
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-setup branch from bccea70 to addaedb Compare September 29, 2026 12:25
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-setup branch from addaedb to c18e302 Compare September 29, 2026 14:54

@fredericoo fredericoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

small comments but overall this looks good. Human output is unchanged, the prompt behaviour matches the rest of the stack (prompts stay, same as env in #4099), and errors go through the shared path. The only real gap is that hydrogen setup itself has no behavioural JSON test.

nice catch on awaiting backgroundWorkPromise in the !i18n && !createShortcut early return, too. Before, IIRC, it returned without waiting on the copy/route work, so any failure there ended up as an unhandled rejection.

expect(stdout).toBe('');
});

it.each([Setup, SetupCSS, SetupMarkets, SetupVite])(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

non-blocking: hydrogen setup is the most involved command in this PR, but its only test is this flag/schema check. Two things aren't covered: the early-return path, which now awaits background work and returns routes, and shortcut flipping to true once createShortcut() succeeds. It's also the one result carrying extra fields (cliCommand, showSummary) that rely on zod stripping them in encode.

Let's add one test that runs runSetup({directory, markets: 'none', shortcut: false, installDeps: false}) and asserts the exact stdout with toEqual. That way a leaked internal field or a missing routes would fail it.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants