Skip to content

Discussion: allow overwrites on existing components #98

@rbadillap

Description

@rbadillap

Hello everyone!

Right now, to overwrite a component using shadcn as a cli, you can use the --overwrite flag.

pnpm dlx shadcn@latest add [component] --overwrite

However, this flag is not bypassed by ai-elements to the final spawnSync execution.

const fullCommand = `${commandPrefix} shadcn@latest add ${targetUrl}`;
const result = spawnSync(fullCommand, {
  stdio: "inherit",
  shell: true,
});

Which means, you cannot use ai-elements's add command if you have the component already.

I would like to suggest two possible approaches:

1. Natively supported the --overwrite flag.

Please consider this approach needs support each flag you want to integrate from shadcn's cli.

pnpm dlx ai-elements@latest add [component] --overwrite

2. By pass extra arguments to shadcn directly.

Less idiomatic, but gives more control to the user.

pnpm dlx ai-elements@latest add [component] -- --overwrite

Steps to reproduce this issue

Image

In an empty next.js project, run:

# install
pnpm dlx ai-elements@latest

# add some component
pnpm dlx ai-elements@latest add actions

# add the same component again
pnpm dlx ai-elements@latest add actions --overwrite

## ... note the cli skips the component since is already there

Thanks for reading!
Ronny

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions