change on services, docker localDB y jasmime

This commit is contained in:
Vicente Falco 2017-10-24 08:56:18 +02:00
parent 2be39c0deb
commit 1c5a65928e
6 changed files with 50 additions and 10515 deletions

View File

@ -15,7 +15,6 @@ var WebpackDevServer = require('webpack-dev-server');
var exec = require('child_process').exec;
// Configuration
var srcDir = './client';
var buildDir = './services/nginx/static';
var langs = ['es', 'en'];
@ -38,19 +37,16 @@ gulp.task('client', ['clean'], function() {
return gulp.start('watch', 'routes', 'locales', 'webpack-dev-server');
});
gulp.task('services', function() {
require('./services/mailer/server.js').start();
var lbServices = [
'auth',
'salix',
'client',
'production',
'route'
];
for (var service of lbServices)
require(`./services/${service}/server/server.js`).start();
gulp.task('services', () => {
process.env.NODE_ENV = gutil.env.env || 'development';
const pathServices = './services/';
const services = fs.readdirSync(pathServices);
services.splice(services.indexOf('loopback'), 1);
return services.forEach(service => {
const serviceJs = pathServices.concat(service, '/server/server.js');
if (fs.existsSync(serviceJs))
require(serviceJs).start();
});
});
gulp.task('clean', function() {
@ -101,7 +97,7 @@ gulp.task('webpack-dev-server', function() {
contentBase: buildDir,
quiet: false,
noInfo: false,
// hot: true,
// hot: true,
stats: {
assets: true,
colors: true,
@ -140,37 +136,49 @@ var routeFiles = `${srcDir}/**/routes.json`;
gulp.task('routes', function() {
return gulp.src(routeFiles)
.pipe(concat('routes.js', {newLine: ','}))
.pipe(wrap('var routes = [<%=contents%>\n];'))
.pipe(gulp.dest(buildDir));
.pipe(concat('routes.js', {newLine: ','}))
.pipe(wrap('var routes = [<%=contents%>\n];'))
.pipe(gulp.dest(buildDir));
});
// Watch
gulp.task('watch', function() {
gulp.watch(routeFiles, ['routes']);
gulp.watch(localeFiles, ['locales']);
});
gulp.task('test', () => {
process.env.NODE_ENV = gutil.env.env || 'test';
console.log(process.env.NODE_ENV);
runSequence('deleteDockerDb', 'buildDockerDb', 'runDockerDb');
// Test environment
gulp.task('test', callback => {
return require('./services_tests').start();
});
gulp.task('runDockerDb', (callback) => {
exec('docker run -d --name dblocal -p 3306:3306 dblocal:latest', (err, stdout, stderr) => {
callback(err);
// docker dblocal
gulp.task('docker', callback => {
runSequence('deleteDockerDb', 'deleteDockerImageDb', 'buildDockerDb', 'runDockerDb', callback);
});
gulp.task('runDockerDb', callback => {
exec('docker run -d --name dblocal -p 3306:3306 dblocal', (err, stdout, stderr) => {
setTimeout(() => {
callback(err);
}, 15000);
});
});
gulp.task('buildDockerDb', (callback) => {
gulp.task('buildDockerDb', callback => {
exec('docker build -t dblocal:latest ./services/db', (err, stdout, stderr) => {
callback(err);
});
});
gulp.task('deleteDockerDb', (callback) => {
exec('docker rm -f dblocal', (err, stdout, stderr) => {
callback();
gulp.task('deleteDockerImageDb', callback => {
exec('docker rmi dblocal:latest', (err, stdout, stderr) => {
callback(err = null);
});
});
gulp.task('deleteDockerDb', callback => {
exec('docker stop dblocal && docker wait dblocal && docker rm -f dblocal', (err, stdout, stderr) => {
callback(err = null);
});
});

10475
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@
"flatpickr": "^2.6.3",
"material-design-lite": "^1.3.0",
"mg-crud": "^1.1.2",
"nodemon": "^1.12.1",
"oclazyload": "^0.6.3",
"validator": "^6.2.1"
},
@ -58,7 +59,6 @@
"merge-stream": "^1.0.1",
"nightmare": "^2.10.0",
"node-sass": "^3.11.0",
"nodemon": "^1.12.0",
"raw-loader": "*",
"run-sequence": "^2.2.0",
"sass-loader": "^4.0.2",

View File

@ -3,7 +3,7 @@ let app = require('../../../../server/server');
describe('Client Create()', () => {
let data = {
name: 'Max Eisenhardt',
name: 'MaxEisenhardt',
userName: 'Magneto',
email: 'magneto@marvel.com',
fi: 'X-tax number',

View File

@ -1,17 +1,17 @@
var express = require('express');
var app = module.exports = express();
var bodyParser = require('body-parser');
var settings = require('./application/settings.js');
var mail = require('./application/mail.js');
var database = require('./application/database.js');
var auth = require('./application/auth.js');
var settings = require('../application/settings.js');
var mail = require('../application/mail.js');
var database = require('../application/database.js');
var auth = require('../application/auth.js');
var path = require('path');
// Body parser middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use('/static', express.static(path.join(__dirname, '/static')));
app.use('/static', express.static(path.join(__dirname, '../static')));
// Auth middleware
var requestToken = function(request, response, next) {
@ -19,7 +19,7 @@ var requestToken = function(request, response, next) {
};
// Load routes
app.use('/', requestToken, require('./application/router.js'));
app.use('/', requestToken, require('../application/router.js'));
app.start = function() {
var listener = app.listen(settings.app().port, function() {
@ -28,7 +28,7 @@ app.start = function() {
database.init();
database.testEmail();
let packageJson = require('./package.json');
let packageJson = require('../package.json');
console.log(`Web server ${packageJson.name} listening at: ${servicePath}`);
if (settings.app().debug) {

View File

@ -36,4 +36,6 @@ jasmine.addReporter(new SpecReporter({
}
}));
jasmine.execute();
exports.start = () => {
jasmine.execute();
};