fix(cli): mirror workspace routing in add --diff/--dry-run#11003
Open
Kaeldehta wants to merge 3 commits into
Open
fix(cli): mirror workspace routing in add --diff/--dry-run#11003Kaeldehta wants to merge 3 commits into
Kaeldehta wants to merge 3 commits into
Conversation
Contributor
|
@Kaeldehta is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
Kaeldehta
force-pushed
the
fix/dry-run-workspace-aliases
branch
from
June 24, 2026 08:20
3d3c027 to
e02cd4f
Compare
…#11002) In a monorepo, `add --diff`/`--dry-run` previewed the app's import aliases for files that the real `add` routes into a separate UI package, so the preview disagreed with what was actually written (e.g. `@workspace/ui/lib/utils` vs `#lib/utils`). Extract the workspace file-grouping/config-routing logic out of `addWorkspaceComponents` into a shared `groupFilesByWorkspaceTarget` helper, and use it from the dry-run path so each file is transformed with the config of the package it's written to. This keeps the preview and the real write in sync and prevents the two paths from drifting again. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Kaeldehta
force-pushed
the
fix/dry-run-workspace-aliases
branch
from
June 24, 2026 08:26
e02cd4f to
2e2ab93
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #11002.
In a monorepo where an app references a UI package by its published name (
@workspace/ui/*) but the UI package itself uses package.json#imports(#lib/utils),shadcn add <component> --diff/--dry-runrun from an app previewed the wrong import aliases for files routed into the UI package.addComponents→addWorkspaceComponents) routesregistry:ui/registry:hook/registry:libfiles into the UI package and transforms them with that package's own config →import { cn } from "#lib/utils".import { cn } from "@workspace/ui/lib/utils".So the preview and the actual write disagreed, making
--diffmisleading. Workspace routing was added to the real path in #10519; the dry-run path was never updated to mirror it.Changes
packages/shadcn/src/utils/workspace-files.ts—groupFilesByWorkspaceTarget(), extracted fromaddWorkspaceComponentsso the file-grouping / per-package config routing is a single source of truth shared by both paths (this drift is what caused the bug).add-components.ts—addWorkspaceComponentsnow uses the shared helper. Pure extraction, behavior-preserving.dry-run.ts—dryRunComponentsnow detects the workspace (same condition as the real path) and processes files per target package, transforming each with its own config and reporting workspace-root-relative paths. CSS/env route to the UI package. Non-workspace behavior is unchanged.Tests
registry:uimonorepo dry-run test asserting the preview emits#lib/utilsand writes topackages/ui/src/components/badge.tsx.addreports.pnpm --filter=shadcn test→ 1524 passed.🤖 Generated with Claude Code