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