Skip to content

Commit 2e18c88

Browse files
Scaffold a README for WP-CLI command requiring latest stable
1 parent 150fc95 commit 2e18c88

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

features/scaffold-package-readme.feature

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,31 @@ Feature: Scaffold a README.md file for an existing package
7979
Success: Uninstalled package.
8080
"""
8181

82+
Scenario: Scaffold a README.md requiring the latest stable release
83+
Given an empty directory
84+
85+
When I run `wp scaffold package wp-cli/foo --dir=foo --require_wp_cli='*'`
86+
Then STDOUT should contain:
87+
"""
88+
Success: Created package readme.
89+
"""
90+
And the foo/composer.json file should contain:
91+
"""
92+
"require": {
93+
"wp-cli/wp-cli": "*"
94+
},
95+
"""
96+
And the foo/README.md file should exist
97+
And the foo/README.md file should contain:
98+
"""
99+
Installing this package requires WP-CLI's latest stable release. Update to the latest stable release with `wp cli update`.
100+
"""
101+
When I run `wp package uninstall wp-cli/foo`
102+
Then STDOUT should contain:
103+
"""
104+
Success: Uninstalled package.
105+
"""
106+
82107
Scenario: Scaffold a readme with custom shields
83108
Given an empty directory
84109
And a foo/composer.json file:

src/ScaffoldPackageCommand.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ public function package_readme( $args, $assoc_args ) {
236236
}
237237
}
238238

239+
$readme_args['wp_cli_requires_instructions'] = "requires WP-CLI {$readme_args['required_wp_cli_version']} or greater";
240+
if ( '*' === $readme_args['required_wp_cli_version'] ) {
241+
$readme_args['wp_cli_requires_instructions'] = "requires WP-CLI's latest stable release";
242+
}
243+
239244
if ( false !== stripos( $readme_args['required_wp_cli_version'], 'alpha' ) ) {
240245
$readme_args['wp_cli_update_to_instructions'] = 'the latest nightly release with `wp cli update --nightly`';
241246
}

templates/readme-installing.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Installing this package requires WP-CLI {{required_wp_cli_version}} or greater. Update to {{wp_cli_update_to_instructions}}.
1+
Installing this package {{wp_cli_requires_instructions}}. Update to {{wp_cli_update_to_instructions}}.
22

33
Once you've done so, you can install this package with:
44

0 commit comments

Comments
 (0)