Skip to content

Commit

Permalink
I-1: Update README and remove console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
Aori Nevo committed Aug 26, 2018
1 parent e09315a commit cb40a7a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 44 deletions.
93 changes: 55 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,74 @@
# Introduction

Apache plugin for `@lantis` cli manager built with redux and yargs.
Apache plugin for `@devly` cli manager built with redux and yargs.

# Installation

Install `redux`, `yargs`, and `@lantis/lantis-apache` in your project.
To add devly-hosts plugin to your project, first make sure your project is set-up to consume Devly plugins (see https://github.com/aorinevo/devly-example#introduction).

```bash
npm i redux yargs @lantis/lantis-apache
```

# Set-up

All lantis plugins assume that the consumer has the following directory structure somewhere in their working directory:
```
├── cli.js
├── actions
├── reducers
└── store.js
```

`reducers/index.js` is where you add the plugins' reducers
Next, install `@devly/devly-apache`:

```bash
npm i @devly/devly-apache
```
const { combineReducers } = require('redux');
const apacheReducer = require('@lantis/lantis-apache/reducers');

module.exports = combineReducers({
apache: apacheReducer
});
# Integration

Use `addApacheConfig` action creator to update the apache state in the devly-store. It is recommneded to place the initialState for apache in a `manifests/apache.js` file and requiring that file within the file that dispatches the action.

```js
// mainfests/hosts.js

module.exports = {
projectPath: '/etc/apache2',
configBarrels: [
{
fileName: 'test-main.conf',
content: 'some content',
directory: 'other',
},
],
certificatesAndKeys: [
{
fileName: 'cert.crt',
content: 'some cert 1',
directory: 'cert',
},
{
fileName: 'cert.key',
content: 'some key 1',
directory: 'cert',
},
{
fileName: 'server.crt',
content: 'some cert 2',
directory: 'cert',
},
{
fileName: 'server.key',
content: 'some key 2',
directory: 'cert',
},
],
};
```

`store.js`
It is recommended that the consumer create a `plugins/index.js` barrel file for the devly plugins it consumes.

```
const {createStore} = require('redux');
const rootReducer = require('./reducers');
```js
// plugins/index.js

const store = createStore(rootReducer);
require('./apache.js');

module.exports = store
```
// plugins/hosts.js
const {store} = require('@devly/devly-store');
const {addApacheConfig, addApacheCommands} = require('@devly/devly-hosts/actions');
const {dispatch} = store;

`cli.js`

```
const store = require('../scripts/reapps/store');
const yargs = require('yargs');
const {addApacheConfig, addApacheCommands} = require('@lantis/lantis-apache/actions');
const Apache = require('@lantis/lantis-apache/scripts/apache');
require('@devly/devly-apache');

store.dispatch(addApacheConfig(require('../manifests/apache')));
store.dispatch(addApacheCommands(yargs, new Apache(store)));
dispatch(addApacheConfig(require('./manifests/apache')));

module.exports = yargs;
dispatch(addApacheCommands());
```
2 changes: 0 additions & 2 deletions actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ const ADD_APACHE_CONFIG = 'ADD_APACHE_CONFIG';
const ADD_APACHE_COMMANDS = 'ADD_APACHE_COMMANDS';

function addApacheConfig (config) {
//console.log('config action fired: ', config);
return {
type: ADD_APACHE_CONFIG,
config
}
}

function addApacheCommands (yargs) {
console.log('action fired: ');
return {
type: ADD_APACHE_COMMANDS,
yargs
Expand Down
2 changes: 0 additions & 2 deletions reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ function updateHttpdVhosts(force, ports, vHost, fileName, directoryPath){
}

module.exports = function apacheReducer(state = initialState, action){
console.log('apacheReducer outside of switch statement : ', action.type);
switch (action.type) {
case ADD_APACHE_CONFIG:
return addApacheConfig(state, action.config);
case ADD_APACHE_COMMANDS:
console.log('add command reducer: ');
return addApacheCommands(state);
case UPDATE_HTTPD_VHOSTS:
return updateHttpdVhosts(state);
Expand Down
2 changes: 0 additions & 2 deletions scripts/apache.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ module.exports = class Apache {

}
init(force) {
console.log('testtest: ', store);
console.log(store.getState());
const {projectPath, certificatesAndKeys, configBarrels } = store.getState().apache;
initProxyServer(force, certificatesAndKeys, configBarrels, projectPath);
}
Expand Down

0 comments on commit cb40a7a

Please sign in to comment.