Skip to content

Commit 169fe4a

Browse files
authored
Merge branch 'main' into copilot/fix-plugin-name-slash-issue
2 parents e97b194 + 7fb8f9e commit 169fe4a

12 files changed

+146
-25
lines changed

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

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

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

2222
- name: Check existence of composer.json file
2323
id: check_composer_file
24-
uses: andstor/file-existence-action@v3
24+
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3
2525
with:
2626
files: "composer.json"
2727

2828
- name: Set up PHP environment
2929
if: steps.check_composer_file.outputs.files_exists == 'true'
30-
uses: shivammathur/setup-php@v2
30+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
3131
with:
3232
php-version: 'latest'
3333
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -38,7 +38,7 @@ jobs:
3838

3939
- name: Install Composer dependencies & cache dependencies
4040
if: steps.check_composer_file.outputs.files_exists == 'true'
41-
uses: ramsey/composer-install@v3
41+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3
4242
env:
4343
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
4444
with:

.github/workflows/issue-triage.yml

Lines changed: 9 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:
@@ -13,14 +13,21 @@ 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
1926
with:
2027
issue_number: >-
2128
${{
2229
(github.event_name == 'workflow_dispatch' && inputs.issue_number) ||
23-
(github.event_name == 'pull_request' && github.event.pull_request.number) ||
30+
(github.event_name == 'pull_request_target' && github.event.pull_request.number) ||
2431
(github.event_name == 'issues' && github.event.issue.number) ||
2532
''
2633
}}

.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
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Welcome New Contributors
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
branches:
7+
- main
8+
- master
9+
10+
permissions:
11+
pull-requests: write
12+
13+
jobs:
14+
welcome:
15+
uses: wp-cli/.github/.github/workflows/reusable-welcome-new-contributors.yml@main

