Skip to content

Commit

Permalink
Merge 0cf3d8c into 02e7473
Browse files Browse the repository at this point in the history
  • Loading branch information
makara committed Apr 4, 2018
2 parents 02e7473 + 0cf3d8c commit 9f826d4
Show file tree
Hide file tree
Showing 37 changed files with 1,306 additions and 1,472 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/backup/
/coverage/
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "wcl-backend"
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
!.gitkeep
!.gitignore
!.npmignore
!.jscsrc
!.eslintignore
!.eslintrc
!.travis.yml
!.coveralls.yml
!.istanbul.yml
Expand Down
7 changes: 0 additions & 7 deletions .jscsrc

This file was deleted.

5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ branches:
- master
node_js:
- "8"
- "6"
- "4"
services:
- docker
install:
- npm install
- npm prune
before_script:
- make fixture-build
- make fixture-up
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MOCHA_OPTS = -b --timeout 10000 --reporter spec

lint:
@echo "Linting..."
@$(BIN)/jscs index.js bin lib test
@$(BIN)/eslint .
test: lint
@echo "Testing..."
@$(ENV) $(BIN)/_mocha $(MOCHA_OPTS) $(TESTS)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Mock multiple (micro-)services with Docker boxes and gateway with Kong.
- _Always shutdown the docker boxes before you change anything_
- Download and install Docker
- `npm install -g micro-mockers`
- `cd` to your work directory (see `example` as an example)
- `cd` to your work directory (see `test/fixture` as an example)
- `mm build`
- `mm up`
- `mm down`
Expand Down
9 changes: 5 additions & 4 deletions bin/mm-down.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ lib.command
.parse(process.argv);

const config = new Config(lib.command.context);

const child = spawn('docker-compose', ['-f', config.compose, 'down']);
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
config.load().then(() => {
const child = spawn('docker-compose', ['-f', config.compose, 'down']);
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
});
45 changes: 23 additions & 22 deletions bin/mm-up.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
const debug = require('debug')('mm:bin:up');
const spawn = require('child_process').spawn;

const pEvent = require('p-event');
const Promise = require('bluebird');

const lib = require('../lib');
const Config = lib.classes.Config;
const adminApi = lib.kong.adminApi;
Expand All @@ -13,26 +16,24 @@ lib.command
.parse(process.argv);

const config = new Config(lib.command.context);
const host = config.adminApi;
const status = new adminApi.Status(host);
const plugins = new adminApi.Plugins(host);
const apis = new adminApi.Apis(host);

debug('running docker-compose up');
const child = spawn('docker-compose', ['-f', config.compose, 'up', '-d', '--build']);
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);

child.on('close', (code) => {
// TODO: error handling when code > 0.
debug('docker-compose up finished with code %s', code);
status.ping().then(syncPlugins).then(syncApis).catch(debug);
config.load().then(() => {
const host = config.adminApi;
const status = new adminApi.Status(host);
const plugins = new adminApi.Plugins(host);
const apis = new adminApi.Apis(host);

debug('running docker-compose up');
const child = spawn('docker-compose', ['-f', config.compose, 'up', '-d', '--build']);
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);

return Promise.resolve(pEvent(child, 'close')).then(Promise.coroutine(function*(code) {
debug('docker-compose up finished with code %s', code);
if (code > 0) {
throw new Error('docker-compose up failed');
}
yield status.ping();
yield plugins.syncAll(config.plugins || []);
yield apis.syncAll(config.apis || []);
}));
});

function syncPlugins() {
return plugins.syncAll(config.plugins || []);
}

function syncApis() {
return apis.syncAll(config.apis || []);
}
4 changes: 0 additions & 4 deletions example/.gitignore

This file was deleted.

Empty file removed example/build/.gitkeep
Empty file.
26 changes: 0 additions & 26 deletions example/config.json

This file was deleted.

45 changes: 0 additions & 45 deletions example/docker-compose.tpl.yml

This file was deleted.

4 changes: 0 additions & 4 deletions example/dockers/docs/Dockerfile

This file was deleted.

24 changes: 0 additions & 24 deletions example/dockers/docs/nginx.conf

This file was deleted.

6 changes: 0 additions & 6 deletions example/dockers/mocks/Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions example/example/README.md

This file was deleted.

15 changes: 0 additions & 15 deletions example/example/drakov.js

This file was deleted.

4 changes: 0 additions & 4 deletions example/example/example-include.md

This file was deleted.

19 changes: 0 additions & 19 deletions example/example/example-schema.json

This file was deleted.

0 comments on commit 9f826d4

Please sign in to comment.