2014-02-02 19:20:52 +00:00
|
|
|
/* jshint node:true */
|
2014-08-01 12:53:31 +00:00
|
|
|
module.exports = function( grunt ) {
|
2014-02-02 19:20:52 +00:00
|
|
|
'use strict';
|
2014-01-30 16:11:02 +00:00
|
|
|
|
2014-02-02 19:22:05 +00:00
|
|
|
grunt.initConfig({
|
2014-08-29 21:04:13 +00:00
|
|
|
|
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-08-29 21:04:13 +00:00
|
|
|
// JavaScript linting with JSHint.
|
2014-08-04 14:12:50 +00:00
|
|
|
jshint: {
|
|
|
|
options: {
|
|
|
|
jshintrc: '.jshintrc'
|
|
|
|
},
|
|
|
|
all: [
|
|
|
|
'Gruntfile.js',
|
|
|
|
'<%= dirs.js %>/admin/*.js',
|
|
|
|
'!<%= dirs.js %>/admin/*.min.js',
|
|
|
|
'!<%= dirs.js %>/admin/jquery.flot*',
|
|
|
|
'<%= dirs.js %>/frontend/*.js',
|
|
|
|
'!<%= dirs.js %>/frontend/*.min.js'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
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'],
|
2014-09-22 16:55:53 +00:00
|
|
|
'<%= dirs.js %>/admin/jquery.flot.time.min.js': ['<%= dirs.js %>/admin/jquery.flot.time.js']
|
2014-02-02 20:47:06 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
frontend: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.js %>/frontend/',
|
|
|
|
src: [
|
|
|
|
'*.js',
|
|
|
|
'!*.min.js'
|
|
|
|
],
|
|
|
|
dest: '<%= dirs.js %>/frontend/',
|
|
|
|
ext: '.min.js'
|
|
|
|
}]
|
2014-09-22 16:55:53 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Compile all .scss files.
|
|
|
|
sass: {
|
|
|
|
compile: {
|
2014-09-26 13:00:36 +00:00
|
|
|
options: {
|
|
|
|
sourcemap: 'none'
|
|
|
|
},
|
2014-09-22 16:55:53 +00:00
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.css %>/',
|
|
|
|
src: ['*.scss'],
|
|
|
|
dest: '<%= dirs.css %>/',
|
|
|
|
ext: '.css'
|
|
|
|
}]
|
|
|
|
}
|
2014-02-02 20:47:06 +00:00
|
|
|
},
|
|
|
|
|
2014-08-04 14:12:50 +00:00
|
|
|
// Minify all .css files.
|
|
|
|
cssmin: {
|
|
|
|
minify: {
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.css %>/',
|
|
|
|
src: ['*.css'],
|
|
|
|
dest: '<%= dirs.css %>/',
|
|
|
|
ext: '.css'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-08-29 21:04:13 +00:00
|
|
|
// Watch changes for assets.
|
2014-02-02 21:33:20 +00:00
|
|
|
watch: {
|
2014-09-22 16:55:53 +00:00
|
|
|
css: {
|
|
|
|
files: ['<%= dirs.css %>/*.scss'],
|
|
|
|
tasks: ['sass', 'cssmin']
|
2014-02-02 21:33:20 +00:00
|
|
|
},
|
|
|
|
js: {
|
|
|
|
files: [
|
|
|
|
'<%= dirs.js %>/admin/*js',
|
|
|
|
'<%= dirs.js %>/frontend/*js',
|
2014-02-19 19:53:00 +00:00
|
|
|
'!<%= dirs.js %>/admin/*.min.js',
|
2014-07-30 17:23:34 +00:00
|
|
|
'!<%= dirs.js %>/frontend/*.min.js'
|
2014-02-02 21:33:20 +00:00
|
|
|
],
|
|
|
|
tasks: ['uglify']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-08-29 21:04:13 +00:00
|
|
|
// Generate POT files.
|
2014-08-01 12:53:31 +00:00
|
|
|
makepot: {
|
|
|
|
options: {
|
|
|
|
type: 'wp-plugin',
|
|
|
|
domainPath: 'i18n/languages',
|
|
|
|
potHeaders: {
|
|
|
|
'report-msgid-bugs-to': 'https://github.com/woothemes/woocommerce/issues',
|
|
|
|
'language-team': 'LANGUAGE <EMAIL@ADDRESS>'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
frontend: {
|
|
|
|
options: {
|
|
|
|
potFilename: 'woocommerce.pot',
|
|
|
|
exclude: [
|
|
|
|
'includes/admin/.*',
|
2014-08-29 18:14:15 +00:00
|
|
|
'apigen/.*',
|
|
|
|
'deploy/.*'
|
2014-08-01 12:53:31 +00:00
|
|
|
],
|
2014-08-01 21:05:30 +00:00
|
|
|
processPot: function ( pot ) {
|
2014-08-01 12:53:31 +00:00
|
|
|
pot.headers['project-id-version'] += ' Frontend';
|
|
|
|
return pot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
admin: {
|
|
|
|
options: {
|
|
|
|
potFilename: 'woocommerce-admin.pot',
|
2014-08-21 18:31:13 +00:00
|
|
|
include: [
|
|
|
|
'includes/admin/.*'
|
2014-08-01 12:53:31 +00:00
|
|
|
],
|
2014-08-01 21:05:30 +00:00
|
|
|
processPot: function ( pot ) {
|
2014-08-01 12:53:31 +00:00
|
|
|
pot.headers['project-id-version'] += ' Admin';
|
|
|
|
return pot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-08-29 21:04:13 +00:00
|
|
|
// Check textdomain errors.
|
2014-08-01 12:53:31 +00:00
|
|
|
checktextdomain: {
|
|
|
|
options:{
|
|
|
|
text_domain: 'woocommerce',
|
|
|
|
keywords: [
|
|
|
|
'__:1,2d',
|
|
|
|
'_e:1,2d',
|
|
|
|
'_x:1,2c,3d',
|
|
|
|
'esc_html__:1,2d',
|
|
|
|
'esc_html_e:1,2d',
|
|
|
|
'esc_html_x:1,2c,3d',
|
|
|
|
'esc_attr__:1,2d',
|
|
|
|
'esc_attr_e:1,2d',
|
|
|
|
'esc_attr_x:1,2c,3d',
|
|
|
|
'_ex:1,2c,3d',
|
|
|
|
'_n:1,2,4d',
|
|
|
|
'_nx:1,2,4c,5d',
|
|
|
|
'_n_noop:1,2,3d',
|
|
|
|
'_nx_noop:1,2,3c,4d'
|
2014-08-01 21:05:30 +00:00
|
|
|
]
|
2014-08-01 12:53:31 +00:00
|
|
|
},
|
|
|
|
files: {
|
|
|
|
src: [
|
|
|
|
'**/*.php', // Include all files
|
|
|
|
'!apigen/**', // Exclude apigen/
|
2014-08-29 21:12:06 +00:00
|
|
|
'!deploy/**', // Exclude deploy/
|
2014-08-01 12:53:31 +00:00
|
|
|
'!node_modules/**' // Exclude node_modules/
|
|
|
|
],
|
2014-08-01 21:05:30 +00:00
|
|
|
expand: true
|
|
|
|
}
|
2014-08-01 12:53:31 +00:00
|
|
|
},
|
|
|
|
|
2014-08-29 21:04:13 +00:00
|
|
|
// Exec shell commands.
|
2014-02-02 19:22:05 +00:00
|
|
|
shell: {
|
2014-02-02 21:16:25 +00:00
|
|
|
options: {
|
|
|
|
stdout: true,
|
|
|
|
stderr: true
|
|
|
|
},
|
2014-02-14 14:29:30 +00:00
|
|
|
apigen: {
|
|
|
|
command: [
|
|
|
|
'cd apigen/',
|
2014-09-22 16:55:53 +00:00
|
|
|
'php apigen.php --source ../ --destination ../wc-apidocs --download yes --template-config ./templates/woodocs/config.neon --title "WooCommerce" --exclude "*/mijireh/*" --exclude "*/includes/libraries/*" --exclude "*/api/*" --exclude "*/i18n/*" --exclude "*/node_modules/*" --exclude "*/deploy/*" --exclude "*/apigen/*" --exclude "*/wc-apidocs/*"'
|
2014-02-14 14:29:30 +00:00
|
|
|
].join( '&&' )
|
2014-02-02 19:22:05 +00:00
|
|
|
}
|
2014-02-10 12:52:41 +00:00
|
|
|
},
|
|
|
|
|
2014-08-29 21:04:13 +00:00
|
|
|
// Clean the directory.
|
2014-02-10 12:52:41 +00:00
|
|
|
clean: {
|
2014-02-14 15:09:35 +00:00
|
|
|
apigen: {
|
|
|
|
src: [ 'wc-apidocs' ]
|
2014-07-30 17:23:34 +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' );
|
2014-08-04 14:12:50 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
|
2014-02-02 20:47:06 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
|
2014-09-22 16:55:53 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-sass' );
|
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
|
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-clean' );
|
2014-08-01 12:53:31 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-wp-i18n' );
|
|
|
|
grunt.loadNpmTasks( 'grunt-checktextdomain' );
|
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', [
|
2014-09-26 13:00:36 +00:00
|
|
|
'css',
|
2014-02-02 20:47:06 +00:00
|
|
|
'uglify'
|
2014-02-02 20:08:35 +00:00
|
|
|
]);
|
|
|
|
|
2014-09-26 13:00:36 +00:00
|
|
|
grunt.registerTask( 'css', [
|
|
|
|
'sass',
|
|
|
|
'cssmin'
|
|
|
|
]);
|
|
|
|
|
2014-02-14 14:29:30 +00:00
|
|
|
grunt.registerTask( 'docs', [
|
2014-07-30 17:23:34 +00:00
|
|
|
'clean:apigen',
|
2014-02-14 14:29:30 +00:00
|
|
|
'shell:apigen'
|
|
|
|
]);
|
|
|
|
|
2014-02-02 20:08:35 +00:00
|
|
|
grunt.registerTask( 'dev', [
|
|
|
|
'default',
|
2014-08-01 12:53:31 +00:00
|
|
|
'makepot'
|
2014-02-02 20:08:35 +00:00
|
|
|
]);
|
2014-07-30 17:23:34 +00:00
|
|
|
};
|