From 47966d0153294604156416b116bd193b74f59a92 Mon Sep 17 00:00:00 2001 From: Stephen Harris Date: Sat, 7 Dec 2013 12:20:24 +0000 Subject: [PATCH] Update gruntfile and package.json --- Gruntfile.js | 150 ++++++++++++++++++++++++++++++++++++++++++++++----- package.json | 16 ++++-- 2 files changed, 150 insertions(+), 16 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9ddf570..230bed8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,8 +1,11 @@ module.exports = function(grunt) { + require('load-grunt-tasks')(grunt); + // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), + uglify: { options: { compress: { @@ -14,21 +17,25 @@ module.exports = function(grunt) { banner: '/*! <%= pkg.name %> <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd HH:MM") %> */\n' }, build: { - files: { - 'js/frontend.min.js': ['js/frontend.js'], - 'js/fullcalendar.min.js': ['js/fullcalendar.js'], - } + files: [{ + expand: true, // Enable dynamic expansion. + src: ['js/*.js', '!js/*.min.js' ], + ext: '.min.js', // Dest filepaths will have this extension. + }] } }, + jshint: { options: { globals: { "WP_MARKDOWN_SCRIPT_DEBUG": false, }, + reporter: require('jshint-stylish'), '-W020': true, //Read only - error when assigning WP_MARKDOWN_SCRIPT_DEBUG a value. }, all: [ 'js/*.js', '!js/*.min.js' ] }, + wp_readme_to_markdown: { convert:{ files: { @@ -36,6 +43,7 @@ module.exports = function(grunt) { }, }, }, + phpunit: { classes: { dir: 'tests/php/' @@ -45,21 +53,137 @@ module.exports = function(grunt) { bootstrap: 'tests/php/phpunit.php', colors: true } - } -}); - + }, + + clean: { + //Clean up build folder + main: ['build/wp-markdown'] + }, + copy: { + // Copy the plugin to a versioned release directory + main: { + src: [ + '**', + '!node_modules/**', + '!build/**', + '!.git/**', + '!tests/**', + '!vendor/**', + '!Gruntfile.js', + '!package.json', + '!.gitignore', + '!.gitmodules', + '!*~', + '!composer.lock', + '!composer.phar', + '!composer.json', + '!CONTRIBUTING.md' + ], + dest: 'build/wp-markdown/' + } + }, + + checkrepo: { + deploy: { + tag: { + eq: '<%= pkg.version %>', // Check if highest repo tag is equal to pkg.version + }, + tagged: true, // Check if last repo commit (HEAD) is not tagged + clean: true, // Check if the repo working directory is clean + } + }, + + wp_deploy: { + deploy:{ + options: { + svn_user: 'stephenharris', + plugin_slug: 'wp-markdown', + build_dir: 'build/wp-markdown/' + }, + } + }, + + po2mo: { + files: { + src: 'languages/*.po', + expand: true, + }, + }, -grunt.loadNpmTasks('grunt-contrib-uglify'); + pot: { + options:{ + text_domain: 'wp-markdown', + dest: 'languages/', + keywords: ['__:1', + '_e:1', + '_x:1,2c', + 'esc_html__:1', + 'esc_html_e:1', + 'esc_html_x:1,2c', + 'esc_attr__:1', + 'esc_attr_e:1', + 'esc_attr_x:1,2c', + '_ex:1,2c', + '_n:1,2', + '_nx:1,2,4c', + '_n_noop:1,2', + '_nx_noop:1,2,3c' + ], + }, + files:{ + src: [ + '**/*.php', + '!node_modules/**', + '!build/**', + '!tests/**', + '!vendor/**', + '!*~', + ], + expand: true, + } + }, -grunt.loadNpmTasks('grunt-contrib-jshint'); + checktextdomain: { + options:{ + text_domain: 'wp-markdown', + 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' + ], + }, + files: { + src: [ + '**/*.php', + '!node_modules/**', + '!build/**', + '!tests/**', + '!vendor/**', + '!*~', + ], + expand: true, + }, + }, + +}); -grunt.loadNpmTasks('grunt-wp-readme-to-markdown'); -grunt.loadNpmTasks('grunt-phpunit'); +//Tasks +grunt.registerTask( 'test', [ 'phpunit', 'jshint' ] ); +grunt.registerTask( 'build', [ 'test', 'newer:uglify', 'pot', 'po2mo', 'wp_readme_to_markdown', 'clean', 'copy' ] ); +grunt.registerTask( 'deploy', [ 'checkbranch:master', 'checkrepo:deploy', 'build', 'wp_deploy' ] ); - // Default task(s). -grunt.registerTask('default', ['uglify']); grunt.registerTask('readme', ['wp_readme_to_markdown']); }; diff --git a/package.json b/package.json index 4803b3c..42ce75a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wp-markdown", - "version": "1.4.0", + "version": "1.5.0", "description": "Allows you to use MarkDown in posts, BBPress forums and comments", "main": "Gruntfile.js", "repository": { @@ -16,7 +16,17 @@ "grunt": "~0.4.1", "grunt-contrib-uglify": "~0.2.2", "grunt-contrib-jshint": "~0.6.3", - "grunt-wp-readme-to-markdown": "~0.1.0", - "grunt-phpunit": "~0.3.0" + "grunt-wp-readme-to-markdown": "~0.4.0", + "grunt-phpunit": "~0.3.0", + "grunt-checktextdomain": "~0.1.0", + "grunt-contrib-clean": "~0.5.0", + "grunt-contrib-copy": "~0.4.1", + "load-grunt-tasks": "~0.2.0", + "jshint-stylish": "~0.1.3", + "grunt-checkrepo": "~0.1.0", + "grunt-checkbranch": "~0.2.2", + "grunt-wp-deploy": "~0.2.0", + "grunt-po2mo": "~0.1.0", + "grunt-pot": "~0.1.0" } }