1
+ var gulp = require ( 'gulp' ) ;
2
+ var pkg = require ( './package.json' ) ;
3
+ var semver = require ( 'semver' ) ;
4
+ var through = require ( 'through' ) ;
5
+
6
+ var argv = require ( 'minimist' ) ( process . argv . slice ( 2 ) ) ;
7
+
1
8
var _ = require ( 'lodash' ) ;
2
9
var buildConfig = require ( './config/build.config.js' ) ;
3
10
var changelog = require ( 'conventional-changelog' ) ;
@@ -13,13 +20,6 @@ var http = require('http');
13
20
var cp = require ( 'child_process' ) ;
14
21
var fs = require ( 'fs' ) ;
15
22
16
- var gulp = require ( 'gulp' ) ;
17
- var pkg = require ( './package.json' ) ;
18
- var semver = require ( 'semver' ) ;
19
- var through = require ( 'through' ) ;
20
-
21
- var argv = require ( 'minimist' ) ( process . argv . slice ( 2 ) ) ;
22
-
23
23
var concat = require ( 'gulp-concat' ) ;
24
24
var footer = require ( 'gulp-footer' ) ;
25
25
var gulpif = require ( 'gulp-if' ) ;
@@ -30,6 +30,7 @@ var rename = require('gulp-rename');
30
30
var sass = require ( 'gulp-sass' ) ;
31
31
var stripDebug = require ( 'gulp-strip-debug' ) ;
32
32
var template = require ( 'gulp-template' ) ;
33
+ var twitter = require ( 'gulp-twitter' ) ;
33
34
var uglify = require ( 'gulp-uglify' ) ;
34
35
var gutil = require ( 'gulp-util' ) ;
35
36
@@ -43,140 +44,9 @@ if (IS_RELEASE_BUILD) {
43
44
) ;
44
45
}
45
46
46
-
47
47
gulp . task ( 'default' , [ 'build' ] ) ;
48
48
gulp . task ( 'build' , [ 'bundle' , 'sass' ] ) ;
49
49
50
- gulp . task ( 'docs-index' , function ( ) {
51
- var idx = lunr ( function ( ) {
52
- this . field ( 'path' ) ;
53
- this . field ( 'title' , { boost : 10 } ) ;
54
- this . field ( 'body' ) ;
55
- this . ref ( 'id' ) ;
56
- } ) ;
57
- var ref = { } ;
58
- var refId = 0 ;
59
-
60
- function addToIndex ( path , title , layout , body ) {
61
- // Add the data to the indexer and ref object
62
- idx . add ( { 'path' : path , 'body' : body , 'title' : title , id : refId } ) ;
63
- ref [ refId ] = { 'p' : path , 't' : title , 'l' : layout } ;
64
- refId ++ ;
65
- }
66
-
67
- return gulp . src ( [
68
- 'tmp/ionic-site/docs/{components,guide,api,overview}/**/*.{md,html,markdown}' ,
69
- 'tmp/ionic-site/docs/index.html' ,
70
- 'tmp/ionic-site/getting-started/index.html' ,
71
- 'tmp/ionic-site/tutorials/**/*.{md,html,markdown}' ,
72
- 'tmp/ionic-site/_posts/**/*.{md,html,markdown}'
73
- ] )
74
- . pipe ( es . map ( function ( file , callback ) {
75
- //docs for gulp file objects: https://github.com/wearefractal/vinyl
76
- var contents = file . contents . toString ( ) ; //was buffer
77
-
78
- // Grab relative path from ionic-site root
79
- var relpath = file . path . replace ( / ^ .* ?t m p \/ i o n i c - s i t e \/ / , '' ) ;
80
-
81
- // Read out the yaml portion of the Jekyll file
82
- var yamlStartIndex = contents . indexOf ( '---' ) ;
83
-
84
- if ( yamlStartIndex === - 1 ) {
85
- return callback ( ) ;
86
- }
87
-
88
- // read Jekyll's page yaml variables at the top of the file
89
- var yamlEndIndex = contents . indexOf ( '---' , yamlStartIndex + 3 ) ; //starting from start
90
- var yamlRaw = contents . substring ( yamlStartIndex + 3 , yamlEndIndex ) ;
91
-
92
- var pageData = yaml . safeLoad ( yamlRaw ) ;
93
- if ( ! pageData . title || ! pageData . layout ) {
94
- return callback ( ) ;
95
- }
96
-
97
- // manually set to not be searchable, or for a blog post, manually set to be searchable
98
- if ( pageData . searchable === false || ( pageData . layout == 'post' && pageData . searchable !== true ) ) {
99
- return callback ( ) ;
100
- }
101
-
102
- // clean up some content so code variables are searchable too
103
- contents = contents . substring ( yamlEndIndex + 3 ) ;
104
- contents = contents . replace ( / < c o d e ? > / gi, '' ) ;
105
- contents = contents . replace ( / < \/ c o d e > / gi, '' ) ;
106
- contents = contents . replace ( / < c o d e ? > < / gi, '' ) ;
107
- contents = contents . replace ( / > < \/ c o d e > / gi, '' ) ;
108
- contents = contents . replace ( / ` < / gi, '' ) ;
109
- contents = contents . replace ( / > ` / gi, '' ) ;
110
-
111
- // create a clean path to the URL
112
- var path = '/' + relpath . replace ( 'index.md' , '' )
113
- . replace ( 'index.html' , '' )
114
- . replace ( '.md' , '.html' )
115
- . replace ( '.markdown' , '.html' ) ;
116
- if ( pageData . layout == 'post' ) {
117
- path = '/blog/' + path . substring ( 19 ) . replace ( '.html' , '/' ) ;
118
- }
119
-
120
- if ( pageData . search_sections === true ) {
121
- // each section within the content should be its own search result
122
- var section = { body : '' , title : '' } ;
123
- var isTitleOpen = false ;
124
-
125
- var parser = new htmlparser . Parser ( {
126
- ontext : function ( text ) {
127
- if ( isTitleOpen ) {
128
- section . title += text ; // get the title of this section
129
- } else {
130
- section . body += text . replace ( / { % .* % } / , '' , 'g' ) ; // Ignore any Jekyll expressions
131
- }
132
- } ,
133
- onopentag : function ( name , attrs ) {
134
- if ( name == 'section' && attrs . id ) {
135
- // start building new section data
136
- section = { body : '' , path : path + '#' + attrs . id , title : '' } ;
137
- } else if ( ( name == 'h1' || name == 'h2' || name == 'h3' ) && attrs . class == 'title' ) {
138
- isTitleOpen = true ; // the next text will be this sections title
139
- }
140
- } ,
141
- onclosetag : function ( name ) {
142
- if ( name == 'section' ) {
143
- // section closed, index this section then clear it out
144
- addToIndex ( section . path , section . title , pageData . layout , section . body ) ;
145
- section = { body : '' , title : '' } ;
146
- } else if ( ( name == 'h1' || name == 'h2' || name == 'h3' ) && isTitleOpen ) {
147
- isTitleOpen = false ;
148
- }
149
- }
150
- } ) ;
151
- parser . write ( contents ) ;
152
- parser . end ( ) ;
153
-
154
- } else {
155
- // index the entire page
156
- var body = '' ;
157
- var parser = new htmlparser . Parser ( {
158
- ontext : function ( text ) {
159
- body += text . replace ( / { % .* % } / , '' , 'g' ) ; // Ignore any Jekyll expressions
160
- }
161
- } ) ;
162
- parser . write ( contents ) ;
163
- parser . end ( ) ;
164
-
165
- addToIndex ( path , pageData . title , pageData . layout , body ) ;
166
- }
167
-
168
- callback ( ) ;
169
-
170
- } ) ) . on ( 'end' , function ( ) {
171
- // Write out as one json file
172
- mkdirp . sync ( 'tmp/ionic-site/data' ) ;
173
- fs . writeFileSync (
174
- 'tmp/ionic-site/data/index.json' ,
175
- JSON . stringify ( { 'ref' : ref , 'index' : idx . toJSON ( ) } )
176
- ) ;
177
- } ) ;
178
- } ) ;
179
-
180
50
gulp . task ( 'docs' , function ( done ) {
181
51
var docVersion = argv [ 'doc-version' ] ;
182
52
if ( docVersion != 'nightly' && ! semver . valid ( docVersion ) ) {
@@ -317,6 +187,151 @@ gulp.task('version', function() {
317
187
. pipe ( gulp . dest ( 'dist' ) ) ;
318
188
} ) ;
319
189
190
+ gulp . task ( 'tweet' , function ( ) {
191
+ var oauth = {
192
+ consumerKey : process . env . TWITTER_CONSUMER_KEY ,
193
+ consumerSecret : process . env . TWITTER_CONSUMER_SECRET ,
194
+ accessToken : process . env . TWITTER_ACCESS_TOKEN ,
195
+ accessTokenSecret : process . env . TWITTER_ACCESS_TOKEN_SECRET
196
+ } ;
197
+ var exclamations = [ "Aah" , "Ah" , "Aha" , "All right" , "Aw" , "Ay" , "Aye" , "Bah" , "Boy" , "By golly" , "Boom" , "Cheerio" , "Cheers" , "Come on" , "Crikey" , "Dear me" , "Egads" , "Fiddle-dee-dee" , "Gadzooks" , "Gangway" , "G'day" , "Gee whiz" , "Gesundheit" , "Get outta here" , "Good golly" , "Good job" , "Gosh" , "Gracious" , "Great" , "Gulp" , "Ha" , "Ha-ha" , "Hah" , "Hallelujah" , "Harrumph" , "Hey" , "Hooray" , "Hot dog" , "Hurray" , "Huzza" , "I say" , "La-di-dah" , "Look" , "Look here" , "Long time" , "Lordy" , "Most certainly" , "My my" , "My word" , "Oh" , "Oho" , "Oh-oh" , "Oh no" , "Okay" , "Okey-dokey" , "Ooh" , "Oye" , "Phew" , "Quite" , "Ready" , "Right on" , "Roger that" , "Rumble" , "Say" , "See ya" , "Snap" , "Sup" , "Ta-da" , "Take that" , "Tally ho" , "Thanks" , "Toodles" , "Touche" , "Tut-tut" , "Very nice" , "Very well" , "Voila" , "Vroom" , "Well done" , "Well, well" , "Whoa" , "Whoopee" , "Whew" , "Word up" , "Wow" , "Wuzzup" , "Ya" , "Yea" , "Yeah" , "Yippee" , "Yo" , "Yoo-hoo" , "You bet" , "You don't say" , "You know" , "Yow" , "Yum" , "Yummy" , "Zap" , "Zounds" , "Zowie" ] ;
198
+ if ( IS_RELEASE_BUILD && argv . codeversion && argv . codename ) {
199
+ var tweet = exclamations [ Math . floor ( Math . random ( ) * exclamations . length ) ] + '! Just released @IonicFramework ' + argv . codename + ' v' + argv . codeversion + ' https://github.com/driftyco/ionic/releases/tag/v' + argv . codeversion ;
200
+ console . log ( tweet ) ;
201
+ return gulp . src ( 'package.json' )
202
+ . pipe ( twitter ( oauth , tweet ) ) ;
203
+ }
204
+ } ) ;
205
+
206
+ gulp . task ( 'docs-index' , function ( ) {
207
+ var idx = lunr ( function ( ) {
208
+ this . field ( 'path' ) ;
209
+ this . field ( 'title' , { boost : 10 } ) ;
210
+ this . field ( 'body' ) ;
211
+ this . ref ( 'id' ) ;
212
+ } ) ;
213
+ var ref = { } ;
214
+ var refId = 0 ;
215
+
216
+ function addToIndex ( path , title , layout , body ) {
217
+ // Add the data to the indexer and ref object
218
+ idx . add ( { 'path' : path , 'body' : body , 'title' : title , id : refId } ) ;
219
+ ref [ refId ] = { 'p' : path , 't' : title , 'l' : layout } ;
220
+ refId ++ ;
221
+ }
222
+
223
+ return gulp . src ( [
224
+ 'tmp/ionic-site/docs/{components,guide,api,overview}/**/*.{md,html,markdown}' ,
225
+ 'tmp/ionic-site/docs/index.html' ,
226
+ 'tmp/ionic-site/getting-started/index.html' ,
227
+ 'tmp/ionic-site/tutorials/**/*.{md,html,markdown}' ,
228
+ 'tmp/ionic-site/_posts/**/*.{md,html,markdown}'
229
+ ] )
230
+ . pipe ( es . map ( function ( file , callback ) {
231
+ //docs for gulp file objects: https://github.com/wearefractal/vinyl
232
+ var contents = file . contents . toString ( ) ; //was buffer
233
+
234
+ // Grab relative path from ionic-site root
235
+ var relpath = file . path . replace ( / ^ .* ?t m p \/ i o n i c - s i t e \/ / , '' ) ;
236
+
237
+ // Read out the yaml portion of the Jekyll file
238
+ var yamlStartIndex = contents . indexOf ( '---' ) ;
239
+
240
+ if ( yamlStartIndex === - 1 ) {
241
+ return callback ( ) ;
242
+ }
243
+
244
+ // read Jekyll's page yaml variables at the top of the file
245
+ var yamlEndIndex = contents . indexOf ( '---' , yamlStartIndex + 3 ) ; //starting from start
246
+ var yamlRaw = contents . substring ( yamlStartIndex + 3 , yamlEndIndex ) ;
247
+
248
+ var pageData = yaml . safeLoad ( yamlRaw ) ;
249
+ if ( ! pageData . title || ! pageData . layout ) {
250
+ return callback ( ) ;
251
+ }
252
+
253
+ // manually set to not be searchable, or for a blog post, manually set to be searchable
254
+ if ( pageData . searchable === false || ( pageData . layout == 'post' && pageData . searchable !== true ) ) {
255
+ return callback ( ) ;
256
+ }
257
+
258
+ // clean up some content so code variables are searchable too
259
+ contents = contents . substring ( yamlEndIndex + 3 ) ;
260
+ contents = contents . replace ( / < c o d e ? > / gi, '' ) ;
261
+ contents = contents . replace ( / < \/ c o d e > / gi, '' ) ;
262
+ contents = contents . replace ( / < c o d e ? > < / gi, '' ) ;
263
+ contents = contents . replace ( / > < \/ c o d e > / gi, '' ) ;
264
+ contents = contents . replace ( / ` < / gi, '' ) ;
265
+ contents = contents . replace ( / > ` / gi, '' ) ;
266
+
267
+ // create a clean path to the URL
268
+ var path = '/' + relpath . replace ( 'index.md' , '' )
269
+ . replace ( 'index.html' , '' )
270
+ . replace ( '.md' , '.html' )
271
+ . replace ( '.markdown' , '.html' ) ;
272
+ if ( pageData . layout == 'post' ) {
273
+ path = '/blog/' + path . substring ( 19 ) . replace ( '.html' , '/' ) ;
274
+ }
275
+
276
+ if ( pageData . search_sections === true ) {
277
+ // each section within the content should be its own search result
278
+ var section = { body : '' , title : '' } ;
279
+ var isTitleOpen = false ;
280
+
281
+ var parser = new htmlparser . Parser ( {
282
+ ontext : function ( text ) {
283
+ if ( isTitleOpen ) {
284
+ section . title += text ; // get the title of this section
285
+ } else {
286
+ section . body += text . replace ( / { % .* % } / , '' , 'g' ) ; // Ignore any Jekyll expressions
287
+ }
288
+ } ,
289
+ onopentag : function ( name , attrs ) {
290
+ if ( name == 'section' && attrs . id ) {
291
+ // start building new section data
292
+ section = { body : '' , path : path + '#' + attrs . id , title : '' } ;
293
+ } else if ( ( name == 'h1' || name == 'h2' || name == 'h3' ) && attrs . class == 'title' ) {
294
+ isTitleOpen = true ; // the next text will be this sections title
295
+ }
296
+ } ,
297
+ onclosetag : function ( name ) {
298
+ if ( name == 'section' ) {
299
+ // section closed, index this section then clear it out
300
+ addToIndex ( section . path , section . title , pageData . layout , section . body ) ;
301
+ section = { body : '' , title : '' } ;
302
+ } else if ( ( name == 'h1' || name == 'h2' || name == 'h3' ) && isTitleOpen ) {
303
+ isTitleOpen = false ;
304
+ }
305
+ }
306
+ } ) ;
307
+ parser . write ( contents ) ;
308
+ parser . end ( ) ;
309
+
310
+ } else {
311
+ // index the entire page
312
+ var body = '' ;
313
+ var parser = new htmlparser . Parser ( {
314
+ ontext : function ( text ) {
315
+ body += text . replace ( / { % .* % } / , '' , 'g' ) ; // Ignore any Jekyll expressions
316
+ }
317
+ } ) ;
318
+ parser . write ( contents ) ;
319
+ parser . end ( ) ;
320
+
321
+ addToIndex ( path , pageData . title , pageData . layout , body ) ;
322
+ }
323
+
324
+ callback ( ) ;
325
+
326
+ } ) ) . on ( 'end' , function ( ) {
327
+ // Write out as one json file
328
+ mkdirp . sync ( 'tmp/ionic-site/data' ) ;
329
+ fs . writeFileSync (
330
+ 'tmp/ionic-site/data/index.json' ,
331
+ JSON . stringify ( { 'ref' : ref , 'index' : idx . toJSON ( ) } )
332
+ ) ;
333
+ } ) ;
334
+ } ) ;
320
335
321
336
gulp . task ( 'sauce-connect' , sauceConnect ) ;
322
337
0 commit comments