From 1ad3f0ae0ec5d12d69fcb8ea6ec6673f398a7af7 Mon Sep 17 00:00:00 2001 From: Fulvio Notarstefano Date: Sun, 18 Oct 2015 17:10:38 +0200 Subject: [PATCH] Update composer and add Grunt support to handle build and deploy --- .gitignore | 17 ++---- Gruntfile.js | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++ composer.json | 2 +- package.json | 28 ++++++++++ 4 files changed, 185 insertions(+), 13 deletions(-) create mode 100644 Gruntfile.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore index e6e808a..d1f7ae9 100644 --- a/.gitignore +++ b/.gitignore @@ -11,28 +11,21 @@ sftp-config.json .floo .flooignore -### Node ### +### Dev ### +/build /node_modules/ -/deploy/ - -### Bower ### -/bower_components - -### Sass ### -.sass-cache/ - -### Composer ### /vendor/ composer.lock -### Unit tests ### +### Tests ### /tmp /tests/bin/tmp ### Logs ### +*.log /logs -### VCS ### +### SVN ### .svn /svn diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..edb087e --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,151 @@ +module.exports = function( grunt ) { + + var pkg = grunt.file.readJSON( 'package.json' ); + + console.log( pkg.title + ' - ' + pkg.version ); + + // Files to include in a release. + var distFiles = [ + 'lib/**', + 'LICENSE.txt', + 'plugin.php', + 'README.txt' + ]; + + grunt.initConfig( { + + pkg: pkg, + + checktextdomain: { + options: { + text_domain : 'wp-api-menus', + correct_domain: false, + 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', + ' __ngettext:1,2,3d', + '__ngettext_noop:1,2,3d', + '_c:1,2d', + '_nc:1,2,4c,5d' + ] + }, + files : { + src : [ + 'lib/**/*.php', + 'plugin.php' + ], + expand: true + } + }, + + makepot: { + target: { + options: { + cwd : '', + domainPath : '/languages', + potFilename : 'wp-api-menus.pot', + mainFile : 'plugin.php', + include : [], + exclude : [ + 'assets/', + 'build/', + 'languages/', + 'svn', + 'tests', + 'tmp', + 'vendor' + ], + potComments : '', + potHeaders : { + poedit : true, + 'x-poedit-keywordslist': true, + 'language' : 'en_US', + 'report-msgid-bugs-to' : 'https://github.com/nekojira/wp-api-menus/issues', + 'last-translator' : 'Fulvio Notarstefano ', + 'language-Team' : 'Fulvio Notarstefano ' + }, + type : 'wp-plugin', + updateTimestamp: true, + updatePoFiles : true, + processPot : null + } + } + }, + + po2mo: { + options: { + deleteSrc: true + }, + files : { + src : 'languages/*.po', + expand: true + } + }, + + clean: { + build: [ 'build' ] + }, + + copy: { + main: { + expand: true, + src : distFiles, + dest : 'build/wp-api-menus' + } + }, + + compress: { + main: { + options: { + mode : 'zip', + archive: './build/wp-api-menus-<%= pkg.version %>.zip' + }, + expand : true, + src : distFiles, + dest : '/wp-api-menus' + } + }, + + wp_deploy: { + deploy: { + options: { + plugin_slug : 'wp-api-menus', + plugin_main_file: 'plugin.php', + build_dir : 'build/wp-api-menus', + max_buffer : 400 * 1024 + } + } + }, + + phpunit: { + classes: { + dir: 'tests/phpunit/unit-tests' + }, + options: { + bin : 'vendor/bin/phpunit', + configuration: 'phpunit.xml', + testSuffix : '.php' + } + }, + + } ); + + require( 'load-grunt-tasks' )(grunt); + + grunt.registerTask( 'build', ['clean:build', 'copy', 'compress'] ); + grunt.registerTask( 'deploy', ['build', 'wp_deploy'] ); + + grunt.util.linefeed = '\n'; +}; diff --git a/composer.json b/composer.json index c87aa2c..03b43fe 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,6 @@ ], "require": { "php": ">=5.3.2", - "composer/installers": "v1.0.19" + "composer/installers": "~1.0" } } \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..41545d9 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "wp-api-menus", + "title": "WP API Menus", + "description": "Extends the WordPress JSON REST WP API with new routes pointing to WordPress menus.", + "version": "1.2.0", + "license": "GPL-2.0+", + "homepage": "https://wordpress.org/plugins/wp-api-menus", + "repository": { + "type": "git", + "url": "https://github.com/nekojira/wp-api-menus" + }, + "keywords": [], + "devDependencies": { + "autoprefixer": "^6.0.1", + "grunt": "^0.4.5", + "grunt-checktextdomain": "^1.0.0", + "grunt-contrib-clean": "^0.6.0", + "grunt-contrib-compress": "^0.13.0", + "grunt-contrib-copy": "^0.8.1", + "grunt-phpunit": "^0.3.6", + "grunt-po2mo": "^0.1.2", + "grunt-shell": "~1.1.2", + "grunt-wp-deploy": "^1.1.0", + "grunt-wp-i18n": "^0.5.2", + "load-grunt-tasks": "^3.2.0", + "reporter-plus": "jayeb/reporter-plus" + } +} \ No newline at end of file