2013-05-31 02:33:12 +00:00
|
|
|
/*!
|
|
|
|
* Grunt file
|
|
|
|
*
|
|
|
|
* @package VisualEditor
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*jshint node:true */
|
|
|
|
module.exports = function ( grunt ) {
|
2013-12-19 23:07:19 +00:00
|
|
|
var modules = grunt.file.readJSON( 'lib/ve/build/modules.json' );
|
2013-05-31 02:33:12 +00:00
|
|
|
|
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-csslint' );
|
2014-06-04 03:07:12 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
|
2013-05-31 02:33:12 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-watch' );
|
2014-04-04 22:22:57 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-banana-checker' );
|
2013-12-06 02:34:44 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-jscs-checker' );
|
2013-12-19 23:07:19 +00:00
|
|
|
grunt.loadTasks( 'lib/ve/build/tasks' );
|
2013-12-14 23:04:08 +00:00
|
|
|
grunt.loadTasks( 'build/tasks' );
|
2013-05-31 02:33:12 +00:00
|
|
|
|
|
|
|
grunt.initConfig( {
|
|
|
|
pkg: grunt.file.readJSON( 'package.json' ),
|
2013-12-19 23:07:19 +00:00
|
|
|
jsduckcatconfig: {
|
|
|
|
main: {
|
|
|
|
target: '.docs/categories.json',
|
|
|
|
from: [
|
|
|
|
'.docs/mw-categories.json',
|
|
|
|
{
|
|
|
|
file: 'lib/ve/.docs/categories.json',
|
|
|
|
aggregate: {
|
|
|
|
'VisualEditor (core)': [
|
|
|
|
'General',
|
|
|
|
'Initialization',
|
|
|
|
'DataModel',
|
|
|
|
'ContentEditable',
|
|
|
|
'User Interface',
|
|
|
|
'Tests'
|
|
|
|
]
|
|
|
|
},
|
2014-05-15 16:12:43 +00:00
|
|
|
include: [ 'UnicodeJS', 'OOJS UI', 'Upstream' ]
|
2013-12-19 01:07:54 +00:00
|
|
|
}
|
2013-12-19 23:07:19 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
buildloader: {
|
|
|
|
egiframe: {
|
2014-05-14 22:04:52 +00:00
|
|
|
targetFile: '.docs/eg-iframe.html',
|
2013-12-19 23:07:19 +00:00
|
|
|
template: '.docs/eg-iframe.html.template',
|
2013-12-14 23:04:08 +00:00
|
|
|
modules: modules,
|
2014-05-21 20:09:56 +00:00
|
|
|
load: [ 'visualEditor.desktop.standalone' ],
|
2014-01-16 20:31:15 +00:00
|
|
|
pathPrefix: 'lib/ve/',
|
2013-12-14 23:04:08 +00:00
|
|
|
indent: '\t\t'
|
|
|
|
}
|
|
|
|
},
|
2013-05-31 02:33:12 +00:00
|
|
|
jshint: {
|
2013-12-18 05:08:36 +00:00
|
|
|
options: {
|
2014-06-04 03:07:12 +00:00
|
|
|
jshintrc: true
|
2013-12-18 05:08:36 +00:00
|
|
|
},
|
2013-12-18 04:33:22 +00:00
|
|
|
all: [
|
|
|
|
'*.js',
|
2013-12-19 23:07:19 +00:00
|
|
|
'{.docs,build}/**/*.js',
|
2013-12-19 20:28:07 +00:00
|
|
|
'modules/**/*.js'
|
2013-12-18 04:33:22 +00:00
|
|
|
]
|
2013-05-31 02:33:12 +00:00
|
|
|
},
|
2013-12-06 02:34:44 +00:00
|
|
|
jscs: {
|
2014-06-04 03:07:12 +00:00
|
|
|
src: '<%= jshint.all %>'
|
2013-12-06 02:34:44 +00:00
|
|
|
},
|
2013-05-31 02:33:12 +00:00
|
|
|
csslint: {
|
|
|
|
options: {
|
|
|
|
csslintrc: '.csslintrc'
|
|
|
|
},
|
2014-06-04 03:07:12 +00:00
|
|
|
all: 'modules/*/**/*.css'
|
2013-05-31 02:33:12 +00:00
|
|
|
},
|
2014-04-04 22:22:57 +00:00
|
|
|
banana: {
|
|
|
|
all: 'modules/ve-{mw,wmf}/i18n/'
|
|
|
|
},
|
2013-05-31 02:33:12 +00:00
|
|
|
watch: {
|
2013-12-18 04:33:22 +00:00
|
|
|
files: [
|
2014-05-06 22:12:39 +00:00
|
|
|
'.{csslintrc,jscsrc,jshintignore,jshintrc}',
|
2013-12-18 04:33:22 +00:00
|
|
|
'<%= jshint.all %>',
|
2013-12-19 23:07:19 +00:00
|
|
|
'<%= csslint.all %>'
|
2013-12-18 04:33:22 +00:00
|
|
|
],
|
2014-05-15 16:12:43 +00:00
|
|
|
tasks: 'test'
|
2013-05-31 02:33:12 +00:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2014-06-26 11:24:06 +00:00
|
|
|
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.write( ret );
|
|
|
|
grunt.log.error( 'Unstaged changes.' );
|
|
|
|
done( false );
|
|
|
|
} else {
|
|
|
|
grunt.log.ok( 'No unstaged changes.' );
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2014-05-15 16:12:43 +00:00
|
|
|
grunt.registerTask( 'build', [ 'jsduckcatconfig', 'buildloader' ] );
|
|
|
|
grunt.registerTask( 'lint', [ 'jshint', 'jscs', 'csslint', 'banana' ] );
|
|
|
|
grunt.registerTask( 'test', [ 'build', 'lint' ] );
|
2014-06-26 11:24:06 +00:00
|
|
|
grunt.registerTask( 'test-ci', [ 'git-status' ] );
|
2014-05-15 16:12:43 +00:00
|
|
|
grunt.registerTask( 'default', 'test' );
|
2014-06-26 11:24:06 +00:00
|
|
|
|
|
|
|
if ( process.env.JENKINS_HOME ) {
|
|
|
|
grunt.renameTask( 'test', 'test-internal' );
|
|
|
|
grunt.registerTask( 'test', [ 'test-internal', 'test-ci' ] );
|
|
|
|
} else {
|
|
|
|
grunt.registerTask( 'ci', [ 'test', 'test-ci' ] );
|
|
|
|
}
|
2013-05-31 02:33:12 +00:00
|
|
|
};
|