Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions features/scaffold-package-readme.feature
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,38 @@ Feature: Scaffold a README.md file for an existing package
"""
Error: Missing one or more commands defined in composer.json -> extras -> commands.
"""

Scenario: README for a bundled command
Given an empty directory
And a foo/composer.json file:
"""
{
"name": "runcommand/profile",
"authors": [],
"minimum-stability": "dev",
"autoload": {
"files": [ "command.php" ]
},
"require": {
},
"require-dev": {
"wp-cli/wp-cli": "*",
"behat/behat": "~2.5"
},
"extra": {
"bundled": true
}
}
"""

When I run `wp scaffold package-readme foo`
Then the foo/README.md file should exist
And the foo/README.md file should contain:
"""
runcommand/profile
==================
"""
And the foo/README.md file should contain:
"""
This package is included with WP-CLI itself
"""
8 changes: 7 additions & 1 deletion src/ScaffoldPackageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,15 @@ public function package_readme( $args, $assoc_args ) {
'heading' => $section_heading,
);
}
$bundled = ! empty( $composer_obj['extra']['bundled'] );
foreach( array( 'using', 'installing', 'contributing' ) as $key ) {
if ( isset( $readme_sections[ $key ] ) ) {
$readme_sections[ $key ]['body'] = dirname( dirname( __FILE__ ) ) . '/templates/readme-' . $key . '.mustache';
$file = dirname( dirname( __FILE__ ) ) . '/templates/readme-' . $key . '.mustache';
if ( $bundled
&& file_exists( dirname( dirname( __FILE__ ) ) . '/templates/readme-' . $key . '-bundled.mustache' ) ) {
$file = dirname( dirname( __FILE__ ) ) . '/templates/readme-' . $key . '-bundled.mustache';
}
$readme_sections[ $key ]['body'] = $file;
}
}

Expand Down
5 changes: 5 additions & 0 deletions templates/readme-installing-bundled.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This package is included with WP-CLI itself, no additional installation necessary.

To install the latest version of this package over what's included in WP-CLI, run:

wp package install git@github.com:{{package_name}}.git