Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(dependencies): move 'tailwindcss-animate' to devDependencies #5772

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
4 changes: 3 additions & 1 deletion apps/www/public/r/styles/default/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"name": "default",
"type": "registry:style",
"dependencies": [
"tailwindcss-animate",
"class-variance-authority",
"lucide-react"
],
"devDependencies": [
"tailwindcss-animate"
],
"registryDependencies": [
"utils"
],
Expand Down
4 changes: 3 additions & 1 deletion apps/www/public/r/styles/new-york/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"name": "new-york",
"type": "registry:style",
"dependencies": [
"tailwindcss-animate",
"class-variance-authority",
"lucide-react"
],
"devDependencies": [
"tailwindcss-animate"
],
"registryDependencies": [
"utils"
],
Expand Down
4 changes: 3 additions & 1 deletion apps/www/scripts/build-registry.mts
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,12 @@ async function buildStylesIndex() {
const targetPath = path.join(REGISTRY_PATH, "styles", style.name)

const dependencies = [
"tailwindcss-animate",
"class-variance-authority",
"lucide-react",
]

const devDependencies = ["tailwindcss-animate"]

// TODO: Remove this when we migrate to lucide-react.
// if (style.name === "new-york") {
// dependencies.push("@radix-ui/react-icons")
Expand All @@ -505,6 +506,7 @@ async function buildStylesIndex() {
name: style.name,
type: "registry:style",
dependencies,
devDependencies,
registryDependencies: ["utils"],
tailwind: {
config: {
Expand Down
2 changes: 1 addition & 1 deletion packages/shadcn/src/utils/add-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function addComponents(

await updateDependencies(tree.dependencies, config, {
silent: options.silent,
})
}, tree.devDependencies)
await updateFiles(tree.files, config, {
overwrite: options.overwrite,
silent: options.silent,
Expand Down
26 changes: 25 additions & 1 deletion packages/shadcn/src/utils/updaters/update-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ export async function updateDependencies(
config: Config,
options: {
silent?: boolean
}
},
devDependencies?: RegistryItem["devDependencies"],
) {
dependencies = Array.from(new Set(dependencies))
if (!dependencies?.length) {
return
}

devDependencies = Array.from(new Set(devDependencies))

options = {
silent: false,
...options,
Expand Down Expand Up @@ -67,6 +70,27 @@ export async function updateDependencies(
}
)
dependenciesSpinner?.succeed()

if (devDependencies?.length) {
const devDependenciesSpinner = spinner(`Installing devDependencies.`, {
silent: options.silent,
})?.start()
devDependenciesSpinner?.start()

await execa(
packageManager,
[
packageManager === "npm" ? "install" : "add",
...(packageManager === "npm" && flag ? [`--${flag}`] : []),
"-D",
...devDependencies,
],
{
cwd: config.resolvedPaths.cwd,
}
)
devDependenciesSpinner?.succeed()
}
}

function isUsingReact19(config: Config) {
Expand Down