boscho87/changelog-checker

一个工具,用于验证 CHANGELOG.md 格式是否符合 "keep a changelog" 指令

1.3.0 2021-07-10 16:55 UTC

This package is auto-updated.

Last update: 2024-09-10 23:52:23 UTC


README

主分支

pipeline status
coverage report

检查 Changelog 是否具有正确的格式,以及自上次提交以来是否已更新。如果需要,某些问题可以通过该工具修复(请参阅配置以了解更多信息)

每次命令都会为您创建 Changelog 备份。它将轮换 4 个备份数据文件。

遵循来自 Keep A Changelog 的指南

此工具仅应在开发环境中使用。

需求

  • > php7.4
  • 某些检查和操作需要 git

安装

最佳实践:在子目录中安装以避免依赖问题

mkdir --parents tools/changelog-checker
## install in working dir
composer require --working-dir=tools/changelog-checker boscho87/changelog-checker
## ignore backup files
echo  .clc.* >> .gitignore 
echo  tools/changelog-checker/vendor >> .gitignore

执行命令

### With default config (or own config file) if your Changelog name is CHANGELOG.md
/tools/changelog-checker/vendor/bin/changelog-checker clc:validate # uses the Changelog and config file from the dir, the command is executed
### Define the Changelog File
/tools/changelog-checker/vendor/bin/changelog-checker clc:validate -f CHANGELOG.md
### Define the config File
/tools/changelog-checker/vendor/bin/changelog-checker clc:validate -c _clc.php
### Force (overwrite the configs) to not only Check, but to resolve the Problems
/tools/changelog-checker/vendor/bin/changelog-checker clc:validate --with-fix=1
### Force (overwrite the configs) to not Fix the Problems
/tools/changelog-checker/vendor/bin/changelog-checker clc:validate --with-fix=0
### Create a new Release (from the Unreleased Section) - ALPHA FEATURE
/tools/changelog-checker/vendor/bin/changelog-checker release # uses the Changelog and composer.json from the dir, the command is executed
### Set a specific  Changelog.md file
/tools/changelog-checker/vendor/bin/changelog-checker release -f CHANGELOG.md
### Set a specific composer.json file 
/tools/changelog-checker/vendor/bin/changelog-checker release -c composer.json
### Commit the Updated Changelog and create a git tag (requires git)
/tools/changelog-checker/vendor/bin/changelog-checker release commit

配置

创建一个名为 {project-root}/_clc.php 的文件来覆盖默认配置

请注意,某些选项依赖于 Changelog 的某种正确性。例如,如果没有 [Unreleased] 标签,Increased Checker 无法在下面添加提交消息。但是,AscendingVersionChecker 可以解决这个问题并添加一个 Unreleased 标签,因此您应该将 fix 设置为 true。

<?php
//if you leave something empty, the default will be used
return [
    'ascendingVersion' => [
        'check' => true,
        'error' => true,
        'fix' => false,
    ],
    'versionBrackets' => [
        'check' => true,
        'error' => true,
        'fix' => false,
    ],
    'actions' => [
        'check' => true,
        'error' => true,
        'fix' => false,
    ],
    //has still some bugs
    'increased' => [
        'check' => false,
        'error' => true,
        'fix' => false,
        //commits allowed without a changelog change
        'fail_after' => 1,
    ],
    'sequence' => [
        'check' => true,
        'error' => true,
        'fix' => false,
    ],
    'linkChecker' => [
        'check' => true,
        'error' => true,
        'fix' => false,
    ],
];

发布者(release 命令)

  • 创建包含 Git 标签的新版本

检查器(validate 命令)

以下检查已实现并可激活

默认检查器

  • 字符串替换,例如,超过两个空格将被删除,只保留一个
  • 修复 > 是
  • 无选项可用

版本括号

  • 版本号是否在括号内?如果不是 > 错误
  • 修复 > 是
  • 无选项可用

递增版本

  • 版本是否递增且永远不会减少
  • 还避免重复版本号
  • 修复 > 否

类型检查器

  • 检查类型字符串是否有效(如 Added|Fixed 等。)
  • 修复 > 否

增加检查器

  • 检查自上次 4 次提交以来 Changelog 是否已更改
  • 修复 向未发布部分添加提交消息
  • 创建两个文件 .clc.cheksum.clc.version
  • 需要 git,运行 git log --oneline -n 4(4 可以更改)

链接检查器

  • 检查 Changelog 是否在文件末尾有链接(需要版本括号才能进行此检查)
  • 修复 > (尚未实现)
  • 需要 git

路线图

  • 添加更多检查器
  • 实现更多修复方法(尽可能实现)
  • 为所有“检查器”实现测试
  • 在编写测试后重构检查器
  • 重构创建发布命令
  • 检查对 alpha/beta 等. 发布和版本的支持