├── .babelrc
├── .eslintignore
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── bin
└── cli.js
├── package.json
└── src
├── cli.js
├── command
├── index.js
├── repo
│ └── index.js
├── trend
│ └── index.js
└── user
│ └── index.js
└── utils
├── cfonts.js
├── chalk.js
├── json.js
└── table.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "env",
5 | {
6 | "targets": { "node": "6" }
7 | }
8 | ]
9 | ],
10 | "plugins": ["transform-class-properties", "transform-object-rest-spread"]
11 | }
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | **/node_modules/**
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Runtime data
9 | pids
10 | *.pid
11 | *.seed
12 | *.pid.lock
13 |
14 | # Directory for instrumented libs generated by jscoverage/JSCover
15 | lib-cov
16 |
17 | # Coverage directory used by tools like istanbul
18 | coverage
19 |
20 | # nyc test coverage
21 | .nyc_output
22 |
23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24 | .grunt
25 |
26 | # Bower dependency directory (https://bower.io/)
27 | bower_components
28 |
29 | # node-waf configuration
30 | .lock-wscript
31 |
32 | # Compiled binary addons (http://nodejs.org/api/addons.html)
33 | build/Release
34 |
35 | # Dependency directories
36 | node_modules/
37 | jspm_packages/
38 |
39 | # Typescript v1 declaration files
40 | typings/
41 |
42 | # Optional npm cache directory
43 | .npm
44 |
45 | # Optional eslint cache
46 | .eslintcache
47 |
48 | # Optional REPL history
49 | .node_repl_history
50 |
51 | # Output of 'npm pack'
52 | *.tgz
53 |
54 | # Yarn Integrity file
55 | .yarn-integrity
56 |
57 | # dotenv environment variables file
58 | .env
59 |
60 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - '8'
4 | - '7'
5 | - '6'
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 ZiHang Gao
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.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
8 |
9 | ## 安装
10 |
11 | ```shell
12 | npm install -g grank
13 | ```
14 |
15 | 
16 |
17 | ## 使用
18 |
19 | ### 最热项目
20 |
21 | ```shell
22 | //用法
23 | grank trend -s|--since -l|--language
24 |
25 | //示例
26 | grank trend -s daily -l all
27 | ```
28 |
29 | 字段|含义
30 | -|-
31 | since|查询天或者周或者月, 默认 daily, 可选值 daily, weekly, monthly
32 | language|查询某个语言, 例如 c, java, node
33 |
34 | ### 搜索用户
35 |
36 | ```shell
37 | //用法
38 | grank user [query] -s|--sort -o|--order -n|--num -p|--page
39 |
40 | //示例
41 | grank user location:china+language:c -n 5 -s followers -o desc
42 | ```
43 |
44 | query 扩展用法, 语法格式为 keywords+key:value+key2:value:
45 |
46 | 类型|含义|示例
47 | -|-|-
48 | type|搜索的用户类型,user 或者 org|`type:user`
49 | in|在何字段中进行q的搜索。通常为user的response中的字段|`in:user`
50 | repos|数量过滤字段。根据所拥有的repos数量进行过滤|`repos:10`
51 | location|所在地过滤|`location:china`
52 | language|所拥有的repos语言过滤|`language:node`
53 | followers|关注数量过滤字段|`followers:100`
54 |
55 | 可选字段
56 |
57 | 字段|含义
58 | -|-
59 | num|每页需要查询的数量
60 | sort|排序依据,值可为followers, repositories, or joined。默认为 best match
61 | order|排序顺序,desc或asc。默认为desc
62 | page|查询第几页
63 |
64 | ---
65 |
66 | ### 搜索仓库
67 |
68 | ```shell
69 | //用法
70 | grank repo [query] -s|--sort -o|--order -n|--num -p|--page
71 |
72 | //示例
73 | grank repo language:node -n 5 -s stars -o desc
74 | ```
75 |
76 | query 扩展用法, 语法格式为 keywords+key:value+key2:value:
77 |
78 | 类型|含义|示例
79 | -|-|-
80 | in|在何字段中对q进行搜索。可用值为repository相关response中的字段|`in:c`
81 | forks|forks字段过滤|`forks:100`
82 | stars|同forks,过滤使用|`stars:100`
83 | language|搜索的语言类型,例 java,c,python 等|`language:node`
84 |
85 | 可选字段
86 |
87 | 字段|含义
88 | -|-
89 | num|每页需要查询的数量
90 | sort|排序依据,值可取 stars,forks,updated。默认为best match
91 | order|排序顺序,desc或asc。默认为desc
92 | page|查询第几页
93 |
94 | ## License
95 |
96 | MIT
--------------------------------------------------------------------------------
/bin/cli.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | if (process.env.NODE_ENV === 'development') {
4 | require('babel-register');
5 | require('../src/cli');
6 | } else {
7 | require('../lib/cli');
8 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "grank",
3 | "version": "1.0.18",
4 | "description": "Github Rank Cli",
5 | "main": "lib/cli.js",
6 | "bin": {
7 | "grank": "lib/cli.js"
8 | },
9 | "files": [
10 | "lib"
11 | ],
12 | "scripts": {
13 | "build": "npm run clean && babel src -d lib --copy-files --ignore '**/*.spec.js' -s && npm run pack",
14 | "pack": "pkg . --out-path packed",
15 | "clean": "rimraf lib packed",
16 | "test": "echo \"no test specified\"",
17 | "prepublishOnly": "npm run build && echo '#!/usr/bin/env node' | cat - lib/cli.js > temp && mv temp lib/cli.js"
18 | },
19 | "repository": {
20 | "type": "git",
21 | "url": "git+ssh://git@github.com/cdoco/grank.git"
22 | },
23 | "keywords": [
24 | "github",
25 | "rank",
26 | "cli"
27 | ],
28 | "author": "ZiHang Gao",
29 | "license": "MIT",
30 | "bugs": {
31 | "url": "https://github.com/cdoco/grank/issues"
32 | },
33 | "homepage": "https://github.com/cdoco/grank#readme",
34 | "dependencies": {
35 | "async-to-gen": "^1.3.3",
36 | "babel-register": "^6.26.0",
37 | "cfonts": "^1.1.3",
38 | "chalk": "^2.3.0",
39 | "cli-table2": "^0.2.0",
40 | "didyoumean": "^1.2.1",
41 | "commander": "^2.11.0",
42 | "date-fns": "^1.29.0",
43 | "is-async-supported": "^1.2.0",
44 | "update-notifier": "^2.3.0",
45 | "axios": "^0.17.1",
46 | "ora": "^1.3.0",
47 | "p-map": "^1.2.0"
48 | },
49 | "pkg": {
50 | "scripts": [
51 | "lib/**/*.js",
52 | "node_modules/blessed/lib/**/*.js"
53 | ],
54 | "assets": "lib/data/fonts/*"
55 | },
56 | "devDependencies": {
57 | "babel-cli": "^6.26.0",
58 | "babel-eslint": "^8.0.1",
59 | "babel-jest": "^21.2.0",
60 | "babel-plugin-transform-class-properties": "^6.24.1",
61 | "babel-plugin-transform-object-rest-spread": "^6.26.0",
62 | "babel-preset-env": "^1.6.1",
63 | "eslint": "^4.9.0",
64 | "eslint-config-airbnb": "^16.1.0",
65 | "eslint-config-prettier": "^2.6.0",
66 | "eslint-plugin-babel": "^4.1.2",
67 | "eslint-plugin-import": "^2.8.0",
68 | "eslint-plugin-jsx-a11y": "^6.0.2",
69 | "eslint-plugin-prettier": "^2.3.1",
70 | "eslint-plugin-react": "^7.4.0",
71 | "husky": "^0.14.3",
72 | "jest": "^21.2.1",
73 | "lint-staged": "^5.0.0",
74 | "pkg": "^4.3.0-beta.4",
75 | "prettier": "^1.8.2",
76 | "rimraf": "^2.6.2"
77 | }
78 | }
--------------------------------------------------------------------------------
/src/cli.js:
--------------------------------------------------------------------------------
1 | import program from 'commander';
2 | import isAsyncSupported from 'is-async-supported';
3 | import didYouMean from 'didyoumean';
4 | import chalk from 'chalk';
5 | import updateNotifier from 'update-notifier';
6 |
7 | import grank from './command';
8 | import { error, bold, red, neonGreen } from './utils/chalk';
9 |
10 | import pkg from '../package.json';
11 |
12 | if (!isAsyncSupported()) {
13 | require('async-to-gen/register');
14 | }
15 |
16 | (async() => {
17 | await updateNotifier({
18 | pkg,
19 | }).notify({ defer: false });
20 | })();
21 |
22 | program.version(pkg.version);
23 |
24 | program
25 | .command('trend')
26 | .alias('t')
27 | .option('-s, --since ', `查询天或者周或者月, 默认 daily, 可选值 daily, weekly, monthly, eg: ${neonGreen('-s weekly')}`)
28 | .option('-l, --language ', `查询某个语言, eg: ${neonGreen('-l java')}`)
29 | .on('--help', () => {
30 | console.log('');
31 | console.log('');
32 | console.log(` 示例:`);
33 | console.log('');
34 | console.log(` ${neonGreen('grank trend -s daily -l all')}`);
35 | console.log('');
36 | })
37 | .action(option => {
38 | grank.trend(option);
39 | });
40 |
41 | program
42 | .command('user [query]')
43 | .alias('u')
44 | .option('-s, --sort ', "排序依据, 值可为 followers, repositories, or joined。默认为 best match")
45 | .option('-o, --order ', "排序顺序, desc 或 asc。默认为 desc")
46 | .option('-n, --num ', "查询的数量, 默认为 10")
47 | .option('-p, --page ', "查询的页数, 默认为 1")
48 | .on('--help', () => {
49 | console.log('');
50 | console.log('');
51 | console.log(` query 扩展用法, 语法格式为 keywords+key:value+key2:value:`);
52 | console.log('');
53 | console.log(` type: 搜索的用户类型,user或者org, eg: ${neonGreen('type:user')}`);
54 | console.log('');
55 | console.log(` in: 在何字段中进行q的搜索。通常为user的response中的字段, eg: ${neonGreen('in:user')}`);
56 | console.log('');
57 | console.log(` repos: 数量过滤字段。根据所拥有的repos数量进行过滤, eg: ${neonGreen('repos:10')}`);
58 | console.log('');
59 | console.log(` location: 所在地过滤, eg: ${neonGreen('location:china')}`);
60 | console.log('');
61 | console.log(` language: 所拥有的repos语言过滤, eg: ${neonGreen('language:node')}`);
62 | console.log('');
63 | console.log(` followers: 关注数量过滤字段, eg: ${neonGreen('followers:100')}`);
64 | console.log('');
65 | console.log(` 示例:`);
66 | console.log('');
67 | console.log(` ${neonGreen('grank user location:china+language:c -n 5 -s followers -o desc')}`);
68 | console.log('');
69 | })
70 | .action((query, option) => {
71 | grank.user(query, option);
72 | });
73 |
74 | program
75 | .command('repo [query]')
76 | .alias('r')
77 | .option('-s, --sort ', "排序依据,值可取 stars, forks, updated。默认为 best match")
78 | .option('-o, --order ', "排序顺序, desc 或 asc。默认为 desc")
79 | .option('-n, --num ', "查询的数量, 默认为 10")
80 | .option('-p, --page ', "查询的页数, 默认为 1")
81 | .on('--help', () => {
82 | console.log('');
83 | console.log('');
84 | console.log(` query 扩展用法, 语法格式为 keywords+key:value+key2:value:`);
85 | console.log('');
86 | console.log(` in: 在何字段中对q进行搜索。可用值为repository相关response中的字段, eg: ${neonGreen('in:c')}`);
87 | console.log('');
88 | console.log(` forks: forks字段过滤, eg: ${neonGreen('forks:100')}`);
89 | console.log('');
90 | console.log(` stars: 同forks,过滤使用, eg: ${neonGreen('stars:100')}`);
91 | console.log('');
92 | console.log(` language: 搜索的语言类型,例 java,c,python 等, eg: ${neonGreen('language:node')}`);
93 | console.log('');
94 | console.log(` 示例:`);
95 | console.log('');
96 | console.log(` ${neonGreen('grank repo language:c -n 5 -s stars -o desc')}`);
97 | console.log('');
98 | })
99 | .action((query, option) => {
100 | grank.repo(query, option);
101 | });
102 |
103 | program.on('--help', () => {
104 | console.log('');
105 | console.log('');
106 | console.log(` Welcome to ${chalk`{bold.hex('#0069b9') Github Rank}`} ${red('Cli')} !`);
107 | console.log('');
108 | console.log(` 查询最热的项目: ${neonGreen('grank trend')}`);
109 | console.log('');
110 | console.log(` 查询用户排名: ${neonGreen('grank user [query]')}`);
111 | console.log('');
112 | console.log(` 查询仓库排名: ${neonGreen('grank repo [query]')}`);
113 | console.log('');
114 | console.log(` 想要获取更多的信息你可以查看帮助文档 ${neonGreen('grank trend -h')} or ${neonGreen('grank user -h')} or ${neonGreen('grank repo -h')}`);
115 | console.log('');
116 | });
117 |
118 | program.option('-v --version', pkg.version);
119 |
120 | program.command('*').action(command => {
121 | error(`Unknown command: ${bold(command)}`);
122 | const commandNames = program.commands
123 | .map(c => c._name)
124 | .filter(name => name !== '*');
125 |
126 | const closeMatch = didYouMean(command, commandNames);
127 | if (closeMatch) {
128 | error(`Did you mean ${bold(closeMatch)} ?`);
129 | }
130 | process.exit(1);
131 | });
132 |
133 | if (process.argv.length === 2) program.help();
134 |
135 | program.parse(process.argv);
--------------------------------------------------------------------------------
/src/command/index.js:
--------------------------------------------------------------------------------
1 | import user from './user';
2 | import repo from './repo';
3 | import trend from './trend';
4 |
5 | export default { user, repo, trend };
--------------------------------------------------------------------------------
/src/command/repo/index.js:
--------------------------------------------------------------------------------
1 | import ora from 'ora';
2 | import format from 'date-fns/format';
3 |
4 | import { github } from '../../utils/json';
5 | import { cfonts } from '../../utils/cfonts';
6 | import { basicTable } from '../../utils/table';
7 | import { error, red, bold, neonGreen } from '../../utils/chalk';
8 |
9 | const alignCenter = columns =>
10 | columns.map(content => ({ content, hAlign: 'left', vAlign: 'center' }));
11 |
12 | const catchError = (err, apiName) => {
13 | error(err);
14 | console.log('');
15 | error(`Oops, ${apiName} goes wrong.`);
16 | error(
17 | 'Please run grank again.\nIf it still does not work, feel free to open an issue on https://github.com/cdoco/grank/issues'
18 | );
19 | process.exit(1);
20 | };
21 |
22 | const repo = async(query = 'language:node', { num = 10, page, sort = 'stars', order } = {}) => {
23 | let repoInfos;
24 | const repoTable = basicTable();
25 |
26 | //title
27 | cfonts('Grank Repo');
28 |
29 | repoTable.push(
30 | alignCenter([
31 | bold(neonGreen("rank")),
32 | bold(neonGreen("name")),
33 | bold(neonGreen("language")),
34 | bold(neonGreen("stars")),
35 | bold(neonGreen("address")),
36 | bold(neonGreen("created")),
37 | ])
38 | );
39 |
40 | //loading style
41 | const spinner = ora('Loading GitHub Rank For Repositorie').start();
42 |
43 | try {
44 | const rsp = await github.get('/search/repositories?q=' + query, {
45 | params: {
46 | per_page: num,
47 | page: page,
48 | sort: sort,
49 | order: order
50 | }
51 | });
52 | repoInfos = rsp.data;
53 | } catch (error) {
54 | spinner.stop();
55 | catchError(error, 'Repositories');
56 | }
57 |
58 | repoInfos.items.forEach((item, index) => {
59 | const {
60 | full_name,
61 | html_url,
62 | language,
63 | stargazers_count,
64 | created_at
65 | } = item;
66 |
67 | repoTable.push(
68 | alignCenter([
69 | ++index,
70 | full_name,
71 | language,
72 | stargazers_count,
73 | html_url,
74 | format(created_at, 'YYYY/MM/DD'),
75 | ])
76 | );
77 | });
78 |
79 | spinner.stop();
80 |
81 | console.log(repoTable.toString());
82 | };
83 |
84 | export default repo;
--------------------------------------------------------------------------------
/src/command/trend/index.js:
--------------------------------------------------------------------------------
1 | import ora from 'ora';
2 | import pMap from 'p-map';
3 | import format from 'date-fns/format';
4 |
5 | import { codehub } from '../../utils/json';
6 | import { cfonts } from '../../utils/cfonts';
7 | import { basicTable } from '../../utils/table';
8 | import { error, red, bold, neonGreen } from '../../utils/chalk';
9 |
10 | const alignCenter = columns =>
11 | columns.map(content => ({ content, hAlign: 'left', vAlign: 'center' }));
12 |
13 | const catchError = (err, apiName) => {
14 | error(err);
15 | console.log('');
16 | error(`Oops, ${apiName} goes wrong.`);
17 | error(
18 | 'Please run grank again.\nIf it still does not work, feel free to open an issue on https://github.com/cdoco/grank/issues'
19 | );
20 | process.exit(1);
21 | };
22 |
23 | const trend = async({ since = 'daily', language = 'all' } = {}) => {
24 | let trendInfos;
25 | const trendTable = basicTable();
26 |
27 | //title
28 | cfonts('Trending');
29 |
30 | trendTable.push(
31 | alignCenter([
32 | bold(neonGreen("rank")),
33 | bold(neonGreen("name")),
34 | bold(neonGreen("language")),
35 | bold(neonGreen("stars")),
36 | bold(neonGreen("forks")),
37 | bold(neonGreen("address")),
38 | bold(neonGreen("created")),
39 | ])
40 | );
41 |
42 | //loading style
43 | const spinner = ora('Loading GitHub Trending').start();
44 |
45 | try {
46 | const rsp = await codehub.get('/trending', {
47 | params: {
48 | since: since,
49 | language: language,
50 | }
51 | });
52 | trendInfos = rsp.data;
53 | } catch (error) {
54 | spinner.stop();
55 | catchError(error, 'Trending');
56 | }
57 |
58 | trendInfos.slice(0, 15).forEach((item, index) => {
59 | const {
60 | full_name,
61 | language,
62 | stargazers_count,
63 | forks,
64 | html_url,
65 | created_at
66 | } = item;
67 |
68 | trendTable.push(
69 | alignCenter([
70 | ++index,
71 | full_name,
72 | language,
73 | stargazers_count,
74 | forks,
75 | html_url,
76 | format(created_at, 'YYYY/MM/DD'),
77 | ])
78 | );
79 | });
80 |
81 | spinner.stop();
82 |
83 | console.log(trendTable.toString());
84 |
85 | }
86 |
87 | export default trend;
--------------------------------------------------------------------------------
/src/command/user/index.js:
--------------------------------------------------------------------------------
1 | import ora from 'ora';
2 | import pMap from 'p-map';
3 | import format from 'date-fns/format';
4 |
5 | import { github } from '../../utils/json';
6 | import { cfonts } from '../../utils/cfonts';
7 | import { basicTable } from '../../utils/table';
8 | import { error, red, bold, neonGreen } from '../../utils/chalk';
9 |
10 | const alignCenter = columns =>
11 | columns.map(content => ({ content, hAlign: 'left', vAlign: 'center' }));
12 |
13 | const catchError = (err, apiName) => {
14 | error(err);
15 | console.log('');
16 | error(`Oops, ${apiName} goes wrong.`);
17 | error(
18 | 'Please run grank again.\nIf it still does not work, feel free to open an issue on https://github.com/cdoco/grank/issues'
19 | );
20 | process.exit(1);
21 | };
22 |
23 | const user = async(query = 'location:china', { num = 10, page, sort, order } = {}) => {
24 | let userInfos;
25 | const userTable = basicTable();
26 |
27 | //title
28 | cfonts('Grank User');
29 |
30 | userTable.push(
31 | alignCenter([
32 | bold(neonGreen("rank")),
33 | bold(neonGreen("username")),
34 | bold(neonGreen("name")),
35 | bold(neonGreen("location")),
36 | bold(neonGreen("blog")),
37 | bold(neonGreen("repos")),
38 | bold(neonGreen("followers")),
39 | bold(neonGreen("created")),
40 | ])
41 | );
42 |
43 | //loading style
44 | const spinner = ora('Loading GitHub Rank For User').start();
45 |
46 | try {
47 | const rsp = await github.get('/search/users?q=' + query, {
48 | params: {
49 | per_page: num,
50 | page: page,
51 | sort: sort,
52 | order: order
53 | }
54 | });
55 | userInfos = rsp.data;
56 | } catch (error) {
57 | spinner.stop();
58 | catchError(error, 'Users.All');
59 | }
60 |
61 | await pMap(
62 | userInfos.items,
63 | async(item, index) => {
64 | let detail;
65 |
66 | try {
67 | const rsp = await github.get(item.url);
68 | detail = rsp.data;
69 | } catch (error) {
70 | spinner.stop();
71 | catchError(error, 'Users.UserDetail');
72 | }
73 |
74 | const {
75 | login,
76 | name,
77 | location,
78 | blog,
79 | public_repos,
80 | followers,
81 | created_at
82 | } = detail;
83 |
84 | userTable.push(
85 | alignCenter([
86 | ++index,
87 | login,
88 | name,
89 | location,
90 | blog,
91 | public_repos,
92 | followers,
93 | format(created_at, 'YYYY/MM/DD'),
94 | ])
95 | );
96 | }, { concurrency: 1 }
97 | );
98 |
99 | spinner.stop();
100 |
101 | console.log(userTable.toString());
102 | };
103 |
104 | export default user;
--------------------------------------------------------------------------------
/src/utils/cfonts.js:
--------------------------------------------------------------------------------
1 | import CFonts from 'cfonts';
2 |
3 | const cfonts = fonts => {
4 | CFonts.say(fonts, {
5 | font: 'block',
6 | align: 'left',
7 | colors: ['blue', 'red'],
8 | background: 'black',
9 | letterSpacing: 1,
10 | lineHeight: 1,
11 | space: true,
12 | maxLength: '20',
13 | });
14 | };
15 |
16 | module.exports = {
17 | cfonts,
18 | };
--------------------------------------------------------------------------------
/src/utils/chalk.js:
--------------------------------------------------------------------------------
1 | import chalk from 'chalk';
2 |
3 | const error = msg => {
4 | console.log(chalk `{red.bold ${msg}}`);
5 | };
6 |
7 | const bold = msg => chalk `{white.bold ${msg}}`;
8 |
9 | const red = msg => chalk `{bold.hex('#f00b47') ${msg}}`;
10 |
11 | const neonGreen = msg => chalk `{hex('#66ff66') ${msg}}`;
12 |
13 | const colorTeamName = (color, name) =>
14 | chalk `{bold.white.bgHex('${color}') ${name}}`;
15 |
16 | export { error, bold, red, neonGreen, colorTeamName };
--------------------------------------------------------------------------------
/src/utils/json.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios';
2 |
3 | //github
4 | const github = axios.create({
5 | baseURL: 'https://api.github.com',
6 | });
7 |
8 | //codehub
9 | const codehub = axios.create({
10 | baseURL: 'http://trending.codehub-app.com/v2',
11 | });
12 |
13 | module.exports = { github, codehub };
--------------------------------------------------------------------------------
/src/utils/table.js:
--------------------------------------------------------------------------------
1 | import Table from 'cli-table2';
2 |
3 | const basicTable = () =>
4 | new Table({
5 | chars: {
6 | top: '═',
7 | 'top-mid': '╤',
8 | 'top-left': '╔',
9 | 'top-right': '╗',
10 | bottom: '═',
11 | 'bottom-mid': '╧',
12 | 'bottom-left': '╚',
13 | 'bottom-right': '╝',
14 | left: '║',
15 | 'left-mid': '╟',
16 | mid: '─',
17 | 'mid-mid': '┼',
18 | right: '║',
19 | 'right-mid': '╢',
20 | middle: '│',
21 | },
22 | });
23 |
24 | module.exports = {
25 | basicTable,
26 | };
--------------------------------------------------------------------------------