Obsolete code & files removed

This commit is contained in:
Juan Ferrer 2019-01-25 23:02:29 +01:00
parent 71af7f6d0e
commit 8fc8292e72
28 changed files with 3308 additions and 3540 deletions

View File

@ -1,4 +1,3 @@
node_modules
front
services
!services/nginx
front/node_modules
services

View File

@ -17,13 +17,10 @@ let SpecReporter = require('jasmine-spec-reporter').SpecReporter;
let serviceSpecs = [
`${__dirname}/**/*[sS]pec.js`,
`${__dirname}/../loopback/**/*[sS]pec.js`
`${__dirname}/../loopback/**/*[sS]pec.js`,
`${__dirname}/../modules/*/back/**/*.[sS]pec.js`
];
let services = require(`../modules.yml`);
for (let service of services)
serviceSpecs.push(`${__dirname}/../modules/${service}/back/**/*[sS]pec.js`);
jasmine.loadConfig({
spec_dir: '.',
spec_files: serviceSpecs,

View File

@ -5,7 +5,7 @@ services:
restart: unless-stopped
build:
context: .
dockerfile: services/nginx/Dockerfile
dockerfile: front/Dockerfile
ports:
- ${PORT}:80
links:

View File

@ -9,7 +9,7 @@ RUN apt-get update \
&& ln -sf /dev/stderr /var/log/nginx/error.log
WORKDIR /etc/nginx
COPY services/nginx/temp/nginx.conf sites-available/salix
COPY front/nginx.conf sites-available/salix
RUN rm sites-enabled/default && ln -s ../sites-available/salix sites-enabled/salix
COPY dist /salix/dist

View File

@ -7,7 +7,7 @@ config.$inject = ['$translateProvider', '$translatePartialLoaderProvider'];
export function config($translateProvider, $translatePartialLoaderProvider) {
$translatePartialLoaderProvider.addPart('core');
let conf = {urlTemplate: '/static/locale/{part}/{lang}.json'};
let conf = {urlTemplate: '/locale/{part}/{lang}.json'};
let fallbackLang = 'es';
let langs = ['en', 'es'];

View File

@ -1,11 +0,0 @@
auth: []
client: []
core: []
item: [client]
salix: []
ticket: [item, client]
order: [item, ticket]
claim: [item, client]
route: []
agency: []
travel: []

View File

@ -7,19 +7,12 @@ server {
root /usr/share/nginx/html;
{{#services}}
location ~ ^/{{.}}(?:/(.*))?$ {
location ~ ^(/[a-zA-Z0-9_-]+)?/api(?:/(.*))?$ {
resolver 127.0.0.11;
proxy_pass http://api:{{defaultPort}}/$1$is_args$args;
proxy_pass http://api:3000/$1$is_args$args;
}
{{/services}}
location ~ ^/static(?:/(.*))?$ {
location ~ ^(?:/(.*))?$ {
alias /salix/dist/$1;
autoindex on;
}
location ~ ^(?:/(.*))?$ {
resolver 127.0.0.11;
proxy_pass http://api:{{defaultPort}}/$1$is_args$args;
}
}

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=no"/>
<meta name="mobile-web-app-capable" content="yes"/>
<title vn-title translate></title>
<script src="/acl"></script>
</head>
<body>
<vn-app></vn-app>

View File

@ -1,5 +1,5 @@
import ngModule from './module';
import deps from 'modules.yml';
import deps from '../../modules.yml';
import modules from 'spliting';
import splitingRegister from 'core/lib/spliting-register';
import getMainRoute from 'core/lib/get-main-route';

View File

@ -1,3 +1,4 @@
import './responsive.scss';
import './title.scss';
import './layout.scss';
import './display.scss';

View File

@ -0,0 +1,48 @@
/* Desktop - Laptop 1360x768 */
@media (max-resolution: 119dpi) and (min-device-width: 1340px) and (max-device-width: 1899px)
{
body { font-size: 10pt; }
}
/* Mobile - Low DPI */
@media
(min-resolution: 120dpi),
(-webkit-min-device-pixel-ratio: 1.5)
{
body { font-size: 9pt; }
}
@media
(min-resolution: 144dpi),
(-webkit-min-device-pixel-ratio: 1.5)
{
body { font-size: 11pt; }
}
/* Mobile - Normal DPI */
@media
(max-device-width: 383px) and (min-resolution: 192dpi),
(max-device-width: 383px) and (-webkit-min-device-pixel-ratio: 2)
{
body { font-size: 10pt; }
}
@media
(min-device-width: 384px) and (min-resolution: 192dpi),
(min-device-width: 384px) and (-webkit-min-device-pixel-ratio: 2)
{
body { font-size: 11pt; }
}
/* Mobile - High DPI */
@media
(max-device-width: 411px) and (min-resolution: 249dpi),
(max-device-width: 411px) and (-webkit-min-device-pixel-ratio: 3)
{
body { font-size: 10pt; }
}
@media
(min-device-width: 412px) and (min-resolution: 249dpi),
(min-device-width: 412px) and (-webkit-min-device-pixel-ratio: 3)
{
body { font-size: 11pt; }
}

View File

@ -1,6 +1,5 @@
require('require-yaml');
const gulp = require('gulp');
const fs = require('fs-extra');
const exec = require('child_process').exec;
const PluginError = require('plugin-error');
const argv = require('minimist')(process.argv.slice(2));
@ -13,40 +12,21 @@ let isWindows = /^win/.test(process.platform);
if (argv.NODE_ENV)
process.env.NODE_ENV = argv.NODE_ENV;
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
let langs = ['es', 'en'];
let srcDir = './front';
let modulesDir = './modules';
let servicesDir = './services';
let modules = require('./modules.yml');
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 proxyEnvFile = `${nginxDir}/config.${env}.yml`;
if (fs.existsSync(proxyEnvFile))
Object.assign(proxyConf, require(proxyEnvFile));
let defaultService = proxyConf.main;
let defaultPort = proxyConf.defaultPort;
let buildDir = 'dist';
// Development
const nginx = gulp.series(nginxStart);
nginx.description = `Starts/restarts the nginx process`;
const localesRoutes = gulp.parallel(locales, routes);
localesRoutes.description = `Builds locales and routes`;
const front = gulp.series(buildClean, gulp.parallel(localesRoutes, watch, webpackDevServer));
front.description = `Starts frontend service`;
const back = gulp.series(dockerStart, backOnly, nginx);
const back = gulp.series(dockerStart, backOnly);
back.description = `Starts backend and database service`;
const defaultTask = gulp.parallel(front, back);
@ -54,7 +34,7 @@ defaultTask.description = `Starts all application services`;
function backOnly(done) {
let app = require(`./loopback/server/server`);
app.start(defaultPort);
app.start();
app.on('started', done);
}
backOnly.description = `Starts backend service`;
@ -130,7 +110,7 @@ smokesOnly.description = `Runs the smokes tests only`;
smokes = gulp.series(docker, smokesOnly);
smokes.description = `Restarts database and runs the smokes tests`;
const clean = gulp.parallel(buildClean, nginxClean);
const clean = gulp.parallel(buildClean);
clean.description = 'Cleans all generated project files';
function install() {
@ -153,7 +133,7 @@ i.description = `Alias for the 'install' task`;
// Deployment
const build = gulp.series(clean, gulp.parallel(localesRoutes, webpack, nginxConf));
const build = gulp.series(clean, gulp.parallel(localesRoutes, webpack));
build.description = `Generates binaries and configuration files`;
function buildClean() {
@ -236,10 +216,10 @@ function locales() {
let streams = [];
let localePaths = [];
for (let mod of modules)
for (let mod in modules)
localePaths[mod] = `${modulesDir}/${mod}`;
let baseMods = ['core', 'auth', 'salix'];
let baseMods = ['core', 'salix'];
for (let mod of baseMods)
localePaths[mod] = `${srcDir}/${mod}`;
@ -379,84 +359,6 @@ function dockerWait() {
}
dockerWait.description = `Waits until database service is ready`;
// Nginx
let nginxConfFile = 'temp/nginx.conf';
let nginxTemp = `${nginxDir}/temp`;
async function nginxStart() {
await nginxConf();
let nginxBin = await nginxGetBin();
if (isWindows)
nginxBin = `start /B ${nginxBin}`;
log(`Application available at http://${proxyConf.host}:${proxyConf.port}/`);
await execP(`${nginxBin} -c "${nginxConfFile}" -p "${nginxDir}"`);
}
nginxStart.description = `Starts the nginx process`;
async function nginxStop() {
try {
let nginxBin = await nginxGetBin();
await fs.stat(`${nginxTemp}/nginx.pid`);
await execP(`${nginxBin} -c "${nginxConfFile}" -p "${nginxDir}" -s stop`);
} catch (e) {}
}
nginxStop.description = `Stops the nginx process`;
/**
* 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.
*/
async function nginxConf() {
await nginxStop();
const mustache = require('mustache');
if (!await fs.exists(nginxTemp))
await fs.mkdir(nginxTemp);
let params = {
services: modules,
defaultService: defaultService,
defaultPort: defaultPort,
devServerPort: devServerPort,
port: proxyConf.port,
host: proxyConf.host
};
let confFile = `${nginxDir}/nginx.${env}.mst`;
if (!await fs.exists(confFile))
confFile = `${nginxDir}/nginx.mst`;
let template = await fs.readFile(confFile, 'utf8');
let nginxConfData = mustache.render(template, params);
await fs.writeFile(`${nginxTemp}/nginx.conf`, nginxConfData);
}
nginxConf.description = `Generates the nginx configuration file`;
async function nginxClean() {
await nginxStop();
const del = require('del');
return del([`${nginxTemp}/*`], {force: true});
}
nginxClean.description = `Cleans all files generated by nginx`;
async function nginxGetBin() {
if (isWindows)
return 'nginx';
try {
let nginxBin = '/usr/sbin/nginx';
await fs.stat(nginxBin);
return nginxBin;
} catch (e) {
return 'nginx';
}
}
// Helpers
/**
@ -497,11 +399,6 @@ module.exports = {
i,
build,
buildClean,
nginxStart,
nginx,
nginxStop,
nginxConf,
nginxClean,
webpack,
webpackDevServer,
locales,

View File

@ -1,18 +0,0 @@
<!doctype html>
<html ng-app="salix">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=no"/>
<meta name="mobile-web-app-capable" content="yes"/>
<title vn-title translate></title>
</head>
<body>
<vn-app></vn-app>
<script type="text/javascript"
src="/static/routes.js?<%= version %>">
</script>
<% for (let jsFile of assets) { %>
<script type="text/javascript" src="<%= jsFile %>"></script>
<% } %>
</body>
</html>

View File

@ -1,13 +1,4 @@
module.exports = function(app) {
let bootTimestamp = new Date().getTime();
app.get('/', function(req, res) {
res.render('index.ejs', {
assets: app.getWpAssets('salix'),
version: bootTimestamp
});
});
// FIXME: Fix until the original can be used
app.get('/api/modelInfo', function(req, res) {
app.models.Schema.modelInfo({req}).then(json => {

View File

@ -1,9 +1,5 @@
{
"initial:before": {
"loopback#favicon": {
"params": "$!../favicon.ico"
}
},
"initial:before": {},
"initial": {
"compression": {},
"cors": {

View File

@ -31,9 +31,7 @@ let rootDir = __dirname;
let lbDir = path.resolve(`${rootDir}/..`);
let appDir = path.resolve(`${__dirname}/../..`);
let localeDir = `${lbDir}/locale`;
let viewDir = `${lbDir}/client`;
let buildDir = `${appDir}/dist`;
let servicesDir = `${appDir}/modules`;
let modulesDir = `${appDir}/modules`;
let modulesPath = `${appDir}/modules.yml`;
app.use(cookieParser());
@ -49,28 +47,6 @@ if (fs.existsSync(localeDir)) {
app.use(i18n.init);
}
// View
if (fs.existsSync(viewDir)) {
app.set('view engine', 'ejs');
app.set('views', viewDir);
app.use(loopback.static(viewDir));
}
app.getWpAssets = entryPoint => {
const wpAssets = require(`${buildDir}/webpack-assets.json`);
let jsFiles = [];
let regex = new RegExp(`(^|~)${entryPoint}($|~)`);
for (let asset in wpAssets) {
if (regex.test(asset))
jsFiles.push(wpAssets[asset].js);
}
return jsFiles;
};
// Initialization
app.disconnect = async function() {
@ -116,9 +92,9 @@ let bootDirs = [
addPath(`${appDir}/back`);
let services = require(modulesPath);
for (let service of services)
addPath(`${servicesDir}/${service}/back`);
let modules = require(modulesPath);
for (let mod in modules)
addPath(`${modulesDir}/${mod}/back`);
function addPath(path) {
modelConfigFiles.push(`${path}/model-config.json`);

View File

@ -1,10 +1,8 @@
[
client,
item,
ticket,
order,
claim,
route,
agency,
travel
]
client: []
item: [client]
ticket: [item, client]
order: [item, ticket]
claim: [item, client]
route: []
agency: []
travel: []

6455
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,6 @@
"object.pick": "^1.3.0",
"request": "^2.88.0",
"require-yaml": "0.0.1",
"serve-favicon": "^2.5.0",
"strong-error-handler": "^2.3.2",
"uuid": "^3.3.2",
"vn-loopback": "file:./loopback"
@ -33,7 +32,6 @@
"@babel/preset-env": "^7.2.0",
"@babel/register": "^7.0.0",
"angular-mocks": "^1.7.4",
"assets-webpack-plugin": "^3.9.7",
"babel-loader": "^8.0.5",
"css-loader": "^0.25.0",
"del": "^2.2.2",
@ -67,7 +65,6 @@
"karma-webpack": "^3.0.5",
"merge-stream": "^1.0.1",
"minimist": "^1.2.0",
"mustache": "^2.3.2",
"mysql2": "^1.6.1",
"nightmare": "^3.0.1",
"node-sass": "^4.9.3",

View File

@ -1 +0,0 @@
temp/*

View File

@ -1,2 +0,0 @@
host: salix
port: 80

View File

@ -1,2 +0,0 @@
host: test-salix
port: 80

View File

@ -1,4 +0,0 @@
host: localhost
port: 5000
main: salix
defaultPort: 3000

View File

@ -1,54 +0,0 @@
worker_processes 1;
error_log temp/error.log;
pid temp/nginx.pid;
events {
worker_connections 1024;
}
http {
sendfile on;
gzip on;
default_type application/octet-stream;
access_log temp/access.log;
client_body_temp_path temp/client-body;
proxy_temp_path temp/proxy;
fastcgi_temp_path temp/fastcgi;
uwsgi_temp_path temp/uwsgi;
scgi_temp_path temp/scgi;
server {
listen {{port}};
server_name {{host}};
autoindex off;
{{#services}}
location ~ ^/{{.}}(?:/(.*))?$ {
proxy_pass http://127.0.0.1:{{defaultPort}}/$1$is_args$args;
}
{{/services}}
location ~ ^/static(?:/(.*)?)$ {
proxy_pass http://127.0.0.1:{{devServerPort}}/$1$is_args$args;
}
location ~ ^(?:/(.*))?$ {
proxy_pass http://127.0.0.1:{{defaultPort}}/$1$is_args$args;
}
}
types {
text/html html;
application/json json;
application/javascript js;
text/css css scss;
text/xml xml;
image/x-icon ico;
image/png png;
image/svg+xml svg;
image/gif gif;
image/jpeg jpeg jpg;
}
}

View File

@ -3,20 +3,16 @@ const webpack = require('webpack');
const path = require('path');
const merge = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const AssetsWebpackPlugin = require('assets-webpack-plugin');
const wpConfig = require('./webpack.config.yml');
let env = process.env.NODE_ENV || 'development';
let mode = env == 'development' ? env : 'production';
let outputPath = path.join(__dirname, wpConfig.buildDir);
let baseConfig = {
entry: wpConfig.entry,
entry: {salix: 'salix'},
mode: mode,
output: {
path: outputPath,
publicPath: `${wpConfig.publicPath}/`
path: path.join(__dirname, 'dist'),
publicPath: '/'
},
module: {
rules: [
@ -74,11 +70,9 @@ let baseConfig = {
}
},
plugins: [
new AssetsWebpackPlugin({
path: outputPath
}),
new HtmlWebpackPlugin({
template: 'front/salix/index.ejs',
favicon: 'front/salix/favicon.ico',
filename: 'index.html',
chunks: ['salix']
})
@ -114,13 +108,20 @@ let devConfig = {
},
devServer: {
host: 'localhost',
port: wpConfig.devServerPort,
port: 5000,
publicPath: '/',
contentBase: wpConfig.buildDir,
contentBase: 'dist',
quiet: false,
noInfo: false,
// hot: true,
stats: baseConfig.stats
stats: baseConfig.stats,
proxy: {
'/api': 'http://localhost:3000',
'/*/api/**': {
target: 'http://localhost:3000',
pathRewrite: {'^/[\\w-]+': ''}
}
}
}
};

View File

@ -1,6 +0,0 @@
buildDir: dist
devServerPort: 3500
publicPath: '/static'
entry: {
salix: salix
}