features/install-wp-tests.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ Feature: Scaffold install-wp-tests.sh tests
383383
Leaving the existing database (wp_cli_test_scaffold) in place
384384
"""
385385
386-
@require-php-7.2 @require-mysql
386+
@require-php-7.4 @require-mysql
387387
Scenario: Install WordPress from trunk
388388
Given a WP install
389389
And a get-phpunit-phar-url.php file:

features/scaffold-block.feature

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ Feature: WordPress block code scaffolding
5959
"""
6060
And the {PLUGIN_DIR}/blocks/the-green-mile.php file should contain:
6161
"""
62-
register_block_type( 'movies/the-green-mile', [
62+
register_block_type(
63+
"""
64+
And the {PLUGIN_DIR}/blocks/the-green-mile.php file should contain:
65+
"""
66+
'movies/the-green-mile',
6367
"""
6468
And the {PLUGIN_DIR}/blocks/the-green-mile.php file should contain:
6569
"""

features/scaffold-lint.feature

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
Feature: Lint scaffolded code
2+
3+
Background:
4+
Given a WP install
5+
And I run `wp plugin path`
6+
And save STDOUT as {PLUGIN_DIR}
7+
8+
# Create a helper plugin to install phpcs once for all scenarios
9+
When I run `wp scaffold plugin phpcs-helper --skip-tests`
10+
Then the return code should be 0
11+
12+
# Install coding standards
13+
When I run `composer config --working-dir={PLUGIN_DIR}/phpcs-helper allow-plugins.dealerdirect/phpcodesniffer-composer-installer true`
14+
Then the return code should be 0
15+
16+
When I run `composer require --dev --working-dir={PLUGIN_DIR}/phpcs-helper dealerdirect/phpcodesniffer-composer-installer wp-coding-standards/wpcs --no-interaction --quiet`
17+
Then the return code should be 0
18+
19+
Scenario: Scaffold plugin and lint it
20+
When I run `wp scaffold plugin test-plugin`
21+
Then STDOUT should not be empty
22+
And the {PLUGIN_DIR}/test-plugin/test-plugin.php file should exist
23+
And the {PLUGIN_DIR}/test-plugin/.phpcs.xml.dist file should exist
24+
25+
When I run `{PLUGIN_DIR}/phpcs-helper/vendor/bin/phpcs --standard=WordPress {PLUGIN_DIR}/test-plugin/test-plugin.php`
26+
Then the return code should be 0
27+
28+
Scenario: Scaffold post-type and lint it
29+
When I run `wp theme install twentytwentyone --force --activate`
30+
And I run `wp eval 'echo STYLESHEETPATH;'`
31+
And save STDOUT as {STYLESHEETPATH}
32+
33+
And I run `wp scaffold post-type movie --theme`
34+
Then STDOUT should not be empty
35+
And the {STYLESHEETPATH}/post-types/movie.php file should exist
36+
37+
When I run `{PLUGIN_DIR}/phpcs-helper/vendor/bin/phpcs --standard=WordPress {STYLESHEETPATH}/post-types/movie.php`
38+
Then the return code should be 0
39+
40+
Scenario: Scaffold taxonomy and lint it
41+
When I run `wp theme install twentytwentyone --force --activate`
42+
And I run `wp eval 'echo STYLESHEETPATH;'`
43+
And save STDOUT as {STYLESHEETPATH}
44+
45+
And I run `wp scaffold taxonomy genre --theme`
46+
Then STDOUT should not be empty
47+
And the {STYLESHEETPATH}/taxonomies/genre.php file should exist
48+
49+
When I run `{PLUGIN_DIR}/phpcs-helper/vendor/bin/phpcs --standard=WordPress {STYLESHEETPATH}/taxonomies/genre.php`
50+
Then the return code should be 0
51+
52+
Scenario: Scaffold plugin tests and lint them
53+
When I run `wp scaffold plugin test-plugin`
54+
Then STDOUT should not be empty
55+
And the {PLUGIN_DIR}/test-plugin/tests directory should exist
56+
And the {PLUGIN_DIR}/test-plugin/tests/bootstrap.php file should exist
57+
And the {PLUGIN_DIR}/test-plugin/tests/test-sample.php file should exist
58+
59+
# Run phpcs on the test files
60+
When I run `{PLUGIN_DIR}/phpcs-helper/vendor/bin/phpcs --standard=WordPress {PLUGIN_DIR}/test-plugin/tests/bootstrap.php {PLUGIN_DIR}/test-plugin/tests/test-sample.php`
61+
Then the return code should be 0
62+
63+
Scenario: Scaffold child theme and lint it
64+
When I run `wp theme install twentytwentyone --force --activate`
65+
And I run `wp theme path`
66+
And save STDOUT as {THEME_DIR}
67+
68+
And I run `wp scaffold child-theme test-child --parent_theme=twentytwentyone`
69+
Then STDOUT should not be empty
70+
And the {THEME_DIR}/test-child/functions.php file should exist
71+
72+
When I run `{PLUGIN_DIR}/phpcs-helper/vendor/bin/phpcs --standard=WordPress {THEME_DIR}/test-child/functions.php`
73+
Then the return code should be 0
74+
75+
Scenario: Scaffold block and lint it
76+
When I run `wp scaffold plugin movies`
77+
And I run `wp plugin path movies --dir`
78+
And save STDOUT as {MOVIES_DIR}
79+
80+
And I run `wp scaffold block the-green-mile --plugin=movies`
81+
Then STDOUT should not be empty
82+
And the {MOVIES_DIR}/blocks/the-green-mile.php file should exist
83+
84+
When I run `{PLUGIN_DIR}/phpcs-helper/vendor/bin/phpcs --standard=WordPress {MOVIES_DIR}/blocks/the-green-mile.php`
85+
Then the return code should be 0

features/scaffold-plugin-tests.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Feature: Scaffold plugin unit tests
2121
"""
2222
And the {PLUGIN_DIR}/hello-world/tests/bootstrap.php file should contain:
2323
"""
24-
require dirname( dirname( __FILE__ ) ) . '/hello-world.php';
24+
require dirname( __DIR__ ) . '/hello-world.php';
2525
"""
2626
And the {PLUGIN_DIR}/hello-world/tests/bootstrap.php file should contain:
2727
"""
@@ -316,7 +316,7 @@ Feature: Scaffold plugin unit tests
316316
When I run `wp scaffold plugin-tests foo`
317317
Then the wp-content/plugins/foo/tests/bootstrap.php file should contain:
318318
"""
319-
require dirname( dirname( __FILE__ ) ) . '/bar.php';
319+
require dirname( __DIR__ ) . '/bar.php';
320320
"""
321321

322322
Scenario: Accept bitbucket as valid CI in plugin scaffold

features/scaffold.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ Feature: WordPress code scaffolding
432432
And the wp-content/mu-plugins/custom-plugin/tests/bootstrap.php file should exist
433433
And the wp-content/mu-plugins/custom-plugin/tests/bootstrap.php file should contain:
434434
"""
435-
require dirname( dirname( __FILE__ ) ) . '/custom-plugin.php';
435+
require dirname( __DIR__ ) . '/custom-plugin.php';
436436
"""
437437
438438
Scenario: Scaffold tests for a plugin with a different slug than plugin directory
@@ -456,7 +456,7 @@ Feature: WordPress code scaffolding
456456
And the wp-content/mu-plugins/custom-plugin2/tests/bootstrap.php file should exist
457457
And the wp-content/mu-plugins/custom-plugin2/tests/bootstrap.php file should contain:
458458
"""
459-
require dirname( dirname( __FILE__ ) ) . '/custom-plugin-slug.php';
459+
require dirname( __DIR__ ) . '/custom-plugin-slug.php';
460460
"""
461461
462462
Scenario: Scaffold tests parses plugin readme.txt

src/Scaffold_Command.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ private function scaffold( $slug, $assoc_args, $defaults, $subdir, $templates )
182182

183183
$target_slug = '';
184184

185-
if ( false !== $control_args['theme'] ) {
185+
if ( true === $control_args['theme'] ) {
186+
$target_slug = get_stylesheet();
187+
} elseif ( false !== $control_args['theme'] ) {
186188
$target_slug = $control_args['theme'];
187189
} elseif ( false !== $control_args['plugin'] ) {
188190
$target_slug = $control_args['plugin'];

0 commit comments

Comments
 (0)