Skip to content

Add typed JSON output to hydrogen deploy - #4098

Draft
gonzaloriestra wants to merge 1 commit into
gonzalo/hydrogen-json-customer-accountfrom
gonzalo/hydrogen-json-deploy
Draft

gonzaloriestra wants to merge 1 commit into
gonzalo/hydrogen-json-customer-accountfrom
gonzalo/hydrogen-json-deploy

Conversation

@gonzaloriestra

@gonzaloriestra gonzaloriestra commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Deployment needs a typed stdout result while preserving the existing CI deployment-file contract.

WHAT is this pull request doing?

Separate deployment execution from its final presentation. Add --json for the completed deployment or null on cancellation, capture custom build output as diagnostics, and flush the result before exiting. Keep --json-output independent and preserve the existing deployment file bytes.

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

shopify hydrogen deploy --json
{"url":"https://example.com"}

HOW to test your changes?

pnpm --filter @shopify/cli-hydrogen test src/commands/hydrogen/deploy.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 4 of 9. Previous: #4097. Next: #4099. 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-deploy 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:56 PM

Learn more about Hydrogen's GitHub integration.

@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-deploy branch from f3d45cb to e3794de Compare September 29, 2026 12:25
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-deploy branch from e3794de to 589de46 Compare September 29, 2026 14:53

@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.

nice and simple - splitting executeDeploy from the presenter in runDeploy reads well, human-mode output is unchanged, and h2_deploy_log.json keeps the same bytes and stays independent of --json (with a test for it). Errors go through the shared JSON error path from #4095, and the two helpers that used to warn-and-return now throw in JSON mode so we don't end up emitting null for what's really a failure.

a couple of small comments on the JSON-mode custom build hook, otherwise LGTM

level: 'warning',
message: stderr.trim(),
});
} catch (error) {

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: when the build fails we drop whatever it printed. exec's error message has stderr in it, but stdout is lost, and some build tools print the useful bit to stdout. Since the failed build is when you most need the logs, let's emit the captured output as diagnostics here too before rethrowing. IIRC the exec rejection error has stdout/stderr on it.

Some smaller tradeoffs vs oxygen-cli's own runner, which already pipes all build output to stderr, so stdout was never at risk. Fine if these are deliberate:

  • output is buffered until the build finishes, so long builds are silent in JSON mode
  • maxBuffer means a very chatty build (>64MB) fails only in JSON mode (unlikely)
  • oxygen-cli's Bugsnag buildCommand metadata isn't recorded on this path

}
});

it('writes a single deployment result and keeps diagnostics off stdout', async () => {

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: the JSON-mode buildFunction for --build-command is the main new behaviour in this PR, but nothing tests it. Let's add a test that runs with buildCommand + json: true and checks the build output ends up as diagnostic events rather than on stdout. The new isJsonOutput() throws in getOxygenDeploymentData and renderMissingStorefront could use a quick test each too (get-oxygen-deployment-data.test.ts already exists).

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