repository-provider
abstract interface to git repository providers like github bitbucket
Example
import { GithubProvider } from 'repository-provider';
const provider = new GithubProvider({ token: 'xxx' });
const repository = await provider.repository('myuser/myrepo');
const branch = await repository.branch('master');
const files = await branch.list();
Derived Providers
list by repository-provider keyword
API
Table of Contents
Provider
Extends Owner
Base repository provider acts as a source of repositories
Parameters
Properties
repositoryGroup
Lookup a repository group
Parameters
Returns Promise<RepositoryGroup>
createRepositoryGroup
Create a new repository group
Parameters
Returns Promise<RepositoryGroup>
repository
Lookup a repository in the provider and all of its repository groups
Parameters
Returns Promise<Repository>
repositoryGroupClass
Returns Class repository group class used by the Provider
pullRequestClass
Returns Class pull request class used by the Provider
rateLimitReached
Is our rate limit reached.
By default we have no rate limit
Returns boolean always false
name
Deliver the provider name
Returns string class name by default
provider
we are our own provider
Returns Provider this
defaultOptions
Default configuration options
Returns Object
optionsFromEnvironment
Extract options suitable for the constructor
form the given set of environment variables
Parameters
Returns Object undefined if no suitable environment variables have been found
options
Pepare configuration by mixing together defaultOptions with actual options
Parameters
Returns Object combined options
Branch
Abstract branch
Parameters
Properties
initialize
called once after constructing
Returns Promise
provider
The provider we live in
Returns Provider
owner
Branch owner
By default we provide the repository owner
Returns string
project
Branch project
By default we provide the repository project
Returns string
fullName
Repository and branch name combined
Returns string 'repo#branch'
fullCondensedName
Repository and branch name combined.
But skipping the branch name if it is the default branch
Returns string 'repo#branch'
url
Deliver repository and branch url combined
Returns string 'repoUrl#branch'
issuesURL
Url of issue tracking system.
Returns string as provided from the repository
homePageURL
Url of home page.
Returns string as provided from the repository
isDefault
Are we the default branch
Returns boolean true if name is 'master'
delete
Delete the branch from the Repository.
Returns Promise<undefined>
content
Deliver file content
Parameters
Returns Promise<Content> content of a given file
commit
Commit files
Parameters
Returns Promise
createPullRequest
Create a pull request
Parameters
Returns Promise<PullRequest>
list
File list
Returns Array<string> all file names in the branch
rateLimitReached
Value delivered from the provider
Returns boolean providers rateLimitReached
rateLimitReached
forward to the Provider
Parameters
Owner
Collection of repositories
Properties
repositoryClass
Returns Class repository class used by the Provider
branchClass
Returns Class branch class used by the Provider
contentClass
Returns Class content class used by the Provider
deleteRepository
Delete a repository
Parameters
Returns Promise<undefined>
repository
Lookup a repository
Parameters
Returns Promise<Repository>
createRepository
Create a new repository
Parameters
Returns Promise<Repository>
branch
Lookup a branch
First lookup repository then the branch
If no branch was specified then the default branch will be delivered.
Parameters
name
string with optional branch name as '#myBranchName'
Returns Promise<Branch>
initialize
Provider initialization
will be called once before content addressing method is called
Returns Promise<undefined>
type
Deliver the repository type
Returns string 'git'
Repository
Abstract repository
Parameters
Properties
provider
the owners provider
Returns Provider
initialize
Called one after constructing
Returns Promise<undefined>
content
Lookup content form the default branch
Branch#content
Parameters
Returns Content
urls
urls to access the repo
Returns Array<string>
url
preffered url to access the repo
Returns string
issuesURL
the url of issue tracking system.
Returns string
homePageURL
the url of home page.
Returns string
owner
Repository owner
Default implementation delivers undefined
Returns string undefined
project
Repository project
Default implementation delivers undefined
Returns string undefined
condensedName
Name without project / owner
Returns string name
branch
Lookup branch by name
Parameters
Returns Promise<Branch>
defaultBranch
Lookup the default branch
Returns Promise<Branch> 'master' branch
branches
Returns Promise<Map> of all branches
createBranch
Create a new Branch by cloning a given source branch
Parameters
Returns Promise<Branch> newly created branch
deleteBranch
Delete a Branch
Parameters
Returns Promise<undefined>
addBranch
Add a branch
Parameters
Returns Promise<undefined>
delete
Delete the repository from the Provider.
Provider#deleteRepository
Returns Promise<undefined>
pullRequests
Deliver all PullRequests
Returns Promise<Map> of all pull requests
pullRequest
The @{link PullRequest} for a given name
Parameters
Returns Promise<PullRequest>
addPullRequest
Add a pull request
Parameters
Returns Promise
deletePullRequest
Delete a PullRequest
Parameters
Returns Promise
type
Returns string providers type
rateLimitReached
Value delivered from the provider
Returns boolean providers rateLimitReached
rateLimitReached
forward to the Provider
Parameters
PullRequest
Abstract pull request
Repository#addPullRequest
Parameters
repository
Repositoyname
stringoptions
Object (optional, default {}
)
Properties
provider
Returns Provider
delete
Delete the pull request from the Repository.
Returns Promise
merge
Merge the pull request
decline
Decline the pull request
RepositoryGroup
Extends Owner
Abstract repository as a collection
Parameters
Properties
Content
Representation of one file or directory entry
Parameters
path
string file name inside of the repositorycontent
(string | Buffer | Stream) (optional, default undefined
)type
string type of the content (optional, default 'blob'
)mode
string file permissions (optional, default '100644'
)
Properties
install
With npm do:
npm install repository-provider
license
BSD-2-Clause