Skip to content

fix(cli): detect slot recipes by defineSlotRecipe helper#572

Open
tobigumo wants to merge 1 commit into
chakra-ui:mainfrom
tobigumo:fix/cli-slot-recipe-detection
Open

fix(cli): detect slot recipes by defineSlotRecipe helper#572
tobigumo wants to merge 1 commit into
chakra-ui:mainfrom
tobigumo:fix/cli-slot-recipe-detection

Conversation

@tobigumo

Copy link
Copy Markdown
Contributor

Problem

When adding a slot-recipe component (e.g. tabs) via the CLI, the recipe is registered under recipes instead of slotRecipes in the generated theme/recipes/index.ts:

// generated (wrong)
export const recipes = { tabs }   // ← slot recipe lands here
export const slotRecipes = {}

Root cause

packages/cli/src/utils/install.ts decides the recipe type with:

type: file.content.includes('slotRecipe') ? 'slotRecipe' : 'recipe',

Recipe sources define slot recipes with defineSlotRecipe (capital S). Because String.prototype.includes is case-sensitive, the lowercase slotRecipe substring is never present in "defineSlotRecipe", so the check returns false, the type collapses to 'recipe', and updateRecipeIndex routes it into recipes.

This affects every slot recipe (all 42 published *-recipe items), not just tabs. The downstream routing in recipes.ts is correct; only the type detection in install.ts was wrong.

Fix

Match the helper name defineSlotRecipe instead:

type: file.content.includes('defineSlotRecipe') ? 'slotRecipe' : 'recipe',

All 42 slot recipes call defineSlotRecipe, and no regular recipe contains that string as a substring (defineRecipedefineSlotRecipe), so the two-way classification stays correct.

Verification

Ran the real updateRecipeIndex against the actual published registry contents:

  • tabs-recipe (slot) — old logic → recipes (reproduces the bug); fixed → slotRecipes
  • button-recipe (defineRecipe) — both old and fixed → recipes ✅ (no regression)

The recipe type detection used `file.content.includes('slotRecipe')`,
but recipe sources call `defineSlotRecipe` (capital S). Since `includes`
is case-sensitive, the lowercase `slotRecipe` substring never matched,
so every slot recipe was misclassified as a regular recipe and registered
under `recipes` instead of `slotRecipes` in the generated theme index.

Match the `defineSlotRecipe` helper name instead, which all 42 published
slot recipes use and no regular recipe contains as a substring.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant