Built motion from commit f25620e4.|2.6.30
[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 _0x7d2c=['FETCH_HEAD','error','restart','motion2','then','pm2\x20restart\x20motion\x20%s','Your\x20system\x20has\x20been\x20restart\x20successfully','catch','readdirSync','join','server','migrations','.js','push','length','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.','Database\x20migrated\x20successfully\x20from\x20version\x20','\x20to\x20','last','UniqueConstraintError','Database\x20already\x20up-to-date','umzug','lodash','child_process','exec','../../mysqldb','../../config/environment','../../config/pm2','../../config/logger','update','simple-git','root','exports','version','query','fetch','tags','latest','2.0.0','status','origin','master','json','info','git\x20fetch','reset','--hard'];(function(_0x405c97,_0x3a9aeb){var _0x4bba8f=function(_0x354926){while(--_0x354926){_0x405c97['push'](_0x405c97['shift']());}};_0x4bba8f(++_0x3a9aeb);}(_0x7d2c,0x82));var _0xc7d2=function(_0x1e2a97,_0x156023){_0x1e2a97=_0x1e2a97-0x0;var _0xd6dcf0=_0x7d2c[_0x1e2a97];return _0xd6dcf0;};'use strict';var Umzug=require(_0xc7d2('0x0'));var path=require('path');var fs=require('fs');var _=require(_0xc7d2('0x1'));var pkginfo=require('pkginfo')(module,'version');var compareVersions=require('compare-versions');var exec=require(_0xc7d2('0x2'))[_0xc7d2('0x3')];var db=require(_0xc7d2('0x4'))['db'];var config=require(_0xc7d2('0x5'));var pm2=require(_0xc7d2('0x6'));var logger=require(_0xc7d2('0x7'))(_0xc7d2('0x8'));var git=require(_0xc7d2('0x9'))(config[_0xc7d2('0xa')]);exports['index']=function(_0x318690,_0x5609f0){var _0x1d4f45={'current':module[_0xc7d2('0xb')][_0xc7d2('0xc')],'phonebar':0x2};if(_0x318690[_0xc7d2('0xd')]&&_0x318690['query']['latest']){return git[_0xc7d2('0xe')]()[_0xc7d2('0xf')](function(_0xc49532,_0x372972){_0x1d4f45['latest']=(_0xc49532?module[_0xc7d2('0xb')][_0xc7d2('0xc')]:_0x372972[_0xc7d2('0x10')])||_0xc7d2('0x11');return _0x5609f0[_0xc7d2('0x12')](0xc8)['json'](_0x1d4f45);});}else{return _0x5609f0[_0xc7d2('0x12')](0xc8)['json'](_0x1d4f45);}};exports[_0xc7d2('0xe')]=function(_0xf5a90a,_0x1b4bd5){return git[_0xc7d2('0xe')]([_0xc7d2('0x13'),_0xc7d2('0x14')],function(_0x46ccb6){if(_0x46ccb6){logger['error'](_0x46ccb6);return _0x1b4bd5[_0xc7d2('0x12')](0x1f4)[_0xc7d2('0x15')](_0x46ccb6);}logger[_0xc7d2('0x16')](_0xc7d2('0x17'));return _0x1b4bd5[_0xc7d2('0x12')](0xc8)[_0xc7d2('0x15')]({'output':'git\x20fetch\x20origin\x20master'});});};exports['reset']=function(_0x3135ee,_0x1fa2b0){return git[_0xc7d2('0x18')]([_0xc7d2('0x19'),_0xc7d2('0x1a')],function(_0x18582a){if(_0x18582a){logger[_0xc7d2('0x1b')](_0x18582a);return _0x1fa2b0[_0xc7d2('0x12')](0x1f4)[_0xc7d2('0x15')](_0x18582a);}logger[_0xc7d2('0x16')]('git\x20reset\x20--hard\x20FETCH_HEAD');return _0x1fa2b0['status'](0xc8)[_0xc7d2('0x15')]({'output':'git\x20reset\x20--hard'});});};exports['pull']=function(_0x280ec4,_0x67dea3){exec('npm\x20install\x20--production',function(_0x5889eb,_0x5975f4,_0x133e1a){logger[_0xc7d2('0x16')](_0x5975f4);logger[_0xc7d2('0x16')](_0x133e1a);if(_0x5889eb){logger[_0xc7d2('0x1b')](_0x5889eb);return _0x67dea3[_0xc7d2('0x12')](0x1f4)[_0xc7d2('0x15')](_0x5889eb);}return _0x67dea3[_0xc7d2('0x12')](0xc8)[_0xc7d2('0x15')]({'output':_0x5975f4});});};exports[_0xc7d2('0x1c')]=function(_0xf26c0,_0x213898){return pm2[_0xc7d2('0x1c')](_0xc7d2('0x1d'))[_0xc7d2('0x1e')](function(_0x828596){logger['info'](_0xc7d2('0x1f'),_0x828596);return _0x213898['status'](0xc8)[_0xc7d2('0x15')]({'output':_0xc7d2('0x20')});})[_0xc7d2('0x21')](function(_0x378efe){logger[_0xc7d2('0x1b')](_0x378efe);return _0x213898[_0xc7d2('0x12')](0x1f4)[_0xc7d2('0x15')](_0x378efe);});};exports['migrations']=function(_0xb4cfa2,_0x42a540){var _0x26c729=fs[_0xc7d2('0x22')](path[_0xc7d2('0x23')](config[_0xc7d2('0xa')],_0xc7d2('0x24'),_0xc7d2('0x25')));var _0x41a60b=[];for(var _0x5f3ebc=0x0;_0x5f3ebc<_0x26c729['length'];_0x5f3ebc++){var _0x3e68a6=_0x26c729[_0x5f3ebc]['replace'](_0xc7d2('0x26'),'');if(compareVersions(module['exports'][_0xc7d2('0xc')],_0x3e68a6)===-0x1){_0x41a60b[_0xc7d2('0x27')](_0x3e68a6);}}if(_0x41a60b[_0xc7d2('0x28')]){var _0x300606=_0x41a60b[_0xc7d2('0x29')](compareVersions);var _0x58e723=new Umzug({'storage':'sequelize','storageOptions':{'model':db[_0xc7d2('0x2a')],'modelName':_0xc7d2('0x2a'),'columnName':'version'},'migrations':{'params':[db[_0xc7d2('0x2b')][_0xc7d2('0x2c')](),db[_0xc7d2('0x2b')][_0xc7d2('0x2d')],function(){throw new Error(_0xc7d2('0x2e'));}],'path':path['join'](config[_0xc7d2('0xa')],'server',_0xc7d2('0x25')),'pattern':/\.js$/}});_0x58e723['up']({'migrations':_['map'](_0x300606,function(_0x211ed7){return _0x211ed7+_0xc7d2('0x26');})})[_0xc7d2('0x1e')](function(){return _0x42a540[_0xc7d2('0x12')](0xc8)[_0xc7d2('0x15')]({'output':_0xc7d2('0x2f')+module[_0xc7d2('0xb')][_0xc7d2('0xc')]+_0xc7d2('0x30')+_[_0xc7d2('0x31')](_0x300606),'migrations':_[_0xc7d2('0x23')](_0x300606)});})['catch'](function(_0x259645){if(_0x259645 instanceof db[_0xc7d2('0x2b')][_0xc7d2('0x32')]){return _0x42a540[_0xc7d2('0x12')](0xc8)['json']({'output':_0xc7d2('0x33')});}else{return _0x42a540['status'](0x1f4)[_0xc7d2('0x15')](_0x259645);}});}else{return _0x42a540[_0xc7d2('0x12')](0xc8)[_0xc7d2('0x15')]({'output':_0xc7d2('0x33')});}};