80a99225e5895fdf8e22a50af9133168b425fdf5
[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 _0x68fd=['git\x20fetch','git\x20fetch\x20origin\x20master','reset','--hard','FETCH_HEAD','info','git\x20reset\x20--hard\x20FETCH_HEAD','git\x20reset\x20--hard','pull','npm\x20install\x20--production','restart','motion2','then','pm2\x20restart\x20motion\x20%s','Your\x20system\x20has\x20been\x20restart\x20successfully','catch','migrations','readdirSync','root','length','.js','sort','Migration','sequelize','constructor','Migration\x20tried\x20to\x20use\x20old\x20style\x20\x22done\x22\x20callback.\x20Please\x20upgrade\x20to\x20\x22umzug\x22\x20and\x20return\x20a\x20promise\x20instead.','join','server','map','Database\x20migrated\x20successfully\x20from\x20version\x20','\x20to\x20','UniqueConstraintError','Database\x20already\x20up-to-date','umzug','lodash','pkginfo','compare-versions','child_process','exec','../../mysqldb','../../config/environment','../../config/pm2','../../config/logger','update','simple-git','index','exports','version','query','fetch','latest','2.0.0','origin','master','error','status','json'];(function(_0x2bc188,_0xbcc2fc){var _0x3b0a0a=function(_0x1aa31e){while(--_0x1aa31e){_0x2bc188['push'](_0x2bc188['shift']());}};_0x3b0a0a(++_0xbcc2fc);}(_0x68fd,0x1e9));var _0xd68f=function(_0x1fae76,_0x2d852d){_0x1fae76=_0x1fae76-0x0;var _0x5e5bf1=_0x68fd[_0x1fae76];return _0x5e5bf1;};'use strict';var Umzug=require(_0xd68f('0x0'));var path=require('path');var fs=require('fs');var _=require(_0xd68f('0x1'));var pkginfo=require(_0xd68f('0x2'))(module,'version');var compareVersions=require(_0xd68f('0x3'));var exec=require(_0xd68f('0x4'))[_0xd68f('0x5')];var db=require(_0xd68f('0x6'))['db'];var config=require(_0xd68f('0x7'));var pm2=require(_0xd68f('0x8'));var logger=require(_0xd68f('0x9'))(_0xd68f('0xa'));var git=require(_0xd68f('0xb'))(config['root']);exports[_0xd68f('0xc')]=function(_0x182353,_0x26f6ca){var _0x22c199={'current':module[_0xd68f('0xd')][_0xd68f('0xe')],'phonebar':0x2};if(_0x182353[_0xd68f('0xf')]&&_0x182353['query']['latest']){return git[_0xd68f('0x10')]()['tags'](function(_0x114bda,_0x41a7e7){_0x22c199[_0xd68f('0x11')]=(_0x114bda?module[_0xd68f('0xd')][_0xd68f('0xe')]:_0x41a7e7[_0xd68f('0x11')])||_0xd68f('0x12');return _0x26f6ca['status'](0xc8)['json'](_0x22c199);});}else{return _0x26f6ca['status'](0xc8)['json'](_0x22c199);}};exports[_0xd68f('0x10')]=function(_0x305c19,_0x48f357){return git[_0xd68f('0x10')]([_0xd68f('0x13'),_0xd68f('0x14')],function(_0x36441f){if(_0x36441f){logger[_0xd68f('0x15')](_0x36441f);return _0x48f357[_0xd68f('0x16')](0x1f4)[_0xd68f('0x17')](_0x36441f);}logger['info'](_0xd68f('0x18'));return _0x48f357['status'](0xc8)['json']({'output':_0xd68f('0x19')});});};exports[_0xd68f('0x1a')]=function(_0x451450,_0x3fdfbf){return git[_0xd68f('0x1a')]([_0xd68f('0x1b'),_0xd68f('0x1c')],function(_0x47fdbc){if(_0x47fdbc){logger['error'](_0x47fdbc);return _0x3fdfbf[_0xd68f('0x16')](0x1f4)[_0xd68f('0x17')](_0x47fdbc);}logger[_0xd68f('0x1d')](_0xd68f('0x1e'));return _0x3fdfbf[_0xd68f('0x16')](0xc8)['json']({'output':_0xd68f('0x1f')});});};exports[_0xd68f('0x20')]=function(_0x3fbc0b,_0x4e00c0){exec(_0xd68f('0x21'),function(_0x1379e2,_0xeba444,_0x590e04){logger['info'](_0xeba444);logger[_0xd68f('0x1d')](_0x590e04);if(_0x1379e2){logger['error'](_0x1379e2);return _0x4e00c0['status'](0x1f4)[_0xd68f('0x17')](_0x1379e2);}return _0x4e00c0[_0xd68f('0x16')](0xc8)[_0xd68f('0x17')]({'output':_0xeba444});});};exports[_0xd68f('0x22')]=function(_0x4595bf,_0x434fde){return pm2[_0xd68f('0x22')](_0xd68f('0x23'))[_0xd68f('0x24')](function(_0x2d2df4){logger[_0xd68f('0x1d')](_0xd68f('0x25'),_0x2d2df4);return _0x434fde[_0xd68f('0x16')](0xc8)['json']({'output':_0xd68f('0x26')});})[_0xd68f('0x27')](function(_0x4b1515){logger[_0xd68f('0x15')](_0x4b1515);return _0x434fde['status'](0x1f4)['json'](_0x4b1515);});};exports[_0xd68f('0x28')]=function(_0x42f8d2,_0x1eaebc){var _0x52a2dc=fs[_0xd68f('0x29')](path['join'](config[_0xd68f('0x2a')],'server',_0xd68f('0x28')));var _0x2dd737=[];for(var _0x426ad2=0x0;_0x426ad2<_0x52a2dc[_0xd68f('0x2b')];_0x426ad2++){var _0x38df7f=_0x52a2dc[_0x426ad2]['replace'](_0xd68f('0x2c'),'');if(compareVersions(module['exports'][_0xd68f('0xe')],_0x38df7f)===-0x1){_0x2dd737['push'](_0x38df7f);}}if(_0x2dd737[_0xd68f('0x2b')]){var _0x2d3b04=_0x2dd737[_0xd68f('0x2d')](compareVersions);var _0x1f6266=new Umzug({'storage':'sequelize','storageOptions':{'model':db[_0xd68f('0x2e')],'modelName':_0xd68f('0x2e'),'columnName':_0xd68f('0xe')},'migrations':{'params':[db[_0xd68f('0x2f')]['getQueryInterface'](),db[_0xd68f('0x2f')][_0xd68f('0x30')],function(){throw new Error(_0xd68f('0x31'));}],'path':path[_0xd68f('0x32')](config[_0xd68f('0x2a')],_0xd68f('0x33'),_0xd68f('0x28')),'pattern':/\.js$/}});_0x1f6266['up']({'migrations':_[_0xd68f('0x34')](_0x2d3b04,function(_0x5590e0){return _0x5590e0+_0xd68f('0x2c');})})[_0xd68f('0x24')](function(){return _0x1eaebc[_0xd68f('0x16')](0xc8)[_0xd68f('0x17')]({'output':_0xd68f('0x35')+module[_0xd68f('0xd')][_0xd68f('0xe')]+_0xd68f('0x36')+_['last'](_0x2d3b04),'migrations':_[_0xd68f('0x32')](_0x2d3b04)});})[_0xd68f('0x27')](function(_0x13f773){if(_0x13f773 instanceof db[_0xd68f('0x2f')][_0xd68f('0x37')]){return _0x1eaebc['status'](0xc8)[_0xd68f('0x17')]({'output':_0xd68f('0x38')});}else{return _0x1eaebc[_0xd68f('0x16')](0x1f4)[_0xd68f('0x17')](_0x13f773);}});}else{return _0x1eaebc[_0xd68f('0x16')](0xc8)[_0xd68f('0x17')]({'output':_0xd68f('0x38')});}};