Skip to content

Commit 8514919

Browse files
authored
Merge branch 'main' into copilot/fix-readme-output-issue
2 parents be76a23 + f3df83d commit 8514919

16 files changed

+416
-101
lines changed

.gitattributes

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/.actrc export-ignore
2+
/.distignore export-ignore
3+
/.editorconfig export-ignore
4+
/.github export-ignore
5+
/.gitignore export-ignore
6+
/.typos.toml export-ignore
7+
/AGENTS.md export-ignore
8+
/behat.yml export-ignore
9+
/features export-ignore
10+
/phpcs.xml.dist export-ignore
11+
/phpstan.neon.dist export-ignore
12+
/phpunit.xml.dist export-ignore
13+
/tests export-ignore
14+
/wp-cli.yml export-ignore

.github/workflows/copilot-setup-steps.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@ jobs:
1717

1818
steps:
1919
- name: Checkout code
20-
uses: actions/checkout@v6
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2121

2222
- name: Check existence of composer.json file
2323
id: check_composer_file
24-
uses: andstor/file-existence-action@v3
25-
with:
26-
files: "composer.json"
24+
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
2725

2826
- name: Set up PHP environment
2927
if: steps.check_composer_file.outputs.files_exists == 'true'
30-
uses: shivammathur/setup-php@v2
28+
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
3129
with:
3230
php-version: 'latest'
3331
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -38,7 +36,7 @@ jobs:
3836

3937
- name: Install Composer dependencies & cache dependencies
4038
if: steps.check_composer_file.outputs.files_exists == 'true'
41-
uses: ramsey/composer-install@v3
39+
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v3
4240
env:
4341
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
4442
with:

.github/workflows/issue-triage.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ name: Issue and PR Triage
1313
required: false
1414
type: string
1515

16+
permissions:
17+
issues: write
18+
pull-requests: write
19+
actions: write
20+
contents: read
21+
models: read
22+
1623
jobs:
1724
issue-triage:
1825
uses: wp-cli/.github/.github/workflows/reusable-issue-triage.yml@main

.github/workflows/regenerate-readme.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
- "features/**"
1111
- "README.md"
1212

13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
1317
jobs:
1418
regenerate-readme:
1519
uses: wp-cli/.github/.github/workflows/reusable-regenerate-readme.yml@main

.github/workflows/welcome-new-contributors.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
- main
88
- master
99

10+
permissions:
11+
pull-requests: write
12+
1013
jobs:
1114
welcome:
1215
uses: wp-cli/.github/.github/workflows/reusable-welcome-new-contributors.yml@main

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ wp scaffold package <name> [--description=<description>] [--homepage=<homepage>]
2222
Default behavior is to create the following files:
2323
- command.php
2424
- composer.json (with package name, description, and license)
25-
- .gitignore, .editorconfig, and .distignore
25+
- LICENSE
26+
- .gitignore, .editorconfig, .distignore, and phpcs.xml.dist
2627
- README.md (via wp scaffold package-readme)
2728
- Test harness (via wp scaffold package-tests)
2829

@@ -52,7 +53,7 @@ WP-CLI `packages/local/` directory.
5253
[--require_wp_cli=<version>]
5354
Required WP-CLI version for the package.
5455
---
55-
default: ^2.12
56+
default: ^2.13
5657
---
5758

5859
[--require_wp_cli_tests=<version>]
@@ -193,7 +194,7 @@ WP-CLI Behat framework uses Behat ~2.5, which is installed with Composer.
193194
Generate a README.md for your command.
194195

195196
~~~
196-
wp scaffold package-readme <dir> [--force] [--branch=<branch>]
197+
wp scaffold package-readme <dir> [--force] [--branch=<branch>] [--license=<license>]
197198
~~~
198199

