From 2feb6a04b4e7c027b8c3cdac40c2e7e705a22481 Mon Sep 17 00:00:00 2001 From: Shishir Date: Tue, 25 Jul 2023 15:11:31 +0000 Subject: [PATCH 1/4] feat: support adding all components via CLI `shadcn-ui add --all` This was manually tested to work as expected. --- packages/cli/src/commands/add.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/commands/add.ts b/packages/cli/src/commands/add.ts index 46ef641575a..0cb36270a78 100644 --- a/packages/cli/src/commands/add.ts +++ b/packages/cli/src/commands/add.ts @@ -24,6 +24,7 @@ const addOptionsSchema = z.object({ yes: z.boolean(), overwrite: z.boolean(), cwd: z.string(), + all: z.boolean(), path: z.string().optional(), }) @@ -38,6 +39,7 @@ export const add = new Command() "the working directory. defaults to the current directory.", process.cwd() ) + .option("-a, --all", "add ALL available components", false) .option("-p, --path ", "the path to add the component to.") .action(async (components, opts) => { try { @@ -65,8 +67,8 @@ export const add = new Command() const registryIndex = await getRegistryIndex() - let selectedComponents = options.components - if (!options.components?.length) { + let selectedComponents = options.all ? registryIndex.map((entry) => entry.name) : options.components + if (!options.components?.length && !options.all) { const { components } = await prompts({ type: "multiselect", name: "components", @@ -76,6 +78,7 @@ export const add = new Command() choices: registryIndex.map((entry) => ({ title: entry.name, value: entry.name, + selected: options.all ? true : options.components?.includes(entry.name) })), }) selectedComponents = components From 16e1c319bdda8bdd4753dc9468a1f0064cf48905 Mon Sep 17 00:00:00 2001 From: Shishir Date: Thu, 3 Aug 2023 17:19:02 +0000 Subject: [PATCH 2/4] chore: run prettier --- packages/cli/src/commands/add.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/commands/add.ts b/packages/cli/src/commands/add.ts index 0cb36270a78..77a4230aca7 100644 --- a/packages/cli/src/commands/add.ts +++ b/packages/cli/src/commands/add.ts @@ -67,7 +67,9 @@ export const add = new Command() const registryIndex = await getRegistryIndex() - let selectedComponents = options.all ? registryIndex.map((entry) => entry.name) : options.components + let selectedComponents = options.all + ? registryIndex.map((entry) => entry.name) + : options.components if (!options.components?.length && !options.all) { const { components } = await prompts({ type: "multiselect", @@ -78,7 +80,9 @@ export const add = new Command() choices: registryIndex.map((entry) => ({ title: entry.name, value: entry.name, - selected: options.all ? true : options.components?.includes(entry.name) + selected: options.all + ? true + : options.components?.includes(entry.name), })), }) selectedComponents = components From 99402b9c9b53908dc8b4e0b68cfe6c8f82cec4c8 Mon Sep 17 00:00:00 2001 From: shadcn Date: Tue, 19 Sep 2023 07:26:15 +0400 Subject: [PATCH 3/4] fix(cli): rename to all --- packages/cli/src/commands/add.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/commands/add.ts b/packages/cli/src/commands/add.ts index 77a4230aca7..88edfd251ac 100644 --- a/packages/cli/src/commands/add.ts +++ b/packages/cli/src/commands/add.ts @@ -39,7 +39,7 @@ export const add = new Command() "the working directory. defaults to the current directory.", process.cwd() ) - .option("-a, --all", "add ALL available components", false) + .option("-a, --all", "add all available components", false) .option("-p, --path ", "the path to add the component to.") .action(async (components, opts) => { try { From 29eae2fc1a4527780ceb3a52badaf82ba9eb76ea Mon Sep 17 00:00:00 2001 From: shadcn Date: Tue, 19 Sep 2023 07:26:56 +0400 Subject: [PATCH 4/4] chore: add changeset --- .changeset/perfect-walls-dress.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/perfect-walls-dress.md diff --git a/.changeset/perfect-walls-dress.md b/.changeset/perfect-walls-dress.md new file mode 100644 index 00000000000..33fdb7f1254 --- /dev/null +++ b/.changeset/perfect-walls-dress.md @@ -0,0 +1,5 @@ +--- +"shadcn-ui": minor +--- + +add --all option