devextreme-schematics 1.2.23 → 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 (76) hide show
  1. package/LICENSE +21 -21
  2. package/package.json +7 -7
  3. package/src/add-app-template/index.d.ts +2 -2
  4. package/src/add-app-template/index.js +26 -26
  5. package/src/add-app-template/index_spec.d.ts +1 -1
  6. package/src/add-app-template/index_spec.js +70 -69
  7. package/src/add-app-template/index_spec.js.map +1 -1
  8. package/src/add-app-template/schema.json +2 -2
  9. package/src/add-layout/files/devextreme.json +1 -1
  10. package/src/add-layout/files/src/app/shared/services/screen.service.ts +1 -1
  11. package/src/add-layout/files/src/dx-styles.scss +4 -0
  12. package/src/add-layout/index.d.ts +2 -2
  13. package/src/add-layout/index.js +277 -266
  14. package/src/add-layout/index.js.map +1 -1
  15. package/src/add-layout/index.ts +28 -30
  16. package/src/add-layout/index_spec.d.ts +1 -1
  17. package/src/add-layout/index_spec.js +251 -250
  18. package/src/add-layout/index_spec.js.map +1 -1
  19. package/src/add-layout/index_spec.ts +2 -2
  20. package/src/add-layout/schema.json +2 -2
  21. package/src/add-sample-views/index.d.ts +2 -2
  22. package/src/add-sample-views/index.js +97 -88
  23. package/src/add-sample-views/index.js.map +1 -1
  24. package/src/add-sample-views/index.ts +3 -3
  25. package/src/add-sample-views/index_spec.d.ts +1 -1
  26. package/src/add-sample-views/index_spec.js +53 -52
  27. package/src/add-sample-views/index_spec.js.map +1 -1
  28. package/src/add-sample-views/index_spec.ts +1 -1
  29. package/src/add-sample-views/schema.json +1 -1
  30. package/src/add-view/index.d.ts +3 -3
  31. package/src/add-view/index.js +125 -113
  32. package/src/add-view/index.js.map +1 -1
  33. package/src/add-view/index.ts +14 -13
  34. package/src/add-view/index_spec.d.ts +1 -1
  35. package/src/add-view/index_spec.js +109 -108
  36. package/src/add-view/index_spec.js.map +1 -1
  37. package/src/add-view/schema.json +1 -1
  38. package/src/install/index.d.ts +2 -2
  39. package/src/install/index.js +76 -63
  40. package/src/install/index.js.map +1 -1
  41. package/src/install/index.ts +4 -2
  42. package/src/install/index_spec.d.ts +1 -1
  43. package/src/install/index_spec.js +96 -95
  44. package/src/install/index_spec.js.map +1 -1
  45. package/src/install/index_spec.ts +1 -1
  46. package/src/install/schema.json +1 -1
  47. package/src/utility/array.d.ts +1 -1
  48. package/src/utility/array.js +7 -6
  49. package/src/utility/array.js.map +1 -1
  50. package/src/utility/change.d.ts +7 -7
  51. package/src/utility/change.js +49 -48
  52. package/src/utility/change.js.map +1 -1
  53. package/src/utility/latest-versions.d.ts +5 -5
  54. package/src/utility/latest-versions.js +9 -8
  55. package/src/utility/latest-versions.js.map +1 -1
  56. package/src/utility/modify-json-file.d.ts +3 -2
  57. package/src/utility/modify-json-file.js +15 -11
  58. package/src/utility/modify-json-file.js.map +1 -1
  59. package/src/utility/modify-json-file.ts +6 -3
  60. package/src/utility/project.d.ts +5 -5
  61. package/src/utility/project.js +48 -25
  62. package/src/utility/project.js.map +1 -1
  63. package/src/utility/project.ts +19 -14
  64. package/src/utility/routing.d.ts +4 -4
  65. package/src/utility/routing.js +32 -31
  66. package/src/utility/routing.js.map +1 -1
  67. package/src/utility/source.d.ts +3 -3
  68. package/src/utility/source.js +13 -12
  69. package/src/utility/source.js.map +1 -1
  70. package/src/utility/string.d.ts +1 -1
  71. package/src/utility/string.js +8 -7
  72. package/src/utility/string.js.map +1 -1
  73. package/src/utility/styles.d.ts +1 -2
  74. package/src/utility/styles.js +29 -30
  75. package/src/utility/styles.js.map +1 -1
  76. package/src/utility/styles.ts +2 -5
@@ -14,8 +14,6 @@ import {
14
14
  template
15
15
  } from '@angular-devkit/schematics';
16
16
 
17
- import { of } from 'rxjs';
18
-
19
17
  import {
20
18
  SourceFile
21
19
  } from 'typescript';
@@ -39,7 +37,8 @@ import {
39
37
  } from '../utility/styles';
40
38
 
41
39
  import {
42
- modifyJSONFile
40
+ modifyJSONFile,
41
+ parseJson
43
42
  } from '../utility/modify-json-file';
44
43
 
45
44
  import {
@@ -68,7 +67,7 @@ import {
68
67
  addImportToModule, addProviderToModule, insertImport
69
68
  } from '@schematics/angular/utility/ast-utils';
70
69
 
71
- import { getWorkspace } from '@schematics/angular/utility/config';
70
+ import { getWorkspace } from '@schematics/angular/utility/workspace';
72
71
  import { Change } from '@schematics/angular/utility/change';
73
72
 
74
73
  const projectFilesSource = './files/src';
@@ -108,8 +107,8 @@ function addBuildThemeScript() {
108
107
  };
109
108
  }
110
109
 
