github-repository-provider
Version:
repository provider for github
256 lines (162 loc) • 8.6 kB
Markdown
[](https://www.npmjs.com/package/github-repository-provider)
[](https://greenkeeper.io/)
[](https://github.com/arlac77/github-repository-provider)
[](https://github.com/prettier/prettier)
[](http://travis-ci.org/arlac77/github-repository-provider)
[](http://codecov.io/github/arlac77/github-repository-provider?branch=master)
[](https://snyk.io/test/github/arlac77/github-repository-provider)
[](https://github.com/arlac77/github-repository-provider/issues)
[](https://david-dm.org/arlac77/github-repository-provider)
[](https://david-dm.org/arlac77/github-repository-provider#info=devDependencies)
[](http://inch-ci.org/github/arlac77/github-repository-provider)
[](https://npmjs.org/package/github-repository-provider)
[](http://commitizen.github.io/cz-cli/)
# github-repository-provider
repository provider for github
<!-- skip example -->
´´´es6
import { GithubProvider } from 'github-repository-provider';
const config = GithubProvider.optionsFromEnvironment(process.env);
const provider = new GithubProvider(config);
const repository = await provider.repository(`myuser/repo1`);
for async (const entry of repository.entries('\*_/_.md')) {
console.log(entry.name);
}
´´´
# API
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
### Table of Contents
- [GithubProvider](#githubprovider)
- [Parameters](#parameters)
- [Properties](#properties)
- [Examples](#examples)
- [repositories](#repositories)
- [Parameters](#parameters-1)
- [branches](#branches)
- [Parameters](#parameters-2)
- [repositoryBases](#repositorybases)
- [rateLimit](#ratelimit)
- [environmentOptions](#environmentoptions)
- [GithubRepository](#githubrepository)
- [urls](#urls)
- [issuesURL](#issuesurl)
- [homePageURL](#homepageurl)
- [refId](#refid)
- [Parameters](#parameters-3)
- [GithubBranch](#githubbranch)
- [writeEntry](#writeentry)
- [Parameters](#parameters-4)
- [createPullRequest](#createpullrequest)
- [Parameters](#parameters-5)
- [commit](#commit)
- [Parameters](#parameters-6)
- [entry](#entry)
- [Parameters](#parameters-7)
- [maybeEntry](#maybeentry)
- [Parameters](#parameters-8)
- [GithubMixin](#githubmixin)
- [GithubOwner](#githubowner)
- [GithubPullRequest](#githubpullrequest)
- [merge](#merge)
## GithubProvider
**Extends Provider**
<!-- skip-example -->
GitHub provider
Lookup a repository
### Parameters
- `options`
### Properties
- `octokit` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
### Examples
```javascript
import GithubProvider from 'github-repository-provider';
const ghp = new GithubProvider();
const r1 = ghp.repository('git@github.com:arlac77/github-repository-provider.git');
const r2 = ghp.repository('git://github.com/arlac77/github-repository-provider.git');
const r3 = ghp.repository('git+ssh://github.com/arlac77/github-repository-provider.git');
const r4 = ghp.repository('https://github.com/arlac77/github-repository-provider.git#master');
const r5 = ghp.repository('git+https://github.com/arlac77/github-repository-provider.git#master');
const r6 = ghp.repository('arlac77/github-repository-provider');
// different ways to address the same repository
```
### repositories
List repositories of the provider
#### Parameters
- `patterns` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))**
Returns **Iterator<Repository>** all matching repositories of the provider
### branches
List branches of the provider
#### Parameters
- `patterns` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))**
Returns **Iterator<Branch>** all matching repositories of the provider
### repositoryBases
All possible base urls
- git@github.com
- git://github.com
- git+ssh://github.com
- <https://github.com>
- git+<https://github.com>
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** common base urls of all repositories
### rateLimit
Query the current rate limit
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** rate limit (remaining)
### environmentOptions
known environment variables
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** GITHUB_TOKEN api token
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** GH_TOKEN api token
## GithubRepository
**Extends GithubMixin(Repository)**
Repository on GitHub
### urls
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** github https url
### issuesURL
Deliver the url of issue tracking system.
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
### homePageURL
Deliver the url of the repositories home page.
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
### refId
#### Parameters
- `ref` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** sha of the ref
## GithubBranch
**Extends GithubMixin(Branch)**
Branch on GitHub
### writeEntry
writes content into the branch
#### Parameters
- `entry` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<Entry>**
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<Entry>>** written content with sha values set
### createPullRequest
- **See: <https://octokit.github.io/rest.js/#api-PullRequests-create>**
#### Parameters
- `destination`
- `msg`
### commit
#### Parameters
- `message`
- `blobs`
- `options` (optional, default `{}`)
### entry
#### Parameters
- `name`
### maybeEntry
#### Parameters
- `name`
## GithubMixin
common stuff for all github objects
## GithubOwner
**Extends GithubMixin(RepositoryGroup)**
## GithubPullRequest
**Extends GithubMixin(PullRequest)**
Github pull request
### merge
- **See: <https://octokit.github.io/rest.js/#api-PullRequests-merge>**
# install
With [npm](http://npmjs.org) do:
```shell
npm install mock-repository-provider
```
# license
BSD-2-Clause