1
1
module . exports = function ( grunt ) {
2
2
3
- "use strict" ;
4
-
5
3
var _ = require ( "underscore" ) ,
6
4
semver = require ( "semver" ) ,
7
5
Handlebars = require ( "handlebars" ) ,
8
6
http = require ( "http" ) ;
9
7
10
- grunt . loadNpmTasks ( "grunt-clean" ) ;
11
- grunt . loadNpmTasks ( "grunt-html" ) ;
12
- grunt . loadNpmTasks ( "grunt-wordpress" ) ;
13
8
grunt . loadNpmTasks ( "grunt-jquery-content" ) ;
14
- grunt . loadNpmTasks ( "grunt-check-modules" ) ;
15
9
16
10
grunt . 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
+ } ) ( )
47
16
} ) ;
48
17
49
18
grunt . registerTask ( "build-index" , function ( ) {
50
19
var rversion = / ^ ( \d + ) \. ( \d + ) (?: \. ( \d + ) ) ? - ? ( .* ) $ / ;
20
+
51
21
function normalizeVersion ( version ) {
52
22
var match = rversion . exec ( version ) ;
53
23
@@ -83,6 +53,7 @@ grunt.registerTask( "build-index", function() {
83
53
version : normalizeVersion ( matches [ 2 ] )
84
54
} ;
85
55
} )
56
+
86
57
// Remove null values from filtering
87
58
. filter ( _ . identity )
88
59
. sort ( function ( a , b ) {
@@ -91,7 +62,7 @@ grunt.registerTask( "build-index", function() {
91
62
}
92
63
93
64
function getCoreData ( ) {
94
- var files = grunt . file . expandFiles ( "cdn/*.js" ) ,
65
+ var files = grunt . file . expand ( "cdn/*.js" ) ,
95
66
coreReleases = parseReleases ( files ,
96
67
/ ( j q u e r y - ( \d + \. \d + (?: \. \d + ) ? [ ^ . ] * ) (?: \. ( m i n | p a c k ) ) ? \. j s ) / ) ,
97
68
jquery2Releases = coreReleases . filter ( function ( match ) {
@@ -137,22 +108,18 @@ grunt.registerTask( "build-index", function() {
137
108
138
109
function getUiData ( ) {
139
110
var majorReleases = { } ,
140
- uiReleases = grunt . file . expandDirs ( "cdn/ui/*" )
111
+ uiReleases = grunt . file . expand ( { filter : "isDirectory" } , "cdn/ui/*" )
141
112
. 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" ;
147
114
148
115
return {
149
116
filename : filename ,
150
- version : version ,
117
+ version : dir . substring ( 7 ) ,
151
118
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
+ } )
156
123
} ;
157
124
} )
158
125
. sort ( function ( a , b ) {
@@ -185,7 +152,7 @@ grunt.registerTask( "build-index", function() {
185
152
}
186
153
187
154
function getMobileData ( ) {
188
- var files = grunt . file . expandFiles ( "cdn/mobile/*/*.css" ) ,
155
+ var files = grunt . file . expand ( "cdn/mobile/*/*.css" ) ,
189
156
releases = files . map ( function ( file ) {
190
157
var version = / c d n \/ m o b i l e \/ ( [ ^ \/ ] + ) / . exec ( file ) [ 1 ] ,
191
158
filename = "mobile/" + version + "/jquery.mobile-" + version + ".js" ,
@@ -232,7 +199,7 @@ grunt.registerTask( "build-index", function() {
232
199
}
233
200
234
201
function getColorData ( ) {
235
- var files = grunt . file . expandFiles ( "cdn/color/*.js" ) ,
202
+ var files = grunt . file . expand ( "cdn/color/*.js" ) ,
236
203
releases = parseReleases ( files ,
237
204
/ ( c o l o r \/ j q u e r y .c o l o r - ( \d + \. \d + (?: \. \d + ) ? [ ^ . ] * ) (?: \. ( m i n ) ) ? \. j s ) / ) ,
238
205
modes = [ "svg-names" , "plus-names" ] ;
@@ -263,7 +230,7 @@ grunt.registerTask( "build-index", function() {
263
230
}
264
231
265
232
function getQunitData ( ) {
266
- var files = grunt . file . expandFiles ( "cdn/qunit/*.js" ) ,
233
+ var files = grunt . file . expand ( "cdn/qunit/*.js" ) ,
267
234
releases = parseReleases ( files ,
268
235
/ ( q u n i t \/ q u n i t - ( \d + \. \d + \. \d + [ ^ . ] * ) (?: \. ( m i n ) ) ? \. j s ) / ) ;
269
236
@@ -317,7 +284,7 @@ grunt.registerTask( "build-index", function() {
317
284
} ) ( ) ) ;
318
285
319
286
var data = getCoreData ( ) ;
320
- data . ui = getUiData ( ) ,
287
+ data . ui = getUiData ( ) ;
321
288
data . mobile = getMobileData ( ) ;
322
289
data . color = getColorData ( ) ;
323
290
data . qunit = getQunitData ( ) ;
@@ -368,9 +335,7 @@ grunt.registerTask( "reload-listings", function() {
368
335
} ) ;
369
336
} ) ;
370
337
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" ] ) ;
375
340
376
341
} ;
0 commit comments