Skip to content

Commit

Permalink
feat: added the cli table for otput
Browse files Browse the repository at this point in the history
  • Loading branch information
nimish-gupta committed May 3, 2020
1 parent eaea7ae commit 5dbe314
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
},
"dependencies": {
"@octokit/rest": "^17.6.0",
"chalk": "^4.0.0",
"cli-table": "^0.3.1",
"inquirer": "^7.1.0",
"ora": "^4.0.4",
"validator": "^13.0.0"
Expand Down
18 changes: 16 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const ora = require('ora');
const Table = require('cli-table');

const Questions = require('./questions');
const Github = require('./github');
Expand All @@ -19,7 +20,7 @@ const getEmailOfFirstTenCollaborators = async ({ usernames }) => {
const info = await Github.getUserInfo(user);

if (info !== null && info.email !== null) {
emailsWithUser.push({ name: info.name, email: info.email });
emailsWithUser.push({ user: info });
userSpinner.succeed(
Log.success(`${user}'s email exist in github as ${info.email}`)
);
Expand All @@ -36,6 +37,18 @@ const getEmailOfFirstTenCollaborators = async ({ usernames }) => {
return emailsWithUser;
};

const printInfo = ({ emailsWithUser }) => {
const table = new Table({
head: ['User Name', 'Full Name', 'Github Link', 'Email'],
});

table.push(
emailsWithUser.map((user) => [user.login, user.name, user.url, user.email])
);

console.log(table.toString());
};

const main = async (args) => {
const { repoQuery: query } = await Questions.getSearchPrompt();

Expand All @@ -62,7 +75,8 @@ const main = async (args) => {
const emailsWithUser = await getEmailOfFirstTenCollaborators({ usernames });

spinner.succeed();
console.table(emailsWithUser);

printInfo({ emailsWithUser });
return process.exit(0);
};

Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ chalk@^3.0.0:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

chalk@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.0.0.tgz#6e98081ed2d17faab615eb52ac66ec1fe6209e72"
integrity sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

chardet@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
Expand All @@ -175,6 +183,13 @@ cli-spinners@^2.2.0:
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.3.0.tgz#0632239a4b5aa4c958610142c34bb7a651fc8df5"
integrity sha512-Xs2Hf2nzrvJMFKimOR7YR0QwZ8fc0u98kdtwN1eNAZzNQgH3vK2pXzff6GJtKh7S5hoJ87ECiAiZFS2fb5Ii2w==

cli-table@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/cli-table/-/cli-table-0.3.1.tgz#f53b05266a8b1a0b934b3d0821e6e2dc5914ae23"
integrity sha1-9TsFJmqLGguTSz0IIebi3FkUriM=
dependencies:
colors "1.0.3"

cli-width@^2.0.0:
version "2.2.1"
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.1.tgz#b0433d0b4e9c847ef18868a4ef16fd5fc8271c48"
Expand Down Expand Up @@ -209,6 +224,11 @@ color-name@~1.1.4:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

[email protected]:
version "1.0.3"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"
integrity sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=

cross-spawn@^6.0.0:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
Expand Down

0 comments on commit 5dbe314

Please sign in to comment.