Giter Site home page Giter Site logo

js-devtools / version-bump-prompt Goto Github PK

View Code? Open in Web Editor NEW
256.0 2.0 69.0 1.04 MB

Interactive CLI that bumps your version numbers and more

Home Page: https://jstools.dev/version-bump-prompt/

License: MIT License

JavaScript 58.86% TypeScript 41.14%
nodejs javascript cli version versioning semver semantic-versioning

version-bump-prompt's Introduction

Version Bump Prompt

Cross-Platform Compatibility Build Status

Coverage Status Dependencies

npm License Buy us a tree

Screenshot

Automate your release process with a single command that can:

  • Prompt for the type of version bump

  • Bump the version number any file, including:

    • package.json
    • package-lock.json
    • config files
    • source code files
    • ReadMe files
    • license files
  • Run your preversion, version, and postversion scripts

  • Commit changes to git

  • Tag the commit with the version number

  • Push the commit to remote

Installation

You can install version-bump-prompt via npm.

npm install -g @jsdevtools/version-bump-prompt

Usage

bump [release] [options] [files...]

Automatically (or with prompts) bump your version number, commit changes, tag, and push to Git

release:
  The release version or type.  Can be one of the following:
   - A semver version number (ex: 1.23.456)
   - prompt: Prompt for the version number (this is the default)
   - major: Increase major version
   - minor: Increase minor version
   - patch: Increase patch version
   - premajor: Increase major version, pre-release
   - preminor: Increase preminor version, pre-release
   - prepatch: Increase prepatch version, pre-release
   - prerelease: Increase prerelease version

options:
  --preid <name>            The identifier for prerelease versions.
                            Defaults to "beta".

  -c, --commit [message]    Commit changed files to Git.
                            Defaults to "release vX.X.X".

  -t, --tag [tag]           Tag the commit in Git.
                            The Default tag is "vX.X.X"

  -p, --push                Push the Git commit.

  -a, --all                 Commit/tag/push ALL pending files,
                            not just the ones that were bumped.
                            (same as "git commit -a")

  --no-verify               Bypass Git commit hooks
                            (same as "git commit --no-verify")

  -v, --version             Show the version number

  -q, --quiet               Suppress unnecessary output

  -h, --help                Show usage information

  --ignore-scripts          Bypass version scripts

files...
  One or more files and/or globs to bump (ex: README.md *.txt docs/**/*).
  Defaults to package.json and package-lock.json.

Examples

Default Behavior (no arguments)

bump

When run without any arguments, the bump command will do the following:

  • Prompt the user to select the bump type (major, minor, prerelease, etc.)
  • Update the version number in package.json and package-lock.json
  • Run any npm version scripts (preversion, version, or postversion)
  • It will NOT commit, tag, or push to git.

Bump Without Prompting

You can specify an explicit version number:

bump 1.23.456
bump 1.23.456-beta.1

Or you can specify a release type:

bump major
bump patch
bump prerelease

For pre-releases, the default identifier is "beta". You can change it using the --preid argument:

bump premajor --preid alpha

All of the above commands do the following:

  • Update the version number in package.json and package-lock.json
  • Run any npm version scripts (preversion, version, or postversion)
  • It will NOT commit, tag, or push to git.

Git Commit

You can use the --commit argument by itself to prompt the user for the version number. If you don't specify a commit message, then it defaults to "release vX.X.X". If you do specify a commit message, then the version number will be appended to it. Or you can insert %s placeholders in the message, and they'll be replaced with the version number instead.

bump --commit
bump --commit "This is release v"
bump --commit "The v%s release"

You can also specify a release type instead of prompting the user:

bump major --commit
bump minor --commit "This is release v"
bump patch --commit "The v%s release"

The above commands do the following:

  • Update the version number in package.json and package-lock.json
  • Run any npm version scripts (preversion, version, or postversion)
  • Commit the package.json and package-lock.json files to git
  • The commit will NOT be tagged
  • The commit will NOT be pushed to the remote

Git Tag

The --commit argument does not tag the commit by default. You can use the --tag argument to do that. You can optionally specify a tag name, which can contain %s placeholders, just like the commit message.

You don't need to specify the --commit argument, since it's implied by --tag. Unless you want to customize the commit message.

