modern-version
v1.4.3
Published
Automated version management and CHANGELOG generation tool
Maintainers
Readme
modern-version
Automated Version Management and CHANGELOG Generation
A feature-rich replacement for standard-version with enhanced capabilities, full lifecycle hooks, multi-file support, and commit validation.
✅ Recommended Commit Format
We recommend using Commitizen or git-cz to follow the Conventional Commits specification. This ensures your commit messages are parsed correctly and changelogs are generated accurately.
Install and use with:
npm install --save-dev commitizen
npx commitizen init cz-conventional-changelog --save-dev --save-exact📦 Installation
npm install --save-dev modern-version
# or globally
npm install -g modern-version🚀 Quick Start
- Add the release script to your
package.json:
{
"scripts": {
"release": "modern-version"
}
}- Run a release:
npm run release -- --release-as minor⚙️ Configuration
Create .versionrc.json in your project root:
Basic Example
{
"changelog": {
"header": "# Change History\n\n",
"types": [
{"type": "feat", "section": "✨ Features"},
{"type": "fix", "section": "🐞 Bug Fixes"},
{"type": "chore", "section": "🔧 Maintenance", "hidden": false},
{"type": "docs", "section": "📚 Documentation"}
]
}
}Advanced Configuration
{
"files": ["package.json", "manifest.json"],
"packages": false,
"changelog": {
"header": "# CHANGELOG\n\n",
"footer": "Automatically generated on {{date}}",
"repositoryUrl": "https://github.com/your/repo",
"commitUrlFormat": "{{host}}/commit/{{hash}}",
"issueUrlFormat": "{{host}}/issues/{{id}}",
"types": [
{"type": "feat", "section": "Features", "hidden": false},
{"type": "fix", "section": "Bug Fixes"},
{"type": "perf", "section": "Performance Improvements"},
{"type": "revert", "section": "Reverts"}
],
"skip": {
"chore": true,
"docs": false
},
"skipInvalidCommits": true
},
"scripts": {
"prerelease": "echo 'Starting release'",
"postchangelog": "prettier --write CHANGELOG.md"
}
}🛠 Complete Config Reference
| Parameter | Type | Description | Default |
| ------------------------- | --------- | ------------------------------------- | ---------------------------- |
| files | string[] | Files to bump version in | ["package.json"] |
| packages | boolean | Enable monorepo mode | false |
| commitMessage | string | Custom commit message | chore(release): v{version} |
| changelog.header | string | Changelog header | "# CHANGELOG\n\n" |
| changelog.footer | string | Footer text (supports {{date}}) | "" |
| changelog.repositoryUrl | string | Repository URL for links | |
| changelog.types | object[] | Grouping for commit types | |
| changelog.skip | object | Types of commits to skip in changelog | |
| scripts | object | Lifecycle hook commands | |
🔄 Lifecycle Hooks
Complete list of available hooks:
| Hook | Description | Return Value |
| --------------- | --------------------------- | ---------------------- |
| prerelease | Before the release starts | - |
| prebump | Before version bump | New version (override) |
| postbump | After version bump | - |
| prechangelog | Before changelog generation | - |
| postchangelog | After changelog generation | - |
| precommit | Before committing changes | - |
| postcommit | After committing changes | - |
| pretag | Before creating a Git tag | - |
| posttag | After tag creation | - |
Hook Usage Example
{
"scripts": {
"prebump": "echo 'Current version: $VERSION'",
"postbump": "npm run build",
"postchangelog": "prettier --write CHANGELOG.md"
}
}💻 CLI Options
modern-version [options]| Option | Description | Example |
| --------------- | ----------------------------- | -------------------- |
| --release-as | Specify the release version | --release-as 1.2.3 |
| --prerelease | Mark as a pre-release | --prerelease beta |
| --dry-run | Run without changing anything | --dry-run |
| --skip.commit | Skip git commit | --skip.commit |
| --skip.tag | Skip git tag creation | --skip.tag |
| --silent | Suppress output | --silent |
📌 Usage Examples
Standard Release
modern-version
# or via npm
npm run releaseMajor Release
modern-version --release-as majorPre-release
modern-version --prerelease betaSkip Specific Steps
modern-version --skip.commit --skip.tagSpecific Version
modern-version --release-as 2.1.0-rc.1🤝 Contributing
- Fork the repository
- Install dependencies:
npm install- Create a feature branch:
git checkout -b feature/new-awesome-feature- Run tests:
npm test- Create a Pull Request
📜 License
MIT © 2025 [RemiRRo]
