ui
This commit is contained in:
+156
@@ -0,0 +1,156 @@
|
||||
|
||||
Changelog
|
||||
===============================================================================
|
||||
|
||||
v1.13.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Update node-notifier to v9
|
||||
|
||||
|
||||
v1.12.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- fix(dependencies): moved the erroneous dependency to devDependencies
|
||||
- Add support set of images for different build status
|
||||
- fix default title, when `title` option skipped
|
||||
- Update node-notifier to v8
|
||||
|
||||
Minimum supported Node version is 6+
|
||||
|
||||
|
||||
v1.11.1
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- support child compilation errors in webpack@<3.11.0
|
||||
|
||||
|
||||
v1.11.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Support for `title` function for dynamic titles ([#53](https://github.com/Turbo87/webpack-notifier/pull/53))
|
||||
|
||||
|
||||
v1.10.1
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- fix(emoji): show success icon
|
||||
- docs(emoji): documentation about emoji option
|
||||
|
||||
|
||||
v1.10.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Add `onlyOnError` option ([#51](https://github.com/Turbo87/webpack-notifier/pull/51))
|
||||
|
||||
|
||||
v1.9.1
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- reduced package size by 2 times
|
||||
|
||||
|
||||
v1.9.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Update node-notifier to v6 ([#56](https://github.com/Turbo87/webpack-notifier/pull/56))
|
||||
|
||||
|
||||
v1.8.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Add `--emoji` option ([#55](https://github.com/Turbo87/webpack-notifier/pull/55))
|
||||
|
||||
|
||||
v1.7.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Handle errors/warnings in child compilations ([#49](https://github.com/Turbo87/webpack-notifier/pull/49))
|
||||
|
||||
|
||||
v1.6.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Add support for webpack 4 plugin system ([#39](https://github.com/Turbo87/webpack-notifier/pull/39))
|
||||
|
||||
|
||||
v1.5.1
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Update `node-notifier` dependency ([#23](https://github.com/Turbo87/webpack-notifier/pull/23) and [#36](https://github.com/Turbo87/webpack-notifier/pull/36))
|
||||
|
||||
|
||||
v1.5.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Add `skipFirstNotification` option ([#21](https://github.com/Turbo87/webpack-notifier/pull/21))
|
||||
|
||||
|
||||
v1.4.1
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Add missing `logo.png` to published NPM package ([#18](https://github.com/Turbo87/webpack-notifier/pull/18))
|
||||
|
||||
|
||||
v1.4.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Pass all options to `node-notifier` ([@opensrcken](https://github.com/opensrcken))
|
||||
- Strip ANSI escape codes from the messages ([@opensrcken](https://github.com/opensrcken))
|
||||
- Remove unnecessary files from NPM package
|
||||
|
||||
|
||||
v1.3.2
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Use contentImage as icon on linux ([#17](https://github.com/Turbo87/webpack-notifier/pull/17))
|
||||
|
||||
|
||||
v1.3.1
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Republished v1.3.0 due to NPM deployment failure
|
||||
|
||||
|
||||
v1.3.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- Prefix error + warning messages ([#13](https://github.com/Turbo87/webpack-notifier/pull/13))
|
||||
|
||||
|
||||
v1.2.1
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- fixed `Cannot read property 'rawRequest' of undefined` error ([#5](https://github.com/Turbo87/webpack-notifier/issues/5))
|
||||
|
||||
|
||||
v1.2.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- `alwaysNotify` option ([#4](https://github.com/Turbo87/webpack-notifier/pull/4))
|
||||
|
||||
|
||||
v1.1.1
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- fixed `error is undefined` exception
|
||||
|
||||
|
||||
v1.1.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- `title` and `contentImage` options ([#1](https://github.com/Turbo87/webpack-notifier/pull/1))
|
||||
- `excludeWarnings` option ([#2](https://github.com/Turbo87/webpack-notifier/pull/2))
|
||||
- fixed warnings display
|
||||
|
||||
|
||||
v1.0.1
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- documentation improvements
|
||||
|
||||
|
||||
v1.0.0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- initial release after fork
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
Copyright (c) 2014, Vsevolod Solovyov <vsevolod.solovyov@gmail.com>
|
||||
Copyright (c) 2015, Tobias Bieniek <tobias.bieniek@gmx.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
# webpack-notifier
|
||||
|
||||
[](https://www.npmjs.com/package/webpack-notifier)
|
||||
[](https://github.com/Turbo87/webpack-notifier/actions?query=workflow:CI)
|
||||
[](https://coveralls.io/github/Turbo87/webpack-notifier?branch=master)
|
||||
[](https://github.com/airbnb/javascript)
|
||||
[](https://www.npmjs.com/package/webpack-notifier)
|
||||

|
||||
|
||||
This is a [webpack](http://webpack.github.io/) plugin that uses the
|
||||
[node-notifier](https://github.com/mikaelbr/node-notifier) package to
|
||||
display build status system notifications to the user.
|
||||
|
||||

|
||||
|
||||
> This is a fork of the
|
||||
[webpack-error-notification](https://github.com/vsolovyov/webpack-error-notification)
|
||||
plugin. It adds support for Windows and there is no need to manually install
|
||||
the `terminal-notifier` package on OS X anymore.
|
||||
|
||||
The plugin will notify you about the first run (success/fail),
|
||||
all failed runs and the first successful run after recovering from
|
||||
a build failure. In other words: it will stay silent if everything
|
||||
is fine with your build.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Use `npm` to install this package:
|
||||
|
||||
npm install --save-dev webpack-notifier
|
||||
|
||||
Check the `node-notifier`
|
||||
[Requirements](https://github.com/mikaelbr/node-notifier#requirements)
|
||||
whether you need to install any additional tools for your OS.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
In the `webpack.config.js` file:
|
||||
|
||||
```js
|
||||
var WebpackNotifierPlugin = require('webpack-notifier');
|
||||
|
||||
var config = module.exports = {
|
||||
// ...
|
||||
|
||||
plugins: [
|
||||
new WebpackNotifierPlugin(),
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
### Title
|
||||
|
||||
Title shown in the notification.
|
||||
|
||||
```js
|
||||
new WebpackNotifierPlugin({title: 'Webpack'});
|
||||
```
|
||||
|
||||
```js
|
||||
new WebpackNotifierPlugin({title: function (params) {
|
||||
return `Build status is ${params.status} with message ${params.message}`;
|
||||
}});
|
||||
```
|
||||
|
||||
### Emojis in message text
|
||||
|
||||
Show status emoji icon before the message.
|
||||
|
||||
```js
|
||||
new WebpackNotifierPlugin({emoji: true});
|
||||
```
|
||||
|
||||
### Content Image
|
||||
|
||||
Image shown in the notification. Can be a path string or object with paths.
|
||||
|
||||
#### String path:
|
||||
```js
|
||||
var path = require('path');
|
||||
|
||||
new WebpackNotifierPlugin({contentImage: path.join(__dirname, 'logo.png')});
|
||||
```
|
||||
|
||||
#### Object string path:
|
||||
```js
|
||||
var path = require('path');
|
||||
|
||||
const statusesPaths = {
|
||||
success: path.join(__dirname, 'success.png'),
|
||||
warning: path.join(__dirname, 'warning.png'),
|
||||
error: path.join(__dirname, 'error.png')
|
||||
}
|
||||
|
||||
new WebpackNotifierPlugin({contentImage: statusesPaths});
|
||||
```
|
||||
|
||||
### Exclude Warnings
|
||||
|
||||
If set to `true`, warnings will not cause a notification.
|
||||
|
||||
```js
|
||||
new WebpackNotifierPlugin({excludeWarnings: true});
|
||||
```
|
||||
|
||||
### Always Notify
|
||||
|
||||
Trigger a notification every time. Call it "noisy-mode".
|
||||
|
||||
```js
|
||||
new WebpackNotifierPlugin({alwaysNotify: true});
|
||||
```
|
||||
|
||||
### Notify on error
|
||||
|
||||
Trigger a notification only on error.
|
||||
|
||||
```js
|
||||
new WebpackNotifierPlugin({onlyOnError: true});
|
||||
```
|
||||
|
||||
### Skip Notification on the First Build
|
||||
|
||||
Do not notify on the first build. This allows you to receive notifications on subsequent incremental builds without being notified on the initial build.
|
||||
|
||||
```js
|
||||
new WebpackNotifierPlugin({skipFirstNotification: true});
|
||||
```
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// Type definitions imported from DefinitielyTyped for webpack-notifier 1.13
|
||||
// Project: https://github.com/Turbo87/webpack-notifier#readme
|
||||
// Definitions by: Benjamin Lim <https://github.com/bumbleblym>
|
||||
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// Alexandre Germain <https://github.com/gerkindev>
|
||||
// Gvozdev Viktor <https://github.com/Gvozd>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.9
|
||||
|
||||
import { Compiler } from 'webpack';
|
||||
|
||||
export = WebpackNotifierPlugin;
|
||||
|
||||
declare class WebpackNotifierPlugin {
|
||||
constructor(options?: WebpackNotifierPlugin.Options);
|
||||
apply(compiler: Compiler): void;
|
||||
}
|
||||
|
||||
declare namespace WebpackNotifierPlugin {
|
||||
interface Options {
|
||||
alwaysNotify?: boolean;
|
||||
contentImage?: {[key in 'success' | 'warning' | 'error']: string} | string;
|
||||
excludeWarnings?: boolean;
|
||||
onlyOnError?: boolean;
|
||||
skipFirstNotification?: boolean;
|
||||
title?: string | TitleGetter;
|
||||
/**
|
||||
* Use emoji in notifications
|
||||
*/
|
||||
emoji?: boolean;
|
||||
}
|
||||
|
||||
/** @deprecated use Options */
|
||||
type Config = Options;
|
||||
|
||||
type TitleGetter = (data: {msg: string,message: string,status: string}) => string;
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
var stripANSI = require('strip-ansi');
|
||||
var path = require('path');
|
||||
var os = require('os');
|
||||
var notifier = require('node-notifier');
|
||||
|
||||
var DEFAULT_LOGO = path.join(__dirname, 'logo.png');
|
||||
|
||||
function WebpackNotifierPlugin(options) {
|
||||
this.options = options || {};
|
||||
this.lastBuildSucceeded = false;
|
||||
this.isFirstBuild = true;
|
||||
}
|
||||
module.exports = WebpackNotifierPlugin;
|
||||
|
||||
function findFirstDFS(compilation, key) {
|
||||
var match = compilation[key][0];
|
||||
if (match) {
|
||||
return match;
|
||||
}
|
||||
|
||||
var children = compilation.children;
|
||||
for (var i = 0; i < children.length; i += 1) {
|
||||
match = findFirstDFS(children[i], key);
|
||||
if (match) {
|
||||
return match;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebpackNotifierPlugin.prototype.compileEndOptions = function compileEndOptions(stats) {
|
||||
if (this.isFirstBuild) {
|
||||
this.isFirstBuild = false;
|
||||
|
||||
if (this.options.skipFirstNotification) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
var imageFromOptions = ('contentImage' in this.options)
|
||||
? this.options.contentImage
|
||||
: DEFAULT_LOGO;
|
||||
|
||||
var successImage = '';
|
||||
var warningsImage = '';
|
||||
var errorsImage = '';
|
||||
if (typeof imageFromOptions === 'object') {
|
||||
successImage = imageFromOptions.success;
|
||||
warningsImage = imageFromOptions.warning;
|
||||
errorsImage = imageFromOptions.error;
|
||||
} else {
|
||||
successImage = imageFromOptions;
|
||||
warningsImage = imageFromOptions;
|
||||
errorsImage = imageFromOptions;
|
||||
}
|
||||
|
||||
var hasEmoji = this.options.emoji;
|
||||
var error;
|
||||
var contentImage;
|
||||
var status;
|
||||
if (this.hasErrors(stats)) {
|
||||
error = findFirstDFS(stats.compilation, 'errors');
|
||||
contentImage = errorsImage;
|
||||
status = 'error';
|
||||
} else if (this.options.onlyOnError) {
|
||||
return {};
|
||||
} else if (this.hasWarnings(stats) && !this.options.excludeWarnings) {
|
||||
error = findFirstDFS(stats.compilation, 'warnings');
|
||||
contentImage = warningsImage;
|
||||
status = 'warning';
|
||||
} else if (!this.lastBuildSucceeded || this.options.alwaysNotify) {
|
||||
this.lastBuildSucceeded = true;
|
||||
return {
|
||||
message: (hasEmoji ? '✅ ' : '') + 'Build successful',
|
||||
contentImage: successImage,
|
||||
status: 'success'
|
||||
};
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
|
||||
this.lastBuildSucceeded = false;
|
||||
|
||||
var message = '';
|
||||
if (error.module && error.module.rawRequest) {
|
||||
message = error.module.rawRequest + '\n';
|
||||
}
|
||||
|
||||
if (error.error) {
|
||||
message = (hasEmoji ? '❌ ' : '') + 'Error: ' + message + error.error.toString();
|
||||
} else if (error.warning) {
|
||||
message = (hasEmoji ? '⚠️ ' : '') + 'Warning: ' + message + error.warning.toString();
|
||||
} else if (error.message) {
|
||||
message = (hasEmoji ? '⚠️ ' : '') + 'Warning: ' + message + error.message.toString();
|
||||
}
|
||||
|
||||
return {
|
||||
message: stripANSI(message),
|
||||
contentImage: contentImage,
|
||||
status: status
|
||||
};
|
||||
};
|
||||
|
||||
WebpackNotifierPlugin.prototype.hasErrors = function hasErrors(stats) {
|
||||
return stats.hasErrors()
|
||||
|| stats.compilation.children.some(child => child.getStats().hasErrors());
|
||||
};
|
||||
|
||||
WebpackNotifierPlugin.prototype.hasWarnings = function hasWarnings(stats) {
|
||||
return stats.hasWarnings()
|
||||
|| stats.compilation.children.some(child => child.getStats().hasWarnings());
|
||||
};
|
||||
|
||||
WebpackNotifierPlugin.prototype.compilationDone = function compilationDone(stats) {
|
||||
var { message, contentImage, status } = this.compileEndOptions(stats);
|
||||
if (message) {
|
||||
var title = this.options.title ? this.options.title : 'Webpack';
|
||||
if (typeof title === 'function') {
|
||||
title = title({
|
||||
msg: message, // compatibility with v1.11.0
|
||||
message: message,
|
||||
status: status
|
||||
});
|
||||
}
|
||||
|
||||
var icon = (os.platform() === 'win32' || os.platform() === 'linux')
|
||||
? contentImage
|
||||
: undefined;
|
||||
|
||||
notifier.notify(Object.assign(
|
||||
{},
|
||||
this.options,
|
||||
{
|
||||
title,
|
||||
message,
|
||||
contentImage,
|
||||
icon
|
||||
}
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
WebpackNotifierPlugin.prototype.apply = function apply(compiler) {
|
||||
if (compiler.hooks) {
|
||||
var plugin = { name: 'Notifier' };
|
||||
|
||||
compiler.hooks.done.tap(plugin, this.compilationDone.bind(this));
|
||||
} else {
|
||||
compiler.plugin('done', this.compilationDone.bind(this));
|
||||
}
|
||||
};
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
+71
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"name": "webpack-notifier",
|
||||
"version": "1.15.0",
|
||||
"description": "webpack + node-notifier = build status system notifications",
|
||||
"main": "index.js",
|
||||
"types": "./index.d.ts",
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"logo.png"
|
||||
],
|
||||
"scripts": {
|
||||
"prepublishOnly": "npm run lint",
|
||||
"lint": "eslint index.js",
|
||||
"test": "jest",
|
||||
"test:coverage": "jest --coverage",
|
||||
"tsd": "tsd"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm run lint"
|
||||
}
|
||||
},
|
||||
"keywords": [
|
||||
"webpack",
|
||||
"notify",
|
||||
"notification",
|
||||
"node-notifier",
|
||||
"notifier",
|
||||
"build"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Turbo87/webpack-notifier.git"
|
||||
},
|
||||
"author": "Tobias Bieniek <tobias.bieniek@gmx.de>",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"node-notifier": "^9.0.0",
|
||||
"strip-ansi": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node-notifier": "^8.0.1",
|
||||
"@types/semver": "^7.3.8",
|
||||
"@types/webpack": ">4.41.31",
|
||||
"eslint": "^7.14.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"husky": "^4.3.0",
|
||||
"jest": "^24.9.0",
|
||||
"memfs": "^3.2.0",
|
||||
"semver": "^7.3.2",
|
||||
"ts-jest": "^24.3.0",
|
||||
"tsd": "^0.17.0",
|
||||
"typescript": "^3.9.7",
|
||||
"webpack-1": "npm:webpack@1",
|
||||
"webpack-2": "npm:webpack@2",
|
||||
"webpack-3": "npm:webpack@3",
|
||||
"webpack-4": "npm:webpack@4",
|
||||
"webpack-5": "npm:webpack@5",
|
||||
"webpack-latest": "npm:webpack@latest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/webpack": ">4.41.31"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/webpack": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user