npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-versioner

v0.1.10

Published

Grunt plugin for versioning, building, tagging your Git project and publishing to NPM.

Downloads

47

Readme

grunt-versioner

Grunt plugin for versioning, building and tagging your Git project.

Current Version: 0.1.10

Circle CI

Getting Started

This plugin requires Grunt ~0.4.2

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-versioner --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-versioner');

The "versioner" task

Overview

In your project's Gruntfile, add a section named versioner to the data object passed into grunt.initConfig().

This shows all of the configuration options and their default values. Individual settings can be given for the different versioning types patch, minor, major and git. The files section is where to put the files you would like the script to update. Most users will only need to create a default task.

grunt.initConfig({
  versioner: {
    options: {
      bump: true,
      file: 'package.json',
      gitAdd: true,
      gitCommit: true,
      gitPush: true,
      gitTag: true,
      gitPushTag: true,
      gitDescribeOptions: '--tags --always --dirty=-d',
      tagPrefix: 'v',
      commitMessagePrefix: 'Release: ',
      tagMessagePrefix: 'Version: ',
      readmeText: 'Current Version:',
      pushTo: 'origin',
      branch: 'master',
      npm: true,
      mode: 'production',
      configs: []
    },
    default {
      files: {
        './package.json': ['./package.json'],
        './bower.json': ['./bower.json'],
        './README.md': ['./README.md'],
        './src/lib/src_file.js': ['./src/lib/src_file.js']
      }
    },
    patch: {
      options: {
        file: './VERSION'
      },
      src: ['./package.json', './bower.json', './README.md']
    }
  },
});

When including a README.md file to update the script looks for a line like the one below to update the both the version link and url. This way your README.md file will maintain a link to your latests release.

Current Version: **[1.0.2](https://github.com/foobar/releases/tag/v1.0.2)**

Additionally any files with YUIdoc style version tags * @version 1.0.2 will be updated to the latest version as well if the files are included in the files configuration.

Usage Examples

$ grunt versioner:default
>> Version bumped to 0.0.2
>> Committed as "Release v0.0.2"
>> Tagged as "v0.0.2"
>> Pushed to origin

$ grunt versioner:default:bump
>> Version bumped to 0.0.3
>> Committed as "Release v0.0.3"
>> Tagged as "v0.0.3"
>> Pushed to origin

$ grunt versioner:default:minor
>> Version bumped to 0.1.0
>> Committed as "Release v0.1.0"
>> Tagged as "v0.1.0"
>> Pushed to origin

$ grunt versioner:default:major
>> Version bumped to 1.0.0
>> Committed as "Release v1.0.0"
>> Tagged as "v1.0.0"
>> Pushed to origin

$ grunt versioner:default:git
>> Version bumped to 1.0.0-1-ge96c
>> Committed as "Release v1.0.0-1-ge96c"
>> Tagged as "v1.0.0-1-ge96c"
>> Pushed to origin

$ grunt versioner:default:gitrev
>> Version bumped to ca40b1c
>> Committed as "Release ca40b1c"
>> Tagged as "ca40b1c"
>> Pushed to origin

If you want to jump to an exact version, you can use the setversion tag in the command line.

$ grunt versioner --setVersion=2.0.1
>> Version bumped to 2.0.1
>> Committed as "Release v2.0.1"
>> Tagged as "v2.0.1"
>> Pushed to origin

If you need to run another task between bumping the version and commiting you can use the tasks versioner:bumpOnly, versioner:commitOnly, and versioner:npmOnly

$ grunt versioner:bumpOnly:default:minor
$ grunt uglify
$ grunt versioner:commitOnly:default
$ grunt versioner:npmOnly:default

To publish your project to NPM and to set a tag. Setting an npmTag is not required. A tag name should not be SemVer range.

$ grunt versioner:npmOnly:default --npmTag v1.2-latest

Options

options.bump - When grunt versioner is run the files will be bumped.

Type: Boolean Default value: true

options.file - File that is read to current the current Version from. This should either be a json file in the format of package.json or bower.json with the version property or it can be VERSION file that only contains the version.

Type: String Default value: package.json

options.gitAdd - The files that are bumped will be add to the git index.

Type: Boolean Default value: true

options.gitCommit - The files will added to the git index will be committed.

Type: Boolean Default value: true

options.gitPush - The changes commited will be pushed to git origin.

Type: Boolean Default value: true

options.gitTag - Create tag of the latest version.

Type: Boolean Default value: true

options.pushTo - Remote repo to push to

Type: String Default value: origin

options.gitPushTag - The tag created for the new version will be pushed to the git origin.

Type: Boolean Default value: true

options.branch - The git branch to push the changes.

Type: String Default value: master

options.npm - Publish to NPM.

Type: boolean Default value: true

options.gitDescribeOptions - Options passed to git describe when using to create a version tag.

Type: String Default: gitDescribeOptions: '--tags --always --dirty=-d'

options.readmeText - If updating version information in your README.md file. This is the text before the version information.

Type: String Default value Current Version:

options.tagPrefix - Prefix text before your git tag.

Type: String Default value v

options.commitMessagePrefix - Prefix text before your commit message. The default full message is Release: 0.2.2.

Type: String Default value Release:

options.tagMessagePrefix - Prefix for the git annotayted tags. The default full message will be Version: 0.2.2.

Type: String Default value Message:

options.mode - Mode that it should run in. The accepted values are test and production. The should only be switched to test when running the tests. This prints out what commands git would have run in produciton.

Type: Array Default value []:

options.configs - When you load package.json into a grunt config variable such as pkg that needs to have the version updated as the grunt process runs. Adding any vars here such as pkg will update any version keys on those config properties so that the correct version is used when using pkg.version in your tasks.

versioner: {
  options: {
    bump: true,
    configs: ['pkg']
  }
}

Contributing

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