8
8
9
9
"use strict" ;
10
10
11
- var baseDir , repoDir , prevVersion , newVersion , nextVersion , tagTime , preRelease , repo ,
11
+ var baseDir , downloadBuilder , repoDir , prevVersion , newVersion , nextVersion , tagTime , preRelease , repo ,
12
12
fs = require ( "fs" ) ,
13
+ path = require ( "path" ) ,
13
14
rnewline = / \r ? \n / ,
14
15
branch = "master" ;
15
16
25
26
confirm ,
26
27
27
28
section ( "building release" ) ,
28
- buildRelease ,
29
+ buildReleaseBranch ,
30
+ buildPackage ,
29
31
30
32
section ( "pushing tag" ) ,
31
33
confirmReview ,
@@ -66,13 +68,6 @@ function cloneRepo() {
66
68
if ( exec ( "npm install" ) . code !== 0 ) {
67
69
abort ( "Error installing dependencies." ) ;
68
70
}
69
- // We need download.jqueryui.com in order to generate themes.
70
- // We only generate themes for stable releases.
71
- if ( ! preRelease ) {
72
- if ( exec ( "npm install download.jqueryui.com" ) . code !== 0 ) {
73
- abort ( "Error installing dependencies." ) ;
74
- }
75
- }
76
71
echo ( ) ;
77
72
}
78
73
@@ -135,9 +130,8 @@ function getVersions() {
135
130
echo ( "After the release, the version will be " + nextVersion . cyan + "." ) ;
136
131
}
137
132
138
- function buildRelease ( ) {
139
- var pkg ,
140
- releaseTask = preRelease ? "release" : "release_cdn" ;
133
+ function buildReleaseBranch ( ) {
134
+ var pkg ;
141
135
142
136
echo ( "Creating " + "release" . cyan + " branch..." ) ;
143
137
git ( "checkout -b release" , "Error creating release branch." ) ;
@@ -158,12 +152,6 @@ function buildRelease() {
158
152
}
159
153
echo ( ) ;
160
154
161
- echo ( "Building release..." ) ;
162
- if ( exec ( "grunt " + releaseTask ) . code !== 0 ) {
163
- abort ( "Error building release." ) ;
164
- }
165
- echo ( ) ;
166
-
167
155
echo ( "Committing release artifacts..." ) ;
168
156
git ( "add *.jquery.json" , "Error adding manifest files to git." ) ;
169
157
git ( "commit -am 'Tagging the " + newVersion + " release.'" ,
@@ -175,6 +163,175 @@ function buildRelease() {
175
163
tagTime = git ( "log -1 --format='%ad'" , "Error getting tag timestamp." ) . trim ( ) ;
176
164
}
177
165
166
+ function buildPackage ( callback ) {
167
+ if ( preRelease ) {
168
+ return buildPreReleasePackage ( callback ) ;
169
+ } else {
170
+ return buildCDNPackage ( callback ) ;
171
+ }
172
+ }
173
+
174
+ function buildPreReleasePackage ( callback ) {
175
+ var build , files , jqueryUi , packer , target , targetZip ;
176
+
177
+ echo ( "Build pre-release Package" ) ;
178
+
179
+ jqueryUi = new downloadBuilder . JqueryUi ( path . resolve ( "." ) ) ;
180
+ build = new downloadBuilder . Builder ( jqueryUi , ":all:" ) ;
181
+ packer = new downloadBuilder . Packer ( build , null , {
182
+ addTests : true ,
183
+ bundleSuffix : "" ,
184
+ skipDocs : true ,
185
+ skipTheme : true
186
+ } ) ;
187
+ target = "../" + jqueryUi . pkg . name + "-" + jqueryUi . pkg . version ;
188
+ targetZip = target + ".zip" ;
189
+
190
+ return walk ( [
191
+ function ( callback ) {
192
+ echo ( "Building release files" ) ;
193
+ packer . pack ( function ( error , _files ) {
194
+ if ( error ) {
195
+ abort ( error . stack ) ;
196
+ }
197
+ files = _files . map ( function ( file ) {
198
+
199
+ // Strip first path
200
+ file . path = file . path . replace ( / ^ [ ^ \/ ] * \/ / , "" ) ;
201
+ return file ;
202
+
203
+ } ) . filter ( function ( file ) {
204
+
205
+ // Filter development-bundle content only
206
+ return ( / ^ d e v e l o p m e n t - b u n d l e / ) . test ( file . path ) ;
207
+ } ) . map ( function ( file ) {
208
+
209
+ // Strip development-bundle
210
+ file . path = file . path . replace ( / ^ d e v e l o p m e n t - b u n d l e \/ / , "" ) ;
211
+ return file ;
212
+
213
+ } ) ;
214
+ return callback ( ) ;
215
+ } ) ;
216
+ } ,
217
+ function ( ) {
218
+ downloadBuilder . util . createZip ( files , targetZip , function ( error ) {
219
+ if ( error ) {
220
+ abort ( error . stack ) ;
221
+ }
222
+ echo ( "Built zip package at " + path . relative ( "../.." , targetZip ) . cyan ) ;
223
+ return callback ( ) ;
224
+ } ) ;
225
+ }
226
+ ] ) ;
227
+ }
228
+
229
+ function buildCDNPackage ( callback ) {
230
+ var build , output , target , targetZip ,
231
+ add = function ( file ) {
232
+ output . push ( file ) ;
233
+ } ,
234
+ bundleFiles = [ ] ,
235
+ jqueryUi = new downloadBuilder . JqueryUi ( path . resolve ( "." ) ) ,
236
+ themeGallery = downloadBuilder . themeGallery ( jqueryUi ) ;
237
+
238
+ echo ( "Build CDN Package" ) ;
239
+
240
+ build = new downloadBuilder . Builder ( jqueryUi , ":all:" ) ;
241
+ output = [ ] ;
242
+ target = "../" + jqueryUi . pkg . name + "-" + jqueryUi . pkg . version + "-cdn" ;
243
+ targetZip = target + ".zip" ;
244
+
245
+ [ "AUTHORS.txt" , "MIT-LICENSE.txt" , "package.json" ] . map ( function ( name ) {
246
+ return build . get ( name ) ;
247
+ } ) . forEach ( add ) ;
248
+
249
+ // "ui/*.js"
250
+ build . componentFiles . filter ( function ( file ) {
251
+ return ( / ^ u i \/ / ) . test ( file . path ) ;
252
+ } ) . forEach ( add ) ;
253
+
254
+ // "ui/*.min.js"
255
+ build . componentMinFiles . filter ( function ( file ) {
256
+ return ( / ^ u i \/ / ) . test ( file . path ) ;
257
+ } ) . forEach ( add ) ;
258
+
259
+ // "i18n/*.js"
260
+ build . i18nFiles . rename ( / ^ u i \/ / , "" ) . forEach ( add ) ;
261
+ build . i18nMinFiles . rename ( / ^ u i \/ / , "" ) . forEach ( add ) ;
262
+ build . bundleI18n . into ( "i18n/" ) . forEach ( add ) ;
263
+ build . bundleI18nMin . into ( "i18n/" ) . forEach ( add ) ;
264
+
265
+ build . bundleJs . forEach ( add ) ;
266
+ build . bundleJsMin . forEach ( add ) ;
267
+
268
+ walk ( themeGallery . map ( function ( theme ) {
269
+ return function ( callback ) {
270
+ var themeCssOnlyRe , themeDirRe ,
271
+ folderName = theme . folderName ( ) ,
272
+ packer = new downloadBuilder . Packer ( build , theme , {
273
+ skipDocs : true
274
+ } ) ;
275
+ // TODO improve code by using custom packer instead of download packer (Packer)
276
+ themeCssOnlyRe = new RegExp ( "development-bundle/themes/" + folderName + "/jquery.ui.theme.css" ) ;
277
+ themeDirRe = new RegExp ( "css/" + folderName ) ;
278
+ packer . pack ( function ( error , files ) {
279
+ if ( error ) {
280
+ abort ( error . stack ) ;
281
+ }
282
+ // Add theme files.
283
+ files
284
+ // Pick only theme files we need on the bundle.
285
+ . filter ( function ( file ) {
286
+ if ( themeCssOnlyRe . test ( file . path ) || themeDirRe . test ( file . path ) ) {
287
+ return true ;
288
+ }
289
+ return false ;
290
+ } )
291
+ // Convert paths the way bundle needs
292
+ . map ( function ( file ) {
293
+ file . path = file . path
294
+
295
+ // Remove initial package name eg. "jquery-ui-1.10.0.custom"
296
+ . split ( "/" ) . slice ( 1 ) . join ( "/" )
297
+
298
+ . replace ( / d e v e l o p m e n t - b u n d l e \/ t h e m e s / , "css" )
299
+ . replace ( / c s s / , "themes" )
300
+
301
+ // Make jquery-ui-1.10.0.custom.css into jquery-ui.css, or jquery-ui-1.10.0.custom.min.css into jquery-ui.min.css
302
+ . replace ( / j q u e r y - u i - .* ?( \. m i n ) * \. c s s / , "jquery-ui$1.css" ) ;
303
+
304
+ return file ;
305
+ } ) . forEach ( add ) ;
306
+ return callback ( ) ;
307
+ } ) ;
308
+
309
+ }
310
+ } ) . concat ( [ function ( ) {
311
+ var crypto = require ( "crypto" ) ;
312
+
313
+ // Create MD5 manifest
314
+ output . push ( {
315
+ path : "MANIFEST" ,
316
+ data : output . sort ( function ( a , b ) {
317
+ return a . path . localeCompare ( b . path ) ;
318
+ } ) . map ( function ( file ) {
319
+ var md5 = crypto . createHash ( "md5" ) ;
320
+ md5 . update ( file . data ) ;
321
+ return file . path + " " + md5 . digest ( "hex" ) ;
322
+ } ) . join ( "\n" )
323
+ } ) ;
324
+
325
+ downloadBuilder . util . createZip ( output , targetZip , function ( error ) {
326
+ if ( error ) {
327
+ abort ( error . stack ) ;
328
+ }
329
+ echo ( "Built zip CDN package at " + path . relative ( "../.." , targetZip ) . cyan ) ;
330
+ return callback ( ) ;
331
+ } ) ;
332
+ } ] ) ) ;
333
+ }
334
+
178
335
function pushRelease ( ) {
179
336
echo ( "Pushing release to GitHub..." ) ;
180
337
git ( "push --tags" , "Error pushing tags to GitHub." ) ;
@@ -419,14 +576,15 @@ function _bootstrap( fn ) {
419
576
fs . mkdirSync ( baseDir ) ;
420
577
421
578
console . log ( "Installing dependencies..." ) ;
422
- require ( "child_process" ) . exec ( "npm install shelljs colors" , function ( error ) {
579
+ require ( "child_process" ) . exec ( "npm install shelljs colors download.jqueryui.com " , function ( error ) {
423
580
if ( error ) {
424
581
console . log ( error ) ;
425
582
return process . exit ( 1 ) ;
426
583
}
427
584
428
585
require ( "shelljs/global" ) ;
429
586
require ( "colors" ) ;
587
+ downloadBuilder = require ( "download.jqueryui.com" ) ;
430
588
431
589
fn ( ) ;
432
590
} ) ;
0 commit comments