devextreme-cli 1.3.0-beta.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/index.js +1 -1
  2. package/package.json +32 -9
  3. package/src/.DS_Store +0 -0
  4. package/src/application.js +1 -1
  5. package/src/applications/application.angular.js +46 -10
  6. package/src/applications/application.react.js +4 -4
  7. package/src/applications/application.vue.js +103 -35
  8. package/src/commands.json +34 -25
  9. package/src/templates/.DS_Store +0 -0
  10. package/src/templates/react/application/src/App.js +3 -3
  11. package/src/templates/react/application/src/Content.js +1 -1
  12. package/src/templates/react/application/src/{NotAuthenticatedContent.js → UnauthenticatedContent.js} +1 -1
  13. package/src/templates/react/application/src/api/auth.js +1 -1
  14. package/src/templates/react/application/src/app-info.js +4 -2
  15. package/src/templates/react/application/src/components/change-password-form/change-password-form.js +1 -1
  16. package/src/templates/react/application/src/components/create-account-form/create-account-form.js +1 -1
  17. package/src/templates/react/application/src/components/footer/footer.js +2 -2
  18. package/src/templates/react/application/src/components/header/header.js +37 -37
  19. package/src/templates/react/application/src/components/login-form/login-form.js +1 -1
  20. package/src/templates/react/application/src/components/reset-password-form/reset-password-form.js +2 -2
  21. package/src/templates/react/application/src/components/side-navigation-menu/side-navigation-menu.js +5 -5
  22. package/src/templates/react/application/src/components/user-panel/user-panel.js +8 -2
  23. package/src/templates/react/application/src/dx-styles.scss +6 -1
  24. package/src/templates/react/application/src/layouts/side-nav-inner-toolbar/side-nav-inner-toolbar.js +1 -1
  25. package/src/templates/react/application/src/layouts/side-nav-outer-toolbar/side-nav-outer-toolbar.js +1 -1
  26. package/src/templates/react/application/src/layouts/single-card/single-card.js +11 -10
  27. package/src/templates/react/application/src/utils/media-query.js +1 -1
  28. package/src/templates/react/application/src/utils/patches.scss +1 -1
  29. package/src/templates/react/sample-pages/home/home.js +47 -46
  30. package/src/templates/react/sample-pages/profile/profile.js +3 -3
  31. package/src/templates/react/sample-pages/tasks/tasks.js +70 -68
  32. package/src/templates/vue-v2/.DS_Store +0 -0
  33. package/src/templates/vue-v2/application/.DS_Store +0 -0
  34. package/src/templates/vue-v2/application/devextreme.json +38 -0
  35. package/src/templates/vue-v2/application/src/.DS_Store +0 -0
  36. package/src/templates/{vue → vue-v2}/application/src/App.vue +3 -3
  37. package/src/templates/{vue → vue-v2}/application/src/app-info.js +0 -0
  38. package/src/templates/{vue → vue-v2}/application/src/app-navigation.js +0 -0
  39. package/src/templates/{vue → vue-v2}/application/src/auth.js +0 -0
  40. package/src/templates/{vue/application/src/components/the-footer.vue → vue-v2/application/src/components/app-footer.vue} +0 -0
  41. package/src/templates/{vue → vue-v2}/application/src/components/header-toolbar.vue +8 -1
  42. package/src/templates/{vue → vue-v2}/application/src/components/side-nav-menu.vue +0 -0
  43. package/src/templates/{vue → vue-v2}/application/src/components/user-panel.vue +0 -0
  44. package/src/templates/{vue → vue-v2}/application/src/dx-styles.scss +4 -0
  45. package/src/templates/{vue → vue-v2}/application/src/layouts/side-nav-inner-toolbar.vue +0 -0
  46. package/src/templates/{vue → vue-v2}/application/src/layouts/side-nav-outer-toolbar.vue +0 -0
  47. package/src/templates/{vue → vue-v2}/application/src/layouts/single-card.vue +0 -0
  48. package/src/templates/{vue → vue-v2}/application/src/main.js +0 -0
  49. package/src/templates/{vue → vue-v2}/application/src/router.js +0 -0
  50. package/src/templates/{vue → vue-v2}/application/src/themes/metadata.additional.json +0 -0
  51. package/src/templates/{vue → vue-v2}/application/src/themes/metadata.base.json +0 -0
  52. package/src/templates/{vue → vue-v2}/application/src/utils/media-query.js +0 -0
  53. package/src/templates/{vue → vue-v2}/application/src/views/change-password-form.vue +2 -3
  54. package/src/templates/{vue → vue-v2}/application/src/views/create-account-form.vue +2 -3
  55. package/src/templates/{vue → vue-v2}/application/src/views/login-form.vue +2 -3
  56. package/src/templates/{vue → vue-v2}/application/src/views/reset-password-form.vue +2 -3
  57. package/src/templates/{vue → vue-v2}/application/vue.config.js +0 -0
  58. package/src/templates/{vue → vue-v2}/page/page.vue +0 -0
  59. package/src/templates/{vue → vue-v2}/sample-pages/home.vue +5 -5
  60. package/src/templates/{vue → vue-v2}/sample-pages/profile.vue +1 -1
  61. package/src/templates/{vue → vue-v2}/sample-pages/tasks.vue +1 -0
  62. package/src/templates/vue-v3/.DS_Store +0 -0
  63. package/src/templates/vue-v3/application/.DS_Store +0 -0
  64. package/src/templates/{vue → vue-v3}/application/devextreme.json +3 -0
  65. package/src/templates/vue-v3/application/src/.DS_Store +0 -0
  66. package/src/templates/vue-v3/application/src/App.vue +101 -0
  67. package/src/templates/vue-v3/application/src/app-info.js +3 -0
  68. package/src/templates/vue-v3/application/src/app-navigation.js +21 -0
  69. package/src/templates/vue-v3/application/src/auth.js +101 -0
  70. package/src/templates/vue-v3/application/src/components/app-footer.vue +21 -0
  71. package/src/templates/vue-v3/application/src/components/header-toolbar.vue +161 -0
  72. package/src/templates/vue-v3/application/src/components/side-nav-menu.vue +204 -0
  73. package/src/templates/vue-v3/application/src/components/user-panel.vue +114 -0
  74. package/src/templates/vue-v3/application/src/dx-styles.scss +57 -0
  75. package/src/templates/vue-v3/application/src/layouts/side-nav-inner-toolbar.vue +192 -0
  76. package/src/templates/vue-v3/application/src/layouts/side-nav-outer-toolbar.vue +144 -0
  77. package/src/templates/vue-v3/application/src/layouts/single-card.vue +83 -0
  78. package/src/templates/vue-v3/application/src/main.js +10 -0
  79. package/src/templates/vue-v3/application/src/router.js +130 -0
  80. package/src/templates/vue-v3/application/src/themes/metadata.additional.json +12 -0
  81. package/src/templates/vue-v3/application/src/themes/metadata.base.json +7 -0
  82. package/src/templates/vue-v3/application/src/utils/media-query.js +33 -0
  83. package/src/templates/vue-v3/application/src/views/change-password-form.vue +115 -0
  84. package/src/templates/vue-v3/application/src/views/create-account-form.vue +155 -0
  85. package/src/templates/vue-v3/application/src/views/login-form.vue +146 -0
  86. package/src/templates/vue-v3/application/src/views/reset-password-form.vue +117 -0
  87. package/src/templates/vue-v3/application/vue.config.js +3 -0
  88. package/src/templates/vue-v3/page/page.vue +13 -0
  89. package/src/templates/vue-v3/sample-pages/home.vue +173 -0
  90. package/src/templates/vue-v3/sample-pages/profile.vue +88 -0
  91. package/src/templates/vue-v3/sample-pages/tasks.vue +133 -0
  92. package/src/themebuider.js +42 -63
  93. package/src/utility/latest-versions.js +4 -4
  94. package/src/utility/package-manager.js +8 -2
  95. package/src/{layout.js → utility/prompts/layout.js} +4 -4
  96. package/src/utility/prompts/prompts.js +16 -0
  97. package/src/utility/prompts/vue-version.js +29 -0
  98. package/src/utility/run-command.js +3 -4
  99. package/src/utility/prompts.js +0 -11
