@@ -171,97 +171,68 @@ grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", fun
171
171
grunt . log . writeln ( "Wrote " + this . file . dest + " with " + hashes . length + " hashes" ) ;
172
172
} ) ;
173
173
174
- // only needed for 1.8
175
- grunt . registerTask ( "download_docs" , function ( ) {
176
- function capitalize ( value ) {
177
- return value [ 0 ] . toUpperCase ( ) + value . slice ( 1 ) ;
174
+ grunt . registerTask ( "generate_themes" , function ( ) {
175
+ var download , files , done ,
176
+ target = "dist/" + grunt . template . process ( grunt . config ( "files.themes" ) , grunt . config ( ) ) + "/" ,
177
+ distFolder = "dist/" + grunt . template . process ( grunt . config ( "files.dist" ) , grunt . config ( ) ) ;
178
+ try {
179
+ require . resolve ( "download.jqueryui.com" ) ;
180
+ } catch ( e ) {
181
+ throw "You need to manually install download.jqueryui.com for this task to work" ;
178
182
}
179
- // should be grunt.config("pkg.version")?
180
- var version = "1.8" ,
181
- docsDir = "dist/docs" ,
182
- files = "draggable droppable resizable selectable sortable accordion autocomplete button datepicker dialog progressbar slider tabs position"
183
- . split ( " " ) . map ( function ( widget ) {
184
- return {
185
- url : "http://docs.jquery.com/action/render/UI/API/" + version + "/" + capitalize ( widget ) ,
186
- dest : docsDir + '/' + widget + '.html'
187
- } ;
188
- } ) ;
189
- files = files . concat ( "animate addClass effect hide removeClass show switchClass toggle toggleClass" . split ( " " ) . map ( function ( widget ) {
190
- return {
191
- url : "http://docs.jquery.com/action/render/UI/Effects/" + widget ,
192
- dest : docsDir + '/' + widget + '.html'
193
- } ;
194
- } ) ) ;
195
- files = files . concat ( "Blind Clip Drop Explode Fade Fold Puff Slide Scale Bounce Highlight Pulsate Shake Size Transfer" . split ( " " ) . map ( function ( widget ) {
196
- return {
197
- url : "http://docs.jquery.com/action/render/UI/Effects/" + widget ,
198
- dest : docsDir + '/effect-' + widget . toLowerCase ( ) + '.html'
199
- } ;
200
- } ) ) ;
201
- grunt . file . mkdir ( "dist/docs" ) ;
202
- grunt . utils . async . forEach ( files , function ( file , done ) {
203
- var out = fs . createWriteStream ( file . dest ) ;
204
- out . on ( "close" , done ) ;
205
- request ( file . url ) . pipe ( out ) ;
206
- } , this . async ( ) ) ;
207
- } ) ;
208
183
209
- grunt . registerTask ( "download_themes" , function ( ) {
210
- // var AdmZip = require('adm-zip');
211
- var done = this . async ( ) ,
212
- themes = grunt . file . read ( "build/themes" ) . split ( "," ) ,
213
- requests = 0 ;
214
- grunt . file . mkdir ( "dist/tmp" ) ;
215
- themes . forEach ( function ( theme , index ) {
216
- requests += 1 ;
217
- grunt . file . mkdir ( "dist/tmp/" + index ) ;
218
- var zipFileName = "dist/tmp/" + index + ".zip" ,
219
- out = fs . createWriteStream ( zipFileName ) ;
220
- out . on ( "close" , function ( ) {
221
- grunt . log . writeln ( "done downloading " + zipFileName ) ;
222
- // TODO AdmZip produces "crc32 checksum failed", need to figure out why
223
- // var zip = new AdmZip(zipFileName);
224
- // zip.extractAllTo('dist/tmp/' + index + '/');
225
- // until then, using cli unzip...
226
- grunt . utils . spawn ( {
227
- cmd : "unzip" ,
228
- args : [ "-d" , "dist/tmp/" + index , zipFileName ]
229
- } , function ( err , result ) {
230
- grunt . log . writeln ( "Unzipped " + zipFileName + ", deleting it now" ) ;
231
- fs . unlinkSync ( zipFileName ) ;
232
- requests -= 1 ;
233
- if ( requests === 0 ) {
234
- done ( ) ;
235
- }
236
- } ) ;
237
- } ) ;
238
- request ( "http://ui-dev.jquery.com/download/?" + theme ) . pipe ( out ) ;
184
+ // copy release files into download builder to avoid cloning again
185
+ grunt . file . expandFiles ( distFolder + "/**" ) . forEach ( function ( file ) {
186
+ grunt . file . copy ( file , "node_modules/download.jqueryui.com/release/" + file . replace ( / ^ d i s t / , "" ) ) ;
239
187
} ) ;
240
- } ) ;
241
188
242
- grunt . registerTask ( "copy_themes" , function ( ) {
243
- // each package includes the base theme, ignore that
244
- var filter = / t h e m e s \/ b a s e / ,
245
- files = grunt . file . expandFiles ( "dist/tmp/*/development-bundle/themes/**/*" ) . filter ( function ( file ) {
246
- return ! filter . test ( file ) ;
247
- } ) ,
248
- // TODO the grunt.template.process call shouldn't be necessary
249
- target = "dist/" + grunt . template . process ( grunt . config ( "files.themes" ) , grunt . config ( ) ) + "/" ,
250
- distFolder = "dist/" + grunt . template . process ( grunt . config ( "files.dist" ) , grunt . config ( ) ) ;
251
- files . forEach ( function ( fileName ) {
252
- var targetFile = fileName . replace ( / d i s t \/ t m p \/ \d + \/ d e v e l o p m e n t - b u n d l e \/ / , "" ) . replace ( "jquery-ui-.custom" , "jquery-ui" ) ;
253
- grunt . file . copy ( fileName , target + targetFile ) ;
254
- } ) ;
189
+ download = new ( require ( "download.jqueryui.com" ) ) ( ) ;
255
190
256
- // copy minified base theme from regular release
257
191
files = grunt . file . expandFiles ( distFolder + "/themes/base/**/*" ) ;
258
192
files . forEach ( function ( fileName ) {
259
193
grunt . file . copy ( fileName , target + fileName . replace ( distFolder , "" ) ) ;
260
194
} ) ;
195
+
196
+ done = this . async ( ) ;
197
+ grunt . utils . async . forEach ( download . themeroller . gallery ( ) , function ( theme , done ) {
198
+ var folderName = theme . folderName ( ) ,
199
+ concatTarget = "css-" + folderName ,
200
+ cssContent = theme . css ( ) ,
201
+ cssFolderName = target + "themes/" + folderName + "/" ,
202
+ cssFileName = cssFolderName + "jquery.ui.theme.css" ,
203
+ cssFiles = grunt . config . get ( "concat.css.src" ) [ 1 ] . slice ( ) ;
204
+
205
+ grunt . file . write ( cssFileName , cssContent ) ;
206
+
207
+ // get css components, replace the last file with the current theme
208
+ cssFiles . splice ( - 1 ) ;
209
+ cssFiles . push ( "<strip_all_banners:" + cssFileName + ">" ) ;
210
+ grunt . config . get ( "concat" ) [ concatTarget ] = {
211
+ src : [ "<banner:meta.bannerCSS>" , cssFiles ] ,
212
+ dest : cssFolderName + "jquery-ui.css"
213
+ } ;
214
+ grunt . task . run ( "concat:" + concatTarget ) ;
215
+
216
+ theme . fetchImages ( function ( err , files ) {
217
+ if ( err ) {
218
+ done ( err ) ;
219
+ return ;
220
+ }
221
+ files . forEach ( function ( file ) {
222
+ grunt . file . write ( cssFolderName + "images/" + file . path , file . data ) ;
223
+ } ) ;
224
+ done ( ) ;
225
+ } ) ;
226
+ } , function ( err ) {
227
+ if ( err ) {
228
+ grunt . log . error ( err ) ;
229
+ }
230
+ done ( ! err ) ;
231
+ } ) ;
261
232
} ) ;
262
233
263
234
grunt . registerTask ( "clean" , function ( ) {
264
235
require ( "rimraf" ) . sync ( "dist" ) ;
265
236
} ) ;
266
237
267
- } ;
238
+ } ;
0 commit comments