1
1
var fs = require ( 'fs' ) ;
2
2
var glob = require ( 'glob' ) ;
3
3
var runSequence = require ( 'run-sequence' ) ;
4
- var build = require ( "@syncfusion/ej2-build" ) ;
5
4
var gulp = require ( "gulp" ) ;
6
5
var webpack = require ( "webpack" ) ;
7
6
// var webpackConfig = require("./webpack.config.js");
8
7
// var clean = require("gulp-clean");
9
8
var shelljs = global . shelljs = global . shelljs || require ( 'shelljs' ) ;
10
- var common = require ( "./node_modules/@syncfusion/ej2-build/src/utils/common.js" ) ;
11
9
var isReleaseBranch = / ^ ( ( r e l e a s e \/ | h o t f i x \/ ) ) / g. test ( process . env . BRANCH_NAME ) ;
12
10
13
11
gulp . task ( 'create-locale' , function ( ) {
@@ -32,6 +30,9 @@ gulp.task('copy-source', function () {
32
30
silent : true ,
33
31
ignore : [ '/src/app/common/**/*.*' , '/src/app/common' ]
34
32
} ) ;
33
+ if ( ! fs . existsSync ( "./src/source/" ) ) {
34
+ fs . mkdirSync ( "./src/source/" ) ;
35
+ }
35
36
if ( localeJson . length ) {
36
37
for ( var i = 0 ; i < localeJson . length ; i ++ ) {
37
38
if ( localeJson [ i ] . indexOf ( '/common' ) == - 1 ) {
@@ -72,8 +73,8 @@ gulp.task('move', function (done) {
72
73
gulp . task ( 'styles-replace' , function ( done ) {
73
74
var nos = glob . sync ( 'node_modules/@syncfusion/ej2/*.css' ) ;
74
75
for ( var j = 0 ; j < nos . length ; j ++ ) {
75
- var htmlfile = fs . readFileSync ( nos [ j ] , 'utf8' ) ;
76
- fs . writeFileSync ( './src/styles/' + nos [ j ] . split ( '/' ) [ 3 ] , htmlfile , 'utf8' ) ;
76
+ var htmlfile = fs . readFileSync ( nos [ j ] , 'utf8' ) ;
77
+ fs . writeFileSync ( './src/styles/' + nos [ j ] . split ( '/' ) [ 3 ] , htmlfile , 'utf8' ) ;
77
78
}
78
79
done ( ) ;
79
80
} ) ;
@@ -84,44 +85,43 @@ gulp.task('SEO-changes', function () {
84
85
var localCss = `<link href="../../styles/OpenNew.css" rel="stylesheet">` ;
85
86
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;
86
87
87
- for ( var i = 0 ; i < newWindowSamples . length ; i ++ ) {
88
+ for ( var i = 0 ; i < newWindowSamples . length ; i ++ ) {
88
89
89
- var indexFile = fs . readFileSync ( newWindowSamples [ i ] , 'utf8' ) ;
90
- if ( samplsListJson [ newWindowSamples [ i ] . split ( '/' ) [ 2 ] ] === undefined ) {
91
- console . log ( `${ i } ------${ newWindowSamples [ i ] } ` ) ;
92
- }
93
- var ControlName = samplsListJson [ newWindowSamples [ i ] . split ( '/' ) [ 2 ] ] . ControlName ;
94
- var sampleName = samplsListJson [ newWindowSamples [ i ] . split ( '/' ) [ 2 ] ] . Samples [ newWindowSamples [ i ] . split ( '/' ) [ 3 ] ] ;
95
-
96
- indexFile = indexFile . replace ( / < m e t a n a m e = " d e s c r i p t i o n " ( .* ) / g, '' ) ;
97
- 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, '' ) ;
98
-
99
- var metaTagTemplate = `<meta name="description" content="This example demonstrates the ${ sampleName } in Angular ${ ControlName } Component. Explore here for more details." />` ;
100
- indexFile = indexFile . replace ( / < t i t l e > ( .* ) / g, '<title>' + 'Angular ' + ControlName + ' ' + sampleName + ' Example - Syncfusion Demos</title>\n\t' + metaTagTemplate ) ;
101
-
102
- var headerDesc = '' ;
103
- if ( newWindowSamples [ i ] . indexOf ( 'sidebar' ) >= 0 ) {
104
- headerDesc = '' ;
105
- } else {
106
- headerDesc = `<h1 class="sb-bread-crumb-text">Example of ${ sampleName } in Angular ${ ControlName } Component</h1>` ;
107
- }
90
+ var indexFile = fs . readFileSync ( newWindowSamples [ i ] , 'utf8' ) ;
91
+ if ( samplsListJson [ newWindowSamples [ i ] . split ( '/' ) [ 2 ] ] === undefined ) {
92
+ console . log ( `${ i } ------${ newWindowSamples [ i ] } ` ) ;
93
+ }
94
+ var ControlName = samplsListJson [ newWindowSamples [ i ] . split ( '/' ) [ 2 ] ] . ControlName ;
95
+ var sampleName = samplsListJson [ newWindowSamples [ i ] . split ( '/' ) [ 2 ] ] . Samples [ newWindowSamples [ i ] . split ( '/' ) [ 3 ] ] ;
108
96
109
- indexFile = indexFile . replace ( `<app-root></app-root>` , headerDesc + `\n\t<app-root></app-root>` ) ;
97
+ indexFile = indexFile . replace ( / < m e t a n a m e = " d e s c r i p t i o n " ( .* ) / g, '' ) ;
98
+ 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, '' ) ;
110
99
111
- if ( ! ( localCssRegex . test ( indexFile ) ) ) {
112
- 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="../../styles/material.css" rel="stylesheet">\n' + localCss )
113
- }
114
-
115
- fs . writeFileSync ( newWindowSamples [ i ] , indexFile . replace ( 'Essential JS 2' , 'Essential Studio' ) , 'utf8' ) ;
100
+ var metaTagTemplate = `<meta name="description" content="This example demonstrates the ${ sampleName } in Angular ${ ControlName } Component. Explore here for more details." />` ;
101
+ indexFile = indexFile . replace ( / < t i t l e > ( .* ) / g, '<title>' + 'Angular ' + ControlName + ' ' + sampleName + ' Example - Syncfusion Demos</title>\n\t' + metaTagTemplate ) ;
102
+
103
+ var headerDesc = '' ;
104
+ if ( newWindowSamples [ i ] . indexOf ( 'sidebar' ) >= 0 ) {
105
+ headerDesc = '' ;
106
+ } else {
107
+ headerDesc = `<h1 class="sb-bread-crumb-text">Example of ${ sampleName } in Angular ${ ControlName } Component</h1>` ;
116
108
}
109
+
110
+ indexFile = indexFile . replace ( `<app-root></app-root>` , headerDesc + `\n\t<app-root></app-root>` ) ;
111
+
112
+ if ( ! ( localCssRegex . test ( indexFile ) ) ) {
113
+ 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="../../styles/material.css" rel="stylesheet">\n' + localCss )
114
+ }
115
+
116
+ fs . writeFileSync ( newWindowSamples [ i ] , indexFile . replace ( 'Essential JS 2' , 'Essential Studio' ) , 'utf8' ) ;
117
117
}
118
+ }
118
119
) ;
119
120
120
121
function camelCase ( str ) {
121
- return str . replace ( / (?: ^ \w | [ A - Z ] | \b \w ) / g, function ( word , index )
122
- {
123
- return index === 0 ?word . toUpperCase ( ) : word . toUpperCase ( ) ;
124
- } ) . replace ( / \s + / g, '' ) . replace ( / \- / g, ' ' ) ;
122
+ return str . replace ( / (?: ^ \w | [ A - Z ] | \b \w ) / g, function ( word , index ) {
123
+ return index === 0 ? word . toUpperCase ( ) : word . toUpperCase ( ) ;
124
+ } ) . replace ( / \s + / g, '' ) . replace ( / \- / g, ' ' ) ;
125
125
}
126
126
127
127
@@ -133,19 +133,19 @@ gulp.task('create-sampleList', function () {
133
133
} ) ;
134
134
135
135
var temp = `{{path}}:{{name}}`
136
- for ( var i = 0 ; i < newWindowSamples . length ; i ++ ) {
137
- var sampleJson = '' ;
138
- var indexFile = fs . readFileSync ( newWindowSamples [ i ] , 'utf8' ) ;
139
- paths = indexFile . match ( / p a t h ( | ) \: [ ^ , ] + / g) ;
140
- names = indexFile . match ( / n a m e ( | | ' | ' ) \: [ ^ , ] + / g) ;
141
- for ( var j = 0 ; j < paths . length ; j ++ ) {
142
- var template = temp ;
143
- template = template . replace ( `{{path}}` , `"${ paths [ j ] . replace ( / p a t h ( | ) \: [ ^ t h e m e ] + t h e m e / g, '' ) . replace ( '\'' , '' ) } "` ) ;
144
- template = template . replace ( `{{name}}` , `"${ names [ j ] . replace ( / n a m e ( | | ' | ' ) \: [ ^ ' ] + \' / g, '' ) . replace ( '\'' , '' ) } "` ) ;
145
- sampleJson += template + `,\n` ;
146
- }
147
- console . log ( i + `----------` + newWindowSamples [ i ] . replace ( `.module.ts` , '' ) . replace ( `./src/app/` , '' ) ) ;
148
- fs . writeFileSync ( newWindowSamples [ i ] . replace ( `.module.ts` , 'sampleList' ) , sampleJson , 'utf8' ) ;
136
+ for ( var i = 0 ; i < newWindowSamples . length ; i ++ ) {
137
+ var sampleJson = '' ;
138
+ var indexFile = fs . readFileSync ( newWindowSamples [ i ] , 'utf8' ) ;
139
+ paths = indexFile . match ( / p a t h ( | ) \: [ ^ , ] + / g) ;
140
+ names = indexFile . match ( / n a m e ( | | ' | ' ) \: [ ^ , ] + / g) ;
141
+ for ( var j = 0 ; j < paths . length ; j ++ ) {
142
+ var template = temp ;
143
+ template = template . replace ( `{{path}}` , `"${ paths [ j ] . replace ( / p a t h ( | ) \: [ ^ t h e m e ] + t h e m e / g, '' ) . replace ( '\'' , '' ) } "` ) ;
144
+ template = template . replace ( `{{name}}` , `"${ names [ j ] . replace ( / n a m e ( | | ' | ' ) \: [ ^ ' ] + \' / g, '' ) . replace ( '\'' , '' ) } "` ) ;
145
+ sampleJson += template + `,\n` ;
149
146
}
147
+ console . log ( i + `----------` + newWindowSamples [ i ] . replace ( `.module.ts` , '' ) . replace ( `./src/app/` , '' ) ) ;
148
+ fs . writeFileSync ( newWindowSamples [ i ] . replace ( `.module.ts` , 'sampleList' ) , sampleJson , 'utf8' ) ;
150
149
}
150
+ }
151
151
) ;
0 commit comments