package/index.js CHANGED
@@ -23,7 +23,7 @@ if(!commands.length) {
23
23
  if(args.version) {
24
24
  console.log(packageJson.version);
25
25
  } else {
26
- console.error('The DevExtreme command is not specified.');
26
+ console.error('DevExtreme command was not specified.');
27
27
  printHelp();
28
28
  }
29
29
  process.exit();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devextreme-cli",
3
- "version": "1.3.0-beta.1",
3
+ "version": "1.3.0",
4
4
  "description": "DevExtreme CLI",
5
5
  "keywords": [
6
6
  "devexpress",
@@ -13,14 +13,23 @@
13
13
  "bin": {
14
14
  "devextreme": "index.js"
15
15
  },
16
+ "engines": {
17
+ "node": ">12.6.0",
18
+ "npm": ">6.2.0",
19
+ "yarn": ">1.21"
20
+ },
16
21
  "files": [
17
22
  "src/**/*",
18
23
  "index.js"
19
24
  ],
20
25
  "scripts": {
21
26
  "lint": "eslint ./",
22
- "test": "npm run lint && jest --runInBand",
27
+ "test": "npm run create-template && npm run lint-template && npm run test-template && npm run test-themebuilder",
28
+ "create-template": "node ./testing/creating.js",
29
+ "lint-template": "node ./testing/linting.js",
30
+ "test-template": "node ./testing/testing.js",
23
31
  "test-dev": "cross-env TEST_MODE=dev jest",
32
+ "test-themebuilder": "jest --config=./jest-themebuilder.config.js --runInBand",
24
33
  "docker:build": "docker build --rm -f \"testing/docker/Dockerfile\" -t devextreme-cli:latest \"testing/docker\"",
25
34
  "docker:run": "docker run --rm -d -p 9222:9222/tcp devextreme-cli:latest"
26
35
  },
@@ -29,22 +38,36 @@
29
38
  "license": "MIT",
30
39
  "dependencies": {
31
40
  "@yarnpkg/lockfile": "^1.1.0",
32
- "dart-sass": "^1.25.0",
41
+ "import-cwd": "^3.0.0",
33
42
  "ip": "^1.1.5",
34
43
  "less": "3.9.0",
35
44
  "minimist": "^1.2.0",
36
45
  "mustache": "^3.0.1",
37
46
  "prompts": "^2.0.4",
38
- "semver": "^5.6.0"
47
+ "sass": "^1.25.0",
48
+ "semver": "^5.6.0",
49
+ "strip-bom": "^4.0.0"
39
50
  },
40
51
  "devDependencies": {
52
+ "@typescript-eslint/parser": "^4.0.1",
53
+ "babel-eslint": "^10.1.0",
41
54
  "cross-env": "^5.2.0",
42
- "eslint": "^7.7.0",
55
+ "eslint": "^7.8.0",
56
+ "eslint-config-angular": "^0.5.0",
57
+ "eslint-plugin-angular": "^4.0.1",
43
58
  "eslint-plugin-jest": "^22.5.1",
44
- "jest": "^24.9.0",
45
- "jest-image-snapshot": "^2.8.2",
59
+ "eslint-plugin-react": "^7.20.6",
60
+ "eslint-plugin-react-hooks": "^4.1.0",
61
+ "eslint-plugin-unused-imports": "^1.1.5",
62
+ "eslint-plugin-vue": "^7.0.0-beta.2",
63
+ "eslint-stylish": "^0.2.0",
64
+ "jest": "^27.3.1",
65
+ "jest-image-snapshot": "^4.5.0",
46
66
  "puppeteer": "^2.1.1",
47
67
  "rimraf": "^2.6.3",
48
- "tree-kill": "^1.2.1"
49
- }
68
+ "tree-kill": "^1.2.1",
69
+ "tree-kill-promise": "^1.0.3",
70
+ "typescript": "^4.0.2"
71
+ },
72
+ "gitHead": "c61a31f44439fe1b0e82449a15c4db8375af34f3"
50
73
  }
