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

@lcluber/gitbranchvalidator

v1.4.1

Published

Git branch name validator on Git hooks for clean workflow

Downloads

421

Readme

This project has been transferred to DWTechs.

Please update your project dependencies to the latest version on the new repository.

License: MIT npm version Jest:coverage

Synopsis

GitBranchValidator is an open source git branch name validator library.

Motivation

The goal of this library is to provide an easy way to check if the current branch name is valid before pushing it to the remote.

It's a good way to help developers keep their branch names clean on the repository and facilitate the workflow of a project with strict naming rules.

The default pattern follows the principles described here.

You can also set your own rules using a custom pattern.

Installation

npm

$ npm i @lcluber/gitbranchvalidator -g

Yarn

$ yarn add @lcluber/gitbranchvalidator -g

Locally

Alternatively, if you are planning to use GitBranchValidator within your npm package only or with npx you can install it as a devDependency in your project.

$ npm i @lcluber/gitbranchvalidator --save-dev
$ yarn add @lcluber/gitbranchvalidator --dev

Usage

Command line

$ cd <git-project>
$ gbvalidator

Alternatively if you did not install GitBranchValidator globally you can use npx.

$ npx gbvalidator

Or as an npm script in your package.

{
  "scripts": {
    "commit": "gbvalidator"
  }
}

Pattern

  • Default : /^(feature|bugfix|release|hotfix|refactor|test|doc|build)/([a-z0-9_#-./]){3,40}$/

The default pattern follows the principles described here.

You can use your own custom pattern by adding an optional regexp :

$ cd <git-project>
$ gbvalidator --pattern "^(feat|fix)\/([a-z0-9_#-\.\/]){3,50}$"

If you use this option for a npm command in package.json, you may need to properly escape your regex in order to get a valid JSON file.

Message

You can customize the end of the error message :

$ cd <git-project>
$ gbvalidator --message "You can learn more about branch name conventions of this project on https://dwtechs.github.io/efficient-git/branch/"

Workflow integration

Validate branch name on pre-commit with Husky :

$ npm install husky --save-dev
{
  "husky": {
    "hooks": {
      "pre-commit": "gbvalidator"
    }
  }
}

options

| Option | Alias | Type | description | | :-------- | :---: | :-----: | ------------------------------------------------------: | | --pattern | -p | string | to use a custom regex | | --message | -m | string | to add a custom message at the end of the error message | | --help | -h | boolean | to learn about library usage |

Contributors

GitBranchValidator is still in development and I would be glad to get all the help you can provide for this project. To contribute please read NOTICE.md for detailed installation guide.

License

MIT

Stack

| Purpose | Choice | Motivation | | :-------------- | :----------------------------------: | ---------------------------------------------------------: | | repository | Github | hosting for software development version control using Git | | package manager | npm | default node.js package manager | | unit testing | Jest | delightful testing with a focus on simplicity |