Built motion from commit (unavailable).|2.5.1
[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 _0x2272=['version','child_process','exec','../../mysqldb','../../config/logger','update','simple-git','root','index','exports','query','fetch','tags','latest','2.0.0','status','json','origin','master','error','info','git\x20fetch','git\x20fetch\x20origin\x20master','reset','--hard','FETCH_HEAD','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','migrations','readdirSync','server','length','.js','push','sort','sequelize','Migration','constructor','Migration\x20tried\x20to\x20use\x20old\x20style\x20\x22done\x22\x20callback.\x20Please\x20upgrade\x20to\x20\x22umzug\x22\x20and\x20return\x20a\x20promise\x20instead.','join','map','\x20to\x20','catch','Database\x20already\x20up-to-date','umzug','path','lodash','pkginfo'];(function(_0x43d6b8,_0x15d2a7){var _0x45673c=function(_0x4aa501){while(--_0x4aa501){_0x43d6b8['push'](_0x43d6b8['shift']());}};_0x45673c(++_0x15d2a7);}(_0x2272,0xd8));var _0x2227=function(_0xa464c9,_0x7c86d8){_0xa464c9=_0xa464c9-0x0;var _0x3d73c4=_0x2272[_0xa464c9];return _0x3d73c4;};'use strict';var Umzug=require(_0x2227('0x0'));var path=require(_0x2227('0x1'));var fs=require('fs');var _=require(_0x2227('0x2'));var pkginfo=require(_0x2227('0x3'))(module,_0x2227('0x4'));var compareVersions=require('compare-versions');var exec=require(_0x2227('0x5'))[_0x2227('0x6')];var db=require(_0x2227('0x7'))['db'];var config=require('../../config/environment');var pm2=require('../../config/pm2');var logger=require(_0x2227('0x8'))(_0x2227('0x9'));var git=require(_0x2227('0xa'))(config[_0x2227('0xb')]);exports[_0x2227('0xc')]=function(_0x1413d2,_0x41fc3f){var _0x34bdd0={'current':module[_0x2227('0xd')][_0x2227('0x4')],'phonebar':0x2};if(_0x1413d2['query']&&_0x1413d2[_0x2227('0xe')]['latest']){return git[_0x2227('0xf')]()[_0x2227('0x10')](function(_0x164735,_0x194df6){_0x34bdd0[_0x2227('0x11')]=(_0x164735?module['exports'][_0x2227('0x4')]:_0x194df6[_0x2227('0x11')])||_0x2227('0x12');return _0x41fc3f[_0x2227('0x13')](0xc8)[_0x2227('0x14')](_0x34bdd0);});}else{return _0x41fc3f[_0x2227('0x13')](0xc8)['json'](_0x34bdd0);}};exports['fetch']=function(_0x5152ef,_0x136f6b){return git['fetch']([_0x2227('0x15'),_0x2227('0x16')],function(_0x510b09){if(_0x510b09){logger[_0x2227('0x17')](_0x510b09);return _0x136f6b[_0x2227('0x13')](0x1f4)[_0x2227('0x14')](_0x510b09);}logger[_0x2227('0x18')](_0x2227('0x19'));return _0x136f6b[_0x2227('0x13')](0xc8)['json']({'output':_0x2227('0x1a')});});};exports[_0x2227('0x1b')]=function(_0x162723,_0x531f75){return git[_0x2227('0x1b')]([_0x2227('0x1c'),_0x2227('0x1d')],function(_0x2482ba){if(_0x2482ba){logger[_0x2227('0x17')](_0x2482ba);return _0x531f75[_0x2227('0x13')](0x1f4)[_0x2227('0x14')](_0x2482ba);}logger['info'](_0x2227('0x1e'));return _0x531f75['status'](0xc8)[_0x2227('0x14')]({'output':_0x2227('0x1f')});});};exports[_0x2227('0x20')]=function(_0x1f28ef,_0x3663ae){exec(_0x2227('0x21'),function(_0x19ab59,_0x10d9ca,_0x3299fd){logger[_0x2227('0x18')](_0x10d9ca);logger[_0x2227('0x18')](_0x3299fd);if(_0x19ab59){logger['error'](_0x19ab59);return _0x3663ae[_0x2227('0x13')](0x1f4)[_0x2227('0x14')](_0x19ab59);}return _0x3663ae['status'](0xc8)[_0x2227('0x14')]({'output':_0x10d9ca});});};exports[_0x2227('0x22')]=function(_0x5ea1c3,_0x4cc85f){return pm2[_0x2227('0x22')](_0x2227('0x23'))[_0x2227('0x24')](function(_0x1f30c3){logger['info'](_0x2227('0x25'),_0x1f30c3);return _0x4cc85f[_0x2227('0x13')](0xc8)[_0x2227('0x14')]({'output':_0x2227('0x26')});})['catch'](function(_0x204def){logger[_0x2227('0x17')](_0x204def);return _0x4cc85f[_0x2227('0x13')](0x1f4)[_0x2227('0x14')](_0x204def);});};exports[_0x2227('0x27')]=function(_0x4789eb,_0x55015e){var _0x5d1d56=fs[_0x2227('0x28')](path['join'](config[_0x2227('0xb')],_0x2227('0x29'),'migrations'));var _0x5916d4=[];for(var _0x1f1ba7=0x0;_0x1f1ba7<_0x5d1d56[_0x2227('0x2a')];_0x1f1ba7++){var _0x21838a=_0x5d1d56[_0x1f1ba7]['replace'](_0x2227('0x2b'),'');if(compareVersions(module['exports'][_0x2227('0x4')],_0x21838a)===-0x1){_0x5916d4[_0x2227('0x2c')](_0x21838a);}}if(_0x5916d4[_0x2227('0x2a')]){var _0xfa2140=_0x5916d4[_0x2227('0x2d')](compareVersions);var _0x256b7b=new Umzug({'storage':_0x2227('0x2e'),'storageOptions':{'model':db[_0x2227('0x2f')],'modelName':_0x2227('0x2f'),'columnName':_0x2227('0x4')},'migrations':{'params':[db[_0x2227('0x2e')]['getQueryInterface'](),db[_0x2227('0x2e')][_0x2227('0x30')],function(){throw new Error(_0x2227('0x31'));}],'path':path[_0x2227('0x32')](config['root'],_0x2227('0x29'),_0x2227('0x27')),'pattern':/\.js$/}});_0x256b7b['up']({'migrations':_[_0x2227('0x33')](_0xfa2140,function(_0x263a3c){return _0x263a3c+'.js';})})[_0x2227('0x24')](function(){return _0x55015e[_0x2227('0x13')](0xc8)[_0x2227('0x14')]({'output':'Database\x20migrated\x20successfully\x20from\x20version\x20'+module['exports'][_0x2227('0x4')]+_0x2227('0x34')+_['last'](_0xfa2140),'migrations':_[_0x2227('0x32')](_0xfa2140)});})[_0x2227('0x35')](function(_0x5dac69){if(_0x5dac69 instanceof db[_0x2227('0x2e')]['UniqueConstraintError']){return _0x55015e[_0x2227('0x13')](0xc8)[_0x2227('0x14')]({'output':_0x2227('0x36')});}else{return _0x55015e[_0x2227('0x13')](0x1f4)['json'](_0x5dac69);}});}else{return _0x55015e[_0x2227('0x13')](0xc8)['json']({'output':_0x2227('0x36')});}};