Compare commits
3 Commits
e041412051
...
v1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 6fa78a1456 | |||
| f7a741245d | |||
| da786a6e02 |
3
AUTHORS.md
Normal file
3
AUTHORS.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
### Authors
|
||||||
|
|
||||||
|
- joe fleming ([w33ble](https://github.com/w33ble))
|
||||||
5
CHANGELOG.md
Normal file
5
CHANGELOG.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
### Changelog
|
||||||
|
|
||||||
|
#### 1.0.0 (6 December 2018)
|
||||||
|
- docs: add usage info to readme [`f7a7412`](https://git.w33ble.com/w33ble/github-info-bitbar/commit/f7a741245d74e613ef145092ef252db7b47b1661)
|
||||||
|
- feat: working bitbar output [`9a96270`](https://git.w33ble.com/w33ble/github-info-bitbar/commit/9a96270df6dbd340c1bae68116f7c43d5dd956cf)
|
||||||
17
README.md
17
README.md
@@ -1,9 +1,24 @@
|
|||||||
# github-info
|
# github-info
|
||||||
|
|
||||||
Github info in your bitbar.
|
Github info in your [bitbar](https://getbitbar.com/).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
Clone this repo and add the following to your bitbar plugins path:
|
||||||
|
|
||||||
|
```js
|
||||||
|
#!/usr/bin/env node
|
||||||
|
const info = require('path/to/github-info');
|
||||||
|
|
||||||
|
info({
|
||||||
|
username: 'w33ble',
|
||||||
|
token: 'not required, but highly recommended',
|
||||||
|
repos: [ 'org/repo', 'w33ble/emo' ]
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
#### License
|
#### License
|
||||||
|
|
||||||
MIT © [w33ble](https://github.com/w33ble)
|
MIT © [w33ble](https://github.com/w33ble)
|
||||||
2
index.js
2
index.js
@@ -2,4 +2,4 @@
|
|||||||
require = require('esm')(module);
|
require = require('esm')(module);
|
||||||
const mod = require('./src/index.mjs').default;
|
const mod = require('./src/index.mjs').default;
|
||||||
|
|
||||||
mod();
|
module.exports = mod;
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
import mod from './src/index.mjs';
|
import mod from './src/index.mjs';
|
||||||
|
|
||||||
mod();
|
export default mod;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "github-info",
|
"name": "github-info",
|
||||||
"version": "0.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Github info in your bitbar",
|
"description": "Github info in your bitbar",
|
||||||
"main": "index",
|
"main": "index",
|
||||||
"module": "index.mjs",
|
"module": "index.mjs",
|
||||||
@@ -50,7 +50,6 @@
|
|||||||
"cjs": true
|
"cjs": true
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^6.2.0",
|
|
||||||
"esm": "^3.0.17",
|
"esm": "^3.0.17",
|
||||||
"node-fetch": "^2.3.0"
|
"node-fetch": "^2.3.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,15 +5,8 @@
|
|||||||
// <bitbar.desc>Get list of pull requests from Github for multiple repositories</bitbar.desc>
|
// <bitbar.desc>Get list of pull requests from Github for multiple repositories</bitbar.desc>
|
||||||
// <bitbar.dependencies>node.js request co bluebird</bitbar.dependencies>
|
// <bitbar.dependencies>node.js request co bluebird</bitbar.dependencies>
|
||||||
|
|
||||||
import dotenv from 'dotenv';
|
|
||||||
import nodeFetch, { FetchError } from 'node-fetch';
|
import nodeFetch, { FetchError } from 'node-fetch';
|
||||||
|
|
||||||
dotenv.config();
|
|
||||||
|
|
||||||
const username = process.env.GITHUB_USER;
|
|
||||||
const token = process.env.GITHUB_TOKEN;
|
|
||||||
const repos = process.env.GITHUB_REPOS.split(',');
|
|
||||||
|
|
||||||
const GITHUB_API = 'https://api.github.com';
|
const GITHUB_API = 'https://api.github.com';
|
||||||
|
|
||||||
// make fetch sane
|
// make fetch sane
|
||||||
@@ -23,6 +16,7 @@ const fetch = async (...args) => {
|
|||||||
throw new FetchError(`Unsuccessful Request (${args[0]}) [${res.status}]`);
|
throw new FetchError(`Unsuccessful Request (${args[0]}) [${res.status}]`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const api = ({ username, token }) => {
|
||||||
const getPull = async (repo, id) =>
|
const getPull = async (repo, id) =>
|
||||||
fetch(`${GITHUB_API}/repos/${repo}/pulls/${id}`, {
|
fetch(`${GITHUB_API}/repos/${repo}/pulls/${id}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -31,7 +25,8 @@ const getPull = async (repo, id) =>
|
|||||||
},
|
},
|
||||||
}).then(res => res.json());
|
}).then(res => res.json());
|
||||||
|
|
||||||
const getPulls = async repo => {
|
return {
|
||||||
|
getPulls: async repo => {
|
||||||
const issues = await fetch(
|
const issues = await fetch(
|
||||||
`${GITHUB_API}/repos/${repo}/issues?state=open&sort=updated&creator=w33ble`,
|
`${GITHUB_API}/repos/${repo}/issues?state=open&sort=updated&creator=w33ble`,
|
||||||
{
|
{
|
||||||
@@ -47,15 +42,17 @@ const getPulls = async repo => {
|
|||||||
|
|
||||||
// return actual pull info
|
// return actual pull info
|
||||||
return Promise.all(pulls.map(pull => getPull(repo, pull.number)));
|
return Promise.all(pulls.map(pull => getPull(repo, pull.number)));
|
||||||
};
|
},
|
||||||
|
|
||||||
const getStatus = async (repo, sha) =>
|
getStatus: async (repo, sha) =>
|
||||||
fetch(`${GITHUB_API}/repos/${repo}/commits/${sha}/status`, {
|
fetch(`${GITHUB_API}/repos/${repo}/commits/${sha}/status`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${Buffer.from(`${username}:${token}`).toString('base64')}`,
|
Authorization: `Basic ${Buffer.from(`${username}:${token}`).toString('base64')}`,
|
||||||
},
|
},
|
||||||
}).then(res => res.json());
|
}).then(res => res.json()),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const getStatusColor = status => {
|
const getStatusColor = status => {
|
||||||
if (status === 'failure') return ' color=#aa0000';
|
if (status === 'failure') return ' color=#aa0000';
|
||||||
@@ -64,7 +61,9 @@ const getStatusColor = status => {
|
|||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async () => {
|
export default async ({ username, token, repos = [] }) => {
|
||||||
|
const { getPulls, getStatus } = api({ username, token });
|
||||||
|
|
||||||
let failed = false;
|
let failed = false;
|
||||||
const tasks = await (() => {
|
const tasks = await (() => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -551,11 +551,6 @@ doctrine@^2.1.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
esutils "^2.0.2"
|
esutils "^2.0.2"
|
||||||
|
|
||||||
dotenv@^6.2.0:
|
|
||||||
version "6.2.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.2.0.tgz#941c0410535d942c8becf28d3f357dbd9d476064"
|
|
||||||
integrity sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w==
|
|
||||||
|
|
||||||
elegant-spinner@^1.0.1:
|
elegant-spinner@^1.0.1:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/elegant-spinner/-/elegant-spinner-1.0.1.tgz#db043521c95d7e303fd8f345bedc3349cfb0729e"
|
resolved "https://registry.yarnpkg.com/elegant-spinner/-/elegant-spinner-1.0.1.tgz#db043521c95d7e303fd8f345bedc3349cfb0729e"
|
||||||
|
|||||||
Reference in New Issue
Block a user