( environment: Environment, targetDir: string, options: Options, )
| 199 | } |
| 200 | |
| 201 | async function installShadcnComponents( |
| 202 | environment: Environment, |
| 203 | targetDir: string, |
| 204 | options: Options, |
| 205 | ) { |
| 206 | if (!options.chosenAddOns.find((a) => a.id === 'shadcn')) { |
| 207 | return |
| 208 | } |
| 209 | |
| 210 | const shadcnComponents = new Set<string>() |
| 211 | for (const addOn of options.chosenAddOns) { |
| 212 | if (addOn.shadcnComponents) { |
| 213 | for (const component of addOn.shadcnComponents) { |
| 214 | shadcnComponents.add(component) |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | if (options.starter?.shadcnComponents) { |
| 219 | for (const component of options.starter.shadcnComponents) { |
| 220 | shadcnComponents.add(component) |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | if (shadcnComponents.size > 0) { |
| 225 | environment.startStep({ |
| 226 | id: 'install-shadcn-components', |
| 227 | type: 'command', |
| 228 | message: `Installing shadcn components (${Array.from(shadcnComponents).join(', ')})...`, |
| 229 | }) |
| 230 | |
| 231 | const { command, args } = getPackageManagerExecuteCommand( |
| 232 | options.packageManager, |
| 233 | 'shadcn@latest', |
| 234 | ['add', '--silent', '--yes', ...Array.from(shadcnComponents)], |
| 235 | ) |
| 236 | await environment.execute(command, args, normalizePath(targetDir)) |
| 237 | |
| 238 | environment.finishStep( |
| 239 | 'install-shadcn-components', |
| 240 | 'Shadcn components installed', |
| 241 | ) |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | async function setupIntent( |
| 246 | environment: Environment, |
no test coverage detected