@qoollo/changelog
v1.4.0
Published
Утилита для обновления CHANGELOG.md на основе нескольких YAML файлов с изменениями
Downloads
2
Readme
@qoollo/changelog
This npm package provides two CLI tools for managing changes and updating changelogs.
Installation
Install the package globally using npm:
npm install -g @qoollo/changelog
or locally, in which case use it in npm scripts or with npx
:
npm install @qoollo/changelog
CLI Tools
generate-changes-file
The generate-changes-file
script generates a new YAML file from a template. It accepts the path to the new YAML file, the base URL for the user page and the username of the contributor.
Usage:
generate-changes-file <path-to-new-yaml-file> <base-user-url> <username>
update-changelog
The update-changelog
tool writes a new record in a changelog file based on multiple YAML files describing changes and updates package.json version if necessary. It accepts the path to the directory with YAML files containing changes and the path to the markdown changelog file.
Usage:
update-changelog <changes-dir> <changelog-path> [options]
Options:
-nv, --new-version <string>
: Specify the version; the script will prompt the user if not provided. Usemajor
,minor
,patch
orcurrent
to automatically resolve the new version number.--date <string>
: Specify the release date (usecurrent
for the current date); the script will prompt the user if not provided.--version-update [boolean]
: Automatically update the version in package.json. Default istrue
. Use--no-version-update
or--version-update false
to skip version update. Will prompt user if not specified.--clean-up [boolean]
: Automatically remove processed YAML files. Default istrue
. Use--no-clean-up
or--clean-up false
to keep processed YAML files. Will prompt user if not specified.-y, --skip-confirmation
: Automatically proceed with changelog update without confirmation.-n, --check-validity
: List valid files without proceeding after parsing changes.
Example
Generate Changes:
generate-changes-file path/to/new-changes.yaml https://git.qoollo.com john_doe
This command generates a new changes file named new-changes.yaml
in the specified path with the contributor link based on provided base url and username.
Usage in husky post-checkout hook:
You can call generate-changes-file
in husky's post-checkout
hook to create a new changes file for every new branch. In the following example, the changes file is generated only if the branch name starts with numbers indicating the issue number.
# .husky/post-checkout
#!/bin/sh
[ -n "$CI" ] && exit 0
. "$(dirname "$0")/_/husky.sh"
ISSUE=$(git rev-parse --abbrev-ref HEAD | grep -m 1 -E '^[0-9]+' | head -n1)
USER_URL_BASE=https://git.qoollo.com
USERNAME=$(git config user.name)
if [ -n "$ISSUE" ]; then
changesFile="changes/${ISSUE}.yaml"
npx generate-changes-file ${changesFile} ${USER_URL_BASE} ${USERNAME}
fi
YAML changes example
Refer to example.yaml for guidance on how to fill the change entries.
Update Changelog:
update-changelog path/to/changes path/to/changelog.md --new-version minor --date 21.02.2024 --version-update --clean-up -y
This command updates the changelog file based on the changes in the specified directory. It automatically updates the version in package.json to the next minor version, marks the release date as "21.02.2024", removes processed YAML files, and proceeds without confirmation.
License
This project is licensed under the MIT License - see the LICENSE file for details.