Skip to content

Commit 342457f

Browse files
add prompt for create new react-app
1 parent af346e4 commit 342457f

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

packages/devextreme-cli/src/application.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +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 getReactScaffoldToolInfo = require('./utility/prompts/react-tool');
56
const printHelp = require('./help').printHelp;
67

78
const isApplicationCommand = (command) => {
@@ -16,9 +17,17 @@ const run = async(commands, options, devextremeConfig) => {
1617
}
1718

1819
if(commands[0] === 'new') {
19-
const app = commands[1];
20+
let app = commands[1];
2021
const appName = commands[2] || 'my-app';
2122

23+
if(app === 'react-app') {
24+
const reactAppType = await getReactScaffoldToolInfo(options['scaffold-tool']);
25+
26+
if(reactAppType === 'nextjs') {
27+
app = 'nextjs-app';
28+
}
29+
}
30+
2231
switch(app) {
2332
case 'angular-app':
2433
await angularApplication.create(appName, options);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const prompts = require('./prompts');
2+
3+
const choices = [
4+
{ value: 'vite', title: 'Vite' },
5+
{ value: 'nextjs', title: 'Next.js' }
6+
];
7+
8+
const question = {
9+
message: 'How would you like to scaffold your React application',
10+
choices: choices
11+
};
12+
13+
const getScaffoldToolInfo = async(defaultValue) => {
14+
return await prompts(question, choices, defaultValue);
15+
};
16+
17+
module.exports = getScaffoldToolInfo;

0 commit comments

Comments
 (0)