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

generate-release

v1.1.1

Published

Generate a release using git-glow

Downloads

2,410

Readme

node-generate-release

Generate a release for a project following semver using nodejs and gitflow or git-stream

Generate Release on Travis CI Coverage Status Generate Release on NPM Generate Release uses the MIT

Current Version: 1.1.1

Requires NodeJS v4.0.0 or greater

Generate Release Example

Usage

You can either install generate-release globally or for a single project

Globally

Install package

npm install -g generate-release

Navigate to your project and execute generate-release

Locally

cd your/project
npm install --save-dev generate-release

Then add the following to your package.json file:

{
    "scripts": {
        "release": "generate-release"
    }
}

Then you can run npm run-script release in order to generate a release.

Important notes for gitflow OSX

Git-flow from nvie is broken on OSX, and generate-release will not work. Please use the updated and actively maintained version from petervanderdoes, https://github.com/petervanderdoes/gitflow-avh. Please follow the OSX Install Guide

What does it do?

This is the default process.

  1. Verify the working directory is clean
  2. Reads git-flow settings from repo config file
  3. Reads Current version from package.json file and generates the new version
  4. Fetches from remote
  5. Rebases remote/develop into develop
  6. Resets master to remote/master
  7. Starts a gitflow or git-stream release named the new version number
  8. Changes the version number in package.json and any files in files_to_version
  9. Runs all pre_commit_commands
  10. Commits the changes to the package.json and any file in files_to_version and files_to_commit
    1. This will also commit any file deletions which may have occurred during the pre_commit_commands
  11. Runs all post_commit_commands
  12. Runs the gitflow or git-stream finish release command
  13. Pushes master, develop, and tags to remote
  14. Runs all the post_complete_commands

If any of the steps aside from the post_complete_commands step fail, the entire release is canceled and everything is reset.

All commands are run in either sh or cmd.exe. If sh is available, even on windows, it will use that first.

Options

CLI

run generate-release --help to see this as well.

-p, --package   FILE            Path to package.json file. Default: ./package.json
-c, --current-version VERSION   Current Version. Default: read from package.json
-v, --next-version VERSION      Next Version. Default: automatically bumps
-t, --release-type TYPE         Release Type: patch, minor, major. Ignored when next-version is given. Default: prompt, if next-version is undefined
-n, --no-confirm                Do not ask for confirmation. Default: prompt for confirmation
-l, --skip-git-pull             Do not pull from origin and rebase master and dev. Default: Do pull
-s, --skip-git-push             Do not push to origin when complete. Default: Do push
-f, --skip-git-flow-finish,     Do not finish git-flow release. Default: Do finish
    --skip-finish
-d, --release-file FILE         Path to your .release.json file. Default: ./.release.json
-o, --remote REMOTE             Change the remote. Default: origin
-q, --quiet                     Less output. Default: Do show output
-m, release-message [MESSAGE]   Set a release message. If no message given, prompt for one. Will replace
                                "{version}" with the next version. Default: Release {version}

Release File

By default, the following options can be set in a .release.json file. The following is an example with all default options set.

  {
      "package_file_location": "./package.json",
      "no_confirm": false,
      "skip_git_pull": false,
      "skip_git_push": false,
      "skip_finish": false,
      "release_message": true,
      "remote": "origin",
      "pre_commit_commands": [],
      "post_commit_commands": [],
      "post_complete_commands": [],
      "files_to_commit": [],
      "files_to_version": ["README.md"]
  }
  

The files_to_commit and files_to_version use node-glob. See the documentation located there on how to format those options.

If release_message is true, then you will be prompted to write a release message via your editor of choice.

package.json

If you are using this for an NPM package, you can include all the above options in your package.json instead of a dedicated file.

Place all your configuration options in config : generateRelease.

{
    ...
    "config": {
        "generateRelease": {
            "no_confirm": false,
            "remote": "origin"
        }
    },
    ...
}

Option Precedence

Precedence is determined in the following order:

  • CLI Argument
  • package.json file
  • .release.json file

Building Assets, Running Tests, and Publishing Package

If you wish to build assets, run test, and/or publish your project automatically when the release is being generated you can use the example .release.json file below. The following assumptions are made:

  • You have a script in your package file to build your assets named build-assets
  • All your built assets are saved to ./build
  • You run your tests via the npm test command
  • You publish your package via the npm publish command

.release.json

{
    "pre_commit_commands": [
        "npm run-script build-assets"
    ],
    "post_commit_commands": [
        "npm test"
    ],
    "post_complete_commands": [
        "npm publish"
    ],
    "files_to_commit": [
        "./build/**/*"
    ]
}

Usage on a Non NPM Based Repo

It's quite simple to use this on a non NPM based repo. The only npm specific aspect baked into Generate Release is the usage of the package.json file. In fact, you are able to use any json file which maintains a version property. If you are working on a PHP project which uses Composer, the composer.json already has the required property. Either call generate-release with -p composer.json or set the package_file_location property of your .release.json file.

If your project does not already contain a json file which maintains a version, you just use the .release.json file! Just put a version property in the file and set package_file_location to ".release.json".

Roadmap

  • Write tests Partial
  • Code coverage for tests Partial
  • ~~Change remote (not origin)~~
  • ~~Allow for custom hook (like running gulp or grunt during release to prepare assets)~~
  • ~~Ability to define arbitrary files to replace version in (like source code files, other MD's, etc)~~
  • ~~Use and parse a .release file to parse defaults (instead of using cli switches)~~
  • ~~Custom release message~~
  • ~~Read git-flow configuration from .git folder~~