Skip to content
This repository was archived by the owner on May 20, 2020. It is now read-only.

Commit b7f97fe

Browse files
author
Adam Braimbridge
authored
Merge pull request #49 from Financial-Times/refactor-projects
Add support for Projects
2 parents 858ae5b + ce34cee commit b7f97fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1840
-1777
lines changed

.editorconfig

-21
This file was deleted.

.eslintrc.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,40 @@ const config = {
22
env: {
33
es6: true,
44
node: true,
5-
jest: true
5+
jest: true,
66
},
77
parserOptions: {
88
ecmaVersion: 2017,
9-
sourceType: "module",
10-
ecmaVersion: 2018
9+
sourceType: 'module',
10+
ecmaVersion: 2018,
1111
},
1212
rules: {
1313
eqeqeq: 2,
14-
"guard-for-in": 2,
15-
"new-cap": 0,
16-
"no-caller": 2,
17-
"no-console": 2,
18-
"no-extend-native": 2,
19-
"no-irregular-whitespace": 2,
20-
"no-loop-func": 2,
21-
"no-undef": 2,
22-
"no-underscore-dangle": 0,
23-
"no-unused-vars": 2,
24-
"no-var": 2,
25-
"one-var": [2, "never"]
14+
'guard-for-in': 2,
15+
'new-cap': 0,
16+
'no-caller': 2,
17+
'no-console': 0,
18+
'no-extend-native': 2,
19+
'no-irregular-whitespace': 2,
20+
'no-loop-func': 2,
21+
'no-undef': 2,
22+
'no-underscore-dangle': 0,
23+
'no-unused-vars': 2,
24+
'no-var': 2,
25+
'one-var': [2, 'never'],
2626
},
2727
globals: {},
28-
plugins: ["no-only-tests"],
29-
extends: ["prettier"],
28+
plugins: ['no-only-tests'],
29+
extends: ['plugin:prettier/recommended'],
3030
overrides: [
3131
{
32-
files: ["test/**/*.js"],
32+
files: ['test/**/*.js'],
3333
rules: {
34-
"no-only-tests/no-only-tests": 2
35-
}
36-
}
34+
'no-only-tests/no-only-tests': 2,
35+
},
36+
},
3737
],
38-
settings: {}
39-
};
38+
settings: {},
39+
}
4040

41-
module.exports = config;
41+
module.exports = config

LICENSE

-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1818
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1919
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
2020
OR OTHER DEALINGS IN THE SOFTWARE.
21-

README.md

+192-31
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,222 @@
11
# GitHub Command Line Tool
22

3-
Human-friendly command line tool for the GitHub API.
3+
A human-friendly<sup>1</sup> command line tool for the GitHub API.
44

5-
## Usage
5+
<sup>1</sup> script-friendly too :)
66

