11module . exports = function ( grunt ) {
22
3- "use strict" ;
4-
53var _ = require ( "underscore" ) ,
64 semver = require ( "semver" ) ,
75 Handlebars = require ( "handlebars" ) ,
86 http = require ( "http" ) ;
97
10- grunt . loadNpmTasks ( "grunt-clean" ) ;
11- grunt . loadNpmTasks ( "grunt-html" ) ;
12- grunt . loadNpmTasks ( "grunt-wordpress" ) ;
138grunt . loadNpmTasks ( "grunt-jquery-content" ) ;
14- grunt . loadNpmTasks ( "grunt-check-modules" ) ;
159
1610grunt . initConfig ( {
17- clean : {
18- folder : "dist/"
19- } ,
20- htmllint : {
21- page : "page/**.html"
22- } ,
23- jshint : {
24- options : {
25- undef : true ,
26- node : true
27- }
28- } ,
29- lint : {
30- grunt : "grunt.js"
31- } ,
32- watch : {
33- pages : {
34- files : "pages/**/*" ,
35- tasks : "deploy"
36- }
37- } ,
38- "build-pages" : {
39- all : grunt . file . expandFiles ( "pages/**" )
40- } ,
41- "build-resources" : {
42- all : grunt . file . expandFiles ( "resources/**" )
43- } ,
44- wordpress : grunt . utils . _ . extend ( {
45- dir : "dist/wordpress"
46- } , grunt . file . readJSON ( "config.json" ) )
11+ wordpress : ( function ( ) {
12+ var config = require ( "./config" ) ;
13+ config . dir = "dist/wordpress" ;
14+ return config ;
15+ } ) ( )
4716} ) ;
4817
4918grunt . registerTask ( "build-index" , function ( ) {
5019 var rversion = / ^ ( \d + ) \. ( \d + ) (?: \. ( \d + ) ) ? - ? ( .* ) $ / ;
20+
5121 function normalizeVersion ( version ) {
5222 var match = rversion . exec ( version ) ;
5323
@@ -83,6 +53,7 @@ grunt.registerTask( "build-index", function() {
8353 version : normalizeVersion ( matches [ 2 ] )
8454 } ;
8555 } )
56+
8657 // Remove null values from filtering
8758 . filter ( _ . identity )
8859 . sort ( function ( a , b ) {
@@ -91,7 +62,7 @@ grunt.registerTask( "build-index", function() {
9162 }
9263
9364 function getCoreData ( ) {
94- var files = grunt . file . expandFiles ( "cdn/*.js" ) ,
65+ var files = grunt . file . expand ( "cdn/*.js" ) ,
9566 coreReleases = parseReleases ( files ,
9667 / ( j q u e r y - ( \d + \. \d + (?: \. \d + ) ? [ ^ . ] * ) (?: \. ( m i n | p a c k ) ) ? \. j s ) / ) ,
9768 jquery2Releases = coreReleases . filter ( function ( match ) {
@@ -137,22 +108,18 @@ grunt.registerTask( "build-index", function() {
137108
138109 function getUiData ( ) {
139110 var majorReleases = { } ,
140- uiReleases = grunt . file . expandDirs ( "cdn/ui/*" )
111+ uiReleases = grunt . file . expand ( { filter : "isDirectory" } , "cdn/ui/*" )
141112 . map ( function ( dir ) {
142- var version ,
143- filename = dir . substring ( 4 ) + "jquery-ui.js" ;
144-
145- version = dir . substring ( 7 ) ;
146- version = version . substring ( 0 , version . length - 1 ) ;
113+ var filename = dir . substring ( 4 ) + "/jquery-ui.js" ;
147114
148115 return {
149116 filename : filename ,
150- version : version ,
117+ version : dir . substring ( 7 ) ,
151118 minified : filename . replace ( ".js" , ".min.js" ) ,
152- themes : grunt . file . expandDirs ( dir + "themes/*" ) . map ( function ( themeDir ) {
153- var theme = themeDir . substring ( dir . length + 7 ) ;
154- return theme . substring ( 0 , theme . length - 1 ) ;
155- } )
119+ themes : grunt . file . expand ( { filter : "isDirectory" } , dir + "/ themes/*" )
120+ . map ( function ( themeDir ) {
121+ return themeDir . substring ( dir . length + 8 ) ;
122+ } )
156123 } ;
157124 } )
158125 . sort ( function ( a , b ) {
@@ -185,7 +152,7 @@ grunt.registerTask( "build-index", function() {
185152 }
186153
187154 function getMobileData ( ) {
188- var files = grunt . file . expandFiles ( "cdn/mobile/*/*.css" ) ,
155+ var files = grunt . file . expand ( "cdn/mobile/*/*.css" ) ,
189156 releases = files . map ( function ( file ) {
190157 var version = / c d n \/ m o b i l e \/ ( [ ^ \/ ] + ) / . exec ( file ) [ 1 ] ,
191158 filename = "mobile/" + version + "/jquery.mobile-" + version + ".js" ,
@@ -232,7 +199,7 @@ grunt.registerTask( "build-index", function() {
232199 }
233200
234201 function getColorData ( ) {
235- var files = grunt . file . expandFiles ( "cdn/color/*.js" ) ,
202+ var files = grunt . file . expand ( "cdn/color/*.js" ) ,
236203 releases = parseReleases ( files ,
237204 / ( c o l o r \/ j q u e r y .c o l o r - ( \d + \. \d + (?: \. \d + ) ? [ ^ . ] * ) (?: \. ( m i n ) ) ? \. j s ) / ) ,
238205 modes = [ "svg-names" , "plus-names" ] ;
@@ -263,7 +230,7 @@ grunt.registerTask( "build-index", function() {
263230 }
264231
265232 function getQunitData ( ) {
266- var files = grunt . file . expandFiles ( "cdn/qunit/*.js" ) ,
233+ var files = grunt . file . expand ( "cdn/qunit/*.js" ) ,
267234 releases = parseReleases ( files ,
268235 / ( q u n i t \/ q u n i t - ( \d + \. \d + \. \d + [ ^ . ] * ) (?: \. ( m i n ) ) ? \. j s ) / ) ;
269236
@@ -317,7 +284,7 @@ grunt.registerTask( "build-index", function() {
317284 } ) ( ) ) ;
318285
319286 var data = getCoreData ( ) ;
320- data . ui = getUiData ( ) ,
287+ data . ui = getUiData ( ) ;
321288 data . mobile = getMobileData ( ) ;
322289 data . color = getColorData ( ) ;
323290 data . qunit = getQunitData ( ) ;
@@ -368,9 +335,7 @@ grunt.registerTask( "reload-listings", function() {
368335 } ) ;
369336} ) ;
370337
371- grunt . registerTask ( "default" , "build-wordpress" ) ;
372- grunt . registerTask ( "build" , "build-pages build-resources build-index" ) ;
373- grunt . registerTask ( "build-wordpress" , "check-modules clean lint build" ) ;
374- grunt . registerTask ( "deploy" , "wordpress-deploy reload-listings" ) ;
338+ grunt . registerTask ( "build" , [ "build-index" ] ) ;
339+ grunt . registerTask ( "deploy" , [ "wordpress-deploy" , "reload-listings" ] ) ;
375340
376341} ;
0 commit comments