2014-02-02 19:20:52 +00:00
|
|
|
/* jshint node:true */
|
|
|
|
module.exports = function( grunt ){
|
|
|
|
'use strict';
|
2014-01-30 16:11:02 +00:00
|
|
|
|
2014-02-02 19:22:05 +00:00
|
|
|
grunt.initConfig({
|
2014-02-02 19:24:02 +00:00
|
|
|
// setting folder templates
|
|
|
|
dirs: {
|
|
|
|
css: 'assets/css',
|
|
|
|
fonts: 'assets/fonts',
|
|
|
|
images: 'assets/images',
|
|
|
|
js: 'assets/js'
|
|
|
|
},
|
|
|
|
|
2014-02-02 19:49:30 +00:00
|
|
|
// Compile all .less files.
|
2014-02-02 19:22:05 +00:00
|
|
|
less: {
|
|
|
|
compile: {
|
|
|
|
options: {
|
|
|
|
// These paths are searched for @imports
|
2014-02-02 19:38:00 +00:00
|
|
|
paths: ['<%= dirs.css %>/']
|
2014-02-02 19:22:05 +00:00
|
|
|
},
|
2014-02-02 20:49:30 +00:00
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.css %>/',
|
|
|
|
src: [
|
|
|
|
'*.less',
|
|
|
|
'!woocommerce-base.less',
|
|
|
|
'!mixins.less'
|
|
|
|
],
|
|
|
|
dest: '<%= dirs.css %>/',
|
|
|
|
ext: '.css'
|
|
|
|
}]
|
2014-02-02 19:22:05 +00:00
|
|
|
}
|
|
|
|
},
|
2014-01-30 16:41:07 +00:00
|
|
|
|
2014-02-02 19:38:00 +00:00
|
|
|
// Minify all .css files.
|
2014-02-02 19:22:05 +00:00
|
|
|
cssmin: {
|
2014-02-02 19:38:00 +00:00
|
|
|
minify: {
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.css %>/',
|
|
|
|
src: ['*.css'],
|
|
|
|
dest: '<%= dirs.css %>/',
|
|
|
|
ext: '.css'
|
|
|
|
}
|
2014-02-02 19:22:05 +00:00
|
|
|
},
|
2014-01-30 16:41:07 +00:00
|
|
|
|
2014-02-02 20:47:06 +00:00
|
|
|
// Minify .js files.
|
|
|
|
uglify: {
|
|
|
|
options: {
|
|
|
|
preserveComments: 'some'
|
|
|
|
},
|
|
|
|
admin: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.js %>/admin/',
|
|
|
|
src: [
|
|
|
|
'*.js',
|
|
|
|
'!*.min.js',
|
2014-02-03 15:05:53 +00:00
|
|
|
'!Gruntfile.js',
|
2014-02-02 20:47:06 +00:00
|
|
|
'!jquery.flot*' // !jquery.flot* prevents to join all jquery.flot files in jquery.min.js
|
|
|
|
],
|
|
|
|
dest: '<%= dirs.js %>/admin/',
|
|
|
|
ext: '.min.js'
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
adminflot: { // minify correctly the jquery.flot lib
|
|
|
|
files: {
|
|
|
|
'<%= dirs.js %>/admin/jquery.flot.min.js': ['<%= dirs.js %>/admin/jquery.flot.js'],
|
|
|
|
'<%= dirs.js %>/admin/jquery.flot.pie.min.js': ['<%= dirs.js %>/admin/jquery.flot.pie.js'],
|
|
|
|
'<%= dirs.js %>/admin/jquery.flot.resize.min.js': ['<%= dirs.js %>/admin/jquery.flot.resize.js'],
|
|
|
|
'<%= dirs.js %>/admin/jquery.flot.stack.min.js': ['<%= dirs.js %>/admin/jquery.flot.stack.js'],
|
|
|
|
'<%= dirs.js %>/admin/jquery.flot.time.min.js': ['<%= dirs.js %>/admin/jquery.flot.time.js'],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
frontend: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.js %>/frontend/',
|
|
|
|
src: [
|
|
|
|
'*.js',
|
|
|
|
'!*.min.js'
|
|
|
|
],
|
|
|
|
dest: '<%= dirs.js %>/frontend/',
|
|
|
|
ext: '.min.js'
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2014-02-02 21:33:20 +00:00
|
|
|
// Watch changes for assets
|
|
|
|
watch: {
|
|
|
|
less: {
|
|
|
|
files: ['<%= dirs.css %>/*.less'],
|
2014-02-03 15:05:53 +00:00
|
|
|
tasks: ['less', 'cssmin'],
|
2014-02-02 21:33:20 +00:00
|
|
|
},
|
|
|
|
js: {
|
|
|
|
files: [
|
|
|
|
'<%= dirs.js %>/admin/*js',
|
|
|
|
'<%= dirs.js %>/frontend/*js',
|
|
|
|
'!<%= dirs.js %>/frontend/*.min.js',
|
|
|
|
'!<%= dirs.js %>/frontend/*.min.js',
|
|
|
|
],
|
|
|
|
tasks: ['uglify']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-02-02 19:22:05 +00:00
|
|
|
shell: {
|
2014-02-02 21:16:25 +00:00
|
|
|
options: {
|
|
|
|
stdout: true,
|
|
|
|
stderr: true
|
|
|
|
},
|
2014-02-02 20:08:35 +00:00
|
|
|
txpull: {
|
|
|
|
command: [
|
|
|
|
'cd i18n',
|
|
|
|
'tx pull -a -f',
|
|
|
|
].join( '&&' )
|
|
|
|
},
|
2014-02-02 19:22:05 +00:00
|
|
|
generatemos: {
|
|
|
|
command: [
|
|
|
|
'cd i18n/languages',
|
2014-02-02 21:16:25 +00:00
|
|
|
'for i in *.po; do msgfmt $i -o ${i%%.*}.mo; done'
|
|
|
|
].join( '&&' )
|
|
|
|
},
|
|
|
|
generatepot: {
|
|
|
|
command: [
|
|
|
|
'cd i18n/makepot/',
|
2014-02-03 16:39:23 +00:00
|
|
|
'sed -i "" "s/exit( \'Locked\' );/\\/\\/exit( \'Locked\' );/g" index.php',
|
2014-02-02 21:16:25 +00:00
|
|
|
'php index.php generate',
|
2014-02-03 16:39:23 +00:00
|
|
|
'sed -i "" "s/\\/\\/exit( \'Locked\' );/exit( \'Locked\' );/g" index.php',
|
2014-02-02 19:22:05 +00:00
|
|
|
].join( '&&' )
|
2014-02-14 14:29:30 +00:00
|
|
|
},
|
|
|
|
apigen: {
|
|
|
|
command: [
|
|
|
|
'cd apigen/',
|
|
|
|
'php apigen.php --source ../ --destination ../wc-apidocs --download yes --template-config ./templates/woodocs/config.neon --title "WooCommerce" --exclude "*/mijireh/*" --exclude "*/includes/libraries/*" --exclude "*/i18n/*" --exclude "*/node_modules/*" --exclude "*/deploy/*"',
|
|
|
|
].join( '&&' )
|
2014-02-02 19:22:05 +00:00
|
|
|
}
|
2014-02-10 12:52:41 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
copy: {
|
|
|
|
deploy: {
|
|
|
|
src: [
|
|
|
|
'**',
|
2014-02-10 13:12:03 +00:00
|
|
|
'!.*',
|
|
|
|
'!.*/**',
|
2014-02-10 12:52:41 +00:00
|
|
|
'.htaccess',
|
|
|
|
'!Gruntfile.js',
|
|
|
|
'!sftp-config.json',
|
|
|
|
'!package.json',
|
2014-02-14 14:29:30 +00:00
|
|
|
'!node_modules/**',
|
|
|
|
'!wc-apidocs/**'
|
2014-02-10 12:52:41 +00:00
|
|
|
],
|
2014-02-10 13:14:46 +00:00
|
|
|
dest: 'deploy',
|
2014-02-10 13:12:03 +00:00
|
|
|
expand: true,
|
|
|
|
dot: true
|
2014-02-10 12:52:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
clean: {
|
|
|
|
deploy: {
|
2014-02-10 13:14:46 +00:00
|
|
|
src: [ 'deploy' ]
|
2014-02-10 12:52:41 +00:00
|
|
|
},
|
2014-02-10 14:29:41 +00:00
|
|
|
}
|
2014-02-02 19:22:05 +00:00
|
|
|
});
|
2014-01-30 16:11:02 +00:00
|
|
|
|
2014-02-02 19:22:05 +00:00
|
|
|
// Load NPM tasks to be used here
|
|
|
|
grunt.loadNpmTasks( 'grunt-shell' );
|
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-less' );
|
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
|
2014-02-02 20:47:06 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
|
2014-02-02 21:33:20 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-watch' );
|
2014-02-10 12:52:41 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-copy' );
|
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-clean' );
|
2014-01-30 16:34:23 +00:00
|
|
|
|
2014-02-02 19:22:05 +00:00
|
|
|
// Register tasks
|
2014-02-02 20:08:35 +00:00
|
|
|
grunt.registerTask( 'default', [
|
|
|
|
'less',
|
|
|
|
'cssmin',
|
2014-02-02 20:47:06 +00:00
|
|
|
'uglify'
|
2014-02-02 20:08:35 +00:00
|
|
|
]);
|
|
|
|
|
2014-02-02 21:16:25 +00:00
|
|
|
// Just an alias for pot file generation
|
|
|
|
grunt.registerTask( 'pot', [
|
|
|
|
'shell:generatepot'
|
|
|
|
]);
|
|
|
|
|
2014-02-14 14:29:30 +00:00
|
|
|
grunt.registerTask( 'docs', [
|
|
|
|
'shell:apigen'
|
|
|
|
]);
|
|
|
|
|
2014-02-02 20:08:35 +00:00
|
|
|
grunt.registerTask( 'dev', [
|
|
|
|
'default',
|
|
|
|
'shell:txpull',
|
|
|
|
'shell:generatemos'
|
|
|
|
]);
|
2014-01-30 16:11:02 +00:00
|
|
|
|
2014-02-10 12:52:41 +00:00
|
|
|
grunt.registerTask( 'deploy', [
|
|
|
|
'clean:deploy',
|
2014-02-10 14:29:41 +00:00
|
|
|
'copy:deploy'
|
2014-02-10 12:52:41 +00:00
|
|
|
]);
|
|
|
|
|
2014-02-02 19:20:52 +00:00
|
|
|
};
|