Skip to content

Commit 76d2053

Browse files
apply PMs remarks
1 parent 5c69a11 commit 76d2053

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

packages/devextreme-cli/src/application.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const angularApplication = require('./applications/application.angular');
22
const reactApplication = require('./applications/application.react');
33
const nextjsApplication = require('./applications/application.nextjs');
44
const vueApplication = require('./applications/application.vue');
5-
const getReactAppType = require('./utility/prompts/react-app-type');
5+
const getReactAppType = require('./utility/prompts/app-type');
66
const printHelp = require('./help').printHelp;
77

88
const isApplicationCommand = (command) => {
@@ -17,30 +17,40 @@ const run = async(commands, options, devextremeConfig) => {
1717
}
1818

1919
if(commands[0] === 'new') {
20-
let app = commands[1];
20+
const app = commands[1];
2121
const appName = commands[2] || 'my-app';
2222

23-
if(app === 'react-app') {
24-
app = await getReactAppType(options['react-app-type']);
25-
}
23+
const handleWrongAppType = (input) => {
24+
console.error(`The '${input}' application type is not valid`);
25+
printHelp(commands[0]);
26+
};
2627

2728
switch(app) {
2829
case 'angular-app':
2930
await angularApplication.create(appName, options);
3031
return;
31-
case 'vite-app':
32-
await reactApplication.create(appName, options);
33-
return;
34-
case 'nextjs-app':
35-
await nextjsApplication.create(appName, options);
32+
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+
3646
return;
3747
case 'vue-app':
3848
await vueApplication.create(appName, options);
3949
return;
4050
default:
41-
console.error(`The '${app}' application type is not valid`);
42-
printHelp(commands[0]);
51+
handleWrongAppType(app);
4352
}
53+
4454
} else {
4555
if(commands[0] === 'add') {
4656
if(commands[1] === 'devextreme-angular') {

packages/devextreme-cli/src/utility/prompts/react-app-type.js renamed to packages/devextreme-cli/src/utility/prompts/app-type.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const prompts = require('./prompts');
22

33
const choices = [
4-
{ value: 'vite-app', title: 'React+Vite' },
5-
{ value: 'nextjs-app', title: 'Next.js-based' }
4+
{ value: 'vite', title: 'React+Vite' },
5+
{ value: 'nextjs', title: 'Next.js-based' }
66
];
77

88
const question = {

0 commit comments

Comments
 (0)