repository-provider
Advanced tools
Comparing version 2.4.3 to 2.5.0
@@ -70,2 +70,5 @@ 'use strict'; | ||
/** | ||
* File list | ||
*/ | ||
async list() { | ||
@@ -117,5 +120,8 @@ return []; | ||
/** | ||
* Lookup content form the default branch | ||
* @return {Content} | ||
*/ | ||
async content(...args) { | ||
const branch = await this.branch('master'); | ||
return branch.content(...args); | ||
return (await this.defaultBranch).content(...args); | ||
} | ||
@@ -133,2 +139,10 @@ | ||
/** | ||
* Lookup the default branch | ||
* @return {Promise<Branch>} 'master' branch | ||
*/ | ||
get defaultBranch() { | ||
return this.branch('master'); | ||
} | ||
/** | ||
* @return {Promise<Map>} of all branches | ||
@@ -281,3 +295,3 @@ */ | ||
* @property {string} path file name inside of the repository | ||
* @property {string} mode file permission | ||
* @property {string} mode file permissions | ||
* @property {string} type | ||
@@ -340,4 +354,9 @@ */ | ||
/** | ||
* Create a new repository | ||
* @return {Promise<Repository>} | ||
*/ | ||
async createRepository(name, options) { | ||
const repository = new this.repositoryClass(this, name, options); | ||
await repository.initialize(); | ||
this.repositories.set(name, repository); | ||
@@ -348,4 +367,5 @@ return repository; | ||
/** | ||
* Lookup a repository | ||
* @param {string} name | ||
* @return {Repository} | ||
* @return {Promise<Repository>} | ||
*/ | ||
@@ -357,2 +377,17 @@ async repository(name) { | ||
/** | ||
* Lookup a branch | ||
* @param {string} name | ||
* @return {Promise<Branch>} | ||
*/ | ||
async branch(name) { | ||
const repository = await this.repository(name); | ||
const m = name.match(/#\w+$/); | ||
if (m) { | ||
return repository.branch(m[1]); | ||
} | ||
return repository.defaultBranch; | ||
} | ||
/** | ||
* Is our rate limit reached. | ||
@@ -359,0 +394,0 @@ * By default we have no rate limit |
{ | ||
"name": "repository-provider", | ||
"version": "2.4.3", | ||
"version": "2.5.0", | ||
"main": "dist/repository-provider.js", | ||
@@ -38,3 +38,3 @@ "module": "src/repository-provider.js", | ||
"rollup-plugin-multi-entry": "^2.0.2", | ||
"semantic-release": "^12.2.0", | ||
"semantic-release": "^12.2.2", | ||
"documentation": "^5.3.5", | ||
@@ -41,0 +41,0 @@ "travis-deploy-once": "^4.3.1" |
@@ -43,2 +43,3 @@ [](https://www.npmjs.com/package/repository-provider) | ||
- [Content](#content) | ||
- [Provider](#provider) | ||
@@ -48,8 +49,9 @@ - [repositoryClass](#repositoryclass) | ||
- [pullRequestClass](#pullrequestclass) | ||
- [createRepository](#createrepository) | ||
- [repository](#repository) | ||
- [branch](#branch) | ||
- [rateLimitReached](#ratelimitreached) | ||
- [defaultOptions](#defaultoptions) | ||
- [options](#options) | ||
- [Content](#content) | ||
- [Branch](#branch) | ||
- [Branch](#branch-1) | ||
- [provider](#provider-1) | ||
@@ -60,2 +62,3 @@ - [delete](#delete) | ||
- [createPullRequest](#createpullrequest) | ||
- [list](#list) | ||
- [rateLimitReached](#ratelimitreached-1) | ||
@@ -65,3 +68,5 @@ - [rateLimitReached](#ratelimitreached-2) | ||
- [initialize](#initialize) | ||
- [branch](#branch-1) | ||
- [content](#content-2) | ||
- [branch](#branch-2) | ||
- [defaultBranch](#defaultbranch) | ||
- [branches](#branches) | ||
@@ -81,2 +86,13 @@ - [createBranch](#createbranch) | ||
## Content | ||
Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | ||
**Properties** | ||
- `content` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Buffer](https://nodejs.org/api/buffer.html))** | ||
- `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** file name inside of the repository | ||
- `mode` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** file permissions | ||
- `type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
## Provider | ||
@@ -107,4 +123,17 @@ | ||
### createRepository | ||
Create a new repository | ||
**Parameters** | ||
- `name` | ||
- `options` | ||
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Repository](#repository)>** | ||
### repository | ||
Lookup a repository | ||
**Parameters** | ||
@@ -114,4 +143,14 @@ | ||
Returns **[Repository](#repository)** | ||
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Repository](#repository)>** | ||
### branch | ||
Lookup a branch | ||
**Parameters** | ||
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Branch](#branch)>** | ||
### rateLimitReached | ||
@@ -140,13 +179,2 @@ | ||
## Content | ||
Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | ||
**Properties** | ||
- `content` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Buffer](https://nodejs.org/api/buffer.html))** | ||
- `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** file name inside of the repository | ||
- `mode` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** file permission | ||
- `type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
## Branch | ||
@@ -214,2 +242,6 @@ | ||
### list | ||
File list | ||
### rateLimitReached | ||
@@ -253,2 +285,12 @@ | ||
### content | ||
Lookup content form the default branch | ||
**Parameters** | ||
- `args` **...any** | ||
Returns **[Content](#content)** | ||
### branch | ||
@@ -264,2 +306,8 @@ | ||
### defaultBranch | ||
Lookup the default branch | ||
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Branch](#branch)>** 'master' branch | ||
### branches | ||
@@ -266,0 +314,0 @@ |
@@ -66,2 +66,5 @@ /** | ||
/** | ||
* File list | ||
*/ | ||
async list() { | ||
@@ -68,0 +71,0 @@ return []; |
@@ -15,3 +15,3 @@ import { Branch } from './branch'; | ||
* @property {string} path file name inside of the repository | ||
* @property {string} mode file permission | ||
* @property {string} mode file permissions | ||
* @property {string} type | ||
@@ -74,4 +74,9 @@ */ | ||
/** | ||
* Create a new repository | ||
* @return {Promise<Repository>} | ||
*/ | ||
async createRepository(name, options) { | ||
const repository = new this.repositoryClass(this, name, options); | ||
await repository.initialize(); | ||
this.repositories.set(name, repository); | ||
@@ -82,4 +87,5 @@ return repository; | ||
/** | ||
* Lookup a repository | ||
* @param {string} name | ||
* @return {Repository} | ||
* @return {Promise<Repository>} | ||
*/ | ||
@@ -91,2 +97,17 @@ async repository(name) { | ||
/** | ||
* Lookup a branch | ||
* @param {string} name | ||
* @return {Promise<Branch>} | ||
*/ | ||
async branch(name) { | ||
const repository = await this.repository(name); | ||
const m = name.match(/#\w+$/); | ||
if (m) { | ||
return repository.branch(m[1]); | ||
} | ||
return repository.defaultBranch; | ||
} | ||
/** | ||
* Is our rate limit reached. | ||
@@ -93,0 +114,0 @@ * By default we have no rate limit |
@@ -25,5 +25,8 @@ /** | ||
/** | ||
* Lookup content form the default branch | ||
* @return {Content} | ||
*/ | ||
async content(...args) { | ||
const branch = await this.branch('master'); | ||
return branch.content(...args); | ||
return (await this.defaultBranch).content(...args); | ||
} | ||
@@ -41,2 +44,10 @@ | ||
/** | ||
* Lookup the default branch | ||
* @return {Promise<Branch>} 'master' branch | ||
*/ | ||
get defaultBranch() { | ||
return this.branch('master'); | ||
} | ||
/** | ||
* @return {Promise<Map>} of all branches | ||
@@ -43,0 +54,0 @@ */ |
34456
707
430