X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=Gruntfile.js;h=f3950f6f505f836e42fd3495b525259e7efa9c2e;hb=9d8759327a0285b7f2e85678e71961bc28a321a2;hp=fec43f343ca534ef54bda04b527378a9f2dea6f2;hpb=a125219ea18035e973491b7e94090d2091f75e8d;p=lhc%2Fweb%2Fwiklou.git diff --git a/Gruntfile.js b/Gruntfile.js index fec43f343c..f3950f6f50 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,11 +8,10 @@ module.exports = function ( grunt ) { grunt.loadNpmTasks( 'grunt-banana-checker' ); grunt.loadNpmTasks( 'grunt-contrib-copy' ); - grunt.loadNpmTasks( 'grunt-contrib-watch' ); grunt.loadNpmTasks( 'grunt-eslint' ); - grunt.loadNpmTasks( 'grunt-jsonlint' ); grunt.loadNpmTasks( 'grunt-karma' ); grunt.loadNpmTasks( 'grunt-stylelint' ); + grunt.loadNpmTasks( 'grunt-svgmin' ); karmaProxy[ wgScriptPath ] = { target: wgServer + wgScriptPath, @@ -22,10 +21,12 @@ module.exports = function ( grunt ) { grunt.initConfig( { eslint: { options: { - reportUnusedDisableDirectives: true + reportUnusedDisableDirectives: true, + extensions: [ '.js', '.json' ], + cache: true }, all: [ - '**/*.js', + '**/*.js{,on}', '!docs/**', '!node_modules/**', '!resources/lib/**', @@ -35,18 +36,13 @@ module.exports = function ( grunt ) { '!tests/coverage/**', '!vendor/**', // Explicitly say "**/*.js" here in case of symlinks - '!extensions/**/*.js', - '!skins/**/*.js' - ] - }, - jsonlint: { - all: [ - '**/*.json', - '!{docs/js,extensions,node_modules,skins,vendor}/**' + '!extensions/**/*.js{,on}', + '!skins/**/*.js{,on}' ] }, banana: { options: { + requireLowerCase: false, disallowBlankTranslations: false }, core: 'languages/i18n/', @@ -57,6 +53,41 @@ module.exports = function ( grunt ) { stylelint: { src: '{resources/src,mw-config}/**/*.{css,less}' }, + svgmin: { + options: { + js2svg: { + indent: '\t', + pretty: true + }, + multipass: true, + plugins: [ { + cleanupIDs: false + }, { + removeDesc: false + }, { + removeRasterImages: true + }, { + removeTitle: false + }, { + removeViewBox: false + }, { + removeXMLProcInst: false + }, { + sortAttrs: true + } ] + }, + all: { + files: [ { + expand: true, + cwd: 'resources/src', + src: [ + '**/*.svg' + ], + dest: 'resources/src/', + ext: '.svg' + } ] + } + }, watch: { files: [ '.{stylelintrc,eslintrc.json}', @@ -67,6 +98,18 @@ module.exports = function ( grunt ) { }, karma: { options: { + customLaunchers: { + ChromeCustom: { + base: 'ChromeHeadless', + // Chrome requires --no-sandbox in Docker/CI. + // Newer CI images expose CHROMIUM_FLAGS which sets this (and + // anything else it might need) automatically. Older CI images, + // (including Quibble for MW) don't set it yet. + flags: ( process.env.CHROMIUM_FLAGS || + ( process.env.ZUUL_PROJECT ? '--no-sandbox' : '' ) + ).split( ' ' ) + } + }, proxies: karmaProxy, files: [ { pattern: wgServer + wgScriptPath + '/index.php?title=Special:JavaScriptTest/qunit/export', @@ -86,13 +129,10 @@ module.exports = function ( grunt ) { crossOriginAttribute: false }, main: { - browsers: [ 'Chrome' ] - }, - chromium: { - browsers: [ 'Chromium' ] + browsers: [ 'ChromeCustom' ] }, firefox: { - browsers: [ 'Firefox' ] + browsers: [ 'FirefoxHeadless' ] } }, copy: { @@ -120,9 +160,7 @@ module.exports = function ( grunt ) { return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH ); } ); + grunt.registerTask( 'minify', 'svgmin' ); grunt.registerTask( 'lint', [ 'eslint', 'banana', 'stylelint' ] ); grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] ); - - grunt.registerTask( 'test', [ 'lint' ] ); - grunt.registerTask( 'default', 'test' ); };