npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

repository-provider

v35.2.26

Published

abstract interface to git repository providers like github, bitbucket and gitlab

Downloads

5,682

Readme

npm License Typed with TypeScript bundlejs downloads GitHub Issues Build Status Styled with prettier Commitizen friendly Known Vulnerabilities Coverage Status

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

Extends OwnedObject

definePropertiesFromOptions

  • 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 }})

Parameters

  • object Object target object
  • options 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, default object.constructor.attributes)

defaultValues

Get default values.

Parameters

Returns Object filled with default values

optionJSON

Create json based on present options. In other words only produce key value pairs if value is defined.

Parameters

  • object Object
  • initial Object (optional, default {})
  • attributes Object to operator on (optional, default object.constructor.attributes)

Returns Object initial + defined values

mapAttributes

Rename attributes. Filters out null, undefined and empty strings.

mapAttributes({a:1},{a:"a'"}) // {"a'": 1}

Parameters

Returns Object keys renamed after mapping

mapAttributesInverse

Same as mapAttributes but with the inverse mapping. Filters out null, undefined and empty strings

Parameters

Returns Object keys renamed after mapping

default_attribute

default_attribute

Common attribute properties.

Type: AttributeDefinition

boolean_attribute

Type: AttributeDefinition

boolean_read_only_attribute

Type: AttributeDefinition

uuid_attribute

Type: AttributeDefinition

empty_attribute

Type: AttributeDefinition

secret_attribute

Type: AttributeDefinition

count_attribute

Type: AttributeDefinition

size_attribute

Type: AttributeDefinition

name_attribute

Type: AttributeDefinition

url_attribute

Type: AttributeDefinition

description_attribute

The description of the object content.

Type: AttributeDefinition

id_attribute

Unique id within the provider.

Type: AttributeDefinition

state_attribute

Type: AttributeDefinition

body_attribute

The body text of the pull request.

Type: AttributeDefinition

title_attribute

The one line description of the pull request.

Type: AttributeDefinition

priority_attribute

In case there are several providers able to support a given source which one sould be used ? this defines the order.

Type: AttributeDefinition

active_attribute

Type: AttributeDefinition

language_attribute

Type: AttributeDefinition

type_attribute

Type: AttributeDefinition

BaseObject

Creates an instance of BaseObject.

Parameters

Properties

id

Type: string

description

Type: string

updateAttributes

Takes values from options.

Parameters

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

equals

Check for equality

Parameters

Returns boolean true if other is present

type

Returns string type we represent

collectionName

Tag -> tags
Repository -> repositories

Returns string name of the collection holding us in the owner

attributes

Attributes definitions.

Returns Object

writableAttributes

User modifyable attributes.

Returns Object writable attributes

attributeMapping

Map attributes between external and internal representation.

Returns Object

BaseProvider

Extends BaseObject

equals

Parameters

  • other any

Returns boolean true if other provider is the same as the receiver

repositoryBases

All supported base urls. For github something like:

Returns Array<string> common base urls of all repositories

supportsBase

Does the provider support the base name.

Parameters

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

  • name string?
  • focus string 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

  • type string name of the method to deliver typed iterator projects,milestones,hooks,repositories,branches,tags
  • patterns Array<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}

instanceIdentifier

Prefix used to form environment variables. 'GITHUB_' -> 'GITHUB_TOKEN'

Returns string identifier for environment options

optionsFromEnvironment

Extract options suitable for the constructor. Form the given set of environment variables. Object with the detected key value pairs is delivered.

Parameters

  • env Object? as from process.env
  • instanceIdentifier string part of variable name. (optional, default this.instanceIdentifier)

Returns (Object | undefined) undefined if no suitable environment variables have been found

areOptionsSufficcient

Check if given options are sufficient to create a provider.

Parameters

Returns boolean true if options ar sufficient to construct a provider

initialize

Creates a new provider for a given set of options.

Parameters

  • options Object additional options

    • options.instanceIdentifier string? name of the provider instance
    • options.description string?
  • env Object taken from process.env

Returns (BaseProvider | undefined) newly created provider or undefined if options are not sufficient to construct a provider

BaseProvider

Extends BaseObject

Parameters

Properties

equals

Parameters

  • other any

Returns boolean true if other provider is the same as the receiver

repositoryBases

All supported base urls. For github something like:

Returns Array<string> common base urls of all repositories

supportsBase

Does the provider support the base name.

Parameters

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

  • name string?
  • focus string 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

  • type string name of the method to deliver typed iterator projects,milestones,hooks,repositories,branches,tags
  • patterns Array<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}

instanceIdentifier

Prefix used to form environment variables. 'GITHUB_' -> 'GITHUB_TOKEN'

Returns string identifier for environment options

optionsFromEnvironment

Extract options suitable for the constructor. Form the given set of environment variables. Object with the detected key value pairs is delivered.

Parameters

  • env Object? as from process.env
  • instanceIdentifier string part of variable name. (optional, default this.instanceIdentifier)

Returns (Object | undefined) undefined if no suitable environment variables have been found

areOptionsSufficcient

Check if given options are sufficient to create a provider.

Parameters

Returns boolean true if options ar sufficient to construct a provider

initialize

Creates a new provider for a given set of options.

Parameters

  • options Object additional options

    • options.instanceIdentifier string? name of the provider instance
    • options.description string?
  • env Object taken from process.env

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

name

Name of the provider.

name

Type: string

messageDestination

To forward info/warn and error messages to

parsedName

Type: Object

Branch

Abstract branch.

Parameters

Properties

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

  • message string commit message
  • updates Array<ContentEntry> content to be commited
  • options Object

Returns Promise<(CommitResult | undefined)>

commitIntoPullRequest

Add commits into a pull request.

Parameters

  • commits (Commit | AsyncGenerator<Commit>) to be commited

  • options Object

    • options.pullRequestBranch (Branch | string) to commit into
    • options.dry boolean do not create a branch and do not commit only create dummy PR (optional, default false)
    • options.skipWithoutCommits boolean do not create a PR if no commits are given
    • options.bodyFromCommitMessages boolean generate body from commit messages
    • options.body string? body of the PR

Returns Promise<PullRequest>

removeEntries

Remove entries form the branch.

Parameters

  • entries AsyncIterable<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

Commit

Parameters

  • repository

Properties

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

Returns Promise<(Repository | undefined)>

branch

Lookup a branch.

Parameters

Returns Promise<(Branch | undefined)>

repositoryGroup

Lookup a repository group.

Parameters

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

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

Returns boolean true if names are equal and have the same provider

toJSON

Provided name and all defined attributes.

OwnedObject

Extends NamedObject

Parameters

  • owner
  • name
  • options
  • additionalProperties

delete

Removes the receiver from the owner.

equals

Check for equality.

Parameters

Returns boolean true if receiver and owner are equal

homePageURL

Url of home page.

Returns (string | undefined) as provided from the owner

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

  • owner
  • name
  • options
  • additionalProperties

delete

Removes the receiver from the owner.

equals

Check for equality.

Parameters

Returns boolean true if receiver and owner are equal

homePageURL

Url of home page.

Returns (string | undefined) as provided from the owner

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

  • name string
  • source Branch
  • destination Branch
  • title **[string](https://developer.mozilla.org/docs/Web/JavaScri