github-pr-release
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -16,2 +16,3 @@ var fs = require('fs') | ||
client.assignReviewers(releasePR, prs) | ||
return client.updatePR(releasePR, message) | ||
@@ -18,0 +19,0 @@ }) |
@@ -1,12 +0,12 @@ | ||
var request = require('request') | ||
var Promise = require('es6-promise').Promise | ||
var parseLinkHeader = require('parse-link-header') | ||
const request = require('request') | ||
const Promise = require('es6-promise').Promise | ||
const parseLinkHeader = require('parse-link-header') | ||
function GithubClient (config) { | ||
this.owner = config.owner | ||
this.repo = config.repo | ||
this.token = config.token | ||
this.head = config.head || 'master' | ||
this.base = config.base || 'production' | ||
this.endpoint = config.endpoint || 'https://api.github.com' | ||
this.owner = config.owner || process.env.GITHUB_PR_RELEASE_OWNER | ||
this.repo = config.repo || process.env.GITHUB_PR_RELEASE_REPO | ||
this.token = config.token || process.env.GITHUB_PR_RELEASE_TOKEN | ||
this.head = config.head || process.env.GITHUB_PR_RELEASE_HEAD || 'master' | ||
this.base = config.base || process.env.GITHUB_PR_RELEASE_BASE || 'production' | ||
this.endpoint = config.endpoint || process.env.GITHUB_PR_RELEASE_ENDPOINT || 'https://api.github.com' | ||
} | ||
@@ -175,2 +175,13 @@ | ||
GithubClient.prototype.assignReviewers = function (pr, prs) { | ||
var reviewers = prs | ||
.map(pr => pr.assignee ? pr.assignee : pr.user) | ||
.filter(user => user.type === 'User') | ||
.map(user => user.login) | ||
return this.post(this.pullRequestEndpoint() + '/' + pr.number + '/requested_reviewers', { reviewers }).then(function (res) { | ||
return res.body | ||
}) | ||
} | ||
GithubClient.prototype.updatePR = function (pr, data) { | ||
@@ -177,0 +188,0 @@ return this.patch(this.pullRequestEndpoint() + '/' + pr.number, data).then(function (res) { |
{ | ||
"name": "github-pr-release", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "Create a release pull request by Github API", | ||
"main": "index.js", | ||
"bin": { | ||
"github-pr-release": "cli/index.js" | ||
}, | ||
"author": "Kazato Sugimoto", | ||
"license": "MIT", | ||
"scripts": { | ||
"test": "standard && mocha --require intelli-espower-loader" | ||
"test": "standard && mocha --require intelli-espower-loader", | ||
"release": "release-it" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/uiureo/github-pr-release.git" | ||
"url": "https://github.com/uiur/github-pr-release.git" | ||
}, | ||
@@ -20,3 +24,4 @@ "dependencies": { | ||
"parse-link-header": "^0.2.0", | ||
"request": "^2.58.0" | ||
"request": "^2.58.0", | ||
"yargs": "^17.3.1" | ||
}, | ||
@@ -30,4 +35,13 @@ "devDependencies": { | ||
"proxyquire": "^1.7.2", | ||
"release-it": "^14.12.3", | ||
"standard": "^12.0.1" | ||
}, | ||
"release-it": { | ||
"github": { | ||
"release": true | ||
}, | ||
"npm": { | ||
"skipChecks": true | ||
} | ||
} | ||
} |
# github-pr-release | ||
[![Build Status](https://travis-ci.org/uiureo/github-pr-release.svg)](https://travis-ci.org/uiureo/github-pr-release) | ||
[![](https://img.shields.io/npm/v/github-pr-release.svg)](https://www.npmjs.com/package/github-pr-release) | ||
@@ -20,7 +19,7 @@ | ||
``` javascript | ||
var release = require('github-pr-release') | ||
const release = require('github-pr-release') | ||
var config = { | ||
const config = { | ||
token: 'your github token', | ||
owner: 'uiureo', | ||
owner: 'uiur', | ||
repo: 'awesome-web-app', | ||
@@ -34,9 +33,17 @@ head: 'master', // optional | ||
// success | ||
// `pullRequest` is an object that github api returns. | ||
// See: https://developer.github.com/v3/pulls/#get-a-single-pull-request | ||
}) | ||
``` | ||
`pullRequest` is an object that github api returns. | ||
Also, the following environment variables can be used for the config: | ||
See: https://developer.github.com/v3/pulls/#get-a-single-pull-request | ||
- `GITHUB_PR_RELEASE_OWNER` | ||
- `GITHUB_PR_RELEASE_REPO` | ||
- `GITHUB_PR_RELEASE_TOKEN` | ||
- `GITHUB_PR_RELEASE_HEAD` | ||
- `GITHUB_PR_RELEASE_BASE` | ||
- `GITHUB_PR_RELEASE_ENDPOINT` | ||
## Install | ||
@@ -58,3 +65,3 @@ ``` | ||
token: 'token' | ||
owner: 'uiureo', | ||
owner: 'uiur', | ||
repo: 'awesome-web-app', | ||
@@ -80,3 +87,3 @@ template: './template.mustache' | ||
token: 'token' | ||
owner: 'uiureo', | ||
owner: 'uiur', | ||
repo: 'awesome-web-app', | ||
@@ -83,0 +90,0 @@ endpoint: 'https://github.yourdomain.com/api/v3' |
@@ -166,2 +166,30 @@ /* global describe before it */ | ||
describe('#assignReviewers()', function () { | ||
const USER1 = 'pr1-owner' | ||
const USER2 = 'pr2-owner' | ||
const BOT = 'bot' | ||
nock('https://api.github.com') | ||
.post('/repos/uiureo/awesome-app/pulls/42/requested_reviewers') | ||
.query(true) | ||
.reply(200, (_, requestBody) => ({ | ||
requested_reviewers: requestBody.reviewers.map(login => ({ login })) | ||
})) | ||
it('returns pr that has reviewers', function (done) { | ||
const prs = [ | ||
{ assignee: { login: USER1, type: 'User' } }, | ||
{ user: { login: USER2, type: 'User' } }, | ||
{ user: { login: BOT, type: 'Bot' } } | ||
] | ||
this.client.assignReviewers({ number: 42 }, prs) | ||
.then(function (pr) { | ||
assert(pr.requested_reviewers.length === 2) | ||
assert(pr.requested_reviewers[0].login === USER1) | ||
assert(pr.requested_reviewers[1].login === USER2) | ||
done() | ||
}).catch(done) | ||
}) | ||
}) | ||
describe('#updatePR()', function () { | ||
@@ -168,0 +196,0 @@ nock('https://api.github.com/') |
@@ -19,2 +19,5 @@ /* global describe it */ | ||
return Promise.resolve({ pr: releasePR, message: message }) | ||
}, | ||
assignReviewers: function (releasePR, prs) { | ||
return Promise.resolve({ requested_reviewers: [] }) | ||
} | ||
@@ -21,0 +24,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 6 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22495
15
475
109
6
8
7
+ Addedyargs@^17.3.1
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedcliui@8.0.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)