( environment: Environment, targetDir: string, options: Options, )
| 3 | import type { Environment, Options } from '../types.js' |
| 4 | |
| 5 | export async function installShadcnComponents( |
| 6 | environment: Environment, |
| 7 | targetDir: string, |
| 8 | options: Options, |
| 9 | ) { |
| 10 | const s = environment.spinner() |
| 11 | |
| 12 | if (options.chosenAddOns.find((a) => a.id === 'shadcn')) { |
| 13 | const shadcnComponents = new Set<string>() |
| 14 | for (const addOn of options.chosenAddOns) { |
| 15 | if (addOn.shadcnComponents) { |
| 16 | for (const component of addOn.shadcnComponents) { |
| 17 | shadcnComponents.add(component) |
| 18 | } |
| 19 | } |
| 20 | } |
| 21 | if (options.starter) { |
| 22 | if (options.starter.shadcnComponents) { |
| 23 | for (const component of options.starter.shadcnComponents) { |
| 24 | shadcnComponents.add(component) |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | if (shadcnComponents.size > 0) { |
| 30 | s.start( |
| 31 | `Installing shadcn components (${Array.from(shadcnComponents).join(', ')})...`, |
| 32 | ) |
| 33 | environment.startStep({ |
| 34 | id: 'install-shadcn-components', |
| 35 | type: 'command', |
| 36 | message: `Installing shadcn components (${Array.from(shadcnComponents).join(', ')})...`, |
| 37 | }) |
| 38 | |
| 39 | await packageManagerExecute( |
| 40 | environment, |
| 41 | resolve(targetDir), |
| 42 | options.packageManager, |
| 43 | 'shadcn@latest', |
| 44 | ['add', '--silent', '--yes', ...Array.from(shadcnComponents)], |
| 45 | ) |
| 46 | |
| 47 | environment.finishStep( |
| 48 | 'install-shadcn-components', |
| 49 | 'Shadcn components installed', |
| 50 | ) |
| 51 | s.stop(`Installed additional shadcn components`) |
| 52 | } |
| 53 | } |
| 54 | } |
nothing calls this directly
no test coverage detected