bump --tag
bump major --tag "v%s tag"
bump patch --commit "release v" --tag "v"

The above commands do the following:

  • Update the version number in package.json and package-lock.json
  • Run any npm version scripts (preversion, version, or postversion)
  • Commit the package.json and package-lock.json files to git
  • Tag the commit
  • The commit will NOT be pushed to the remote

Git Push

The --push argument pushes the git commit and tags.

bump --commit --push
bump major --tag --push
bump patch --tag "v%s tag" --push
bump prerelease --commit "release v" --tag "v" --push

Specifying Files to Update

All of the bump commands shown above operate on the package.json and package-lock.json files by default. You can specify a custom list of files and/or glob patterns to update instead.

Note: If you specify your own file list, then the package.json and package-lock.json files will not be updated by default. You need to explicitly include them in your file list if you want them updated.

bump README.md
bump package.json package-lock.json README.md
bump *.json *.md

Version Scripts

version-bump-prompt will execute your preversion, version, and postversion scripts, just like the npm version command does. If your package.json file contains any or all of these scripts, then they will be executed in the following order:

  • The preversion script runs before the version is updated (and before the version prompt is shown)
  • The version script runs after the version is updated, but before git commit and git tag
  • The postversion script runs after git commit and git tag, but before git push

Contributing

Contributions, enhancements, and bug-fixes are welcome! Open an issue on GitHub and submit a pull request.

Building

To build the project locally on your computer:

  1. Clone this repo
    git clone https://github.com/JS-DevTools/version-bump-prompt.git

  2. Install dependencies
    npm install

  3. Build the code
    npm run build

  4. Run the tests
    npm test

License

Version Bump Prompt is 100% free and open-source, under the MIT license. Use it however you want.

This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

Big Thanks To

Thanks to these awesome companies for their support of Open Source developers ❤

GitHub NPM Coveralls Travis CI SauceLabs

version-bump-prompt's People

Contributors

greenkeeperio-bot avatar jamesmessinger avatar sidtagirisa avatar sqrtofsaturn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

version-bump-prompt's Issues

$ foo> bump dir/package.json doesn't work

reads the file correctly and presents the correct version, but then complains that foo/package.json doesn't exist (which it rightfully doesn't) and doesn't really write the file that it was supposed to.

Integration with husky

I have the following configuration in my package.json:

{
  "husky": {
    "hooks": {
      "pre-commit": "npm run lint && npm run bump",
    }
  }
...

The bump-prompt is opened and asks me for the version but does not let me choose and returns to my console. Exists some way to integrate with husky hooks?

A typo in README

There is a typo in README.md:

Bump the version number in all of your JSON manifets, including:

Support for -n or --no-verify option

Hello,

I started using this module as a remplacement for npm/standard version, but in my workflow we use commitlint to ensure well formated commit message.

And when i prepare a release, and because i don't need to lint my commit message, i can use --no-verif to bypass linting.

At this moment i have found a workaround with git-branch-is to check the branch name, but i think it would be cool to add this option.

Thanks !

Can you add a variable for the version in the commit message?

Can you add a variable for the version in the commit message?

npm version does this. See https://docs.npmjs.com/cli/version.html

If supplied with -m or --message config option, npm will use it as a commit message when creating a version commit. If the message config contains %s then that will be replaced with the resulting version number. For example: npm version patch -m "Upgrade to %s for reasons"

So%s becomes the version - bump --premajor --lock --commit "release %s to the wild"

Thanks!

Can't see output

I have a script called publish in my package.json, which simply does "bump --prompt". This in turns kicks off the "version" script in my package.json as expected which runs my webpack build but I can't see any output from the "version" script. If I run "version" directly via "npm run version" I see the expected output.

All occurences of old version are replaced in files instead of only the first

Hi,

In my package.json (and others files passed to bump command), there are some dependencies like "cordova-plugin-add-swift-support": "1.7.0", in it.

When i bump with bump --prompt --tag --push --all --grep config.xml for new value at 1.7.1 for example, if my actual package version is the same as dependencies versions (exemple 1.7.0), then all occurences are replaces in files instead of only the first value (example in package.json : "version": "1.7.0",).
So when bump is finished, the dependencie is also at the new version "cordova-plugin-add-swift-support": "1.7.1",, altough it must not be !

A correction for this will be to replace the line 162 in lib/index.js: let oldVersionPattern = new RegExp(oldVersion.replace(/\./g, '\\.'), 'g');
with let oldVersionPattern = new RegExp(oldVersion.replace(/./g, '\.'));
The new code replace only the first occurence of old version in any files changing by bump command.

What do you think ?

Update version in text file via regex or other means

If you have a changelog file or similar, it would be helpful to specify a next or other named field that will be replaced by the new bumped version.

Possibly configurable via a local config file maybe, or a predefined value like next.

Leave as-is crashes - exit code 1

When choosing an existing version (leave as-is in the menu) the app crashes as Git fails to commit without any changes:

$ bump prompt --commit --tag --push --preid r

?
The current version in package.json is 0.2.0
How would you like to bump it? leave as-is (0.2.0)
ℹ package.json did not need to be updated
ℹ package-lock.json did not need to be updated
git commit --message "release v0.2.0" exited with a status of 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] bump: `bump prompt --commit --tag --push --preid r`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] bump script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/x/.npm/_logs/2019-11-15T11_33_15_429Z-debug.log
ERROR: "bump" exited with 1.

