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

buenos-commit-msg

v1.0.2

Published

Commit message validator

Downloads

2

Readme

buenos-commit-msg

Validates your commit message format to match the format:

<type>(<scope>): <subject> <issue>

Note that scope is optional, and the issues (if provided) should match a JIRA format (i.e. ISS-123).

Usage

Simply install as a dev dependency:

$ npm install --save-dev buenos-commit-msg

and create a hook on commit-msg (i.e. .git/hooks/commit-msg):
note: make sure the file is executable ($ chmod +x path/to/file)

#!/usr/bin/env node

try {
    require('buenos-commit-msg').hook();
} catch (e) {
    console.log(e.message);
    process.exit(1);
}

See https://www.npmjs.com/package/git-hooks for a cool implementation of git-hooks.

Configuration

It's possible to configure the allowed type and scope properties by creating a file called .commit-msg.json in the root of your project:

{
  "extend": true,
  "types": [
    "customType1",
    "customType2"
  ],
  "scopes": [
    "customScope1",
    "customScope2"
  ],
  "errors": {
    "TYPE_AND_SUBJECT_REQUIRED": "Type and subject is required"
  }
}

extend

When false, the types and scopes will be overwritten with your values. When true or unspecified, the types and scopes you've defined will be added to the default values.

types

A case-sensitive array of allowed types. Default values are bugfix, build, ci, docs, feature, format, merge, perf, refactor, style, test, version.

Set to an empty array to allow any type.

scopes

A case-sensitive array of allowed scopes. By default all values are allowed.

Set to an empty array to allow any scope.

errors

Allows customizing the error messages.

The following errors are specified and can be overwritten:

{
    TYPE_AND_SUBJECT_REQUIRED: 'At least a type and subject is required',
    TYPE_SCOPE_MALFORMED: 'Type and scope should be formatted as \'type(scope):\'',
    REQUIRE_SPACE_AFTER_COLON: 'Add a space before subject',
    NO_SPACE_BEFORE_COLON: 'No space before the colon',
    SUBJECT_ISSUE_MALFORMED: 'Subject and issue should be formatted as \'some subject ISS-123\'',
    JIRA_ISSUE_CAPITALIZED: 'JIRA reference should be in full caps',
    SUBJECT_REQUIRED: 'Subject is required, even if a JIRA issue is provided',
    SUBJECT_DONT_END_ON_CHARS: 'Subject should not end on dot (.) or colon (:)',
    TYPE_INVALID: `Type should be one of: %types%`,
    SCOPE_INVALID:`Type should be one of: %scopes%`,
    SCOPE_EMPTY: 'Scope should have a value or be left out entirely'
}

Note that %types% and %scopes% will be replaced with a joined value of types and scopes for errors TYPE_INVALID and SCOPE_INVALID.

Also note that any errors that you don't specify will always be filled from the default config.

API

hook()

Runs the validator, uses the git commit message as provided by git and uses a config file if it finds one, or falls back to the default config.

This is probably what you want for your git hook.

getCommitMessage()

Retrieves the commit message as provided by git. Can be useful if you want a fancier git hook.

configure(config = undefined)

Creates and returns a configuration object that can be used in validate().

When config argument is not provided it will use the default config combined with a custom config file if it finds one.

When config is an object it will use that.

validate(commitMessage, config = undefined)

Validates the commitMessage using the provided configuration object. If no config is specified the default config will be used.

It will return the validation object when the message was successfully validated, or will throw an error when a validation error has occured.


Derived from the Angular Commit Messages Guidelines