• Stars
    star
    199
  • Rank 196,105 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A cross packaging module version bumper. CLI or API for bumping versions of package.json, bower.json, *.jquery.json etc.

mversion - A cross packaging manager module version handler/bumper

npm Travis Gemnasium

Imitates npm version to also work on other packaging files. For those times you have either have multiple packaging files (like bower.json, component.json, manifest.json) or just not a package.json file. mversion can easily bump your version and optionally commit and create a tag.

mversion file support

  • package.json
  • npm-shrinkwrap.json
  • component.json
  • bower.json
  • manifest.json
  • *.jquery.json (jquery plugin files, e.g plugin.jquery.json)

Usage CLI

npm install -g mversion

Examples

$ mversion patch
New Version: 0.0.6
Updated package.json
Updated component.json
$ mversion 0.0.5 -m
New Version: 0.0.5
Updated package.json
Updated component.json
Updated manifest.json
Commited to git and created tag v0.0.5
$ mversion 1.0.0-rc1 -m "Now in wopping v%s"
New Version: 1.0.0-rc1
Updated package.json
Updated component.json
Commited to git and created tag v1.0.0-rc1

Help

$ mversion -h

Usage: mversion [ <newversion> | major | minor | patch | prerelease ] [ -m <optional message> ] [ -n | --no-prefix ]
(run in package dir) - (Also supports premajor, preminor and prepatch, see semver summary)

Update module version in either one or all of package.json,
component.json, bower.json, manifest.json and *.jquery.json.

Run without arguments to get current version.

Semver Summary

Given a version number MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when you make incompatible API changes,,
  • MINOR version when you add functionality in a backwards-compatible manner, and,
  • PATCH version when you make backwards-compatible bug fixes., Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.,

Update version

Update version by defining new semver valid version or a release string (major, minor, patch, build).

Ex: "mversion minor" Ex: "mversion 1.0.1-beta"

Git

Use -m to auto commit and tag. Apply optional message and use '%s' as placeholder for the updated version. Default message is 'v%s' where %s is replaced with new version.

--tag (or -t for short) allows for overriding the tag name used. This does not change behaviour of the message, just the tag name. As with -m, all occurances of %s is replaced with the newly bumped version.

--no-prefix (or -n for short) is a short hand for setting a tag name without v as prefix. This does not change behaviour of the message, just the tag name.

-- Ex: "mversion minor -m" Ex: "mversion minor -m 'Bumped to v%s' --tag 'v%s-src'"

Version aliases

If you are lazy you can also use aliases for the version release type.

mversion p

The full list of aliases:

"pa": "patch",
"pr": "prerelease",
"ma": "major",
"mi": "minor",
// one char might be controversial, but it saves key strokes
"m": "major",
"p": "patch",
"i": "minor"

Default settings

Create a .mversionrc file in your root with default settings as defined in the README.md of the project.


## Default Settings

You can provide default settings by creating a `.mversionrc` file
in the root of your project (or in a directory higher up in the hierarchy).
This way you can define project specific tag names or commit messages.

See API below to see what options are accepted.

### Example `.mversionrc`

