devextreme-schematics 1.2.21 → 1.2.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. package/package.json +2 -2
  2. package/src/add-app-template/index.ts +30 -0
  3. package/src/add-app-template/index_spec.ts +73 -0
  4. package/src/add-layout/files/e2e/src/app.e2e-spec.ts +14 -14
  5. package/src/add-layout/files/e2e/src/app.po.ts +11 -11
  6. package/src/add-layout/files/src/app/app-navigation.ts +1 -1
  7. package/src/add-layout/files/src/app/layouts/index.ts +3 -3
  8. package/src/add-layout/files/src/app/shared/components/change-password-form/change-password-form.component.html +8 -6
  9. package/src/add-layout/files/src/app/shared/components/create-account-form/create-account-form.component.html +9 -7
  10. package/src/add-layout/files/src/app/shared/components/footer/footer.component.ts +19 -19
  11. package/src/add-layout/files/src/app/shared/components/login-form/login-form.component.html +8 -6
  12. package/src/add-layout/files/src/app/shared/components/reset-password-form/reset-password-form.component.html +8 -6
  13. package/src/add-layout/index.ts +386 -0
  14. package/src/add-layout/index_spec.ts +340 -0
  15. package/src/add-sample-views/files/pages/home/home.component.ts +10 -10
  16. package/src/add-sample-views/files/pages/profile/profile.component.ts +33 -33
  17. package/src/add-sample-views/index.ts +141 -0
  18. package/src/add-sample-views/index_spec.ts +74 -0
  19. package/src/add-view/index.ts +165 -0
  20. package/src/add-view/index_spec.ts +155 -0
  21. package/src/install/index.ts +86 -0
  22. package/src/install/index_spec.ts +106 -0
  23. package/src/install/schema.json +1 -1
  24. package/src/utility/array.ts +3 -0
  25. package/src/utility/change.js +1 -1
  26. package/src/utility/change.ts +66 -0
  27. package/src/utility/latest-versions.js +2 -2
  28. package/src/utility/latest-versions.ts +6 -0
  29. package/src/utility/modify-json-file.ts +13 -0
  30. package/src/utility/project.ts +25 -0
  31. package/src/utility/routing.js +4 -4
  32. package/src/utility/routing.ts +44 -0
  33. package/src/utility/source.ts +16 -0
  34. package/src/utility/string.ts +5 -0
  35. package/src/utility/styles.ts +33 -0
@@ -0,0 +1,44 @@
1
+ import {
2
+ Node,
3
+ SourceFile,
4
+ SyntaxKind
5
+ } from 'typescript';
6
+
7
+ import {
8
+ strings,
9
+ basename,
10
+ normalize
11
+ } from '@angular-devkit/core';
12
+
13
+ function getRouteComponentName(pageName: string) {
14
+ return `${strings.classify(basename(normalize(pageName)))}Component`;
15
+ }
16
+
17
+ export function hasComponentInRoutes(routes: Node, name: string) {
18
+ const routesText = routes.getText();
19
+ const componentName = getRouteComponentName(name);
20
+ return routesText.indexOf(componentName) !== -1;
21
+ }
22
+
23
+ export function getRoute(name: string) {
24
+ return ` {
25
+ path: '${strings.dasherize(name)}',
26
+ component: ${getRouteComponentName(name)},
27
+ canActivate: [ AuthGuardService ]
28
+ }`;
29
+ }
30
+
31
+ function isRouteVariable(node: Node, text: string) {
32
+ return node.kind === SyntaxKind.VariableStatement &&
33
+ text.search(/\:\s*Routes/) !== -1;
34
+ }
35
+
36
+ export function findRoutesInSource(source: SourceFile) {
37
+ // TODO: try to use ast-utils/findNodes
38
+ return source.forEachChild((node) => {
39
+ const text = node.getText();
40
+ if (isRouteVariable(node, text)) {
41
+ return node;
42
+ }
43
+ });
44
+ }
@@ -0,0 +1,16 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ import {
3
+ createSourceFile,
4
+ ScriptTarget,
5
+ SourceFile
6
+ } from 'typescript';
7
+
8
+ export function getSourceFile(host: Tree, filePath: string): SourceFile | undefined {
9
+ const buffer = host.read(filePath);
10
+
11
+ if (!buffer) {
12
+ return;
13
+ }
14
+ const serializedFile = host.read(filePath)!.toString();
15
+ return createSourceFile(filePath, serializedFile, ScriptTarget.Latest, true);
16
+ }
@@ -0,0 +1,5 @@
1
+ import { strings } from '@angular-devkit/core';
2
+
3
+ export function humanize(str: string) {
4
+ return str.split('-').map((part: string) => strings.capitalize(part)).join(' ');
5
+ }
@@ -0,0 +1,33 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ import { getProjectName } from './project';
3
+ import { makeArrayUnique } from './array';
4
+
5
+ function cleanStyles(projectStyles: Array<any>, defaultStyles: any) {
6
+ return projectStyles.filter((style) => {
7
+ return style !== defaultStyles[0] && style !== defaultStyles[1];
8
+ });
9
+ }
10
+
11
+ export function addStylesToApp(host: Tree, project: string, config: any, styles?: Array<any>) {
12
+ const projectName = getProjectName(host, project);
13
+ const projectBuildOptopns = config['projects'][projectName]['architect']['build']['options'];
14
+ const defaultStyles = [
15
+ 'node_modules/devextreme/dist/css/dx.light.css',
16
+ 'node_modules/devextreme/dist/css/dx.common.css'
17
+ ];
18
+ let projectStyles = projectBuildOptopns['styles'];
19
+
20
+ if (!styles) {
21
+ styles = defaultStyles;
22
+ } else {
23
+ projectStyles = cleanStyles(projectStyles, defaultStyles);
24
+ }
25
+
26
+ styles.forEach((style) => {
27
+ projectStyles.unshift(style);
28
+ });
29
+
30
+ projectBuildOptopns['styles'] = makeArrayUnique(projectStyles);
31
+
32
+ return config;
33
+ }