@@ -11,8 +11,8 @@ const sandboxPath = path.join(process.cwd(), './testing/sandbox/angular');
1111const appPath = path . join ( sandboxPath , appName ) ;
1212const schematicsDirectory = '../../../../devextreme-schematics' ;
1313const schematicsPath = path . join ( sandboxPath , schematicsDirectory ) ;
14- const routingFilePath = path . join ( appPath , 'src/app/app-routing.module.ts ' ) ;
15- const appComponentPath = path . join ( appPath , 'src/app/app.component.html ' ) ;
14+ const appComponentTemplatePath = path . join ( appPath , 'src/app/app.component.html ' ) ;
15+ const appComponentPath = path . join ( appPath , 'src/app/app.component.ts ' ) ;
1616
1717async function prepareSchematics ( ) {
1818 await packageManager . runInstall ( {
@@ -60,16 +60,28 @@ exports.createApp = async(depsVersionTag) => {
6060 cwd : appPath ,
6161 forceNoCmd : true
6262 } ) ;
63-
64- const data = fs . readFileSync ( routingFilePath , 'utf8' ) ;
65- const result = data . replace ( 'RouterModule.forRoot(routes)' , 'RouterModule.forRoot(routes, {useHash: true})' ) ;
66- fs . writeFileSync ( routingFilePath , result , 'utf8' ) ;
6763} ;
6864
6965exports . setLayout = ( layoutName ) => {
70- const regexToFind = / a p p - s i d e - n a v - \w + - t o o l b a r / g;
71- const newSubStr = `app-${ layoutName } ` ;
72- const data = fs . readFileSync ( appComponentPath , 'utf8' ) ;
73- const result = data . replace ( regexToFind , newSubStr ) ;
74- fs . writeFileSync ( appComponentPath , result , 'utf8' ) ;
66+ const layoutClassName = layoutName === 'side-nav-outer-toolbar'
67+ ? 'SideNavOuterToolbarComponent'
68+ : 'SideNavInnerToolbarComponent' ;
69+
70+ [
71+ {
72+ filePath : appComponentTemplatePath ,
73+ regexp : / a p p - s i d e - n a v - \w + - t o o l b a r / g,
74+ replacement : `app-${ layoutName } ` ,
75+ } ,
76+ {
77+ filePath : appComponentPath ,
78+ regexp : / S i d e N a v \w + T o o l b a r C o m p o n e n t / ,
79+ replacement : layoutClassName ,
80+ }
81+ ] . forEach ( ( { filePath, regexp, replacement } ) => {
82+ const data = fs . readFileSync ( filePath , 'utf8' ) ;
83+ const result = data . replace ( regexp , replacement ) ;
84+ fs . writeFileSync ( filePath , result , 'utf8' ) ;
85+ } ) ;
86+
7587} ;
0 commit comments