# NodeWrite

[![Build Status](https://travis-ci.org/nodewrite/nodewrite.svg?branch=master)](https://travis-ci.org/nodewrite/nodewrite)
[![Code Climate](https://codeclimate.com/github/nodewrite/nodewrite/badges/gpa.svg)](https://codeclimate.com/github/nodewrite/nodewrite)
[![Coverage Status](https://coveralls.io/repos/github/nodewrite/nodewrite/badge.svg?branch=master)](https://coveralls.io/github/nodewrite/nodewrite?branch=master)
[![Dependency Status](https://gemnasium.com/badges/github.com/nodewrite/nodewrite.svg)](https://gemnasium.com/github.com/nodewrite/nodewrite)

![Screenshot](https://github.com/nodewrite/nodewrite/raw/master/screenshot.png)

## Requirements
* [Node.js Latest LTS Version 6](https://nodejs.org/en/download/)
* [RethinkDB](https://www.rethinkdb.com/docs/install/)

## Installation
Clone respository to your system:
```shell
git clone https://github.com/nodewrite/nodewrite.git
```
Install package dependencies:
```shell
npm install --loglevel=error --depth=0
```

### Configuration
After npm installation is complete a gulp task will the copy default configuration file for each installed plugin into the `/config/default` directory. You can change the values within default configuration files, but each package update will cause the defaults to be overwritten by the upgraded version.

To make configuration changes that are permanent you'll want to create a sub-directory within `/config` that targets your current `NODE_ENV` and store your settings there instead. The quickest way to do this is by duplicating the `config/default` directory. Optionally, you may add individual config files and settings as needed as opposed to duplicating all the defaults.

The configuration object loaded on startup is merged together such that the global `config/default` settings are loaded first followed by the merging of keys provided by an environment's custom `config/[env]` directory.

The example configuration provided below is targeting three different environments each with its own `nodewrite-core-data` settings. Plugin configuration options not provided by a custom environment are inherited from the defaults:
```
.
├── /config
|   ├── /default
|   |   ├── core-data.yml
|   |   ├── plugin-gravatar.yml
|   |   └── etc...
|   ├── /development
|   |   └── core-data.yml
|   └── /production
|   |   └── core-data.yml
```

> If `NODE_ENV` is not set, but a `config/development` directory exists then it will be used automatically without the need to set your `NODE_ENV` to `development`.

## API
Public events and methods provided by this package are outlined below.

### Events
Events for this package are emitted on the `nodewrite` channel:

* `register` - plugin was registered by the server with signature `function(packageName)` where:
  * `packageName` - package name of the plugin that was registered.
