API: Allow fetching login token from action=query&meta=tokens on private wikis
[mediawiki.git] / Gruntfile.js
blob354f0483b615d0986739df2738e1fc9148a6c51d
1 /*jshint node:true */
2 module.exports = function ( grunt ) {
3         grunt.loadNpmTasks( 'grunt-contrib-copy' );
4         grunt.loadNpmTasks( 'grunt-contrib-jshint' );
5         grunt.loadNpmTasks( 'grunt-contrib-watch' );
6         grunt.loadNpmTasks( 'grunt-banana-checker' );
7         grunt.loadNpmTasks( 'grunt-jscs' );
8         grunt.loadNpmTasks( 'grunt-jsonlint' );
9         grunt.loadNpmTasks( 'grunt-karma' );
11         var wgServer = process.env.MW_SERVER,
12                 wgScriptPath = process.env.MW_SCRIPT_PATH,
13                 karmaProxy = {};
15         karmaProxy[ wgScriptPath ] = wgServer + wgScriptPath;
17         grunt.initConfig( {
18                 jshint: {
19                         options: {
20                                 jshintrc: true
21                         },
22                         all: '.'
23                 },
24                 jscs: {
25                         all: '.'
26                 },
27                 jsonlint: {
28                         all: [
29                                 '.jscsrc',
30                                 '**/*.json',
31                                 '!{docs/js,extensions,node_modules,skins,vendor}/**'
32                         ]
33                 },
34                 banana: {
35                         options: {
36                                 disallowBlankTranslations: false
37                         },
38                         core: 'languages/i18n/',
39                         api: 'includes/api/i18n/',
40                         installer: 'includes/installer/i18n/'
41                 },
42                 watch: {
43                         files: [
44                                 '.js*',
45                                 '**/*',
46                                 '!{docs,extensions,node_modules,skins,vendor}/**'
47                         ],
48                         tasks: 'test'
49                 },
50                 karma: {
51                         options: {
52                                 proxies: karmaProxy,
53                                 files: [ {
54                                         pattern: wgServer + wgScriptPath + '/index.php?title=Special:JavaScriptTest/qunit/export',
55                                         watched: false,
56                                         included: true,
57                                         served: false
58                                 } ],
59                                 logLevel: 'DEBUG',
60                                 frameworks: [ 'qunit' ],
61                                 reporters: [ 'progress' ],
62                                 singleRun: true,
63                                 autoWatch: false,
64                                 // Some tests in extensions don't yield for more than the default 10s (T89075)
65                                 browserNoActivityTimeout: 60 * 1000
66                         },
67                         main: {
68                                 browsers: [ 'Chrome' ]
69                         },
70                         more: {
71                                 browsers: [ 'Chrome', 'Firefox' ]
72                         }
73                 },
74                 copy: {
75                         jsduck: {
76                                 src: 'resources/**/*',
77                                 dest: 'docs/js/modules',
78                                 expand: true,
79                                 rename: function ( dest, src ) {
80                                         return require( 'path' ).join( dest, src.replace( 'resources/', '' ) );
81                                 }
82                         }
83                 }
84         } );
86         grunt.registerTask( 'assert-mw-env', function () {
87                 if ( !process.env.MW_SERVER ) {
88                         grunt.log.error( 'Environment variable MW_SERVER must be set.\n' +
89                                 'Set this like $wgServer, e.g. "http://localhost"'
90                         );
91                 }
92                 if ( !process.env.MW_SCRIPT_PATH ) {
93                         grunt.log.error( 'Environment variable MW_SCRIPT_PATH must be set.\n' +
94                                 'Set this like $wgScriptPath, e.g. "/w"' );
95                 }
96                 return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH );
97         } );
99         grunt.registerTask( 'lint', [ 'jshint', 'jscs', 'jsonlint', 'banana' ] );
100         grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] );
102         grunt.registerTask( 'test', [ 'lint' ] );
103         grunt.registerTask( 'default', 'test' );