File tree Expand file tree Collapse file tree 5 files changed +234
-14
lines changed
Expand file tree Collapse file tree 5 files changed +234
-14
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,9 @@ Create a release pull request and return Promise.
1616You must pass a config as an argument.
1717
1818``` javascript
19- var release = require (' github-pr-release' )
19+ const release = require (' github-pr-release' )
2020
21- var config = {
21+ const config = {
2222 token: ' your github token' ,
2323 owner: ' uiur' ,
2424 repo: ' awesome-web-app' ,
@@ -29,12 +29,20 @@ var config = {
2929
3030release (config).then (function (pullRequest ) {
3131 // success
32+ // `pullRequest` is an object that github api returns.
33+ // See: https://developer.github.com/v3/pulls/#get-a-single-pull-request
3234})
3335```
3436
35- ` pullRequest ` is an object that github api returns.
37+ Also, the following environment variables can be used for the config:
38+
39+ - ` GITHUB_PR_RELEASE_OWNER `
40+ - ` GITHUB_PR_RELEASE_REPO `
41+ - ` GITHUB_PR_RELEASE_TOKEN `
42+ - ` GITHUB_PR_RELEASE_HEAD `
43+ - ` GITHUB_PR_RELEASE_BASE `
44+ - ` GITHUB_PR_RELEASE_ENDPOINT `
3645
37- See: https://developer.github.com/v3/pulls/#get-a-single-pull-request
3846
3947## Install
4048```
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ const yargs = require ( 'yargs/yargs' )
4+ const { hideBin } = require ( 'yargs/helpers' )
5+ const argv = yargs ( hideBin ( process . argv ) )
6+ . usage ( 'Usage: $0 [repo]' )
7+ . example ( '$0 uiur/github-pr-release --head master --base production' , '' )
8+ . demandCommand ( 1 )
9+ . default ( 'head' , 'master' )
10+ . default ( 'base' , 'production' )
11+ . argv
12+
13+ const createReleasePR = require ( '../' )
14+
15+ async function main ( ) {
16+ const repoInput = argv . _ [ 0 ]
17+ const [ owner , repo ] = repoInput . split ( '/' )
18+ const config = {
19+ owner,
20+ repo,
21+ head : argv . head ,
22+ base : argv . base
23+ }
24+
25+ const pullRequest = await createReleasePR ( config )
26+
27+ console . log ( pullRequest . html_url )
28+ }
29+
30+ main ( ) . catch ( err => {
31+ console . error ( err )
32+ process . exit ( 1 )
33+ } )
Original file line number Diff line number Diff line change 1- var request = require ( 'request' )
2- var Promise = require ( 'es6-promise' ) . Promise
3- var parseLinkHeader = require ( 'parse-link-header' )
1+ const request = require ( 'request' )
2+ const Promise = require ( 'es6-promise' ) . Promise
3+ const parseLinkHeader = require ( 'parse-link-header' )
44
55function GithubClient ( config ) {
6- this . owner = config . owner
7- this . repo = config . repo
8- this . token = config . token
9- this . head = config . head || 'master'
10- this . base = config . base || 'production'
11- this . endpoint = config . endpoint || 'https://api.github.com'
6+ this . owner = config . owner || process . env . GITHUB_PR_RELEASE_OWNER
7+ this . repo = config . repo || process . env . GITHUB_PR_RELEASE_REPO
8+ this . token = config . token || process . env . GITHUB_PR_RELEASE_TOKEN
9+ this . head = config . head || process . env . GITHUB_PR_RELEASE_HEAD || 'master'
10+ this . base = config . base || process . env . GITHUB_PR_RELEASE_BASE || 'production'
11+ this . endpoint = config . endpoint || process . env . GITHUB_PR_RELEASE_ENDPOINT || 'https://api.github.com'
1212}
1313
1414GithubClient . prototype . pullRequestEndpoint = function ( ) {
Original file line number Diff line number Diff line change 33 "version" : " 1.3.2" ,
44 "description" : " Create a release pull request by Github API" ,
55 "main" : " index.js" ,
6+ "bin" : {
7+ "github-pr-release" : " cli/index.js"
8+ },
69 "author" : " Kazato Sugimoto" ,
710 "license" : " MIT" ,
811 "scripts" : {
1720 "moment" : " ^2.9.0" ,
1821 "mustache" : " ^3.0.1" ,
1922 "parse-link-header" : " ^0.2.0" ,
20- "request" : " ^2.58.0"
23+ "request" : " ^2.58.0" ,
24+ "yargs" : " ^17.3.1"
2125 },
2226 "devDependencies" : {
2327 "espower-loader" : " ^1.2.2" ,
You can’t perform that action at this time.
0 commit comments