├── .gitignore ├── .npmignore ├── bin └── anybar-webpack.js ├── .travis.yml ├── anybar-webpack.gif ├── notification.jpg ├── lib ├── icons │ ├── webpack-fail@2x.png │ ├── webpack-compile@2x.png │ ├── webpack-fail_alt@2x.png │ ├── webpack-success@2x.png │ ├── webpack-compile_alt@2x.png │ └── webpack-success_alt@2x.png ├── anybar-client.js ├── postinstall.js └── index.js ├── CHANGELOG.md ├── .editorconfig ├── test └── anybar-client.test.js ├── package.json ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | anybar-webpack.gif 2 | -------------------------------------------------------------------------------- /bin/anybar-webpack.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../lib/index'); 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: node_js 3 | node_js: 4 | - '0.10' 5 | - '0.12' 6 | - 'io.js' 7 | -------------------------------------------------------------------------------- /anybar-webpack.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roman01la/anybar-webpack/master/anybar-webpack.gif -------------------------------------------------------------------------------- /notification.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roman01la/anybar-webpack/master/notification.jpg -------------------------------------------------------------------------------- /lib/icons/webpack-fail@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roman01la/anybar-webpack/master/lib/icons/webpack-fail@2x.png -------------------------------------------------------------------------------- /lib/icons/webpack-compile@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roman01la/anybar-webpack/master/lib/icons/webpack-compile@2x.png -------------------------------------------------------------------------------- /lib/icons/webpack-fail_alt@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roman01la/anybar-webpack/master/lib/icons/webpack-fail_alt@2x.png -------------------------------------------------------------------------------- /lib/icons/webpack-success@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roman01la/anybar-webpack/master/lib/icons/webpack-success@2x.png -------------------------------------------------------------------------------- /lib/icons/webpack-compile_alt@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roman01la/anybar-webpack/master/lib/icons/webpack-compile_alt@2x.png -------------------------------------------------------------------------------- /lib/icons/webpack-success_alt@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roman01la/anybar-webpack/master/lib/icons/webpack-success_alt@2x.png -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.6 2 | 3 | Added: 4 | 5 | - Support Linux (Ubuntu) installation for [somebar](https://github.com/limpbrains/somebar) app 6 | - Icons in white color 7 | 8 | ## 1.1.0 9 | 10 | Added: 11 | 12 | - Show compilation error notification using `node-notifier` 13 | 14 | ## 1.2.0 15 | 16 | Changed: 17 | 18 | - Notifications are disabled by default. Enable by passing options object with field `enableNotifications: true`. 19 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | 10 | # Change these settings to your own preference 11 | indent_style = space 12 | indent_size = 4 13 | 14 | # We recommend you to keep these unchanged 15 | end_of_line = lf 16 | charset = utf-8 17 | trim_trailing_whitespace = true 18 | insert_final_newline = true 19 | 20 | [*.md] 21 | trim_trailing_whitespace = false 22 | -------------------------------------------------------------------------------- /lib/anybar-client.js: -------------------------------------------------------------------------------- 1 | var client = require('dgram').createSocket('udp4'), 2 | defaultHost = '127.0.0.1', 3 | defaultPort = 1738; 4 | 5 | client.on('close', process.exit.bind(null, 0)); 6 | 7 | module.exports = function (command, port, host) { 8 | 9 | var port = port || defaultPort, 10 | host = host || defaultHost, 11 | message = new Buffer(command); 12 | 13 | client.send(message, 0, message.length, port, host, function() { 14 | 15 | command === 'white' && client.close(); 16 | }); 17 | }; 18 | -------------------------------------------------------------------------------- /lib/postinstall.js: -------------------------------------------------------------------------------- 1 | if (process.platform === 'darwin' || process.platform === 'linux') { 2 | 3 | require('child_process') 4 | .exec('mkdir -p ~/.AnyBar && cp ./lib/icons/webpack-* ~/.AnyBar/', 5 | function (err, stdout, stderr) { 6 | 7 | err ? 8 | console.log('\x1b[31m%s\x1b[0m', 'Something went wrong, try to install again.') : 9 | console.log('\x1b[32m%s\x1b[0m', 'Initialized successfully!'); 10 | }); 11 | } 12 | else { 13 | 14 | console.log('\x1b[31m%s\x1b[0m', 'anybar-webpack plugin is for Mac OS and Linux only.') 15 | } 16 | -------------------------------------------------------------------------------- /test/anybar-client.test.js: -------------------------------------------------------------------------------- 1 | var dgram = require('dgram'); 2 | var anyBarClient = require('../lib/anybar-client'); 3 | 4 | var cmd = 'test', 5 | port = 1799, 6 | host = '0.0.0.0'; 7 | 8 | var testMsg = 'Should receive command: ' + cmd; 9 | 10 | var server = dgram.createSocket('udp4', function (msg) { 11 | 12 | if (msg.toString('utf-8') !== cmd) { 13 | 14 | throw new Error(testMsg); 15 | } 16 | else { 17 | 18 | console.log(testMsg); 19 | server.close(); 20 | process.exit(0); 21 | } 22 | }); 23 | 24 | server.bind(port); 25 | 26 | anyBarClient(cmd, port, host); 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "anybar-webpack", 3 | "version": "1.2.0", 4 | "description": "Webpack build status plugin for menubar status indicator applications", 5 | "bin": { 6 | "anybar-webpack": "bin/anybar-webpack.js" 7 | }, 8 | "scripts": { 9 | "test": "node test/anybar-client.test.js", 10 | "postinstall": "node lib/postinstall" 11 | }, 12 | "main": "lib/index.js", 13 | "author": "Roman Liutikov ", 14 | "license": "MIT", 15 | "bugs": { 16 | "url": "https://github.com/roman01la/anybar-webpack/issues" 17 | }, 18 | "homepage": "https://github.com/roman01la/anybar-webpack", 19 | "keywords": [ 20 | "anybar", 21 | "status", 22 | "notification", 23 | "webpack", 24 | "plugin" 25 | ], 26 | "repository": { 27 | "type": "git", 28 | "url": "git://github.com/roman01la/anybar-webpack.git" 29 | }, 30 | "dependencies": { 31 | "node-notifier": "^4.3.1" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Roman Liutikov 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 | 23 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | var anyBarClient = require('./anybar-client'); 2 | var notifier = require('node-notifier'); 3 | var path = require('path'); 4 | 5 | var fail = anyBarClient.bind(null, 'webpack-fail'), 6 | compile = anyBarClient.bind(null, 'webpack-compile'), 7 | success = anyBarClient.bind(null, 'webpack-success'), 8 | exit = anyBarClient.bind(null, 'white'); 9 | 10 | var AnyBarWebpackPlugin = function (port, host, opts) { 11 | 12 | var self = this; 13 | 14 | var enableNotifications; 15 | 16 | opts = opts || {}; 17 | 18 | if (typeof port === 'object') { 19 | opts = port; 20 | port = undefined; 21 | } 22 | 23 | enableNotifications = opts.enableNotifications; 24 | 25 | var failBinded = fail.bind(this, port, host); 26 | this.fail = function(projectName, errorName) { 27 | 28 | failBinded(); 29 | 30 | if (enableNotifications === true) { 31 | notifier.notify({ 32 | title: 'Webpack Build Status', 33 | subtitle: 'Project: ' + projectName, 34 | message: errorName, 35 | icon: path.join(__dirname, 'icons/webpack-fail@2x.png') 36 | }); 37 | } 38 | }; 39 | 40 | this.compile = compile.bind(this, port, host); 41 | this.success = success.bind(this, port, host); 42 | this.exit = exit.bind(this, port, host); 43 | }; 44 | 45 | AnyBarWebpackPlugin.prototype.apply = function (compiler) { 46 | 47 | var _this = this; 48 | 49 | compiler.plugin('compile', function() { 50 | 51 | _this.compile(); 52 | }); 53 | 54 | compiler.plugin('done', function (stats) { 55 | stats.hasErrors() ? 56 | _this.fail( 57 | stats.compilation.options.name, 58 | stats.compilation.errors[0].name) : 59 | _this.success(); 60 | }); 61 | 62 | process.on('SIGINT', _this.exit.bind(null)); 63 | }; 64 | 65 | module.exports = AnyBarWebpackPlugin; 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![npm version](https://badge.fury.io/js/anybar-webpack.svg)](http://badge.fury.io/js/anybar-webpack) 2 | [![Build Status](https://travis-ci.org/roman01la/anybar-webpack.svg?branch=master)](https://travis-ci.org/roman01la/anybar-webpack) 3 | [![NPM Downloads](https://img.shields.io/npm/dm/anybar-webpack.svg?style=flat)](https://www.npmjs.org/package/anybar-webpack) 4 | 5 | # AnyBarWebpackPlugin 6 | [Webpack](http://webpack.github.io/) build status plugin for status bar indicator applications. 7 | 8 | ![anybar webpack plugin animated gif demo](anybar-webpack.gif) 9 | 10 | Now with cross-platform native notifications, thanks to [node-notifier](https://github.com/mikaelbr/node-notifier). 11 | 12 | ![anybar webpack plugin notification demo](notification.jpg) 13 | 14 | *__Note__: Notifies only about build errors.* 15 | 16 | ## Known apps 17 | 18 | - [AnyBar](https://github.com/tonsky/AnyBar) on OS X 19 | - [somebar](https://github.com/limpbrains/somebar) on Linux 20 | 21 | ## Known issues 22 | 23 | ### No notifications when running from tmux 24 | Please, follow [this instructions](https://github.com/julienXX/terminal-notifier/issues/115#issuecomment-104214742). After that, update tmux config: `tmux source-file ~/.tmux.conf`. 25 | 26 | ## Installation 27 | 28 | Make sure you have an application installed and running 29 | 30 | ``` 31 | npm i -D anybar-webpack 32 | ``` 33 | 34 | ## Usage 35 | 36 | Use it in your `webpack.config.js`: 37 | 38 | ```javascript 39 | var AnyBarWebpackPlugin = require('anybar-webpack'); 40 | 41 | module.exports = { 42 | // ... 43 | plugins: [ 44 | new AnyBarWebpackPlugin({ 45 | enableNotifications: true 46 | }) 47 | ] 48 | // ... 49 | }; 50 | ``` 51 | 52 | ## API 53 | 54 | ### `new AnyBarWebpackPlugin([port][, host][, options])` 55 | All arguments are optional. If you want to pass the `host` argument, you need to pass a `port` first. 56 | 57 | ### `port` 58 | - Type: `Number` 59 | - Default: `1738` 60 | 61 | The port the status bar application is running on. 62 | 63 | ### `host` 64 | - Type: `String` 65 | - Default: `'127.0.0.1'` 66 | 67 | The host the status bar application is running on. 68 | 69 | ### `enableNotifications` 70 | - Type: `Boolean` 71 | - Default: `false` 72 | 73 | Enable build errors desktop notifications. 74 | --------------------------------------------------------------------------------