Generate LICENSE file when scaffolding packages#276
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This pull request adds automatic generation of a LICENSE file when scaffolding new WP-CLI packages. Previously, scaffolded packages specified "license": "MIT" in composer.json but didn't include an actual LICENSE file. The change addresses issue #84 by generating a standard MIT license file with appropriate copyright information.
Changes:
- Adds LICENSE.mustache template with MIT license text using
{{year}}and{{name}}placeholders for copyright line - Updates ScaffoldPackageCommand to generate LICENSE file and pass current year via
gmdate('Y') - Updates readme-contributing.mustache to add License subsection referencing the LICENSE file
- Adds comprehensive test coverage for LICENSE file generation
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| templates/LICENSE.mustache | New MIT license template with dynamic year and package name placeholders |
| src/ScaffoldPackageCommand.php | Adds year variable and LICENSE file generation to package scaffolding |
| templates/readme-contributing.mustache | Adds License subsection linking to LICENSE file in Contributing section |
| features/scaffold-package.feature | Adds tests verifying LICENSE file creation and content, updates session file with additional skip prompt |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "{$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 ), |
There was a problem hiding this comment.
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.
|
|
||
| ### License | ||
|
|
||
| This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
There was a problem hiding this comment.
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.
| 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. |
Scaffolded packages specify
"license": "MIT"in composer.json but don't include an actual LICENSE file.Changes
templates/LICENSE.mustache): Standard MIT license text with{{year}}and{{name}}placeholders for copyright linegmdate('Y')Example
Scaffolding now produces:
Copyright line uses package name since no author/organization option exists per requirements ("No options").
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.