Prepare Hydrogen commands for typed JSON output - #4095
gonzaloriestra wants to merge 1 commit into
Conversation
f6fd624 to
e0da655
Compare
|
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
e0da655 to
60a805a
Compare
60a805a to
806fac6
Compare
fredericoo
left a comment
There was a problem hiding this comment.
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 ?? []), |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
a couple of follow-up questions I forgot to include earlier, neither blocking the approval
| overrides: | ||
| '@oclif/core': '3.26.5' | ||
| '@shopify/cli-kit': '3.80.4' | ||
| '@oclif/core': '4.8.3' |
There was a problem hiding this comment.
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.
| "@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", |
There was a problem hiding this comment.
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?
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-hydrogento 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.tsAfter 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.