Skip to content

Commit

Permalink
added grunt
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiosanches committed Jan 16, 2014
1 parent 31b7d9a commit 9e6a65f
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
node_modules/
public/assets/js/*.min.js
24 changes: 24 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"es3": true,
"expr": true,
"immed": true,
"noarg": true,
"onevar": true,
"quotmark": "single",
"trailing": true,
"undef": true,
"unused": true,

"browser": true,

"globals": {
"_": false,
"Backbone": false,
"jQuery": false,
"wp": false
}
}
170 changes: 170 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/* jshint node:true */
'use strict';

module.exports = function( grunt ) {

// auto load grunt tasks
require( 'load-grunt-tasks' )( grunt );

var pluginConfig = {

// gets the package vars
pkg: grunt.file.readJSON( 'package.json' ),

// plugin directories
dirs: {
front: {
js: 'public/assets/js'
}
},

// svn settings
svn_settings: {
path: '../../../../wp_plugins/<%= pkg.name %>',
tag: '<%= svn_settings.path %>/tags/<%= pkg.version %>',
trunk: '<%= svn_settings.path %>/trunk',
exclude: [
'.editorconfig',
'.git/',
'.gitignore',
'.jshintrc',
'node_modules/',
'public/assets/js/update-checkout.js',
'Gruntfile.js',
'README.md',
'package.json',
'*.zip'
]
},

// javascript linting with jshint
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'<%= dirs.front.js %>/update-checkout.js'
]
},

// uglify to concat and minify
uglify: {
dist: {
files: {
'<%= dirs.front.js %>/update-checkout.min.js': ['<%= dirs.front.js %>/update-checkout.js']
}
}
},

// watch for changes and trigger compass, jshint and uglify
watch: {
js: {
files: [
'<%= jshint.all %>'
],
tasks: ['jshint', 'uglify']
}
},

// image optimization
imagemin: {
dist: {
options: {
optimizationLevel: 7,
progressive: true
},
files: [
{
expand: true,
cwd: './',
src: 'screenshot-*.png',
dest: './'
}
]
}
},

// rsync commands used to take the files to svn repository
rsync: {
options: {
args: ['--verbose'],
exclude: '<%= svn_settings.exclude %>',
syncDest: true,
recursive: true
},
tag: {
options: {
src: './',
dest: '<%= svn_settings.tag %>'
}
},
trunk: {
options: {
src: './',
dest: '<%= svn_settings.trunk %>'
}
}
},

// shell command to commit the new version of the plugin
shell: {
// Remove delete files.
svn_remove: {
command: 'svn st | grep \'^!\' | awk \'{print $2}\' | xargs svn --force delete',
options: {
stdout: true,
stderr: true,
execOptions: {
cwd: '<%= svn_settings.path %>'
}
}
},
// Add new files.
svn_add: {
command: 'svn add --force * --auto-props --parents --depth infinity -q',
options: {
stdout: true,
stderr: true,
execOptions: {
cwd: '<%= svn_settings.path %>'
}
}
},
// Commit the changes.
svn_commit: {
command: 'svn commit -m "updated the plugin version to <%= pkg.version %>"',
options: {
stdout: true,
stderr: true,
execOptions: {
cwd: '<%= svn_settings.path %>'
}
}
}
}
};

// initialize grunt config
// --------------------------
grunt.initConfig( pluginConfig );

// register tasks
// --------------------------

// default task
grunt.registerTask( 'default', [
'jshint',
'uglify'
] );

// deploy task
grunt.registerTask( 'deploy', [
'default',
'rsync:tag',
'rsync:trunk',
'shell:svn_remove',
'shell:svn_add',
'shell:svn_commit'
] );
};
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "woocommerce-payment-discounts",
"description": "WooCommerce Discounts Per Payment Method",
"version": "2.0.0",
"main": "Gruntfile.js",
"devDependencies": {
"grunt": "~0.4.1",
"load-grunt-tasks": "0.2.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-jshint": "~0.7.2",
"grunt-contrib-uglify": "~0.2.7",
"grunt-contrib-imagemin": "~0.4.0",
"grunt-rsync": "~0.2.1",
"grunt-shell": "~0.6.1"
},
"engines": {
"node": ">=0.8.0",
"npm": ">=1.1.0"
}
}
2 changes: 1 addition & 1 deletion public/class-wc-payment-discounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function load_plugin_textdomain() {
*/
public function enqueue_scripts() {
if ( is_checkout() ) {
wp_enqueue_script( self::$plugin_slug, plugins_url( 'assets/js/update-checkout.js', __FILE__ ), array( 'wc-checkout' ), self::VERSION );
wp_enqueue_script( self::$plugin_slug, plugins_url( 'assets/js/update-checkout.min.js', __FILE__ ), array( 'wc-checkout' ), self::VERSION );
}
}

Expand Down

0 comments on commit 9e6a65f

Please sign in to comment.