feat(cli): support adding all components
This commit is contained in:
parent
05da2d82f3
commit
02cdee807a
|
|
@ -25,6 +25,7 @@ const addOptionsSchema = z.object({
|
||||||
yes: z.boolean(),
|
yes: z.boolean(),
|
||||||
overwrite: z.boolean(),
|
overwrite: z.boolean(),
|
||||||
cwd: z.string(),
|
cwd: z.string(),
|
||||||
|
all: z.boolean(),
|
||||||
path: z.string().optional(),
|
path: z.string().optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -39,6 +40,7 @@ export const add = new Command()
|
||||||
'the working directory. defaults to the current directory.',
|
'the working directory. defaults to the current directory.',
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
)
|
)
|
||||||
|
.option('-a, --all', 'add all available components', false)
|
||||||
.option('-p, --path <path>', 'the path to add the component to.')
|
.option('-p, --path <path>', 'the path to add the component to.')
|
||||||
.action(async (components, opts) => {
|
.action(async (components, opts) => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -64,8 +66,10 @@ export const add = new Command()
|
||||||
|
|
||||||
const registryIndex = await getRegistryIndex()
|
const registryIndex = await getRegistryIndex()
|
||||||
|
|
||||||
let selectedComponents = options.components
|
let selectedComponents = options.all
|
||||||
if (!options.components?.length) {
|
? registryIndex.map(entry => entry.name)
|
||||||
|
: options.components
|
||||||
|
if (!options.components?.length && !options.all) {
|
||||||
const { components } = await prompts({
|
const { components } = await prompts({
|
||||||
type: 'autocompleteMultiselect',
|
type: 'autocompleteMultiselect',
|
||||||
name: 'components',
|
name: 'components',
|
||||||
|
|
@ -75,6 +79,9 @@ export const add = new Command()
|
||||||
choices: registryIndex.map(entry => ({
|
choices: registryIndex.map(entry => ({
|
||||||
title: entry.name,
|
title: entry.name,
|
||||||
value: entry.name,
|
value: entry.name,
|
||||||
|
selected: options.all
|
||||||
|
? true
|
||||||
|
: options.components?.includes(entry.name),
|
||||||
})),
|
})),
|
||||||
})
|
})
|
||||||
selectedComponents = components
|
selectedComponents = components
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user