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
@@ -1,7 +1,9 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
- const packageManager = require('./utility/package-manager');
4
3
  const semver = require('semver');
4
+ const stripBom = require('strip-bom');
5
+ const importCwd = require('import-cwd');
6
+ const packageManager = require('./utility/package-manager');
5
7
  const lock = require('./utility/file-lock');
6
8
 
7
9
  const commands = {
@@ -10,7 +12,7 @@ const commands = {
10
12
  BUILD_META: 'export-theme-meta'
11
13
  };
12
14
 
13
- const themeBuilderPackagePath = path.join(__dirname, '..', 'node_modules', 'devextreme-themebuilder');
15
+ const themeBuilderPackagePath = path.join(process.cwd(), 'node_modules', 'devextreme-themebuilder');
14
16
 
15
17
  const scssCompiler = {
16
18
  render: (scss) => {
@@ -43,7 +45,12 @@ const createPath = filePath => {
43
45
  };
44
46
 
45
47
  const readFile = fileName => new Promise((resolve, reject) => {
46
- fs.readFile(require.resolve(fileName), 'utf8', (error, data) => {
48
+ const fullFileName = path.normalize(path.join(
49
+ themeBuilderPackagePath,
50
+ '..',
51
+ fileName
52
+ ));
53
+ fs.readFile(fullFileName, 'utf8', (error, data) => {
47
54
  error ? reject(error) : resolve(data);
48
55
  });
49
56
  });
@@ -72,6 +79,7 @@ const readInput = options => new Promise(resolve => {
72
79
  console.error(`Unable to read the ${fileName} file.`);
73
80
  } else {
74
81
  const extension = path.extname(fileName);
82
+ data = stripBom(data.toString());
75
83
  if(extension !== '.json') {
76
84
  options.data = data;
77
85
  } else {
@@ -87,63 +95,34 @@ const getMeta = (fullMeta, base, filter, baseParametersList) => {
87
95
  let result = {};
88
96
 
89
97
  for(const key in fullMeta) {
90
- if(base && baseParametersList.indexOf(key) === -1) continue;
91
- if(filter && filter.length > 0 && filter.indexOf(key) === -1) continue;
98
+ let universalKey = key.replace('$', '@');
99
+ if(base && baseParametersList.indexOf(universalKey) === -1) continue;
100
+ if(filter && filter.length > 0 && filter.indexOf(universalKey) === -1) continue;
92
101
  result[key] = fullMeta[key];
93
102
  }
94
103
 
95
104
  return result;
96
105
  };
97
106
 
98
- const installThemeBuilder = async version => {
99
- const packageJsonPath = path.join(themeBuilderPackagePath, 'package.json');
100
- const cwd = path.join(__dirname, '..');
101
- const npmrc = './.npmrc';
102
- const installationNpmrc = path.join(cwd, '.npmrc');
103
- let removeNpmrc = false;
104
-
105
- if(fs.existsSync(packageJsonPath) && require(packageJsonPath).version === version) {
106
- return;
107
+ const getInstalledPackageVersion = (packageName) => {
108
+ try {
109
+ return importCwd(`${packageName}/package.json`).version;
110
+ } catch(e) {
111
+ return null;
107
112
  }
113
+ };
108
114
 
109
- if(fs.existsSync(npmrc)) {
110
- removeNpmrc = true;
111
- fs.copyFileSync(npmrc, installationNpmrc);
115
+ const installThemeBuilder = async version => {
116
+ if(getInstalledPackageVersion('devextreme-themebuilder') === version) {
117
+ return;
112
118
  }
113
119
 
114
120
  await packageManager.installPackage(`devextreme-themebuilder@${version}`, {
115
- cwd,
116
- stdio: 'ignore'
121
+ cwd: process.cwd(),
122
+ stdio: 'inherit'
117
123
  }, {
118
- npm: ['--no-save']
124
+ npm: ['--no-save', '--fund=false', '--package-lock=false', '--omit=dev', '--omit=optional']
119
125
  });
120
-
121
- if(removeNpmrc) {
122
- fs.unlinkSync(installationNpmrc);
123
- }
124
- };
125
-
126
- const getDevExtremeInfo = (dependencies) => {
127
- const keyValue = Object.keys(dependencies).find((key) => /devextreme@/.test(key));
128
-
129
- return dependencies[keyValue];
130
- };
131
-
132
- const getDevExtremeVersion = () => {
133
- const cwd = process.cwd();
134
- const dependencies = packageManager.getDependencies({ cwd });
135
- const installedDevExtremePackageJson = path.join(cwd, 'node_modules', 'devextreme', 'package.json');
136
-
137
- if(dependencies) {
138
- const devextremeInfo = dependencies.devextreme || getDevExtremeInfo(dependencies);
139
- if(devextremeInfo) {
140
- return devextremeInfo.version;
141
- }
142
- } else if(fs.existsSync(installedDevExtremePackageJson)) {
143
- return require(installedDevExtremePackageJson).version;
144
- }
145
-
146
- return;
147
126
  };
148
127
 
149
128
  const setWidgetsOption = (options, version) => {
@@ -165,6 +144,7 @@ const getVarsFilter = (options) => {
165
144
 
166
145
  const runThemeBuilder = async rawOptions => {
167
146
  const options = await readInput(camelize(rawOptions));
147
+ const initialItems = options.items ? [...options.items] : [];
168
148
  options.reader = readFile;
169
149
  options.sassCompiler = scssCompiler;
170
150
  options.lessCompiler = require('less/lib/less-node');
@@ -177,7 +157,7 @@ const runThemeBuilder = async rawOptions => {
177
157
  options.lessCompiler.options['rootpath'] = options.assetsBasePath;
178
158
  }
179
159
 
180
- const version = options.version || getDevExtremeVersion() || 'latest';
160
+ const version = options.version || getInstalledPackageVersion('devextreme') || 'latest';
181
161
 
182
162
  await lock.acquire();
183
163
 
@@ -186,11 +166,12 @@ const runThemeBuilder = async rawOptions => {
186
166
  await installThemeBuilder(version);
187
167
  } catch(e) {
188
168
  console.log(`The devextreme-themebuilder npm package of v${version} was not installed. Please verify you are using v18.2.5 or higher and examine the installation error log to further troubleshoot the issue.`);
169
+ lock.release();
189
170
  return;
190
171
  }
191
172
 
192
- const themeBuilder = require('devextreme-themebuilder/modules/builder');
193
- const baseParameters = require('devextreme-themebuilder/modules/base-parameters');
173
+ const themeBuilder = importCwd('devextreme-themebuilder/modules/builder');
174
+ const baseParameters = importCwd('devextreme-themebuilder/modules/base-parameters');
194
175
 
195
176
  lock.release();
196
177
 
@@ -216,27 +197,24 @@ const runThemeBuilder = async rawOptions => {
216
197
  const metadata = getMeta(result.compiledMetadata, options.base, filter, baseParameters);
217
198
 
218
199
  for(const metadataKey in metadata) {
219
- const formatKey = options.fileFormat === 'scss' ? metadataKey.replace('@', '$') : metadataKey;
200
+ const formatKey = options.fileFormat === 'scss' ?
201
+ metadataKey.replace('@', '$') :
202
+ metadataKey.replace('$', '@'); // lgtm[js/incomplete-sanitization]
220
203
  content += formatKey + ': ' + metadata[metadataKey] + ';\n';
221
204
  }
222
205
  } else if(options.command === commands.BUILD_META) {
223
206
  const metadata = getMeta(result.compiledMetadata, options.base, filter, baseParameters);
224
- let exportedMeta = [];
225
-
226
- for(const metadataKey in metadata) {
227
- exportedMeta.push({ key: metadataKey, value: metadata[metadataKey] });
228
- }
229
207
 
230
208
  const meta = {
231
209
  baseTheme: [ options.themeName, options.colorScheme.replace(/-/g, '.') ].join('.'),
232
- items: exportedMeta,
233
- version: result.version
210
+ items: initialItems.filter(item => metadata[item.key]),
211
+ version: result.version,
212
+ removeExternalResources: !!options.removeExternalResources,
213
+ outputColorScheme: options.outColorScheme,
214
+ makeSwatch: !!options.makeSwatch,
215
+ widgets: options.widgets
234
216
  };
235
217
 
236
- if(result.widgets) {
237
- Object.assign(meta, { widgets: result.widgets });
238
- }
239
-
240
218
  content = JSON.stringify(meta, ' ', 4);
241
219
  }
242
220
 
@@ -258,5 +236,6 @@ const isThemeBuilderCommand = command => {
258
236
 
259
237
  module.exports = {
260
238
  run: runThemeBuilder,
261
- isThemeBuilderCommand: isThemeBuilderCommand
239
+ isThemeBuilderCommand,
240
+ getInstalledPackageVersion
262
241
  };
@@ -1,8 +1,8 @@
1
1
  const packageJson = require('../../package.json');
2
2
  module.exports = {
3
- 'devextreme': '20.1-stable',
4
- 'devextreme-react': '20.1-stable',
5
- 'devextreme-vue': '20.1-stable',
3
+ 'devextreme': '^21.2.4',
4
+ 'devextreme-react': '^21.2.4',
5
+ 'devextreme-vue': '^21.2.4',
6
6
  'devextreme-cli': packageJson.version,
7
- 'devextreme-schematics': 'next'
7
+ 'devextreme-schematics': 'latest'
8
8
  };
@@ -5,17 +5,23 @@ const yarnLockfile = require('@yarnpkg/lockfile');
5
5
  const defaultPackageManager = 'npm';
6
6
  let currentPackageManager;
7
7
 
8
+ const getLock = (cwd, fileName, parser) => {
9
+ const fullFileName = path.join(cwd, fileName);
10
+ const fileNameContent = fs.readFileSync(fullFileName, 'utf8');
11
+ return parser.parse(fileNameContent);
12
+ };
13
+
8
14
  const packageManagers = {
9
15
  npm: {
10
16
  installCommand: 'install',
11
17
  lockFileName: 'package-lock.json',
12
- getLockFile: (cwd) => require(path.join(cwd, 'package-lock.json')),
18
+ getLockFile: (cwd) => getLock(cwd, 'package-lock.json', JSON),
13
19
  getDependencies: (obj) => obj.dependencies
14
20
  },
15
21
  yarn: {
16
22
  installCommand: 'add',
17
23
  lockFileName: 'yarn.lock',
18
- getLockFile: (cwd) => yarnLockfile.parse(fs.readFileSync(path.join(cwd, 'yarn.lock'), 'utf8')),
24
+ getLockFile: (cwd) => getLock(cwd, 'yarn.lock', yarnLockfile),
19
25
  getDependencies: (obj) => obj.object
20
26
  }
21
27
  };
@@ -1,4 +1,4 @@
1
- const runPrompts = require('./utility/prompts');
1
+ const runPrompts = require('./prompts');
2
2
  const layouts = [
3
3
  { value: 'side-nav-outer-toolbar', title: 'Side navigation (outer toolbar)' },
4
4
  { value: 'side-nav-inner-toolbar', title: 'Side navigation (inner toolbar)' }
@@ -12,16 +12,16 @@ const getValidLayoutName = (layoutName) => {
12
12
  };
13
13
 
14
14
  const getLayoutInfo = (layoutName) => {
15
- const prompts = [
15
+ const questions = [
16
16
  {
17
17
  type: 'select',
18
18
  name: 'layout',
19
- message: 'What layout do you want to add?',
19
+ message: 'Specify desired application layout:',
20
20
  choices: layouts
21
21
  }
22
22
  ];
23
23
 
24
- return runPrompts(prompts, getValidLayoutName(layoutName));
24
+ return runPrompts(questions, getValidLayoutName(layoutName));
25
25
  };
26
26
 
27
27
  module.exports = {
@@ -0,0 +1,16 @@
1
+ const prompts = require('prompts');
2
+
3
+ const runPrompts = async(questions, validateValue) => {
4
+ if(validateValue) {
5
+ const optionData = {
6
+ [questions[0].name]: validateValue
7
+ };
8
+ return new Promise((resolve, reject) => {
9
+ resolve(optionData);
10
+ });
11
+ }
12
+
13
+ return await prompts(questions);
14
+ };
15
+
16
+ module.exports = runPrompts;
@@ -0,0 +1,29 @@
1
+ const runPrompts = require('./prompts');
2
+ const versions = [
3
+ { value: 'v2', title: 'Vue version (v2)' },
4
+ { value: 'v3', title: 'Vue version (v3)' }
5
+ ];
6
+
7
+ const getValidVersion = (versionValue) => {
8
+ if(!versionValue || !versions.some((version) => `v${versionValue}` === version.value)) {
9
+ return;
10
+ }
11
+ return `v${versionValue}`;
12
+ };
13
+
14
+ const getVersionInfo = (versionValue) => {
15
+ const questions = [
16
+ {
17
+ type: 'select',
18
+ name: 'version',
19
+ message: 'What version do you want?',
20
+ choices: versions
21
+ }
22
+ ];
23
+
24
+ return runPrompts(questions, getValidVersion(versionValue));
25
+ };
26
+
27
+ module.exports = {
28
+ getVersionInfo
29
+ };
@@ -4,7 +4,7 @@ module.exports = function(commandName, args = [], customConfig = {}) {
4
4
  const forceNoCmd = customConfig.forceNoCmd;
5
5
  const command = /^win/.test(process.platform) && !forceNoCmd ? `${commandName}.cmd` : commandName;
6
6
  const config = {
7
- stdio: customConfig.silent ? 'ignore' : 'inherit',
7
+ stdio: 'inherit',
8
8
  windowsVerbatimArguments: true
9
9
  };
10
10
 
@@ -15,8 +15,7 @@ module.exports = function(commandName, args = [], customConfig = {}) {
15
15
  console.log(`> ${command} ${args.join(' ')}`);
16
16
 
17
17
  return new Promise((resolve, reject) => {
18
- spawn(command, args, config).on('exit', (code) => {
19
- code ? reject(code) : resolve();
20
- });
18
+ spawn(command, args, config)
19
+ .on('exit', (code) => code ? reject(code) : resolve());
21
20
  });
22
21
  };
@@ -1,11 +0,0 @@
1
- const prompts = require('prompts');
2
-
3
- const runPrompts = async(promptsValue, options) => {
4
- if(options) {
5
- prompts.inject([options]);
6
- }
7
-
8
- return await prompts(promptsValue);
9
- };
10
-
11
- module.exports = runPrompts;