abstract interface to git repository providers like github, bitbucket, gitlab, gitea, ...
see list of avaliable implementations below
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);
list by repository-provider keyword
- Application
- definePropertiesFromOptions
- defaultValues
- optionJSON
- mapAttributes
- mapAttributesInverse
- default_attribute
- default_attribute
- boolean_attribute
- boolean_read_only_attribute
- uuid_attribute
- empty_attribute
- secret_attribute
- count_attribute
- size_attribute
- name_attribute
- url_attribute
- description_attribute
- id_attribute
- state_attribute
- body_attribute
- title_attribute
- priority_attribute
- active_attribute
- language_attribute
- type_attribute
- BaseObject
- BaseProvider
- equals
- repositoryBases
- supportsBase
- normalizeRepositoryName
- normalizeGroupName
- areRepositoryNamesCaseSensitive
- areGroupNamesCaseSensitive
- parseName
- createRepository
- list
- projects
- milestones
- repositories
- branches
- tags
- hooks
- pullRequests
- name
- provider
- toJSON
- instanceIdentifier
- optionsFromEnvironment
- areOptionsSufficcient
- initialize
- BaseProvider
- Parameters
- Properties
- equals
- repositoryBases
- supportsBase
- normalizeRepositoryName
- normalizeGroupName
- areRepositoryNamesCaseSensitive
- areGroupNamesCaseSensitive
- parseName
- createRepository
- list
- projects
- milestones
- repositories
- branches
- tags
- hooks
- pullRequests
- name
- provider
- toJSON
- instanceIdentifier
- optionsFromEnvironment
- areOptionsSufficcient
- initialize
- DecodedRepositoryName
- MessageDestination
- name
- 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
- isDisabled
- isTemplate
- delete
- defaultBranch
- branch
- hasBranches
- branches
- createBranch
- addBranch
- deleteBranch
- tag
- tags
- addTag
- createPullRequest
- addPullRequest
- pullRequests
- pullRequest
- deletePullRequest
- addHook
- createHook
- hooks
- hook
- milestone
- project
- application
- type
- refId
- attributes
- defaultBranchName
- branches
- tags
- projects
- applications
- milestones
- pullRequests
- Review
- SingleGroupProvider
- Tag
- asArray
- stripBaseName
- stripBaseNames
- generateBranchName
Extends OwnedObject
- See: Object.definedProperties()
- See: Object.getOwnPropertyDescriptor()
Create properties from options and default options. Already present properties (direct) are skipped. The attribute list from the class will be applied to the options and merged with the given set of properties.
class aClass {
static get attributes() {
return { with_default: { default: 77 }};
}
}
definePropertiesFromOptions(new aClass());
// equivalent to
Object.definedProperties(new aClass(),{ with_default: { value: 77 }})
object
Object target objectoptions
Object as passed to object constructor. Used as values for the attributes. (optional, default{}
)properties
Object object properties (optional, default{}
)attributes
Object? attribute meta info (optional, defaultobject.constructor.attributes
)
Get default values.
Returns Object filled with default values
Create json based on present options. In other words only produce key value pairs if value is defined.
object
Objectinitial
Object (optional, default{}
)attributes
Object to operator on (optional, defaultobject.constructor.attributes
)
Returns Object initial + defined values
Rename attributes. Filters out null, undefined and empty strings.
mapAttributes({a:1},{a:"a'"}) // {"a'": 1}
Returns Object keys renamed after mapping
Same as mapAttributes but with the inverse mapping. Filters out null, undefined and empty strings
Returns Object keys renamed after mapping
Common attribute properties.
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
The description of the object content.
Type: AttributeDefinition
Unique id within the provider.
Type: AttributeDefinition
Type: AttributeDefinition
The description of the pull request.
Type: AttributeDefinition
The one line description of the pull request.
Type: AttributeDefinition
In case there are several providers able to support a given source which one sould be used ? this defines the order.
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Creates an instance of BaseObject.
Type: string
Type: string
Takes values from options.
Save object attributes in the backing store.
Returns string fullName
Complete name in the hierachy.
Returns string
By default cannot be written to.
Returns boolean false
Check for equality
other
(BaseObject | undefined)
Returns boolean true if other is present
Returns string type we represent
Tag -> tags
Repository -> repositories
Returns string name of the collection holding us in the owner
Attributes definitions.
Returns Object
User modifyable attributes.
Returns Object writable attributes
Map attributes between external and internal representation.
Returns Object
Extends BaseObject
other
any
Returns boolean true if other provider is the same as the receiver
All supported base urls. For github something like:
- git@github.com
- 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
Does the provider support the base name.
base
string? to be checked
Returns boolean true if base is supported or base is undefined
Bring a repository name into its normal form by removing any clutter. Like .git suffix or #branch names.
Returns (string | undefined) normalized name
Bring a group name into its normal form by removing any clutter. Like .git suffix or #branch names.
Returns (string | undefined) normalized name
Are repository names case sensitive. Overwrite and return false if you want to have case insensitive repository lookup.
Returns boolean true
Are repositroy group names case sensitive. Overwrite and return false if you want to have case insensitive group lookup.
Returns boolean true
Parses repository name and tries to split it into base, group, repository and branch.
name
string?focus
string where lies the focus if only one path component is given (optional, default"repository"
)
Returns DecodedRepositoryName result
Create a repository.
Returns Promise<Repository>
List provider objects of a given type.
type
string name of the method to deliver typed iterator projects,milestones,hooks,repositories,branches,tagspatterns
Array<string> group / repository filter
Returns AsyncIterable<(Repository | PullRequest | Branch | Tag | Project | Milestone | Hook)> all matching repositories of the providers
List projects.
Returns AsyncIterable<Project> all matching projects of the provider
List milestones.
Returns AsyncIterable<Milestone> all matching milestones of the provider
List repositories.
Returns AsyncIterable<Repository> all matching repos of the provider
List branches.
Returns AsyncIterable<Branch> all matching branches of the provider
List tags.
Returns AsyncIterable<Tag> all matching tags of the provider
List hooks.
Returns AsyncIterable<Hook> all matching hooks of the provider
List pull requests.
Returns AsyncIterable<PullRequest> all matching pullRequests of the provider
Deliver the provider name.
Returns string class name by default
We are our own provider.
Returns BaseProvider this
List all defined entries from attributes.
Returns {name: string}
Prefix used to form environment variables. 'GITHUB_' -> 'GITHUB_TOKEN'
Returns string identifier for environment options
Extract options suitable for the constructor. Form the given set of environment variables. Object with the detected key value pairs is delivered.
env
Object? as from process.envinstanceIdentifier
string part of variable name. (optional, defaultthis.instanceIdentifier
)
Returns (Object | undefined) undefined if no suitable environment variables have been found
Check if given options are sufficient to create a provider.
options
Object
Returns boolean true if options ar sufficient to construct a provider
Creates a new provider for a given set of options.
Returns (BaseProvider | undefined) newly created provider or undefined if options are not sufficient to construct a provider
Extends BaseObject
-
options
Object?options.url
string?options.messageDestination
MessageDestination?
messageDestination
MessageDestinationurl
stringapi
string
other
any
Returns boolean true if other provider is the same as the receiver
All supported base urls. For github something like:
- git@github.com
- 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
Does the provider support the base name.
base
string? to be checked
Returns boolean true if base is supported or base is undefined
Bring a repository name into its normal form by removing any clutter. Like .git suffix or #branch names.
Returns (string | undefined) normalized name
Bring a group name into its normal form by removing any clutter. Like .git suffix or #branch names.
Returns (string | undefined) normalized name
Are repository names case sensitive. Overwrite and return false if you want to have case insensitive repository lookup.
Returns boolean true
Are repositroy group names case sensitive. Overwrite and return false if you want to have case insensitive group lookup.
Returns boolean true
Parses repository name and tries to split it into base, group, repository and branch.
name
string?focus
string where lies the focus if only one path component is given (optional, default"repository"
)
Returns DecodedRepositoryName result
Create a repository.
Returns Promise<Repository>
List provider objects of a given type.
type
string name of the method to deliver typed iterator projects,milestones,hooks,repositories,branches,tagspatterns
Array<string> group / repository filter
Returns AsyncIterable<(Repository | PullRequest | Branch | Tag | Project | Milestone | Hook)> all matching repositories of the providers
List projects.
Returns AsyncIterable<Project> all matching projects of the provider
List milestones.
Returns AsyncIterable<Milestone> all matching milestones of the provider
List repositories.
Returns AsyncIterable<Repository> all matching repos of the provider
List branches.
Returns AsyncIterable<Branch> all matching branches of the provider
List tags.
Returns AsyncIterable<Tag> all matching tags of the provider
List hooks.
Returns AsyncIterable<Hook> all matching hooks of the provider
List pull requests.
Returns AsyncIterable<PullRequest> all matching pullRequests of the provider
Deliver the provider name.
Returns string class name by default
We are our own provider.
Returns BaseProvider this
List all defined entries from attributes.
Returns {name: string}
Prefix used to form environment variables. 'GITHUB_' -> 'GITHUB_TOKEN'
Returns string identifier for environment options
Extract options suitable for the constructor. Form the given set of environment variables. Object with the detected key value pairs is delivered.
env
Object? as from process.envinstanceIdentifier
string part of variable name. (optional, defaultthis.instanceIdentifier
)
Returns (Object | undefined) undefined if no suitable environment variables have been found
Check if given options are sufficient to create a provider.
options
Object
Returns boolean true if options ar sufficient to construct a provider
Creates a new provider for a given set of options.
Returns (BaseProvider | undefined) newly created provider or undefined if options are not sufficient to construct a provider
Type: Object
Type: Object
info
function (string): voiddebug
function (string): voidwarn
function (string): voiderror
function (string): voidtrace
function (string): void
Name of the provider.
Type: string
To forward info/warn and error messages to
Type: Object
Abstract branch.
owner
RepositoryOwnername
stringoptions
Object
repository
Repositoryprovider
Providername
string
Deliver repository and branch url combined.
Returns string 'repoUrl#branch'
Returns string heades
Returns any true if not isArchived and isDisabled and isLocked and isProtected
Are we the default branch.
Returns boolean true if name matches the repository default branch
Delete the branch from the Repository.
Returns Promise<any>
Commit entries.
Returns Promise<(CommitResult | undefined)>
Add commits into a pull request.
-
options
Objectoptions.pullRequestBranch
(Branch | string) to commit intooptions.dry
boolean do not create a branch and do not commit only create dummy PR (optional, defaultfalse
)options.skipWithoutCommits
boolean do not create a PR if no commits are givenoptions.bodyFromCommitMessages
boolean generate body from commit messagesoptions.body
string? body of the PR
Returns Promise<PullRequest>
Remove entries form the branch.
entries
AsyncIterable<ContentEntry>
Create a pull request.
Returns Promise<PullRequest>
Create a new Branch by cloning a given source branch. Simply calls Repository.createBranch() with the receiver as source branch
Returns Promise<Branch> newly created branch (or already present old one with the same name)
ref
ref
string
repository
repository
Repositorymessage
stringsha
stringauthor
Usercommitter
User
Extends OwnedObject
Repository hook.
Extends OwnedObject
Extends OwnedObject
Extends BaseProvider
Provider supporting serveral repository groups.
Lookup a repository in the provider and all of its repository groups.
name
string of the repository
Returns Promise<(Repository | undefined)>
Lookup a branch.
name
string of the branch
Returns Promise<(Branch | undefined)>
Lookup a repository group.
name
string of the group
Returns Promise<(RepositoryGroup | undefined)>
List groups.
Returns AsyncIterable<RepositoryGroup> all matching repositories groups of the provider
Create a new repository group. If there is already a group for the given name it will be returend instead
Returns Promise<RepositoryGroup>
Add a new repository group (not provider specific actions are executed).
Returns RepositoryGroup
Extends BaseObject
Object with a name.
name
string
Beautified name use for human displaying only.
Returns string human readable name
Name with default parts removed
Returns string
Complete name in the hierachy.
Returns string
Check for equality.
other
NamedObject
Returns boolean true if names are equal and have the same provider
Provided name and all defined attributes.
Extends NamedObject
owner
name
options
additionalProperties
Removes the receiver from the owner.
Check for equality.
other
OwnedObject
Returns boolean true if receiver and owner are equal
Url of home page.
Returns (string | undefined) as provided from the owner
- See: Repository#issuesURL
Url of issue tracking system.
Returns (string | undefined) as provided from the repository
Forwarded from the owner.
Returns boolean
Forwarded from the owner.
Returns boolean
Forwarded from the owner.
Returns boolean
API as given by the owner.
Returns string url
API as given by the owner.
Returns string url
URL as given by the owner.
Returns string url
The provider we live in.
Returns BaseProvider
Short human readable identifier with provider and branch.
Returns string
Returns string name with owner name
Forwarded to the owner.
args
...any
Forwarded to the owner.
args
...any
Forwarded to the owner.
args
...any
Forwarded to the owner.
args
...any
Forwarded to the owner.
args
...any
Method name to be called to register one instance in the owner. sample: Application => _addApplication
Returns string
Method name to be called to unregister one instance in the owner. sample: Application => _deleteApplication
Returns string
Extends NamedObject
Named Object registering itself in the owner.
owner
name
options
additionalProperties
Removes the receiver from the owner.
Check for equality.
other
OwnedObject
Returns boolean true if receiver and owner are equal
Url of home page.
Returns (string | undefined) as provided from the owner
- See: Repository#issuesURL
Url of issue tracking system.
Returns (string | undefined) as provided from the repository
Forwarded from the owner.
Returns boolean
Forwarded from the owner.
Returns boolean
Forwarded from the owner.
Returns boolean
API as given by the owner.
Returns string url
API as given by the owner.
Returns string url
URL as given by the owner.
Returns string url
The provider we live in.
Returns BaseProvider
Short human readable identifier with provider and branch.
Returns string
Returns string name with owner name
Forwarded to the owner.
args
...any
Forwarded to the owner.
args
...any
Forwarded to the owner.
args
...any
Forwarded to the owner.
args
...any
Forwarded to the owner.
args
...any
Method name to be called to register one instance in the owner. sample: Application => _addApplication
Returns string
Method name to be called to unregister one instance in the owner. sample: Application => _deleteApplication
Returns string
Extends OwnedObject
Extends OwnedObject
Abstract pull request. Repository#addPullRequest
name
stringsource
Branchdestination
Branchtitle
string?state
string?merged
boolean?locked
boolean?url
string
Type: Branch
Name of the PR together with the repository.
Returns string PR full name
URL of the pull request.
Returns string url
Returns Repository destination repository
Delete the pull request from the Repository.
Returns Promise
Merge the pull request.
method
string (optional, default"MERGE"
)
Decline the pull request.
Returns AsyncIterable<Review>
Short human readable identifier with provider and branch.
Returns string
States to list pull request by default
Returns Set<string> states to list by default
possible states
Type: string
All valid merge methods
Type: string
Returns Set<string> valid merge methods.
List all pull request for a given repo. Result will be filtered by source branch, destination branch and states
-
repository
Repository -
filter
Object?
Returns AsyncIterable<PullRequest>
Open a pull request
state of the pull request.
- OPEN
- MERGED
- CLOSED
Returns string
Locked state of the pull request.
Returns boolean
Merged state of the pull request.
Returns boolean
Draft state of the pull request.
Returns boolean
Extends OwnedObject
Full ref path.
Returns string git ref of the Ref
Get sha of our ref.
Returns Promise<string> sha of the ref
List entries of the branch.
Returns AsyncGenerator<ContentEntry> all matching entries in the branch
List all entries of the branch.
Returns AsyncGenerator<ContentEntry> all entries in the branch
Get exactly one matching entry by name or undefine if no such entry is found.
name
string
Returns Promise<(ContentEntry | undefined)>
Get exactly one matching entry by name (throws if entry is not found).
name
string
Returns Promise<ContentEntry>
- See: Repository#owner
Ref owner. By default we provide the repository owner
Returns Repository
Repository and branch name combined.
Returns string 'repo#branch'
Repository fullName and branch name combined. But skipping the branch name if it is the default branch.
Returns string 'user/repo#branch'
Returns any false
Are we the default ref.
Returns boolean false
Attributes
Type: Object
Extends OwnedObject
Base for Branch and Tag
Full ref path.
Returns string git ref of the Ref
Get sha of our ref.
Returns Promise<string> sha of the ref
List entries of the branch.
Returns AsyncGenerator<ContentEntry> all matching entries in the branch
List all entries of the branch.
Returns AsyncGenerator<ContentEntry> all entries in the branch
Get exactly one matching entry by name or undefine if no such entry is found.
name
string
Returns Promise<(ContentEntry | undefined)>
Get exactly one matching entry by name (throws if entry is not found).
name
string
Returns Promise<ContentEntry>
- See: Repository#owner
Ref owner. By default we provide the repository owner
Returns Repository
Repository and branch name combined.
Returns string 'repo#branch'
Repository fullName and branch name combined. But skipping the branch name if it is the default branch.
Returns string 'user/repo#branch'
Returns any false
Are we the default ref.
Returns boolean false
Attributes
Type: Object
Can the ref be modified.
Returns boolean
Extends RepositoryOwner(OwnedObject)
Abstract repository collection.
-
provider
BaseProvider -
name
string of the group -
options
Object?
provider
BaseProvidername
string
Map attributes between external and internal representation.
Type of the repository group either User or Organization.
The url of home page.
Returns string
Mixin to define a class able to handle a collection of repositories.
base
Object to be extendet
Abstract repository
-
owner
RepositoryOwner -
name
string (#branch) will be removed -
options
Object?
owner
RepositoryOwnername
string without (#branch)description
string? from options.descriptionid
string? from options.idbranches
Map<string, Branch>tags
Map<string, Tag>pullRequests
Map<string, PullRequest>milestones
Map<string, Milestone>
Name of the repo as used in the URL.
Returns string
Returns string
Lookup entries form the head of the default branch. Branch#entry
name
Returns Promise<ContentEntry>
List entries of the default branch.
Returns AsyncIterable<ContentEntry> all matching entries in the branch
Get exactly one matching entry by name or undefined if no such entry is found.
name
string
Returns Promise<(ContentEntry | undefined)>
List commits of the default branch.
options
Object?
Returns AsyncIterable<Commit> all matching commits in the repository
The url used for cloning the repo.
Returns string
The url of issue tracking system.
The url of home page.
By default we are not archived.
Returns boolean false
By default we are not locked.
Returns boolean false
By default we are not disabled.
Returns boolean false
By default we are not a template.
Returns boolean false
Delete the repository from the Provider. Provider#deleteRepository
Returns Promise<any>
Lookup the default branch.
Returns Promise<(Branch | undefined)> branch named after defaultBranchName
Lookup branch by name.
name
string
Returns Promise<(Branch | undefined)>
Returns boolean true if there is at least one branch
Returns AsyncGenerator<Branch> of all branches
Create a new Branch by cloning a given source branch.
Returns Promise<Branch> newly created branch (or already present old one with the same name)
Add a new Branch. Internal branch creation does not call repository.initialize()
Returns Branch newly created branch or already present one for the given name
Delete a Branch.
name
string of the branch
Returns Promise<any>
Get a Tag.
name
string
Returns AsyncGenerator<Tag> of all tags
Add a new Tag. Internal tag creation does not call repository.initialize()
Returns Tag newly created tag
Create a pull request (or deliver an already present for the given name).
Returns Promise<PullRequest>
Add a pull request.
Returns PullRequest
Deliver all PullRequests.
Returns AsyncGenerator<PullRequest> of all pull requests
The @see PullRequest for a given name.
name
string
Returns Promise<(PullRequest | undefined)>
Delete a PullRequest.
name
string
Returns Promise<any>
Add a new Hook.
Returns Hook newly created hook
Add a new Hook.
hook
Hook
List hooks.
Returns AsyncGenerator<Hook> all hooks of the repository
Get a Hook.
Returns Promise<(Hook | undefined)> for the given id
Get a Milestone.
name
string
Returns Promise<(Milestone | undefined)> for the given name
Get a Project.
name
string
Returns Promise<(Project | undefined)> for the given name
Get an Application.
name
string
Returns Promise<(Application | undefined)> for the given name
Get type of the repository.
Returns string 'git'
Get sha of a ref.
ref
string
Returns Promise<(string | undefined)> sha of the ref
options
The name of the default branch
Returns string
Type: Map<string, Application>
Type: Map<string, PullRequest>
Extends OwnedObject
Extends RepositoryOwner(BaseProvider)
Provider holding a single set of repositories (no repository groups).
Lookup a repository in the provider and all of its repository groups.
name
string of the repository
Returns Promise<(Repository | undefined)>
Get a single group.
name
string
Returns Promise<(RepositoryGroup | undefined)> deliver the one and only present group
List groups.
Returns AsyncIterable<RepositoryGroup> always deliver the one and only present group
Extends Ref
Tag refs
Returns string tags
Convert scalar into an array. The value undefined will be represented as an empty array.
value
(Array | any)
Returns Array value encapsulated in an array
Strip repository base name away. A URL auth component will be removed to.
name
(string | undefined)repositoryBases
Array<string> all possible baseswhenFound
function (string): void? to be called with the found base name
Returns (string | undefined) name without base
Loops over names and executes stripBaseName.
names
(Array<string> | string | undefined)repositoryBases
Array<string> all possible baseswhenFound
function (string): void? to be called with the found base name
Returns (Array<string> | string | undefined) names without base
Find a new branch name for a given pattern. '' will be replaced by a number. 'something/' will get to something/1 something/2 ...
repository
Repositorypattern
string
With npm do:
npm install repository-provider
BSD-2-Clause