@@ -2,12 +2,33 @@ const angularApplication = require('./applications/application.angular');
22const reactApplication = require ( './applications/application.react' ) ;
33const nextjsApplication = require ( './applications/application.nextjs' ) ;
44const vueApplication = require ( './applications/application.vue' ) ;
5+ const getReactAppType = require ( './utility/prompts/react-app-type' ) ;
56const printHelp = require ( './help' ) . printHelp ;
67
78const isApplicationCommand = ( command ) => {
89 return [ 'new' , 'add' ] . includes ( command ) ;
910} ;
1011
12+ const handleWrongAppType = ( appType , command ) => {
13+ console . error ( `The '${ appType } ' application type is not valid` ) ;
14+ printHelp ( command ) ;
15+ } ;
16+
17+ const createReact = async ( appName , options , command ) => {
18+ const reactAppType = await getReactAppType ( options [ 'app-type' ] ) ;
19+
20+ switch ( reactAppType ) {
21+ case 'vite' :
22+ await reactApplication . create ( appName , options ) ;
23+ return ;
24+ case 'nextjs' :
25+ await nextjsApplication . create ( appName , options ) ;
26+ return ;
27+ default :
28+ handleWrongAppType ( reactAppType , command ) ;
29+ }
30+ } ;
31+
1132const run = async ( commands , options , devextremeConfig ) => {
1233 if ( ! commands [ 1 ] ) {
1334 console . error ( 'Command is incomplete. Please specify parameters.' ) ;
@@ -24,18 +45,15 @@ const run = async(commands, options, devextremeConfig) => {
2445 await angularApplication . create ( appName , options ) ;
2546 return ;
2647 case 'react-app' :
27- await reactApplication . create ( appName , options ) ;
28- return ;
29- case 'nextjs-app' :
30- await nextjsApplication . create ( appName , options ) ;
48+ await createReact ( appName , options , commands [ 0 ] ) ;
3149 return ;
3250 case 'vue-app' :
3351 await vueApplication . create ( appName , options ) ;
3452 return ;
3553 default :
36- console . error ( `The '${ app } ' application type is not valid` ) ;
37- printHelp ( commands [ 0 ] ) ;
54+ handleWrongAppType ( app , commands [ 0 ] ) ;
3855 }
56+
3957 } else {
4058 if ( commands [ 0 ] === 'add' ) {
4159 if ( commands [ 1 ] === 'devextreme-angular' ) {
0 commit comments