devextreme-schematics 1.2.20 → 1.2.24
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.
- package/package.json +2 -2
 - package/src/add-app-template/index.ts +30 -0
 - package/src/add-app-template/index_spec.ts +73 -0
 - package/src/add-layout/files/e2e/src/app.e2e-spec.ts +14 -14
 - package/src/add-layout/files/e2e/src/app.po.ts +11 -11
 - package/src/add-layout/files/src/app/app-navigation.ts +1 -1
 - package/src/add-layout/files/src/app/layouts/index.ts +3 -3
 - package/src/add-layout/files/src/app/layouts/side-nav-inner-toolbar/side-nav-inner-toolbar.component.ts +1 -1
 - package/src/add-layout/files/src/app/layouts/side-nav-outer-toolbar/side-nav-outer-toolbar.component.ts +1 -1
 - package/src/add-layout/files/src/app/shared/components/change-password-form/change-password-form.component.html +8 -6
 - package/src/add-layout/files/src/app/shared/components/create-account-form/create-account-form.component.html +9 -7
 - package/src/add-layout/files/src/app/shared/components/footer/footer.component.ts +19 -19
 - package/src/add-layout/files/src/app/shared/components/login-form/login-form.component.html +8 -6
 - package/src/add-layout/files/src/app/shared/components/reset-password-form/reset-password-form.component.html +8 -6
 - package/src/add-layout/files/src/dx-styles.scss +4 -0
 - package/src/add-layout/index.ts +386 -0
 - package/src/add-layout/index_spec.ts +340 -0
 - package/src/add-sample-views/files/pages/home/home.component.ts +10 -10
 - package/src/add-sample-views/files/pages/profile/profile.component.ts +33 -33
 - package/src/add-sample-views/index.ts +141 -0
 - package/src/add-sample-views/index_spec.ts +74 -0
 - package/src/add-view/index.ts +165 -0
 - package/src/add-view/index_spec.ts +155 -0
 - package/src/install/index.ts +86 -0
 - package/src/install/index_spec.ts +106 -0
 - package/src/install/schema.json +1 -1
 - package/src/utility/array.ts +3 -0
 - package/src/utility/change.js +1 -1
 - package/src/utility/change.ts +66 -0
 - package/src/utility/latest-versions.js +2 -2
 - package/src/utility/latest-versions.ts +6 -0
 - package/src/utility/modify-json-file.ts +13 -0
 - package/src/utility/project.ts +25 -0
 - package/src/utility/routing.js +4 -4
 - package/src/utility/routing.ts +44 -0
 - package/src/utility/source.ts +16 -0
 - package/src/utility/string.ts +5 -0
 - 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,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 
     | 
    
         
            +
            }
         
     |