Skip to content

Commit 963114e

Browse files
sramamshadcn
andauthored
feat(cli): support adding all components via CLI (#1033)
* feat: support adding all components via CLI `shadcn-ui add --all` This was manually tested to work as expected. * chore: run prettier * fix(cli): rename to all * chore: add changeset --------- Co-authored-by: shadcn <m@shadcn.com>
1 parent 0a42865 commit 963114e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.changeset/perfect-walls-dress.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"shadcn-ui": minor
3+
---
4+
5+
add --all option

packages/cli/src/commands/add.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const addOptionsSchema = z.object({
2424
yes: z.boolean(),
2525
overwrite: z.boolean(),
2626
cwd: z.string(),
27+
all: z.boolean(),
2728
path: z.string().optional(),
2829
})
2930

@@ -38,6 +39,7 @@ export const add = new Command()
3839
"the working directory. defaults to the current directory.",
3940
process.cwd()
4041
)
42+
.option("-a, --all", "add all available components", false)
4143
.option("-p, --path <path>", "the path to add the component to.")
4244
.action(async (components, opts) => {
4345
try {
@@ -65,8 +67,10 @@ export const add = new Command()
6567

6668
const registryIndex = await getRegistryIndex()
6769

68-
let selectedComponents = options.components
69-
if (!options.components?.length) {
70+
let selectedComponents = options.all
71+
? registryIndex.map((entry) => entry.name)
72+
: options.components
73+
if (!options.components?.length && !options.all) {
7074
const { components } = await prompts({
7175
type: "multiselect",
7276
name: "components",
@@ -76,6 +80,9 @@ export const add = new Command()
7680
choices: registryIndex.map((entry) => ({
7781
title: entry.name,
7882
value: entry.name,
83+
selected: options.all
84+
? true
85+
: options.components?.includes(entry.name),
7986
})),
8087
})
8188
selectedComponents = components

0 commit comments

Comments
 (0)