Skip to content

Generate LICENSE file when scaffolding packages#276

Merged
swissspidy merged 4 commits intomainfrom
copilot/add-license-file-to-scaffold
Feb 16, 2026
Merged

Generate LICENSE file when scaffolding packages#276
swissspidy merged 4 commits intomainfrom
copilot/add-license-file-to-scaffold

Conversation

Copy link
Contributor

Copilot AI commented Feb 15, 2026

Scaffolded packages specify "license": "MIT" in composer.json but don't include an actual LICENSE file.

Changes

  • License template (templates/LICENSE.mustache): Standard MIT license text with {{year}} and {{name}} placeholders for copyright line
  • Scaffold command: Generates LICENSE file alongside other package files; adds current year to template variables via gmdate('Y')
  • README generation: Contributing section now includes License subsection linking to LICENSE file
  • Tests: Verify LICENSE file creation and content in scaffold scenarios

Example

Scaffolding now produces:

LICENSE                    # New: MIT license with "Copyright (C) 2026 vendor/package Contributors"
composer.json              # Existing: "license": "MIT"
README.md                  # Updated: "### License" section in Contributing

Copyright line uses package name since no author/organization option exists per requirements ("No options").

Original prompt

This section details on the original issue you should resolve

<issue_title>Generate LICENSE file when scaffolding a new command</issue_title>
<issue_description>We should make sure each scaffolded package includes a proper LICENSE file

From wp-cli/restful#97</issue_description>

<agent_instructions>Add MIT license file. No options.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@danielbachhuber Similarly, we should include mention of the license in the README @danielbachhuber > How do you envision this being implemented?

I don't have any strong opinions at this point, other than to generally follow the pattern of other commands.

Should templates for common licenses be bundled? Or maybe use an API like GitHub Licenses?

Probably bundled. We don't need to support that many, and they don't change very often.

Should a name/author option be added for licenses like MIT? Or should the license be added as-is, allowing the author to replace the various placeholders on their own?

No strong preference.

What about cases where some obscure/unsupported license is requested by the user? A blank license file that they have to manually fill in? Or no license file at all?

No license file at all, I think.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 15, 2026 23:03
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add LICENSE file when scaffolding a new command Generate LICENSE file when scaffolding packages Feb 15, 2026
Copilot AI requested a review from swissspidy February 15, 2026 23:06
@swissspidy swissspidy marked this pull request as ready for review February 16, 2026 22:43
@swissspidy swissspidy requested a review from a team as a code owner February 16, 2026 22:43
Copilot AI review requested due to automatic review settings February 16, 2026 22:43
@swissspidy swissspidy added this to the 2.2.2 milestone Feb 16, 2026
@swissspidy swissspidy merged commit d323f65 into main Feb 16, 2026
65 of 66 checks passed
@swissspidy swissspidy deleted the copilot/add-license-file-to-scaffold branch February 16, 2026 22:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ),
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.

### 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate LICENSE file when scaffolding a new command

2 participants