2013-05-28 01:57:39 +04:00
|
|
|
/**
|
|
|
|
* How to run grunt tasks:
|
|
|
|
* - At project root, run 'npm install' - It will install nodedependencies declared in package,json in <root>/.node_modules
|
|
|
|
* - install grunt CLI tools globally, run 'npm install -g grunt-cli'
|
|
|
|
* - run a grunt target defined in Gruntfiles.js, ex: 'grunt lint'
|
|
|
|
*
|
|
|
|
* Note: The 'ghost' grunt task have special deps on CasperJS and phantomjs.
|
2013-08-04 20:27:32 +04:00
|
|
|
* For now, It's configured to run only on TravisCI where these deps are
|
2013-05-28 01:57:39 +04:00
|
|
|
* correctly defined.
|
2013-08-04 20:27:32 +04:00
|
|
|
* If you run this task locally, it may require some env set up first.
|
2013-05-28 01:57:39 +04:00
|
|
|
*/
|
|
|
|
|
2013-05-27 02:02:48 +04:00
|
|
|
module.exports = function(grunt) {
|
2013-08-11 15:37:23 +04:00
|
|
|
var piskelScripts = require('./piskel-script-list.js').scripts;
|
|
|
|
var getGhostConfig = function (delay) {
|
|
|
|
return {
|
|
|
|
filesSrc : ['tests/integration/casperjs/*_test.js'],
|
|
|
|
options : {
|
|
|
|
args : {
|
2013-08-11 22:51:04 +04:00
|
|
|
baseUrl : 'http://localhost:' + '<%= connect.test.options.port %>/',
|
2013-08-11 15:37:23 +04:00
|
|
|
mode : '?debug',
|
|
|
|
delay : delay
|
|
|
|
},
|
|
|
|
direct : false,
|
|
|
|
logLevel : 'info',
|
|
|
|
printCommand : false,
|
|
|
|
printFilePaths : true
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2013-08-04 20:27:32 +04:00
|
|
|
grunt.initConfig({
|
2013-08-10 14:11:16 +04:00
|
|
|
jshint: {
|
|
|
|
options: {
|
2013-08-10 16:28:10 +04:00
|
|
|
indent:2,
|
|
|
|
undef : true,
|
|
|
|
latedef : true,
|
|
|
|
browser : true,
|
2013-09-30 00:50:24 +04:00
|
|
|
trailing : true,
|
2013-09-29 01:52:51 +04:00
|
|
|
curly : true,
|
|
|
|
es3 : true,
|
2013-09-07 19:50:43 +04:00
|
|
|
globals : {'$':true, 'jQuery' : true, 'pskl':true, 'Events':true, 'Constants':true, 'console' : true, 'module':true, 'require':true}
|
2013-08-10 14:11:16 +04:00
|
|
|
},
|
|
|
|
files: [
|
2013-08-04 20:27:32 +04:00
|
|
|
'Gruntfile.js',
|
|
|
|
'package.json',
|
|
|
|
'js/**/*.js',
|
|
|
|
'!js/lib/**/*.js' // Exclude lib folder (note the leading !)
|
|
|
|
]
|
|
|
|
},
|
|
|
|
connect : {
|
2013-08-11 22:51:04 +04:00
|
|
|
test : {
|
2013-08-04 20:27:32 +04:00
|
|
|
options : {
|
|
|
|
base : '.',
|
2013-08-11 22:51:04 +04:00
|
|
|
port : 4321
|
|
|
|
}
|
|
|
|
},
|
|
|
|
serve : {
|
|
|
|
options : {
|
|
|
|
base : '.',
|
|
|
|
port : 1234,
|
|
|
|
keepalive : true
|
2013-08-04 20:27:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ghost : {
|
2013-09-29 01:52:51 +04:00
|
|
|
'default' : getGhostConfig(3000),
|
2013-08-11 15:37:23 +04:00
|
|
|
local : getGhostConfig(50)
|
2013-08-04 20:27:32 +04:00
|
|
|
},
|
|
|
|
concat : {
|
|
|
|
options : {
|
2013-09-29 01:52:51 +04:00
|
|
|
separator : ';'
|
2013-08-04 20:27:32 +04:00
|
|
|
},
|
|
|
|
dist : {
|
2013-08-11 15:37:23 +04:00
|
|
|
src : piskelScripts,
|
2013-09-29 01:52:51 +04:00
|
|
|
dest : 'build/piskel-packaged.js'
|
|
|
|
}
|
2013-08-04 20:27:32 +04:00
|
|
|
},
|
|
|
|
uglify : {
|
|
|
|
options : {
|
|
|
|
mangle : true
|
|
|
|
},
|
|
|
|
my_target : {
|
|
|
|
files : {
|
|
|
|
'build/piskel-packaged-min.js' : ['build/piskel-packaged.js']
|
|
|
|
}
|
|
|
|
}
|
2013-09-28 20:51:10 +04:00
|
|
|
},
|
|
|
|
closureCompiler: {
|
|
|
|
options: {
|
|
|
|
// [REQUIRED] Path to closure compiler
|
2013-09-28 21:06:35 +04:00
|
|
|
compilerFile: 'closure_compiler_20130823.jar',
|
2013-09-28 20:51:10 +04:00
|
|
|
|
|
|
|
// [OPTIONAL] set to true if you want to check if files were modified
|
|
|
|
// before starting compilation (can save some time in large sourcebases)
|
2013-09-28 23:28:45 +04:00
|
|
|
//checkModified: true,
|
2013-09-28 20:51:10 +04:00
|
|
|
|
|
|
|
// [OPTIONAL] Set Closure Compiler Directives here
|
|
|
|
compilerOpts: {
|
|
|
|
/**
|
|
|
|
* Keys will be used as directives for the compiler
|
|
|
|
* values can be strings or arrays.
|
|
|
|
* If no value is required use null
|
|
|
|
*/
|
2013-09-28 23:10:12 +04:00
|
|
|
//compilation_level: 'ADVANCED_OPTIMIZATIONS',
|
2013-09-28 21:06:35 +04:00
|
|
|
compilation_level: 'SIMPLE_OPTIMIZATIONS',
|
2013-09-28 23:10:12 +04:00
|
|
|
externs: ['piskel-closure-externs.js'],
|
2013-09-28 23:28:45 +04:00
|
|
|
// Inject some constants in JS code, could we use that for appengine wiring ?
|
|
|
|
//define: ["'goog.DEBUG=false'"],
|
2013-09-28 21:06:35 +04:00
|
|
|
warning_level: 'verbose',
|
|
|
|
jscomp_off: ['checkTypes', 'fileoverviewTags'],
|
|
|
|
summary_detail_level: 1,
|
2013-09-28 23:10:12 +04:00
|
|
|
language_in: 'ECMASCRIPT3'
|
|
|
|
//output_wrapper: '"(function(){%output%}).call(this);"'
|
2013-09-28 20:51:10 +04:00
|
|
|
},
|
|
|
|
execOpts: { // [OPTIONAL] Set exec method options
|
2013-09-28 21:06:35 +04:00
|
|
|
maxBuffer: 999999 * 1024
|
2013-09-28 20:51:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
compile: {
|
|
|
|
|
|
|
|
/**
|
|
|
|
*[OPTIONAL] Here you can add new or override previous option of the Closure Compiler Directives.
|
|
|
|
* IMPORTANT! The feature is enabled as a temporary solution to [#738](https://github.com/gruntjs/grunt/issues/738).
|
|
|
|
* As soon as issue will be fixed this feature will be removed.
|
|
|
|
*/
|
|
|
|
TEMPcompilerOpts: {
|
|
|
|
},
|
|
|
|
src: [
|
|
|
|
'js/**/*.js',
|
2013-09-28 23:10:12 +04:00
|
|
|
//'!js/lib/**/*.js',
|
|
|
|
'!js/lib/bootstrap/**/*.js',
|
|
|
|
'!js/lib/jsColor_1_4_0/**/*.js',
|
|
|
|
'!js/lib/gif/**/*.js',
|
2013-09-28 20:51:10 +04:00
|
|
|
'piskel-boot.js',
|
|
|
|
'piskel-script-list.js'
|
2013-09-28 23:28:45 +04:00
|
|
|
],
|
2013-09-28 20:51:10 +04:00
|
|
|
|
2013-09-28 23:28:45 +04:00
|
|
|
// This generated JS binary is currently not used and even excluded from source control using .gitignore.
|
|
|
|
dest: 'closure_compiled_binary.js'
|
2013-09-28 20:51:10 +04:00
|
|
|
}
|
2013-08-04 20:27:32 +04:00
|
|
|
}
|
|
|
|
});
|
2013-05-27 01:58:59 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
grunt.config.set('leadingIndent.indentation', 'spaces');
|
|
|
|
grunt.config.set('leadingIndent.jsFiles', {
|
|
|
|
src: ['js/**/*.js','!js/lib/**/*.js']
|
|
|
|
});
|
|
|
|
grunt.config.set('leadingIndent.cssFiles', {
|
|
|
|
src: ['css/**/*.css']
|
|
|
|
});
|
2013-05-27 01:58:59 +04:00
|
|
|
|
2013-08-04 20:27:32 +04:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-connect');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
2013-09-28 20:51:10 +04:00
|
|
|
grunt.loadNpmTasks('grunt-closure-tools');
|
2013-08-04 20:27:32 +04:00
|
|
|
grunt.loadNpmTasks('grunt-ghost');
|
2013-08-10 16:47:26 +04:00
|
|
|
grunt.loadNpmTasks('grunt-leading-indent');
|
2013-08-10 14:11:16 +04:00
|
|
|
|
2013-08-11 22:51:04 +04:00
|
|
|
// Validate
|
2013-08-10 16:47:26 +04:00
|
|
|
grunt.registerTask('lint', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint']);
|
2013-05-27 01:58:59 +04:00
|
|
|
|
2013-09-29 01:52:51 +04:00
|
|
|
// Validate & Test
|
2013-09-28 21:11:41 +04:00
|
|
|
grunt.registerTask('test', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'compile', 'connect:test', 'ghost:default']);
|
2013-08-11 22:51:04 +04:00
|
|
|
|
|
|
|
// Validate & Test (faster version) will NOT work on travis !!
|
2013-09-28 23:10:12 +04:00
|
|
|
grunt.registerTask('precommit', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'compile', 'connect:test', 'ghost:local']);
|
2013-08-11 22:51:04 +04:00
|
|
|
|
2013-09-28 20:51:10 +04:00
|
|
|
// Compile JS code (eg verify JSDoc annotation and types, no actual minified code generated).
|
|
|
|
grunt.registerTask('compile', ['closureCompiler:compile']);
|
2013-08-11 22:51:04 +04:00
|
|
|
|
|
|
|
// Validate & Build
|
2013-09-28 23:10:12 +04:00
|
|
|
grunt.registerTask('default', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'concat', 'compile', 'uglify']);
|
2013-08-11 22:51:04 +04:00
|
|
|
|
|
|
|
// Start webserver
|
|
|
|
grunt.registerTask('serve', ['connect:serve']);
|
2013-05-27 02:02:48 +04:00
|
|
|
};
|