Skip to content

Commit 080d6d1

Browse files
committed
Add documentation
1 parent 196a6c2 commit 080d6d1

File tree

7 files changed

+273
-17
lines changed

7 files changed

+273
-17
lines changed

.gitignore

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/node
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=node
3+
4+
### Node ###
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage
33+
# (https://gruntjs.com/creating-plugins#storing-task-files)
34+
.grunt
35+
36+
# Bower dependency directory (https://bower.io/)
37+
bower_components
38+
39+
# node-waf configuration
40+
.lock-wscript
41+
42+
# Compiled binary addons (https://nodejs.org/api/addons.html)
43+
build/Release
44+
45+
# Dependency directories
46+
node_modules/
47+
jspm_packages/
48+
49+
# TypeScript v1 declaration files
50+
typings/
51+
52+
# TypeScript cache
53+
*.tsbuildinfo
54+
55+
# Optional npm cache directory
56+
.npm
57+
58+
# Optional eslint cache
59+
.eslintcache
60+
61+
# Optional stylelint cache
62+
.stylelintcache
63+
64+
# Microbundle cache
65+
.rpt2_cache/
66+
.rts2_cache_cjs/
67+
.rts2_cache_es/
68+
.rts2_cache_umd/
69+
70+
# Optional REPL history
71+
.node_repl_history
72+
73+
# Output of 'npm pack'
74+
*.tgz
75+
76+
# Yarn Integrity file
77+
.yarn-integrity
78+
79+
# dotenv environment variables file
80+
.env
81+
.env.test
82+
.env*.local
83+
84+
# parcel-bundler cache (https://parceljs.org/)
85+
.cache
86+
.parcel-cache
87+
88+
# Next.js build output
89+
.next
90+
91+
# Nuxt.js build / generate output
92+
.nuxt
93+
dist
94+
95+
# Gatsby files
96+
.cache/
97+
# Comment in the public line in if your project uses Gatsby and not Next.js
98+
# https://nextjs.org/blog/next-9-1#public-directory-support
99+
# public
100+
101+
# vuepress build output
102+
.vuepress/dist
103+
104+
# Serverless directories
105+
.serverless/
106+
107+
# FuseBox cache
108+
.fusebox/
109+
110+
# DynamoDB Local files
111+
.dynamodb/
112+
113+
# TernJS port file
114+
.tern-port
115+
116+
# Stores VSCode versions used for testing VSCode extensions
117+
.vscode-test
118+
119+
# End of https://www.toptal.com/developers/gitignore/api/node

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Danny Feliz
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# open-pr
2+
3+
open-pr is a CLI that allows you to open the URL to create a pull request pointing to the base branch in Github.
4+
5+
## Installation
6+
7+
Use npm or yarn to install open-pr.
8+
9+
```bash
10+
# npm
11+
npm install @dannyfeliz/open-pr --global
12+
13+
# yarn
14+
yarn add @dannyfeliz/open-pr --global
15+
```
16+
17+
## Usage
18+
19+
```
20+
// in the terminal in your project folder
21+
open-pr
22+
```
23+
24+
It will open an URL to create a new pull request pointing to the base branch.
25+
26+
e.g.
27+
if you have the `linux` project and you're working in a cool feature like `my-cool-feature` and the project origin url is `[email protected]:torvalds/linux.git` if you run `open-pr` it will open this URL
28+
29+
```bash
30+
https://github.com/torvalds/linux/compare/my-cool-feature?expand=1
31+
```
32+
33+
## Contributing
34+
35+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
36+
37+
## License
38+
39+
[MIT](https://choosealicense.com/licenses/mit/)

open-pr.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env node
2+
const util = require('util');
3+
const exec = util.promisify(require('child_process').exec);
4+
const gitRemoteOriginUrl = require('git-remote-origin-url');
5+
const open = require('open');
6+
7+
async function generateLink() {
8+
try {
9+
const { stdout, stderr } = await exec('git rev-parse --abbrev-ref HEAD');
10+
if (stderr) {
11+
throw stderr;
12+
}
13+
14+
const branchName = stdout.trim();
15+
const remoteOriginUrl = await gitRemoteOriginUrl();
16+
const newPullRequestUrl = `https://${remoteOriginUrl.replace("git@", "").replace(":", "/").replace(/\.git$/, "")}/pull/new/${branchName}`;
17+
18+
await open(newPullRequestUrl);
19+
} catch (error) {
20+
throw error;
21+
}
22+
}
23+
24+
generateLink();

package-lock.json

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
{
2-
"name": "open-pr",
2+
"name": "@dannyfeliz/open-pr",
33
"version": "1.0.0",
4-
"description": "",
5-
"main": "index.js",
6-
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
8-
},
9-
"keywords": [],
4+
"description": "Allow to open the URL to create a pull request pointing to the base branch",
5+
"keywords": [
6+
"github",
7+
"git",
8+
"create pull request",
9+
"create pr",
10+
"open pr",
11+
"pr",
12+
"pull request"
13+
],
1014
"author": "Danny Feliz <[email protected]>",
11-
"license": "ISC"
15+
"license": "MIT",
16+
"dependencies": {
17+
"git-remote-origin-url": "^3.1.0",
18+
"open": "^7.4.0"
19+
},
20+
"bin": {
21+
"open-pr": "./script.js"
22+
}
1223
}

script.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)