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

ghrepos

v2.1.0

Published

Interact with the GitHub repos API

Downloads

44,093

Readme

ghrepos

Build Status

A node library to interact with the GitHub repos API

NPM

See also:

  • https://github.com/rvagg/ghissues
  • https://github.com/rvagg/ghusers
  • https://github.com/rvagg/ghteams
  • https://github.com/rvagg/ghauth

API

listUser(auth[, user][, options], callback)

List all repos for a user. If user and options are omitted the current user is assumed.

List all repos for user 'rvagg':

const ghrepos     = require('ghrepos')
    , authOptions = { user: 'rvagg', token: '24d5dee258c64aef38a66c0c5eca459c379901c2' }

ghrepos.listUser(authOptions, 'rvagg', function (err, repolist) {
  console.log(reposlist)
})

listOrg(auth, org[, options], callback)

List all repos for a organisation. If org and options are omitted the current org is assumed.

List all repos for org 'nodejs':

const ghrepos     = require('ghrepos')
    , authOptions = { user: 'rvagg', token: '24d5dee258c64aef38a66c0c5eca459c379901c2' }

ghrepos.listOrg(authOptions, 'nodejs', function (err, repolist) {
  console.log(reposlist)
})

listRefs(auth, org, repo[, options], callback)

Get git ref data for all refs in a repo.

Get all ref data for nodejs/node repo:

ghrepos.listRefs(authOptions, 'nodejs', 'node', function (err, refData) {
  // data containing ref information including sha and github url
  console.log(refData)
})

listBranches(auth, org, repo[, options], callback)

List git branches for a repo.

Get all branches for nodejs/node repo:

ghrepos.listBranches(authOptions, 'nodejs', 'node', function (err, refData) {
  // data containing branch information including sha and github API url
  console.log(refData)
})

listCommits(auth, org, repo[, options], callback)

List git commits for a repo.

Get all commits for nodejs/node repo:

ghrepos.listCommits(authOptions, 'nodejs', 'node', function (err, refData) {
  // data containing commit information including sha and github API url
  console.log(refData)
})

listTags(auth, org, repo[, options], callback)

List git tags for a repo.

Get all tag for nodejs/node repo:

ghrepos.listTags(authOptions, 'nodejs', 'node', function (err, refData) {
  // data containing tag information including sha and github API url
  console.log(refData)
})

getRef(auth, org, repo, ref[, options], callback)

Get git ref data for a particular ref string.

Get git ref data for v1.x branch in nodejs/node repo:

ghrepos.getRef(authOptions, 'nodejs', 'node', 'heads/v1.x', function (err, refData) {
  // data containing ref information including sha and github url
  console.log(refData)
})

getBranch(auth, org, repo, branch[, options], callback)

Get git branch data for a given branch name

Get git branch data for v1.x branch in nodejs/node repo:

ghrepos.getBranch(authOptions, 'nodejs', 'node', 'v1.x', function (err, refData) {
  // data containing branch information including sha and github API url
  console.log(refData)
})

getCommit(auth, org, repo, sha1[, options], callback)

Get git commit data for a given sha1

Get git commit data for sha1 75318e46b in nodejs/node repo:

ghrepos.getCommit(authOptions, 'nodejs', 'node', '75318e46b', function (err, refData) {
  // data containing commit information including sha and github API url
  console.log(refData)
})

getCommitComments(auth, org, repo, sha1[, options], callback)

Get git commit comments data for a given sha1

Get git commit comments data for sha1 75318e46b in nodejs/node repo:

ghrepos.getCommitComments(authOptions, 'nodejs', 'node', '75318e46b', function (err, comments) {
  // array containing commit comments information
  console.log(JSON.stringify(comments.map(function (i) {
    return { user: i.user.login, body: i.body }
  }), null, 2))
})

Yields:

[
  {
    "user": "Trott",
    "body": "@cjihrig There's no PR-URL on this commit message. (`core-validate-commit` FTW as usual!)"
  },
  {
    "user": "mscdex",
    "body": "PR-URL is: https://github.com/nodejs/node/pull/15745"
  }
]

createLister(type)

Creates a function that lists different sub types related to the '/repos' api, e.g. list 'issues', 'pulls' or 'releases'. The function returned has the signature: function list (auth, org, repo, options, callback).

More methods coming .. as I need them or as you PR them in.

The auth data is compatible with ghauth so you can just connect them together to make a simple command-line application:

const ghauth     = require('ghauth')
    , ghrepos    = require('ghrepos')
    , authOptions = {
          configName : 'lister'
        , scopes     : [ 'user' ]
      }

ghauth(authOptions, function (err, authData) {
  ghrepos.listUser(authData, 'rvagg', function (err, list) {
    console.log('Repos for rvagg:')
    console.log(util.inspect(list.map(function (i) { return {
        name: i.name
      , desc: i.description
      , fork: i.fork
    }})))
  })
})

License

ghrepos is Copyright (c) 2015 Rod Vagg @rvagg and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.