GithubHelp home page GithubHelp logo

npm-bump's Introduction

npm-bump

A better npm version major|minor|patch

Installation

To install invoke:

npm install -g npm-bump

You now have the npm-bump binary available.

If you want to use it as a module, invoke:

npm install npm-bump --save

Rationale

The aim of this module is to keep a repository in a state where if the version value in package.json points to a stable version, it's a tagged commit that was published to npm. Since one can add Git endpoints as packages' "versions", this allows to quickly check if an installed dependency uses a pre-release or a stable version.

Usage

Once the package has been installed, it may be used from the terminal:

npm-bump releaseType

where releaseType is one of: major, minor and patch.

To use as a module, do the following:

var npmBump = require('npm-bump');
npmBump(releaseType);

You can check the version of npm-bump via:

npm-bump --version

Regardless of using the package as a binary or a module, invoking the above code will result in:

  1. Creating a new commit that increases the project version to the nearest stable one having a larger major/minor/patch than currently.
  2. Tagging the commit with a specified version.
  3. Creating a new commit with an increased patch version and the -pre suffix added.
  4. Asking the user to do a final check and proceed or rollback.

If the user goes along, the new version gets published and created commits and tags pushed to the origin remote. Otherwise, all the changes are reversed.

Until the user gives the final green light, everything happens locally and is fully reversible.

Pre-releases

If you supply releaseType other than major/minor/patch, it will be treated as a pre-release identifier and a proper pre-release version will be tagged & published. Such a version will be published with an npm tag equal to the identifier. For example, if your package is currently at version 1.0.0-pre, the following command:

npm-bump beta

will publish a version 1.0.0-beta.0 under the tag beta and bump the version to 1.0.0-beta.1-pre.

Options

You can optionally pass the remote name and the branch name to be used, in addition to a prefix to be applied to the version bump commit message. By default the remote is assumed to be origin and the branch: main.

You can also provide the access option with the public or private value to declare whether the package should be public or private. When not provided, it uses default npm behavior: scoped packages are private & unscoped ones - public.

To customize, do the following:

  1. When using from shell:
npm-bump minor --remote origin --branch main --prefix "[no-ci]" --access public

or:

npm-bump minor -r origin -b main -p "[no-ci]" ---access public

Run:

npm-bump --help

or:

npm-bump -h

to see the full information about accepted options.

  1. When using as a library:
var npmBump = require('npm-bump').custom({
    remote: 'origin',
    branch: 'main',
    prefix: '[no-ci]',
    access: 'public',
});
npmBump(minor);

Supported Node.js versions

This project aims to support all Node.js versions supported upstream with the exception of those in maintenance mode (see Release README for more details).

Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using npm test.

License

Copyright (c) 2014 Michał Gołębiowski-Owczarek. Licensed under the MIT license.

npm-bump's People

Contributors

dependabot[bot] avatar mgol avatar robloach avatar viqueen 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

Watchers

 avatar  avatar  avatar  avatar

npm-bump's Issues

A better rollback when something fails

If anything throws in a process before we publish on npm, a full rollback should happen (including a push --force on a branch to the previous version?)

Support Windows

This line fails on windows:

const getPackageJsonPath = () => `${ process.cwd() }/${ getRootPath() }package.json`;

Version bumped from 0.0.1-beta.0 to 0.0.1-beta.1
fatal: pathspec 'C\:\\Users\\username\\path\\to\\folder/package.json' did not match any files
C:\Users\username\path\to\folder\node_modules\npm-bump\bin\npm-bump:22
        throw error;
        ^

Error: Command failed: git add C\:\\Users\\username\\path\\to\\folder/package.json
fatal: pathspec 'C\:\\Users\\username\\path\\to\\folder/package.json' did not match any files

    at checkExecSyncError (child_process.js:490:13)
    at execSync (child_process.js:530:13)
    at run (C:\Users\username\path\to\folder\node_modules\npm-bump\lib\cli.js:46:32)
    at doBump (C:\Users\username\path\to\folder\node_modules\npm-bump\lib\cli.js:61:13)
    at releaseType (C:\Users\username\path\to\folder\node_modules\npm-bump\lib\cli.js:120:9)
    at Object.<anonymous> (C:\Users\username\path\to\folder\node_modules\npm-bump\bin\npm-bump:17:65)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1

bumping snapshot/build version in CI only

Cześć Michał :)

I've got a usecase with managing npm package versions and I'm not sure whether it matches with you npm-bump library. I would like a CI server (e.g. jenkins, travis, etc) to build my app, run tests and then publish it - for each build, I need to have all snapshots. For this reason, I have to bump up package.json's version each time. Doing it manually is practically undoable, so I was looking for something like: npm bump ${MyCIBuildNumber} which would automatically update the version without saving it back in git.

Do you think it matches the purpose of this lib? I need no actual git actions performed, no npm publish, just to update version with a value from CLI.

git commit subcommand fails on Windows 10 (probably due to ' ' instead of " ")

Tried in Git Bash, Powershell and cmd

child_process.js:669
throw err;
^
Error: Command failed: git commit -m 'Tag 1.1.10'
error: pathspec '1.1.10'' did not match any file(s) known to git
at checkExecSyncError (child_process.js:629:11)
at execSync (child_process.js:666:13)
at run ((...)\node_modules\npm-bump\lib\cli.js:72:13)
at doBump ((...)\node_modules\npm-bump\lib\cli.js:110:13)
at releaseType ((...)\node_modules\npm-bump\lib\cli.js:213:9)
at (...)\deploy.js:12:52
at Object.<anonymous> ((...)\deploy.js:40:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)```

An option to skip git commit/push

I found this script and want to use it for snapshot versioning. It would be nice to disable git commit/push functionality to prevent spamming the git repository.

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.