Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): support adding all components #65

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/cli/src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const addOptionsSchema = z.object({
yes: z.boolean(),
overwrite: z.boolean(),
cwd: z.string(),
all: z.boolean(),
path: z.string().optional(),
})

Expand All @@ -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 <path>', 'the path to add the component to.')
.action(async (components, opts) => {
try {
Expand All @@ -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',
Expand All @@ -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
Expand Down