Skip to content

Commit

Permalink
refactoring documentation, example configuration, and removed test ha…
Browse files Browse the repository at this point in the history
…rness
  • Loading branch information
computamike committed Dec 7, 2017
1 parent 7e552dc commit 839765b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 79 deletions.
7 changes: 3 additions & 4 deletions .huerc-example
@@ -1,6 +1,5 @@
{
"name": "",
"myConfigVariable": "3abxxxxxxxxxxxxxxxxx0f5",
"pollInterval": 2000,
"light": "Hue color lamp 2"
"name": "huelog-slack",
"logLevel": "info",
"slackWebhookUrl": "slack address here"
}
74 changes: 23 additions & 51 deletions README.md
@@ -1,67 +1,39 @@
# huelog-slack

[![NPM Package](https://img.shields.io/npm/v/huestatus.svg?maxAge=2592000)](https://npmjs.com/package/huelog-slack)
[![Build Status](https://travis-ci.org/APCOvernight/huelog-slack.svg?branch=master)](https://travis-ci.org/APCOvernight/huelog-slack) [![Coverage Status](https://coveralls.io/repos/github/APCOvernight/huelog-slack/badge.svg?branch=master)](https://coveralls.io/github/APCOvernight/huelog-slack?branch=master) [![Maintainability]( https://img.shields.io/codeclimate/maintainability/APCOvernight/huelog-slack.svg)](https://codeclimate.com/github/APCOvernight/huelog-slack/maintainability)
[![Dependencies](https://img.shields.io/david/APCOvernight/huelog-slack.svg)](https://david-dm.org/APCOvernight/huelog-slack) [![Greenkeeper badge](https://badges.greenkeeper.io/APCOvernight/huelog-slack.svg)](https://greenkeeper.io/)

Template [HueStatus](https://github.com/APCOvernight/huestatus/) module

## Get Started

- Clone or Fork this Repo
- Add your desired module name, version, git repo, author etc to package.json
- Run `npm install` to install dependencies
- Make sure [HueStatus](https://github.com/APCOvernight/huestatus/) is installed globally `npm install -g huestatus`

## Building your module

The entry point for this module is index.js. It must export a class that extends the [BaseModule class from HueStatus](https://github.com/APCOvernight/huestatus/blob/master/src/Module.js).
[Slack](https://slack.com/) output for huestatus events

Your module class must have a `start` method. This is called when the module is loaded and HueStatus is ready to start updating.
## Features
- Broadcasts status events onto a slack channel

Your module class can optionally have a `generateInstanceName` method, that generates a unique instanceName for use in debugging. If this method is omitted a uuid will be generated instead.
## Installation

The BaseModule constructor adds the module config object to `this.config`. It also creates an event emitter at `this.emitter` but you shouldn't have to access this directly. You should use the change method (see below). Configuration is read from the `.heurc` file, typically located in your home directory.

### this.change(status, message) ⇒ <code>async function</code>
The BaseModule change method is used to update the status (by emitting an event to the huestatus module).

**Returns**: <code>Promise</code>
```
npm install -g huestatus huelog-slack
```

| Param | Type | Description |
| --- | --- | --- |
| status | <code>String</code> | The status to send to the Hue Light - One of '*ok*', '*alert*', '*warning*', '*working*' |
| message | <code>String</code> | Message to send to the debug log. (Why is the status changing?) |
Create a `.huerc` file on your home directory, see [HueStatus Docs](https://www.npmjs.com/package/huestatus) for more info. Add an object like this to the reporters array:

**Example**
```js
if (someConditionIsMet) {
await this.change('ok', 'everything is ok')
{
"name": "huelog-slack",
"logLevel": "info",
"slackWebhookUrl": "slack address here"
}

```

## Testing

The default codestyle in this repository is [APC-style](https://github.com/APCOvernight/apc-style). Run `npm run lint` to lint all js files in your project.

Unit tests based on [mocha](https://mochajs.org/) are included in the `test` folder. Run these with `npm run test` command. Test coverage is calculated using [nyc](https://github.com/istanbuljs/nyc).

[Stryker](https://stryker-mutator.github.io/) mutation tests can be run with `npm run stryker`

### Running in your local environment

Run `npm link` ([docs](https://docs.npmjs.com/cli/link)) from the project directory, to make it available to node globally. Then you can register it in your .huerc and run `huestatus` to test it manually.

## Integrations

A .travis.yml file is included for simple [Continuous Integration in Travis](https://travis-ci.org). You will need to add your repo to travis to set up automated builds.

The npm coverage script is set up to send coverage to [Coveralls](https://coveralls.io/) and [Code Climate](https://codeclimate.com/) upon build. You will need to create an account and add your repositories there for this to work.

## Publishing

Make sure to write your own `README.md`, and to replace all references in `package.json` to your new module name.
## Configuring a slack app (in slack)
* Click your workspace name in the top left to open the menu.
* Select Manage Apps.
* Select Custom Integrations
* Click on Incoming WebHooks
* Click Add Configuration
* Select the channel that messages will be posted to, or create a new channel
* Click Add Incoming WebHooks integrations
* The Webhook URL address should be copied into the `.huerc` configuration file, under the setting `slackWebhookUrl`

You should include a `.huerc-example` file with an example of all the possible module config variables.

When you are ready, publish to NPM with `npm publish`.
Then run `huestatus`. As monitored statuses change, HueStatus will output information to the slack channel.
18 changes: 12 additions & 6 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "",
"name": "huelog-slack",
"version": "0.1.0",
"description": "HueStatus module for...",
"description": "HueStatus module for slack reporting.",
"main": "index.js",
"scripts": {
"test": "npm run lint && nyc mocha",
Expand Down Expand Up @@ -30,18 +30,21 @@
"stryker-mocha-framework": "^0.7.1",
"stryker-mocha-runner": "^0.10.1"
},
"repository": {},
"repository": {
"type": "git",
"url": "git+https://github.com/APCOvernight/huelog-slack.git"
},
"keywords": [
"huestatus",
"philips",
"hue",
"status",
"light"
],
"author": "",
"author": "Mike Hingley",
"license": "MIT",
"bugs": {},
"homepage": "",
"bugs":{"url":"https://github.com/APCOvernight/huelog-slack/issues"},
"homepage": "https://github.com/APCOvernight/huelog-slack#readme",
"nyc": {
"include": [
"index.js"
Expand Down Expand Up @@ -73,5 +76,8 @@
"cobertura"
],
"cache": true
},
"directories": {
"test": "test"
}
}
18 changes: 0 additions & 18 deletions testharness.js

This file was deleted.

0 comments on commit 839765b

Please sign in to comment.