fix (core.gbapp): warnings and comments handled.

This commit is contained in:
Rodrigo Rodriguez 2020-01-08 17:52:46 -03:00
parent 071f38cfc3
commit eca9099225
6 changed files with 34 additions and 48 deletions

31
boot.js
View file

@ -4,27 +4,29 @@ const Fs = require('fs');
const Path = require('path'); const Path = require('path');
const { exec } = require('child_process'); const { exec } = require('child_process');
// display version of Node JS being used at runtime and others runtime attributes // Displays version of Node JS being used at runtime and others attributes.
console.log(`process.version = ${process.version}`);
console.log(`process.env = ${process.env}`); console.log(`[GB Runtime] version = ${process.version}`);
console.log(`process.platform = ${process.platform}`); console.log(`[GB Runtime] env = ${process.env}`);
console.log(`process.release = ${process.release}`); console.log(`[GB Runtime] platform = ${process.platform}`);
console.log(`process.argv = ${process.argv}`); console.log(`[GB Runtime] release = ${process.release}`);
console.log(`process.env.USER = ${process.env.USER}`); console.log(`[GB Runtime] argv = ${process.argv}`);
console.log(`process.env.PATH = ${process.env.PATH.split(':').join('\n')}`); console.log(`[GB Runtime] env.USER = ${process.env.USER}`);
console.log(`process.env.PWD = ${process.env.PWD}`); console.log(`[GB Runtime] env.PATH = ${process.env.PATH.split(':').join('\n')}`);
console.log(`process.env.HOME = ${process.env.HOME}`); console.log(`[GB Runtime] env.PWD = ${process.env.PWD}`);
console.log(`process.debugPort = ${process.debugPort}`); console.log(`[GB Runtime] env.HOME = ${process.env.HOME}`);
console.log(`[GB Runtime] debugPort = ${process.debugPort}`);
var now = () => { var now = () => {
return (new Date()).toISOString().replace(/T/, ' ').replace(/\..+/, '') + ' UTC'; return (new Date()).toISOString().replace(/T/, ' ').replace(/\..+/, '') + ' UTC';
} }
try { try {
// 1. define functions: run and processDist
var run = () => { var run = () => {
console.log(`[GB Runtime] Now starting General Bots Server...`);
const GBServer = require("./dist/src/app").GBServer const GBServer = require("./dist/src/app").GBServer
console.log(`${now()} - Running '${GBServer.name}' on '${__dirname}' directory`); console.log(`[GB Runtime] ${now()} - Running '${GBServer.name}' on '${__dirname}' directory`);
process.env.PWD = __dirname; process.env.PWD = __dirname;
GBServer.run(); GBServer.run();
} }
@ -44,7 +46,8 @@ try {
} }
}; };
// 2. start running // Installing modules if it has not been done yet.
if (!Fs.existsSync('node_modules')) { if (!Fs.existsSync('node_modules')) {
console.log(`${now()} - Installing modules for the first time, please wait...`); console.log(`${now()} - Installing modules for the first time, please wait...`);
exec('npm install', (err, stdout, stderr) => { exec('npm install', (err, stdout, stderr) => {

View file

@ -33,8 +33,8 @@
"pretest": "npm run build", "pretest": "npm run build",
"coveralls": "npm run test && nyc report --reporter=text-lcov | coveralls", "coveralls": "npm run test && nyc report --reporter=text-lcov | coveralls",
"start": "node ./boot.js", "start": "node ./boot.js",
"reverse-proxy": "node_modules/.bin/ngrok http 4242",
"watch:build": "tsc --watch", "watch:build": "tsc --watch",
"watch:server": "nodemon './dist/index.js' --watch './dist'",
"posttypedoc": "shx cp .nojekyll docs/reference/.nojekyll", "posttypedoc": "shx cp .nojekyll docs/reference/.nojekyll",
"ban": "ban", "ban": "ban",
"issues": "git-issues", "issues": "git-issues",
@ -116,7 +116,6 @@
"git-issues": "1.3.1", "git-issues": "1.3.1",
"license-checker": "25.0.1", "license-checker": "25.0.1",
"nsp": "3.2.1", "nsp": "3.2.1",
"pre-commit": "^1.2.2",
"prettier-standard": "^16.1.0", "prettier-standard": "^16.1.0",
"semantic-release": "^15.14.0", "semantic-release": "^15.14.0",
"travis-deploy-once": "5.0.11", "travis-deploy-once": "5.0.11",
@ -205,18 +204,8 @@
}, },
"pre-git": { "pre-git": {
"commit-msg": "simple", "commit-msg": "simple",
"pre-commit": [ "pre-commit": [],
"npm prune", "pre-push": [],
"git add packages/*.ts",
"npm run ban"
],
"pre-push": [
"echo skip npm run unused-deps",
"echo skip npm npm run secure",
"echo skip npm run license",
"echo skip npm run ban -- --all",
"echo skip run size"
],
"post-commit": [], "post-commit": [],
"post-checkout": [], "post-checkout": [],
"post-merge": [] "post-merge": []

View file

@ -38,7 +38,7 @@
import { GBLog, IGBCoreService, IGBInstallationDeployer, IGBInstance, IGBPackage } from 'botlib'; import { GBLog, IGBCoreService, IGBInstallationDeployer, IGBInstance, IGBPackage } from 'botlib';
import * as fs from 'fs'; import * as fs from 'fs';
import { Sequelize } from 'sequelize-typescript'; import { Sequelize, SequelizeOptions } from 'sequelize-typescript';
import { Op, Dialect } from 'sequelize'; import { Op, Dialect } from 'sequelize';
import { GBServer } from '../../../src/app'; import { GBServer } from '../../../src/app';
import { GBAdminPackage } from '../../admin.gbapp/index'; import { GBAdminPackage } from '../../admin.gbapp/index';
@ -133,7 +133,11 @@ export class GBCoreService implements IGBCoreService {
const encrypt: boolean = GBConfigService.get('STORAGE_ENCRYPT') === 'true'; const encrypt: boolean = GBConfigService.get('STORAGE_ENCRYPT') === 'true';
const acquire = parseInt(GBConfigService.get('STORAGE_ACQUIRE_TIMEOUT')); const acquire = parseInt(GBConfigService.get('STORAGE_ACQUIRE_TIMEOUT'));
const sequelizeOptions = { const sequelizeOptions: SequelizeOptions = {
define: {
freezeTableName: true,
timestamps: false
},
host: host, host: host,
logging: logging as boolean, logging: logging as boolean,
dialect: this.dialect as Dialect, dialect: this.dialect as Dialect,
@ -154,7 +158,7 @@ export class GBCoreService implements IGBCoreService {
this.sequelize = new Sequelize( this.sequelize = new Sequelize(
database, database,
username, username,
password, password,
sequelizeOptions sequelizeOptions
); );
@ -265,7 +269,7 @@ STORAGE_SYNC=true
} catch (error) { } catch (error) {
// There are false positive from ngrok regarding to no memory, but it's just // There are false positive from ngrok regarding to no memory, but it's just
// lack of connection. // lack of connection.
throw new Error(`Error connecting to remote ngrok server, please check network connection. ${error.msg}`); throw new Error(`Error connecting to remote ngrok server, please check network connection. ${error.msg}`);
} }
} }
@ -284,7 +288,7 @@ STORAGE_SYNC=true
} }
} }
public async deleteInstance(botId:string) { public async deleteInstance(botId: string) {
const options = { where: {} }; const options = { where: {} };
options.where = { botId: botId }; options.where = { botId: botId };
await GuaribasInstance.destroy(options); await GuaribasInstance.destroy(options);

View file

@ -3035,7 +3035,7 @@
}, },
"callsites": { "callsites": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", "resolved": "http://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz",
"integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=" "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA="
}, },
"camel-case": { "camel-case": {

View file

@ -335,17 +335,7 @@ class GBUIApp extends React.Component {
if (!this.state.instance) { if (!this.state.instance) {
sideBar = ''; sideBar = '';
} }
return (
<div>
{gbCss}
{sideBar}
<div className="player">{playerComponent}</div>
<div className="webchat">
</div>
</div>
);
/*
return ( return (
<div> <div>
{gbCss} {gbCss}
@ -355,7 +345,7 @@ class GBUIApp extends React.Component {
{chat} {chat}
</div> </div>
</div> </div>
); */ );
} }
} }

View file

@ -49,8 +49,8 @@ export class GBWhatsappPackage implements IGBPackage {
public loadBot(min: GBMinInstance): void { public loadBot(min: GBMinInstance): void {
// Only loads engine if it is defined on services.json. // Only loads engine if it is defined on services.json.
if (min.instance.whatsappBotKey !== undefined) { if (min.instance.whatsappBotKey !== undefined && min.instance.whatsappBotKey !== null ) {
min.whatsAppDirectLine = new WhatsappDirectLine( min.whatsAppDirectLine = new WhatsappDirectLine(
min.botId, min.botId,
min.instance.whatsappBotKey, min.instance.whatsappBotKey,
min.instance.whatsappServiceKey, min.instance.whatsappServiceKey,