@@ -19,25 +19,36 @@ const submodule = "igniteui-live-editing-samples";
1919gulp . task ( "generate-live-editing" , async ( ) => {
2020 var appDv = argv . appDv !== undefined && argv . appDv . toLowerCase ( ) . trim ( ) === "true" ;
2121 const liveEditingOptions = appDv ?
22- {
23- platform : 'angular' ,
24- projectDir : "./projects/app-lob" ,
25- samplesDir : "./projects/app-lob/src/assets" ,
26- configGeneratorPath : "./live-editing/generators/AppDVConfigGenerators.ts" ,
27- module : {
28- moduleName : "DV_MODULE_ROUTES" , routerPath : './live-editing/Routes.ts' ,
22+ {
23+ platform : 'angular' ,
24+ projectDir : "./projects/app-lob" ,
25+ samplesDir : "./projects/app-lob/src/assets" ,
26+ configGeneratorPath : "./live-editing/generators/AppDVConfigGenerators.ts" ,
27+ module : {
28+ moduleName : "DV_MODULE_ROUTES" , routerPath : './live-editing/Routes.ts' ,
29+ }
2930 }
30- }
3131 :
32- {
33- platform : 'angular' ,
34- samplesDir : "./src/assets" ,
35- configGeneratorPath : "./live-editing/generators/ConfigGenerators.ts" ,
36- module : {
37- moduleName : "MODULE_ROUTES" , routerPath : './live-editing/Routes.ts' ,
38- } ,
39- additionalSharedStyles : [ "_variables.scss" , "_app-layout.scss" ]
40- }
32+ ( argv . appCrm ?
33+ {
34+ platform : 'angular' ,
35+ projectDir : "./projects/app-crm" ,
36+ samplesDir : "./projects/app-crm/src/assets" ,
37+ configGeneratorPath : "./live-editing/generators/AppCRMConfigGenerators.ts" ,
38+ module : {
39+ moduleName : "CRM_MODULE_ROUTES" , routerPath : './live-editing/Routes.ts' ,
40+ }
41+ }
42+ :
43+ {
44+ platform : 'angular' ,
45+ samplesDir : "./src/assets" ,
46+ configGeneratorPath : "./live-editing/generators/ConfigGenerators.ts" ,
47+ module : {
48+ moduleName : "MODULE_ROUTES" , routerPath : './live-editing/Routes.ts' ,
49+ } ,
50+ additionalSharedStyles : [ "_variables.scss" , "_app-layout.scss" ]
51+ } )
4152 await generateLiveEditing ( liveEditingOptions ) ;
4253} ) ;
4354
@@ -128,96 +139,101 @@ const getSampleNameFromFileName = (fileName, sampleBaseDir) => fileName.replace(
128139var assetsRegex = new RegExp ( / ( [ \. ] { 0 , 2 } \/ ) * a s s e t s \/ / g) ;
129140
130141const processApp = ( projectPath , dest , directoriesToExclude ) => {
131- if ( ! fs . existsSync ( submodule ) ) {
142+ if ( ! fs . existsSync ( submodule ) ) {
132143 return console . error ( "No submodule found" ) ;
133144 }
134145 const directories = [ ] ;
135146 const appExcludedDirectories = excludedDirectories . concat ( directoriesToExclude ) ;
136147 const appDir = fs . readdirSync ( projectPath + "/app" , "utf-8" ) ;
137- appDir . filter ( dir => appExcludedDirectories . indexOf ( dir ) === - 1 )
138- . forEach ( child => {
139- if ( fs . lstatSync ( `${ projectPath + "/app" } /${ child } ` ) . isDirectory ( ) ) {
148+ appDir . filter ( dir => appExcludedDirectories . indexOf ( dir ) === - 1 )
149+ . forEach ( child => {
150+ if ( fs . lstatSync ( `${ projectPath + "/app" } /${ child } ` ) . isDirectory ( ) ) {
140151 directories . push ( child ) ;
141152 }
142- } ) ;
153+ } ) ;
154+
143155 const jsonSamplesPath = path . join ( __dirname , `${ projectPath } /assets/samples` ) ;
144156 const sharedJson = JSON . parse ( fs . readFileSync ( path . join ( jsonSamplesPath , "/shared.json" ) ) ) ;
145157 const submoduleAppDest = submodule + `/${ dest } /` ;
146- if ( ! fs . existsSync ( submoduleAppDest ) ) {
158+ if ( ! fs . existsSync ( submoduleAppDest ) ) {
147159 fs . mkdirSync ( submoduleAppDest ) ;
148160 }
149161
150162 let i = 0 ;
151- return gulp . src ( [ `${ jsonSamplesPath } /*.json` , `!${ jsonSamplesPath } /shared.json` , `!${ jsonSamplesPath } /meta.json` ] )
152- . pipe ( es . map ( ( file , cb ) => {
153- fs . readFile ( file . path , 'utf-8' , ( err , content ) => {
154- // Adjust sample application bundle files
155- const jsonObj = JSON . parse ( content ) ;
156- const additionals = [ ] ;
157- const packageJson =
158- {
159- "path" : "package.json" ,
160- "hasRelativeAssetsUrls" : false ,
161- "content" : JSON . stringify ( {
162- "dependencies" : JSON . parse ( jsonObj . sampleDependencies ) ,
163- "devDependencies" : sharedJson . devDependencies } , null , 2 )
164- }
165- additionals . push ( packageJson ) ;
166-
167- if ( jsonObj . addTsConfig ) {
168- additionals . push ( sharedJson . tsConfig ) ;
169- }
170-
171- jsonObj . sampleFiles = jsonObj . sampleFiles . concat ( sharedJson . files ) . concat ( additionals ) ;
172-
173- // Configure sample application file structure
174- const fileName = file . path . substring ( file . base . length + 1 ) . replace ( ".json" , "" ) ;
175- let sampleBaseDir = fileName . indexOf ( "--" ) !== - 1 ? fileName . substring ( 0 , fileName . indexOf ( "--" ) ) : "" ;
176- if ( sampleBaseDir && ! fs . existsSync ( submoduleAppDest + sampleBaseDir ) ) {
177- fs . mkdirSync ( submoduleAppDest + sampleBaseDir ) ;
178- }
179- const sampleName = sampleBaseDir ? getSampleNameFromFileName ( fileName , sampleBaseDir ) : fileName ;
180- const sampleAppPath = submoduleAppDest + sampleBaseDir + "/" + sampleName ;
181- if ( ! fs . existsSync ( sampleAppPath ) ) {
182- fs . mkdirSync ( sampleAppPath ) ;
183- }
184-
185- // Distribute Sample Files
186- jsonObj . sampleFiles . forEach ( sampleFile => {
187- let sampleContent ;
188- const isProduction = argv . prod !== undefined && argv . prod . toLowerCase ( ) . trim ( ) === "true" ;
189- const assetsUrl = `https://${ isProduction ? "www." : "staging." } infragistics.com/${ dest } /assets/` ;
190- if ( sampleFile . hasRelativeAssetsUrls ) {
191- sampleContent = sampleFile . content . replace ( assetsRegex , assetsUrl ) ;
192- } else {
193- sampleContent = sampleFile . content ;
163+ return gulp . src ( [ `${ jsonSamplesPath } /*.json` , `!${ jsonSamplesPath } /shared.json` , `!${ jsonSamplesPath } /meta.json` ] )
164+ . pipe ( es . map ( ( file , cb ) => {
165+ fs . readFile ( file . path , 'utf-8' , ( err , content ) => {
166+ // Adjust sample application bundle files
167+ const jsonObj = JSON . parse ( content ) ;
168+ const additionals = [ ] ;
169+ const packageJson =
170+ {
171+ "path" : "package.json" ,
172+ "hasRelativeAssetsUrls" : false ,
173+ "content" : JSON . stringify ( {
174+ "dependencies" : JSON . parse ( jsonObj . sampleDependencies ) ,
175+ "devDependencies" : sharedJson . devDependencies
176+ } , null , 2 )
177+ }
178+ additionals . push ( packageJson ) ;
179+
180+ if ( jsonObj . addTsConfig ) {
181+ additionals . push ( sharedJson . tsConfig ) ;
182+ }
183+
184+ jsonObj . sampleFiles = jsonObj . sampleFiles . concat ( sharedJson . files ) . concat ( additionals ) ;
185+
186+ // Configure sample application file structure
187+ const fileName = file . path . substring ( file . base . length + 1 ) . replace ( ".json" , "" ) ;
188+ let sampleBaseDir = fileName . indexOf ( "--" ) !== - 1 ? fileName . substring ( 0 , fileName . indexOf ( "--" ) ) : "" ;
189+ if ( sampleBaseDir && ! fs . existsSync ( submoduleAppDest + sampleBaseDir ) ) {
190+ fs . mkdirSync ( submoduleAppDest + sampleBaseDir ) ;
191+ }
192+ const sampleName = sampleBaseDir ? getSampleNameFromFileName ( fileName , sampleBaseDir ) : fileName ;
193+ const sampleAppPath = submoduleAppDest + sampleBaseDir + "/" + sampleName ;
194+
195+ if ( ! fs . existsSync ( sampleAppPath ) ) {
196+ fs . mkdirSync ( sampleAppPath ) ;
197+ }
198+
199+ // Distribute Sample Files
200+ jsonObj . sampleFiles . forEach ( sampleFile => {
201+ let sampleContent ;
202+ const isProduction = argv . prod !== undefined && argv . prod . toLowerCase ( ) . trim ( ) === "true" ;
203+ const assetsUrl = `https://${ isProduction ? "www." : "staging." } infragistics.com/${ dest } /assets/` ;
204+ if ( sampleFile . hasRelativeAssetsUrls ) {
205+ sampleContent = sampleFile . content . replace ( assetsRegex , assetsUrl ) ;
206+ } else {
207+ sampleContent = sampleFile . content ;
208+ }
209+ const paths = sampleFile . path . replace ( "./" , "" ) . split ( "/" ) ;
210+ let tempPath = "" ;
211+ paths . forEach ( p => {
212+ tempPath += p + "/" ;
213+ if ( p . indexOf ( "." ) !== - 1 ) {
214+ fs . writeFileSync ( sampleAppPath + "/" + tempPath , sampleContent ) ;
215+ } else
216+ if ( ! fs . existsSync ( sampleAppPath + "/" + tempPath ) ) {
217+ fs . mkdirSync ( sampleAppPath + "/" + tempPath )
194218 }
195- const paths = sampleFile . path . replace ( "./" , "" ) . split ( "/" ) ;
196- let tempPath = "" ;
197- paths . forEach ( p => {
198- tempPath += p + "/" ;
199- if ( p . indexOf ( "." ) !== - 1 ) {
200- fs . writeFileSync ( sampleAppPath + "/" + tempPath , sampleContent ) ;
201- } else
202- if ( ! fs . existsSync ( sampleAppPath + "/" + tempPath ) ) {
203- fs . mkdirSync ( sampleAppPath + "/" + tempPath )
204- }
205- } )
206- } ) ;
207- i ++ ;
208- console . log ( `Processing ${ fileName } .json with SCSS styling` ) ;
209- cb ( null , file ) ;
210219 } )
211- } ) )
212- . on ( "error" , ( ) => console . log ( err ) )
213- . on ( "end" , ( ) => console . log ( `Geneared ${ i } applications with SCSS in ${ dest . toUpperCase ( ) } project.` ) ) ;
220+ } ) ;
221+ i ++ ;
222+ console . log ( `Processing ${ fileName } .json with SCSS styling` ) ;
223+ cb ( null , file ) ;
224+ } )
225+ } ) )
226+ . on ( "error" , ( ) => console . log ( err ) )
227+ . on ( "end" , ( ) => console . log ( `Generated ${ i } applications with SCSS in ${ dest . toUpperCase ( ) } project.` ) ) ;
214228}
215229
216- const processDemosWithScss = ( ) => processApp ( "src" , "angular-demos" , "data" ) ;
230+ const processDemosWithScss = ( ) => processApp ( "src" , "angular-demos" , "data" ) ;
217231const processDemosLobWithScss = ( ) => processApp ( "projects/app-lob/src" , "angular-demos-lob" , "services" ) ;
232+ const processDemosCrmWithScss = ( ) => processApp ( "projects/app-crm/src" , "angular-demos-grid-crm" ) ;
218233
219234let repositoryfyAngularDemos ;
220235let repositoryfyAngularDemosLob ;
236+ let repositoryfyAngularDemosCrm ;
221237
222238const cleanupAngularDemos = ( cb ) => {
223239 fsExtra . removeSync ( submodule + "/angular-demos" ) ;
@@ -230,5 +246,13 @@ const cleanupAngularDemosLob = (cb) => {
230246 fsExtra . mkdirSync ( submodule + "/angular-demos-lob" ) ;
231247 cb ( ) ;
232248}
249+
250+ const cleanupAngularDemosCrm = ( cb ) => {
251+ fsExtra . removeSync ( submodule + "/angular-demos-grid-crm" ) ;
252+ fsExtra . mkdirSync ( submodule + "/angular-demos-grid-crm" ) ;
253+ cb ( ) ;
254+ }
255+
233256exports . repositoryfyAngularDemos = repositoryfyAngularDemos = gulp . series ( cleanupAngularDemos , processDemosWithScss ) ;
234- exports . repositoryfyAngularDemosLob = repositoryfyAngularDemosLob = gulp . series ( cleanupAngularDemosLob , processDemosLobWithScss ) ;
257+ exports . repositoryfyAngularDemosLob = repositoryfyAngularDemosLob = gulp . series ( cleanupAngularDemosLob , processDemosLobWithScss ) ;
258+ exports . repositoryfyAngularDemosCrm = repositoryfyAngularDemosCrm = gulp . series ( cleanupAngularDemosCrm , processDemosCrmWithScss ) ;
0 commit comments