package/src/.DS_Store ADDED
Binary file
@@ -9,7 +9,7 @@ const isApplicationCommand = (command) => {
9
9
 
10
10
  const run = (commands, options, devextremeConfig) => {
11
11
  if(!commands[1]) {
12
- console.error('No parameters found.');
12
+ console.error('Command is incomplete. Please specify parameters.');
13
13
  printHelp(commands[0]);
14
14
  return;
15
15
  }
@@ -1,5 +1,6 @@
1
- const getLayoutInfo = require('../layout').getLayoutInfo;
1
+ const getLayoutInfo = require('../utility/prompts/layout').getLayoutInfo;
2
2
  const path = require('path');
3
+ const moduleWorker = require('../utility/module');
3
4
  const runCommand = require('../utility/run-command');
4
5
  const semver = require('semver').SemVer;
5
6
  const fs = require('fs');
@@ -7,6 +8,7 @@ const exec = require('child_process').exec;
7
8
  const minNgCliVersion = new semver('8.0.0');
8
9
  const latestVersions = require('../utility/latest-versions');
9
10
  const schematicsVersion = latestVersions['devextreme-schematics'] || 'latest';
11
+ let globalNgCliVersion = '';
10
12
 
11
13
  async function runSchematicCommand(schematicCommand, options, evaluatingOptions) {
12
14
  const collectionName = 'devextreme-schematics';
@@ -18,19 +20,19 @@ async function runSchematicCommand(schematicCommand, options, evaluatingOptions)
18
20
  }
19
21
 
20
22
  if(!localPackageExists(collectionName)) {
21
- await runNgCommand(['add', collectionPath], evaluatingOptions);
23
+ await runNgCommand(['add', collectionPath, '--skipConfirmation=true'], evaluatingOptions);
22
24
  }
23
25
 
24
26
  const commandArguments = ['g', `${collectionName}:${schematicCommand}`];
25
27
  for(let option in options) {
26
28
  commandArguments.push(`--${option}=${options[option]}`);
27
- };
29
+ }
28
30
 
29
31
  runNgCommand(commandArguments, evaluatingOptions);
30
32
  }
31
33
 