7-
### Command Line Tool
7+
![image](https://user-images.githubusercontent.com/224547/57020759-3b3c3480-6c22-11e9-8907-565a929d3cd9.png)
88

9-
#### Install globally (recommmended)
9+
## Installation
1010

11-
```shell
11+
### Global installation (recommmended)
12+
13+
```bash
1214
npm install --global @financial-times/github
15+
```
16+
17+
When you run the tool, it will automatically notify you if there is a newer version of it available for you to update to.
1318

14-
github --help
19+
[You can disable notifications](https://www.npmjs.com/package/update-notifier#user-settings) if you'd prefer not to be notified about updates.
20+
21+
### No installation
22+
23+
```bash
24+
npx @financial-times/github
1525
```
1626

17-
When you run the tool it will automatically notify you if there is a newer
18-
version of it available for you to update to. This
19-
[can be disabled](https://www.npmjs.com/package/update-notifier#user-settings)
20-
if you'd prefer not to be notified about updates.
27+
The `npx` command lets you use this tool without installing it. However, each time you use `npx` it downloads the whole package from the npm registry, which takes a while. That's why global installation is reccommended.
2128

22-
Note: If you install this tool globally on your machine and then run
23-
`npx @financial-times/github`, it will use the globally installed version of the
24-
tool rather than temporarily installing it from the npm registry.
29+
> Note: If this tool is globally installed, `npx @financial-times/github` will use that globally installed version rather than downloading.
2530
26-
#### No installation
31+
## Commands
2732

28-
If you just want to try this tool out without installing it, you can run it with
29-
[`npx`](https://www.npmjs.com/package/npx) e.g.
33+
```bash
34+
github
3035

31-
```shell
32-
npx @financial-times/github --help
36+
# Display help.
3337
```
3438

35-
### Library
39+
```bash
40+
github <command>
3641

42+
# Display help for the command.
3743
```
38-
npm install @financial-times/github
44+
45+
```bash
46+
github --version
47+
48+
# Show the version number.
49+
```
50+
51+
### Working with GitHub Projects
52+
53+
```bash
54+
github add-pull-request [--column-url] [--pull-request-url]
55+
56+
# Add a pull request to a GitHub project column.
3957
```
4058

41-
```javascript
42-
const github = require("@financial-times/github")({
43-
personalAccessToken: process.env.GITHUB_PERSONAL_ACCESS_TOKEN
44-
});
59+
```bash
60+
github close-project <github-url>
61+
62+
# Set the state of an existing project board to `closed`.
63+
```
64+
65+
```bash
66+
github create-project <github-url> [--body]
67+
68+
# Create a new project.
69+
```
70+
71+
@see: [`src/commands/projects/README.md`](https://github.com/Financial-Times/github/blob/master/src/commands/projects/README.md) for more details.
72+
73+
### Working with GitHub Pull Requests
74+
75+
```bash
76+
github close-pull-request <github-url>
77+
78+
# Set the state of an existing pull request to `closed`.
79+
```
80+
81+
```bash
82+
github create-comment <github-url> [--body]
83+
84+
# Create a comment on an existing pull request.
85+
```
86+
87+
```bash
88+
github create-review-request <github-url> [reviewers|team-reviewers]
89+
90+
# Request a review for a pull request.
91+
```
92+
93+
```bash
94+
github create-pull-request <github-url> [--base] [--body] [--title]
95+
96+
# Create a new pull request.
97+
```
98+
99+
```bash
100+
github delete-comment <github-url>
101+
102+
# Delete a comment on an existing pull request.
103+
```
104+
105+
```bash
106+
github delete-review-request <github-url> [reviewers|team-reviewers]
107+
108+
# Delete a review for a pull request.
109+
```
110+
111+
```bash
112+
github merge-pull-request <github-url> [--method]
113+
114+
# Merge an existing pull request.
115+
```
116+
117+
```bash
118+
github open-pull-request <github-url>
119+
120+
# Set the state of an existing pull request to `open`.
121+
```
122+
123+
@see: [`src/commands/pulls/README.md`](https://github.com/Financial-Times/github/blob/master/src/commands/pulls/README.md) for more details.
124+
125+
### Global Options
126+
127+
```bash
128+
--json
129+
130+
# Format command output as JSON string.
131+
```
132+
133+
```bash
134+
--token
135+
136+
# GitHub personal access token.
137+
# Generate one at https://github.com/settings/tokens
138+
```
139+
140+
> Note: You can omit the `--token` argument, because it will default to `$GITHUB_PERSONAL_ACCESS_TOKEN`.
141+
>
142+
> In that case you will need to export the token to your environment:
143+
144+
```bash
145+
export $GITHUB_PERSONAL_ACCESS_TOKEN=[your token here]
45146
```
46147

47148
# Developers
48149

49150
## Command hierarchy and directory structure
50151

51-
This project follows the example provided in the Yargs documentation for command hierarchy and directory structure.
152+
This project loosely follows the example provided in the Yargs documentation for command hierarchy and directory structure.
153+
154+
- @see: https://github.com/yargs/yargs/blob/master/docs/advanced.md#commanddirdirectory-opts
155+
- @see: [`bin/github.js`](https://github.com/Financial-Times/github/blob/master/bin/github.js) for the root `github` command.
156+
- @see: [`src/commands`](https://github.com/Financial-Times/github/blob/master/src/commands/) for the `github <command>` commands.
157+
158+
## Conventions
159+
160+
### CamelCase, hyphen-case and under_scores
161+
162+
- All yargs commands and filenames are in `hyphen-case`.
163+
- All function names and variables are in `camelCase`.
164+
- The parameters used by Octokit are in `under_score` format.
165+
166+
### Code formatting and linting
167+
168+
- The [.eslintrc.js](https://github.com/Financial-Times/github/blob/master/.eslintrc.js) file contains the settings for code linting.
169+
170+
- @see: https://eslint.org/
171+
172+
- Consider installing `eslint` in your editor. Plugins are available for most popular editors.
173+
174+
- @see: https://eslint.org/docs/user-guide/integrations#editors
52175

53-
- @see: https://github.com/yargs/yargs/blob/master/docs/advanced.md#commanddirdirectory-opts
54-
- @see: [`src/commands`](https://github.com/Financial-Times/github/blob/master/src/commands/) for all available commands.
176+
- Note: `.eslintrc.js` extends the `prettier` tool, which applies code formatting rules.
55177

56-
## Conventions: CamelCase and under_scores
178+
- @see: https://prettier.io/docs/en/integrating-with-linters.html
57179

58-
All commands and variables are consistent with the Ocktokit and GitHub APIs documentation, respectively:
180+
- You can `npm run eslint-check` to check there are no conflicts between eslint and prettier configurations.
59181

60-
- https://octokit.github.io/rest.js/#api-Pulls <-- Instead of camelCaseFormat, we use hyphen-format.
61-
- https://developer.github.com/v3/pulls <-- Variables are under_score_format.
182+
- @see: https://github.com/prettier/eslint-config-prettier#cli-helper-tool
183+
184+
- The `prettier` tool uses the "@adambraimbridge/prettierrc-2019-05" configuration.
185+
186+
- @see: https://www.npmjs.com/package/@adambraimbridge/prettierrc-2019-05
187+
188+
- Consider installing `prettier` in your editor. Plugins are available for most popular editors.
189+
190+
- @see: https://prettier.io/docs/en/editors.html
191+
192+
## Package.json scripts
193+
194+
```bash
195+
npm run unit-test
196+
197+
# jest --coverage
198+
```
199+
200+
```bash
201+
npm run test
202+
203+
# npm run lint && npm run unit-test
204+
```
205+
206+
```bash
207+
npm run lint
208+
209+
# eslint src/ bin/ test/
210+
```
211+
212+
```bash
213+
npm run lint-fix
214+
215+
# eslint --fix eslint --fix src/ bin/ test/
216+
```
217+
218+
```bash
219+
npm run eslint-check
220+
221+
# eslint --print-config . | eslint-config-prettier-check
222+
```

0 commit comments

Comments
 (0)