Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github-pr-release

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-pr-release - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

.github/workflows/create-pr.js.yml

1

index.js

@@ -16,2 +16,3 @@ var fs = require('fs')

client.assignReviewers(releasePR, prs)
return client.updatePR(releasePR, message)

@@ -18,0 +19,0 @@ })

29

lib/github-client.js

@@ -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 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc