Skip to content

[sync] Add LICENSE file auto-generation from composer.json (#11)#25

Merged
coisa merged 4 commits intomainfrom
feature/11-license-generation
Apr 10, 2026
Merged

[sync] Add LICENSE file auto-generation from composer.json (#11)#25
coisa merged 4 commits intomainfrom
feature/11-license-generation

Conversation

@coisa
Copy link
Copy Markdown
Contributor

@coisa coisa commented Apr 10, 2026

Summary

Extends dev-tools:sync to automatically generate a LICENSE file when one does not exist and a supported license is declared in composer.json. This ensures package metadata consistency between Composer and the repository.

Changes

  • Added new License namespace with isolated classes:
    • Reader: reads license metadata from composer.json
    • Resolver: resolves SPDX license identifiers to templates
    • TemplateLoader: loads license templates from resources
    • PlaceholderResolver: resolves template placeholders (year, organization, author, project)
    • Generator: orchestrates license file generation
  • Added 9 license templates: MIT, BSD-2-Clause, BSD-3-Clause, Apache-2.0, ISC, GPL-3.0-or-later, LGPL-3.0-or-later, MPL-2.0, Unlicense
  • Updated SyncCommand to call generateLicense() method

Behavior

  • If LICENSE already exists → skip generation
  • If no license in composer.json → warn and skip
  • If unsupported license → warn and skip
  • Only generates for single supported SPDX license

Testing

  • Added unit tests for all License classes (Reader, Resolver, TemplateLoader, PlaceholderResolver)
  • All tests pass: composer dev-tools tests -- --filter="License"

Closes #11

coisa added 4 commits April 9, 2026 23:27
Implements issue #11 - auto-create LICENSE file from composer.json

- Added new License namespace with isolated classes:
  - Reader: reads license metadata from composer.json
  - Resolver: resolves SPDX license identifiers to templates
  - TemplateLoader: loads license templates from resources
  - PlaceholderResolver: resolves template placeholders (year, organization, author, project)
  - Generator: orchestrates license file generation
- Added license templates for: MIT, BSD-2-Clause, BSD-3-Clause, Apache-2.0, ISC, GPL-3.0-or-later, LGPL-3.0-or-later, MPL-2.0, Unlicense
- Updated SyncCommand to call generateLicense() method
- Added unit tests for all License classes

Behavior:
- If LICENSE already exists, skip generation
- If no license in composer.json, warn and skip
- If unsupported license, warn and skip
- Only generates for single supported SPDX license
Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
@coisa coisa merged commit 075177d into main Apr 10, 2026
5 checks passed
@coisa coisa deleted the feature/11-license-generation branch April 10, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance dev-tools:sync to auto-create the correct LICENSE file from composer.json

1 participant