Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
166d43c561
|
@ -1,5 +1,6 @@
|
||||||
import './styles/mdl-override.css';
|
import './styles/mdl-override.css';
|
||||||
import './styles/mdi-override.css';
|
import './styles/mdi-override.css';
|
||||||
|
import './styles/zoom-image.css';
|
||||||
|
|
||||||
export * from './module';
|
export * from './module';
|
||||||
export * from './directives/index';
|
export * from './directives/index';
|
||||||
|
|
|
@ -4,3 +4,4 @@ import './dialog';
|
||||||
import './validation';
|
import './validation';
|
||||||
import './acl';
|
import './acl';
|
||||||
import './on-error-src';
|
import './on-error-src';
|
||||||
|
import './zoom-image';
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
describe('Directive zoomImage', () => {
|
||||||
|
let idContainer = 'zoomImage';
|
||||||
|
let compile;
|
||||||
|
let scope;
|
||||||
|
let srcDefault = 'http://default.img.jpg/';
|
||||||
|
let srcZoom = 'http://zoom.img.jpg/';
|
||||||
|
let findContainer;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
angular.mock.module('client');
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(angular.mock.inject(($compile, $rootScope) => {
|
||||||
|
compile = $compile;
|
||||||
|
scope = $rootScope.$new();
|
||||||
|
}));
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
findContainer = document.getElementById(idContainer);
|
||||||
|
if (findContainer) {
|
||||||
|
findContainer.parentNode.removeChild(findContainer);
|
||||||
|
findContainer = undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function getCompiledImage(imgHtml) {
|
||||||
|
let element = angular.element(imgHtml);
|
||||||
|
var compiledElement = compile(element)(scope);
|
||||||
|
scope.$digest();
|
||||||
|
return compiledElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
it('should create zoom container when click into image', () => {
|
||||||
|
let image = getCompiledImage(`<img src="${srcDefault}" zoom-image>`);
|
||||||
|
image[0].click();
|
||||||
|
findContainer = document.getElementById(idContainer);
|
||||||
|
|
||||||
|
expect(findContainer).not.toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should detroy zoom container when click outside zoomed image', () => {
|
||||||
|
let image = getCompiledImage(`<img src="${srcDefault}" zoom-image>`);
|
||||||
|
image[0].click();
|
||||||
|
findContainer = document.getElementById(idContainer);
|
||||||
|
|
||||||
|
let findOutsideImage = findContainer.querySelector('.zoomImage-background');
|
||||||
|
findOutsideImage.click();
|
||||||
|
|
||||||
|
findContainer = document.getElementById(idContainer);
|
||||||
|
|
||||||
|
expect(findContainer).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create new image, into zoom container, with src as original image src', () => {
|
||||||
|
let image = getCompiledImage(`<img src="${srcDefault}" zoom-image>`);
|
||||||
|
image[0].click();
|
||||||
|
findContainer = document.getElementById(idContainer);
|
||||||
|
let findNewImage = findContainer.querySelector('img');
|
||||||
|
|
||||||
|
expect(findNewImage.src).toEqual(srcDefault);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create new image, into zoom container, with src likes zoomImage value', () => {
|
||||||
|
let image = getCompiledImage(`<img src="${srcDefault}" zoom-image="${srcZoom}">`);
|
||||||
|
image[0].click();
|
||||||
|
findContainer = document.getElementById(idContainer);
|
||||||
|
let findNewImage = findContainer.querySelector('img');
|
||||||
|
|
||||||
|
expect(findNewImage.src).toEqual(srcZoom);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,89 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
|
||||||
|
export function directive($timeout) {
|
||||||
|
let idContainer = 'zoomImage';
|
||||||
|
let container;
|
||||||
|
let background;
|
||||||
|
let image;
|
||||||
|
|
||||||
|
function createContainers(src) {
|
||||||
|
if (document.getElementById(idContainer)) {
|
||||||
|
destroyContainers();
|
||||||
|
}
|
||||||
|
container = document.createElement('div');
|
||||||
|
container.id = idContainer;
|
||||||
|
|
||||||
|
background = document.createElement('div');
|
||||||
|
background.className = 'zoomImage-background';
|
||||||
|
container.appendChild(background);
|
||||||
|
|
||||||
|
image = document.createElement('img');
|
||||||
|
image.src = src;
|
||||||
|
container.appendChild(image);
|
||||||
|
|
||||||
|
document.body.appendChild(container);
|
||||||
|
|
||||||
|
$timeout(() => {
|
||||||
|
resizeImage();
|
||||||
|
container.className = 'open';
|
||||||
|
}, 250);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addListeners() {
|
||||||
|
background.addEventListener('click', destroyContainers);
|
||||||
|
document.addEventListener('keydown', e => keyDownHandler(e));
|
||||||
|
window.addEventListener('resize', resizeImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeListeners() {
|
||||||
|
if (container) {
|
||||||
|
background.removeEventListener('click', destroyContainers);
|
||||||
|
document.removeEventListener('keydown', e => keyDownHandler(e));
|
||||||
|
window.removeEventListener('resize', resizeImage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function keyDownHandler(event) {
|
||||||
|
if (event.keyCode === 27) {
|
||||||
|
destroyContainers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroyContainers() {
|
||||||
|
if (document.getElementById(idContainer)) {
|
||||||
|
removeListeners();
|
||||||
|
container.parentNode.removeChild(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
container = undefined;
|
||||||
|
background = undefined;
|
||||||
|
image = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resizeImage() {
|
||||||
|
if (image) {
|
||||||
|
image.style.marginLeft = `-${Math.floor(image.clientWidth / 2)}px`;
|
||||||
|
image.style.marginTop = `-${Math.floor(image.clientHeight / 2)}px`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
restrict: 'A',
|
||||||
|
priority: 9999,
|
||||||
|
link: function($scope, $element, $attrs) {
|
||||||
|
$element.on('click', function(event) {
|
||||||
|
let src = $attrs.zoomImage || $attrs.src;
|
||||||
|
if (src) {
|
||||||
|
createContainers(src);
|
||||||
|
addListeners();
|
||||||
|
} else
|
||||||
|
throw new Error('No image source detected');
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
directive.$inject = ['$timeout'];
|
||||||
|
|
||||||
|
ngModule.directive('zoomImage', directive);
|
|
@ -0,0 +1,40 @@
|
||||||
|
img[zoom-image]{
|
||||||
|
cursor: zoom-in;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#zoomImage, div#zoomImage .zoomImage-background {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
z-index: 11;
|
||||||
|
}
|
||||||
|
div#zoomImage{
|
||||||
|
opacity: 0;
|
||||||
|
transition: visibility 0s, opacity 0.5s linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#zoomImage .zoomImage-background{
|
||||||
|
background: rgba(0, 0, 0, 0.7);
|
||||||
|
cursor: zoom-out;
|
||||||
|
}
|
||||||
|
div#zoomImage img{
|
||||||
|
z-index: 12;
|
||||||
|
position: fixed;
|
||||||
|
max-height: 98%;
|
||||||
|
max-width: 98%;
|
||||||
|
left: 50%;
|
||||||
|
top: 50%;
|
||||||
|
opacity: 0;
|
||||||
|
transition: visibility 0s, opacity 1s linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#zoomImage.open {
|
||||||
|
visibility: visible;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#zoomImage.open img{
|
||||||
|
visibility: visible;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
|
@ -16,7 +16,6 @@ class ItemCard {
|
||||||
{relation: "producer"},
|
{relation: "producer"},
|
||||||
{relation: "intrastat"},
|
{relation: "intrastat"},
|
||||||
{relation: "expence"},
|
{relation: "expence"},
|
||||||
{relation: "taxClass"},
|
|
||||||
{relation: "itemTag", scope: {order: "priority ASC", include: {relation: "tag"}}}
|
{relation: "itemTag", scope: {order: "priority ASC", include: {relation: "tag"}}}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,8 +21,8 @@ describe('Item', () => {
|
||||||
describe('$onInit()', () => {
|
describe('$onInit()', () => {
|
||||||
it('should request to patch the propagation of tax status', () => {
|
it('should request to patch the propagation of tax status', () => {
|
||||||
controller.client = {id: 123, isEqualizated: false};
|
controller.client = {id: 123, isEqualizated: false};
|
||||||
$httpBackend.whenGET('/item/api/Items/undefined?filter={"include":[{"relation":"itemType"},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"},{"relation":"taxClass"},{"relation":"itemTag","scope":{"order":"priority ASC","include":{"relation":"tag"}}}]}').respond({data: 'item'});
|
$httpBackend.whenGET('/item/api/Items/undefined?filter={"include":[{"relation":"itemType"},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"},{"relation":"itemTag","scope":{"order":"priority ASC","include":{"relation":"tag"}}}]}').respond({data: 'item'});
|
||||||
$httpBackend.expectGET('/item/api/Items/undefined?filter={"include":[{"relation":"itemType"},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"},{"relation":"taxClass"},{"relation":"itemTag","scope":{"order":"priority ASC","include":{"relation":"tag"}}}]}');
|
$httpBackend.expectGET('/item/api/Items/undefined?filter={"include":[{"relation":"itemType"},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"},{"relation":"itemTag","scope":{"order":"priority ASC","include":{"relation":"tag"}}}]}');
|
||||||
controller.$onInit();
|
controller.$onInit();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
<vn-title>New item</vn-title>
|
<vn-title>New item</vn-title>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield vn-one label="Name" field="$ctrl.item.name" vn-focus></vn-textfield>
|
<vn-textfield vn-one label="Name" field="$ctrl.item.name" vn-focus></vn-textfield>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
url="/item/api/ItemTypes"
|
url="/item/api/ItemTypes"
|
||||||
label="Type"
|
label="Type"
|
||||||
|
@ -20,8 +22,6 @@
|
||||||
field="$ctrl.item.typeFk"
|
field="$ctrl.item.typeFk"
|
||||||
>
|
>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
url="/item/api/Intrastats"
|
url="/item/api/Intrastats"
|
||||||
label="Intrastat"
|
label="Intrastat"
|
||||||
|
@ -33,7 +33,6 @@
|
||||||
>
|
>
|
||||||
<tpl-item>{{$parent.$parent.item.description}}</tpl-item>
|
<tpl-item>{{$parent.$parent.item.description}}</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-textfield vn-one label="Relevancy" field="$ctrl.item.relevancy" type="number"></vn-textfield>
|
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
|
|
|
@ -60,19 +60,6 @@
|
||||||
initial-data="$ctrl.item.expence"
|
initial-data="$ctrl.item.expence"
|
||||||
></vn-autocomplete>
|
></vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
|
||||||
<vn-autocomplete vn-one
|
|
||||||
url="/item/api/TaxClasses"
|
|
||||||
label="TaxClass"
|
|
||||||
show-field="description"
|
|
||||||
value-field="id"
|
|
||||||
order="description ASC"
|
|
||||||
filter-search="{where: {description: {regexp: 'search'}} }"
|
|
||||||
field="$ctrl.item.taxClassFk"
|
|
||||||
initial-data="$ctrl.item.taxClass"
|
|
||||||
><tpl-item>{{$parent.$parent.item.description}}</tpl-item></vn-autocomplete>
|
|
||||||
<vn-one></vn-one>
|
|
||||||
</vn-horizontal>
|
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-button-bar>
|
<vn-button-bar>
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
<img ng-src="/static/images/icon_item.png"/>
|
<img ng-src="/static/images/icon_item.png"/>
|
||||||
</vn-auto>
|
</vn-auto>
|
||||||
<vn-auto pad-medium text-center>
|
<vn-auto pad-medium text-center>
|
||||||
<img ng-src="http://verdnatura.es/vn-image-data/catalog/200x200/{{$ctrl.item.image}}" on-error-src/>
|
<img
|
||||||
|
ng-src="http://verdnatura.es/vn-image-data/catalog/200x200/{{$ctrl.item.image}}"
|
||||||
|
zoom-image="http://verdnatura.es/vn-image-data/catalog/900x900/{{$ctrl.item.image}}" on-error-src/>
|
||||||
</vn-auto>
|
</vn-auto>
|
||||||
<vn-auto pad-medium>
|
<vn-auto pad-medium>
|
||||||
<div><span translate>Id</span>: <b>{{$ctrl.item.id}}</b></div>
|
<div><span translate>Id</span>: <b>{{$ctrl.item.id}}</b></div>
|
||||||
|
|
|
@ -4,53 +4,42 @@
|
||||||
<vn-textfield vn-one label="Id" model="$ctrl.filter.id" vn-focus></vn-textfield>
|
<vn-textfield vn-one label="Id" model="$ctrl.filter.id" vn-focus></vn-textfield>
|
||||||
<vn-textfield vn-three label="Description" model="$ctrl.filter.description"></vn-textfield>
|
<vn-textfield vn-three label="Description" model="$ctrl.filter.description"></vn-textfield>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield vn-one label="Category" type="number" model="$ctrl.filter.category"></vn-textfield>
|
<vn-textfield vn-one label="Category" type="number" model="$ctrl.filter.category"></vn-textfield>
|
||||||
<vn-textfield vn-one label="Size" type="number" model="$ctrl.filter.itemSize"></vn-textfield>
|
<vn-textfield vn-one label="Size" type="number" model="$ctrl.filter.itemSize"></vn-textfield>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
url="/item/api/ItemTypes"
|
url="/item/api/ItemTypes"
|
||||||
label="Type"
|
label="Type"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
field="$ctrl.filter.typeFk"
|
field="$ctrl.filter.typeFk">
|
||||||
>
|
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
url="/item/api/Inks"
|
url="/item/api/Inks"
|
||||||
label="Ink"
|
label="Ink"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
field="$ctrl.filter.inkFk"
|
field="$ctrl.filter.inkFk">
|
||||||
>
|
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
url="/item/api/Origins"
|
url="/item/api/Origins"
|
||||||
label="Origin"
|
label="Origin"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
field="$ctrl.filter.originFk"
|
field="$ctrl.filter.originFk">
|
||||||
>
|
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
url="/item/api/Producers"
|
url="/item/api/Producers"
|
||||||
label="Producer"
|
label="Producer"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
field="$ctrl.filter.producerFk"
|
field="$ctrl.filter.producerFk">
|
||||||
>
|
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
||||||
|
|
||||||
<vn-horizontal margin-large-top>
|
<vn-horizontal margin-large-top>
|
||||||
<vn-submit label="Search"></vn-submit>
|
<vn-submit label="Search"></vn-submit>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
salix: []
|
|
||||||
auth: []
|
auth: []
|
||||||
core: []
|
|
||||||
client: []
|
client: []
|
||||||
production: []
|
core: []
|
||||||
route: []
|
|
||||||
locator: []
|
|
||||||
item: []
|
item: []
|
||||||
|
locator: []
|
||||||
|
production: []
|
||||||
|
salix: []
|
||||||
|
route: []
|
||||||
|
|
152
gulpfile.js
152
gulpfile.js
|
@ -9,28 +9,30 @@ const log = require('fancy-log');
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
|
|
||||||
const isWindows = /^win/.test(process.platform);
|
let isWindows = /^win/.test(process.platform);
|
||||||
|
|
||||||
if (argv.NODE_ENV)
|
if (argv.NODE_ENV)
|
||||||
process.env.NODE_ENV = argv.NODE_ENV;
|
process.env.NODE_ENV = argv.NODE_ENV;
|
||||||
|
|
||||||
const env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
|
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
|
||||||
|
|
||||||
const langs = ['es', 'en'];
|
let langs = ['es', 'en'];
|
||||||
const srcDir = './client';
|
let srcDir = './client';
|
||||||
const servicesDir = './services';
|
let servicesDir = './services';
|
||||||
const nginxDir = `${servicesDir}/nginx`;
|
|
||||||
const buildDir = `${nginxDir}/static`;
|
|
||||||
|
|
||||||
|
let wpConfig = require('./webpack.config.yml');
|
||||||
|
let buildDir = wpConfig.buildDir;
|
||||||
|
let devServerPort = wpConfig.devServerPort;
|
||||||
|
|
||||||
|
let nginxDir = `${servicesDir}/nginx`;
|
||||||
let proxyConf = require(`${nginxDir}/config.yml`);
|
let proxyConf = require(`${nginxDir}/config.yml`);
|
||||||
let proxyEnvFile = `${nginxDir}/config.${env}.yml`;
|
let proxyEnvFile = `${nginxDir}/config.${env}.yml`;
|
||||||
|
|
||||||
if (fs.existsSync(proxyEnvFile))
|
if (fs.existsSync(proxyEnvFile))
|
||||||
Object.assign(proxyConf, require(proxyEnvFile));
|
Object.assign(proxyConf, require(proxyEnvFile));
|
||||||
|
|
||||||
const defaultService = proxyConf.main;
|
let defaultService = proxyConf.main;
|
||||||
const defaultPort = proxyConf.defaultPort;
|
let defaultPort = proxyConf.defaultPort;
|
||||||
const devServerPort = proxyConf.devServerPort;
|
|
||||||
|
|
||||||
// Development
|
// Development
|
||||||
|
|
||||||
|
@ -42,30 +44,51 @@ gulp.task('client', ['build-clean'], () => {
|
||||||
return gulp.start('watch', 'routes', 'locales', 'webpack-dev-server');
|
return gulp.start('watch', 'routes', 'locales', 'webpack-dev-server');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts all backend services, including the nginx proxy and the database.
|
||||||
|
*/
|
||||||
gulp.task('services', async () => {
|
gulp.task('services', async () => {
|
||||||
await runSequenceP('docker-start', 'services-only', 'nginx');
|
await runSequenceP('docker-start', 'services-only', 'nginx');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts all backend services.
|
||||||
|
*/
|
||||||
gulp.task('services-only', async () => {
|
gulp.task('services-only', async () => {
|
||||||
const services = await getServices();
|
const services = await getServices();
|
||||||
for (let service of services)
|
for (let service of services)
|
||||||
require(service.index).start(service.port);
|
require(service.index).start(service.port);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs the e2e tests, restoring the fixtures first.
|
||||||
|
*/
|
||||||
gulp.task('e2e', ['docker-rebuild'], async () => {
|
gulp.task('e2e', ['docker-rebuild'], async () => {
|
||||||
await runSequenceP('e2e-only');
|
await runSequenceP('e2e-only');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs the e2e tests.
|
||||||
|
*/
|
||||||
gulp.task('e2e-only', () => {
|
gulp.task('e2e-only', () => {
|
||||||
const jasmine = require('gulp-jasmine');
|
const jasmine = require('gulp-jasmine');
|
||||||
return gulp.src('./e2e_tests.js')
|
return gulp.src('./e2e_tests.js')
|
||||||
.pipe(jasmine({reporter: 'none'}));
|
.pipe(jasmine({reporter: 'none'}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleans all generated project files.
|
||||||
|
*/
|
||||||
gulp.task('clean', ['build-clean', 'nginx-clean']);
|
gulp.task('clean', ['build-clean', 'nginx-clean']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for the 'install' task.
|
||||||
|
*/
|
||||||
gulp.task('i', ['install']);
|
gulp.task('i', ['install']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Installs node dependencies in all project directories.
|
||||||
|
*/
|
||||||
gulp.task('install', () => {
|
gulp.task('install', () => {
|
||||||
const install = require('gulp-install');
|
const install = require('gulp-install');
|
||||||
const print = require('gulp-print');
|
const print = require('gulp-print');
|
||||||
|
@ -123,6 +146,9 @@ gulp.task('docker-compose', async () => {
|
||||||
await fs.writeFile('./docker-compose.yml', ymlString);
|
await fs.writeFile('./docker-compose.yml', ymlString);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleans all files generated by the 'build' task.
|
||||||
|
*/
|
||||||
gulp.task('build-clean', () => {
|
gulp.task('build-clean', () => {
|
||||||
const del = require('del');
|
const del = require('del');
|
||||||
const files = [
|
const files = [
|
||||||
|
@ -139,10 +165,16 @@ gulp.task('build-clean', () => {
|
||||||
let nginxConf = 'temp/nginx.conf';
|
let nginxConf = 'temp/nginx.conf';
|
||||||
let nginxTemp = `${nginxDir}/temp`;
|
let nginxTemp = `${nginxDir}/temp`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the nginx process, if it is started, restarts it.
|
||||||
|
*/
|
||||||
gulp.task('nginx', async () => {
|
gulp.task('nginx', async () => {
|
||||||
await runSequenceP('nginx-stop', 'nginx-start');
|
await runSequenceP('nginx-stop', 'nginx-start');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the nginx process, generating it's configuration file first.
|
||||||
|
*/
|
||||||
gulp.task('nginx-start', ['nginx-conf'], async () => {
|
gulp.task('nginx-start', ['nginx-conf'], async () => {
|
||||||
let nginxBin = await nginxGetBin();
|
let nginxBin = await nginxGetBin();
|
||||||
|
|
||||||
|
@ -153,6 +185,9 @@ gulp.task('nginx-start', ['nginx-conf'], async () => {
|
||||||
await execP(`${nginxBin} -c "${nginxConf}" -p "${nginxDir}"`);
|
await execP(`${nginxBin} -c "${nginxConf}" -p "${nginxDir}"`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops the nginx process.
|
||||||
|
*/
|
||||||
gulp.task('nginx-stop', async () => {
|
gulp.task('nginx-stop', async () => {
|
||||||
try {
|
try {
|
||||||
let nginxBin = await nginxGetBin();
|
let nginxBin = await nginxGetBin();
|
||||||
|
@ -161,6 +196,11 @@ gulp.task('nginx-stop', async () => {
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the nginx configuration file. If NODE_ENV is defined and the
|
||||||
|
* 'nginx.[environment].mst' file exists, it is used as a template, otherwise,
|
||||||
|
* the 'nginx.mst' template file is used.
|
||||||
|
*/
|
||||||
gulp.task('nginx-conf', ['nginx-stop'], async () => {
|
gulp.task('nginx-conf', ['nginx-stop'], async () => {
|
||||||
const mustache = require('mustache');
|
const mustache = require('mustache');
|
||||||
|
|
||||||
|
@ -187,6 +227,9 @@ gulp.task('nginx-conf', ['nginx-stop'], async () => {
|
||||||
await fs.writeFile(`${nginxTemp}/nginx.conf`, nginxConf);
|
await fs.writeFile(`${nginxTemp}/nginx.conf`, nginxConf);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleans all files generated by nginx.
|
||||||
|
*/
|
||||||
gulp.task('nginx-clean', ['nginx-stop'], () => {
|
gulp.task('nginx-clean', ['nginx-stop'], () => {
|
||||||
const del = require('del');
|
const del = require('del');
|
||||||
return del([`${nginxTemp}/*`], {force: true});
|
return del([`${nginxTemp}/*`], {force: true});
|
||||||
|
@ -280,6 +323,11 @@ gulp.task('webpack-dev-server', function() {
|
||||||
|
|
||||||
let localeFiles = `${srcDir}/**/locale/*.yml`;
|
let localeFiles = `${srcDir}/**/locale/*.yml`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mixes all locale files into one JSON file per module and language. It looks
|
||||||
|
* recursively in all project directories for locale folders with per language
|
||||||
|
* yaml translation files.
|
||||||
|
*/
|
||||||
gulp.task('locales', function() {
|
gulp.task('locales', function() {
|
||||||
const extend = require('gulp-extend');
|
const extend = require('gulp-extend');
|
||||||
const yaml = require('gulp-yaml');
|
const yaml = require('gulp-yaml');
|
||||||
|
@ -323,6 +371,10 @@ gulp.task('watch', function() {
|
||||||
|
|
||||||
// Docker
|
// Docker
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rebuilds the docker and it's image, if these already exist, destroys and
|
||||||
|
* rebuilds them.
|
||||||
|
*/
|
||||||
gulp.task('docker-rebuild', async () => {
|
gulp.task('docker-rebuild', async () => {
|
||||||
try {
|
try {
|
||||||
await execP('docker rm -f dblocal');
|
await execP('docker rm -f dblocal');
|
||||||
|
@ -334,16 +386,22 @@ gulp.task('docker-rebuild', async () => {
|
||||||
await runSequenceP('docker-run');
|
await runSequenceP('docker-run');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the minium effort to start the docker, if it doesn't exists calls
|
||||||
|
* the 'docker-run' task, if it is started does nothing. Keep in mind that when
|
||||||
|
* you do not rebuild the docker you may be using an outdated version of it.
|
||||||
|
* See the 'docker-rebuild' task for more info.
|
||||||
|
*/
|
||||||
gulp.task('docker-start', async () => {
|
gulp.task('docker-start', async () => {
|
||||||
let result;
|
let state;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = await execP('docker container inspect -f "{{json .State}}" dblocal');
|
let result = await execP('docker container inspect -f "{{json .State}}" dblocal');
|
||||||
|
state = JSON.parse(result.stdout);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return await runSequenceP('docker-run');
|
return await runSequenceP('docker-run');
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (JSON.parse(result.stdout).Status) {
|
switch (state.Status) {
|
||||||
case 'running':
|
case 'running':
|
||||||
return;
|
return;
|
||||||
case 'exited':
|
case 'exited':
|
||||||
|
@ -353,6 +411,9 @@ gulp.task('docker-start', async () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs the docker, if the container or it's image doesn't exists builds them.
|
||||||
|
*/
|
||||||
gulp.task('docker-run', async () => {
|
gulp.task('docker-run', async () => {
|
||||||
try {
|
try {
|
||||||
await execP('docker image inspect -f "{{json .Id}}" dblocal');
|
await execP('docker image inspect -f "{{json .Id}}" dblocal');
|
||||||
|
@ -364,29 +425,58 @@ gulp.task('docker-run', async () => {
|
||||||
await runSequenceP('docker-wait');
|
await runSequenceP('docker-wait');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits until MySQL docker is started and ready to serve connections.
|
||||||
|
*/
|
||||||
gulp.task('docker-wait', callback => {
|
gulp.task('docker-wait', callback => {
|
||||||
let maxInterval = 30 * 60000;
|
const mysql = require('mysql2');
|
||||||
let interval = 1000;
|
|
||||||
let timer = 0;
|
let interval = 1;
|
||||||
|
let elapsedTime = 0;
|
||||||
|
let maxInterval = 30 * 60;
|
||||||
|
|
||||||
log('Waiting for MySQL init process...');
|
log('Waiting for MySQL init process...');
|
||||||
let waitForLocaldb = setInterval(() => {
|
checker();
|
||||||
if (timer < maxInterval) {
|
|
||||||
timer += interval;
|
async function checker() {
|
||||||
exec('docker logs --tail 1 dblocal', (err, stdout, stderr) => {
|
elapsedTime += interval;
|
||||||
if (stderr.includes('starting as process 1') || err) {
|
let state;
|
||||||
clearInterval(waitForLocaldb);
|
|
||||||
callback(err);
|
try {
|
||||||
|
let result = await execP('docker container inspect -f "{{json .State}}" dblocal');
|
||||||
|
state = JSON.parse(result.stdout);
|
||||||
|
} catch (err) {
|
||||||
|
return callback(new Error(err.message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state.Status === 'exited')
|
||||||
|
return callback(new Error('Docker exited, please see the docker logs for more info'));
|
||||||
|
|
||||||
|
let conn = mysql.createConnection({
|
||||||
|
host: 'localhost',
|
||||||
|
user: 'root'
|
||||||
|
});
|
||||||
|
conn.on('error', () => {});
|
||||||
|
conn.connect(err => {
|
||||||
|
conn.destroy();
|
||||||
|
if (!err) return callback();
|
||||||
|
|
||||||
|
if (elapsedTime >= maxInterval)
|
||||||
|
callback(new Error(`MySQL not initialized whithin ${elapsedTime} secs`));
|
||||||
|
else
|
||||||
|
setTimeout(checker, interval * 1000);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
clearInterval(waitForLocaldb);
|
|
||||||
callback(new Error(`MySQL not initialized whithin ${maxInterval / 1000} secs`));
|
|
||||||
}
|
}
|
||||||
}, interval);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Promisified version of exec().
|
||||||
|
*
|
||||||
|
* @param {String} command The exec command
|
||||||
|
* @return {Promise} The promise
|
||||||
|
*/
|
||||||
function execP(command) {
|
function execP(command) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
exec(command, (err, stdout, stderr) => {
|
exec(command, (err, stdout, stderr) => {
|
||||||
|
@ -401,6 +491,12 @@ function execP(command) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Promisified version of runSequence().
|
||||||
|
*
|
||||||
|
* @param {String} args The list of gulp task names
|
||||||
|
* @return {Promise} The promise
|
||||||
|
*/
|
||||||
function runSequenceP() {
|
function runSequenceP() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let args = Array.prototype.slice.call(arguments);
|
let args = Array.prototype.slice.call(arguments);
|
||||||
|
|
|
@ -263,6 +263,12 @@
|
||||||
"integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=",
|
"integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"ansicolors": {
|
||||||
|
"version": "0.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansicolors/-/ansicolors-0.2.1.tgz",
|
||||||
|
"integrity": "sha1-vgiVmQl7dKXJxKhKDNvNtivYeu8=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"anymatch": {
|
"anymatch": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.0.tgz",
|
||||||
|
@ -429,6 +435,38 @@
|
||||||
"integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=",
|
"integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"assets-webpack-plugin": {
|
||||||
|
"version": "3.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/assets-webpack-plugin/-/assets-webpack-plugin-3.5.1.tgz",
|
||||||
|
"integrity": "sha1-kxzg1m1C6I7V5/GNZVIpQ8V6OH0=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"camelcase": "1.2.1",
|
||||||
|
"escape-string-regexp": "1.0.5",
|
||||||
|
"lodash.assign": "3.2.0",
|
||||||
|
"lodash.merge": "3.3.2",
|
||||||
|
"mkdirp": "0.5.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"camelcase": {
|
||||||
|
"version": "1.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
|
||||||
|
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"lodash.assign": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-3.2.0.tgz",
|
||||||
|
"integrity": "sha1-POnwI0tLIiPilrj6CsH+6OvKZPo=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"lodash._baseassign": "3.2.0",
|
||||||
|
"lodash._createassigner": "3.1.1",
|
||||||
|
"lodash.keys": "3.1.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"assign-symbols": {
|
"assign-symbols": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz",
|
||||||
|
@ -1335,12 +1373,6 @@
|
||||||
"integrity": "sha1-TK2iGTZS6zyp7I5VyQFWacmAaXg=",
|
"integrity": "sha1-TK2iGTZS6zyp7I5VyQFWacmAaXg=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"bignumber.js": {
|
|
||||||
"version": "4.0.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-4.0.4.tgz",
|
|
||||||
"integrity": "sha1-fED1q80tZiOre5loLufbgbEYiaQ=",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"binary-extensions": {
|
"binary-extensions": {
|
||||||
"version": "1.8.0",
|
"version": "1.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.8.0.tgz",
|
||||||
|
@ -1833,6 +1865,16 @@
|
||||||
"integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=",
|
"integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"cardinal": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/cardinal/-/cardinal-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-UOIcGwqjdyn5N33vGWtanOyTLuk=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"ansicolors": "0.2.1",
|
||||||
|
"redeyed": "1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"caseless": {
|
"caseless": {
|
||||||
"version": "0.11.0",
|
"version": "0.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz",
|
||||||
|
@ -4098,6 +4140,12 @@
|
||||||
"integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=",
|
"integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"denque": {
|
||||||
|
"version": "1.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/denque/-/denque-1.2.3.tgz",
|
||||||
|
"integrity": "sha512-BOjyD1zPf7gqgXlXBCnCsz84cbRNfqpQNvWOUiw3Onu9s7a2afW2LyHzctoie/2KELfUoZkNHTnW02C3hCU20w==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"depd": {
|
"depd": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
|
||||||
|
@ -11062,6 +11110,18 @@
|
||||||
"integrity": "sha1-0iyaxmAojzhD4Wun0rXQbMon13c=",
|
"integrity": "sha1-0iyaxmAojzhD4Wun0rXQbMon13c=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"lodash._arraycopy": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz",
|
||||||
|
"integrity": "sha1-due3wfH7klRzdIeKVi7Qaj5Q9uE=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"lodash._arrayeach": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash._arrayeach/-/lodash._arrayeach-3.0.0.tgz",
|
||||||
|
"integrity": "sha1-urFWsqkNPxu9XGU0AzSeXlkz754=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"lodash._baseassign": {
|
"lodash._baseassign": {
|
||||||
"version": "3.2.0",
|
"version": "3.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz",
|
||||||
|
@ -11078,6 +11138,12 @@
|
||||||
"integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=",
|
"integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"lodash._basefor": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash._basefor/-/lodash._basefor-3.0.3.tgz",
|
||||||
|
"integrity": "sha1-dVC06SGO8J+tJDQ7YSAhx5tMIMI=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"lodash._basetostring": {
|
"lodash._basetostring": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz",
|
||||||
|
@ -11279,6 +11345,23 @@
|
||||||
"lodash._objecttypes": "2.4.1"
|
"lodash._objecttypes": "2.4.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"lodash.isplainobject": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-3.2.0.tgz",
|
||||||
|
"integrity": "sha1-moI4rhayAEMpYM1zRlEtASP79MU=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"lodash._basefor": "3.0.3",
|
||||||
|
"lodash.isarguments": "3.1.0",
|
||||||
|
"lodash.keysin": "3.0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lodash.istypedarray": {
|
||||||
|
"version": "3.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.istypedarray/-/lodash.istypedarray-3.0.6.tgz",
|
||||||
|
"integrity": "sha1-yaR3SYYHUB2OhJTSg7h8OSgc72I=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"lodash.keys": {
|
"lodash.keys": {
|
||||||
"version": "3.1.2",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz",
|
||||||
|
@ -11290,6 +11373,35 @@
|
||||||
"lodash.isarray": "3.0.4"
|
"lodash.isarray": "3.0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"lodash.keysin": {
|
||||||
|
"version": "3.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.keysin/-/lodash.keysin-3.0.8.tgz",
|
||||||
|
"integrity": "sha1-IsRJPrvtsUJ5YqVLRFssinZ/tH8=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"lodash.isarguments": "3.1.0",
|
||||||
|
"lodash.isarray": "3.0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lodash.merge": {
|
||||||
|
"version": "3.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-3.3.2.tgz",
|
||||||
|
"integrity": "sha1-DZDZPtY3sYeEN7s+IWASYNev6ZQ=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"lodash._arraycopy": "3.0.0",
|
||||||
|
"lodash._arrayeach": "3.0.0",
|
||||||
|
"lodash._createassigner": "3.1.1",
|
||||||
|
"lodash._getnative": "3.9.1",
|
||||||
|
"lodash.isarguments": "3.1.0",
|
||||||
|
"lodash.isarray": "3.0.4",
|
||||||
|
"lodash.isplainobject": "3.2.0",
|
||||||
|
"lodash.istypedarray": "3.0.6",
|
||||||
|
"lodash.keys": "3.1.2",
|
||||||
|
"lodash.keysin": "3.0.8",
|
||||||
|
"lodash.toplainobject": "3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"lodash.mergewith": {
|
"lodash.mergewith": {
|
||||||
"version": "4.6.0",
|
"version": "4.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.0.tgz",
|
||||||
|
@ -11335,6 +11447,16 @@
|
||||||
"lodash.escape": "3.2.0"
|
"lodash.escape": "3.2.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"lodash.toplainobject": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.toplainobject/-/lodash.toplainobject-3.0.0.tgz",
|
||||||
|
"integrity": "sha1-KHkK2ULSk9eKpmOgfs9/UsoEGY0=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"lodash._basecopy": "3.0.1",
|
||||||
|
"lodash.keysin": "3.0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"lodash.values": {
|
"lodash.values": {
|
||||||
"version": "2.4.1",
|
"version": "2.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/lodash.values/-/lodash.values-2.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/lodash.values/-/lodash.values-2.4.1.tgz",
|
||||||
|
@ -11399,6 +11521,12 @@
|
||||||
"integrity": "sha1-4PyVEztu8nbNyIh82vJKpvFW+Po=",
|
"integrity": "sha1-4PyVEztu8nbNyIh82vJKpvFW+Po=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"long": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"longest": {
|
"longest": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
|
||||||
|
@ -11809,22 +11937,46 @@
|
||||||
"integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=",
|
"integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"mysql": {
|
"mysql2": {
|
||||||
"version": "2.15.0",
|
"version": "1.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/mysql/-/mysql-2.15.0.tgz",
|
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-1.5.2.tgz",
|
||||||
"integrity": "sha1-6haEEVY0Po8uR/yJhexBzdlXO1w=",
|
"integrity": "sha512-976p3FxXdNMRRiF6Qe/FCOwaUYw3KXVJiIYu5iE5shM7ggIASgF6G/9gd9rhpBqP8V6MVa3KQJ6Ao1xBeGBljw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"bignumber.js": "4.0.4",
|
"cardinal": "1.0.0",
|
||||||
"readable-stream": "2.3.3",
|
"denque": "1.2.3",
|
||||||
|
"generate-function": "2.0.0",
|
||||||
|
"iconv-lite": "0.4.19",
|
||||||
|
"long": "4.0.0",
|
||||||
|
"lru-cache": "4.1.1",
|
||||||
|
"named-placeholders": "1.1.1",
|
||||||
|
"object-assign": "4.1.1",
|
||||||
|
"readable-stream": "2.3.2",
|
||||||
"safe-buffer": "5.1.1",
|
"safe-buffer": "5.1.1",
|
||||||
|
"seq-queue": "0.0.5",
|
||||||
"sqlstring": "2.3.0"
|
"sqlstring": "2.3.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"lru-cache": {
|
||||||
|
"version": "4.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz",
|
||||||
|
"integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"pseudomap": "1.0.2",
|
||||||
|
"yallist": "2.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"object-assign": {
|
||||||
|
"version": "4.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||||
|
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"readable-stream": {
|
"readable-stream": {
|
||||||
"version": "2.3.3",
|
"version": "2.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.2.tgz",
|
||||||
"integrity": "sha1-No8lEtefnUb9/HE0mueHi7weuVw=",
|
"integrity": "sha1-WgTfBeT1f+Pw3Gj90R3FyXx+b00=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"core-util-is": "1.0.2",
|
"core-util-is": "1.0.2",
|
||||||
|
@ -11839,11 +11991,34 @@
|
||||||
"string_decoder": {
|
"string_decoder": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
||||||
"integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=",
|
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "5.1.1"
|
"safe-buffer": "5.1.1"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"yallist": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
|
||||||
|
"integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"named-placeholders": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.1.tgz",
|
||||||
|
"integrity": "sha1-O3oNJiA910s6nfTJz7gnsvuQfmQ=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"lru-cache": "2.5.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"lru-cache": {
|
||||||
|
"version": "2.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.0.tgz",
|
||||||
|
"integrity": "sha1-2COIrpyWC+y+oMc7uet5tsbOmus=",
|
||||||
|
"dev": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -13403,6 +13578,23 @@
|
||||||
"strip-indent": "1.0.1"
|
"strip-indent": "1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"redeyed": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/redeyed/-/redeyed-1.0.1.tgz",
|
||||||
|
"integrity": "sha1-6WwZO0DAgWsArshCaY5hGF5VSYo=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"esprima": "3.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"esprima": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/esprima/-/esprima-3.0.0.tgz",
|
||||||
|
"integrity": "sha1-U88kes2ncxPlUcOqLnM0LT+099k=",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"regenerate": {
|
"regenerate": {
|
||||||
"version": "1.3.3",
|
"version": "1.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.3.3.tgz",
|
||||||
|
@ -13956,6 +14148,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"seq-queue": {
|
||||||
|
"version": "0.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz",
|
||||||
|
"integrity": "sha1-1WgS4cAXpuTnw+Ojeh2m143TyT4=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"sequencify": {
|
"sequencify": {
|
||||||
"version": "0.0.7",
|
"version": "0.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz",
|
||||||
|
@ -16873,6 +17071,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"webpack-merge": {
|
||||||
|
"version": "4.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.1.1.tgz",
|
||||||
|
"integrity": "sha512-geQsZ86YkXOVOjvPC5yv3JSNnL6/X3Kzh935AQ/gJNEYXEfJDQFu/sdFuktS9OW2JcH/SJec8TGfRdrpHshH7A==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"lodash": "4.17.5"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"lodash": {
|
||||||
|
"version": "4.17.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz",
|
||||||
|
"integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"webpack-sources": {
|
"webpack-sources": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.1.0.tgz",
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"angular-mocks": "^1.6.6",
|
"angular-mocks": "^1.6.6",
|
||||||
|
"assets-webpack-plugin": "^3.5.1",
|
||||||
"babel": "^6.23.0",
|
"babel": "^6.23.0",
|
||||||
"babel-core": "^6.26.0",
|
"babel-core": "^6.26.0",
|
||||||
"babel-loader": "^7.1.2",
|
"babel-loader": "^7.1.2",
|
||||||
|
@ -63,7 +64,7 @@
|
||||||
"merge-stream": "^1.0.1",
|
"merge-stream": "^1.0.1",
|
||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
"mustache": "^2.3.0",
|
"mustache": "^2.3.0",
|
||||||
"mysql": "^2.15.0",
|
"mysql2": "^1.5.2",
|
||||||
"nightmare": "^2.10.0",
|
"nightmare": "^2.10.0",
|
||||||
"node-sass": "^4.7.2",
|
"node-sass": "^4.7.2",
|
||||||
"nodemon": "^1.12.1",
|
"nodemon": "^1.12.1",
|
||||||
|
@ -74,6 +75,7 @@
|
||||||
"style-loader": "^0.20.1",
|
"style-loader": "^0.20.1",
|
||||||
"webpack": "^3.10.0",
|
"webpack": "^3.10.0",
|
||||||
"webpack-dev-server": "^2.11.1",
|
"webpack-dev-server": "^2.11.1",
|
||||||
|
"webpack-merge": "^4.1.1",
|
||||||
"yaml-loader": "^0.5.0"
|
"yaml-loader": "^0.5.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -2,6 +2,7 @@ FROM node:8.9.4
|
||||||
|
|
||||||
COPY auth /app
|
COPY auth /app
|
||||||
COPY loopback /loopback
|
COPY loopback /loopback
|
||||||
|
COPY nginx/static/webpack-assets.json /loopback/server/
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,8 @@
|
||||||
</head>
|
</head>
|
||||||
<body ng-app="vnAuth">
|
<body ng-app="vnAuth">
|
||||||
<vn-login></vn-login>
|
<vn-login></vn-login>
|
||||||
<script type="text/javascript"
|
<% for (let jsFile of assets('auth', ['vendor'])) { %>
|
||||||
src="/static/bundle.manifest.js">
|
<script type="text/javascript" src="<%= jsFile %>"></script>
|
||||||
</script>
|
<% } %>
|
||||||
<script type="text/javascript"
|
|
||||||
src="/static/bundle.vendor.js">
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript"
|
|
||||||
src="/static/bundle.auth.js">
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -17,6 +17,14 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"required": true
|
"required": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"acls": [
|
||||||
|
{
|
||||||
|
"accessType": "READ",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,7 @@ RUN chmod -R 755 .
|
||||||
|
|
||||||
CMD ["mysqld"]
|
CMD ["mysqld"]
|
||||||
|
|
||||||
|
#HEALTHCHECK --interval=5s --timeout=10s --retries=200 \
|
||||||
|
# CMD mysqladmin ping -h 127.0.0.1 -u root || exit 1
|
||||||
|
|
||||||
EXPOSE 3306
|
EXPOSE 3306
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
let mysql = require('mysql');
|
let mysql = require('mysql2');
|
||||||
|
|
||||||
let connection = mysql.createConnection({
|
let connection = mysql.createConnection({
|
||||||
multipleStatements: true,
|
multipleStatements: true,
|
||||||
|
|
|
@ -75,11 +75,6 @@
|
||||||
"model": "Expence",
|
"model": "Expence",
|
||||||
"foreignKey": "expenceFk"
|
"foreignKey": "expenceFk"
|
||||||
},
|
},
|
||||||
"taxClass": {
|
|
||||||
"type": "belongsTo",
|
|
||||||
"model": "TaxClass",
|
|
||||||
"foreignKey": "taxClassFk"
|
|
||||||
},
|
|
||||||
"itemTag": {
|
"itemTag": {
|
||||||
"type": "hasMany",
|
"type": "hasMany",
|
||||||
"model": "ItemTag",
|
"model": "ItemTag",
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -7,6 +7,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"compression": "^1.0.3",
|
"compression": "^1.0.3",
|
||||||
"cors": "^2.5.2",
|
"cors": "^2.5.2",
|
||||||
|
"fs-extra": "^5.0.0",
|
||||||
"helmet": "^1.3.0",
|
"helmet": "^1.3.0",
|
||||||
"i18n": "^0.8.3",
|
"i18n": "^0.8.3",
|
||||||
"loopback": "^3.14.0",
|
"loopback": "^3.14.0",
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
"loopback-connector-remote": "^3.1.1",
|
"loopback-connector-remote": "^3.1.1",
|
||||||
"loopback-context": "^3.3.0",
|
"loopback-context": "^3.3.0",
|
||||||
"md5": "^2.2.1",
|
"md5": "^2.2.1",
|
||||||
|
"require-yaml": "0.0.1",
|
||||||
"serve-favicon": "^2.0.1",
|
"serve-favicon": "^2.0.1",
|
||||||
"strong-error-handler": "^2.1.0"
|
"strong-error-handler": "^2.1.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
require('require-yaml');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains the webpack asset filenames with its hash.
|
||||||
|
*
|
||||||
|
* @param {String} main The main asset name
|
||||||
|
* @param {Array} deps The main asset dependencies
|
||||||
|
* @return {Array} The assets filenames
|
||||||
|
*/
|
||||||
|
function assets(main, deps) {
|
||||||
|
let jsFiles;
|
||||||
|
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
|
||||||
|
|
||||||
|
if (env === 'development') {
|
||||||
|
const wpConfig = require('../../../webpack.config.yml');
|
||||||
|
let publicPath = wpConfig.publicPath;
|
||||||
|
|
||||||
|
jsFiles = [`${publicPath}/manifest.js`];
|
||||||
|
|
||||||
|
for (let dep of deps)
|
||||||
|
jsFiles.push(`${publicPath}/${dep}.js`);
|
||||||
|
|
||||||
|
jsFiles.push(`${publicPath}/${main}.js`);
|
||||||
|
} else {
|
||||||
|
const wpAssets = require('./webpack-assets.json');
|
||||||
|
|
||||||
|
let jsFiles = [wpAssets.manifest.js];
|
||||||
|
|
||||||
|
for (let dep of deps)
|
||||||
|
jsFiles.push(wpAssets[dep].js);
|
||||||
|
|
||||||
|
jsFiles.push(wpAssets[main].js);
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = assets;
|
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
let loopback = require('loopback');
|
let loopback = require('loopback');
|
||||||
let boot = require('loopback-boot');
|
let boot = require('loopback-boot');
|
||||||
let path = require('path');
|
let fs = require('fs-extra');
|
||||||
let fs = require('fs');
|
|
||||||
let i18n = require('i18n');
|
let i18n = require('i18n');
|
||||||
|
let path = require('path');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
loopback: loopback,
|
loopback: loopback,
|
||||||
|
@ -32,6 +32,11 @@ function vnBoot(app, rootDir, rootModule) {
|
||||||
app.set('view engine', 'ejs');
|
app.set('view engine', 'ejs');
|
||||||
app.set('views', viewDir);
|
app.set('views', viewDir);
|
||||||
app.use(loopback.static(path.resolve(rootDir, '../client')));
|
app.use(loopback.static(path.resolve(rootDir, '../client')));
|
||||||
|
app.get('/', function(req, res) {
|
||||||
|
res.render(`${viewDir}/index.ejs`, {
|
||||||
|
assets: require('./assets')
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
|
|
|
@ -2,4 +2,3 @@ host: localhost
|
||||||
port: 5000
|
port: 5000
|
||||||
main: salix
|
main: salix
|
||||||
defaultPort: 3000
|
defaultPort: 3000
|
||||||
devServerPort: 8081
|
|
|
@ -2,6 +2,7 @@ FROM node:8.9.4
|
||||||
|
|
||||||
COPY salix /app
|
COPY salix /app
|
||||||
COPY loopback /loopback
|
COPY loopback /loopback
|
||||||
|
COPY nginx/static/webpack-assets.json /loopback/server/
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
|
@ -10,15 +10,8 @@
|
||||||
<script type="text/javascript"
|
<script type="text/javascript"
|
||||||
src="/static/routes.js">
|
src="/static/routes.js">
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript"
|
<% for (let jsFile of assets('salix', ['vendor'])) { %>
|
||||||
src="/static/bundle.manifest.js">
|
<script type="text/javascript" src="<%= jsFile %>"></script>
|
||||||
</script>
|
<% } %>
|
||||||
<script type="text/javascript"
|
|
||||||
src="/static/bundle.vendor.js">
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript"
|
|
||||||
src="/static/bundle.salix.js">
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
|
require('require-yaml');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const path = require('path');
|
||||||
|
const merge = require('webpack-merge');
|
||||||
|
const AssetsWebpackPlugin = require('assets-webpack-plugin');
|
||||||
|
const wpConfig = require('./webpack.config.yml');
|
||||||
|
|
||||||
var webpack = require('webpack');
|
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
|
||||||
var path = require('path');
|
let devMode = env === 'development';
|
||||||
|
let outputPath = path.join(__dirname, wpConfig.buildDir);
|
||||||
|
|
||||||
var devMode = process.env.NODE_ENV !== 'production';
|
let baseConfig = {
|
||||||
|
entry: wpConfig.entry,
|
||||||
var config = {
|
|
||||||
entry: {
|
|
||||||
'bundle.salix': ['salix'],
|
|
||||||
'bundle.auth': ['auth'],
|
|
||||||
'bundle.vendor': ['vendor']
|
|
||||||
},
|
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, './services/nginx/static'),
|
path: outputPath,
|
||||||
filename: '[name].js',
|
publicPath: `${wpConfig.publicPath}/`
|
||||||
publicPath: '/static/',
|
|
||||||
chunkFilename: 'chunk.[name].[chunkhash].js'
|
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
@ -52,20 +51,41 @@ var config = {
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
names: ['bundle.vendor', 'bundle.manifest']
|
names: ['vendor', 'manifest']
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
devtool: 'source-map'
|
devtool: 'source-map'
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!devMode) {
|
let prodConfig = {
|
||||||
|
output: {
|
||||||
|
filename: '[name].[chunkhash].js',
|
||||||
|
chunkFilename: 'chunk.[id].[chunkhash].js'
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
// FIXME: https://github.com/webpack-contrib/uglifyjs-webpack-plugin/issues/132
|
// FIXME: https://github.com/webpack-contrib/uglifyjs-webpack-plugin/issues/132
|
||||||
// config.plugins.push(
|
new webpack.optimize.UglifyJsPlugin({
|
||||||
// new webpack.optimize.UglifyJsPlugin({
|
minimize: true,
|
||||||
// minimize: true,
|
compress: {warnings: false}
|
||||||
// compress: {warnings: false}
|
}),
|
||||||
// })
|
new AssetsWebpackPlugin({
|
||||||
// );
|
path: outputPath
|
||||||
}
|
}),
|
||||||
|
new webpack.HashedModuleIdsPlugin()
|
||||||
|
],
|
||||||
|
devtool: 'source-map'
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = config;
|
let devConfig = {
|
||||||
|
output: {
|
||||||
|
filename: '[name].js',
|
||||||
|
chunkFilename: 'chunk.[id].js'
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new webpack.NamedModulesPlugin()
|
||||||
|
],
|
||||||
|
devtool: 'eval'
|
||||||
|
};
|
||||||
|
|
||||||
|
let mrgConfig = devMode ? devConfig : prodConfig;
|
||||||
|
module.exports = merge(baseConfig, mrgConfig);
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
buildDir: services/nginx/static
|
||||||
|
devServerPort: 3500
|
||||||
|
publicPath: /static
|
||||||
|
entry: {
|
||||||
|
salix: [salix],
|
||||||
|
auth: [auth],
|
||||||
|
vendor: [vendor]
|
||||||
|
}
|
Loading…
Reference in New Issue