feat: refs #5483 unify DB #1955
|
@ -1,6 +1,10 @@
|
|||
const Docker = require('../db/docker.js');
|
||||
const path = require('path');
|
||||
const Myt = require('../../myt/myt');
|
||||
const Run = require('../../myt/myt-run');
|
||||
let dataSources = require('../loopback/server/datasources.json');
|
||||
|
||||
let myt;
|
||||
|
||||
process.on('warning', warning => {
|
||||
console.log(warning.name);
|
||||
console.log(warning.message);
|
||||
|
@ -8,28 +12,28 @@ process.on('warning', warning => {
|
|||
});
|
||||
|
||||
process.on('SIGUSR2', async() => {
|
||||
if (container) await container.rm();
|
||||
if (myt) await myt.deinit();
|
||||
});
|
||||
|
||||
process.on('exit', async function() {
|
||||
if (container) await container.rm();
|
||||
if (myt) await myt.deinit();
|
||||
});
|
||||
|
||||
let container;
|
||||
async function test() {
|
||||
let isCI = false;
|
||||
const isCI = process.argv[2] === 'ci';
|
||||
|
||||
if (process.argv[2] === 'ci')
|
||||
isCI = true;
|
||||
myt = new Myt();
|
||||
await myt.init({
|
||||
workspace: path.join(__dirname, '..'),
|
||||
random: true,
|
||||
ci: isCI
|
||||
});
|
||||
const {dbConfig} = await myt.run(Run);
|
||||
|
||||
container = new Docker();
|
||||
|
||||
await container.run(isCI);
|
||||
dataSources = JSON.parse(JSON.stringify(dataSources));
|
||||
|
||||
Object.assign(dataSources.vn, {
|
||||
host: container.dbConf.host,
|
||||
port: container.dbConf.port
|
||||
host: dbConfig.host,
|
||||
port: dbConfig.port
|
||||
});
|
||||
|
||||
const bootOptions = {dataSources};
|
||||
|
@ -77,7 +81,7 @@ async function test() {
|
|||
|
||||
await jasmine.execute();
|
||||
if (app) await app.disconnect();
|
||||
if (container) await container.rm();
|
||||
if (myt) await myt.deinit();
|
||||
console.log('App disconnected & container removed');
|
||||
}
|
||||
|
||||
|
|
17
gulpfile.js
17
gulpfile.js
|
@ -3,7 +3,9 @@ const gulp = require('gulp');
|
|||
const PluginError = require('plugin-error');
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
const log = require('fancy-log');
|
||||
const Docker = require('./db/docker.js');
|
||||
const Myt = require('../myt/myt');
|
||||
const Run = require('../myt/myt-run');
|
||||
const Start = require('../myt/myt-start');
|
||||
|
||||
// Configuration
|
||||
|
||||
|
@ -231,14 +233,18 @@ watch.description = `Watches for changes in routes and locale files`;
|
|||
|
||||
// Docker
|
||||
async function dockerStart() {
|
||||
const container = new Docker('salix-db');
|
||||
await container.start();
|
||||
const myt = new Myt();
|
||||
await myt.init({workspace: __dirname});
|
||||
await myt.run(Start);
|
||||
await myt.deinit();
|
||||
}
|
||||
dockerStart.description = `Starts the salix-db container`;
|
||||
|
||||
async function docker() {
|
||||
const container = new Docker('salix-db');
|
||||
await container.run();
|
||||
const myt = new Myt();
|
||||
await myt.init({workspace: __dirname});
|
||||
await myt.run(Run);
|
||||
await myt.deinit();
|
||||
}
|
||||
docker.description = `Runs the salix-db container`;
|
||||
|
||||
|
@ -258,5 +264,6 @@ module.exports = {
|
|||
locales,
|
||||
localesRoutes,
|
||||
watch,
|
||||
dockerStart,
|
||||
docker
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue