1.5.11 • Published 4 months ago

nbump v1.5.11

Weekly downloads
-
License
-
Repository
-
Last release
4 months ago

New Bump version

A small command line tool to simplify releasing software by updating all version strings in your source code by the correct increment. Out of box, UI friendly and configure easily. And with other features:

Install

npm i -g nbump

Usage

vv # or bump
vv alpha # bump to next prerelease version, other args please see below.

Feature

Hooks

There are two kind of hooks supported.

  1. leading hook, this hook will run before package json version updated.
  2. trailing hook, run after updated of course.

E.g.

{
  "leading": ["git pull --rebase", "pnpm i"],
  "trailing": ["npm run build"]
}

Attach Changelog

Auto detect changelog file location, and regenerate after update package version.

To enable it.

{
  "changelog": true
}

Whitelist or Blacklist branch

The bump version allows you ban special branch run it, such as you don't want to be contaminated other branches which is not main branch. In main branch, you just allow publish stable version, but ban unstable version. Oppositely, dev branch not allow to publish stable version just unstable. It's ok. Just write configuration as below.

{
  "allowed_branches": [
    "main",
    {
      "name": "dev/*",
      "allow_types": ["premajor", "preminor", "prepatch", "prerelease"]
    }
  ]
}

Git Tag Mode

If the project maintains by a team and other developers can publish their own unstable version, the publish action will create a git tag based on new version. So, if another developer bump version at same time, he will got a conflict error because of git tag is exist on remote repository.

For example, if Developer A and Developer B checkout two private branches from the master branch and fix a bug that requires release new version. At this point, the projects are both at version 1.0.0, and A has created a Git Tag 1.0.0-alpha.0 on the private branch and pushed it to the remote repository, while B has also created a Git Tag 1.0.0-alpha.0 on the private branch, and there is a conflict.

So, the tool provide git tag mode, it can fetch remote git tags, and gerenate the correct version according to the git tags (or remote) sequence, and no conflicting tags are generated.

To enable it.

{
  "with_tags": true,
  "remote_tags": true
}

Now if your local or remote tags has tag 1.0.1, but project current version is 1.0.0, so the next patch version will be generate as 1.0.2.

Another example, if remote tags has tag 1.2.0 1.3.0, project current version is 1.1.0, the next minor version is 1.2.0 theoretically, but if you enable this feature, it will generate a non-conflicting version as 1.4.0.

Other information, please see the test suit.

Args

This is args passed in cli command. e.g. vv --dry-run.

ArgsDescriptionExample
--dry-runDry run mode
-f --filterRun in special monorepo workspace-f packages/core
--alpha --prereleaseCreate prerelease version
--tag-prefixCustom git tag prefix, the priority is higher than rcfile
--no-verifyForce bump version, no verify allowed branches or disallow.
minorCreate minor version
majorCreate major version
patchCreate patch version
prepatchCreate prepatch version
preminorCreate preminor version
premajorCreate premajor version
branchCreate version based on git branch (1.2.2-dev-perid.0)

Configuration

Define in package.json, add field bump or create .bumprc in root dir:

There is a example configuration.

{
  "leading": ["git pull --rebase", "pnpm i", "npm run build"],
  "trailing": ["sh ./scripts/create-tags.sh", "npm publish --access=public"],
  "changelog": true,
  "publish": true
}
NameDescriptionTypeDefault
leadingRun script before change versionstring[][]
trailingRun script after change versionstring[][]
publishPublish package after bumpbooleanfalse
tagCreate git tag after bumpbooleantrue
pushPush git commit after bumpbooleantrue
commit_messageCommit message for new version tagstringrelease: v${NEW_VERSION}
changelogGenerate changelogboolean | ChangelogOptionsfalse
allowed_branchesAllow run bump version on special branch(RegExp | string | AllowedBranchesOptions)[]["main", "master"]
tag-prefixGit prefix tagstringv
modeWorkspace modeindependent monorepoindependent
packagesMonorepo mode packages pathstring[][]
with_tagsGenerate next version based on git tags, maybe slowly.booleanfalse
remote_tagsFetch git remote tags before version generate, only work when with_tags enable.booleantrue

Interface

type ReleaseType =
  | 'patch'
  | 'minor'
  | 'major'
  | 'premajor'
  | 'preminor'
  | 'prepatch'
  | 'prerelease'

export interface AllowedBranchesOptions {
  name: string
  disallowTypes: ReleaseType[]
  allowTypes: ReleaseType[]
}

/**
 * @see https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-core
 */
export type ChangelogOptions = Parameters<typeof conventionalChangelog>[0] & {
  enable: boolean
}

License

2022 © Innei, Released under the MIT License.

Personal Website · GitHub @Innei

1.5.11

4 months ago

1.5.9

1 year ago