diff --git a/features/scaffold.feature b/features/scaffold.feature index 23aee121b..19e1e3c52 100644 --- a/features/scaffold.feature +++ b/features/scaffold.feature @@ -209,8 +209,7 @@ Feature: WordPress code scaffolding And the {PLUGIN_DIR}/hello-world/.editorconfig file should exist And the {PLUGIN_DIR}/hello-world/hello-world.php file should exist And the {PLUGIN_DIR}/hello-world/readme.txt file should exist - And the {PLUGIN_DIR}/hello-world/package.json file should exist - And the {PLUGIN_DIR}/hello-world/Gruntfile.js file should exist + And the {PLUGIN_DIR}/hello-world/composer.json file should exist And the {PLUGIN_DIR}/hello-world/.gitignore file should contain: """ .DS_Store @@ -219,6 +218,7 @@ Feature: WordPress code scaffolding Thumbs.db wp-cli.local.yml node_modules/ + vendor/ """ And the {PLUGIN_DIR}/hello-world/.distignore file should contain: """ @@ -254,14 +254,10 @@ Feature: WordPress code scaffolding Tested up to: {WP_VERSION} """ - When I run `cat {PLUGIN_DIR}/hello-world/package.json` - Then STDOUT should be JSON containing: - """ - {"author":"Hello World Author"} - """ - And STDOUT should be JSON containing: + When I run `cat {PLUGIN_DIR}/hello-world/composer.json` + Then STDOUT should contain: """ - {"version":"0.1.0"} + wp-cli/i18n-command """ Scenario: Scaffold a plugin by prompting diff --git a/src/Scaffold_Command.php b/src/Scaffold_Command.php index 99734daaa..74423231e 100644 --- a/src/Scaffold_Command.php +++ b/src/Scaffold_Command.php @@ -670,8 +670,7 @@ public function plugin( $args, $assoc_args ) { $files_to_create = [ $plugin_path => self::mustache_render( 'plugin.mustache', $data ), $plugin_readme_path => self::mustache_render( 'plugin-readme.mustache', $data ), - "{$plugin_dir}/package.json" => self::mustache_render( 'plugin-packages.mustache', $data ), - "{$plugin_dir}/Gruntfile.js" => self::mustache_render( 'plugin-gruntfile.mustache', $data ), + "{$plugin_dir}/composer.json" => self::mustache_render( 'plugin-composer.mustache', $data ), "{$plugin_dir}/.gitignore" => self::mustache_render( 'plugin-gitignore.mustache', $data ), "{$plugin_dir}/.distignore" => self::mustache_render( 'plugin-distignore.mustache', $data ), "{$plugin_dir}/.editorconfig" => file_get_contents( self::get_template_path( '.editorconfig' ) ), diff --git a/templates/plugin-composer.mustache b/templates/plugin-composer.mustache new file mode 100644 index 000000000..aa3ad7147 --- /dev/null +++ b/templates/plugin-composer.mustache @@ -0,0 +1,8 @@ +{ + "require-dev": { + "wp-cli/i18n-command": "^2" + }, + "scripts": { + "makepot": "wp i18n make-pot ." + } +} diff --git a/templates/plugin-gitignore.mustache b/templates/plugin-gitignore.mustache index 6f68bc7f6..6cc91535c 100644 --- a/templates/plugin-gitignore.mustache +++ b/templates/plugin-gitignore.mustache @@ -4,6 +4,7 @@ phpunit.xml Thumbs.db wp-cli.local.yml node_modules/ +vendor/ *.sql *.tar.gz *.zip diff --git a/templates/plugin-gruntfile.mustache b/templates/plugin-gruntfile.mustache deleted file mode 100644 index eda2254e6..000000000 --- a/templates/plugin-gruntfile.mustache +++ /dev/null @@ -1,56 +0,0 @@ -module.exports = function( grunt ) { - - 'use strict'; - - // Project configuration - grunt.initConfig( { - - pkg: grunt.file.readJSON( 'package.json' ), - - addtextdomain: { - options: { - textdomain: '{{textdomain}}', - }, - update_all_domains: { - options: { - updateDomains: true - }, - src: [ '*.php', '**/*.php', '!\.git/**/*', '!bin/**/*', '!node_modules/**/*', '!tests/**/*' ] - } - }, - - wp_readme_to_markdown: { - your_target: { - files: { - 'README.md': 'readme.txt' - } - }, - }, - - makepot: { - target: { - options: { - domainPath: '/languages', - exclude: [ '\.git/*', 'bin/*', 'node_modules/*', 'tests/*' ], - mainFile: '{{plugin_slug}}.php', - potFilename: '{{plugin_slug}}.pot', - potHeaders: { - poedit: true, - 'x-poedit-keywordslist': true - }, - type: 'wp-plugin', - updateTimestamp: true - } - } - }, - } ); - - grunt.loadNpmTasks( 'grunt-wp-i18n' ); - grunt.loadNpmTasks( 'grunt-wp-readme-to-markdown' ); - grunt.registerTask( 'default', [ 'i18n','readme' ] ); - grunt.registerTask( 'i18n', ['addtextdomain', 'makepot'] ); - grunt.registerTask( 'readme', ['wp_readme_to_markdown'] ); - - grunt.util.linefeed = '\n'; - -}; diff --git a/templates/plugin-packages.mustache b/templates/plugin-packages.mustache deleted file mode 100644 index 04a4733ec..000000000 --- a/templates/plugin-packages.mustache +++ /dev/null @@ -1,17 +0,0 @@ - -{ - "name": "{{plugin_slug}}", - "version": "0.1.0", - "main": "Gruntfile.js", - "author": "{{plugin_author}}", - "scripts" : { - "start" : "grunt default" , - "readme" : "grunt readme", - "i18n" : "grunt i18n" - }, - "devDependencies": { - "grunt": "~0.4.5", - "grunt-wp-i18n": "~0.5.0", - "grunt-wp-readme-to-markdown": "~1.0.0" - } -}