bpv v1.1.1
bpv - BumP Version
Bpv is a package that helps you to increase semver versions in your project. It takes the current version, increases it, and then updates all matches in the specified files with the new version.
Installation
npm i -D bpvOr, you may want to install it globally:
npm i -g bpvConfiguration
Bpv expects a bpv.conf.json file, which
looks like this:
{
"currentVersion": "20.0.3",
"commitMessage": "chore: bump version",
"rules": [
{"file": "bpv.conf.json", "version": "\"currentVersion\": \"{{version}}\""},
{"file": "manifest.xml", "version": "\"version\": \"{{version}}\""}
]
}currentVersionholds current software's version.rulesis an array of objects with information about files that contain version strings and how version strings look.{{version}}in the "version" property is an actual semver version. Use\"to escape quotes.commitMessage(optional) is a commit message that will be used if--commitflag is provided
Example
If we have a build.gradle file:
android {
namespace 'com.example.testapp'
compileSdk 33
defaultConfig {
applicationId "com.example.testapp"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0.3"
...
}
}
...And we want to increment version only in this file, our
bpv.conf.json should look so:
{
"currentVersion": "1.0.3",
"rules": [
{"file": "bpv.conf.json", "version": "\"currentVersion\": \"{{version}}\""},
{"file": "android/build.gradle", "version": "versionName \"{{version}}\""}
]
}Note that bpv.conf.json is also presented in the config file.
Usage
Increment version
Use bump command with a version number to increment (major, minor, or patch),
for example:
npx bpv bump --majorThere're also a few optional flags:
--commit,-c- if set, bpv creates a commit with the "Bump version" message. Under the hoodbpvusesgit add -uorhg cicommands to add files, so files that are not in the git index won't be commited. Supports git and mercurial.--tag,-t- create a tag after version increment with new version as annotate message--verbose,-v- print the list of files and the result of version replacement in them.
Bump version and create a "Bump version" commit:
npx bpv bump --patch --commitSet version
Use the set command to set a version directly:
npx bpv set "1.0.0-beta.0"The set command also accepts --commit, --tag and --verbose flags.
Test version bump
You can check how a command will work without
any real changes with a --dry (-d) option.
It prints a new version and the list of files that will be changed:
npx bpv bump --major --dryOutput:
DRY RUN MODE IS ON. NO FILES WILL BE ACTUALLY MODIFIED
New version is: 2.0.0
File: bpv.conf.json changed: true
File: app/last_changelog.md changed: trueYou can use --dry option with --commit or --tag options as well.
No files will be committed and no tags will be created, but you can
see any potential issues:
npx bpv bump --major -dctOutput:
Can't commit because the repository has modified filesTODO
- Use
bp.conf.jsonconfig file instead ofbpv.conf.json - Check if git is available before commit/tag
- Add support for other VCS (mercurial)
- Get rid of
replace-in-filepackage dependency - Add
setcommand to manually set the version - Create tags in git, not only commits