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

@stinobe/git-tools

v1.0.2

Published

A tool to help validate commit messages before committing & branch names before pushing them.

Downloads

3

Readme

Git Helpers

A tool to help validate commit messages before committing & branch names before pushing them.
The tool will not run in CI thanks to ci-info

To be used with Husky

Installation

npm install @stinobe/git-tools

Setup

Assuming you haven't installed and/or configured Husky.

Add precommit and prepublish scripts in package.json

# Set script for commits
npm set-script precommit "stinobe-commit-message"

# Set script for branches
npm set-script prepush "stinobe-branch-name"

If Husky not yet installed

# Install Husky
npm install husky --save-dev

# Enable Git hook
npx husky install

# Automatically enable Git hooks after install
npm set-script prepare "husky install"

Add previously created NPM scripts to Husky

# Inform Husky of pre commit script
npx husky add .husky/pre-commit "npm run precommit"

# Inform Husky of pre publish script
npx husky add .husky/pre-publish "npm run prepublish"

Configuration

A default configuration is built in, but you can overwrite those by a .gittoolrc , .gittool.json or by adding a gittool property in the package.json file (in order of hierarchy).

Configuration exists of Commit message configuration and Branch name configuration.

{
  "commits": [],
  "branches": {}
}

All settings are optional

Commit message configuration

Commit settings exists of an array containing differenc configuration for different branch names

| Property | Type | Description | | ---------- | ---------- | -------------------------------------------------------- | | branches | RegExp | Regex to check if rules apply on current branch | | validation | RegExp | Regex where commit message will be tested against | | examples | string[] | Will be printed out in the console when validation fails |

How the default commit message settings look like

{
  "commits": [
    {
      "branches": /.*/,
      "validation": /([Cc]lose[sd]?|[Ff]ix(e[sd])?|[Rr]esolve[sd]?) #[1-9]+\d*/,
      "examples": [
        "Commit message contains one of:",
        "\tclose #[issue-number]",
        "\tcloses #[issue-number]",
        "\tclosed #[issue-number]",
        "\tfix #[issue-number]",
        "\tfixes #[issue-number]",
        "\tfixed #[issue-number]",
        "\tresolve #[issue-number]",
        "\tresolves #[issue-number]",
        "\tresolved #[issue-number]"
      ]
    }
  ],
  "branches": {}
}

branches property can be an empty string or be left out but will cause a log in the output.

Branch name configuration

| Property | Type | Description | | ---------- | ---------- | ---------------------------------------------------------------- | | validation | RegExp[] | List of regular expressions with allowed branch names | | examples | string[] | List of example branch names, will be logged if validation fails |

How the default branch name settings look like

{
  "commit": [],
  "branches": {
    "validation": [
      /^(feature|bug|docs|hotfix)\/(\d+)-[a-z-]+/,
      /^wip\/[a-z1-9]+[a-z0-9]*/
    ],
    "examples": [
      "feature/[issue_number]-[subject]",
      "bug/[issue_number]-[subject]",
      "docs/[issue_number]-[subject]",
      "hotfix/[issue_number]-[subject]"
    ]
  }
}