From 02cdee807a65d178897789d2d7004238cffc4d77 Mon Sep 17 00:00:00 2001 From: Dunqing Date: Wed, 20 Sep 2023 15:30:40 +0800 Subject: [PATCH] feat(cli): support adding all components --- packages/cli/src/commands/add.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/commands/add.ts b/packages/cli/src/commands/add.ts index a549a7b4b..2cb28e7f2 100644 --- a/packages/cli/src/commands/add.ts +++ b/packages/cli/src/commands/add.ts @@ -25,6 +25,7 @@ const addOptionsSchema = z.object({ yes: z.boolean(), overwrite: z.boolean(), cwd: z.string(), + all: z.boolean(), path: z.string().optional(), }) @@ -39,6 +40,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 { @@ -64,8 +66,10 @@ 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: 'autocompleteMultiselect', name: 'components', @@ -75,6 +79,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), })), }) selectedComponents = components