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

npm-git-library-version

v1.0.0

Published

Script for validating, versioning and tagging an npm release

Downloads

18

Readme

npm-git-library-version

Scripts for versioning a library through npm and git.

This library is targeted at modules which want to check built files into releases without placing them under primary source control. Works with npm and, optionally, bower.

Installation

npm install --save-dev npm-git-library-version

Usage

  1. Place the following commands into your package.json
{
  "files": [
    "if the files key exists in your package.json, it is used as the default list of files to add to git before distribution"
  ],
  "scripts": {
    "preversion": "npm-git-library-version preversion",
    "version": "npm-git-library-version version",
    "postversion": "npm-git-library-version postversion",
    "build": "echo \"Optional build script. Will be run to generate any files required for distribution\" && exit 0",
    "test": "echo \"Required testing script. If no build script is provided, this is expected to build the package before testing\" && exit 0"
  }
}
  1. Ensure you have a .npmrc file alongside your package .json with the following content
git-tag-version=false

Commandline

Usage: npm-git-library-version <command> [options]
                       
Commands:
  preversion   To be run as part of your npm preversion script.
               Verifies git is on the master branch and is clean
  version      To be run as part of your npm version script.
               Builds, Validates, Commits and Tags the package.
  postversion  To be run as part of your npm postversion script.
               Verifies git state and structure then pushes changes and publishes to npm.

Options:
 -h  Show help                                                        [boolean]

preversion

Usage: npm-git-library-version preversion [options]

Options:
  -h               Show help  [boolean]
  -b, --branch     Set the expected branch name  [string] [default: "master"]
  --ignore-branch  Skip branch name verification  [boolean] [default: false]
  --ignore-dirty   Skip clean working folder verification  [boolean] [default: false]

Does the following:

* Verifies head is <branch>
* Verifies working folder is not dirty

Exit code is non-zero on error.

version

Usage: npm-git-library-version version [options] [files...]

Options:
  -h                     Show help  [boolean]
  -b, --branch           Set the expected branch name  [string] [default: "master"]
  --ignore-changes       Ignore any unexpected file changes  [boolean] [default: false]
  --ignore-bower         Do not syncronise/add bower.json  [boolean] [default: false]
  --dont-sync            Do not syncronise version across package files  [boolean] [default: false]
  --dont-commit-version  Do not commit version changes  [boolean] [default: false]
  --dont-push            Do not push changes to origin  [boolean] [default: false]

Notes:
  [files...] defaults to those provided in package.json

Does the following:

* Verify expected (and only expected) files have been modified
* Syncronise package files
* Add package files
* Commit changes
* Build (npm run-script build), if required
* Test (npm test)
* Add distribution files
* Commit distribution files
* Tag as a versioned release
* Publish
* Revert to original branch
* Push to origin with tags

Exit code is non-zero on error.

Workging folder is reset/cleaned on error.

postversion

Usage: npm-git-library-version postversion [options]

Options:
  -h                Show help  [boolean]
  -b, --branch      Set the expected branch name  [string] [default: "master"]
  --ignore-branch   Skip branch name verification  [boolean] [default: false]
  --ignore-dirty    Skip clean working folder verification  [boolean] [default: false]
  --no-git-push     Do not push changes  [boolean] [default: false]
  --no-npm-publish  Do not publish to npm  [boolean] [default: false]

Does the following:

* Verifies head is <branch>
* Verifies working folder is not dirty
* Verifies current version is tagged
* git push / git push --tags
* Checkout version tag
* npm publish
* Revert to branch

Exit code is non-zero on error.