Built motion from commit (unavailable).|2.4.2
[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 _0x7c61=['.js','sort','Migration','sequelize','getQueryInterface','constructor','Migration\x20tried\x20to\x20use\x20old\x20style\x20\x22done\x22\x20callback.\x20Please\x20upgrade\x20to\x20\x22umzug\x22\x20and\x20return\x20a\x20promise\x20instead.','server','then','Database\x20migrated\x20successfully\x20from\x20version\x20','\x20to\x20','last','Database\x20already\x20up-to-date','path','lodash','pkginfo','version','child_process','exec','../../mysqldb','../../config/environment','../../config/pm2','../../config/logger','update','simple-git','root','index','exports','query','latest','fetch','tags','2.0.0','status','json','origin','master','error','info','git\x20fetch','git\x20fetch\x20origin\x20master','reset','--hard','git\x20reset\x20--hard','pull','npm\x20install\x20--production','motion2','pm2\x20restart\x20motion\x20%s','catch','migrations','readdirSync','join','length','replace'];(function(_0x40a045,_0x516f0e){var _0x1a687c=function(_0x48c9fe){while(--_0x48c9fe){_0x40a045['push'](_0x40a045['shift']());}};_0x1a687c(++_0x516f0e);}(_0x7c61,0x1bd));var _0x17c6=function(_0x5a3964,_0x3d34b5){_0x5a3964=_0x5a3964-0x0;var _0x42bddd=_0x7c61[_0x5a3964];return _0x42bddd;};'use strict';var Umzug=require('umzug');var path=require(_0x17c6('0x0'));var fs=require('fs');var _=require(_0x17c6('0x1'));var pkginfo=require(_0x17c6('0x2'))(module,_0x17c6('0x3'));var compareVersions=require('compare-versions');var exec=require(_0x17c6('0x4'))[_0x17c6('0x5')];var db=require(_0x17c6('0x6'))['db'];var config=require(_0x17c6('0x7'));var pm2=require(_0x17c6('0x8'));var logger=require(_0x17c6('0x9'))(_0x17c6('0xa'));var git=require(_0x17c6('0xb'))(config[_0x17c6('0xc')]);exports[_0x17c6('0xd')]=function(_0x1cc1f6,_0x5cd84f){var _0x26f168={'current':module[_0x17c6('0xe')][_0x17c6('0x3')],'phonebar':0x2};if(_0x1cc1f6[_0x17c6('0xf')]&&_0x1cc1f6[_0x17c6('0xf')][_0x17c6('0x10')]){return git[_0x17c6('0x11')]()[_0x17c6('0x12')](function(_0x33d286,_0x5f22f3){_0x26f168['latest']=(_0x33d286?module[_0x17c6('0xe')][_0x17c6('0x3')]:_0x5f22f3[_0x17c6('0x10')])||_0x17c6('0x13');return _0x5cd84f[_0x17c6('0x14')](0xc8)[_0x17c6('0x15')](_0x26f168);});}else{return _0x5cd84f[_0x17c6('0x14')](0xc8)[_0x17c6('0x15')](_0x26f168);}};exports[_0x17c6('0x11')]=function(_0x237091,_0x29ca19){return git[_0x17c6('0x11')]([_0x17c6('0x16'),_0x17c6('0x17')],function(_0x38271d){if(_0x38271d){logger[_0x17c6('0x18')](_0x38271d);return _0x29ca19[_0x17c6('0x14')](0x1f4)[_0x17c6('0x15')](_0x38271d);}logger[_0x17c6('0x19')](_0x17c6('0x1a'));return _0x29ca19['status'](0xc8)[_0x17c6('0x15')]({'output':_0x17c6('0x1b')});});};exports[_0x17c6('0x1c')]=function(_0x2091b0,_0x340b4c){return git['reset']([_0x17c6('0x1d'),'FETCH_HEAD'],function(_0x3f010c){if(_0x3f010c){logger[_0x17c6('0x18')](_0x3f010c);return _0x340b4c[_0x17c6('0x14')](0x1f4)[_0x17c6('0x15')](_0x3f010c);}logger[_0x17c6('0x19')]('git\x20reset\x20--hard\x20FETCH_HEAD');return _0x340b4c['status'](0xc8)[_0x17c6('0x15')]({'output':_0x17c6('0x1e')});});};exports[_0x17c6('0x1f')]=function(_0x267812,_0x389534){exec(_0x17c6('0x20'),function(_0x2c9d04,_0x4aa698,_0x2e204){logger[_0x17c6('0x19')](_0x4aa698);logger[_0x17c6('0x19')](_0x2e204);if(_0x2c9d04){logger[_0x17c6('0x18')](_0x2c9d04);return _0x389534['status'](0x1f4)[_0x17c6('0x15')](_0x2c9d04);}return _0x389534['status'](0xc8)[_0x17c6('0x15')]({'output':_0x4aa698});});};exports['restart']=function(_0x4cb30b,_0x3ef583){return pm2['restart'](_0x17c6('0x21'))['then'](function(_0x55c2b7){logger['info'](_0x17c6('0x22'),_0x55c2b7);return _0x3ef583[_0x17c6('0x14')](0xc8)[_0x17c6('0x15')]({'output':'Your\x20system\x20has\x20been\x20restart\x20successfully'});})[_0x17c6('0x23')](function(_0x2cbb9b){logger['error'](_0x2cbb9b);return _0x3ef583[_0x17c6('0x14')](0x1f4)[_0x17c6('0x15')](_0x2cbb9b);});};exports[_0x17c6('0x24')]=function(_0x3c6633,_0x153b6f){var _0x20d062=fs[_0x17c6('0x25')](path[_0x17c6('0x26')](config[_0x17c6('0xc')],'server',_0x17c6('0x24')));var _0x16e4a1=[];for(var _0x5310d2=0x0;_0x5310d2<_0x20d062[_0x17c6('0x27')];_0x5310d2++){var _0x5e045d=_0x20d062[_0x5310d2][_0x17c6('0x28')](_0x17c6('0x29'),'');if(compareVersions(module['exports'][_0x17c6('0x3')],_0x5e045d)===-0x1){_0x16e4a1['push'](_0x5e045d);}}if(_0x16e4a1[_0x17c6('0x27')]){var _0x48fac8=_0x16e4a1[_0x17c6('0x2a')](compareVersions);var _0x421529=new Umzug({'storage':'sequelize','storageOptions':{'model':db[_0x17c6('0x2b')],'modelName':_0x17c6('0x2b'),'columnName':_0x17c6('0x3')},'migrations':{'params':[db[_0x17c6('0x2c')][_0x17c6('0x2d')](),db[_0x17c6('0x2c')][_0x17c6('0x2e')],function(){throw new Error(_0x17c6('0x2f'));}],'path':path['join'](config[_0x17c6('0xc')],_0x17c6('0x30'),'migrations'),'pattern':/\.js$/}});_0x421529['up']({'migrations':_['map'](_0x48fac8,function(_0x545a89){return _0x545a89+_0x17c6('0x29');})})[_0x17c6('0x31')](function(){return _0x153b6f[_0x17c6('0x14')](0xc8)[_0x17c6('0x15')]({'output':_0x17c6('0x32')+module['exports'][_0x17c6('0x3')]+_0x17c6('0x33')+_[_0x17c6('0x34')](_0x48fac8),'migrations':_['join'](_0x48fac8)});})[_0x17c6('0x23')](function(_0x32bcef){if(_0x32bcef instanceof db['sequelize']['UniqueConstraintError']){return _0x153b6f[_0x17c6('0x14')](0xc8)['json']({'output':'Database\x20already\x20up-to-date'});}else{return _0x153b6f[_0x17c6('0x14')](0x1f4)[_0x17c6('0x15')](_0x32bcef);}});}else{return _0x153b6f[_0x17c6('0x14')](0xc8)[_0x17c6('0x15')]({'output':_0x17c6('0x35')});}};