@@ -175,67 +175,42 @@ grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", fun
175
175
} ) ;
176
176
177
177
grunt . registerTask ( "generate_themes" , function ( ) {
178
- var download , files , done , configContent ,
179
- target = "dist/" + grunt . template . process ( grunt . config ( "files.themes" ) , grunt . config ( ) ) + "/" ,
178
+ var download , done ,
180
179
distFolder = "dist/" + grunt . template . process ( grunt . config ( "files.dist" ) , grunt . config ( ) ) ,
181
- configFile = "node_modules/download.jqueryui.com/config.json" ;
180
+ target = "dist/" + grunt . template . process ( grunt . config ( "files.themes" ) , grunt . config ( ) ) + "/" ;
181
+
182
182
try {
183
183
require . resolve ( "download.jqueryui.com" ) ;
184
184
} catch ( error ) {
185
185
throw new Error ( "You need to manually install download.jqueryui.com for this task to work" ) ;
186
186
}
187
187
188
- // copy release files into download builder to avoid cloning again
189
- grunt . file . expandFiles ( distFolder + "/**" ) . forEach ( function ( file ) {
190
- grunt . file . copy ( file , "node_modules/download.jqueryui.com/release/" + file . replace ( / ^ d i s t \/ j q u e r y - u i - / , "" ) ) ;
191
- } ) ;
192
- // make it look for the right version
193
- configContent = grunt . file . readJSON ( configFile ) ;
194
- configContent . jqueryUi . stable . version = grunt . config ( "pkg.version" ) ;
195
- grunt . file . write ( configFile , JSON . stringify ( configContent , null , "\t" ) + "\n" ) ;
196
-
197
- download = new ( require ( "download.jqueryui.com" ) ) ( ) ;
198
-
199
- files = grunt . file . expandFiles ( distFolder + "/themes/base/**/*" ) ;
200
- files . forEach ( function ( fileName ) {
201
- grunt . file . copy ( fileName , target + fileName . replace ( distFolder , "" ) ) ;
188
+ download = require ( "download.jqueryui.com" ) ( {
189
+ config : {
190
+ "jqueryUi" : {
191
+ "stable" : { "path" : path . resolve ( __dirname + "/../../" + distFolder ) }
192
+ } ,
193
+ "jquery" : "skip"
194
+ }
202
195
} ) ;
203
196
204
197
done = this . async ( ) ;
205
- grunt . utils . async . forEach ( download . themeroller . gallery ( ) , function ( theme , done ) {
206
- var folderName = theme . folderName ( ) ,
207
- concatTarget = "css-" + folderName ,
208
- cssContent = theme . css ( ) ,
209
- cssFolderName = target + "themes/" + folderName + "/" ,
210
- cssFileName = cssFolderName + "jquery.ui.theme.css" ,
211
- cssFiles = grunt . config . get ( "concat.css.src" ) [ 1 ] . slice ( ) ;
212
-
213
- grunt . file . write ( cssFileName , cssContent ) ;
214
-
215
- // get css components, replace the last file with the current theme
216
- cssFiles . splice ( - 1 ) ;
217
- cssFiles . push ( "<strip_all_banners:" + cssFileName + ">" ) ;
218
- grunt . config . get ( "concat" ) [ concatTarget ] = {
219
- src : [ "<banner:meta.bannerCSS>" , cssFiles ] ,
220
- dest : cssFolderName + "jquery-ui.css"
221
- } ;
222
- grunt . task . run ( "concat:" + concatTarget ) ;
223
-
224
- theme . fetchImages ( function ( err , files ) {
225
- if ( err ) {
226
- done ( err ) ;
227
- return ;
228
- }
229
- files . forEach ( function ( file ) {
230
- grunt . file . write ( cssFolderName + "images/" + file . path , file . data ) ;
231
- } ) ;
232
- done ( ) ;
233
- } ) ;
234
- } , function ( err ) {
198
+ download . buildThemesBundle ( function ( err , files ) {
235
199
if ( err ) {
236
200
grunt . log . error ( err ) ;
201
+ return done ( false ) ;
237
202
}
238
- done ( ! err ) ;
203
+ done (
204
+ files . every ( function ( file ) {
205
+ try {
206
+ grunt . file . write ( target + file . path , file . data ) ;
207
+ } catch ( err ) {
208
+ grunt . log . error ( err ) ;
209
+ return false ;
210
+ }
211
+ return true ;
212
+ } ) && grunt . log . writeln ( "Generated at " + target )
213
+ ) ;
239
214
} ) ;
240
215
} ) ;
241
216
0 commit comments