In this case, version 0.2.0 has already been released and I simply wanted to leave the version as-is during deployment to another location.

Suggested fix: If a user selects leave-as-is, all other operations should be bypassed (git etc.) - Maybe process.exit(0)?

Make git tag prefix "v" optional.

Hello,

I noticed that git tags are prefixed with the letter "v" but this is not the case for package.json.

In some workflows we need git tags and npm versions to be identical.

So, it may be practical to be able to standardize both.

Thanks.

Version number added to beginning of commit message

The version number is added to the beginning of the commit message instead of the end.

Steps to recreate:

  1. NPM package.json version is v1.7.0-alpha.0
  2. Run bump --preminor --lock --commit 'Upgrading to v'
  3. New commit message is "v1.8.0-alpha.0 Upgrading to v"

Syncing versions

Would be nice if we could sync the version from package.json to the other JSONs. In my case, I want to keep my composer, bower and package JSONs in sync, version-wise.

is that be possible to be added?

[Feature] Support no-bump option

I use this package in a lot of projects, and it's terribly convenient, but one item which is missing in my opinion is the ability to specify a no-bump option. Sometimes a deployment fails due to some network condition in one of our projects and we'd simply like to deploy the bumped version.. It'd be great if there were a flag for such an option within version-bump-prompt, such as --allow-no-bump or --opt-bypass, for example.

As version-bump-prompt is usually always the first step for me, having such a feature would mean that I wouldn't need to add another prompt before this one.

EDIT: I'd happily add this if it's something you'd be interested in.

Doesn't find version in OpenApi spec

I have an JSON OpenApi spec that I want to bump the version in as part of a build process. The version property is located in the info object of the JSON as dictated by the OpenAPI standard. When I run the command, for example, bump 3.0.0 my-api.json, it results in a message of my-api.json did not need to be updated. Is there a way to tell the bump command where to look for the version? When I played around with it, it seems that bump only finds the version field if it is at the top level. Is there a way to tell where the version is actually located?

BUG package-lock.json version does not get bumped at second position

we do have a vscode extension, which adds itself as a package in package-lock.json - but it just bumps the version in line 3, but not in line 8, which is reference to own package. After npm install this version gets changed too..

{
  "name": "generic-vscode-extension",
  "version": "0.1.0", // this gets bumped
  "lockfileVersion": 2,
  "requires": true,
  "packages": {
    "": {
      "version": "0.0.9", // this is just updated after running npm install, so not working
      "license": "MIT",
      "devDependencies": {
        ...
      }
    },
    ...
  }
}

Config file for defaults

Hi, awesome project!! I'd love to contribute.

I run bump --tag --commit every time one of my repos changes and I was thinking there would be a lot of convenience to have a .bumprc file to set default behavior and such. For me I would put tag=true and commit=true in the .bumprc file and only have to run bump from the project root. Thoughts?

Local version supported?

Ideally I don't want to install this globally so I installed against a single repo and ran:

npx bump patch ./app-version.json

But that just changed my package.json version to "patch"

I've also tried npx bump --patch app-version.json but can't seem to find the right combination of arguments to update my custom file.

app-version.json:

{
  "version": "2.0.5"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.