Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / version / version.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xe0d1=['../../config/environment','../../config/logger','update','simple-git','index','exports','query','latest','fetch','2.0.0','status','json','origin','master','error','info','git\x20fetch','git\x20fetch\x20origin\x20master','reset','FETCH_HEAD','git\x20reset\x20--hard\x20FETCH_HEAD','pull','npm\x20install\x20--production','restart','then','pm2\x20restart\x20motion\x20%s','catch','migrations','join','root','server','length','replace','.js','push','sequelize','Migration','getQueryInterface','constructor','Migration\x20tried\x20to\x20use\x20old\x20style\x20\x22done\x22\x20callback.\x20Please\x20upgrade\x20to\x20\x22umzug\x22\x20and\x20return\x20a\x20promise\x20instead.','map','Database\x20migrated\x20successfully\x20from\x20version\x20','\x20to\x20','last','UniqueConstraintError','Database\x20already\x20up-to-date','umzug','path','lodash','pkginfo','version','compare-versions','child_process','exec','../../mysqldb'];(function(_0x45391a,_0xad83fd){var _0x4651b0=function(_0x112be1){while(--_0x112be1){_0x45391a['push'](_0x45391a['shift']());}};_0x4651b0(++_0xad83fd);}(_0xe0d1,0x141));var _0x1e0d=function(_0x31abee,_0x11ff0c){_0x31abee=_0x31abee-0x0;var _0x3c1761=_0xe0d1[_0x31abee];return _0x3c1761;};'use strict';var Umzug=require(_0x1e0d('0x0'));var path=require(_0x1e0d('0x1'));var fs=require('fs');var _=require(_0x1e0d('0x2'));var pkginfo=require(_0x1e0d('0x3'))(module,_0x1e0d('0x4'));var compareVersions=require(_0x1e0d('0x5'));var exec=require(_0x1e0d('0x6'))[_0x1e0d('0x7')];var db=require(_0x1e0d('0x8'))['db'];var config=require(_0x1e0d('0x9'));var pm2=require('../../config/pm2');var logger=require(_0x1e0d('0xa'))(_0x1e0d('0xb'));var git=require(_0x1e0d('0xc'))(config['root']);exports[_0x1e0d('0xd')]=function(_0x245454,_0x1cc9cb){var _0x379bf8={'current':module[_0x1e0d('0xe')]['version'],'phonebar':0x2};if(_0x245454[_0x1e0d('0xf')]&&_0x245454['query'][_0x1e0d('0x10')]){return git[_0x1e0d('0x11')]()['tags'](function(_0x7e6cd0,_0x1fa1df){_0x379bf8[_0x1e0d('0x10')]=(_0x7e6cd0?module[_0x1e0d('0xe')]['version']:_0x1fa1df[_0x1e0d('0x10')])||_0x1e0d('0x12');return _0x1cc9cb[_0x1e0d('0x13')](0xc8)[_0x1e0d('0x14')](_0x379bf8);});}else{return _0x1cc9cb[_0x1e0d('0x13')](0xc8)[_0x1e0d('0x14')](_0x379bf8);}};exports[_0x1e0d('0x11')]=function(_0x36522e,_0x46245c){return git[_0x1e0d('0x11')]([_0x1e0d('0x15'),_0x1e0d('0x16')],function(_0x1ea6ec){if(_0x1ea6ec){logger[_0x1e0d('0x17')](_0x1ea6ec);return _0x46245c[_0x1e0d('0x13')](0x1f4)['json'](_0x1ea6ec);}logger[_0x1e0d('0x18')](_0x1e0d('0x19'));return _0x46245c['status'](0xc8)[_0x1e0d('0x14')]({'output':_0x1e0d('0x1a')});});};exports[_0x1e0d('0x1b')]=function(_0x18caa9,_0x1f917e){return git[_0x1e0d('0x1b')](['--hard',_0x1e0d('0x1c')],function(_0x30527f){if(_0x30527f){logger[_0x1e0d('0x17')](_0x30527f);return _0x1f917e['status'](0x1f4)[_0x1e0d('0x14')](_0x30527f);}logger[_0x1e0d('0x18')](_0x1e0d('0x1d'));return _0x1f917e[_0x1e0d('0x13')](0xc8)[_0x1e0d('0x14')]({'output':'git\x20reset\x20--hard'});});};exports[_0x1e0d('0x1e')]=function(_0xec7b52,_0x4ad6c3){exec(_0x1e0d('0x1f'),function(_0x59f116,_0x299305,_0xe24f0b){logger['info'](_0x299305);logger[_0x1e0d('0x18')](_0xe24f0b);if(_0x59f116){logger['error'](_0x59f116);return _0x4ad6c3[_0x1e0d('0x13')](0x1f4)['json'](_0x59f116);}return _0x4ad6c3['status'](0xc8)[_0x1e0d('0x14')]({'output':_0x299305});});};exports[_0x1e0d('0x20')]=function(_0x4d56e,_0x223a93){return pm2['restart']('motion2')[_0x1e0d('0x21')](function(_0x59c491){logger[_0x1e0d('0x18')](_0x1e0d('0x22'),_0x59c491);return _0x223a93[_0x1e0d('0x13')](0xc8)[_0x1e0d('0x14')]({'output':'Your\x20system\x20has\x20been\x20restart\x20successfully'});})[_0x1e0d('0x23')](function(_0x5b693c){logger['error'](_0x5b693c);return _0x223a93[_0x1e0d('0x13')](0x1f4)[_0x1e0d('0x14')](_0x5b693c);});};exports[_0x1e0d('0x24')]=function(_0x170ccf,_0xc624da){var _0x1d2350=fs['readdirSync'](path[_0x1e0d('0x25')](config[_0x1e0d('0x26')],_0x1e0d('0x27'),_0x1e0d('0x24')));var _0x3db4a0=[];for(var _0x378a65=0x0;_0x378a65<_0x1d2350[_0x1e0d('0x28')];_0x378a65++){var _0x288797=_0x1d2350[_0x378a65][_0x1e0d('0x29')](_0x1e0d('0x2a'),'');if(compareVersions(module['exports'][_0x1e0d('0x4')],_0x288797)===-0x1){_0x3db4a0[_0x1e0d('0x2b')](_0x288797);}}if(_0x3db4a0[_0x1e0d('0x28')]){var _0x26d542=_0x3db4a0['sort'](compareVersions);var _0x23446e=new Umzug({'storage':_0x1e0d('0x2c'),'storageOptions':{'model':db['Migration'],'modelName':_0x1e0d('0x2d'),'columnName':'version'},'migrations':{'params':[db[_0x1e0d('0x2c')][_0x1e0d('0x2e')](),db['sequelize'][_0x1e0d('0x2f')],function(){throw new Error(_0x1e0d('0x30'));}],'path':path[_0x1e0d('0x25')](config[_0x1e0d('0x26')],_0x1e0d('0x27'),_0x1e0d('0x24')),'pattern':/\.js$/}});_0x23446e['up']({'migrations':_[_0x1e0d('0x31')](_0x26d542,function(_0x42e00a){return _0x42e00a+_0x1e0d('0x2a');})})['then'](function(){return _0xc624da[_0x1e0d('0x13')](0xc8)['json']({'output':_0x1e0d('0x32')+module[_0x1e0d('0xe')][_0x1e0d('0x4')]+_0x1e0d('0x33')+_[_0x1e0d('0x34')](_0x26d542),'migrations':_[_0x1e0d('0x25')](_0x26d542)});})['catch'](function(_0x33c310){if(_0x33c310 instanceof db[_0x1e0d('0x2c')][_0x1e0d('0x35')]){return _0xc624da['status'](0xc8)[_0x1e0d('0x14')]({'output':_0x1e0d('0x36')});}else{return _0xc624da[_0x1e0d('0x13')](0x1f4)[_0x1e0d('0x14')](_0x33c310);}});}else{return _0xc624da[_0x1e0d('0x13')](0xc8)[_0x1e0d('0x14')]({'output':_0x1e0d('0x36')});}};