Skip to content

Prepare Hydrogen commands for typed JSON output - #4095

Draft
gonzaloriestra wants to merge 1 commit into
mainfrom
gonzalo/hydrogen-json-support
Draft

gonzaloriestra wants to merge 1 commit into
mainfrom
gonzalo/hydrogen-json-support

Conversation

@gonzaloriestra

@gonzaloriestra gonzaloriestra commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Finite Hydrogen commands need shared schema, error and event support before they can expose reliable JSON results.

WHAT is this pull request doing?

Pin CLI Kit to 0.0.0-nightly-20260929144221 (temporarily until the next stable release is out) and align Oclif with the nightly. Keep Shopify CLI on its existing nightly because the matching CLI package was not published. Add a shared result writer, JSON-aware alerts, and real-stream test capture. Use CLI Kit’s task renderer directly, removing the temporary task adapter. Keep project validation and disabled-command checks in the init hook, using CLI Kit’s standard JSON error handler when JSON output is requested and preserving the existing text warnings otherwise. Update the local launcher so schema discovery runs before hooks and the bundled Hydrogen hook does not run alongside local commands.

Adapt create-hydrogen to the nightly: remove the obsolete standalone Yoga WASM copy, read terminal UI from stderr in the integration test, and create the onboarding fixture with a stable directory name. Align GraphQL resolutions with CLI Kit to prevent codegen from loading incompatible module instances. Keep the upgrade E2E fixture on npm so the nightly does not inherit pnpm from the test runner and mix package managers.

The CLI Kit nightly includes the task renderer from Shopify/cli#8672. The local alert wrapper remains necessary for JSON diagnostics. CLI Kit startup warnings can still appear as text on stderr. Before marking the stack ready, switch to the upcoming CLI release and recheck the launcher and streams.

HOW to test your changes?

pnpm --filter @shopify/cli-hydrogen test src/hooks/init.test.ts src/lib/hydrogen-command-policy.test.ts src/lib/ui.test.ts src/lib/patch-cli.test.ts

After rebasing onto main, all seven package builds, CLI typecheck, and lint passed. CLI tests passed (509 tests, 6 skipped); three init checks initially overlapped with the build and passed on rerun after it completed. The compiled create-hydrogen integration test and direct CLI Kit JSON task smoke checks passed, including retries, skipped/nested tasks, shared context, and failures. Generated help manifests were refreshed throughout the stack. Schema discovery for all 22 finite commands was checked previously. Command-line smoke checks covered a successful unlink result, non-project and disabled-command JSON errors, the JSON environment flag, and the existing text warning. Hook tests also cover help/schema requests and both --path forms. Live authenticated Shopify operations have not been exercised.

@shopify

shopify Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Oxygen deployed a preview of your gonzalo/hydrogen-json-support 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:55 PM

Learn more about Hydrogen's GitHub integration.

@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-support branch from e0da655 to 60a805a Compare September 29, 2026 12:25
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-support branch from 60a805a to 806fac6 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 groundwork for the stack - the init hook tests covering --, --path=, help/schema and the env flag are really thorough, and good to see the task adapter gone now the nightly has cli#8672. One small comment on how alerts get flattened in JSON mode, nothing blocking.

options.headline,
options.body,
...(options.nextSteps ?? []),
...(options.reference ?? []),

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: in JSON mode this only flattens headline, body, nextSteps and reference, so customSections get dropped silently. That's where most of the useful content lives for a few alerts, e.g. the upgrade summaries in upgrade.ts ("Included in this upgrade", "Updated dependencies", "What's next?") and the onboarding success banner in onboarding/common.ts, so the diagnostic event ends up as just the headline.

Let's fold the sections in too, something like:

...(options.customSections ?? []).flatMap((section) => [
  section.title,
  section.body,
]),

IIRC itemToString already handles the list tokens those sections use, but worth a quick check.

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

a couple of follow-up questions I forgot to include earlier, neither blocking the approval

Comment thread pnpm-workspace.yaml
overrides:
'@oclif/core': '3.26.5'
'@shopify/cli-kit': '3.80.4'
'@oclif/core': '4.8.3'

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.

question: @shopify/oxygen-cli@4.6.18 declares @oclif/core: ^3.26.5 as a peer, and this override forces it onto 4.8.3. hydrogen deploy goes through its createDeploy, and the description mentions live authenticated runs haven't been tested yet. Could we do a deploy smoke test against a real storefront before this leaves draft? If Oxygen CLI breaks on Oclif 4, deploy breaks with it.

Comment thread package.json
"@react-router/dev": "7.16.0",
"@react-router/fs-routes": "7.16.0",
"@shopify/cli": "3.93.2",
"@shopify/cli": "0.0.0-nightly-20260928062710",

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.

question: root @shopify/cli is on the 0928 nightly while CLI Kit is on 0929. The description explains why (the matching CLI nightly wasn't published), but since the local launcher reaches into CLI Kit's private schema module with the CLI's config, shall we line these up again when the stable release lands?

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