Add typed JSON output to Hydrogen setup commands - #4102
gonzaloriestra wants to merge 1 commit into
Conversation
828e6e0 to
b5e9444
Compare
|
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
b5e9444 to
bccea70
Compare
bccea70 to
addaedb
Compare
addaedb to
c18e302
Compare
fredericoo
left a comment
There was a problem hiding this comment.
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])( |
There was a problem hiding this comment.
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.
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
--jsontosetup,setup css,setup marketsandsetup 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:{"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.tsBuild 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.