Skip to content

Commit f584977

Browse files
authored
Merge branch 'main' into copilot/add-wordpress-coding-standards
2 parents 3b0c3a2 + 233838d commit f584977

File tree

5 files changed

+60
-3
lines changed

5 files changed

+60
-3
lines changed

.github/workflows/issue-triage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Issue and PR Triage
44
'on':
55
issues:
66
types: [opened]
7-
pull_request:
7+
pull_request_target:
88
types: [opened]
99
workflow_dispatch:
1010
inputs:
@@ -20,7 +20,7 @@ jobs:
2020
issue_number: >-
2121
${{
2222
(github.event_name == 'workflow_dispatch' && inputs.issue_number) ||
23-
(github.event_name == 'pull_request' && github.event.pull_request.number) ||
23+
(github.event_name == 'pull_request_target' && github.event.pull_request.number) ||
2424
(github.event_name == 'issues' && github.event.issue.number) ||
2525
''
2626
}}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Welcome New Contributors
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
branches:
7+
- main
8+
- master
9+
10+
jobs:
11+
welcome:
12+
uses: wp-cli/.github/.github/workflows/reusable-welcome-new-contributors.yml@main

features/scaffold-package-readme.feature

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,37 @@ Feature: Scaffold a README.md file for an existing package
352352
"""
353353
This package is included with WP-CLI itself
354354
"""
355+
356+
Scenario: README includes command aliases
357+
Given an empty directory
358+
And a foo/composer.json file:
359+
"""
360+
{
361+
"name": "wp-cli/alias-test",
362+
"description": "Test package for command aliases",
363+
"license": "MIT",
364+
"authors": [],
365+
"minimum-stability": "dev",
366+
"autoload": {
367+
"files": [ "command.php" ]
368+
},
369+
"require": {
370+
"wp-cli/wp-cli": "^2.12"
371+
},
372+
"require-dev": {
373+
"wp-cli/wp-cli-tests": "^5.0.0"
374+
},
375+
"extra": {
376+
"commands": [
377+
"scaffold post-type"
378+
]
379+
}
380+
}
381+
"""
382+
383+
When I run `wp scaffold package-readme foo`
384+
Then the foo/README.md file should exist
385+
And the foo/README.md file should contain:
386+
"""
387+
**Alias:** `cpt`
388+
"""

src/ScaffoldPackageCommand.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,19 @@ public function package_readme( $args, $assoc_args ) {
350350
// definition lists
351351
$longdesc = preg_replace_callback( '/([^\n]+)\n: (.+?)(\n\n|$)/s', [ __CLASS__, 'rewrap_param_desc' ], $longdesc );
352352

353-
$readme_args['commands'][] = [
353+
$command_data = [
354354
'name' => "wp {$command}",
355355
'shortdesc' => isset( $parent_command['description'] ) ? $parent_command['description'] : '',
356356
'synopsis' => "wp {$command}" . ( empty( $parent_command['subcommands'] ) ? ( isset( $parent_command['synopsis'] ) ? " {$parent_command['synopsis']}" : '' ) : '' ),
357357
'longdesc' => $longdesc,
358358
];
359+
360+
// Add alias if present.
361+
if ( ! empty( $parent_command['alias'] ) ) {
362+
$command_data['alias'] = $parent_command['alias'];
363+
}
364+
365+
$readme_args['commands'][] = $command_data;
359366
}
360367
$readme_args['has_commands'] = true;
361368
$readme_args['has_multiple_commands'] = count( $readme_args['commands'] ) > 1;

templates/readme-using.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ This package implements the following commands:
1515
{{synopsis}}
1616
~~~
1717

18+
{{#alias}}
19+
**Alias:** `{{alias}}`
20+
21+
{{/alias}}
1822
{{longdesc}}
1923

2024
{{/commands}}

0 commit comments

Comments
 (0)