├── .github └── FUNDING.yml ├── .gitignore ├── CONTRIBUTING.md ├── DOCUMENTATION.md ├── LICENSE ├── README.md ├── bin └── gh-notifier ├── example └── index.js ├── lib └── index.js ├── package.json └── res ├── gh.png ├── mark-github.svg └── octoface.svg /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: ionicabizau 2 | patreon: ionicabizau 3 | open_collective: ionicabizau 4 | custom: https://www.buymeacoffee.com/h96wwchmy -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | *~ 4 | *.log 5 | node_modules 6 | *.env 7 | .DS_Store 8 | package-lock.json 9 | .bloggify/* 10 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # 🌟 Contributing 2 | 3 | Want to contribute to this project? Great! Please read these quick steps to streamline the process and avoid unnecessary tasks. ✨ 4 | 5 | ## 💬 Discuss Changes 6 | Start by opening an issue in the repository using the [bug tracker][1]. Describe your proposed contribution or the bug you've found. If relevant, include platform info and screenshots. 🖼️ 7 | 8 | Wait for feedback before proceeding unless the fix is straightforward, like a typo. 📝 9 | 10 | ## 🔧 Fixing Issues 11 | 12 | Fork the project and create a branch for your fix, naming it `some-great-feature` or `some-issue-fix`. Commit changes while following the [code style][2]. If the project has tests, add one. ✅ 13 | 14 | If a `package.json` or `bower.json` exists, add yourself to the `contributors` array; create it if it doesn't. 🙌 15 | 16 | ```json 17 | { 18 | "contributors": [ 19 | "Your Name (http://your.website)" 20 | ] 21 | } 22 | ``` 23 | 24 | ## 📬 Creating a Pull Request 25 | Open a pull request and reference the initial issue (e.g., *fixes #*). Provide a clear title and consider adding visual aids for clarity. 📊 26 | 27 | ## ⏳ Wait for Feedback 28 | Your contributions will be reviewed. If feedback is given, update your branch as needed, and the pull request will auto-update. 🔄 29 | 30 | ## 🎉 Everyone Is Happy! 31 | Your contributions will be merged, and everyone will appreciate your effort! 😄❤️ 32 | 33 | Thanks! 🤩 34 | 35 | [1]: /issues 36 | [2]: https://github.com/IonicaBizau/code-style -------------------------------------------------------------------------------- /DOCUMENTATION.md: -------------------------------------------------------------------------------- 1 | ## Documentation 2 | 3 | You can see below the API reference of this module. 4 | 5 | ### `githubNotify(token, interval, callback)` 6 | Creates requests to the GitHub private atom stream and calls the callback 7 | function when there is a new item in the stream. 8 | 9 | #### Params 10 | 11 | - **String** `token`: The GitHub token. 12 | - **Number** `interval`: The number of milliseconds between requests. 13 | - **Function** `callback`: The callback function. 14 | 15 | #### Return 16 | - **PageChanged** The [`PageChanged`](https://github.com/IonicaBizau/node-page-changed) instance. 17 | 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-25 Ionică Bizău (https://ionicabizau.net) 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 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | [![gh-notifier](http://i.imgur.com/OqMXPq5.png)](#) 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | # `$ gh-notifier` 23 | 24 | [![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/gh-notifier.svg)](https://www.npmjs.com/package/gh-notifier) [![Downloads](https://img.shields.io/npm/dt/gh-notifier.svg)](https://www.npmjs.com/package/gh-notifier) [![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) 25 | 26 | Buy Me A Coffee 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | > Receive desktop notifications from your GitHub dashboard. 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | [![gh-notifier](http://i.imgur.com/ViV1UST.png)](#) 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | ## :cloud: Installation 55 | 56 | You can install the package globally and use it as command line tool: 57 | 58 | 59 | ```sh 60 | # Using npm 61 | npm install --global gh-notifier 62 | 63 | # Using yarn 64 | yarn global add gh-notifier 65 | ``` 66 | 67 | 68 | Then, run `gh-notifier --help` and see what the CLI tool can do. 69 | 70 | 71 | ``` 72 | $ gh-notifier --help 73 | Usage: gh-notifier [options] 74 | 75 | Options: 76 | -i, --interval The delay between requests (milliseconds). 77 | -t, --token The GitHub token. 78 | -d, --daemon Daemonize the process. 79 | -h, --help Displays this help. 80 | -v, --version Displays version information. 81 | 82 | Examples: 83 | gh-notifier -t 9b0...ab1 84 | gh-notifier -t 9b0...ab1 -i 10000 # every ten seconds 85 | 86 | 87 | ``` 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | ## :clipboard: Example 102 | 103 | 104 | 105 | Here is an example how to use this package as library. To install it locally, as library, you can use `npm install gh-notifier` (or `yarn add gh-notifier`): 106 | 107 | 108 | 109 | ```js 110 | const notify = require("gh-notifier"); 111 | 112 | // Check every 3 seconds 113 | notify("b80688e1...fc5ba8c4", 3000, (err, data) => { 114 | console.log(err || `${data.title[0]._} ${data.published[0]}`); 115 | }); 116 | // GhitaB forked IonicaBizau/Resources to GhitaB/Resources 2016-01-12T09:03:22Z 117 | ``` 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | ## :question: Get Help 131 | 132 | There are few ways to get help: 133 | 134 | 135 | 136 | 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. 137 | 2. For bug reports and feature requests, open issues. :bug: 138 | 3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket: 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | ## :memo: Documentation 147 | 148 | For full API reference, see the [DOCUMENTATION.md][docs] file. 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | ## :yum: How to contribute 162 | Have an idea? Found a bug? See [how to contribute][contributing]. 163 | 164 | 165 | ## :sparkling_heart: Support my projects 166 | I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, 167 | 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). 168 | 169 | 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: 170 | 171 | 172 | - Starring and sharing the projects you like :rocket: 173 | - [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you after years if you buy me one. :grin: :book: 174 | - [![PayPal][badge_paypal]][paypal-donations]—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea: 175 | - [![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). 176 | - **Bitcoin**—You can send me bitcoins at this address (or scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6` 177 | 178 | ![](https://i.imgur.com/z6OQI95.png) 179 | 180 | 181 | Thanks! :heart: 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | ## :scroll: License 207 | 208 | [MIT][license] © [Ionică Bizău][website] 209 | 210 | 211 | 212 | 213 | 214 | 215 | [license]: /LICENSE 216 | [website]: https://ionicabizau.net 217 | [contributing]: /CONTRIBUTING.md 218 | [docs]: /DOCUMENTATION.md 219 | [badge_patreon]: https://ionicabizau.github.io/badges/patreon.svg 220 | [badge_amazon]: https://ionicabizau.github.io/badges/amazon.svg 221 | [badge_paypal]: https://ionicabizau.github.io/badges/paypal.svg 222 | [badge_paypal_donate]: https://ionicabizau.github.io/badges/paypal_donate.svg 223 | [patreon]: https://www.patreon.com/ionicabizau 224 | [amazon]: http://amzn.eu/hRo9sIZ 225 | [paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW 226 | -------------------------------------------------------------------------------- /bin/gh-notifier: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | "use strict"; 4 | 5 | const Clp = require("clp") 6 | , packageJson = require("../package") 7 | , abs = require("abs") 8 | , log = require("emoji-logger") 9 | , notify = require("../lib") 10 | , readJson = require("r-json") 11 | , deffy = require("deffy") 12 | , notifier = require("node-notifier") 13 | , moment = require("moment") 14 | , diable = require("diable") 15 | ; 16 | 17 | // Constants 18 | const CONFIG_PATH = abs("~/.github-config.json"); 19 | 20 | // Parse the command line arguments 21 | var intervalOpt = new Clp.Option(["i", "interval"], "The delay between requests (milliseconds).", "ms", 8000) 22 | , tokenOpt = new Clp.Option(["t", "token"], "The GitHub token.", "token") 23 | , daemonOpt = new Clp.Option(["d", "daemon"], "Daemonize the process.") 24 | , parser = new Clp({ 25 | name: "GitHub Notify" 26 | , version: packageJson.version 27 | , exe: packageJson.name 28 | , examples: [ 29 | "gh-notifier -t 9b0...ab1" 30 | , "gh-notifier -t 9b0...ab1 -i 10000 # every ten seconds" 31 | ] 32 | , docs_url: packageJson.homapage 33 | , process: true 34 | }, [ 35 | intervalOpt 36 | , tokenOpt 37 | , daemonOpt 38 | ]) 39 | ; 40 | 41 | // Daemonize 42 | if (!diable.isDaemon() && daemonOpt.is_provided) { 43 | return diable(); 44 | } 45 | 46 | readJson(CONFIG_PATH, (err, conf) => { 47 | if (err) { 48 | conf = {}; 49 | } 50 | tokenOpt.value = deffy(tokenOpt.value, conf.token, true); 51 | intervalOpt.value = parseInt(intervalOpt.value); 52 | 53 | if (isNaN(intervalOpt.value)) { 54 | return log("Invalid interval value.", "error"); 55 | } 56 | 57 | notify(tokenOpt.value, intervalOpt.value, (err, data) => { 58 | if (err) { 59 | return notifier.notify({ 60 | title: "Error!" 61 | , message: err.message || err.toString() 62 | }); 63 | } 64 | notifier.notify({ 65 | title: data.title[0]._ 66 | , message: moment(data.published[0]).fromNow() 67 | , icon: __dirname + "/../res/gh.png" 68 | }); 69 | }); 70 | }); 71 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const notify = require("../lib"); 4 | 5 | // Check every 3 seconds 6 | notify("b80688e1...fc5ba8c4", 3000, (err, data) => { 7 | console.log(err || `${data.title[0]._} ${data.published[0]}`); 8 | }); 9 | // GhitaB forked IonicaBizau/Resources to GhitaB/Resources 2016-01-12T09:03:22Z 10 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Dependencies 4 | const parseXML = require("xml2js").parseString 5 | , request = require("request") 6 | , pageChanged = require("page-changed") 7 | , notifier = require('node-notifier') 8 | , moment = require("moment") 9 | , path = require("path") 10 | , GitHub = require("gh.js") 11 | ; 12 | 13 | /** 14 | * githubNotify 15 | * Creates requests to the GitHub private atom stream and calls the callback 16 | * function when there is a new item in the stream. 17 | * 18 | * @name githubNotify 19 | * @function 20 | * @param {String} token The GitHub token. 21 | * @param {Number} interval The number of milliseconds between requests. 22 | * @param {Function} callback The callback function. 23 | * @return {PageChanged} The [`PageChanged`](https://github.com/IonicaBizau/node-page-changed) instance. 24 | */ 25 | module.exports = function githubNotify(token, interval, callback) { 26 | 27 | if (!token) { 28 | return callback(new Error("The token is mandatory.")); 29 | } 30 | 31 | var gh = new GitHub({ 32 | token: token 33 | }); 34 | 35 | gh.get("user", (err, authUser) => { 36 | if (err) { return callback(err); } 37 | 38 | var pc = pageChanged({ 39 | page: `https://github.com/${authUser.login}.private.atom` 40 | , interval: interval 41 | , request: function (cb) { 42 | request.get({ 43 | headers: { 44 | "user-agent": "GitHub - Notify" 45 | } 46 | , auth: { 47 | username: authUser.login 48 | , password: token 49 | } 50 | , url: this.page 51 | }, function (err, res, body) { 52 | if (res.statusCode === 404) { 53 | err = new Error("Cannot access the private stream. Check if your token has access to the private stream."); 54 | } 55 | if (err) { return callback(err); } 56 | parseXML(body, function (err, result) { 57 | if (err) { return cb(err); } 58 | cb(null, JSON.stringify(result.feed.entry[0])); 59 | }); 60 | }); 61 | } 62 | }, (err, body) => { 63 | if (err) { return callback(err); } 64 | body = JSON.parse(body); 65 | callback(null, body); 66 | }); 67 | 68 | }); 69 | 70 | return gh; 71 | }; 72 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gh-notifier", 3 | "version": "1.1.1", 4 | "description": "Receive desktop notifications from your GitHub dashboard.", 5 | "main": "lib/index.js", 6 | "bin": { 7 | "gh-notifier": "./bin/gh-notifier" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+ssh://git@github.com/IonicaBizau/gh-notifier.git" 15 | }, 16 | "keywords": [ 17 | "github", 18 | "notifications", 19 | "desktop" 20 | ], 21 | "author": "Ionică Bizău (https://ionicabizau.net)", 22 | "license": "MIT", 23 | "homepage": "https://github.com/IonicaBizau/gh-notifier#readme", 24 | "dependencies": { 25 | "abs": "^1.2.0", 26 | "clp": "^3.2.0", 27 | "deffy": "^2.2.0", 28 | "diable": "^2.3.0", 29 | "emoji-logger": "^1.0.0", 30 | "gh.js": "^2.4.0", 31 | "moment": "^2.11.1", 32 | "node-notifier": "^4.4.0", 33 | "page-changed": "^1.2.0", 34 | "r-json": "^1.2.0", 35 | "request": "^2.67.0", 36 | "xml2js": "^0.4.15" 37 | }, 38 | "blah": { 39 | "h_img": "http://i.imgur.com/OqMXPq5.png", 40 | "ex_img": "http://i.imgur.com/ViV1UST.png" 41 | }, 42 | "files": [ 43 | "bin/", 44 | "app/", 45 | "lib/", 46 | "dist/", 47 | "src/", 48 | "scripts/", 49 | "resources/", 50 | "menu/", 51 | "cli.js", 52 | "index.js", 53 | "index.d.ts", 54 | "package-lock.json", 55 | "bloggify.js", 56 | "bloggify.json", 57 | "bloggify/" 58 | ], 59 | "bugs": { 60 | "url": "https://github.com/IonicaBizau/gh-notifier/issues" 61 | } 62 | } -------------------------------------------------------------------------------- /res/gh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IonicaBizau/gh-notifier/51e2ccda3dd1a3c018dfc3d861befd54bcf88bef/res/gh.png -------------------------------------------------------------------------------- /res/mark-github.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /res/octoface.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | --------------------------------------------------------------------------------