199200
Creates a README.md with Using, Installing, and Contributing instructions
@@ -230,15 +231,15 @@ composer.json includes:
230231
],
231232
"readme": {
232233
"shields": [
233-
"[![Build Status](https://travis-ci.org/runcommand/reset-password.svg?branch=master)](https://travis-ci.org/runcommand/reset-password)"
234+
"[![Build Status](https://travis-ci.org/runcommand/reset-password.svg?branch=main)](https://travis-ci.org/runcommand/reset-password)"
234235
],
235236
"sections": [
236237
"Using",
237238
"Installing",
238239
"Support"
239240
],
240241
"support": {
241-
"body": "https://raw.githubusercontent.com/runcommand/runcommand-theme/master/bin/readme-partials/support-open-source.md"
242+
"body": "https://raw.githubusercontent.com/runcommand/runcommand-theme/main/bin/readme-partials/support-open-source.md"
242243
},
243244
"show_powered_by": false
244245
}
@@ -257,7 +258,7 @@ For sections, "pre", "body" and "post" are supported. Example:
257258
```
258259
"support": {
259260
"pre": "highlight.md",
260-
"body": "https://raw.githubusercontent.com/runcommand/runcommand-theme/master/bin/readme-partials/support-open-source.md",
261+
"body": "https://raw.githubusercontent.com/runcommand/runcommand-theme/main/bin/readme-partials/support-open-source.md",
261262
"post": "This is additional text to show after main body content."
262263
},
263264
```
@@ -276,7 +277,13 @@ In this example:
276277
Overwrite the readme if it already exists.
277278

278279
[--branch=<branch>]
279-
Name of default branch of the underlying repository. Defaults to master.
280+
Name of default branch of the underlying repository. Defaults to main.
281+
282+
[--license=<license>]
283+
License for the package.
284+
---
285+
default: MIT
286+
---
280287

281288

282289

