Skip to content

fix(cookbook): remove withResolvedCatalog from regenerate command#3723

Open
fredericoo wants to merge 1 commit intomainfrom
fd/fix-cookbook-regenerate
Open

fix(cookbook): remove withResolvedCatalog from regenerate command#3723
fredericoo wants to merge 1 commit intomainfrom
fd/fix-cookbook-regenerate

Conversation

@fredericoo
Copy link
Copy Markdown
Contributor

@fredericoo fredericoo commented Apr 15, 2026

WHY are these changes introduced?

withResolvedCatalog() resolves workspace:* and catalog: protocols to concrete versions in all workspace package.json files. The regenerate command wraps all three steps inside this helper, which means applyRecipe() sees resolved values (e.g. "@shopify/hydrogen": "2026.4.0") instead of the original protocol strings. Patches whose context lines include "workspace:*" or "catalog:" fail to apply because the file no longer matches.

Recipes whose patch context windows happen to avoid those lines (e.g. infinite-scroll, metaobjects) regenerate fine. Recipes like multipass and partytown fail.

How this went undetected

The bug was latent because the E2E validation tests use --template <copy>, which applies patches to a copy of the skeleton that isn't modified by catalog resolution. So validation always passed. The issue only surfaces when running regenerate against the in-tree skeleton (without --template), which is the normal developer workflow for refreshing recipes after skeleton changes.

This was discovered while working on the Vite 8 migration (fd-vite-8), where skeleton package.json changes caused regenerate to fail on recipes like multipass and partytown. The workaround was calling applyRecipe() directly and running generate/render separately — this PR eliminates the need for that workaround.

WHAT is this pull request doing?

Removes the withResolvedCatalog() wrapper from the regenerate command. The three inner steps don't need it:

  • applyRecipe() needs workspace:* intact so patch context matches
  • generateRecipe() diffs against HEAD, which also has workspace:*
  • renderRecipe() reads YAML and generates markdown

The existing git checkout/git clean at the end of each loop iteration already handles skeleton restoration. The apply and validate commands still use withResolvedCatalog() — no dead code.

HOW to test your changes?

cd cookbook
npx ts-node src/index.ts regenerate --recipe multipass
npx ts-node src/index.ts regenerate --recipe partytown

Both should succeed where they previously failed with patch application errors.

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or functional changes. Test changes or internal-only config changes do not require a changeset.
  • I've added tests to cover my changes
  • I've added or updated the documentation

The regenerate command wrapped applyRecipe/generateRecipe/renderRecipe
inside withResolvedCatalog(), which resolves workspace:* and catalog:
protocols to concrete versions in package.json files before the callback
runs. This broke patch application for recipes whose context lines
include those protocol values (e.g. multipass, partytown) because the
skeleton's package.json no longer matched what the patches expected.

The regenerate command doesn't need resolved versions — patches need
workspace:* intact for context matching, generateRecipe diffs against
HEAD (which also has workspace:*), and renderRecipe just reads YAML.
The existing git checkout/clean at the end of each loop iteration
already handles skeleton restoration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@shopify
Copy link
Copy Markdown
Contributor

shopify bot commented Apr 15, 2026

Oxygen deployed a preview of your fd/fix-cookbook-regenerate branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment April 15, 2026 5:26 PM

Learn more about Hydrogen's GitHub integration.

@fredericoo fredericoo marked this pull request as ready for review April 15, 2026 17:32
@fredericoo fredericoo requested a review from a team as a code owner April 15, 2026 17:32
@andguy95
Copy link
Copy Markdown
Collaborator

@fredericoo Top hatting this PR and it does fix the regenerate command issue. However it introduces a potential UX regression for consideration.

The regenerate in this PR will now regenerate the package.json files and leave the workspace:* and catalog:* in the patch files leaking monorepo-internal protocols into user-facing docs. This would produce confusing documentation for every recipe that touches package.json. The external user's LLM would implement workspace:*/catalog:* dependencies that can't be installed.


The current ordering is:

  1. resolve
  2. apply
  3. generate
  4. render
  5. restore

This fails because apply sees a resolved skeleton but patches have workspace:* context.

Maybe if we move resolution to between apply and generate:

  1. apply
  2. resolve
  3. generate
  4. render
  5. restore

Now what should happen could be:

  1. apply patches onto unresolved skeleton — workspace:* matches workspace:*
  2. resolve the now-patched skeleton — workspace:* becomes 2026.4.0

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