```json
{
  "commitMessage": "Bumped to %s",
  "tagName": "v%s-src"
}

Now, when doing this in the Terminal:

$ mversion minor

would now be the same as doing:

mversion minor -m "Bumped to %s" -t "v%s-src"

Note: CLI arguments take precedence over default options. So doing this (with the .mversionrc file as defined above):

mversion minor -m "Kicked version to %s"

Would lead to the commit message being Kicked version to %s, and tag name to be v%s-src.

Hooks

.mversionrc will also allow you to define hooks before (preupdate) and after (postupdate) version is updated.

Example

{
  "scripts": {
    "preupdate": "echo 'Bumping version'",
    "precommit": "sh ./someHook.sh",
    "postcommit": "git push && git push --tags && npm publish",
    "postupdate": "echo 'Updated to version %s in manifest files'"
  }
}

If precommit fails (returns something other that exit 0) the commit will be checked out (removing the version bump changes).

Usage API

npm install mversion
var mversion = require('mversion');

mversion.get(function (err, data) {
  /*
    data = {
      'package.json': VERSION,
      'component.json': VERSION
    }
  */
});

mversion.update('minor', function (err, data) { })
mversion.update('major', function (err, data) { })
mversion.update({
    version: 'major',
    commitMessage: 'Some commit message for version %s'
  }, function (err, data) { }) // Will commit/tag
mversion.update({
    version: 'major',
    commitMessage: 'Some commit message for version %s',
    noPrefix: true
  }, function (err, data) { }) // Make tag without v prefix
mversion.update('patch', function (err, data) { })
mversion.update('prerelease', function (err, data) { })
mversion.update({
    version: '0.0.1',
    commitMessage: 'Bumping version'
  }, function (err, data) { }) // Will commit/tag
mversion.update('v1.0.1', function (err, data) { })
mversion.update('v1.0.1-beta', function (err, data) { })
mversion.update('v1.0.1-010988', function (err, data) { })

mversion.get(callback(err, data))

Get version of all the different package files. See example above.

mversion.update([options, ]callback(err, data))

Update version of found package files.

Example of the data returned from the callback:

{
  "newVersion": "1.0.0",
  "versions": { "package.json": "1.0."},
  "message": "Updated package.json",
  "updatedFiles": ["/mversion/example/package.json"]
}

Some times both data and err has values. In this case some package files were updated and some not.

options : Undefined

If options is undefined a standard bump of minor will be used.

options : String

If options is a string, this string is used as the version bump.

Example:

mversion.update('major')

options.version : String

Used to bump version. See above.

options.commitMessage : String

Used as message when creating commit in Git. Also used as message for the annotated tag created. If undefined, no commit will be made.

Occurances of %s in commit message will be replaced with new version number.

Example:

mversion.update({
  version: 'major',
  commitMessage: 'Bumps to version %s'
});

options.tagName : String

Default: v%s

Allows for overriding of tagName. For instance adding a suffix and changeing tag to be named v%s-src.

Will only take affect if commitMessage is defined.

Occurances of %s in tag name will be replaced with new version number.

Example:

mversion.update({
  version: 'major',
  commitMessage: 'Bumps to version %s',
  tagName: 'v%s-src'
});
// Might produce annotated tag named v1.0.0-src

options.noPrefix : Boolean

If true and commit message is defined, the annotated tag created will not have 'v' as prefix. This is a short hand for defining setting tag name to %s. Do not work if tag name is overriden (options.tagName is defined).

Example:

mversion.update({
  version: 'major',
  commitMessage: 'Bumps to version %s',
  noPrefix: true
});
// Might produce annotated tag named 1.0.0

This would be the same as:

mversion.update({
  version: 'major',
  commitMessage: 'Bumps to version %s',
  tagName: '%s'
});
// Might produce annotated tag named 1.0.0

mversion.isPackageFile(filename) : Boolean

Checks whether or not the given filename is a valid package file type.

Examples:

assert.equal(mversion.isPackageFile('package.json'), true);
assert.equal(mversion.isPackageFile('component.json'), true);
assert.equal(mversion.isPackageFile('bower.json'), true);
assert.equal(mversion.isPackageFile('foobar.json'), false);
assert.equal(mversion.isPackageFile('foobar.jquery.json'), true);
assert.equal(mversion.isPackageFile('foojquery.json'), false);

Changelog

1.9.0

  1. Adds aliases for bumps (p, m, i) (#20)

1.8.0

  1. Adds Composer support. (#19)

1.7.0

  1. Replaces %s with newVersion in post scripts. Fixes #18

1.6.1

  1. Adds support for git staging files with spaces. Fixes #17

1.6.0

  1. Adds auto-updater to mversion.

1.5.0

  1. Fixes issue with version bump being parsed as number and running string operations.
  2. Improves error given on invalid version input
  3. Bumps minimatch and semver to latest versions.

1.4.0

  1. Adds pre-/postcommit hooks allowing for commands to be run before and after version bump git commit.

1.3.0

  1. Adds .mversionrc file for defining default settings
  2. Adds pre-/postupdate hooks allowing for commands to be run before and after version bump. Useful for instance for doing npm publish or git push.

1.2.0

  1. Adds option to override tag name (options.tagName) in #update.
  2. Misc. refactoring and further testing.

1.1.0

  1. Improves CLI arguments. Now arguments is indifferent to order
  2. Adds better error handling and user feedback on partial version update (not all files).

1.0.0

  1. Changes API to use an object literal, avoiding magic strings/primitives.

0.5.0

  1. Adds noPrefix flag. Allowing to define whether or not to prefix tags with "v".

License

MIT License

More Repositories

1

node-notifier

A Node.js module for sending notifications on native Mac, Windows and Linux (or Growl as fallback)
JavaScript
5,742
star
2

awesome-es2015-proxy

For learning how to use JavaScript Proxy, or just to see what is possible
JavaScript
609
star
3

gulp-notify

gulp plugin to send messages based on Vinyl Files or Errors to Mac OS X, Linux or Windows using the node-notifier module. Fallbacks to Growl or simply logging
JavaScript
592
star
4

marked-terminal

A Renderer for the marked project. Allowing you to render Markdown to print to your Terminal
JavaScript
423
star
5

node-notifier-cli

CLI API for node-notifier as separate package.
JavaScript
143
star
6

SocialFeed.js

Generate a social feed in javascript.
JavaScript
132
star
7

metatune

PHP Wrapper for the Spotify Metadata API and the Spotify Play Button
PHP
55
star
8

node-osascript

A stream for Apple Open Scripting Architecture (OSA) through AppleScript or Javascript
JavaScript
50
star
9

bacon-love

A Nodeschool type workshop for Functional Reactive Programming and Bacon.js
JavaScript
48
star
10

fp-react

Functional tools for React components
JavaScript
41
star
11

vscodemod

VSCode extension for doing codemod on selected text
JavaScript
30
star
12

did-i-do-that

A debug tool based on JavaScript Proxy to track surprising/unwanted mutation of objects.
JavaScript
26
star
13

gulp-gitmodified

A plugin for Gulp to get an object stream of modified files on git.
JavaScript
22
star
14

frp-piano

An example of Functional Reactive Programming, by implementing a simple collaborative piano.
CSS
19
star
15

babel-plugin-transform-react-require

Transform files using JSX to implicitly require React (or other implementations).
JavaScript
15
star
16

node-heartrate

A Bluethooth Low Energy heart rate stream
JavaScript
15
star
17

gulp-gitshasuffix

A plugin for Gulp to suffix files with latest commit sha.
JavaScript
11
star
18

chrome-github-packages

Enhance Package.json on Github by linking up modules to NPM
JavaScript
11
star
19

mrun

mrun - A npm module for setting npm run properties to build/watch less and browserify code
JavaScript
10
star
20

lastfm-spotify-urilist

A Node.js module for an easy way of getting a list of Spotify URIs based on Last.fm data.
JavaScript
10
star
21

markdowner

Markdowner is a cloud based application for writing and sharing Markdown documents.
JavaScript
9
star
22

cli-usage

Easily show the usage of your CLI tool from a Markdown string or file
JavaScript
9
star
23

AI-Poker-Player

NTNU Project for AI Programming
Python
8
star
24

metabrag

A jQuery plugin for showing off your GitHub and Coderwall stats.
JavaScript
7
star
25

kodesnutt

Kode brukt i episoder av Kodesnutt.io
JavaScript
5
star
26

simplify-playbutton

Automated service for generating Spotify Play Button for your Last.fm scrobbled tracks. Using Node.js and running on Heroku.
JavaScript
5
star
27

kakle

If Commit, Then Do. Kakle helps you remember when you should run commands after pulling external changes
JavaScript
5
star
28

clapper

Do actions on applause and listen on claps on browser usermedia
JavaScript
4
star
29

node-csstats

Parse AMX Mod X Stats File. A result of procrastinating during a Master's thesis and nostalgia.
JavaScript
4
star
30

SwarmWebots

Project 4 - Artificial Swarm Behavior
Python
4
star
31

traceur-cli

Wraps traceur cli to add REPL and string eval
JavaScript
4
star
32

record-access

Property accessors as functions similar to .property in elm-lang.
JavaScript
4
star
33

didt

Did I do that?
JavaScript
3
star
34

json-ast

OCaml JSON AST generator. Work in progress
OCaml
3
star
35

phpcoderwall

PHP library for fetching Coderwall data
PHP
3
star
36

presentations

A collection of presentations
JavaScript
3
star
37

bacon.decorate

Unify your API and abstract time using Functional Reactive Programming and Bacon.js
JavaScript
3
star
38

graphql-node-import

Import `.graphql` and `.gql` files directly in Node, accessing queries and fragments
TypeScript
3
star
39

rm-debugger

Simplest codemod you can think of, but is still handy: Remove all `debugger;` statements from your code.
JavaScript
2
star
40

nextjs-css-relative-assets-bug-repro

JavaScript
2
star
41

diy-nextjs-server-actions

Example code from presentation "DIY Nextjs Server Actions"
TypeScript
2
star
42

standalone-unrar

A standalone unrar library without any need for external dependencies.
JavaScript
2
star
43

AnnWebots

Project 3 - Webots with Generic Anns
Python
2
star
44

node-repo-github

A very simple node.js wrapper to get Github Repo Information.
JavaScript
2
star
45

twit-stream

Streaming Twitter data with proper Node.JS streams2 with a simple API
JavaScript
2
star
46

react-formdata

A library for generating an object of values from a set of inputs in React
JavaScript
2
star
47

twitscraper

A binary used for scraping the Twitter site for tweets and generate a .tsv file for output
JavaScript
2
star
48

mikaelbr

My special repository
2
star
49

release-actions-demo

JavaScript
1
star
50

bekk-open-source

Repo brukt for planlegging av faggruppearbeid ifm. Open Source
1
star
51

metaenter

A simple jQuery plugin for simulating a facebook-like text input.
JavaScript
1
star
52

dotfiles

My dotfiles used for importing to new systems and backup
Shell
1
star
53

Basic-Evolutionary-Programming

The code for a University project
Python
1
star
54

simplserv

A simple HTTP server using Python. For web development and testing AJAX calls.
Python
1
star
55

aoc22

Advent of Code solutions for 2022 in OCaml
OCaml
1
star
56

lsystem-reasonml

ReasonML experimentation implementing Lindenmayer system
OCaml
1
star
57

stringywingy

Check if a sentence or a word is an anagram or a palindrome.
JavaScript
1
star
58

tweetsa

Python
1
star
59

webkom-kurs2015

Kurs for Webkom Kickoff 2015.
JavaScript
1
star
60

tdcinfographic-raspberry

Server component to the tdcinfographic application. Connecting to the tdcinfographic Node.js app through WebSockets.
Python
1
star
61

podcast-player

CLI tool for listening to podcasts.
JavaScript
1
star
62

kodesnutt.io

Kodesnutt.io homepage
HTML
1
star
63

asyncjs.kodesnutt.io-source

Source for asyncjs.kodesnutt.io
CSS
1
star
64

async-kodesnutt

CSS
1
star
65

webkom-kurs2015-webpack

Kurs for Webkom Kickoff 2015 - WebPack versjon
JavaScript
1
star
66

gifme

gifme client for posting gifs to Slack
OCaml
1
star
67

ndc

My talk for NDC2014: Functional Reactive Programming and Bacon
JavaScript
1
star
68

simplify-zones

Simplify geometry of tariff zones from Entur
JavaScript
1
star
69

tweetannotator

A web tool for annotating sentiment on random tweets. Can be used to generate data sets for machine learning algorithms
JavaScript
1
star
70

CP-Sudoku

Constraint based sudoku solver
Java
1
star
71

immutable-memo

Memoization with immutable data structures for React.memo
JavaScript
1
star
72

textareaAutoHeight

Create a Facebook like input box in seconds. A text area will automaticly set height according to content, and submit on enter, but give new line at shift + enter.
JavaScript
1
star
73

auto-unrar

Automatic unpack all recursive rar-files from a directory
JavaScript
1
star
74

azure-ml-text-analysis

API Wrapper for doing text analysis on Azure Machine Learning Platform
JavaScript
1
star
75

cheerful.dev

Test site for Svelte, Sapper and Now.sh
Svelte
1
star
76

Coding-Dojo-Counter

A web application for selecting sparrers and keeping time in Coding Dojos. Integration with Facebook Events
JavaScript
1
star
77

bekk-trhfrontend-prosjektoppsett

Oppsett av nye frontendprosjekter med transpilering og LESS. Stegvis guide til hvordan det kan gjøres.
JavaScript
1
star