From f1e5cc4666ced2166a859660d769ccee16cde46e Mon Sep 17 00:00:00 2001 From: Neeraj Dalal Date: Sat, 19 Apr 2025 14:35:52 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20feat(fix):=20mark=20"tw-animate-?= =?UTF-8?q?css"=20as=20devDep=20(#6985)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: tweaks to build-registry.mts ~ 1 file 2+ 5- apps/v4/scripts/build-registry.mts * chore: tweaks to index.json ~ 1 file 4+ 9- apps/www/public/r/styles/new-york-v4/index.json * chore: tweaks to registry.json ~ 1 file 221+ 850- apps/v4/registry.json * chore: tweaks to index.json ~ 1 file 47+ 144- apps/www/public/r/index.json * chore: tweaks to registry.json ~ 1 file 852+ 221- apps/v4/registry.json * chore: tweaks to build-registry.mts ~ 1 file 7+ 2- apps/v4/scripts/build-registry.mts * chore: tweaks to build-registry.mts ~ 1 file 2+ 2- apps/v4/scripts/build-registry.mts * chore: tweaks to index.json ~ 1 file 11+ 4- apps/www/public/r/styles/new-york-v4/index.json * chore: tweaks to index.json ~ 1 file 1+ 1- apps/www/public/r/index.json * chore: tweaks to index.json ~ 1 file 143+ 46- apps/www/public/r/index.json * chore: tweaks to update-dependencies.ts ~ 1 file 20+ packages/shadcn/src/utils/updaters/update-dependencies.ts * chore: tweaks to update-dependencies.ts ~ 1 file 1- packages/shadcn/src/utils/updaters/update-dependencies.ts * chore: tweaks to update-dependencies.ts ~ 1 file 19- packages/shadcn/src/utils/updaters/update-dependencies.ts * chore: tweaks to add-components.ts update-dependencies.ts ~ 2 files 21+ 2- packages/shadcn/src/utils/add-components.ts packages/shadcn/src/utils/updaters/update-dependencies.ts * chore: tweaks to update-dependencies.ts ~ 1 file 29+ 28- packages/shadcn/src/utils/updaters/update-dependencies.ts * refactor: remove redundant code tw-animate-css already has accordion animations * chore: tweaks > migrate-icons.ts packages/shadcn/src/migrations/migrate-icons.ts * fix: formatting > add-components.ts update-dependencies.ts packages/shadcn/src/utils/add-components.ts packages/shadcn/src/utils/updaters/update-dependencies.ts * chore: add changeset --------- Co-authored-by: shadcn --- .changeset/spicy-singers-try.md | 5 +++ apps/v4/registry.json | 38 +++------------- apps/v4/scripts/build-registry.mts | 4 +- .../public/r/styles/new-york-v4/index.json | 4 +- .../shadcn/src/migrations/migrate-icons.ts | 2 +- packages/shadcn/src/utils/add-components.ts | 13 ++++-- .../src/utils/updaters/update-dependencies.ts | 44 ++++++++++++++----- 7 files changed, 58 insertions(+), 52 deletions(-) create mode 100644 .changeset/spicy-singers-try.md diff --git a/.changeset/spicy-singers-try.md b/.changeset/spicy-singers-try.md new file mode 100644 index 0000000000..fcbede33bb --- /dev/null +++ b/.changeset/spicy-singers-try.md @@ -0,0 +1,5 @@ +--- +"shadcn": patch +--- + +move tw-animate-css to devDependencies diff --git a/apps/v4/registry.json b/apps/v4/registry.json index b18af6c66d..1c71b11f69 100644 --- a/apps/v4/registry.json +++ b/apps/v4/registry.json @@ -6,10 +6,12 @@ "name": "index", "type": "registry:style", "dependencies": [ - "tw-animate-css", "class-variance-authority", "lucide-react" ], + "devDependencies": [ + "tw-animate-css" + ], "registryDependencies": [ "utils" ], @@ -27,37 +29,7 @@ "path": "registry/new-york-v4/ui/accordion.tsx", "type": "registry:ui" } - ], - "tailwind": { - "config": { - "theme": { - "extend": { - "keyframes": { - "accordion-down": { - "from": { - "height": "0" - }, - "to": { - "height": "var(--radix-accordion-content-height)" - } - }, - "accordion-up": { - "from": { - "height": "var(--radix-accordion-content-height)" - }, - "to": { - "height": "0" - } - } - }, - "animation": { - "accordion-down": "accordion-down 0.2s ease-out", - "accordion-up": "accordion-up 0.2s ease-out" - } - } - } - } - } + ] }, { "name": "alert", @@ -2833,4 +2805,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/apps/v4/scripts/build-registry.mts b/apps/v4/scripts/build-registry.mts index e583049d62..72ed29a20b 100644 --- a/apps/v4/scripts/build-registry.mts +++ b/apps/v4/scripts/build-registry.mts @@ -21,10 +21,12 @@ const registry = { name: "index", type: "registry:style", dependencies: [ - "tw-animate-css", "class-variance-authority", "lucide-react", ], + "devDependencies": [ + "tw-animate-css", + ], registryDependencies: ["utils"], cssVars: {}, files: [], diff --git a/apps/www/public/r/styles/new-york-v4/index.json b/apps/www/public/r/styles/new-york-v4/index.json index 8e85cbd881..3a8ab07687 100644 --- a/apps/www/public/r/styles/new-york-v4/index.json +++ b/apps/www/public/r/styles/new-york-v4/index.json @@ -3,10 +3,12 @@ "name": "index", "type": "registry:style", "dependencies": [ - "tw-animate-css", "class-variance-authority", "lucide-react" ], + "devDependencies": [ + "tw-animate-css" + ], "registryDependencies": [ "utils" ], diff --git a/packages/shadcn/src/migrations/migrate-icons.ts b/packages/shadcn/src/migrations/migrate-icons.ts index 91142c8446..343678ed49 100644 --- a/packages/shadcn/src/migrations/migrate-icons.ts +++ b/packages/shadcn/src/migrations/migrate-icons.ts @@ -98,7 +98,7 @@ export async function migrateIcons(config: Config) { } if (targetLibrary.package) { - await updateDependencies([targetLibrary.package], config, { + await updateDependencies([targetLibrary.package], [], config, { silent: false, }) } diff --git a/packages/shadcn/src/utils/add-components.ts b/packages/shadcn/src/utils/add-components.ts index 20639476c4..444776358b 100644 --- a/packages/shadcn/src/utils/add-components.ts +++ b/packages/shadcn/src/utils/add-components.ts @@ -103,7 +103,7 @@ async function addProjectComponents( silent: options.silent, }) - await updateDependencies(tree.dependencies, config, { + await updateDependencies(tree.dependencies, tree.devDependencies, config, { silent: options.silent, }) await updateFiles(tree.files, config, { @@ -213,9 +213,14 @@ async function addWorkspaceComponents( } // 4. Update dependencies. - await updateDependencies(component.dependencies, targetConfig, { - silent: true, - }) + await updateDependencies( + component.dependencies, + component.devDependencies, + targetConfig, + { + silent: true, + } + ) // 5. Update files. const files = await updateFiles(component.files, targetConfig, { diff --git a/packages/shadcn/src/utils/updaters/update-dependencies.ts b/packages/shadcn/src/utils/updaters/update-dependencies.ts index e4f0570f98..1006b48548 100644 --- a/packages/shadcn/src/utils/updaters/update-dependencies.ts +++ b/packages/shadcn/src/utils/updaters/update-dependencies.ts @@ -9,13 +9,16 @@ import prompts from "prompts" export async function updateDependencies( dependencies: RegistryItem["dependencies"], + devDependencies: RegistryItem["devDependencies"], config: Config, options: { silent?: boolean } ) { dependencies = Array.from(new Set(dependencies)) - if (!dependencies?.length) { + devDependencies = Array.from(new Set(devDependencies)) + + if (!dependencies?.length && !devDependencies?.length) { return } @@ -59,17 +62,34 @@ export async function updateDependencies( dependenciesSpinner?.start() - await execa( - packageManager, - [ - packageManager === "npm" ? "install" : "add", - ...(packageManager === "npm" && flag ? [`--${flag}`] : []), - ...dependencies, - ], - { - cwd: config.resolvedPaths.cwd, - } - ) + if (dependencies?.length) { + await execa( + packageManager, + [ + packageManager === "npm" ? "install" : "add", + ...(packageManager === "npm" && flag ? [`--${flag}`] : []), + ...dependencies, + ], + { + cwd: config.resolvedPaths.cwd, + } + ) + } + + if (devDependencies?.length) { + await execa( + packageManager, + [ + packageManager === "npm" ? "install" : "add", + ...(packageManager === "npm" && flag ? [`--${flag}`] : []), + "-D", + ...devDependencies, + ], + { + cwd: config.resolvedPaths.cwd, + } + ) + } dependenciesSpinner?.succeed() }