adachsoft/changelog-linter

Changelog linter tool - validate and convert changelog formats

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Forks: 0

pkg:composer/adachsoft/changelog-linter

v0.1.1 2025-11-07 07:57 UTC

This package is not auto-updated.

Last update: 2025-11-07 07:01:54 UTC


README

A minimal PHP library for validating and converting changelog formats between JSON and Markdown.

Installation

Install via Composer:

composer require --dev adachsoft/changelog-linter

Usage

CLI Commands

Validate changelog.json

vendor/bin/changelog validate --path=changelog.json

Generate Markdown from JSON

vendor/bin/changelog generate-md --input=changelog.json --output=CHANGELOG.md

Generate JSON from Markdown

vendor/bin/changelog generate-json --input=CHANGELOG.md --output=changelog.json

Composer Scripts

The package provides convenient composer scripts:

composer run changelog:validate    # Validate changelog.json
composer run changelog:generate    # Generate Markdown from JSON
composer run changelog:from-md     # Generate JSON from Markdown

File Formats

changelog.json (JSON Schema)

{
  "versions": [
    {
      "version": "1.1.0",
      "date": "2024-01-15",
      "changes": {
        "added": ["New feature"],
        "changed": ["Updated documentation"],
        "fixed": ["Bug fix"],
        "removed": ["Deprecated method"]
      }
    },
    {
      "version": "1.0.0",
      "date": "2024-01-01",
      "changes": {
        "added": ["Initial release"]
      }
    }
  ]
}

CHANGELOG.md (Markdown)

# Changelog

## [1.1.0] - 2024-01-15
### Added
- New feature

### Changed
- Updated documentation

### Fixed
- Bug fix

### Removed
- Deprecated method

## [1.0.0] - 2024-01-01
### Added
- Initial release

Validation Rules

The validator checks for:

  • Valid JSON format
  • Required fields (version, date, changes)
  • Semantic versioning format (X.Y.Z)
  • Valid date format (YYYY-MM-DD)
  • Versions sorted in descending order
  • No duplicate versions
  • Valid change section keys (added, changed, fixed, removed)

Development

Running Tests

composer test

Code Style

composer cs:check    # Check code style
composer cs:fix      # Fix code style

Static Analysis

composer stan

Requirements

  • PHP >= 8.2
  • Composer

Dependencies

  • justinrainbow/json-schema: JSON Schema validation
  • twig/twig: Markdown generation templates
  • adachsoft/collection: Immutable collections
  • phpunit/phpunit: Testing framework