Skip to content

Commit 030686c

Browse files
authored
Merge pull request #139 from wp-cli/scaffold-github-templates
Scaffold GitHub issue and pull request templates by default
2 parents 53f5148 + b5ce1e8 commit 030686c

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This package implements the following commands:
1616
Generate the files needed for a basic WP-CLI command.
1717

1818
~~~
19-
wp scaffold package <name> [--description=<description>] [--homepage=<homepage>] [--dir=<dir>] [--license=<license>] [--require_wp_cli=<version>] [--skip-tests] [--skip-readme] [--skip-install] [--force]
19+
wp scaffold package <name> [--description=<description>] [--homepage=<homepage>] [--dir=<dir>] [--license=<license>] [--require_wp_cli=<version>] [--skip-tests] [--skip-readme] [--skip-github] [--skip-install] [--force]
2020
~~~
2121

2222
Default behavior is to create the following files:
@@ -61,6 +61,9 @@ WP-CLI `packages/local/` directory.
6161
[--skip-readme]
6262
Don't generate a README.md for the package.
6363

64+
[--skip-github]
65+
Don't generate GitHub issue and pull request templates.
66+
6467
[--skip-install]
6568
Don't install the package after scaffolding.
6669

features/scaffold-package-github.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Feature: Scaffold GitHub configuration for an existing package
3030
When I run `wp package path`
3131
Then save STDOUT as {PACKAGE_PATH}
3232

33-
When I run `wp scaffold package wp-cli/default-github`
33+
When I run `wp scaffold package wp-cli/default-github --skip-github`
3434
Then the {PACKAGE_PATH}/local/wp-cli/default-github directory should exist
3535

3636
When I run `wp scaffold package-github {PACKAGE_PATH}/local/wp-cli/default-github`

features/scaffold-package.feature

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ Feature: Scaffold WP-CLI commands
4545
"""
4646
And the {PACKAGE_PATH}/local/wp-cli/foo/wp-cli.yml file should exist
4747
And the {PACKAGE_PATH}/local/wp-cli/foo/.travis.yml file should not exist
48+
And the {PACKAGE_PATH}/local/wp-cli/foo/.github/PULL_REQUEST_TEMPLATE file should exist
49+
And the {PACKAGE_PATH}/local/wp-cli/foo/.github/ISSUE_TEMPLATE file should exist
4850

4951
When I run `wp --require={PACKAGE_PATH}/local/wp-cli/foo/command.php hello-world`
5052
Then STDOUT should be:
@@ -147,13 +149,13 @@ Feature: Scaffold WP-CLI commands
147149
s
148150
"""
149151

150-
When I run `wp scaffold package wp-cli/same-package --skip-tests`
152+
When I run `wp scaffold package wp-cli/same-package --skip-tests --skip-github`
151153
Then STDOUT should contain:
152154
"""
153155
Success: Created package files
154156
"""
155157

156-
When I run `wp scaffold package wp-cli/same-package --skip-tests < session`
158+
When I run `wp scaffold package wp-cli/same-package --skip-tests --skip-github < session`
157159
And STDERR should contain:
158160
"""
159161
Warning: File already exists
@@ -231,10 +233,13 @@ Feature: Scaffold WP-CLI commands
231233
"""
232234
And the /tmp/wp-cli-home/foo directory should exist
233235
234-
Scenario: Scaffold a package but skip installation
236+
Scenario: Scaffold a package but skip installation and GitHub templates
235237
Given an empty directory
236238
237-
When I run `wp scaffold package wp-cli/foo --skip-install`
239+
When I run `wp package path`
240+
Then save STDOUT as {PACKAGE_PATH}
241+
242+
When I run `wp scaffold package wp-cli/foo --skip-install --skip-github`
238243
Then STDOUT should contain:
239244
"""
240245
Success: Created package files
@@ -243,3 +248,6 @@ Feature: Scaffold WP-CLI commands
243248
"""
244249
Installing package
245250
"""
251+
And the {PACKAGE_PATH}/local/wp-cli/foo/.gitignore file should exist
252+
And the {PACKAGE_PATH}/local/wp-cli/foo/.github/PULL_REQUEST_TEMPLATE file should not exist
253+
And the {PACKAGE_PATH}/local/wp-cli/foo/.github/ISSUE_TEMPLATE file should not exist

src/ScaffoldPackageCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ class ScaffoldPackageCommand {
5353
* [--skip-readme]
5454
* : Don't generate a README.md for the package.
5555
*
56+
* [--skip-github]
57+
* : Don't generate GitHub issue and pull request templates.
58+
*
5659
* [--skip-install]
5760
* : Don't install the package after scaffolding.
5861
*
@@ -124,6 +127,10 @@ public function package( $args, $assoc_args ) {
124127
WP_CLI::runcommand( "scaffold package-readme {$package_dir} {$force_flag}", array( 'launch' => false ) );
125128
}
126129

130+
if ( ! Utils\get_flag_value( $assoc_args, 'skip-github' ) ) {
131+
WP_CLI::runcommand( "scaffold package-github {$package_dir} {$force_flag}", array( 'launch' => false ) );
132+
}
133+
127134
if ( ! Utils\get_flag_value( $assoc_args, 'skip-install' ) ) {
128135
WP_CLI::runcommand( "package install {$package_dir}", array( 'launch' => false ) );
129136
}

0 commit comments

Comments
 (0)