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 🙏

© 2026 – Pkg Stats / Ryan Hefner

git-history-changelog

v0.1.5

Published

changelog builder framework from git history

Readme

git-history-changelog

Framework for writing changelog generation tools based on git history.

Uses nodegit.

  • Split commit messages to custom categories.
  • By default all stages autosaves in local config (check Store object).
  • You can provide your render and formatting methods.
  • Framework care and track branches.

Please contact me if you use this library in your projects or for support and proposals.

Example result

Branch: refs/heads/master, 2018-1-7 06:00:38  
  
# 0.1.0  
## example  
* package-history added  
## critical  
* Store now handles Git.Repository instance  
* openOrCreate now with repository path argument  
* filterParsedCommits renamed to formatParsedCommits  
## log  
* custom message types now passing through mapping/formatting methods  
## new  
* reduceUnreleasedCommits, groupEveryKeyByKeys methods added  

# 0.0.3  
## log  
* link fixed in readme  
* repo updated  

# 0.0.1  
## dev  
* readme added  
* example with categories  
## bugfix  
* second parse error fixed

Simple use

    1. Pick untracked commits
    1. Format commit messages from '{messageCategory}: message;'
    1. Accept all filtered and mapped commits
    1. Render all categories with default simple markdown renderer
const store = await Store.openOrCreate('./changelog.json', './', 'autosave');

// 1. Pick untracked commits
const parsedCommits = await parseUntrackedCommits(store);

// 2. Format commit messages from '{messageCategory}: message;'
const formatted = await formatParsedCommits(store, parsedCommits, (x) => {
    const messages = x.message.split(';').map(y => y.trim());
    const categorized: ChangelogMessages<string[]> = {};
    const defaultCategory = 'log';

    for (const msg of messages) {
        const [ category, text ] = msg.includes(':') ? msg.split(':') : [ defaultCategory, msg ];
        if (!(category in categorized))
            categorized[category] = [];
        categorized[category].push(text.trim());
    }

    return categorized;
});

// 3. Accept all filtered and mapped commits
const changelog = await toChangelog(store, formatted);

// 4. Render all categories with default simple markdown renderer
const rendered = renderChangelog(store, {
    entries: changelog,
    categories: 'all',
});

fs.writeFile('./changelog.md', rendered, 'utf8', err => {
    if (err) console.error(err);
    else console.log('ok');
});

Result for this repo:

# example  
* package-history added  
# critical  
* Store now handles Git.Repository instance  
* openOrCreate now with repository path argument  
* filterParsedCommits renamed to formatParsedCommits  
# log  
* custom message types now passing through mapping/formatting methods  

Future plans

  • git tags extraction
  • more examples
  • ui

Api

Store

Cache control object. Provide simple methods for saving and loading config.

Fields:

  • filename - absolute path to config
  • data - config, typeof GitHistoryType
  • autosave - flag, if true, framework will save config after every step
  • repo - NodeGit.Repository instance

Methods:

  • static async openOrCreate(filename, repositoryPath, autoSave: false|'autosave'): Store - open or create config and open repository
  • async clearChangelog() - clear changelog (from last step)
  • async save(): true - save config to filename

git

This methods care about git commits, branches etc.

async function parseUntrackedCommits(store: Store, {
    branchName?: string,
    onlyLastCommit?: boolean
}): ParsedHistoryCommit[]

Parse untracked commits with specified options.
Returns new parsed commits.

  • branchName - target git branch, (current by default)
  • onlyLastCommit - track only last commit, skip others (track all by default)
async function fileContentBlob(
    store: Store,
    commitHash: string,
    filePath: string
): NodeGit.Blob

async function fileContentBuffer(
    store: Store,
    commitHash: string,
    filePath: string
): Buffer

async function fileContentString(
    store: Store,
    commitHash: string,
    filePath: string
): string

Read file by it's path from specified commit.

  • filePath - relative to repository root (eg 'package.json')

commits

This methods care about commits filtering and messages extraction.

async function formatParsedCommits(
    store: Store,
    parsedCommits: ParsedHistoryCommit[],
    format: FormatFunc,
    onlyMarked?: false|'onlyMarked'
): UnreleasedChangelogCommit[]

Format & filter commit messages.

  • parsedCommits - commits that will be formatted & filtered.
  • format - filtering and extraction method (check example).
  • onlyMarked: false|'onlyMarked' - pick commits only with commitToUnreleasedChangelog=true (all by default)
async function reduceUnreleasedCommits(
    store: Store,
    unreleasedCommits: UnreleasedChangelogCommit[]
): UnreleasedChangelogCommit[]

Pick last commit for each listed branch,
take all messages to last commit,
group all messages by categories.

For better example, check package-history example.

changelog

This methods care about changelog entries and rendering.

async function toChangelog(
    store: Store,
    commits: UnreleasedChangelogCommit[]
): ChangelogEntry[]

Fixes specified commits as changelog entries.

async function renderChangelog(store: Store, {
    entries: ChangelogEntry[],
    categories: 'all'|string[],
    messageRenderer?: RenderChangelogMessageFunc,
    changelogRenderer?: RenderChangelogFunc
}): string

Renders changelog entries with specified renderers.
By default it uses simple markdown renderers (check source code).

Better use custom rendering method (check package-history example).

utils

function groupByKeys<T>(items: { [keyName: string]: T }[] )
    : { [keyName: string]: T[] };

Group every item's values by it's keys.
Example:

groupByKeys([ { a: 1 }, { a: 2 } ]) -> { a: [ 1, 2 ] }
function groupEveryKeyByKeys<T>(
    item: { [keyA: string]: { [keyB: string]: T }<T>[] }
):
    { [keyA: string]: { [keyB: string]: T[] } }

Example:

groupEveryKeyByKeys({ x: [ { a: 1 }, { a: 2 } ] }) -> { x: { a: [ 1, 2 ] } }