32
34
  async function runNgCommand(commandArguments, evaluatingOptions) {
33
- const ngCommandArguments = await hasSutableNgCli() ? [] : ['-p', '@angular/cli@v9-lts'];
35
+ const ngCommandArguments = await hasSutableNgCli() ? [] : ['-p', '@angular/cli'];
34
36
 
35
37
  ngCommandArguments.push('ng', ...commandArguments);
36
38
  return runCommand('npx', ngCommandArguments, evaluatingOptions);
@@ -49,9 +51,13 @@ function localPackageExists(packageName) {
49
51
  function hasSutableNgCli() {
50
52
  return new Promise((resolve, reject) => {
51
53
  exec('ng v', (err, stdout, stderr) => {
52
- stderr || parseNgCliVersion(stdout).compare(minNgCliVersion) < 0
53
- ? resolve(false)
54
- : resolve(true);
54
+ const parsingResult = !stderr && parseNgCliVersion(stdout);
55
+ if(parsingResult && parsingResult.compare(minNgCliVersion) < 0) {
56
+ globalNgCliVersion = parsingResult.version;
57
+ resolve(true);
58
+ } else {
59
+ resolve(false);
60
+ }
55
61
  });
56
62
  });
57
63
  }
@@ -61,20 +67,33 @@ function parseNgCliVersion(stdout) {
61
67
  }
62
68
 
63
69
  const install = (options) => {
64
- runSchematicCommand('install', options);
70
+ runSchematicCommand('install', { ...options, globalNgCliVersion });
65
71
  };
66
72
 
67
73
  const create = (appName, options) => {
68
- const commandArguments = ['new', appName, '--style=scss', '--routing=false', '--skip-tests=true', '--skip-install=true'];
74
+ const commandArguments = [
75
+ 'new',
76
+ appName,
77
+ '--style=scss',
78
+ '--routing=false',
79
+ '--skip-tests=true',
80
+ '--skip-install=true',
81
+ ];
69
82
 
70
83
  getLayoutInfo(options.layout).then(layoutInfo => {
71
84
  runNgCommand(commandArguments).then(() => {
85
+ const appPath = path.join(process.cwd(), appName);
86
+
72
87
  options.resolveConflicts = 'override';
73
88
  options.updateBudgets = true;
74
89
  options.layout = layoutInfo.layout;
75
90
  addTemplate(appName, options, {
76
- cwd: path.join(process.cwd(), appName)
91
+ cwd: appPath
77
92
  });
93
+
94
+ changeMainTs(appPath);
95
+ }).catch((e) => {
96
+ console.log(e);
78
97
  });
79
98
  });
80
99
  };
@@ -92,6 +111,23 @@ const addView = (viewName, options) => {
92
111
  runSchematicCommand('add-view', schematicOptions);
93
112
  };
94
113
 
114
+ const changeMainTs = (appPath) => {
115
+ const filePath = path.join(appPath, 'src', 'main.ts');
116
+
117
+ moduleWorker.insertImport(filePath, 'devextreme/ui/themes', 'themes', true);
118
+
119
+ const fileContent = fs.readFileSync(filePath).toString();
120
+ const firstChaptStr = 'platformBrowserDynamic().bootstrapModule(AppModule)';
121
+ const lastChaptStr = '.catch(err => console.error(err));';
122
+
123
+ fs.writeFileSync(
124
+ filePath,
125
+ fileContent
126
+ .replace(firstChaptStr, `themes.initialized(() => {\n ${firstChaptStr}`)
127
+ .replace(lastChaptStr, ` ${lastChaptStr}\n});`)
128
+ );
129
+ };
130
+
95
131
  module.exports = {
96
132
  install,
97
133
  create,
@@ -1,7 +1,7 @@
1
1
  const runCommand = require('../utility/run-command');
2
2
  const path = require('path');
3
3
  const fs = require('fs');
4
- const getLayoutInfo = require('../layout').getLayoutInfo;
4
+ const getLayoutInfo = require('../utility/prompts/layout').getLayoutInfo;
5
5
  const templateCreator = require('../utility/template-creator');
6
6
  const packageManager = require('../utility/package-manager');
7
7
  const packageJsonUtils = require('../utility/package-json-utils');
@@ -19,9 +19,9 @@ const defaultStyles = [
19
19
 
20
20
  const preparePackageJsonForTemplate = (appPath, appName) => {
21
21
  const dependencies = [
22
- { name: 'node-sass', version: '^4.11.0' },
22
+ { name: 'sass', version: '^1.34.1' },
23
23
  { name: 'devextreme-cli', version: latestVersions['devextreme-cli'], dev: true },
24
- { name: 'react-router-dom', version: '^5.0.0' }
24
+ { name: 'react-router-dom', version: '^5.0.0' },
25
25
  ];
26
26
  const scripts = [
27
27
  { name: 'build-themes', value: 'devextreme build' },
@@ -42,7 +42,7 @@ const updateJsonPropName = (path, name) => {
42
42
  };
43
43
 
44
44
  const create = (appName, options) => {
45
- const commandArguments = ['create-react-app', appName];
45
+ const commandArguments = ['-p=create-react-app', 'create-react-app', appName];
46
46
 
47
47
  getLayoutInfo(options.layout).then((layoutInfo) => {
48
48
  runCommand('npx', commandArguments).then(() => {
@@ -1,6 +1,7 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
- const getLayoutInfo = require('../layout').getLayoutInfo;
3
+ const getLayoutInfo = require('../utility/prompts/layout').getLayoutInfo;
4
+ const getVersionInfo = require('../utility/prompts/vue-version').getVersionInfo;
4
5
  const templateCreator = require('../utility/template-creator');
5
6
  const packageManager = require('../utility/package-manager');
6
7
  const packageJsonUtils = require('../utility/package-json-utils');
@@ -13,14 +14,35 @@ const defaultStyles = [
13
14
  'devextreme/dist/css/dx.light.css',
14
15
  'devextreme/dist/css/dx.common.css'
15
16
  ];
17
+ const defaultVueVersion = 'v2';
18
+
19
+ const getVueVersion = () => {
20
+ const devextremeConfig = require('../utility/devextreme-config').read();
21
+
22
+ return devextremeConfig.vue
23
+ ? `v${devextremeConfig.vue.version}`
24
+ : defaultVueVersion;
25
+ };
26
+
27
+ const preparePackageJsonForTemplate = (appPath, appName, version) => {
28
+ if(!version) {
29
+ version = getVueVersion();
30
+ }
16
31
 
17
- const preparePackageJsonForTemplate = (appPath, appName) => {
18
32
  const dependencies = [
19
- { name: 'node-sass', version: '^4.11.0' },
33
+ { name: 'sass', version: '^1.34.1' },
20
34
  { name: 'vue-router', version: '^3.0.1' },
21
35
  { name: 'devextreme-cli', version: latestVersions['devextreme-cli'], dev: true },
22
- { name: 'sass-loader', version: '^7.1.0', dev: true }
36
+ { name: 'sass-loader', version: '^10', dev: true }
23
37
  ];
38
+
39
+ if(version === 'v3') {
40
+ const nameDepends = dependencies.map(d => d.name);
41
+ const indexVueRouter = nameDepends.indexOf('vue-router');
42
+
43
+ dependencies[indexVueRouter].version = '^4.0.1';
44
+ }
45
+
24
46
  const scripts = [
25
47
  { name: 'build-themes', value: 'devextreme build' },
26
48
  { name: 'postinstall', value: 'npm run build-themes' }
@@ -31,23 +53,33 @@ const preparePackageJsonForTemplate = (appPath, appName) => {
31
53
  packageJsonUtils.updateName(appPath, appName);
32
54
  };
33
55
 
34
- async function createVueApp(name) {
35
- return runCommand('npx', ['-p', '@vue/cli', 'vue', 'create', name, '--default']);
56
+ async function createVueApp(name, version) {
57
+ const argList = ['-p', '@vue/cli', 'vue', 'create', name];
58
+
59
+ if(version === defaultVueVersion) {
60
+ argList.push('--default');
61
+ } else {
62
+ argList.push('-p');
63
+ argList.push('__default_vue_3__');
64
+ }
65
+
66
+ return runCommand('npx', argList);
36
67
  }
37
68
 
38
- const create = (appName, options) => {
39
- getLayoutInfo(options.layout).then((layoutInfo) => {
40
- createVueApp(appName).then(() => {
41
- const appPath = path.join(process.cwd(), appName);
42
- const humanizedName = stringUtils.humanize(appName);
43
- const templateOptions = Object.assign({}, options, {
44
- project: humanizedName,
45
- layout: layoutInfo.layout
46
- });
47
- modifyIndexHtml(appPath, humanizedName);
48
- addTemplate(appPath, appName, templateOptions);
49
- });
69
+ const create = async(appName, options) => {
70
+ const versionInfo = await getVersionInfo(options.version);
71
+ const layoutInfo = await getLayoutInfo(options.layout);
72
+
73
+ await createVueApp(appName, versionInfo.version);
74
+
75
+ const appPath = path.join(process.cwd(), appName);
76
+ const humanizedName = stringUtils.humanize(appName);
77
+ const templateOptions = Object.assign({}, options, {
78
+ project: humanizedName,
79
+ layout: layoutInfo.layout
50
80
  });
81
+ modifyIndexHtml(appPath, humanizedName);
82
+ addTemplate(appPath, appName, templateOptions, versionInfo.version);
51
83
  };
52
84
 
53
85
  const modifyIndexHtml = (appPath, appName) => {
@@ -59,8 +91,18 @@ const modifyIndexHtml = (appPath, appName) => {
59
91
  fs.writeFileSync(indexHtmlPath, htmlContent);
60
92
  };
61
93
 
62
- const addTemplate = (appPath, appName, templateOptions) => {
63
- const templateSourcePath = path.join(__dirname, '..', 'templates', 'vue', 'application');
94
+ const getMainModulePath = (appPath) => {
95
+ const jsModule = path.join(appPath, 'src', 'main.js');
96
+
97
+ return fs.existsSync(jsModule) ? jsModule : path.join(appPath, 'src', 'main.ts');
98
+ };
99
+
100
+ const addTemplate = (appPath, appName, templateOptions, version) => {
101
+ if(!version) {
102
+ version = getVueVersion();
103
+ }
104
+
105
+ const templateSourcePath = path.join(__dirname, '..', 'templates', `vue-${version}`, 'application');
64
106
  const styles = [
65
107
  './themes/generated/theme.additional.css',
66
108
  './themes/generated/theme.base.css',
@@ -69,29 +111,34 @@ const addTemplate = (appPath, appName, templateOptions) => {
69
111
 
70
112
  templateCreator.moveTemplateFilesToProject(templateSourcePath, appPath, templateOptions);
71
113
  if(!templateOptions.empty) {
72
- addSamplePages(appPath);
114
+ addSamplePages(appPath, version);
73
115
  }
74
- preparePackageJsonForTemplate(appPath, appName);
116
+ preparePackageJsonForTemplate(appPath, appName, version);
75
117
  install({}, appPath, styles);
76
118
  };
77
119
 
78
120
  const install = (options, appPath, styles) => {
79
121
  appPath = appPath ? appPath : process.cwd();
80
- const mainModulePath = path.join(appPath, 'src', 'main.js');
81
- addStylesToApp(mainModulePath, styles || defaultStyles);
122
+ addStylesToApp(appPath, styles || defaultStyles);
82
123
  packageJsonUtils.addDevextreme(appPath, options.dxversion, 'vue');
83
124
 
84
125
  packageManager.runInstall({ cwd: appPath });
85
126
  };
86
127
 
87
- const addStylesToApp = (filePath, styles) => {
128
+ const addStylesToApp = (appPath, styles) => {
129
+ const mainModulePath = getMainModulePath(appPath);
130
+
88
131
  styles.forEach(style => {
89
- moduleUtils.insertImport(filePath, style);
132
+ moduleUtils.insertImport(mainModulePath, style);
90
133
  });
91
134
  };
92
135
 
93
- const addSamplePages = (appPath) => {
94
- const templateSourcePath = path.join(__dirname, '..', 'templates', 'vue', 'sample-pages');
136
+ const addSamplePages = (appPath, version) => {
137
+ if(!version) {
138
+ version = getVueVersion();
139
+ }
140
+
141
+ const templateSourcePath = path.join(__dirname, '..', 'templates', `vue-${version}`, 'sample-pages');
95
142
  const pagesPath = createPathToPage(appPath);
96
143
  templateCreator.moveTemplateFilesToProject(templateSourcePath, pagesPath, {});
97
144
  };
@@ -100,15 +147,35 @@ const getComponentPageName = (viewName) => {
100
147
  return `${stringUtils.classify(viewName)}`;
101
148
  };
102
149
 
103
- const getVueRoute = (viewName, componentName, pagePath) => {
104
- const components = `\n {\n layout: defaultLayout,\n content: ${componentName}\n }\n `;
105
- return `\n {\n path: "/${pagePath}",\n name: "${stringUtils.dasherize(viewName)}",\n meta: { requiresAuth: true },\n components: ${components}}`;
150
+ const getVueRoute = (viewName, componentName, pagePath, version) => {
151
+ if(!version) {
152
+ version = getVueVersion();
153
+ }
154
+
155
+ const path = `path: "/${pagePath}"`;
156
+ const name = `name: "${stringUtils.dasherize(viewName)}"`;
157
+
158
+ const metaPart = version === defaultVueVersion
159
+ ? 'meta: { requiresAuth: true }'
160
+ : 'meta: {\n requiresAuth: true,\n layout: defaultLayout\n }';
161
+
162
+ const componentPart = version === defaultVueVersion
163
+ ? `components:\n {\n layout: defaultLayout,\n content: ${componentName}\n }`
164
+ : `component: ${componentName}`;
165
+
166
+ const commonPart = `\n {\n ${path},\n ${name},\n ${metaPart},\n ${componentPart}\n }`;
167
+
168
+ return commonPart;
106
169
  };
107
170
 
108
- const getNavigationData = (viewName, componentName, icon) => {
171
+ const getNavigationData = (viewName, componentName, icon, version) => {
172
+ if(!version) {
173
+ version = getVueVersion();
174
+ }
175
+
109
176
  const pagePath = stringUtils.dasherize(viewName);
110
177
  return {
111
- route: getVueRoute(viewName, componentName, pagePath),
178
+ route: getVueRoute(viewName, componentName, pagePath, version),
112
179
  navigation: `\n {\n text: \'${stringUtils.humanize(viewName)}\',\n path: \'/${pagePath}\',\n icon: \'${icon}\'\n }`
113
180
  };
114
181
  };
@@ -124,12 +191,13 @@ const createPathToPage = (appPath) => {
124
191
  };
125
192
 
126
193
  const addView = (pageName, options) => {
194
+ const version = getVueVersion();
127
195
  const componentName = getComponentPageName(pageName);
128
196
  const pathToPage = createPathToPage(process.cwd());
129
- const pageTemplatePath = path.join(__dirname, '..', 'templates', 'vue', 'page');
197
+ const pageTemplatePath = path.join(__dirname, '..', 'templates', `vue-${version}`, 'page');
130
198
  const routingModulePath = path.join(process.cwd(), 'src', 'router.js');
131
199
  const navigationModulePath = path.join(process.cwd(), 'src', 'app-navigation.js');
132
- const navigationData = getNavigationData(pageName, componentName, options && options.icon || 'folder');
200
+ const navigationData = getNavigationData(pageName, componentName, options && options.icon || 'folder', version);
133
201
 
134
202
  templateCreator.addPageToApp(pageName, pathToPage, pageTemplatePath);
135
203
  moduleUtils.insertImport(routingModulePath, `./views/${pageName}`, componentName, true);
package/src/commands.json CHANGED
@@ -5,38 +5,41 @@
5
5
  "usage": "devextreme new <application-type> <name> [options]",
6
6
  "arguments": [{
7
7
  "name": "name",
8
- "description": "The application name"
8
+ "description": "Application name"
9
9
  }, {
10
10
  "name": "angular-app",
11
- "description": "The application type",
11
+ "description": "Application type",
12
12
  "options": [{
13
13
  "name": "--layout",
14
- "description": "Specifies the type of a DevExtreme layout to add. Available values: side-nav-outer-toolbar(default)|side-nav-inner-toolbar"
14
+ "description": "Specifies DevExtreme layout type to add. Available values: side-nav-outer-toolbar(default)|side-nav-inner-toolbar"
15
15
  }, {
16
16
  "name": "--empty",
17
- "description": "Specifies whether to skip sample views generation (default: false)"
17
+ "description": "Skips sample view generation (default: false)"
18
+ }, {
19
+ "name": "--version",
20
+ "description": "Specifies whether to generate a Vue 2 or Vue 3 application. Available values: 2 (default) and 3"
18
21
  }]
19
22
  }]
20
23
  }, {
21
24
  "name": "add",
22
- "description": "Add the DevExtreme layout template or view to an Angular application or DevExtreme to an Angular application",
25
+ "description": "Add DevExtreme layout template or view to an Angular application or DevExtreme to an Angular application",
23
26
  "usage": "devextreme add <parameter> [options]",
24
27
  "arguments": [{
25
28
  "name": "angular-template",
26
29
  "description": "Add the DevExtreme layout template to an Angular application",
27
30
  "options": [{
28
31
  "name": "--layout",
29
- "description": "Specifies the type of a DevExtreme layout to add. Available values: side-nav-outer-toolbar(default)|side-nav-inner-toolbar"
32
+ "description": "Specifies DevExtreme layout type to add. Available values: side-nav-outer-toolbar(default)|side-nav-inner-toolbar"
30
33
  }, {
31
34
  "name": "--empty",
32
- "description": "Specifies whether to skip sample views generation (default: false)"
35
+ "description": "Skips sample view generation (default: false)"
33
36
  }, {
34
37
  "name": "--resolve-conflicts",
35
- "description": "Specifies whether to override the existing app component or create a component with another name. Available values: createNew(default)|override"
38
+ "description": "Override an existing app component or create a component with a different name. Available values: createNew(default)|override"
36
39
  }]
37
40
  }, {
38
41
  "name": "view",
39
- "description": "Add a view to an Angular application with the DevExtreme layout template",
42
+ "description": "Add a view to an Angular application using the DevExtreme layout template",
40
43
  "options": [{
41
44
  "name": "--icon",
42
45
  "description": "Specifies the view's icon name (default: folder)"
@@ -51,25 +54,31 @@
51
54
  "usage": "devextreme build-theme [options]",
52
55
  "options": [{
53
56
  "name": "--base-theme",
54
- "description": "Specifies a base theme’s name (the default value is generic.light)"
57
+ "description": "Specifies base theme name (default value is generic.light)"
55
58
  }, {
56
59
  "name": "--input-file",
57
- "description": "Specifies the name of the file that contains input data (a .json file with metadata or a .less/.scss file with Bootstrap variables)"
60
+ "description": "Specifies file name with input data (a .json file with metadata or a .less/.scss file with Bootstrap variables)"
58
61
  }, {
59
62
  "name": "--make-swatch",
60
63
  "description": "If present, adds a CSS scope to each CSS rule (.dx-swatch-xxx), where xxx is the value from the --output-color-scheme parameter"
61
64
  }, {
62
65
  "name": "--output-file",
63
- "description": "Specifies the output file name"
66
+ "description": "Specifies output file name"
64
67
  }, {
65
68
  "name": "--output-color-scheme",
66
- "description": "Specifies the custom color scheme name (the default value is custom-scheme)"
69
+ "description": "Specifies custom color scheme name (default value is custom-scheme)"
67
70
  }, {
68
71
  "name": "--version",
69
- "description": "Specifies the target DevExtreme version or a tag that points to it (the default value is 'latest')"
72
+ "description": "Specifies target DevExtreme build or a tag that points to it (default value is 'latest')"
70
73
  }, {
71
74
  "name": "--widgets",
72
- "description": "Specifies a comma-separated list of widgets whose styles should be included in the resulting CSS file (available from DevExtreme 19.2.3). If this argument is not specified, styles of all widgets are included."
75
+ "description": "Specifies a comma-separated list of widgets whose styles should be included in the resulting CSS file. If this argument is not specified, styles used for all widgets are included. Available from DevExtreme v19.2.3."
76
+ }, {
77
+ "name": "--remove-external-resources",
78
+ "description": "When present, removes links to external resources, such as fonts. The theme will use local fallbacks instead. Available from DevExtreme v20.2.7."
79
+ }, {
80
+ "name": "--bootstrap-version",
81
+ "description": "Specifies Bootstrap version 4 or 5 if '--input-file' is a '.scss' file. Available from DevExtreme v21.1.5. Default value: 4."
73
82
  }]
74
83
  }, {
75
84
  "name": "export-theme-vars",
@@ -77,22 +86,22 @@
77
86
  "usage": "devextreme export-theme-vars [options]",
78
87
  "options": [{
79
88
  "name": "--base-theme",
80
- "description": "Specifies a base theme’s name (the default value is generic.light)"
89
+ "description": "Specifies base theme name (default value is generic.light)"
81
90
  }, {
82
91
  "name": "--input-file",
83
- "description": "Specifies the name of the file that contains input data (a .json file with metadata or a .less/.scss file with Bootstrap variables)"
92
+ "description": "Specifies file name with input data (a .json file with metadata or a .less/.scss file with Bootstrap variables)"
84
93
  }, {
85
94
  "name": "--output-format",
86
- "description": "Specifies the format of the output variables (less or scss) (the default value is less or the extension extracted from the --output-file value (if it contains any))"
95
+ "description": "Specifies the format of output variables (less or scss) (default value is less or the extension extracted from the --output-file value (if it contains any))"
87
96
  }, {
88
97
  "name": "--output-file",
89
98
  "description": "Specifies the output file name"
90
99
  }, {
91
100
  "name": "--base",
92
- "description": "Exports only base variables which are used to produce the derived variables"
101
+ "description": "Exports only base variables used to produce derived variables"
93
102
  }, {
94
103
  "name": "--version",
95
- "description": "Specifies the target DevExtreme version or a tag that points to it (the default value is 'latest')"
104
+ "description": "Specifies target DevExtreme build or a tag that points to it (default value is 'latest')"
96
105
  }]
97
106
  }, {
98
107
  "name": "export-theme-meta",
@@ -100,19 +109,19 @@
100
109
  "usage": "devextreme export-theme-meta [options]",
101
110
  "options": [{
102
111
  "name": "--base-theme",
103
- "description": "Specifies a base theme’s name (the default value is generic.light)"
112
+ "description": "Specifies base theme name (default value is generic.light)"
104
113
  }, {
105
114
  "name": "--input-file",
106
- "description": "Specifies the name of the file that contains input data (a .json file with metadata or a .less/.scss file with Bootstrap variables)"
115
+ "description": "Specifies file name with input data (a .json file with metadata or a .less/.scss file with Bootstrap variables)"
107
116
  }, {
108
117
  "name": "--output-file",
109
- "description": "Specifies the output file name"
118
+ "description": "Specifies output file name"
110
119
  }, {
111
120
  "name": "--base",
112
- "description": "Exports only base variables which are used to produce the derived variables"
121
+ "description": "Only exports base variables used to produce derived variables"
113
122
  }, {
114
123
  "name": "--version",
115
- "description": "Specifies the target DevExtreme version or a tag that points to it (the default value is 'latest')"
124
+ "description": "Specifies target DevExtreme build or the tag that points to it (default value is 'latest')"
116
125
  }]
117
126
  }]
118
127
  }
Binary file
@@ -6,7 +6,7 @@ import { NavigationProvider } from './contexts/navigation';
6
6
  import { AuthProvider, useAuth } from './contexts/auth';
7
7
  import { useScreenSizeClass } from './utils/media-query';
8
8
  import Content from './Content';
9
- import NotAuthenticatedContent from './NotAuthenticatedContent';
9
+ import UnauthenticatedContent from './UnauthenticatedContent';
10
10
 
11
11
  function App() {
12
12
  const { user, loading } = useAuth();
@@ -19,10 +19,10 @@ function App() {
19
19
  return <Content />;
20
20
  }
21
21
 
22
- return <NotAuthenticatedContent />;
22
+ return <UnauthenticatedContent />;
23
23
  }
24
24
 
25
- export default function () {
25
+ export default function Root() {
26
26
  const screenSizeClass = useScreenSizeClass();
27
27
 
28
28
  return (
@@ -5,7 +5,7 @@ import routes from './app-routes';
5
5
  import { <%=layout%> as SideNavBarLayout } from './layouts';
6
6
  import { Footer } from './components';
7
7
 
8
- export default function() {
8
+ export default function Content() {
9
9
  return (
10
10
  <SideNavBarLayout title={appInfo.title}>
11
11
  <Switch>
@@ -3,7 +3,7 @@ import { Switch, Route, Redirect } from 'react-router-dom';
3
3
  import { SingleCard } from './layouts';
4
4
  import { LoginForm, ResetPasswordForm, ChangePasswordForm, CreateAccountForm } from './components';
5
5
 
6
- export default function () {
6
+ export default function UnauthenticatedContent() {
7
7
  return (
8
8
  <Switch>
9
9
  <Route exact path='/login' >