UNPKG

@sprouted/create-vibes

Version:
48 lines (40 loc) 1.51 kB
import { CreateAppCommand, CreateAppOptions } from './create-app.js'; import { TemplateEngine } from '../template-engine/engine.js'; import inquirer from 'inquirer'; type AppType = 'web' | 'mobile' | 'api' | 'desktop'; export class AddAppCommand { private createAppCommand: CreateAppCommand; constructor(templateEngine: TemplateEngine) { this.createAppCommand = new CreateAppCommand(templateEngine); } async execute(appType?: string): Promise<void> { let finalType: AppType; // If no type provided, prompt for it if (!appType) { const typeAnswer = await inquirer.prompt([{ type: 'list', name: 'type', message: 'What type of app?', choices: [ { name: 'Web (React/Next.js)', value: 'web' }, { name: 'Mobile (React Native/Expo)', value: 'mobile' }, { name: 'API (Express/TypeScript)', value: 'api' }, { name: 'Desktop (Electron)', value: 'desktop' } ] }]); finalType = typeAnswer.type; } else { // Validate the provided type const validTypes = ['web', 'mobile', 'api', 'desktop']; if (!validTypes.includes(appType)) { throw new Error(`Invalid app type: ${appType}. Must be one of: ${validTypes.join(', ')}`); } finalType = appType as AppType; } // Delegate to CreateAppCommand with the type const options: CreateAppOptions = { type: finalType }; await this.createAppCommand.execute(options); } }