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

gitsome

v0.2.3

Published

Simply retrieve some useful information about your repo

Downloads

25

Readme

Build Status

Gitsome

A small library which helps make decisions based on the existing data in a git repository. It's easy to extract the 'next' version number based on the keywords you provide. It's also simple to do more complex and interesting things given the exposed arrays of commits.

Motivation

I want to have a reliable way of making decisions about versioning projects to remove some of the risk for errors.

Installation

If you want to skip devDependencies, add the '--production' flag to your install command:

$ npm install gitsome --save --production

Code Example

Given this initialization...

const gitSome = require('gitsome')

const options = {
  path: '/Set/to/a/local/git/repo',
  tag: true
}

const gs = gitSome(options)

gs.version() can be used like this:

const keywords = {
  minor: ['merge', 'feature'],
  patch: ['patch', 'fix', 'refactor', 'tweak', 'update']
}

const { current, diff, next } = gs.version(keywords)
// current => 1.0.0 (last tag, or defaults to 1.0.0)
// diff => 0.0.1
// next => 1.0.27

// A diff of 0.1.0 is applied like this
const { current, diff, next } = gs.version(keywords, '0.2.3') // notice also this forced current-version
// current => 0.2.3
// diff => 0.1.0
// next => 0.3.0

gs.version(keywords) Matches commits against the keywords, resulting in a semver 'next' value. several other properties are also returned for the sake of flexibility:

current defaults to: last known tagged version OR 1.0.0 if none is found

diff is the number of commits counted from version.current to now, aggregated down into an incremental format.

next is version.current + version.diff

commits is a copy of the commits which make up the version bump, separated into 'minors' and 'patches'.

gs.Commits is an array of 'commit' objects. It's elements can be fully customized by passing an array of 'git-log format:' formatters into the gitsome options object. By default, it will include every available formatter.

Commit object (example from vuejs/vue)

{
  "commitHash": "b8f730ce989a176437dd3a3c359a469c121e10a7",
  "commitHashShort": "b8f730c",
  "treeHash": "60bae6133e7a2d879a4d34ec94c211cf2ab4d60e",
  "treeHashShort": "60bae61",
  "parentHashes": "c289a7e240e6a0fa22c0fda8bc3ecb1835455acd",
  "parentHashesShort": "c289a7e",
  "authorName": "Anirudh Sanjeev",
  "authorEmail": "[email protected]",
  "authorDate": "Fri Jul 22 22:49:31 2016 +0530",
  "authorDateFull": "Fri, 22 Jul 2016 22:49:31 +0530",
  "authorDateRelative": "3 weeks ago",
  "authorDateTimestamp": "1469207971",
  "authorDateISO": "2016-07-22 22:49:31 +0530",
  "authorDateISOStrict": "2016-07-22T22:49:31+05:30",
  "committerName": "Evan You",
  "committerEmail": "[email protected]",
  "committerDate": "Fri Jul 22 13:19:31 2016 -0400",
  "committerDateFull": "Fri, 22 Jul 2016 13:19:31 -0400",
  "committerDateRelative": "3 weeks ago",
  "committerDateTimestamp": "1469207971",
  "committerDateISO": "2016-07-22 13:19:31 -0400",
  "committerDateISOStrict": "2016-07-22T13:19:31-04:00",
  "refNames": "HEAD -> dev, origin/dev, origin/HEAD",
  "encoding": "",
  "subject": "Handle back-ticks in expression (#3292)",
  "subjectDashed": "Handle-back-ticks-in-expression-3292",
  "body": [
    "Handle back-ticks in expression (#3292)"
  ],
  "commitNotes": "",
  "reflogSector": "",
  "reflogIdentityName": "",
  "reflogIdentityEmail": "",
  "reflogSubject": ""
}

Future

Complete the test suite. Implement new methods to do fun things with the gitsome.commits array. Further explore the application of functional paradigms on the codebase.

License

MIT. See LICENSE in this repo.