Built motion from commit e6806ed6.|2.6.0
[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 _0xdd8b=['latest','fetch','tags','2.0.0','status','json','master','info','git\x20fetch\x20origin\x20master','reset','--hard','FETCH_HEAD','error','git\x20reset\x20--hard\x20FETCH_HEAD','git\x20reset\x20--hard','pull','npm\x20install\x20--production','restart','then','pm2\x20restart\x20motion\x20%s','Your\x20system\x20has\x20been\x20restart\x20successfully','catch','migrations','join','server','length','replace','.js','push','sort','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.','Database\x20migrated\x20successfully\x20from\x20version\x20','last','UniqueConstraintError','Database\x20already\x20up-to-date','umzug','lodash','pkginfo','version','child_process','exec','../../mysqldb','../../config/pm2','../../config/logger','update','root','exports','query'];(function(_0x21630b,_0xcaf485){var _0x231916=function(_0x474a8d){while(--_0x474a8d){_0x21630b['push'](_0x21630b['shift']());}};_0x231916(++_0xcaf485);}(_0xdd8b,0xc3));var _0xbdd8=function(_0x2becba,_0x4ea656){_0x2becba=_0x2becba-0x0;var _0x90b5dd=_0xdd8b[_0x2becba];return _0x90b5dd;};'use strict';var Umzug=require(_0xbdd8('0x0'));var path=require('path');var fs=require('fs');var _=require(_0xbdd8('0x1'));var pkginfo=require(_0xbdd8('0x2'))(module,_0xbdd8('0x3'));var compareVersions=require('compare-versions');var exec=require(_0xbdd8('0x4'))[_0xbdd8('0x5')];var db=require(_0xbdd8('0x6'))['db'];var config=require('../../config/environment');var pm2=require(_0xbdd8('0x7'));var logger=require(_0xbdd8('0x8'))(_0xbdd8('0x9'));var git=require('simple-git')(config[_0xbdd8('0xa')]);exports['index']=function(_0x3c19b0,_0x4712bb){var _0x61a563={'current':module[_0xbdd8('0xb')][_0xbdd8('0x3')],'phonebar':0x2};if(_0x3c19b0[_0xbdd8('0xc')]&&_0x3c19b0[_0xbdd8('0xc')][_0xbdd8('0xd')]){return git[_0xbdd8('0xe')]()[_0xbdd8('0xf')](function(_0x41ce74,_0x5ad963){_0x61a563[_0xbdd8('0xd')]=(_0x41ce74?module['exports'][_0xbdd8('0x3')]:_0x5ad963['latest'])||_0xbdd8('0x10');return _0x4712bb[_0xbdd8('0x11')](0xc8)['json'](_0x61a563);});}else{return _0x4712bb[_0xbdd8('0x11')](0xc8)[_0xbdd8('0x12')](_0x61a563);}};exports['fetch']=function(_0x1e0ac8,_0x3c9aca){return git[_0xbdd8('0xe')](['origin',_0xbdd8('0x13')],function(_0x39cb50){if(_0x39cb50){logger['error'](_0x39cb50);return _0x3c9aca[_0xbdd8('0x11')](0x1f4)['json'](_0x39cb50);}logger[_0xbdd8('0x14')]('git\x20fetch');return _0x3c9aca['status'](0xc8)['json']({'output':_0xbdd8('0x15')});});};exports[_0xbdd8('0x16')]=function(_0x26b02d,_0x4562f8){return git[_0xbdd8('0x16')]([_0xbdd8('0x17'),_0xbdd8('0x18')],function(_0x2b68b1){if(_0x2b68b1){logger[_0xbdd8('0x19')](_0x2b68b1);return _0x4562f8[_0xbdd8('0x11')](0x1f4)['json'](_0x2b68b1);}logger[_0xbdd8('0x14')](_0xbdd8('0x1a'));return _0x4562f8['status'](0xc8)[_0xbdd8('0x12')]({'output':_0xbdd8('0x1b')});});};exports[_0xbdd8('0x1c')]=function(_0x3dfe53,_0x42492c){exec(_0xbdd8('0x1d'),function(_0x1191e2,_0x1e3afa,_0x39960c){logger[_0xbdd8('0x14')](_0x1e3afa);logger[_0xbdd8('0x14')](_0x39960c);if(_0x1191e2){logger[_0xbdd8('0x19')](_0x1191e2);return _0x42492c[_0xbdd8('0x11')](0x1f4)[_0xbdd8('0x12')](_0x1191e2);}return _0x42492c[_0xbdd8('0x11')](0xc8)[_0xbdd8('0x12')]({'output':_0x1e3afa});});};exports['restart']=function(_0x4880bb,_0x48297a){return pm2[_0xbdd8('0x1e')]('motion2')[_0xbdd8('0x1f')](function(_0x273172){logger[_0xbdd8('0x14')](_0xbdd8('0x20'),_0x273172);return _0x48297a[_0xbdd8('0x11')](0xc8)[_0xbdd8('0x12')]({'output':_0xbdd8('0x21')});})[_0xbdd8('0x22')](function(_0x120567){logger[_0xbdd8('0x19')](_0x120567);return _0x48297a[_0xbdd8('0x11')](0x1f4)[_0xbdd8('0x12')](_0x120567);});};exports[_0xbdd8('0x23')]=function(_0x1b4f52,_0x28d43e){var _0x31d087=fs['readdirSync'](path[_0xbdd8('0x24')](config['root'],_0xbdd8('0x25'),_0xbdd8('0x23')));var _0x5ae45d=[];for(var _0x3141a1=0x0;_0x3141a1<_0x31d087[_0xbdd8('0x26')];_0x3141a1++){var _0x2c82d7=_0x31d087[_0x3141a1][_0xbdd8('0x27')](_0xbdd8('0x28'),'');if(compareVersions(module[_0xbdd8('0xb')][_0xbdd8('0x3')],_0x2c82d7)===-0x1){_0x5ae45d[_0xbdd8('0x29')](_0x2c82d7);}}if(_0x5ae45d[_0xbdd8('0x26')]){var _0x39ca59=_0x5ae45d[_0xbdd8('0x2a')](compareVersions);var _0x1d0b5e=new Umzug({'storage':_0xbdd8('0x2b'),'storageOptions':{'model':db[_0xbdd8('0x2c')],'modelName':_0xbdd8('0x2c'),'columnName':_0xbdd8('0x3')},'migrations':{'params':[db[_0xbdd8('0x2b')][_0xbdd8('0x2d')](),db[_0xbdd8('0x2b')][_0xbdd8('0x2e')],function(){throw new Error(_0xbdd8('0x2f'));}],'path':path['join'](config[_0xbdd8('0xa')],_0xbdd8('0x25'),_0xbdd8('0x23')),'pattern':/\.js$/}});_0x1d0b5e['up']({'migrations':_['map'](_0x39ca59,function(_0xefc448){return _0xefc448+_0xbdd8('0x28');})})[_0xbdd8('0x1f')](function(){return _0x28d43e[_0xbdd8('0x11')](0xc8)['json']({'output':_0xbdd8('0x30')+module['exports'][_0xbdd8('0x3')]+'\x20to\x20'+_[_0xbdd8('0x31')](_0x39ca59),'migrations':_[_0xbdd8('0x24')](_0x39ca59)});})[_0xbdd8('0x22')](function(_0x1ffed5){if(_0x1ffed5 instanceof db[_0xbdd8('0x2b')][_0xbdd8('0x32')]){return _0x28d43e[_0xbdd8('0x11')](0xc8)[_0xbdd8('0x12')]({'output':_0xbdd8('0x33')});}else{return _0x28d43e['status'](0x1f4)[_0xbdd8('0x12')](_0x1ffed5);}});}else{return _0x28d43e['status'](0xc8)[_0xbdd8('0x12')]({'output':'Database\x20already\x20up-to-date'});}};