repository-provider
v36.0.8
Published
abstract interface to git repository providers like github, bitbucket and gitlab
Readme
repository-provider
abstract interface to git repository providers like github, bitbucket, gitlab, gitea, ...
see list of avaliable implementations below
Example
import { Provider } from 'repository-provider';
const provider = new Provider({ /* access options as hosts and credentials */ });
const branch = await provider.branch('myuser/myrepo#myBranch');
for await (const entry of branch.entries('**/*.md')) {
console.log(entry.name);
}
const readme = await branch.entry('README.md');
console.log(await readme.string);Derived Providers
list by repository-provider keyword
API
Table of Contents
- Application
- BaseObject
- BaseProvider
- BaseProvider
- Parameters
- Properties
- equals
- repositoryBases
- supportsBase
- normalizeRepositoryName
- normalizeGroupName
- areRepositoryNamesCaseSensitive
- areGroupNamesCaseSensitive
- parseName
- createRepository
- list
- projects
- milestones
- repositories
- branches
- tags
- hooks
- pullRequests
- name
- provider
- toJSON
- repositoryGroupClassFor
- instanceIdentifier
- initialize
- DecodedRepositoryName
- MessageDestination
- name
- messageDestination
- parsedName
- Branch
- CommitResult
- Commit
- Hook
- Issue
- Milestone
- MultiGroupProvider
- NamedObject
- OwnedObject
- OwnedObject
- Project
- PullRequest
- state
- locked
- merged
- draft
- Ref
- Ref
- isProtected
- RepositoryGroup
- type
- homePageURL
- RepositoryOwner
- Repository
- Parameters
- Properties
- slug
- url
- entry
- entries
- maybeEntry
- commits
- cloneURL
- issuesURL
- homePageURL
- isArchived
- isLocked
- delete
- defaultBranch
- branch
- hasBranches
- branches
- createBranch
- addBranch
- deleteBranch
- tag
- tags
- addTag
- _addTag
- createPullRequest
- addPullRequest
- _addPullRequest
- pullRequests
- pullRequest
- deletePullRequest
- addHook
- _addHook
- createHook
- hooks
- hook
- _addMilestone
- milestone
- _addProject
- project
- _addApplication
- application
- type
- refId
- attributes
- defaultBranchName
- branches
- tags
- projects
- applications
- milestones
- pullRequests
- hooks
- Review
- SingleGroupProvider
- Tag
- asArray
- stripBaseName
- stripBaseNames
- generateBranchName
Application
Extends OwnedObject
BaseObject
Creates an instance of BaseObject.
Parameters
Properties
id
Type: string
description
Type: string
updateAttributes
Takes values from options.
Parameters
optionsObject?
update
Save object attributes in the backing store.
toString
Returns string fullName
fullName
Complete name in the hierachy.
Returns string
isWritable
By default cannot be written to.
Returns boolean false
isDisabled
By default we are not disabled.
Returns boolean false
isTemplate
By default we are not a template.
Returns boolean false
equals
Check for equality
Parameters
other(BaseObject | undefined)
Returns boolean true if other is present
type
Returns string type we represent
collectionName
Tag -> tags
Repository -> repositoriesReturns string name of the collection holding us in the owner
attributes
Attributes definitions.
Returns Object
writableAttributes
User modifyable attributes.
Returns Object writable attributes
BaseProvider
Extends BaseObject
equals
Parameters
otherany
Returns boolean true if other provider is the same as the receiver
repositoryBases
All supported base urls. For github something like:
- [email protected]
- git://github.com
- git+ssh://github.com
- https://github.com
- git+https://github.com By default we provide provider name with ':'.
Returns Array<string> common base urls of all repositories
supportsBase
Does the provider support the base name.
Parameters
basestring? to be checked
Returns boolean true if base is supported or base is undefined
normalizeRepositoryName
Bring a repository name into its normal form by removing any clutter. Like .git suffix or #branch names.
Parameters
Returns (string | undefined) normalized name
normalizeGroupName
Bring a group name into its normal form by removing any clutter. Like .git suffix or #branch names.
Parameters
Returns (string | undefined) normalized name
areRepositoryNamesCaseSensitive
Are repository names case sensitive. Overwrite and return false if you want to have case insensitive repository lookup.
Returns boolean true
areGroupNamesCaseSensitive
Are repositroy group names case sensitive. Overwrite and return false if you want to have case insensitive group lookup.
Returns boolean true
parseName
Parses repository name and tries to split it into base, group, repository and branch.
Parameters
namestring?focusstring where lies the focus if only one path component is given (optional, default"repository")
Returns DecodedRepositoryName result
createRepository
Create a repository.
Parameters
Returns Promise<Repository>
list
List provider objects of a given type.
Parameters
typestring name of the method to deliver typed iterator projects,milestones,hooks,repositories,branches,tagspatternsArray<string> group / repository filter
Returns AsyncIterable<(Repository | PullRequest | Branch | Tag | Project | Milestone | Hook)> all matching repositories of the providers
projects
List projects.
Parameters
Returns AsyncIterable<Project> all matching projects of the provider
milestones
List milestones.
Parameters
Returns AsyncIterable<Milestone> all matching milestones of the provider
repositories
List repositories.
Parameters
Returns AsyncIterable<Repository> all matching repos of the provider
branches
List branches.
Parameters
Returns AsyncIterable<Branch> all matching branches of the provider
tags
List tags.
Parameters
Returns AsyncIterable<Tag> all matching tags of the provider
hooks
List hooks.
Parameters
Returns AsyncIterable<Hook> all matching hooks of the provider
pullRequests
List pull requests.
Parameters
Returns AsyncIterable<PullRequest> all matching pullRequests of the provider
name
Deliver the provider name.
Returns string class name by default
provider
We are our own provider.
Returns BaseProvider this
toJSON
List all defined entries from attributes.
Returns {name: string}
repositoryGroupClassFor
Retrieve class suitable to hold repository group for name and options
Parameters
Returns Function
instanceIdentifier
Prefix used to form environment variables. 'GITHUB_' -> 'GITHUB_TOKEN'
Returns string identifier for environment options
initialize
Creates a new provider for a given set of options.
Parameters
Returns (BaseProvider | undefined) newly created provider or undefined if options are not sufficient to construct a provider
BaseProvider
Extends BaseObject
Parameters
optionsObject?options.urlstring?options.messageDestinationMessageDestination?
Properties
messageDestinationMessageDestinationurlstringapistring
equals
Parameters
otherany
Returns boolean true if other provider is the same as the receiver
repositoryBases
All supported base urls. For github something like:
- [email protected]
- git://github.com
- git+ssh://github.com
- https://github.com
- git+https://github.com By default we provide provider name with ':'.
Returns Array<string> common base urls of all repositories
supportsBase
Does the provider support the base name.
Parameters
basestring? to be checked
Returns boolean true if base is supported or base is undefined
normalizeRepositoryName
Bring a repository name into its normal form by removing any clutter. Like .git suffix or #branch names.
Parameters
Returns (string | undefined) normalized name
normalizeGroupName
Bring a group name into its normal form by removing any clutter. Like .git suffix or #branch names.
Parameters
Returns (string | undefined) normalized name
areRepositoryNamesCaseSensitive
Are repository names case sensitive. Overwrite and return false if you want to have case insensitive repository lookup.
Returns boolean true
areGroupNamesCaseSensitive
Are repositroy group names case sensitive. Overwrite and return false if you want to have case insensitive group lookup.
Returns boolean true
parseName
Parses repository name and tries to split it into base, group, repository and branch.
Parameters
namestring?focusstring where lies the focus if only one path component is given (optional, default"repository")
Returns DecodedRepositoryName result
createRepository
Create a repository.
Parameters
Returns Promise<Repository>
list
List provider objects of a given type.
Parameters
typestring name of the method to deliver typed iterator projects,milestones,hooks,repositories,branches,tagspatternsArray<string> group / repository filter
Returns AsyncIterable<(Repository | PullRequest | Branch | Tag | Project | Milestone | Hook)> all matching repositories of the providers
projects
List projects.
Parameters
Returns AsyncIterable<Project> all matching projects of the provider
milestones
List milestones.
Parameters
Returns AsyncIterable<Milestone> all matching milestones of the provider
repositories
List repositories.
Parameters
Returns AsyncIterable<Repository> all matching repos of the provider
branches
List branches.
Parameters
Returns AsyncIterable<Branch> all matching branches of the provider
tags
List tags.
Parameters
Returns AsyncIterable<Tag> all matching tags of the provider
hooks
List hooks.
Parameters
Returns AsyncIterable<Hook> all matching hooks of the provider
pullRequests
List pull requests.
Parameters
Returns AsyncIterable<PullRequest> all matching pullRequests of the provider
name
Deliver the provider name.
Returns string class name by default
provider
We are our own provider.
Returns BaseProvider this
toJSON
List all defined entries from attributes.
Returns {name: string}
repositoryGroupClassFor
Retrieve class suitable to hold repository group for name and options
Parameters
Returns Function
instanceIdentifier
Prefix used to form environment variables. 'GITHUB_' -> 'GITHUB_TOKEN'
Returns string identifier for environment options
initialize
Creates a new provider for a given set of options.
Parameters
Returns (BaseProvider | undefined) newly created provider or undefined if options are not sufficient to construct a provider
DecodedRepositoryName
Type: Object
Properties
MessageDestination
Type: Object
Properties
infofunction (string): voiddebugfunction (string): voidwarnfunction (string): voiderrorfunction (string): voidtracefunction (string): void
name
Name of the provider.
messageDestination
To forward info/warn and error messages to
parsedName
Type: Object
Branch
Abstract branch.
Parameters
ownerRepositoryOwnernamestringoptionsObject
Properties
repositoryRepositoryproviderProvidernamestring
url
Deliver repository and branch url combined.
Returns string 'repoUrl#branch'
refType
Returns string heades
isWritable
Returns any true if not isArchived and isDisabled and isLocked and isProtected
isDefault
Are we the default branch.
Returns boolean true if name matches the repository default branch
delete
Delete the branch from the Repository.
Returns Promise<any>
commit
Commit entries.
Parameters
Returns Promise<(CommitResult | undefined)>
commitIntoPullRequest
Add commits into a pull request.
Parameters
optionsObjectoptions.pullRequestBranch(Branch | string) to commit intooptions.dryboolean do not create a branch and do not commit only create dummy PR (optional, defaultfalse)options.skipWithoutCommitsboolean do not create a PR if no commits are givenoptions.bodyFromCommitMessagesboolean generate body from commit messagesoptions.bodystring? body of the PR
Returns Promise<PullRequest>
removeEntries
Remove entries form the branch.
Parameters
entriesAsyncIterable<ContentEntry>
createPullRequest
Create a pull request.
Parameters
Returns Promise<PullRequest>
createBranch
Create a new Branch by cloning a given source branch. Simply calls Repository.createBranch() with the receiver as source branch
Parameters
Returns Promise<Branch> newly created branch (or already present old one with the same name)
CommitResult
Parameters
ref
Properties
refstring
Commit
Parameters
repositoryRepositoryoptionsObject
Properties
repositoryRepositorymessagestringshastringauthorUsercommitterUser
Hook
Extends OwnedObject
Repository hook.
Issue
Extends OwnedObject
Milestone
Extends OwnedObject
MultiGroupProvider
Extends BaseProvider
Provider supporting serveral repository groups.
repository
Lookup a repository in the provider and all of its repository groups.
Parameters
namestring of the repository
Returns Promise<(Repository | undefined)>
branch
Lookup a branch.
Parameters
namestring of the branch
Returns Promise<(Branch | undefined)>
repositoryGroup
Lookup a repository group.
Parameters
namestring of the group
Returns Promise<(RepositoryGroup | undefined)>
repositoryGroups
List groups.
Parameters
Returns AsyncIterable<RepositoryGroup> all matching repositories groups of the provider
createRepositoryGroup
Create a new repository group. If there is already a group for the given name it will be returend instead
Parameters
Returns Promise<RepositoryGroup>
addRepositoryGroup
Add a new repository group (not provider specific actions are executed).
Parameters
Returns RepositoryGroup
NamedObject
Extends BaseObject
Object with a name.
Parameters
Properties
namestring
displayName
Beautified name use for human displaying only.
Returns string human readable name
condensedName
Name with default parts removed
Returns string
fullCondensedName
Complete name in the hierachy.
Returns string
equals
Check for equality.
Parameters
otherNamedObject
Returns boolean true if names are equal and have the same provider
toJSON
Provided name and all defined attributes.
Parameters
filter
OwnedObject
Extends NamedObject
Parameters
ownernameoptions
delete
Removes the receiver from the owner.
equals
Check for equality.
Parameters
otherOwnedObject
Returns boolean true if receiver and owner are equal
homePageURL
Url of home page.
Returns (string | undefined) as provided from the owner
issuesURL
- See: Repository#issuesURL
Url of issue tracking system.
Returns (string | undefined) as provided from the repository
isLocked
Forwarded from the owner.
Returns boolean
isArchived
Forwarded from the owner.
Returns boolean
isDisabled
Forwarded from the owner.
Returns boolean
api
API as given by the owner.
Returns string url
slug
API as given by the owner.
Returns string url
url
URL as given by the owner.
Returns string url
provider
The provider we live in.
Returns BaseProvider
identifier
Short human readable identifier with provider and branch.
Returns string
fullName
Returns string name with owner name
trace
Forwarded to the owner.
Parameters
args...any
info
Forwarded to the owner.
Parameters
args...any
warn
Forwarded to the owner.
Parameters
args...any
error
Forwarded to the owner.
Parameters
args...any
debug
Forwarded to the owner.
Parameters
args...any
addMethodName
Method name to be called to register one instance in the owner. sample: Application => _addApplication
Returns string
deleteMethodName
Method name to be called to unregister one instance in the owner. sample: Application => _deleteApplication
Returns string
OwnedObject
Extends NamedObject
Named Object registering itself in the owner.
Parameters
ownerBaseObjectnamestringoptions(Object | undefined)
delete
Removes the receiver from the owner.
equals
Check for equality.
Parameters
otherOwnedObject
Returns boolean true if receiver and owner are equal
homePageURL
Url of home page.
Returns (string | undefined) as provided from the owner
issuesURL
- See: Repository#issuesURL
Url of issue tracking system.
Returns (string | undefined) as provided from the repository
isLocked
Forwarded from the owner.
Returns boolean
isArchived
Forwarded from the owner.
Returns boolean
isDisabled
Forwarded from the owner.
Returns boolean
api
API as given by the owner.
Returns string url
slug
API as given by the owner.
Returns string url
url
URL as given by the owner.
Returns string url
provider
The provider we live in.
Returns BaseProvider
identifier
Short human readable identifier with provider and branch.
Returns string
fullName
Returns string name with owner name
trace
Forwarded to the owner.
Parameters
args...any
info
Forwarded to the owner.
Parameters
args...any
warn
Forwarded to the owner.
Parameters
args...any
error
Forwarded to the owner.
Parameters
args...any
debug
Forwarded to the owner.
Parameters
args...any
addMethodName
Method name to be called to register one instance in the owner. sample: Application => _addApplication
Returns string
deleteMethodName
Method name to be called to unregister one instance in the owner. sample: Application => _deleteApplication
Returns string
Project
Extends OwnedObject
PullRequest
Extends OwnedObject
Abstract pull request. Repository#addPullRequest
Parameters
Properties
namestringsourceBranchdestinationBranchtitlestring?statestring?mergedboolean?lockedboolean?urlstring
source
Type: Branch
fullName
Name of the PR together with the repository.
Returns string PR full name
url
URL of the pull request.
Returns string url
repository
Returns Repository destination repository
delete
Delete the pull request from the Repository.
Returns Promise
merge
Merge the pull request.
Parameters
methodstring (optional, default"MERGE")
decline
Decline the pull request.
reviews
Returns AsyncIterable<Review>
identifier
Short human readable identifier with provider and branch.
Returns string
defaultListStates
States to list pull request by default
Returns Set<string> states to list by default
states
possible states
Type: string
validMergeMethods
All valid merge methods
Type: string
Returns Set<string> valid merge methods.
list
List all pull request for a given repo. Result will be filtered by source branch, destination branch and states
Parameters
repositoryRepositoryfilterObject?
Returns AsyncIterable<PullRequest>
open
Open a pull request
Parameters
state
state of the pull request.
- OPEN
- MERGED
- CLOSED
Returns string
locked
Locked state of the pull request.
Returns boolean
merged
Merged state of the pull request.
Returns boolean
draft
Draft state of the pull request.
Returns boolean
Ref
Extends OwnedObject
ref
Full ref path.
Returns string git ref of the Ref
refId
Get sha of our ref.
Returns Promise<string> sha of the ref
entries
List entries of the branch.
Parameters
Returns AsyncGenerator<ContentEntry> all matching entries in the branch
asyncIterator
List all entries of the branch.
Returns AsyncGenerator<ContentEntry> all entries in the branch
maybeEntry
Get exactly one matching entry by name or undefine if no such entry is found.
Parameters
namestring
Returns Promise<(ContentEntry | undefined)>
entry
Get exactly one matching entry by name (throws if entry is not found).
Parameters
namestring
Returns Promise<ContentEntry>
repository
- See: Repository#owner
Ref owner. By default we provide the repository owner
Returns Repository
fullName
Repository and branch name combined.
Returns string 'repo#branch'
fullCondensedName
Repository fullName and branch name combined. But skipping the branch name if it is the default branch.
Returns string 'user/repo#branch'
isProtected
Returns any false
isDefault
Are we the default ref.
Returns boolean false
attributes
Attributes
Type: Object
Ref
Extends OwnedObject
Base for Branch and Tag
ref
Full ref path.
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global
