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
|
|
|
|
2015-04-03 09:33:22 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-copy' );
|
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' );
|
2015-06-13 08:14:38 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-jsonlint' );
|
2014-04-04 22:22:57 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-banana-checker' );
|
2014-07-18 20:21:27 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-jscs' );
|
2015-12-09 00:44:55 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-tyops' );
|
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( {
|
2013-12-19 23:07:19 +00:00
|
|
|
jsduckcatconfig: {
|
|
|
|
main: {
|
2015-03-05 22:51:53 +00:00
|
|
|
target: '.jsduck/categories.json',
|
2013-12-19 23:07:19 +00:00
|
|
|
from: [
|
2015-03-05 22:51:53 +00:00
|
|
|
'.jsduck/mw-categories.json',
|
2013-12-19 23:07:19 +00:00
|
|
|
{
|
2015-03-03 08:26:34 +00:00
|
|
|
file: 'lib/ve/.jsduck/categories.json',
|
2013-12-19 23:07:19 +00:00
|
|
|
aggregate: {
|
|
|
|
'VisualEditor (core)': [
|
|
|
|
'General',
|
|
|
|
'Initialization',
|
|
|
|
'DataModel',
|
|
|
|
'ContentEditable',
|
|
|
|
'User Interface',
|
|
|
|
'Tests'
|
|
|
|
]
|
|
|
|
},
|
2015-06-10 19:28:09 +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: {
|
2015-03-05 22:51:53 +00:00
|
|
|
targetFile: '.jsduck/eg-iframe.html',
|
|
|
|
template: '.jsduck/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'
|
|
|
|
}
|
|
|
|
},
|
2015-12-09 00:44:55 +00:00
|
|
|
tyops: {
|
|
|
|
options: {
|
|
|
|
typos: 'build/typos.json'
|
|
|
|
},
|
|
|
|
src: [
|
|
|
|
'**/*.{js,json,less,css,txt}',
|
|
|
|
'!build/typos.json',
|
|
|
|
'!lib/**',
|
|
|
|
'!{docs,node_modules,vendor}/**',
|
|
|
|
'!.git/**'
|
|
|
|
]
|
|
|
|
},
|
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',
|
2015-03-05 22:51:53 +00:00
|
|
|
'{.jsduck,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: {
|
2015-06-03 23:33:39 +00:00
|
|
|
fix: {
|
|
|
|
options: {
|
|
|
|
fix: true
|
|
|
|
},
|
|
|
|
src: '<%= jshint.all %>'
|
|
|
|
},
|
|
|
|
main: {
|
|
|
|
src: '<%= jshint.all %>'
|
|
|
|
}
|
2013-12-06 02:34:44 +00:00
|
|
|
},
|
2013-05-31 02:33:12 +00:00
|
|
|
csslint: {
|
|
|
|
options: {
|
|
|
|
csslintrc: '.csslintrc'
|
|
|
|
},
|
2014-10-11 01:21:21 +00:00
|
|
|
all: 'modules/**/*.css'
|
2013-05-31 02:33:12 +00:00
|
|
|
},
|
2014-04-04 22:22:57 +00:00
|
|
|
banana: {
|
2015-07-18 14:30:01 +00:00
|
|
|
all: [
|
|
|
|
'modules/ve-{mw,wmf}/i18n/',
|
|
|
|
'modules/ve-mw/tests/browser/i18n'
|
|
|
|
]
|
2014-04-04 22:22:57 +00:00
|
|
|
},
|
2015-06-13 08:14:38 +00:00
|
|
|
jsonlint: {
|
|
|
|
all: [
|
2016-03-29 16:53:56 +00:00
|
|
|
'*.json',
|
2015-06-13 08:14:38 +00:00
|
|
|
'**/*.json',
|
2015-10-29 17:26:47 +00:00
|
|
|
'!**/node_modules/**',
|
2015-06-22 17:33:32 +00:00
|
|
|
'!lib/**'
|
2015-06-13 08:14:38 +00:00
|
|
|
]
|
|
|
|
},
|
2015-04-03 09:33:22 +00:00
|
|
|
copy: {
|
|
|
|
jsduck: {
|
|
|
|
src: 'lib/ve/**/*',
|
|
|
|
dest: 'docs/',
|
|
|
|
expand: true
|
|
|
|
}
|
|
|
|
},
|
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 ) {
|
2015-06-01 15:15:06 +00:00
|
|
|
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 );
|
|
|
|
} );
|
2014-06-26 11:24:06 +00:00
|
|
|
} else {
|
|
|
|
grunt.log.ok( 'No unstaged changes.' );
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2014-05-15 16:12:43 +00:00
|
|
|
grunt.registerTask( 'build', [ 'jsduckcatconfig', 'buildloader' ] );
|
2015-12-09 00:44:55 +00:00
|
|
|
grunt.registerTask( 'lint', [ 'tyops', 'jshint', 'jscs:main', 'csslint', 'jsonlint', 'banana' ] );
|
2015-06-03 23:33:39 +00:00
|
|
|
grunt.registerTask( 'fix', [ 'jscs:fix' ] );
|
2014-05-15 16:12:43 +00:00
|
|
|
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
|
|
|
};
|