cli-github 1.8.18 → 1.8.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-20 Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)
3
+ Copyright (c) 2014-26 Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,17 +1,5 @@
1
1
  <!-- Please do not edit this file. Edit the `blah` field in the `package.json` instead. If in doubt, open an issue. -->
2
2
 
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
3
  ```
16
4
  CLI GitHub
17
5
  A fancy GitHub client for command line.
@@ -47,45 +35,13 @@
47
35
  .;1tt1i: :;;: ,i11i..;;;. :;;; :1t1i,.;;. ;;:.;111;
48
36
  ```
49
37
 
50
-
51
-
52
-
53
-
54
-
55
-
56
38
  # `$ cli-github`
57
39
 
58
- [![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [![Ask me anything](https://img.shields.io/badge/ask%20me-anything-1abc9c.svg)](https://github.com/IonicaBizau/ama) [![Version](https://img.shields.io/npm/v/cli-github.svg)](https://www.npmjs.com/package/cli-github) [![Downloads](https://img.shields.io/npm/dt/cli-github.svg)](https://www.npmjs.com/package/cli-github) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)
40
+ [![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [![Ask me anything](https://img.shields.io/badge/ask%20me-anything-1abc9c.svg)](https://github.com/IonicaBizau/ama) [![Version](https://img.shields.io/npm/v/cli-github.svg)](https://www.npmjs.com/package/cli-github) [![Downloads](https://img.shields.io/npm/dt/cli-github.svg)](https://www.npmjs.com/package/cli-github) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/@johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)
59
41
 
60
42
  <a href="https://www.buymeacoffee.com/H96WwChMy" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png" alt="Buy Me A Coffee"></a>
61
43
 
62
-
63
-
64
-
65
-
66
-
67
-
68
44
  > A fancy GitHub client for command line.
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
45
 
90
46
  ## Prerequisites
91
47
 
@@ -165,102 +121,38 @@ Use the following key shortcuts to access different GitHub resources:
165
121
  ### Pull Requests
166
122
 
167
123
  ![](/screenshots/pull-requests.png "")
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
124
  ## :question: Get Help
186
125
 
187
- There are few ways to get help:
126
+ There are a few ways to get help:
188
127
 
189
-
190
-
191
- 1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question.
128
+ 1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long as you add a link to your Stack Overflow question.
192
129
  2. For bug reports and feature requests, open issues. :bug:
193
130
  3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:
194
131
 
132
+ ## :yum: How to Contribute
195
133
 
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
209
-
210
- ## :yum: How to contribute
211
134
  Have an idea? Found a bug? See [how to contribute][contributing].
212
135
 
136
+ ## :sparkling_heart: Support My Projects
213
137
 
214
- ## :sparkling_heart: Support my projects
215
- I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously,
216
- this takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute (even resell it).
217
-
218
- However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:
138
+ I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute it (even resell it).
219
139
 
140
+ However, if you get some profit from this or just want to encourage me to continue creating stuff, there are a few ways you can do it:
220
141
 
221
142
  - Starring and sharing the projects you like :rocket:
222
- - [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you after years if you buy me one. :grin: :book:
143
+ - [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you for years if you buy me one. :grin: :book:
223
144
  - [![PayPal][badge_paypal]][paypal-donations]—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:
224
145
  - [![Support me on Patreon][badge_patreon]][patreon]—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).
225
- - **Bitcoin**—You can send me bitcoins at this address (or scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`
226
-
227
- ![](https://i.imgur.com/z6OQI95.png)
146
+ - **Bitcoin**—You can send me bitcoins at this address (or by scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`
228
147
 
148
+ ![Bitcoin QR code](https://i.imgur.com/z6OQI95.png)
229
149
 
230
150
  Thanks! :heart:
231
151
 
232
-
233
-
234
-
235
-
236
-
237
-
238
-
239
-
240
-
241
-
242
-
243
-
244
-
245
-
246
-
247
-
248
-
249
-
250
-
251
-
252
-
253
-
254
-
255
152
  ## :scroll: License
256
153
 
257
154
  [MIT][license] © [Ionică Bizău][website]
258
155
 
259
-
260
-
261
-
262
-
263
-
264
156
  [license]: /LICENSE
265
157
  [website]: https://ionicabizau.net
266
158
  [contributing]: /CONTRIBUTING.md
@@ -270,5 +162,5 @@ Thanks! :heart:
270
162
  [badge_paypal]: https://ionicabizau.github.io/badges/paypal.svg
271
163
  [badge_paypal_donate]: https://ionicabizau.github.io/badges/paypal_donate.svg
272
164
  [patreon]: https://www.patreon.com/ionicabizau
273
- [amazon]: http://amzn.eu/hRo9sIZ
165
+ [amazon]: https://amzn.eu/hRo9sIZ
274
166
  [paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW
package/lib/api/login.js CHANGED
@@ -1,18 +1,17 @@
1
- "use strict";
2
-
3
1
  // Dependencies
4
- var Config = require("../conf"),
5
- Fs = require("fs"),
6
- idy = require("idy");
2
+ var Config = require("../conf")
3
+ , Fs = require("fs")
4
+ , idy = require("idy")
5
+ ;
7
6
 
8
7
  // 2FA OTP Scheme
9
8
  var otpScheme = {
10
9
  properties: {
11
10
  otp: {
12
- required: true,
13
- message: "Invalid 2FA authentication code.",
14
- description: "",
15
- type: "number"
11
+ required: true
12
+ , message: "Invalid 2FA authentication code."
13
+ , description: ""
14
+ , type: "number"
16
15
  }
17
16
  }
18
17
  };
@@ -36,8 +35,8 @@ var login = module.exports = function (callback) {
36
35
 
37
36
  if (Config.token) {
38
37
  Config._github.authenticate({
39
- type: "oauth",
40
- token: Config.token
38
+ type: "oauth"
39
+ , token: Config.token
41
40
  });
42
41
  } else {
43
42
  if (!Config.username || !Config.password) {
@@ -47,15 +46,20 @@ var login = module.exports = function (callback) {
47
46
  }
48
47
 
49
48
  Config._github.authenticate({
50
- type: "basic",
51
- username: Config.username,
52
- password: Config.password
49
+ type: "basic"
50
+ , username: Config.username
51
+ , password: Config.password
53
52
  });
54
53
 
55
54
  var opts = {
56
- note: "CLI GitHub :: " + idy(),
57
- note_url: "https://github.com/IonicaBizau/cli-github",
58
- scopes: ["user", "public_repo", "repo", "repo_deployment", "repo:status", "delete_repo", "notifications", "read:org", "write:org", "admin:org"]
55
+ note: "CLI GitHub :: " + idy()
56
+ , note_url: "https://github.com/IonicaBizau/cli-github"
57
+ , scopes: [
58
+ "user", "public_repo", "repo"
59
+ , "repo_deployment", "repo:status"
60
+ , "delete_repo", "notifications"
61
+ , "read:org", "write:org", "admin:org"
62
+ ]
59
63
  };
60
64
 
61
65
  if (Config.otp) {
@@ -74,10 +78,8 @@ var login = module.exports = function (callback) {
74
78
  if (!err) {
75
79
  Config.token = res.token;
76
80
  if (JSON.stringify(res.scopes) !== JSON.stringify(opts.scopes)) {
77
- Config._github.authorization.delete({ id: res.id }, function (err) {
78
- if (err) {
79
- return callback(err);
80
- }
81
+ Config._github.authorization.delete({id: res.id}, function (err) {
82
+ if (err) { return callback(err); }
81
83
  Config._github.authorization.create(opts, function (err, res) {
82
84
  if (err) return callback(err);
83
85
  Config.token = res.token;
@@ -96,6 +98,7 @@ var login = module.exports = function (callback) {
96
98
  error = err.toString();
97
99
  }
98
100
 
101
+
99
102
  if (error.indexOf("Must specify two-factor authentication OTP code.") !== -1 && !Config.otp) {
100
103
  while (!(Config.otp = Config.prompt("2FA Authentication Code"))) {}
101
104
  login(callback);
@@ -115,10 +118,10 @@ var login = module.exports = function (callback) {
115
118
  }
116
119
 
117
120
  Fs.writeFileSync(Config.CONFIG_PATH, JSON.stringify({
118
- username: Config.username,
119
- token: Config.token
121
+ username: Config.username
122
+ , token: Config.token
120
123
  }));
121
124
 
122
125
  callback(null, user);
123
126
  });
124
- };
127
+ };
@@ -1,8 +1,7 @@
1
- "use strict";
2
-
3
1
  // Dependencies
4
- var Config = require("../conf"),
5
- Request = require("request");
2
+ var Config = require("../conf")
3
+ , Request = require("request")
4
+ ;
6
5
 
7
6
  /**
8
7
  * Profile
@@ -26,34 +25,28 @@ module.exports = function (options, progress, callback) {
26
25
  var user = options.username || options;
27
26
  Request.get({
28
27
  headers: {
29
- "user-agent": "GitHub - CLI",
30
- "Authorization": "token " + Config.token
31
- },
32
- url: "https://api.github.com/users/" + user,
33
- json: true
34
- }, function (err, status, body) {
35
- if (err || body.error) {
36
- return callback(err || body.error);
28
+ "user-agent": "GitHub - CLI"
29
+ , "Authorization": "token " + Config.token
37
30
  }
31
+ , url: "https://api.github.com/users/" + user
32
+ , json: true
33
+ }, function (err, status, body) {
34
+ if (err || body.error) { return callback(err || body.error); }
38
35
  progress(null, "Fetching repositories ...");
39
36
  Config._github.repos.getForUser({
40
- username: user,
41
- sort: "updated"
37
+ username: user
38
+ , sort: "updated"
42
39
  }, function (err, repos) {
43
- if (err) {
44
- return callback(err);
45
- }
40
+ if (err) { return callback(err); }
46
41
  body.repos = repos;
47
42
  progress(null, "Fetching organizations ...");
48
43
  Config._github.orgs.getForUser({
49
44
  username: user
50
45
  }, function (err, orgs) {
51
- if (err) {
52
- return callback(err);
53
- }
46
+ if (err) { return callback(err); }
54
47
  body.orgs = orgs;
55
48
  callback(null, body);
56
49
  });
57
50
  });
58
51
  });
59
- };
52
+ };
package/lib/api/stream.js CHANGED
@@ -1,22 +1,21 @@
1
- "use strict";
2
-
3
1
  // Dependencies
4
- var Config = require("../conf"),
5
- Request = require("request"),
6
- Couleurs = require("couleurs"),
7
- Moment = require("moment"),
8
- ParseXML = require('xml2js').parseString;
2
+ var Config = require("../conf")
3
+ , Request = require("request")
4
+ , Couleurs = require("couleurs")
5
+ , Moment = require("moment")
6
+ , ParseXML = require('xml2js').parseString
7
+ ;
9
8
 
10
9
  // Icons! :-)
11
10
  var icons = {
12
- "CreateEvent": "⊕",
13
- "WatchEvent": "★",
14
- "PushEvent": "─●─",
15
- "ForkEvent": "⑂",
16
- "PullRequestEvent": "⇑",
17
- "DeleteEvent": "⊗",
18
- "ReleaseEvent": "⌗",
19
- "IssuesEvent": "⚠"
11
+ "CreateEvent": "⊕"
12
+ , "WatchEvent": "★"
13
+ , "PushEvent": "─●─"
14
+ , "ForkEvent": "⑂"
15
+ , "PullRequestEvent": "⇑"
16
+ , "DeleteEvent": "⊗"
17
+ , "ReleaseEvent": "⌗"
18
+ , "IssuesEvent": "⚠"
20
19
  };
21
20
 
22
21
  /**
@@ -33,31 +32,27 @@ module.exports = function (callback) {
33
32
  Request.get({
34
33
  headers: {
35
34
  "user-agent": "GitHub - CLI"
36
- },
37
- auth: {
38
- username: Config.username,
39
- password: Config.token
40
- },
41
- url: "https://github.com/" + Config.username + ".private.atom"
42
- }, function (err, status, body) {
43
- if (err || body.error) {
44
- return callback(err || body.error);
45
35
  }
36
+ , auth: {
37
+ username: Config.username
38
+ , password: Config.token
39
+ }
40
+ , url: "https://github.com/" + Config.username + ".private.atom"
41
+ }, function (err, status, body) {
42
+ if (err || body.error) { return callback(err || body.error); }
46
43
  // TODO Body is ' '
47
44
  ParseXML(body, function (err, result) {
48
- if (err) {
49
- return callback(err);
50
- }
45
+ if (err) { return callback(err); }
51
46
  var streamData = [];
52
47
  for (var i = 0; i < result.feed.entry.length; ++i) {
53
48
  var cEv = result.feed.entry[i];
54
49
  streamData.push({
55
- icon: icons[cEv.id[0].split(/:|\//)[2]] || " ",
56
- description: cEv.title[0]._,
57
- time: Moment(cEv.updated[0]).fromNow()
50
+ icon: icons[cEv.id[0].split(/:|\//)[2]] || " "
51
+ , description: cEv.title[0]._
52
+ , time: Moment(cEv.updated[0]).fromNow()
58
53
  });
59
54
  }
60
55
  callback(null, streamData);
61
56
  });
62
57
  });
63
- };
58
+ };
@@ -1,9 +1,8 @@
1
- "use strict";
2
-
3
1
  // Dependencies
4
- var Config = require("../conf"),
5
- Request = require("request"),
6
- QueryString = require("querystring");
2
+ var Config = require("../conf")
3
+ , Request = require("request")
4
+ , QueryString = require("querystring")
5
+ ;
7
6
 
8
7
  /*!
9
8
  * getAll
@@ -23,15 +22,13 @@ function getAll(url, callback, progress, i, data) {
23
22
  i = i || 1;
24
23
  Request.get({
25
24
  headers: {
26
- "user-agent": "GitHub - CLI",
27
- "Authorization": "token " + Config.token
28
- },
29
- json: true,
30
- url: url + "&page=" + i
31
- }, function (err, status, body) {
32
- if (err || body.error) {
33
- return callback(err || body.error);
25
+ "user-agent": "GitHub - CLI"
26
+ , "Authorization": "token " + Config.token
34
27
  }
28
+ , json: true
29
+ , url: url + "&page=" + i
30
+ }, function (err, status, body) {
31
+ if (err || body.error) { return callback(err || body.error); }
35
32
  data = data.concat(body.items);
36
33
  if (!body.items.length) {
37
34
  return callback(null, data);
@@ -59,9 +56,7 @@ function getAll(url, callback, progress, i, data) {
59
56
  module.exports = function (options, progress, callback) {
60
57
  options = Object(options);
61
58
  getAll("https://api.github.com/search/issues?" + QueryString.stringify(options.ops), function (err, res) {
62
- if (err) {
63
- return callback(err);
64
- }
59
+ if (err) { return callback(err); }
65
60
  callback(null, res);
66
61
  }, progress);
67
- };
62
+ };
@@ -1,9 +1,8 @@
1
- "use strict";
2
-
3
1
  // Dependencies
4
- var Config = require("../conf"),
5
- Request = require("request"),
6
- QueryString = require("querystring");
2
+ var Config = require("../conf")
3
+ , Request = require("request")
4
+ , QueryString = require("querystring")
5
+ ;
7
6
 
8
7
  /**
9
8
  * UserIssues
@@ -22,18 +21,18 @@ var Config = require("../conf"),
22
21
  module.exports = function (options, callback) {
23
22
  if (options.type === "followers") {
24
23
  return Config._github.users.getFollowersForUser({
25
- username: options.user,
26
- per_page: 100
24
+ username: options.user
25
+ , per_page: 100
27
26
  }, callback);
28
27
  } else if (options.type === "following") {
29
28
  return Config._github.users.getFollowingForUser({
30
- username: options.user,
31
- per_page: 100
29
+ username: options.user
30
+ , per_page: 100
32
31
  }, callback);
33
32
  } else if (options.type === "members") {
34
33
  return Config._github.orgs.getMembers({
35
- org: options.user,
36
- per_page: 100
34
+ org: options.user
35
+ , per_page: 100
37
36
  }, callback);
38
37
  }
39
- };
38
+ };
package/lib/conf/index.js CHANGED
@@ -1,27 +1,27 @@
1
- "use strict";
2
-
3
1
  // Dependencies
4
2
  var Path = require("path");
5
3
 
6
4
  // Constants
7
- var HOME_DIRECTORY = process.env[process.platform == "win32" ? "USERPROFILE" : "HOME"];
5
+ const HOME_DIRECTORY = process.env[
6
+ process.platform == "win32" ? "USERPROFILE" : "HOME"
7
+ ];
8
8
 
9
9
  process.stdout.columns = process.stdout.columns || 212;
10
10
  process.stdout.rows = process.stdout.rows || 56;
11
11
 
12
12
  // Configuration
13
13
  module.exports = {
14
- root: Path.resolve(__dirname, "../.."),
15
- cli: {
16
- w: process.stdout.columns,
17
- h: process.stdout.rows
18
- },
19
- cache: {
14
+ root: Path.resolve(__dirname, "../..")
15
+ , cli: {
16
+ w: process.stdout.columns
17
+ , h: process.stdout.rows
18
+ }
19
+ , cache: {
20
20
  avatars: {}
21
- },
22
- promptRunning: false,
23
- HOMDE_DIR: HOME_DIRECTORY,
24
- CONFIG_PATH: HOME_DIRECTORY + "/.github-config.json",
25
- title: "CLI GitHub - A fancy GitHub client.",
26
- description: "</> with <3 by @IonicaBizau"
27
- };
21
+ }
22
+ , promptRunning: false
23
+ , HOMDE_DIR: HOME_DIRECTORY
24
+ , CONFIG_PATH: HOME_DIRECTORY + "/.github-config.json"
25
+ , title: "CLI GitHub - A fancy GitHub client."
26
+ , description: "</> with <3 by @IonicaBizau"
27
+ };