Skip to content

Commit c9c1e54

Browse files
Merge branch 'dev' of https://github.com/DevExpress/devextreme-cli into dev_ng_use_standalone
2 parents 7d92176 + a734198 commit c9c1e54

File tree

5 files changed

+45
-8
lines changed

5 files changed

+45
-8
lines changed

packages/devextreme-cli/src/application.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,33 @@ 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');
56
const printHelp = require('./help').printHelp;
67

78
const 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+
1132
const 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') {

packages/devextreme-cli/src/templates/nextjs/sample-pages/home/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default function Page() {
6969
<p>Thanks for using the DevExtreme React App Template.</p>
7070
<p>
7171
<span>This application was built using </span>
72-
<a href={'https://vite.dev/guide/'} target={'_blank'} rel={'noopener noreferrer'}>create-vite</a>
72+
<a href={'https://nextjs.org/'} target={'_blank'} rel={'noopener noreferrer'}>NextJs</a>
7373
<span> and </span>
7474
<a href={'https://js.devexpress.com/Documentation/Guide/Common/DevExtreme_CLI/'} target={'_blank'} rel={'noopener noreferrer'}>DevExtreme CLI</a>
7575
<span> and includes the following DevExtreme components:</span>
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: 'React+Vite' },
5+
{ value: 'nextjs', title: 'Next.js-based' }
6+
];
7+
8+
const question = {
9+
message: 'Specify the desired React application type:',
10+
choices: choices
11+
};
12+
13+
const getReactAppType = async(defaultValue) => {
14+
return await prompts(question, choices, defaultValue);
15+
};
16+
17+
module.exports = getReactAppType;

packages/devextreme-cli/testing/env.nextjs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ function getConfig({ engine, template, fileExtension, templateExtension, transpi
2929
await runCommand('node', [
3030
path.join(process.cwd(), './index.js'),
3131
'new',
32-
'nextjs-app',
32+
'react-app',
33+
'--app-type=nextjs',
3334
`--template=${template}`,
3435
'--layout=side-nav-outer-toolbar',
3536
...additionalArguments

packages/devextreme-cli/testing/env.react.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function getConfig({ engine, template, fileExtension, templateExtension, transpi
3030
path.join(process.cwd(), './index.js'),
3131
'new',
3232
'react-app',
33+
'--app-type=vite',
3334
'--layout=side-nav-outer-toolbar',
3435
`--template=${template}`,
3536
`--transpiler=${transpiler}`,

0 commit comments

Comments
 (0)