Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions features/scaffold-package.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ Feature: Scaffold WP-CLI commands
"""
Contributing
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/LICENSE file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/LICENSE file should contain:
"""
The MIT License (MIT)
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/LICENSE file should contain:
"""
wp-cli/foo Contributors
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/wp-cli.yml file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/.travis.yml file should not exist
And the {PACKAGE_PATH}/local/wp-cli/foo/.github/PULL_REQUEST_TEMPLATE file should exist
Expand Down Expand Up @@ -138,6 +147,7 @@ Feature: Scaffold WP-CLI commands
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/LICENSE file should exist
And the custom-directory/hello-world-command.php file should exist
And the custom-directory/wp-cli.yml file should exist
And the custom-directory/.travis.yml file should not exist
Expand Down Expand Up @@ -168,6 +178,7 @@ Feature: Scaffold WP-CLI commands
s
s
s
s
"""

When I try `wp scaffold package wp-cli/same-package --skip-tests --skip-github`
Expand Down
3 changes: 3 additions & 0 deletions src/ScaffoldPackageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ScaffoldPackageCommand {
* Default behavior is to create the following files:
* - command.php
* - composer.json (with package name, description, and license)
* - LICENSE
* - .gitignore, .editorconfig, .distignore, and phpcs.xml.dist
* - README.md (via wp scaffold package-readme)
* - Test harness (via wp scaffold package-tests)
Expand Down Expand Up @@ -81,6 +82,7 @@ public function package( $args, $assoc_args ) {
];
$assoc_args = array_merge( $defaults, $assoc_args );
$assoc_args['name'] = $args[0];
$assoc_args['year'] = gmdate( 'Y' );

$bits = explode( '/', $assoc_args['name'] );
if ( 2 !== count( $bits ) || empty( $bits[0] ) || empty( $bits[1] ) ) {
Expand Down Expand Up @@ -123,6 +125,7 @@ public function package( $args, $assoc_args ) {
"{$package_dir}/.distignore" => file_get_contents( "{$package_root}/.distignore" ),
"{$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}/LICENSE" => Utils\mustache_render( "{$template_path}/LICENSE.mustache", $assoc_args ),
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LICENSE file is always generated with MIT license text, but the --license parameter allows users to specify other licenses for composer.json. This creates an inconsistency where a user could run wp scaffold package vendor/pkg --license=GPL-2.0 and get a composer.json with "license": "GPL-2.0" but a LICENSE file containing MIT license text. Consider adding a conditional check to only generate the LICENSE file when the license is "MIT", or add support for other common licenses with separate templates.

Copilot uses AI. Check for mistakes.
"{$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 ),
"{$package_dir}/src/HelloWorldCommand.php" => Utils\mustache_render( "{$template_path}/HelloWorldCommand.mustache", $assoc_args ),
Expand Down
21 changes: 21 additions & 0 deletions templates/LICENSE.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (C) {{year}} {{name}} Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
4 changes: 4 additions & 0 deletions templates/readme-contributing.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ Once you’ve done a bit of searching and discovered there isn’t an open or fi
Want to contribute a new feature? Please first [open a new issue](https://github.com/{{package_name}}/issues/new) to discuss whether the feature is a good fit for the project.

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.

### License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readme-contributing.mustache template hardcodes "MIT License" in the text, which will be incorrect if a user specifies a different license via the --license parameter. This creates inconsistency between the LICENSE file, composer.json, and README. Consider making this text dynamic based on the license parameter, or only including this section when the license is MIT.

Suggested change
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
This project is licensed under the {{license}} license. See the [LICENSE](LICENSE) file for details.

Copilot uses AI. Check for mistakes.