Skip to content

Commit ec6e0f0

Browse files
prettier
1 parent 76d2053 commit ec6e0f0

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

packages/devextreme-cli/src/application.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@ const isApplicationCommand = (command) => {
99
return [ 'new', 'add' ].includes(command);
1010
};
1111

12+
const handleWrongAppType = (input, command) => {
13+
console.error(`The '${input}' application type is not valid`);
14+
printHelp(command);
15+
};
16+
17+
const createReact = async(appName, options, command) => {
18+
const appType = await getReactAppType(options['app-type']);
19+
20+
switch(appType) {
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(appType, command);
29+
}
30+
};
31+
1232
const run = async(commands, options, devextremeConfig) => {
1333
if(!commands[1]) {
1434
console.error('Command is incomplete. Please specify parameters.');
@@ -20,35 +40,18 @@ const run = async(commands, options, devextremeConfig) => {
2040
const app = commands[1];
2141
const appName = commands[2] || 'my-app';
2242

23-
const handleWrongAppType = (input) => {
24-
console.error(`The '${input}' application type is not valid`);
25-
printHelp(commands[0]);
26-
};
27-
2843
switch(app) {
2944
case 'angular-app':
3045
await angularApplication.create(appName, options);
3146
return;
3247
case 'react-app':
33-
const appType = await getReactAppType(options['app-type']);
34-
35-
switch(appType) {
36-
case 'vite':
37-
await reactApplication.create(appName, options);
38-
return;
39-
case 'nextjs':
40-
await nextjsApplication.create(appName, options);
41-
return;
42-
default:
43-
handleWrongAppType(appType);
44-
}
45-
48+
await createReact(appName, options, commands[0]);
4649
return;
4750
case 'vue-app':
4851
await vueApplication.create(appName, options);
4952
return;
5053
default:
51-
handleWrongAppType(app);
54+
handleWrongAppType(app, commands[0]);
5255
}
5356

5457
} else {

0 commit comments

Comments
 (0)