@@ -2,149 +2,6 @@ var fs = require('fs');
22var glob = require ( 'glob' ) ;
33var gulp = require ( "gulp" ) ;
44var shelljs = global . shelljs = global . shelljs || require ( 'shelljs' ) ;
5- const exec = require ( 'child_process' ) . exec ;
6-
7- gulp . task ( 'replace-service-link' , gulp . series ( function ( done ) {
8- var srcFiles = glob . sync (
9- './src/app/{pdfviewer,document-editor}/*.component.ts'
10- ) ;
11- var srcFilesOpen = glob . sync (
12- './OpenNewSamples/{document-editor,pdfviewer}/*.js'
13- ) ;
14- srcFiles = srcFiles . concat ( srcFilesOpen ) ;
15- for ( var src of srcFiles ) {
16- var content = fs . readFileSync ( src , 'utf8' ) ;
17- console . log ( src ) ;
18- content = content . replace ( / h t t p s : \/ \/ (?: e j 2 ) ? s e r v i c e s .s y n c f u s i o n .c o m \/ (?: t s | j s | a n g u l a r | r e a c t | v u e ) \/ (?: p r o d u c t i o n | r e l e a s e | h o t f i x | d e v e l o p m e n t ) | h t t p s : \/ \/ (?: e j 2 ) ? s e r v i c e s .s y n c f u s i o n .c o m \/ p r o d u c t i o n \/ w e b - s e r v i c e s / g, 'http://localhost:62728' ) ;
19- fs . writeFileSync ( src , content ) ;
20- }
21- done ( ) ;
22- } ) ) ;
23-
24- gulp . task ( 'ls-log' , function ( cb ) {
25- shelljs . mkdir ( '-p' , './cireports/logs' ) ;
26- exec ( 'npm ls >./cireports/logs/install.log' , function ( err , stdout , stderr ) {
27- cb ( err ) ;
28- } ) ;
29- } ) ;
30-
31- // Update the stackblitz files as per the ng structure
32- gulp . task ( 'update-stackblitz' , function ( done ) {
33-
34- const rootFiles = [ 'tsconfig.json' , 'dependencies.json' , 'angular.json' ] ,
35- angularJsonFiles = [ '"index.html"' , '"main.ts"' , '"polyfills.ts"' , '"tsconfig.app.json"' ] ;
36- let count = 0 ;
37-
38- try {
39-
40- // Read the *-stackb.json file from src/app folder
41- let filesArray = glob . sync ( __dirname + '/src/app/**/*.json' , {
42- silent : true ,
43- ignore : [ '/src/app/common/**/*.*' , '/src/app/common' ]
44- } ) ;
45-
46- if ( ! filesArray . length || ! ( filesArray . length > 0 ) ) throw ( 'No files found' ) ;
47-
48- // Update the stackblitz file structure
49- for ( let i = 0 ; i < filesArray . length ; i ++ ) {
50-
51- if ( ! fs . existsSync ( filesArray [ i ] ) || ! filesArray [ i ] . includes ( 'stackb.json' ) ) continue ;
52-
53- let fileData = JSON . parse ( fs . readFileSync ( filesArray [ i ] , 'utf8' ) ) , jsonData = { } ;
54-
55- if ( ! fileData || Object . keys ( fileData ) . length === 0 || fileData . hasOwnProperty ( "src/index.html" ) ) continue ;
56-
57- console . log ( filesArray [ i ] ) ;
58-
59- for ( const key in fileData ) {
60-
61- if ( ! fileData . hasOwnProperty ( key ) ) continue ;
62-
63- let element = fileData [ key ] ;
64- jsonData [ rootFiles . includes ( key ) && ! key . includes ( 'src' ) ? key : 'src/' + key ] = element ;
65- }
66-
67- // Add reflect-metadata package in dependencies.json data
68- if ( jsonData [ "dependencies.json" ] && ! jsonData [ "dependencies.json" ] . includes ( 'reflect-metadata' ) ) {
69- jsonData [ "dependencies.json" ] = replaceString ( jsonData [ "dependencies.json" ] , '"core-js"' , '\"reflect-metadata\": \"*\", "core-js"' ) ;
70- }
71-
72- // Update the files name in angular.json file
73- if ( jsonData [ "angular.json" ] ) {
74- angularJsonFiles . forEach ( fileName => {
75- jsonData [ "angular.json" ] = replaceString ( jsonData [ "angular.json" ] , fileName , '"src/' + fileName . slice ( 1 ) ) ;
76- } ) ;
77- }
78-
79- // Update the styles link in index.html file
80- if ( jsonData [ "src/index.html" ] && ! jsonData [ "src/index.html" ] . includes ( 'https://cdn.syncfusion.com/ej2/' ) ) {
81- jsonData [ "src/index.html" ] = replaceString ( jsonData [ "src/index.html" ] , '</head>' , '<link href="https://cdn.syncfusion.com/ej2/material.css" rel="stylesheet"/> \n</head>' ) ;
82- }
83-
84- if ( ! jsonData || Object . keys ( jsonData ) . length === 0 ) continue ;
85-
86- // Write the updated data to the file
87- fs . writeFileSync ( filesArray [ i ] , JSON . stringify ( jsonData ) , 'utf8' ) ;
88- count ++ ;
89- }
90-
91- if ( count > 0 ) console . log ( '\n' + count + ' files updated \n' ) ;
92-
93- } catch ( error ) {
94- if ( error ) console . log ( "stackblitz-update: " + error ) ;
95- }
96- done ( ) ;
97- } ) ;
98-
99- // Replace the string in the file
100- function replaceString ( data , pattern , replaceString ) {
101- try {
102- if ( data && pattern && replaceString && data . includes ( pattern ) ) {
103- return data . replace ( pattern , replaceString ) ;
104- }
105- return data ;
106- } catch ( error ) { if ( error ) console . log ( 'replaceString function: ' , error ) ; }
107- }
108-
109- gulp . task ( 'hide-license' , function ( done ) {
110- if ( process . env . samples === 'true' ) {
111- console . log ( 'Skipped the hide license task for ES Build' ) ;
112- done ( ) ;
113- } else {
114- try {
115- let patternArray = [ 'it.validate()' , 'licenseValidator.validate()' ] ;
116- let pathArray = [
117- require . resolve ( '@syncfusion/ej2-base/dist/ej2-base.umd.min.js' ) ,
118- require . resolve ( '@syncfusion/ej2-base/dist/es6/ej2-base.es5.js' ) ,
119- require . resolve ( '@syncfusion/ej2-base/dist/es6/ej2-base.es2015.js' ) ,
120- require . resolve ( '@syncfusion/ej2-base/src/validate-lic.js' )
121- ] ;
122-
123- for ( let i in pathArray ) { replaceStringInFile ( pathArray [ i ] , patternArray [ i === '0' ? 0 : 1 ] , 'true' ) ; }
124-
125- } catch ( error ) { if ( error ) console . log ( 'Gulp task to hide license ' , error ) ; }
126- done ( ) ;
127- }
128- } ) ;
129-
130- function replaceStringInFile ( filePath , pattern , replaceString ) {
131- try {
132- if ( fs . existsSync ( filePath ) ) {
133- const data = fs . readFileSync ( filePath , 'utf8' ) ;
134- if ( data && pattern && replaceString && data . includes ( pattern ) ) {
135- fs . writeFileSync ( filePath , data . replace ( pattern , replaceString ) , 'utf8' ) ;
136- }
137- }
138- } catch ( error ) { if ( error ) console . log ( 'replaceStringInFile function: ' , error ) ; }
139- }
140-
141- gulp . task ( 'copy-source' , function ( done ) {
142- gulp . src ( [ 'src/app/**/*' , '!src/app/common' , '!src/app/common/**/*.*' ] )
143- . pipe ( gulp . dest ( 'src/source' ) )
144- . on ( 'end' , function ( ) {
145- done ( ) ;
146- } ) ;
147- } ) ;
1485
1496gulp . task ( 'build' , gulp . series ( function ( done ) {
1507 shelljs . exec ( 'npm run build:prod' , function ( exitCode , error ) {
@@ -153,22 +10,6 @@ gulp.task('build', gulp.series(function (done) {
15310 } ) ;
15411} ) ) ;
15512
156- // gulp.task('serve', ['copy-source', 'styles-all'], function () {
157- // shelljs.exec('npm run start');
158- // });
159-
160- gulp . task ( 'move' , function ( done ) {
161- shelljs . cp ( '-rf' , './OpenNewSamples/*' , './output' ) ;
162- shelljs . cp ( '-rf' , './sitemap-demos.xml' , './output' ) ;
163- var mainBundle ;
164- if ( fs . existsSync ( './output/main.js' ) ) {
165- mainBundle = fs . readFileSync ( './output/main.js' , 'utf8' ) ;
166- }
167- mainBundle = mainBundle . replace ( / \( \/ a s s e t s / g, '(./assets' ) . replace ( / \( ' \/ a s s e t s / g, `('./assets` ) ;
168- fs . writeFileSync ( './output/main.js' , mainBundle , 'utf8' ) ;
169- done ( ) ;
170- } ) ;
171-
17213gulp . task ( 'styles-replace' , gulp . series ( function ( done ) {
17314 var nos = glob . sync ( 'node_modules/@syncfusion/ej2/*.css' ) ;
17415 for ( var j = 0 ; j < nos . length ; j ++ ) {
@@ -178,58 +19,6 @@ gulp.task('styles-replace', gulp.series(function (done) {
17819 done ( ) ;
17920} ) ) ;
18021
181- gulp . task ( 'SEO-changes' , gulp . series ( function ( done ) {
182- var newWindowSamples = glob . sync ( './OpenNewSamples/**/**/index.html' ) ;
183- var samplsListJson = JSON . parse ( fs . readFileSync ( './sampleOrder.json' ) ) ;
184- var localCss = `<link href="/angular/demos/styles/OpenNew.css" rel="stylesheet">` ;
185- var localCssRegex = / ( .* ) s t y l e s \/ O p e n N e w .c s s \" r e l \= \" s t y l e s h e e t ( .* ) / g;
186-
187- for ( var i = 0 ; i < newWindowSamples . length ; i ++ ) {
188-
189- var indexFile = fs . readFileSync ( newWindowSamples [ i ] , 'utf8' ) ;
190- var scriptMatch = indexFile . match ( / < s c r i p t \b [ ^ > ] * > ( [ \s \S ] * ?) < \/ s c r i p t > / g) ;
191- for ( var j = 0 ; j < scriptMatch . length ; j ++ ) {
192- if ( scriptMatch [ j ] . includes ( 'var baseref =' ) ) {
193- indexFile = indexFile . replace ( scriptMatch [ j ] , `<base href="/angular/demos/${ newWindowSamples [ i ] . replace ( './OpenNewSamples/' , '' ) . replace ( 'index.html' , '' ) } ">` ) ;
194- }
195- }
196- if ( samplsListJson [ newWindowSamples [ i ] . split ( '/' ) [ 2 ] ] === undefined ) {
197- console . log ( `${ i } ------${ newWindowSamples [ i ] } ` ) ;
198- }
199- var ControlName = samplsListJson [ newWindowSamples [ i ] . split ( '/' ) [ 2 ] ] . ControlName ;
200- var sampleName = samplsListJson [ newWindowSamples [ i ] . split ( '/' ) [ 2 ] ] . Samples [ newWindowSamples [ i ] . split ( '/' ) [ 3 ] ] ;
201-
202- indexFile = indexFile . replace ( / < m e t a n a m e = " d e s c r i p t i o n " ( .* ) / g, '' ) ;
203- indexFile = indexFile . replace ( / < h 1 c l a s s = " s b - b r e a d - c r u m b - t e x t " > ( .* ) / g, '' ) ;
204-
205- var metaTagTemplate = `<meta name="description" content="This example demonstrates the ${ sampleName } in Angular ${ ControlName } Component. Explore here for more details." />` ;
206- indexFile = indexFile . replace ( / < t i t l e > ( .* ) / g, '<title>' + 'Angular ' + ControlName + ' ' + sampleName + ' Example - Syncfusion Demos</title>\n\t' + metaTagTemplate ) ;
207-
208- var headerDesc = '' ;
209- if ( newWindowSamples [ i ] . indexOf ( 'sidebar' ) >= 0 ) {
210- headerDesc = '' ;
211- } else {
212- headerDesc = `<h1 class="sb-bread-crumb-text">Example of ${ sampleName } in Angular ${ ControlName } Component</h1>` ;
213- }
214-
215- indexFile = indexFile . replace ( `<app-root></app-root>` , headerDesc + `\n\t<app-root></app-root>` ) ;
216-
217- if ( ! ( localCssRegex . test ( indexFile ) ) ) {
218- indexFile = indexFile . replace ( / ( .* ) s t y l e s \/ m a t e r i a l .c s s \" r e l \= \" s t y l e s h e e t ( .* ) / g, '<link href="/angular/demos/styles/material.css" rel="stylesheet">\n' + localCss )
219- }
220-
221- indexFile = indexFile . replace ( '<script src="../vendors.bundle.js"></script>' , `<script src="/angular/demos/${ newWindowSamples [ i ] . split ( '/' ) [ 2 ] } /vendors.bundle.js"></script>` ) ;
222- indexFile = indexFile . replace ( '<script src="./main.bundle.js"></script>' , `<script src="/angular/demos/${ newWindowSamples [ i ] . split ( '/' ) [ 2 ] } /${ newWindowSamples [ i ] . split ( '/' ) [ 3 ] } /main.bundle.js"></script>` ) ;
223-
224- indexFile = indexFile . replace ( / < h e a d > / , `<head>
225- <script>function _0xde02(){var _0x5f2ba3=['9TYJyPJ','8519130vccODC','length','indexOf','642676nYqdEN','split','1588446jBtanR','1207348wihLFo','204856gJKXOd','1996386mrrBRO','7202905WqbCdL','href','ej2.syncfusion.com','36VGEwVI'];_0xde02=function(){return _0x5f2ba3;};return _0xde02();}var _0x5c03ce=_0x2e99;(function(_0x4610ba,_0x2edf38){var _0x2bab05=_0x2e99,_0x295339=_0x4610ba();while(!![]){try{var _0x258b1a=parseInt(_0x2bab05(0xd5))/0x1+-parseInt(_0x2bab05(0xd7))/0x2+parseInt(_0x2bab05(0xd1))/0x3*(parseInt(_0x2bab05(0xd8))/0x4)+-parseInt(_0x2bab05(0xdb))/0x5+parseInt(_0x2bab05(0xd2))/0x6+parseInt(_0x2bab05(0xda))/0x7+-parseInt(_0x2bab05(0xd9))/0x8*(parseInt(_0x2bab05(0xd0))/0x9);if(_0x258b1a===_0x2edf38)break;else _0x295339['push'](_0x295339['shift']());}catch(_0x5cb54d){_0x295339['push'](_0x295339['shift']());}}}(_0xde02,0xdfa28));var bypassKey=[0x73,0x79,0x6e,0x63,0x66,0x75,0x73,0x69,0x6f,0x6e,0x2e,0x69,0x73,0x4c,0x69,0x63,0x56,0x61,0x6c,0x69,0x64,0x61,0x74,0x65,0x64];function _0x2e99(_0x50a339,_0x56f268){var _0xde0271=_0xde02();return _0x2e99=function(_0x2e9975,_0x55ee02){_0x2e9975=_0x2e9975-0xce;var _0x32119=_0xde0271[_0x2e9975];return _0x32119;},_0x2e99(_0x50a339,_0x56f268);}function convertToChar(_0x3e5688){var _0x37d95d=_0x2e99,_0x30ade7='';for(var _0x30d200=0x0,_0x532558=_0x3e5688;_0x30d200<_0x532558[_0x37d95d(0xd3)];_0x30d200++){var _0xc98512=_0x532558[_0x30d200];_0x30ade7+=String['fromCharCode'](_0xc98512);}return _0x30ade7;}location[_0x5c03ce(0xce)]&&location['href'][_0x5c03ce(0xd4)](_0x5c03ce(0xcf))!==-0x1&&(window[convertToChar(bypassKey)['split']('.')[0x0]]={},window[convertToChar(bypassKey)[_0x5c03ce(0xd6)]('.')[0x0]][convertToChar(bypassKey)[_0x5c03ce(0xd6)]('.')[0x1]]=!![]);</script>` ) ;
226-
227- fs . writeFileSync ( newWindowSamples [ i ] , indexFile . replace ( 'Essential JS 2' , 'Essential Studio' ) , 'utf8' ) ;
228- }
229- done ( ) ;
230- }
231- ) ) ;
232-
23322gulp . task ( 'Angular-latest-changes' , gulp . series ( function ( done ) {
23423 var componentTs = glob . sync ( './src/app/**/**.component.ts' , {
23524 silent : true ,
@@ -256,45 +45,3 @@ gulp.task('Angular-latest-changes', gulp.series(function (done) {
25645 }
25746 done ( ) ;
25847} ) ) ;
259-
260- gulp . task ( 'create-sampleList' , gulp . series ( function ( done ) {
261-
262- var newWindowSamples = glob . sync ( './src/app/**/**.module.ts' , {
263- silent : true ,
264- ignore : [ './src/app/app.module.ts' , './src/app/common/shared.module.ts' ]
265- } ) ;
266-
267- var temp = `{{path}}:{{name}}`
268- for ( var i = 0 ; i < newWindowSamples . length ; i ++ ) {
269- var sampleJson = '' ;
270- var indexFile = fs . readFileSync ( newWindowSamples [ i ] , 'utf8' ) ;
271- paths = indexFile . match ( / p a t h ( | ) \: [ ^ , ] + / g) ;
272- names = indexFile . match ( / n a m e ( | | ' | ' ) \: [ ^ , ] + / g) ;
273- for ( var j = 0 ; j < paths . length ; j ++ ) {
274- var template = temp ;
275- template = template . replace ( `{{path}}` , `"${ paths [ j ] . replace ( / p a t h ( | ) \: [ ^ t h e m e ] + t h e m e / g, '' ) . replace ( '\'' , '' ) } "` ) ;
276- template = template . replace ( `{{name}}` , `"${ names [ j ] . replace ( / n a m e ( | | ' | ' ) \: [ ^ ' ] + \' / g, '' ) . replace ( '\'' , '' ) } "` ) ;
277- sampleJson += template + `,\n` ;
278- }
279- console . log ( i + `----------` + newWindowSamples [ i ] . replace ( `.module.ts` , '' ) . replace ( `./src/app/` , '' ) ) ;
280- fs . writeFileSync ( newWindowSamples [ i ] . replace ( `.module.ts` , 'sampleList' ) , sampleJson , 'utf8' ) ;
281- }
282- done ( ) ;
283- }
284- ) ) ;
285-
286- gulp . task ( 'CDN-changes' , gulp . series ( function ( done ) {
287- var stackFiles = glob . sync ( './src/app/**/*-stackb.json' , {
288- ignore : [ './src/app/{images,common}/**' , './src/app/app.module.ts' ]
289- } ) ;
290- if ( fs . existsSync ( './config.json' ) ) {
291- for ( var i = 0 ; i < stackFiles . length ; i ++ ) {
292- var stackFile = fs . readFileSync ( stackFiles [ i ] , 'utf8' ) ;
293- var config = JSON . parse ( fs . readFileSync ( './config.json' , 'utf-8' ) ) ;
294- stackFile = stackFile . replace ( / \/ \/ c d n .s y n c f u s i o n .c o m \/ e j 2 \/ / g, '//cdn.syncfusion.com/ej2/' + config . releaseVersion + '/' ) ;
295- fs . writeFileSync ( stackFiles [ i ] , stackFile , 'utf8' ) ;
296- }
297- }
298- done ( ) ;
299- } ) ) ;
300-
0 commit comments