Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Organization Repositories

Get meta data for all repositories belonging to an organization.

Usage

var repos = require( '@stdlib/_tools/github/org-repos' );

repos( opts, clbk )

Gets meta data for all repositories belonging to an organization.

var opts = {
    'org': 'stdlib-js'
};

repos( opts, clbk );

function clbk( error, results, info ) {
    // Check for rate limit information...
    if ( info ) {
        console.error( 'Limit: %d', info.limit );
        console.error( 'Remaining: %d', info.remaining );
        console.error( 'Reset: %s', (new Date( info.reset*1000 )).toISOString() );
    }
    if ( error ) {
        throw new Error( error.message );
    }
    console.log( JSON.stringify( results ) );
    // => <repo_data>
}

The function accepts the following options:

  • org: GitHub organization name (required).
  • type: repository type; e.g., forks, public, private, etc. Default: 'all'.
  • token: GitHub access token.
  • useragent: user agent string.

To authenticate with GitHub, set the token option.

var opts = {
    'org': 'stdlib-js',
    'token': 'tkjorjk34ek3nj4!'
};

repos( opts, clbk );

To specify a user agent, set the useragent option.

var opts = {
    'org': 'stdlib-js',
    'useragent': 'hello-github!'
};

repos( opts, clbk );

To return repositories of a particular type, set the type option.

var opts = {
    'org': 'stdlib-js',
    'type': 'forks'
};

repos( opts, clbk );

repos.factory( options, clbk )

Creates a reusable function.

var opts = {
    'org': 'stdlib-js',
    'token': 'tkjorjk34ek3nj4!'
};

var get = repos.factory( opts, clbk );

get();
get();
get();
// ...

The factory method accepts the same options as repos().

Notes

  • Rate limit information includes the following:
    • limit: maximum number of requests a consumer is permitted to make per hour.
    • remaining: number of remaining requests.
    • reset: time at which the current rate limit window resets in UTC seconds.

Examples

var repos = require( '@stdlib/_tools/github/org-repos' );

var opts = {
    'org': 'stdlib-js',
    'useragent': 'beep-boop-bop'
};

repos( opts, clbk );

function clbk( error, results, info ) {
    if ( info ) {
        console.error( info );
    }
    if ( error ) {
        throw new Error( error.message );
    }
    console.log( results );
}

CLI

Usage

Usage: ghorgrepos [options] (--org org | org)

Options:

  -h,  --help               Print this message.
  -V,  --version            Print the package version.
       --token token        GitHub access token.
       --org org            GitHub organization name.
  -ua, --useragent ua       User agent.
       --type type          Repository type; e.g., forks, public, private, etc.

Notes

  • In addition to the token option, the token may also be specified by a GITHUB_TOKEN environment variable. The command-line option always takes precedence.
  • Request resources are written to stdout.
  • Rate limit information is written to stderr.

Examples

Setting the access token using the command-line option:

$ DEBUG=* ghorgrepos --token <token> --org 'stdlib-js'
# => '[{...},{...},...]'

Setting the access token using an environment variable:

$ DEBUG=* GITHUB_TOKEN=<token> ghorgrepos --org 'stdlib-js'
# => '[{...},{...},...]'