@@ -341,6 +348,10 @@ Want to contribute a new feature? Please first [open a new issue](https://github
341348

342349
Once you've decided to commit the time to seeing your pull request through, [please follow our guidelines for creating a pull request](https://make.wordpress.org/cli/handbook/pull-requests/) to make sure it's a pleasant experience. See "[Setting up](https://make.wordpress.org/cli/handbook/pull-requests/#setting-up)" for details specific to working on this package locally.
343350

351+
### License
352+
353+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
354+
344355
## Support
345356

346357
GitHub issues aren't for general support questions, but there are other venues you can try: https://wp-cli.org/#support

features/scaffold-package-readme.feature

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ Feature: Scaffold a README.md file for an existing package
4040
And the {PACKAGE_PATH}/local/wp-cli/default-readme/README.md file should exist
4141
And the {PACKAGE_PATH}/local/wp-cli/default-readme/README.md file should contain:
4242
"""
43-
Installing this package requires WP-CLI v2.12 or greater. Update to the latest stable release with `wp cli update`.
43+
Installing this package requires WP-CLI v2.13 or greater. Update to the latest stable release with `wp cli update`.
4444
"""
4545
And the {PACKAGE_PATH}/local/wp-cli/default-readme/README.md file should contain:
4646
"""
47-
[![Build Status](https://travis-ci.org/wp-cli/default-readme.svg?branch=master)
47+
[![Build Status](https://travis-ci.org/wp-cli/default-readme.svg?branch=main)
4848
"""
4949
And the {PACKAGE_PATH}/local/wp-cli/default-readme/README.md file should contain:
5050
"""
5151
*This README.md is generated dynamically from the project's codebase
5252
"""
5353
And the {PACKAGE_PATH}/local/wp-cli/default-readme/README.md file should contain:
5454
"""
55-
wp package install wp-cli/default-readme:dev-master
55+
wp package install wp-cli/default-readme:dev-main
5656
"""
5757
When I run `wp package uninstall wp-cli/default-readme`
5858
Then STDOUT should contain:
@@ -76,7 +76,7 @@ Feature: Scaffold a README.md file for an existing package
7676
And the {PACKAGE_PATH}/local/wp-cli/custom-branch/README.md file should exist
7777
And the {PACKAGE_PATH}/local/wp-cli/custom-branch/README.md file should contain:
7878
"""
79-
Installing this package requires WP-CLI v2.12 or greater. Update to the latest stable release with `wp cli update`.
79+
Installing this package requires WP-CLI v2.13 or greater. Update to the latest stable release with `wp cli update`.
8080
"""
8181
And the {PACKAGE_PATH}/local/wp-cli/custom-branch/README.md file should contain:
8282
"""
@@ -152,7 +152,7 @@ Feature: Scaffold a README.md file for an existing package
152152
"files": [ "command.php" ]
153153
},
154154
"require": {
155-
"wp-cli/wp-cli": "^2.12"
155+
"wp-cli/wp-cli": "^2.13"
156156
},
157157
"require-dev": {
158158
"wp-cli/wp-cli-tests": "^5.0.0"
@@ -376,7 +376,7 @@ Feature: Scaffold a README.md file for an existing package
376376
"files": [ "command.php" ]
377377
},
378378
"require": {
379-
"wp-cli/wp-cli": "^2.12"
379+
"wp-cli/wp-cli": "^2.13"
380380
},
381381
"require-dev": {
382382
"wp-cli/wp-cli-tests": "^5.0.0"
@@ -395,3 +395,46 @@ Feature: Scaffold a README.md file for an existing package
395395
"""
396396
**Alias:** `cpt`
397397
"""
398+
399+
Scenario: README correctly indents multi-paragraph parameter descriptions
400+
Given an empty directory
401+
And a foo/command.php file:
402+
"""
403+
<?php
404+
/**
405+
* Multi-paragraph test command.
406+
*/
407+
class Multi_Para_Test_Command {
408+
/**
409+
* Test command with a multi-paragraph parameter description.
410+
*
411+
* ## OPTIONS
412+
*
413+
* [<file>]
414+
* : Read content from <file>. If this value is present, the
415+
* `--content` argument will be ignored.
416+
*
417+
* Passing `-` will cause content to
418+
* be read from STDIN.
419+
*
420+
* @when before_wp_load
421+
*/
422+
public function __invoke( $args, $assoc_args ) {}
423+
}
424+
WP_CLI::add_command( 'multi-para-test', 'Multi_Para_Test_Command' );
425+
"""
426+
And a foo/composer.json file:
427+
"""
428+
{
429+
"name": "wp-cli/multi-para-test",
430+
"description": "Test",
431+
"extra": {
432+
"commands": ["multi-para-test"]
433+
}
434+
}
435+
"""
436+
437+
When I run `wp --require=foo/command.php scaffold package-readme foo`
438+
Then the foo/README.md file should exist
439+
And the contents of the foo/README.md file should match /\t\t.*Read content from/
440+
And the contents of the foo/README.md file should match /\t\t.*Passing/

features/scaffold-package.feature

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ Feature: Scaffold WP-CLI commands
1818
"""
1919
.gitignore
2020
"""
21+
And the {PACKAGE_PATH}/local/wp-cli/foo/phpcs.xml.dist file should exist
22+
And the {PACKAGE_PATH}/local/wp-cli/foo/phpcs.xml.dist file should contain:
23+
"""
24+
WP_CLI_CS
25+
"""
26+
And the {PACKAGE_PATH}/local/wp-cli/foo/phpcs.xml.dist file should contain:
27+
"""
28+
wpcli_foo
29+
"""
2130
And the {PACKAGE_PATH}/local/wp-cli/foo/composer.json file should exist
2231
And the {PACKAGE_PATH}/local/wp-cli/foo/composer.json file should contain:
2332
"""
@@ -34,7 +43,7 @@ Feature: Scaffold WP-CLI commands
3443
And the {PACKAGE_PATH}/local/wp-cli/foo/composer.json file should contain:
3544
"""
3645
"require": {
37-
"wp-cli/wp-cli": "^2.12"
46+
"wp-cli/wp-cli": "^2.13"
3847
},
3948
"""
4049
And the {PACKAGE_PATH}/local/wp-cli/foo/hello-world-command.php file should exist
@@ -43,6 +52,15 @@ Feature: Scaffold WP-CLI commands
4352
"""
4453
Contributing
4554
"""
55+
And the {PACKAGE_PATH}/local/wp-cli/foo/LICENSE file should exist
56+
And the {PACKAGE_PATH}/local/wp-cli/foo/LICENSE file should contain:
57+
"""
58+
The MIT License (MIT)
59+
"""
60+
And the {PACKAGE_PATH}/local/wp-cli/foo/LICENSE file should contain:
61+
"""
62+
wp-cli/foo Contributors
63+
"""
4664
And the {PACKAGE_PATH}/local/wp-cli/foo/wp-cli.yml file should exist
4765
And the {PACKAGE_PATH}/local/wp-cli/foo/.travis.yml file should not exist
4866
And the {PACKAGE_PATH}/local/wp-cli/foo/.github/PULL_REQUEST_TEMPLATE file should exist
@@ -127,7 +145,9 @@ Feature: Scaffold WP-CLI commands
127145
"""
128146
And the custom-directory/.gitignore file should exist
129147
And the custom-directory/.editorconfig file should exist
148+
And the custom-directory/phpcs.xml.dist file should exist
130149
And the custom-directory/composer.json file should exist
150+
And the custom-directory/LICENSE file should exist
131151
And the custom-directory/hello-world-command.php file should exist
132152
And the custom-directory/wp-cli.yml file should exist
133153
And the custom-directory/.travis.yml file should not exist
@@ -157,6 +177,8 @@ Feature: Scaffold WP-CLI commands
157177
s
158178
s
159179
s
180+
s
181+
s
160182
"""
161183

162184
When I try `wp scaffold package wp-cli/same-package --skip-tests --skip-github`
@@ -195,6 +217,7 @@ Feature: Scaffold WP-CLI commands
195217
"""
196218
And the {PACKAGE_PATH}/local/wp-cli/with-tests/.gitignore file should exist
197219
And the {PACKAGE_PATH}/local/wp-cli/with-tests/.editorconfig file should exist
220+
And the {PACKAGE_PATH}/local/wp-cli/with-tests/phpcs.xml.dist file should exist
198221
And the {PACKAGE_PATH}/local/wp-cli/with-tests/composer.json file should exist
199222
And the {PACKAGE_PATH}/local/wp-cli/with-tests/hello-world-command.php file should exist
200223
And the {PACKAGE_PATH}/local/wp-cli/with-tests/wp-cli.yml file should exist
@@ -260,5 +283,40 @@ Feature: Scaffold WP-CLI commands
260283
Installing package
261284
"""
262285
And the {PACKAGE_PATH}/local/wp-cli/foo/.gitignore file should exist
286+
And the {PACKAGE_PATH}/local/wp-cli/foo/phpcs.xml.dist file should exist
263287
And the {PACKAGE_PATH}/local/wp-cli/foo/.github/PULL_REQUEST_TEMPLATE file should not exist
264288
And the {PACKAGE_PATH}/local/wp-cli/foo/.github/ISSUE_TEMPLATE file should not exist
289+
290+
Scenario: Scaffolded package includes autoloader documentation
291+
Given an empty directory
292+
293+
When I run `wp package path`
294+
Then save STDOUT as {PACKAGE_PATH}
295+
296+
When I run `wp scaffold package wp-cli/foo --skip-tests --skip-readme --skip-github --skip-install`
297+
Then STDOUT should contain:
298+
"""
299+
Success: Created package files
300+
"""
301+
And STDOUT should contain:
302+
"""
303+
Next steps:
304+
"""
305+
And STDOUT should contain:
306+
"""
307+
composer dump-autoload
308+
"""
309+
310+
When I run `cat {PACKAGE_PATH}/local/wp-cli/foo/src/HelloWorldCommand.php`
311+
Then STDOUT should contain:
312+
"""
313+
IMPORTANT: After modifying this file or adding new command classes, you need to
314+
"""
315+
And STDOUT should contain:
316+
"""
317+
composer dump-autoload --working-dir=$(wp package path)
318+
"""
319+
And STDOUT should contain:
320+
"""
321+
https://getcomposer.org/doc/01-basic-usage.md#autoloading
322+
"""

0 commit comments

Comments
 (0)