@@ -67,6 +67,25 @@ import { Change } from '@schematics/angular/utility/change';
6767
6868import { PatchNodePackageInstallTask } from '../utility/patch' ;
6969
70+ const routes = [
71+ {
72+ name : 'LoginFormComponent' ,
73+ path : 'login-form'
74+ } ,
75+ {
76+ name : 'ResetPasswordFormComponent' ,
77+ path : 'reset-password'
78+ } ,
79+ {
80+ name : 'CreateAccountFormComponent' ,
81+ path : 'create-account'
82+ } ,
83+ {
84+ name : 'ChangePasswordFormComponent' ,
85+ path : 'change-password'
86+ }
87+ ] ;
88+
7089const projectFilesSource = './files/src' ;
7190const workspaceFilesSource = './files' ;
7291
@@ -291,15 +310,23 @@ function updateDevextremeConfig(sourcePath: string = '') {
291310const modifyRouting = ( host : Tree , routingFilePath : string ) => {
292311 // TODO: Try to use the isolated host to generate the result string
293312 let source = getSourceFile ( host , routingFilePath ) ! ;
294- const importChange = insertImport ( source , routingFilePath , 'LoginFormComponent' , './shared/components' ) ;
295- applyChanges ( host , [ importChange ] , routingFilePath ) ;
296-
297- source = getSourceFile ( host , routingFilePath ) ! ;
298- const routes = findRoutesInSource ( source ) ! ;
299- if ( ! hasComponentInRoutes ( routes , 'login-form' ) ) {
300- const loginFormRoute = getRoute ( 'login-form' ) ;
301- insertItemToArray ( host , routingFilePath , routes , loginFormRoute ) ;
313+ const importChanges = [ ] ;
314+ importChanges . push ( insertImport ( source , routingFilePath , 'AuthGuardService' , './shared/services' ) ) ;
315+
316+ for ( const route of routes ) {
317+ importChanges . push ( insertImport ( source , routingFilePath , route . name , './shared/components' ) ) ;
302318 }
319+
320+ applyChanges ( host , importChanges , routingFilePath ) ;
321+ for ( const route of routes ) {
322+ source = getSourceFile ( host , routingFilePath ) ! ;
323+ const routeInSource = findRoutesInSource ( source ) ! ;
324+ if ( ! hasComponentInRoutes ( routeInSource , route . path ) ) {
325+ const routeToAdd = getRoute ( route . path , route . name ) ;
326+ insertItemToArray ( host , routingFilePath , routeInSource , routeToAdd ) ;
327+ }
328+ }
329+
303330} ;
304331
305332export default function ( options : any ) : Rule {
0 commit comments