UnitTest:JQM Unit TC helper has been added,TCs have been modified
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.2.0 / grunt.js
1 var path = require( 'path' ), fs = require( 'fs' );
2
3 module.exports = function( grunt ) {
4         var dirs, names, min = {}, cssmin = {},
5                 theme, rootFile, structureFile, themeFile,
6                 verOfficial, suffix;
7
8         dirs = {
9                 output: 'compiled',
10                 temp: 'tmp'
11         };
12
13         verOfficial = grunt.file.read( 'version.txt' ).replace(/\n/, '');
14
15         suffix = process.env.IS_DEPLOY_TARGET === "true" ? "-" + verOfficial : "";
16
17         names= {
18                 base: 'jquery.mobile' + suffix,
19                 // this will change for the deploy target to include version information
20                 root: 'jquery.mobile' + suffix,
21                 structure: 'jquery.mobile.structure' + suffix,
22                 theme: 'jquery.mobile.theme' + suffix
23         };
24
25         function outputPath( name ){
26                 return path.join( dirs.output, name );
27         }
28
29         rootFile = outputPath( names.root );
30         structureFile = outputPath( names.structure );
31         themeFile = outputPath( names.theme );
32
33         // TODO again, I'd like to use grunt params but I'm not sure
34         //      how to get that working with a custom task with deps
35         theme =  process.env.THEME || 'default';
36
37         // Project configuration.
38         grunt.config.init({
39                 jshint: {
40                         options: {
41                                 curly: true,
42                                 eqeqeq: true,
43
44                                 // (function(){})() seems acceptable
45                                 immed: false,
46                                 latedef: true,
47                                 newcap: true,
48                                 noarg: true,
49                                 sub: true,
50                                 undef: true,
51                                 boss: true,
52                                 eqnull: true,
53                                 browser: true
54                         },
55
56                         globals: {
57                                 jQuery: true,
58                                 "$": true,
59
60                                 // qunit globals
61                                 // TODO would be nice to confine these to test files
62                                 module: true,
63                                 ok: true,
64                                 test: true,
65                                 asyncTest: true,
66                                 same: true,
67                                 start: true,
68                                 stop: true,
69                                 expect: true,
70
71                                 // require js global
72                                 define: true,
73                                 require: true
74                         }
75                 },
76
77                 // TODO add test files here once we can specify different configs for
78                 //      different globs
79                 lint: {
80                         files: [ 'js/**/*.mobile.*.js', 'js/*/*.js' ]
81                 },
82
83                 // NOTE these configuration settings are used _after_ compilation has taken place
84                 //      using requirejs. Thus the .compiled extensions. The exception being the theme concat
85                 concat: {
86                         js: {
87                                 src: [ '<banner:global.ver.header>', rootFile + '.compiled.js' ],
88                                 dest: rootFile + '.js'
89                         },
90
91                         structure: {
92                                 src: [ '<banner:global.ver.header>', structureFile + '.compiled.css' ],
93                                 dest: structureFile + '.css'
94                         },
95
96                         regular: {
97                                 src: [ '<banner:global.ver.header>', rootFile + '.compiled.css' ],
98                                 dest: rootFile + '.css'
99                         },
100
101                         theme: {
102                                 src: [
103                                         '<banner:global.ver.header>',
104                                         'css/themes/' + theme + '/jquery.mobile.theme.css'
105                                 ],
106                                 dest: themeFile + '.css'
107                         }
108                 },
109
110                 // NOTE the keys are filenames which, being stored as variables requires that we use
111                 //      key based assignment. See below.
112                 min: undefined,
113                 cssmin: undefined,
114
115                 // JS config, mostly the requirejs configuration
116                 js: {
117                         require: {
118                                 baseUrl: 'js',
119                                 name: 'jquery.mobile',
120                                 exclude: [
121                                         'jquery',
122                                         'depend',
123                                         'text',
124                                         'text!../version.txt'
125                                 ],
126                                 out: rootFile + '.compiled.js',
127                                 pragmasOnSave: { jqmBuildExclude: true },
128                                 wrap: { startFile: 'build/wrap.start', endFile: 'build/wrap.end' },
129                                 findNestedDependencies: true,
130                                 skipModuleInsertion: true,
131                                 optimize: 'none'
132                         }
133                 },
134
135                 // CSS config, mostly the requirejs configuration
136                 css: {
137                         theme: process.env.THEME || 'default',
138
139                         themeFile: themeFile,
140
141                         require: {
142                                 all: {
143                                         cssIn: 'css/themes/default/jquery.mobile.css',
144                                         optimizeCss: 'standard.keepComments.keepLines',
145                                         baseUrl: '.',
146                                         out: rootFile + '.compiled.css'
147                                 },
148
149                                 structure: {
150                                         cssIn: 'css/structure/jquery.mobile.structure.css',
151                                         out: structureFile + '.compiled.css'
152                                 }
153                         }
154                 },
155
156                 global: {
157                         dirs: dirs,
158
159                         names: names,
160
161                         files: {
162                                 license: 'LICENSE-INFO.txt'
163                         },
164
165                         // other version information is added via the asyncConfig helper that
166                         // depends on git commands (eg ver.min, ver.header)
167                         ver: {
168                                 official: verOfficial,
169                                 min: '/*! jQuery Mobile v<%= build_sha %> jquerymobile.com | jquery.org/license !*/',
170                                 gitLongSha: 'git log -1 --format=format:"Git Build: SHA1: %H <> Date: %cd"',
171                                 gitShortSha: 'git log -1 --format=format:"%H"'
172                         },
173
174                         shas: {}
175                 }
176         });
177
178         // MIN configuration
179         min[ rootFile + '.min.js' ] = [ "<banner:global.ver.min>", rootFile + '.js' ];
180         grunt.config.set( 'min', min );
181
182         // CSSMIN configuration
183         cssmin[ rootFile + '.min.css' ] = [ "<banner:global.ver.min>", rootFile + '.css' ];
184         cssmin[ structureFile + '.min.css' ] = [ "<banner:global.ver.min>", structureFile + '.css' ];
185         cssmin[ themeFile + '.min.css' ] = [ "<banner:global.ver.min>", themeFile + '.css' ];
186         grunt.config.set( 'cssmin', cssmin );
187
188         // set the default task.
189         grunt.registerTask('default', 'lint');
190
191         // csslint and cssmin tasks
192         grunt.loadNpmTasks( "grunt-css" );
193
194         // authors task
195         grunt.loadNpmTasks( "grunt-git-authors" );
196
197         grunt.loadNpmTasks( "grunt-junit" );
198
199         // A convenient task alias.
200         grunt.registerTask('test', 'config:test:pages config:test junit');
201
202         // Ease of use aliases for users who want the zip and docs
203         grunt.registerTask('docs', 'js css legacy_tasks:docs');
204         grunt.registerTask('zip', 'js css legacy_tasks:zip');
205
206         // load the project's default tasks
207         grunt.loadTasks( 'build/tasks');
208 };