@versu/cli
v3.2.0
Published
Versu (CLI)
Maintainers
Readme

@versu/cli - Command-Line Interface
Command-line interface for Versu. This CLI provides all the power of Versu's semantic versioning engine through an easy-to-use command-line tool, perfect for local development and custom CI/CD systems.
For comprehensive documentation, examples, and configuration options, please refer to the our website https://versuhq.github.io/.
Installation
Global Installation
npm install -g @versu/cliLocal Installation
npm install --save-dev @versu/cliUsing npx (no installation)
npx @versu/cli runUsage
Basic Usage
Navigate to your project root and run:
versu runThis will:
- Detect your project type (Gradle, etc.)
- Analyze commits since the last version
- Calculate version bumps based on Conventional Commits
- Update version files
- Generate changelogs
- Create git commits and tags
- Push changes to remote
Dry Run
Preview what would happen without making changes:
versu run --dry-runSpecify Project Root
versu run /path/to/projectSpecify Adapter
If auto-detection fails or you want to be explicit:
versu run --adapter gradleCommand Reference
versu run <repositoryRoot> [options]
Calculate and apply semantic version changes.
Arguments:
<repositoryRoot>- Path to the repository root (default:.)
Flags:
| Flag | Description | Default |
| ------ | ------------- | --------- |
| --prerelease-mode | Generate pre-release versions instead of final versions | false |
| --prerelease-id <value> | Pre-release identifier (e.g., alpha, beta, rc) | alpha |
| --bump-unchanged | In prerelease mode, bump modules even when no changes are detected | false |
| --add-build-metadata | Add build metadata with short SHA to all versions | false |
| --timestamp-versions | Use timestamp-based prerelease identifiers (requires prerelease-mode) | false |
| --append-snapshot | Add -SNAPSHOT suffix to all versions if supported by adapter | false |
| --create-tags | Create git tags for new versions | true |
| --generate-changelog | Generate or update changelog files for changed modules | true |
| --generate-release-notes | Generate release notes summarizing all changes | true |
| --push-changes | Commit and push version changes and changelogs to remote | true |
| --dry-run | Run without writing or pushing changes | false |
| --sequential-tag-push | Push tags sequentially instead of all at once | false |
| --commit-release-notes | Include release notes in the commit when pushing changes | false |
| --adapter <value> | Language adapter (e.g., gradle). Auto-detected if not provided | - |
| --changelog-filename <value> | Filename for generated changelog | CHANGELOG.md |
| --release-notes-filename <value> | Filename for generated release notes | RELEASE.md |
| --from-ref <value> | Git ref to compare from (e.g., previous tag or commit SHA) | - |
| --provider <value> | Version control provider (e.g., github, gitlab) | - |
| --strip-module-prefix | Strip module name from tags when the project has a single module | false |
| --tag-version-prefix <value> | Prefix to add on tag versions (e.g., v) | - |
Examples
Release Version
Apply semantic versions based on commits:
versu runPre-release Versions
Generate beta pre-release versions:
versu run --prerelease-mode --prerelease-id betaTimestamp Versions
Generate timestamp-based pre-release versions for CI builds:
versu run --prerelease-mode --prerelease-id alpha --timestamp-versions --add-build-metadataThis generates versions like: 1.2.3-alpha.20251208.1530+abc1234
Gradle SNAPSHOT Versions
Generate Gradle SNAPSHOT versions:
versu run --append-snapshotDevelopment Workflow
Bump all modules (even unchanged) for development:
versu run --prerelease-mode --bump-unchangedLocal Testing
Test without committing or pushing:
versu run --dry-run --no-push-changes --no-create-tagsManual Git Operations
Calculate versions without automatic git operations:
versu run --no-push-changes --no-create-tagsThen manually review, commit, and push.
Configuration
Versu CLI uses the same configuration system as the core library. Configuration files are automatically detected in your repository root.
You can provide configuration in any of the supported config files (e.g., .versurc, versu.config.js, etc.) or via package.json under the versu key. For the full list please refer to cosmiconfig search places documentation.
Configuration Example
.versurc.json:
{
"versioning": {
"breakingChange": {
"stable": "major",
"prerelease": "premajor"
},
"unknownCommitType": {
"stable": "patch",
"prerelease": "prepatch"
},
"commitTypes": {
"feat": {
"stable": "minor",
"prerelease": "preminor"
},
"fix": {
"stable": "patch",
"prerelease": "prepatch"
}
},
"cascadeRules": {
"stable": {
"major": "major",
"minor": "minor",
"patch": "patch"
},
"prerelease": {
"premajor": "premajor",
"preminor": "preminor",
"prepatch": "prepatch",
"prerelease": "prerelease"
}
}
},
"changelog": {
"root": {
"context": {
"prependPlaceholder": "<!-- Next Version Placeholder -->"
}
},
"module": {
"context": {
"prependPlaceholder": "<!-- Next Version Placeholder -->"
}
}
}
}For more configuration examples, see the core package documentation.
Advanced Changelog Configuration:
Versu supports conventional-changelog-writer options for customizing changelog generation. For advanced customization with functions (transforms, sorting, templates), use JavaScript configuration files:
// versu.config.js
module.exports = {
versioning: {
// ... version rules
},
changelog: {
module: {
options: {
groupBy: 'type',
commitsGroupsSort: (a, b) => {
const order = { feat: 1, fix: 2, perf: 3 };
return (order[a.title] || 99) - (order[b.title] || 99);
},
transform: (commit, context) => {
// Custom commit transformation
const commitPatch = {};
return commitPatch;
}
}
}
}
};Build System Support
Build system support is provided by adapter plugins:
- @versu/plugin-gradle - Gradle (Groovy & Kotlin DSL)
- @versu/plugin-maven - Maven
- @versu/plugin-node - Node.js (npm, yarn and pnpm workspaces)
For more details please refer to each plugin documentation.
Commit Message Format
Versu uses Conventional Commits to determine version bumps:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]Examples:
feat(api): add new endpoint→ minor bumpfix(core): resolve memory leak→ patch bumpfeat!: breaking API change→ major bump
Breaking Changes
Breaking changes trigger major version bumps:
Using
!after the type:feat!: remove deprecated APIUsing
BREAKING CHANGE:in the footer:feat: update API BREAKING CHANGE: The old API is removed
CI/CD Integration
GitHub Actions
- name: Install Versu CLI
run: npm install -g @versu/cli
- name: Install Adapter
run: |
# install required adapters
npm install -g @versu/plugin-gradle
- name: Version modules
run: versu runGitLab CI
version:
script:
- npm install -g @versu/cli
- npm install -g @versu/plugin-gradle
- versu runJenkins
stage('Version') {
steps {
sh 'npm install -g @versu/cli'
sh 'npm install -g @versu/plugin-gradle'
sh 'versu run'
}
}Local Development
Add to your package.json:
{
"scripts": {
"version": "versu run --dry-run",
"version:release": "versu run"
}
}Then run:
npm run version # Dry run
npm run version:release # Actual releaseTroubleshooting
Command Not Found
If versu is not found after global installation:
- Check npm global bin path:
npm bin -g - Ensure it's in your PATH
- Try using npx:
npx @versu/cli
Permission Denied on Push
If you get permission errors when pushing:
- Ensure you have proper git credentials configured
- Check if you have write access to the repository
- Use
--no-push-changes --no-create-tagsto skip git operations
No Version Bump Detected
If versions aren't bumping:
- Check commit messages follow Conventional Commits format
- Verify you have commits since the last version
- Check configuration if certain commit types are ignored
- Use
--dry-runto see what Versu detects
Adapter Not Detected
If auto-detection fails:
- Verify your project has the expected build files
- Explicitly specify the adapter:
--adapter gradle - Check if your project structure is supported
Development
Building from Source
# From monorepo root
npm install
npm run build
# Or from CLI package
cd packages/cli
npm install
npm run buildRunning Locally
# After building
bin/dev.js --dry-runPublishing
npm publish --workspace packages/cli --access publicRelated Packages
- @versu/core - Core library for custom integrations
- @versu/action - GitHub Actions integration
- @versu/plugin-gradle - Gradle adapter plugin
- @versu/plugin-maven - Maven adapter plugin
- @versu/plugin-node - Node.js adapter plugin
License
MIT License - see LICENSE for details.
