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