111
- function addCustomThemeStyles(options: any, sourcePath: string) {
112
- return (host: Tree) => {
110
+ async function addCustomThemeStyles(host: Tree, options: any, sourcePath: string = '') {
111
+ const projectName = await getProjectName(host, options.project);
113
112
  modifyJSONFile(host, './angular.json', config => {
114
113
  const stylesList = [
115
114
  `${sourcePath}/dx-styles.scss`,
@@ -118,17 +117,15 @@ function addCustomThemeStyles(options: any, sourcePath: string) {
118
117
  'node_modules/devextreme/dist/css/dx.common.css'
119
118
  ];
120
119
 
121
- return addStylesToApp(host, options.project, config, stylesList);
120
+ return addStylesToApp(projectName, config, stylesList);
122
121
  });
123
122
 
124
123
  return host;
125
- };
126
124
  }
127
125
 
128
- function updateBudgets(options: any) {
129
- return (host: Tree) => {
130
- modifyJSONFile(host, './angular.json', config => {
131
- const projectName = getProjectName(host, options.project);
126
+ async function updateBudgets(host: Tree, options: any) {
127
+ const projectName = await getProjectName(host, options.project);
128
+ modifyJSONFile(host, './angular.json', config => {
132
129
  const budgets: any[] = config.projects[projectName].architect.build.configurations.production.budgets;
133
130
 
134
131
  const budget = budgets.find((item) => item.type === 'initial');
@@ -138,13 +135,12 @@ function updateBudgets(options: any) {
138
135
  }
139
136
 
140
137
  return config;
141
- });
138
+ });
142
139
 
143
- return host;
144
- };
140
+ return host;
145
141
  }
146
142
 
147
- function addViewportToBody(sourcePath: string) {
143
+ function addViewportToBody(sourcePath: string = '') {
148
144
  return (host: Tree) => {
149
145
  const indexPath = join(sourcePath, 'index.html');
150
146
  let indexContent = host.read(indexPath)!.toString();
@@ -242,7 +238,7 @@ function addPackagesToDependency(globalNgCliVersion: string) {
242
238
  }
243
239
 
244
240
  function modifyContentByTemplate(
245
- sourcePath: string,
241
+ sourcePath: string = '',
246
242
  templateSourcePath: string,
247
243
  filePath: string | null,
248
244
  templateOptions: any = {},
@@ -282,14 +278,13 @@ function modifyContentByTemplate(
282
278
  const modifiedSource = apply(url(templateSourcePath), rules);
283
279
  const resultRule = mergeWith(modifiedSource);
284
280
 
285
- return callRule(resultRule, of(host), context);
281
+ return callRule(resultRule, host, context);
286
282
  };
287
283
  }
288
284
 
289
- function updateDevextremeConfig(sourcePath: string) {
285
+ function updateDevextremeConfig(sourcePath: string = '') {
290
286
  const devextremeConfigPath = '/devextreme.json';
291
287
  const templateOptions = {
292
- engine: 'angular',
293
288
  sourcePath
294
289
  };
295
290
 
@@ -321,17 +316,20 @@ const modifyRoutingModule = (host: Tree, routingModulePath: string) => {
321
316
  };
322
317
 
323
318
  export default function(options: any): Rule {
324
- return (host: Tree) => {
325
- const project = getProjectName(host, options.project);
326
- const workspace = getWorkspace(host);
327
- const prefix = workspace.projects[project].prefix;
319
+ return async (host: Tree) => {
320
+ const ngConfig = host.read('./angular.json')!.toString();
321
+ const defaultProjectName = parseJson(ngConfig).defaultProject;
322
+ const project = await getProjectName(host, options.project);
323
+ const workspace = await getWorkspace(host);
324
+ const ngProject = workspace.projects.get(project);
325
+ const prefix = ngProject?.prefix;
328
326
  const title = humanize(project);
329
- const appPath = getApplicationPath(host, project);
330
- const sourcePath = getSourceRootPath(host, project);
327
+ const appPath = await getApplicationPath(host, project);
328
+ const sourcePath = await getSourceRootPath(host, project);
331
329
  const layout = options.layout;
332
330
  const override = options.resolveConflicts === 'override';
333
331
  const componentName = override ? 'app' : getComponentName(host, appPath);
334
- const pathToCss = sourcePath.replace(/\/?(\w)+\/?/g, '../');
332
+ const pathToCss = sourcePath?.replace(/\/?(\w)+\/?/g, '../');
335
333
  const templateOptions = {
336
334
  name: componentName,
337
335
  layout,
@@ -359,13 +357,13 @@ export default function(options: any): Rule {
359
357
  updateDevextremeConfig(sourcePath),
360
358
  updateAppModule(host, appPath),
361
359
  addBuildThemeScript(),
362
- addCustomThemeStyles(options, sourcePath),
360
+ () => addCustomThemeStyles(host, options, sourcePath) as any,
363
361
  addViewportToBody(sourcePath),
364
362
  addPackagesToDependency(options.globalNgCliVersion)
365
363
  ];
366
364
 
367
365
  if (options.updateBudgets) {
368
- rules.push(updateBudgets(options));
366
+ rules.push(() => updateBudgets(host, options) as any);
369
367
  }
370
368
 
371
369
  if (!options.skipInstall) {
@@ -375,7 +373,7 @@ export default function(options: any): Rule {
375
373
  }
376
374
 
377
375
  if (override) {
378
- if (project === workspace.defaultProject) {
376
+ if (project === defaultProjectName) {
379
377
  rules.push(modifyContentByTemplate('./', workspaceFilesSource, 'e2e/src/app.e2e-spec.ts', { title }));
380
378
  rules.push(modifyContentByTemplate('./', workspaceFilesSource, 'e2e/src/app.po.ts'));
381
379
  }
@@ -1 +1 @@
1
- export {};
1
+ export {};