travis-ci-repo-info v1.1.1
Repository Info
Get repository info for one or more repositories.
Installation
$ npm install travis-ci-repo-info
Usage
var repoinfo = require( 'travis-ci-repo-info' );
repoinfo( options, clbk )
Gets repository info for one or more repositories.
var opts = {
'repos': [
'math-io/erf',
'math-io/erfc',
'unknown/repo'
]
};
repoinfo( opts, clbk );
function clbk( error, results ) {
if ( error ) {
throw new Error( error.message );
}
console.dir( results );
/*
{
"meta": {
"total": 3,
"success": 2,
"failure": 1
},
"data": {
"math-io/erf": {...},
"math-io/erfc": {...}
},
"failures": {
"unknown/repo": "Not Found"
}
}
*/
}
The function
accepts the following options
:
- repos:
array
of Github repository slugs (required). Aslug
should obey the format:owner/:repo
. - token: Travis CI access token.
- hostname: endpoint hostname. Default:
'api.travis-ci.org'
.
To authenticate with Travis CI, set the token
option.
var opts = {
'repos': ['kgryte/utils-copy'],
'token': 'tkjorjk34ek3nj4!'
};
repoinfo( opts, clbk );
By default, the function
retrieves repository info from the Travis CI API for open source. To retrieve from a different Travis CI API endpoint, set the hostname
option.
var opts = {
'repos': ['kgryte/utils-deep-get'],
'hostname': 'api.travis-ci.com'
};
repoinfo( opts, clbk );
repoinfo.factory( options, clbk )
Creates a reusable function
.
var opts = {
'repos': [
'math-io/gamma',
'math-io/factorial'
],
'token': 'tkjorjk34ek3nj4!',
'hostname': 'api.travis-ci.org'
};
var get = repoinfo.factory( opts, clbk );
get();
get();
get();
// ...
The factory method accepts the same options
as repoinfo()
.
Notes
- If the module encounters an application-level
error
(e.g., no network connection, etc), thaterror
is returned immediately to the providedcallback
. - If the module encounters a downstream
error
(e.g., timeout, reset connection, etc), thaterror
is included in the returned results under thefailures
field.
Examples
var repoinfo = require( 'travis-ci-repo-info' );
var opts = {
'repos': [
'math-io/erf',
'math-io/erfc',
'math-io/erfinv'
]
};
repoinfo( opts, clbk );
function clbk( error, results ) {
if ( error ) {
throw new Error( error.message );
}
console.dir( results );
}
To run the example code from the top-level application directory,
$ node ./examples/index.js
CLI
Installation
To use the module as a general utility, install the module globally
$ npm install -g travis-ci-repo-info
Usage
Usage: travisrepoinfo [options] slug1 slug2 ...
Options:
-h, --help Print this message.
-V, --version Print the package version.
--hostname host Hostname. Default: api.travis-ci.org.
--token token Travis CI access token.
Notes
If a
slug
is not provided, the implementation will attempt to infer aslug
by executinggit config remote.origin.url
in the current working directory.
In addition to the
token
option, the token may be specified by aTRAVISCI_TOKEN
environment variable. The command-line option always takes precedence.- If a repository's info is successfully resolved, the repository info is written to
stdout
. - If a repository's info cannot be resolved due to a downstream
error
(failure), the repositoryslug
(and its associatederror
) is written tosterr
. - Output order is not guaranteed to match input order.
Examples
Setting the access token using the command-line option:
$ DEBUG=* travisrepoinfo --token <token> math-io/erfinv
# => {...}
Setting the access token using an environment variable:
$ DEBUG=* TRAVISCI_TOKEN=<token> travisrepoinfo math-io/erfinv
# => {...}
For local installations, modify the command to point to the local installation directory; e.g.,
$ DEBUG=* ./node_modules/.bin/travisrepoinfo --token <token> math-io/erfinv
# => {...}
Or, if you have cloned this repository and run npm install
, modify the command to point to the executable; e.g.,
$ DEBUG=* node ./bin/cli --token <token> math-io/erfinv
# => {...}
Tests
Unit
This repository uses tape for unit tests. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ make view-cov
Browser Support
This repository uses Testling for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory:
$ make test-browsers
To view the tests in a local web browser,
$ make view-browser-tests
License
Copyright
Copyright © 2016. Athan Reines.