From 391b22ce1996ff7c14486044036278661295956d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Dec 2025 16:19:53 +0000 Subject: [PATCH 1/5] Initial plan From adee07111779003c0ed9dab072b690ae956da6fc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Dec 2025 16:27:55 +0000 Subject: [PATCH 2/5] Add phpcs.xml.dist to scaffolded packages Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/scaffold-package.feature | 8 ++++++++ src/ScaffoldPackageCommand.php | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/features/scaffold-package.feature b/features/scaffold-package.feature index d321887..9c79506 100644 --- a/features/scaffold-package.feature +++ b/features/scaffold-package.feature @@ -18,6 +18,11 @@ Feature: Scaffold WP-CLI commands """ .gitignore """ + And the {PACKAGE_PATH}/local/wp-cli/foo/phpcs.xml.dist file should exist + And the {PACKAGE_PATH}/local/wp-cli/foo/phpcs.xml.dist file should contain: + """ + WP_CLI_CS + """ And the {PACKAGE_PATH}/local/wp-cli/foo/composer.json file should exist And the {PACKAGE_PATH}/local/wp-cli/foo/composer.json file should contain: """ @@ -127,6 +132,7 @@ Feature: Scaffold WP-CLI commands """ And the custom-directory/.gitignore file should exist And the custom-directory/.editorconfig file should exist + And the custom-directory/phpcs.xml.dist file should exist And the custom-directory/composer.json file should exist And the custom-directory/hello-world-command.php file should exist And the custom-directory/wp-cli.yml file should exist @@ -195,6 +201,7 @@ Feature: Scaffold WP-CLI commands """ And the {PACKAGE_PATH}/local/wp-cli/with-tests/.gitignore file should exist And the {PACKAGE_PATH}/local/wp-cli/with-tests/.editorconfig file should exist + And the {PACKAGE_PATH}/local/wp-cli/with-tests/phpcs.xml.dist file should exist And the {PACKAGE_PATH}/local/wp-cli/with-tests/composer.json file should exist And the {PACKAGE_PATH}/local/wp-cli/with-tests/hello-world-command.php file should exist And the {PACKAGE_PATH}/local/wp-cli/with-tests/wp-cli.yml file should exist @@ -260,5 +267,6 @@ Feature: Scaffold WP-CLI commands Installing package """ And the {PACKAGE_PATH}/local/wp-cli/foo/.gitignore file should exist + And the {PACKAGE_PATH}/local/wp-cli/foo/phpcs.xml.dist file should exist And the {PACKAGE_PATH}/local/wp-cli/foo/.github/PULL_REQUEST_TEMPLATE file should not exist And the {PACKAGE_PATH}/local/wp-cli/foo/.github/ISSUE_TEMPLATE file should not exist diff --git a/src/ScaffoldPackageCommand.php b/src/ScaffoldPackageCommand.php index 7a854a9..e2b48e4 100644 --- a/src/ScaffoldPackageCommand.php +++ b/src/ScaffoldPackageCommand.php @@ -16,7 +16,7 @@ class ScaffoldPackageCommand { * Default behavior is to create the following files: * - command.php * - composer.json (with package name, description, and license) - * - .gitignore, .editorconfig, and .distignore + * - .gitignore, .editorconfig, .distignore, and phpcs.xml.dist * - README.md (via wp scaffold package-readme) * - Test harness (via wp scaffold package-tests) * @@ -118,6 +118,7 @@ public function package( $args, $assoc_args ) { "{$package_dir}/.gitignore" => file_get_contents( "{$package_root}/.gitignore" ), "{$package_dir}/.editorconfig" => file_get_contents( "{$package_root}/.editorconfig" ), "{$package_dir}/.distignore" => file_get_contents( "{$package_root}/.distignore" ), + "{$package_dir}/phpcs.xml.dist" => file_get_contents( "{$package_root}/phpcs.xml.dist" ), "{$package_dir}/CONTRIBUTING.md" => file_get_contents( "{$package_root}/CONTRIBUTING.md" ), "{$package_dir}/wp-cli.yml" => $wp_cli_yml, "{$package_dir}/hello-world-command.php" => Utils\mustache_render( "{$template_path}/hello-world-command.mustache", $assoc_args ), From 92e6abe67f6e229cbc16bf9a7aa962b856887133 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Dec 2025 16:29:30 +0000 Subject: [PATCH 3/5] Update README.md with phpcs.xml.dist documentation Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a0aa170..b497cc7 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ wp-cli/scaffold-package-command Scaffolds WP-CLI commands with functional tests, full README.md, and more. -[![Testing](https://github.com/wp-cli/scaffold-package-command/actions/workflows/testing.yml/badge.svg)](https://github.com/wp-cli/scaffold-package-command/actions/workflows/testing.yml) [![CircleCI](https://circleci.com/gh/wp-cli/scaffold-package-command/tree/main.svg?style=svg)](https://circleci.com/gh/wp-cli/scaffold-package-command/tree/main) +[![Testing](https://github.com/wp-cli/scaffold-package-command/actions/workflows/testing.yml/badge.svg)](https://github.com/wp-cli/scaffold-package-command/actions/workflows/testing.yml) [![CircleCI](https://circleci.com/gh/wp-cli/scaffold-package-command/tree/master.svg?style=svg)](https://circleci.com/gh/wp-cli/scaffold-package-command/tree/master) Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contributing) | [Support](#support) @@ -22,7 +22,7 @@ wp scaffold package [--description=] [--homepage=] Default behavior is to create the following files: - command.php - composer.json (with package name, description, and license) -- .gitignore, .editorconfig, and .distignore +- .gitignore, .editorconfig, .distignore, and phpcs.xml.dist - README.md (via wp scaffold package-readme) - Test harness (via wp scaffold package-tests) @@ -316,7 +316,7 @@ wp package install wp-cli/scaffold-package-command:@stable To install the latest development version of this package, use the following command instead: ```bash -wp package install wp-cli/scaffold-package-command:dev-main +wp package install wp-cli/scaffold-package-command:dev-master ``` ## Contributing From 6ea47cf71eea9e6ca9c0c507d07b455fe96b93ae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Dec 2025 10:16:32 +0000 Subject: [PATCH 4/5] Use template for phpcs.xml.dist with customizable prefix Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/scaffold-package.feature | 4 +++ src/ScaffoldPackageCommand.php | 5 ++- templates/phpcs.xml.dist.mustache | 54 +++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 templates/phpcs.xml.dist.mustache diff --git a/features/scaffold-package.feature b/features/scaffold-package.feature index 9c79506..c8a544c 100644 --- a/features/scaffold-package.feature +++ b/features/scaffold-package.feature @@ -23,6 +23,10 @@ Feature: Scaffold WP-CLI commands """ WP_CLI_CS """ + And the {PACKAGE_PATH}/local/wp-cli/foo/phpcs.xml.dist file should contain: + """ + wpcli_foo + """ And the {PACKAGE_PATH}/local/wp-cli/foo/composer.json file should exist And the {PACKAGE_PATH}/local/wp-cli/foo/composer.json file should contain: """ diff --git a/src/ScaffoldPackageCommand.php b/src/ScaffoldPackageCommand.php index e2b48e4..26db8e3 100644 --- a/src/ScaffoldPackageCommand.php +++ b/src/ScaffoldPackageCommand.php @@ -87,6 +87,9 @@ public function package( $args, $assoc_args ) { WP_CLI::error( "'{$assoc_args['name']}' is an invalid package name. Package scaffold expects '/'." ); } + // Generate a slug from the package name for use in prefixes. + $assoc_args['package_name_slug'] = str_replace( '-', '_', $bits[1] ); + if ( ! empty( $assoc_args['dir'] ) ) { $package_dir = $assoc_args['dir']; } else { @@ -118,7 +121,7 @@ public function package( $args, $assoc_args ) { "{$package_dir}/.gitignore" => file_get_contents( "{$package_root}/.gitignore" ), "{$package_dir}/.editorconfig" => file_get_contents( "{$package_root}/.editorconfig" ), "{$package_dir}/.distignore" => file_get_contents( "{$package_root}/.distignore" ), - "{$package_dir}/phpcs.xml.dist" => file_get_contents( "{$package_root}/phpcs.xml.dist" ), + "{$package_dir}/phpcs.xml.dist" => Utils\mustache_render( "{$template_path}/phpcs.xml.dist.mustache", $assoc_args ), "{$package_dir}/CONTRIBUTING.md" => file_get_contents( "{$package_root}/CONTRIBUTING.md" ), "{$package_dir}/wp-cli.yml" => $wp_cli_yml, "{$package_dir}/hello-world-command.php" => Utils\mustache_render( "{$template_path}/hello-world-command.mustache", $assoc_args ), diff --git a/templates/phpcs.xml.dist.mustache b/templates/phpcs.xml.dist.mustache new file mode 100644 index 0000000..30e69ca --- /dev/null +++ b/templates/phpcs.xml.dist.mustache @@ -0,0 +1,54 @@ + + + Custom ruleset for WP-CLI {{name}} + + + + + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 3b0c3a2de7cf19af5348e73af425e3da9b3466f1 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 23 Dec 2025 18:11:26 +0100 Subject: [PATCH 5/5] Update test --- features/scaffold-package.feature | 1 + 1 file changed, 1 insertion(+) diff --git a/features/scaffold-package.feature b/features/scaffold-package.feature index c8a544c..a445b12 100644 --- a/features/scaffold-package.feature +++ b/features/scaffold-package.feature @@ -167,6 +167,7 @@ Feature: Scaffold WP-CLI commands s s s + s """ When I try `wp scaffold package wp-cli/same-package --skip-tests --skip-github`