mediawiki-extensions-Visual.../Gruntfile.js
Timo Tijhof 7f613ed571 build: Change pathPrefix for eg-iframe back from '../lib' to 'lib'
Follows-up 94a7e34. The main fix there was adding the promise to
the example execution. The path change was not needed, and actually
breaks the demo, again. Only the 'docs' directory is published.
Accessing ../lib results in 404 Not Found after syncing to doc.wikimedia.org.

This is why we run 'grunt copy:jsduck', which copies those files into
the docs/ directory.

Change-Id: I2ea89bfbd980910510cbd8639f871ec931a768f1
2016-11-18 16:12:16 -08:00

189 lines
4.2 KiB
JavaScript

/*!
* Grunt file
*
* @package VisualEditor
*/
require( 'babel-polyfill' );
/* eslint-env node */
module.exports = function ( grunt ) {
var modules = grunt.file.readJSON( 'lib/ve/build/modules.json' );
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-mocha-test' );
grunt.loadNpmTasks( 'grunt-stylelint' );
grunt.loadNpmTasks( 'grunt-tyops' );
grunt.loadTasks( 'lib/ve/build/tasks' );
grunt.loadTasks( 'build/tasks' );
grunt.initConfig( {
jsduckcatconfig: {
main: {
target: '.jsduck/categories.json',
from: [
'.jsduck/mw-categories.json',
{
file: 'lib/ve/.jsduck/categories.json',
aggregate: {
'VisualEditor (core)': [
'General',
'Initialization',
'DataModel',
'ContentEditable',
'User Interface',
'Tests'
]
},
include: [ 'UnicodeJS', 'OOjs UI', 'Upstream' ]
}
]
}
},
buildloader: {
egiframe: {
targetFile: '.jsduck/eg-iframe.html',
template: '.jsduck/eg-iframe.html.template',
modules: modules,
load: [ 'visualEditor.desktop.standalone' ],
pathPrefix: 'lib/ve/',
indent: '\t\t'
}
},
mochaTest: {
'screenshots-en': {
options: {
reporter: 'spec',
timeout: 40000,
require: [
function () {
// eslint-disable-next-line no-undef
langs = [ 'en' ];
}
]
},
src: [ 'build/screenshots.js' ]
},
'screenshots-all': {
options: {
reporter: 'spec',
timeout: 40000,
require: [
function () {
// eslint-disable-next-line no-undef
langs = require( './build/tasks/screenshotLangs.json' ).langs;
}
]
},
src: [ 'build/screenshots.js' ]
}
},
tyops: {
options: {
typos: 'build/typos.json'
},
src: [
'**/*.{js,json,less,css,txt}',
'!build/typos.json',
'!lib/**',
'!{docs,node_modules,vendor}/**',
'!.git/**'
]
},
eslint: {
fix: {
options: {
fix: true
},
src: [
'<%= eslint.all %>'
]
},
all: [
'*.js',
'{build,modules}/**/*.js',
'!modules/ve-mw/init/classListSkipFunction.js'
]
},
stylelint: {
all: [
'**/*.css',
'!coverage/**',
'!dist/**',
'!docs/**',
'!lib/**',
'!node_modules/**'
]
},
banana: {
all: [
'modules/ve-{mw,wmf}/i18n/'
]
},
jsonlint: {
all: [
'*.json',
'.eslintrc.json',
'**/*.json',
'!**/node_modules/**',
'!lib/**'
]
},
copy: {
jsduck: {
src: 'lib/ve/**/*',
dest: 'docs/',
expand: true
}
},
watch: {
files: [
'.{stylelintrc,eslintrc.json}',
'<%= eslint.all %>',
'<%= stylelint.all %>'
],
tasks: 'test'
}
} );
grunt.registerTask( 'git-status', function () {
var done = this.async();
// Are there unstaged changes?
require( 'child_process' ).exec( 'git ls-files --modified', function ( err, stdout, stderr ) {
var ret = err || stderr || stdout;
if ( ret ) {
grunt.log.error( 'Unstaged changes in these files:' );
grunt.log.error( ret );
// Show a condensed diff
require( 'child_process' ).exec( 'git diff -U1 | tail -n +3', function ( err, stdout, stderr ) {
grunt.log.write( err || stderr || stdout );
done( false );
} );
} else {
grunt.log.ok( 'No unstaged changes.' );
done();
}
} );
} );
grunt.registerTask( 'build', [ 'jsduckcatconfig', 'buildloader' ] );
grunt.registerTask( 'lint', [ 'tyops', 'eslint:all', 'stylelint', 'jsonlint', 'banana' ] );
grunt.registerTask( 'fix', [ 'eslint:fix' ] );
grunt.registerTask( 'test', [ 'build', 'lint' ] );
grunt.registerTask( 'test-ci', [ 'git-status' ] );
grunt.registerTask( 'screenshots', [ 'mochaTest:screenshots-en' ] );
grunt.registerTask( 'screenshots-all', [ 'mochaTest:screenshots-all' ] );
grunt.registerTask( 'default', 'test' );
if ( process.env.JENKINS_HOME ) {
grunt.renameTask( 'test', 'test-internal' );
grunt.registerTask( 'test', [ 'test-internal', 'test-ci' ] );
} else {
grunt.registerTask( 'ci', [ 'test', 'test-ci' ] );
}
};