Code Monkey home page Code Monkey logo

npm-fetch-changelog's Introduction

npm-fetch-changelog

CircleCI Coverage Status semantic-release Commitizen friendly npm version

fetch the changelog for an npm package from GitHub

How it works

Right now only packages hosted on GitHub are supported. npm-fetch-changelog will get the package info and repository URL from npm, then try to fetch the GitHub release for each relevant version tag. If no GitHub release is found it will fall back to trying to parse the package's CHANGELOG.md or changelog.md. GitHub releases are way more reliable for this purpose though, so please use them!

Caveats

npm-fetch-changelog inevitably fails to find changelog entries for some packages/releases because many maintainers are not very detail-oriented about it (and don't choose to use excellent tools that would do the work for them, like semantic-release).

However, I've also seen cases where some versions were never published to npm (for instance, at the time of writing, superagent version 5.0.0 was never published to npm, yet it does have a changelog entry). npm-fetch-changelog currently only displays changelog entries for published versions.

API Tokens

GitHub heavily rate limits public API requests, but allows more throughput for authenticated requests. If you set the GH_TOKEN environment variable to a personal access token, npm-fetch-changelog will use it when requesting GitHub releases. Otherwise npm-fetch-changelog will try to get it from gh auth token (gh is the GitHub CLI).

npm-fetch-changelog will also use the NPM_TOKEN environment variable or try to get the npm token from your ~/.npmrc, so that it can get information for private packages you request.

You can also store one or both of these tokesn in ~/.config/npm-fetch-changelog.json:

{
  "githubToken": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "npmToken": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

CLI

npm i -g npm-fetch-changelog
npm-fetch-changelog <package name>[@<range>]
what-broke <package name>[@<range>]

Prints changelog entries fetched from GitHub for each version released on npm in the given range.

what-broke is just a shortcut for npm-fetch-changelog --no-minor.

Options:

-r, --range

semver version range to get changelog entries for, e.g. ^7.0.0 (defaults to > the version installed in the working directory, if it exists)

You can also pass the range together with the package name (you might need to quote it):

npm-fetch-changelog 'foo@>=2'

--json

output JSON instead of Markdown

--major

exclude minor and patch versions

--minor

exclude patch versions

--pre

include prerelease versions

Node.js API

(the CLI just uses this under the hood)

import { fetchChangelog } from 'npm-fetch-changelog'
async function fetchChangelog(
  package: string,
  options?: {
    include?:
      | (
          | ((version: string) => boolean)
          | {
              range?: ?string
              prerelease?: ?boolean
              minor?: ?boolean
              patch?: ?boolean
            }
        )
      | null
  }
): Promise<
  Record<
    string,
    {
      version: string
      header: string
      body?: string
      date?: Date
      error?: Error
    }
  >
>

npm-fetch-changelog's People

Contributors

greenkeeper[bot] avatar jedwards1211 avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

minigod kzkn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.