MessageCache invalidation improvements
[mediawiki.git] / Gruntfile.js
blob55b7932f002b1e4bfab0e935457d9751094ff39b
1 /* eslint-env node */
3 module.exports = function ( grunt ) {
5         var wgServer = process.env.MW_SERVER,
6                 wgScriptPath = process.env.MW_SCRIPT_PATH,
7                 karmaProxy = {};
9         grunt.loadNpmTasks( 'grunt-banana-checker' );
10         grunt.loadNpmTasks( 'grunt-contrib-copy' );
11         grunt.loadNpmTasks( 'grunt-contrib-watch' );
12         grunt.loadNpmTasks( 'grunt-eslint' );
13         grunt.loadNpmTasks( 'grunt-jsonlint' );
14         grunt.loadNpmTasks( 'grunt-karma' );
15         grunt.loadNpmTasks( 'grunt-stylelint' );
17         karmaProxy[ wgScriptPath ] = wgServer + wgScriptPath;
19         grunt.initConfig( {
20                 eslint: {
21                         all: [
22                                 '**/*.js',
23                                 '!docs/**',
24                                 '!tests/**',
25                                 '!node_modules/**',
26                                 '!resources/lib/**',
27                                 '!resources/src/jquery.tipsy/**',
28                                 '!resources/src/jquery/jquery.farbtastic.js',
29                                 '!resources/src/mediawiki.libs/**',
30                                 '!vendor/**',
31                                 // Explicitly say "**/*.js" here in case of symlinks
32                                 '!extensions/**/*.js',
33                                 '!skins/**/*.js',
34                                 // Skip functions aren't even parseable
35                                 '!resources/src/dom-level2-skip.js',
36                                 '!resources/src/es5-skip.js',
37                                 '!resources/src/mediawiki.hidpi-skip.js'
38                         ]
39                 },
40                 jsonlint: {
41                         all: [
42                                 '**/*.json',
43                                 '!{docs/js,extensions,node_modules,skins,vendor}/**'
44                         ]
45                 },
46                 banana: {
47                         options: {
48                                 disallowBlankTranslations: false
49                         },
50                         core: 'languages/i18n/',
51                         api: 'includes/api/i18n/',
52                         installer: 'includes/installer/i18n/'
53                 },
54                 stylelint: {
55                         options: {
56                                 syntax: 'less'
57                         },
58                         src: '{resources/src/*,mw-config/**}/*.{css,less}'
59                 },
60                 watch: {
61                         files: [
62                                 '.{stylelintrc,eslintrc.json}',
63                                 '**/*',
64                                 '!{docs,extensions,node_modules,skins,vendor}/**'
65                         ],
66                         tasks: 'test'
67                 },
68                 karma: {
69                         options: {
70                                 proxies: karmaProxy,
71                                 files: [ {
72                                         pattern: wgServer + wgScriptPath + '/index.php?title=Special:JavaScriptTest/qunit/export',
73                                         watched: false,
74                                         included: true,
75                                         served: false
76                                 } ],
77                                 logLevel: 'DEBUG',
78                                 frameworks: [ 'qunit' ],
79                                 reporters: [ 'progress' ],
80                                 singleRun: true,
81                                 autoWatch: false,
82                                 // Some tests in extensions don't yield for more than the default 10s (T89075)
83                                 browserNoActivityTimeout: 60 * 1000
84                         },
85                         main: {
86                                 browsers: [ 'Chrome' ]
87                         },
88                         more: {
89                                 browsers: [ 'Chrome', 'Firefox' ]
90                         }
91                 },
92                 copy: {
93                         jsduck: {
94                                 src: 'resources/**/*',
95                                 dest: 'docs/js/modules',
96                                 expand: true,
97                                 rename: function ( dest, src ) {
98                                         return require( 'path' ).join( dest, src.replace( 'resources/', '' ) );
99                                 }
100                         }
101                 }
102         } );
104         grunt.registerTask( 'assert-mw-env', function () {
105                 if ( !process.env.MW_SERVER ) {
106                         grunt.log.error( 'Environment variable MW_SERVER must be set.\n' +
107                                 'Set this like $wgServer, e.g. "http://localhost"'
108                         );
109                 }
110                 if ( !process.env.MW_SCRIPT_PATH ) {
111                         grunt.log.error( 'Environment variable MW_SCRIPT_PATH must be set.\n' +
112                                 'Set this like $wgScriptPath, e.g. "/w"' );
113                 }
114                 return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH );
115         } );
117         grunt.registerTask( 'lint', [ 'eslint', 'banana', 'stylelint' ] );
118         grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] );
120         grunt.registerTask( 'test', [ 'lint' ] );
121         grunt.registerTask( 'default', 'test' );