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.
@@ -1,59 +1,57 @@
1
- "use strict";
2
-
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
-
5
- var Config = require("./conf"),
6
- Profile = require(Config.root + "/lib/ui/profile"),
7
- Overlap = require("overlap"),
8
- Keypress = require("keypress"),
9
- Box = require("cli-box");
1
+ var Config = require("./conf")
2
+ , Profile = require(Config.root + "/lib/ui/profile")
3
+ , Overlap = require("overlap")
4
+ , Keypress = require("keypress")
5
+ , Box = require("cli-box")
6
+ ;
10
7
 
11
8
  var Handlers = module.exports = {};
12
9
 
13
10
  var Dialog = {
14
- show: function show(message) {
11
+ show: function (message) {
15
12
  var old = Config.cache._currentScreen;
16
13
  if (!message) {
17
14
  return Config.cli.update.render("\n" + old, false, {}, false);
18
15
  }
19
16
 
20
17
  var box = Box({
21
- w: 50,
22
- h: 5,
23
- marks: {
24
- nw: "╔",
25
- n: "═",
26
- ne: "╗",
27
- e: "║",
28
- se: "╝",
29
- s: "═",
30
- sw: "╚",
31
- w: "║",
32
- b: " "
18
+ w: 50
19
+ , h: 5
20
+ , marks: {
21
+ nw: "╔"
22
+ , n: "═"
23
+ , ne: "╗"
24
+ , e: "║"
25
+ , se: "╝"
26
+ , s: "═"
27
+ , sw: "╚"
28
+ , w: "║"
29
+ , b: " "
33
30
  }
34
31
  }, {
35
- text: message,
36
- stretch: true,
37
- autoEOL: true,
38
- hAlign: "center",
39
- vAlign: "middle"
32
+ text: message
33
+ , stretch: true
34
+ , autoEOL: true
35
+ , hAlign: "center"
36
+ , vAlign: "middle"
40
37
  });
41
38
 
42
39
  var newS = Overlap({
43
- who: old,
44
- with: box,
45
- where: {
46
- x: Math.floor(old.split("\n")[0].length / 2 - box.split("\n")[0].length / 2 - 1),
47
- y: Math.floor(old.split("\n").length / 2 - box.split("\n").length / 2)
40
+ who: old
41
+ , with: box
42
+ , where: {
43
+ x: Math.floor(old.split("\n")[0].length / 2 - box.split("\n")[0].length / 2 - 1)
44
+ , y: Math.floor(old.split("\n").length / 2 - box.split("\n").length / 2)
48
45
  }
49
46
  }).trim();
50
47
  Config.cli.update.render(newS, false, {}, false);
51
48
  }
52
49
  };
53
50
 
51
+
54
52
  Handlers["news-feed"] = {
55
53
  // Create repository
56
- "C": function C() {
54
+ "C": function () {
57
55
  Dialog.show("Waiting for user input ...");
58
56
  Config.promptRunning = true;
59
57
  var result = {};
@@ -75,26 +73,20 @@ Handlers["news-feed"] = {
75
73
  }
76
74
 
77
75
  Config.promptRunning = false;
78
- if (!result) {
79
- return Dialog.show();
80
- }
76
+ if (!result) { return Dialog.show(); }
81
77
  Dialog.show("Loading...");
82
78
  Config._github.repos.create(result, function (err, data) {
83
- if (err) {
84
- return Dialog.show("Cannot create repository: " + JSON.parse(err.message).message);
85
- }
79
+ if (err) { return Dialog.show("Cannot create repository: " + JSON.parse(err.message).message); }
86
80
  Dialog.show("Repository created at: " + data.ssh_url);
87
81
  });
88
82
  }
89
83
  // Profile
90
- , "P": function P() {
84
+ , "P": function () {
91
85
  Dialog.show("Waiting for user input ...");
92
86
  Config.promptRunning = true;
93
87
  var username = Config.prompt("Username");
94
88
  Config.promptRunning = false;
95
- if (!username) {
96
- return Dialog.show();
97
- }
89
+ if (!username) { return Dialog.show(); }
98
90
  Dialog.show("Loading...");
99
91
  Profile(username, function (err, progressMsg) {
100
92
  Dialog.show(err || progressMsg);
@@ -105,32 +97,33 @@ Handlers["news-feed"] = {
105
97
  });
106
98
  }
107
99
  // Show issues
108
- , "I": function I() {
100
+ , "I": function () {
109
101
  Dialog.show("Fetching issues...");
110
102
  require("./ui/user-issues")({
111
- type: "issues",
112
- ops: {
113
- sort: "updated",
114
- q: "is:open is:issue assignee:" + Config.username
103
+ type: "issues"
104
+ , ops: {
105
+ sort: "updated"
106
+ , q: "is:open is:issue assignee:" + Config.username
115
107
  }
116
108
  }, function (msg) {
117
109
  Dialog.show(msg);
118
110
  });
119
111
  }
120
112
  // Show pull requests
121
- , "R": function R() {
113
+ , "R": function () {
122
114
  Dialog.show("Fetching pull requests...");
123
- require("./ui/user-issues")(_defineProperty({
124
- type: "pullrequests",
125
- ops: {
126
- filter: "created",
127
- sort: "updated",
128
- state: "open"
115
+ require("./ui/user-issues")({
116
+ type: "pullrequests"
117
+ , ops: {
118
+ filter: "created"
119
+ , sort: "updated"
120
+ , state: "open"
121
+ }
122
+ , ops: {
123
+ sort: "updated"
124
+ , q: "is:open is:pr author:" + Config.username
129
125
  }
130
- }, "ops", {
131
- sort: "updated",
132
- q: "is:open is:pr author:" + Config.username
133
- }), function (msg) {
126
+ }, function (msg) {
134
127
  Dialog.show(msg);
135
128
  });
136
129
  }
@@ -138,42 +131,36 @@ Handlers["news-feed"] = {
138
131
 
139
132
  Handlers["profile"] = {
140
133
  // Show followers
141
- "R": function R() {
142
- if (Config.cFrameData.type !== "User") {
143
- return;
144
- }
134
+ "R": function () {
135
+ if (Config.cFrameData.type !== "User") { return; }
145
136
  Dialog.show("Fetching followers...");
146
137
  require("./ui/user-list")({
147
- type: "followers",
148
- user: Config.cFrameData.login
138
+ type: "followers"
139
+ , user: Config.cFrameData.login
149
140
  }, function (msg) {
150
141
  Dialog.show(msg);
151
142
  });
152
143
  }
153
144
 
154
145
  // Show following
155
- , "N": function N() {
156
- if (Config.cFrameData.type !== "User") {
157
- return;
158
- }
146
+ , "N": function () {
147
+ if (Config.cFrameData.type !== "User") { return; }
159
148
  Dialog.show("Fetching following...");
160
149
  require("./ui/user-list")({
161
- type: "following",
162
- user: Config.cFrameData.login
150
+ type: "following"
151
+ , user: Config.cFrameData.login
163
152
  }, function (msg) {
164
153
  Dialog.show(msg);
165
154
  });
166
155
  }
167
156
 
168
157
  // Show members
169
- , "M": function M() {
170
- if (Config.cFrameData.type !== "Organization") {
171
- return;
172
- }
158
+ , "M": function () {
159
+ if (Config.cFrameData.type !== "Organization") { return; }
173
160
  Dialog.show("Fetching members...");
174
161
  require("./ui/user-list")({
175
- type: "members",
176
- user: Config.cFrameData.login
162
+ type: "members"
163
+ , user: Config.cFrameData.login
177
164
  }, function (msg) {
178
165
  Dialog.show(msg);
179
166
  });
@@ -182,4 +169,4 @@ Handlers["profile"] = {
182
169
 
183
170
  Handlers["user-list"] = {
184
171
  "P": Handlers["news-feed"].P
185
- };
172
+ };
package/lib/ui/profile.js CHANGED
@@ -1,13 +1,12 @@
1
- "use strict";
2
-
3
1
  // Dependencies
4
- var Config = require("../conf"),
5
- Table = require("le-table"),
6
- Overlap = require("overlap"),
7
- Profile = require("../api/profile"),
8
- Utils = require(Config.root + "/lib/utils"),
9
- ImageToAscii = require("image-to-ascii"),
10
- Moment = require("moment");
2
+ var Config = require("../conf")
3
+ , Table = require("le-table")
4
+ , Overlap = require("overlap")
5
+ , Profile = require("../api/profile")
6
+ , Utils = require(Config.root + "/lib/utils")
7
+ , ImageToAscii = require("image-to-ascii")
8
+ , Moment = require("moment")
9
+ ;
11
10
 
12
11
  /*!
13
12
  * getAvatar
@@ -26,12 +25,10 @@ function getAvatar(userObj, callback) {
26
25
  }
27
26
 
28
27
  ImageToAscii(userObj.avatar_url, {
29
- size: { height: "70%" },
30
- colored: Config.coloredImages
28
+ size: { height: "70%" }
29
+ , colored: Config.coloredImages
31
30
  }, function (err, cAvatar) {
32
- if (err) {
33
- return callback(err);
34
- }
31
+ if (err) { return callback(err); }
35
32
  callback(null, Config.cache.avatars[userObj.login] = cAvatar);
36
33
  });
37
34
  }
@@ -49,9 +46,7 @@ function getAvatar(userObj, callback) {
49
46
  */
50
47
  module.exports = function (options, progress, callback) {
51
48
  Profile(options, progress, function (err, data) {
52
- if (err) {
53
- return callback(err);
54
- }
49
+ if (err) { return callback(err); }
55
50
  getAvatar(data, function (err, cAvatar) {
56
51
  if (err) {
57
52
  return callback(err);
@@ -59,35 +54,26 @@ module.exports = function (options, progress, callback) {
59
54
 
60
55
  // Profile
61
56
  var profileScreen = Overlap({
62
- who: Config.background.toString(),
63
- with: cAvatar,
64
- where: {
65
- x: 3,
66
- y: 2
57
+ who: Config.background.toString()
58
+ , with: cAvatar
59
+ , where: {
60
+ x: 3
61
+ , y: 2
67
62
  }
68
63
  });
69
- var info = [],
70
- name = data.name + " (@" + data.login + ")",
71
- separator = Array(name.length).join("-");
64
+ var info = []
65
+ , name = data.name + " (@" + data.login + ")"
66
+ , separator = Array(name.length).join("-")
67
+ ;
72
68
 
73
69
  info.push(separator);
74
- info.push(name);
70
+ info.push(name)
75
71
  info.push(separator);
76
- if (data.company) {
77
- info.push("♟ " + data.company);
78
- }
79
- if (data.location) {
80
- info.push("༐ " + data.location);
81
- }
82
- if (data.email) {
83
- info.push("✉ " + data.email);
84
- }
85
- if (data.blog) {
86
- info.push("⊜ " + data.blog);
87
- }
88
- if (data.created_at) {
89
- info.push("⇴ Joined on " + Moment(data.created_at).format("LL"));
90
- }
72
+ if (data.company) { info.push("♟ " + data.company); }
73
+ if (data.location) { info.push("༐ " + data.location); }
74
+ if (data.email) { info.push("✉ " + data.email); }
75
+ if (data.blog) { info.push("⊜ " + data.blog); }
76
+ if (data.created_at) { info.push("⇴ Joined on " + Moment(data.created_at).format("LL")); }
91
77
  info.push(separator);
92
78
  if (data.type === "User") {
93
79
  info.push("Followe(R)s: " + data.followers);
@@ -107,21 +93,21 @@ module.exports = function (options, progress, callback) {
107
93
  }
108
94
 
109
95
  for (var i = 0; i < show; ++i) {
110
- var cRepo = data.repos[i],
111
- type = "source";
96
+ var cRepo = data.repos[i]
97
+ , type = "source"
98
+ ;
112
99
 
113
- if (cRepo.fork) {
114
- type = "fork";
115
- }
116
- if (cRepo.private) {
117
- type = "private";
118
- }
100
+ if (cRepo.fork) { type = "fork"; }
101
+ if (cRepo.private) { type = "private"; }
119
102
 
120
103
  repos.addRow([i + 1, type, cRepo.name, cRepo.ssh_url]);
121
104
  }
122
105
 
123
106
  var cRepos = repos.stringify().trim();
124
- profileScreen = Utils.overlap(profileScreen, ["Repositories", cRepos], 2, cAvatar.split("\n")[0].length + 5);
107
+ profileScreen = Utils.overlap(profileScreen, [
108
+ "Repositories"
109
+ , cRepos
110
+ ], 2, cAvatar.split("\n")[0].length + 5);
125
111
 
126
112
  // Organizations
127
113
  var orgs = new Table();
@@ -133,7 +119,10 @@ module.exports = function (options, progress, callback) {
133
119
  }
134
120
 
135
121
  if (data.orgs.length) {
136
- profileScreen = Utils.overlap(profileScreen, ["Organizations", orgs.stringify().trim()], 2, cAvatar.split("\n")[0].length + 5 + cRepos.split("\n")[0].length + 3);
122
+ profileScreen = Utils.overlap(profileScreen, [
123
+ "Organizations"
124
+ , orgs.stringify().trim()
125
+ ], 2, cAvatar.split("\n")[0].length + 5 + cRepos.split("\n")[0].length + 3);
137
126
  }
138
127
 
139
128
  Config.currentFrame = "profile";
@@ -144,4 +133,4 @@ module.exports = function (options, progress, callback) {
144
133
  });
145
134
  });
146
135
  });
147
- };
136
+ };
@@ -1,10 +1,9 @@
1
- "use strict";
2
-
3
1
  // Dependencies
4
- var Config = require("../conf"),
5
- ImageToAscii = require("image-to-ascii"),
6
- Overlap = require("overlap"),
7
- Utils = require(Config.root + "/lib/utils");
2
+ var Config = require("../conf")
3
+ , ImageToAscii = require("image-to-ascii")
4
+ , Overlap = require("overlap")
5
+ , Utils = require(Config.root + "/lib/utils")
6
+ ;
8
7
 
9
8
  /**
10
9
  * SplashScreen.show
@@ -16,46 +15,42 @@ var Config = require("../conf"),
16
15
  * @return {undefined}
17
16
  */
18
17
  var bOut = null;
19
- exports.show = function (callback) {
18
+ exports.show = function(callback) {
20
19
 
21
20
  Config.currentFrame = "splashscreen";
22
21
  ImageToAscii(Config.root + "/resources/github.png", {
23
22
  size: {
24
23
  height: "25%"
25
- },
26
- pxWidth: 1,
27
- reverse: true,
28
- colored: false
29
- }, function (err, cGithub) {
30
- if (err) {
31
- callback(err);
32
24
  }
25
+ , pxWidth: 1
26
+ , reverse: true
27
+ , colored: false
28
+ }, function(err, cGithub) {
29
+ if (err) { callback(err); }
33
30
 
34
31
  ImageToAscii(Config.root + "/resources/octocat.png", {
35
32
  size: {
36
33
  height: "30%"
37
- },
38
- colored: false,
39
- pixels: "@O!. ",
40
- pxWidth: 1
41
- }, function (err, cOctocat) {
42
- if (err) {
43
- callback(err);
44
34
  }
35
+ , colored: false
36
+ , pixels: "@O!. "
37
+ , pxWidth: 1
38
+ }, function(err, cOctocat) {
39
+ if (err) { callback(err); }
45
40
  var output = Overlap({
46
- who: Config.background.toString(),
47
- with: cGithub,
48
- where: {
49
- x: Config.cli.w / 2 - cGithub.split("\n")[0].length / 2,
50
- y: Config.cli.h - cGithub.split("\n").length - 4
41
+ who: Config.background.toString()
42
+ , with: cGithub
43
+ , where: {
44
+ x: Config.cli.w / 2 - cGithub.split("\n")[0].length / 2
45
+ , y: Config.cli.h - cGithub.split("\n").length - 4
51
46
  }
52
47
  });
53
48
  bOut = output = Overlap({
54
- who: output,
55
- with: cOctocat,
56
- where: {
57
- x: Config.cli.w / 2 - cOctocat.split("\n")[0].length / 2,
58
- y: Config.cli.h - cGithub.split("\n").length - cGithub.split("\n").length - 10
49
+ who: output
50
+ , with: cOctocat
51
+ , where: {
52
+ x: Config.cli.w / 2 - cOctocat.split("\n")[0].length / 2
53
+ , y: Config.cli.h - cGithub.split("\n").length - cGithub.split("\n").length - 10
59
54
  }
60
55
  }).trim();
61
56
  Config.cli.update.render(output, true, {
@@ -77,4 +72,4 @@ exports.show = function (callback) {
77
72
  */
78
73
  exports.updateMessage = function (message) {
79
74
  Config.cli.update.render(Utils.overlap(bOut, message, bOut.split("\n").length - 2, "center").trim(), false);
80
- };
75
+ };
package/lib/ui/stream.js CHANGED
@@ -1,29 +1,28 @@
1
- "use strict";
2
-
3
1
  // Dependencies
4
- var Config = require("../conf"),
5
- Table = require("le-table"),
6
- Couleurs = require("couleurs"),
7
- Overlap = require("overlap"),
8
- Stream = require("../api/stream"),
9
- Utils = require(Config.root + "/lib/utils");
2
+ var Config = require("../conf")
3
+ , Table = require("le-table")
4
+ , Couleurs = require("couleurs")
5
+ , Overlap = require("overlap")
6
+ , Stream = require("../api/stream")
7
+ , Utils = require(Config.root + "/lib/utils")
8
+ ;
10
9
 
11
10
  // Set default marks
12
11
  Table.defaults.marks = {
13
- nw: "┌",
14
- n: "─",
15
- ne: "┐",
16
- e: "│",
17
- se: "┘",
18
- s: "─",
19
- sw: "└",
20
- w: "│",
21
- b: " ",
22
- mt: "┬",
23
- ml: "├",
24
- mr: "┤",
25
- mb: "┴",
26
- mm: "┼"
12
+ nw: "┌"
13
+ , n: "─"
14
+ , ne: "┐"
15
+ , e: "│"
16
+ , se: "┘"
17
+ , s: "─"
18
+ , sw: "└"
19
+ , w: "│"
20
+ , b: " "
21
+ , mt: "┬"
22
+ , ml: "├"
23
+ , mr: "┤"
24
+ , mb: "┴"
25
+ , mm: "┼"
27
26
  };
28
27
 
29
28
  /**
@@ -36,76 +35,84 @@ Table.defaults.marks = {
36
35
  * @return {undefined}
37
36
  */
38
37
  module.exports = function (callback) {
39
- callback = callback || function () {};
40
- Stream(function (err, data) {
41
- if (err) {
42
- data = [];
43
- }
44
- Config.currentFrame = "news-feed";
38
+ callback = callback || function () {};
39
+ Stream(function (err, data) {
40
+ if (err) { data = [] }
41
+ Config.currentFrame = "news-feed";
45
42
 
46
- var timeline = new Table();
47
- timeline.addRow(["#", {
48
- text: "Type",
49
- data: {
50
- width: 8,
51
- hAlign: "center"
52
- }
53
- }, "Description", {
54
- text: "Time",
55
- data: {
56
- width: 18
57
- }
58
- }]);
43
+ var timeline = new Table();
44
+ timeline.addRow(["#", {
45
+ text: "Type"
46
+ , data: {
47
+ width: 8
48
+ , hAlign: "center"
49
+ }
50
+ }, "Description", {
51
+ text: "Time"
52
+ , data: {
53
+ width: 18
54
+ }
55
+ }]);
59
56
 
60
- var offsetTop = 10,
61
- show = Math.floor((Config.cli.h - offsetTop - 3) / 2) - 1;
57
+ var offsetTop = 10
58
+ , show = Math.floor((Config.cli.h - offsetTop - 3) / 2) - 1
59
+ ;
62
60
 
63
- if (show > data.length) {
64
- show = data.length;
65
- }
61
+ if (show > data.length) {
62
+ show = data.length;
63
+ }
66
64
 
67
- for (var i = 0; i < show; ++i) {
68
- var cEv = data[i];
65
+ for (var i = 0; i < show; ++i) {
66
+ var cEv = data[i];
69
67
 
70
- timeline.addRow([{
71
- text: i + 1,
72
- data: {
73
- vAlign: "middle",
74
- width: 6
75
- }
76
- }, {
77
- text: cEv.icon,
78
- data: {
79
- hAlign: "center",
80
- vAlign: "middle"
81
- }
82
- }, {
83
- text: cEv.description,
84
- data: {
85
- vAlign: "middle"
68
+ timeline.addRow([{
69
+ text: i + 1
70
+ , data: {
71
+ vAlign: "middle"
72
+ , width: 6
73
+ }
74
+ }, {
75
+ text: cEv.icon
76
+ , data: {
77
+ hAlign: "center"
78
+ , vAlign: "middle"
79
+ }
80
+ }, {
81
+ text: cEv.description
82
+ , data: {
83
+ vAlign: "middle"
84
+ }
85
+ }, {
86
+ text: cEv.time
87
+ , data: {
88
+ vAlign: "middle"
89
+ , width: 18
90
+ }
91
+ }]);
86
92
  }
87
- }, {
88
- text: cEv.time,
89
- data: {
90
- vAlign: "middle",
91
- width: 18
92
- }
93
- }]);
94
- }
95
93
 
96
- var cTimeline = timeline.stringify(),
97
- output = Overlap({
98
- who: Config.background.toString(),
99
- with: cTimeline,
100
- where: {
101
- x: Config.cli.w / 2 - cTimeline.split("\n")[0].length / 2,
102
- y: 10
103
- }
104
- });
94
+ var cTimeline = timeline.stringify()
95
+ , output = Overlap({
96
+ who: Config.background.toString()
97
+ , with: cTimeline
98
+ , where: {
99
+ x: Config.cli.w / 2 - cTimeline.split("\n")[0].length / 2
100
+ , y: 10
101
+ }
102
+ })
103
+ ;
105
104
 
106
- output = Utils.overlap(output, [Config.title, " - - - ", Config.description, "", "-----------------------------------------------------------------", "(C)reate new repository | (P)rofile | (I)ssues | Pull (R)equests", "-----------------------------------------------------------------"], 2, "center");
107
- Config.cli.update.render(output.trim(), true, {
108
- currentFrame: Config.currentFrame
105
+ output = Utils.overlap(output, [
106
+ Config.title
107
+ , " - - - "
108
+ , Config.description
109
+ , ""
110
+ , "-----------------------------------------------------------------"
111
+ , "(C)reate new repository | (P)rofile | (I)ssues | Pull (R)equests"
112
+ , "-----------------------------------------------------------------"
113
+ ], 2, "center");
114
+ Config.cli.update.render(output.trim(), true, {
115
+ currentFrame: Config.currentFrame
116
+ });
109
117
  });
110
- });
111
- };
118
+ };