Built motion from commit dc14b02d.|2.6.27
[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 _0x5520=['replace','.js','push','length','sequelize','Migration','getQueryInterface','constructor','map','Database\x20migrated\x20successfully\x20from\x20version\x20','\x20to\x20','UniqueConstraintError','Database\x20already\x20up-to-date','umzug','path','pkginfo','version','compare-versions','child_process','exec','../../mysqldb','../../config/environment','update','simple-git','index','exports','query','latest','fetch','tags','2.0.0','status','json','origin','error','info','git\x20fetch','git\x20fetch\x20origin\x20master','--hard','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','join','root','server'];(function(_0x35c4b6,_0x3f462e){var _0x444f74=function(_0xee09cb){while(--_0xee09cb){_0x35c4b6['push'](_0x35c4b6['shift']());}};_0x444f74(++_0x3f462e);}(_0x5520,0x187));var _0x0552=function(_0xefe955,_0x139c69){_0xefe955=_0xefe955-0x0;var _0x50ce7d=_0x5520[_0xefe955];return _0x50ce7d;};'use strict';var Umzug=require(_0x0552('0x0'));var path=require(_0x0552('0x1'));var fs=require('fs');var _=require('lodash');var pkginfo=require(_0x0552('0x2'))(module,_0x0552('0x3'));var compareVersions=require(_0x0552('0x4'));var exec=require(_0x0552('0x5'))[_0x0552('0x6')];var db=require(_0x0552('0x7'))['db'];var config=require(_0x0552('0x8'));var pm2=require('../../config/pm2');var logger=require('../../config/logger')(_0x0552('0x9'));var git=require(_0x0552('0xa'))(config['root']);exports[_0x0552('0xb')]=function(_0x687486,_0x1259ab){var _0x50e664={'current':module[_0x0552('0xc')][_0x0552('0x3')],'phonebar':0x2};if(_0x687486['query']&&_0x687486[_0x0552('0xd')][_0x0552('0xe')]){return git[_0x0552('0xf')]()[_0x0552('0x10')](function(_0x325a9a,_0x1a5ea0){_0x50e664[_0x0552('0xe')]=(_0x325a9a?module['exports'][_0x0552('0x3')]:_0x1a5ea0[_0x0552('0xe')])||_0x0552('0x11');return _0x1259ab[_0x0552('0x12')](0xc8)['json'](_0x50e664);});}else{return _0x1259ab['status'](0xc8)[_0x0552('0x13')](_0x50e664);}};exports[_0x0552('0xf')]=function(_0x16d955,_0x352a0f){return git[_0x0552('0xf')]([_0x0552('0x14'),'master'],function(_0x27f91e){if(_0x27f91e){logger[_0x0552('0x15')](_0x27f91e);return _0x352a0f[_0x0552('0x12')](0x1f4)[_0x0552('0x13')](_0x27f91e);}logger[_0x0552('0x16')](_0x0552('0x17'));return _0x352a0f['status'](0xc8)['json']({'output':_0x0552('0x18')});});};exports['reset']=function(_0x4a1b0d,_0x4ee6d9){return git['reset']([_0x0552('0x19'),'FETCH_HEAD'],function(_0x52a729){if(_0x52a729){logger['error'](_0x52a729);return _0x4ee6d9[_0x0552('0x12')](0x1f4)[_0x0552('0x13')](_0x52a729);}logger[_0x0552('0x16')](_0x0552('0x1a'));return _0x4ee6d9['status'](0xc8)[_0x0552('0x13')]({'output':_0x0552('0x1b')});});};exports[_0x0552('0x1c')]=function(_0x3f7786,_0x36e938){exec(_0x0552('0x1d'),function(_0x1b5969,_0x2d6545,_0x561a63){logger[_0x0552('0x16')](_0x2d6545);logger['info'](_0x561a63);if(_0x1b5969){logger['error'](_0x1b5969);return _0x36e938['status'](0x1f4)[_0x0552('0x13')](_0x1b5969);}return _0x36e938[_0x0552('0x12')](0xc8)[_0x0552('0x13')]({'output':_0x2d6545});});};exports[_0x0552('0x1e')]=function(_0x138cb5,_0xd57eea){return pm2[_0x0552('0x1e')](_0x0552('0x1f'))[_0x0552('0x20')](function(_0x2d2f9b){logger[_0x0552('0x16')](_0x0552('0x21'),_0x2d2f9b);return _0xd57eea['status'](0xc8)['json']({'output':_0x0552('0x22')});})[_0x0552('0x23')](function(_0x2126c0){logger[_0x0552('0x15')](_0x2126c0);return _0xd57eea[_0x0552('0x12')](0x1f4)[_0x0552('0x13')](_0x2126c0);});};exports[_0x0552('0x24')]=function(_0x9f2be3,_0x52bbd1){var _0x2dc63f=fs[_0x0552('0x25')](path[_0x0552('0x26')](config[_0x0552('0x27')],_0x0552('0x28'),'migrations'));var _0x6677de=[];for(var _0x4c2356=0x0;_0x4c2356<_0x2dc63f['length'];_0x4c2356++){var _0x2ca6aa=_0x2dc63f[_0x4c2356][_0x0552('0x29')](_0x0552('0x2a'),'');if(compareVersions(module[_0x0552('0xc')]['version'],_0x2ca6aa)===-0x1){_0x6677de[_0x0552('0x2b')](_0x2ca6aa);}}if(_0x6677de[_0x0552('0x2c')]){var _0x48f00b=_0x6677de['sort'](compareVersions);var _0x1c5e83=new Umzug({'storage':_0x0552('0x2d'),'storageOptions':{'model':db[_0x0552('0x2e')],'modelName':_0x0552('0x2e'),'columnName':_0x0552('0x3')},'migrations':{'params':[db['sequelize'][_0x0552('0x2f')](),db[_0x0552('0x2d')][_0x0552('0x30')],function(){throw new Error('Migration\x20tried\x20to\x20use\x20old\x20style\x20\x22done\x22\x20callback.\x20Please\x20upgrade\x20to\x20\x22umzug\x22\x20and\x20return\x20a\x20promise\x20instead.');}],'path':path[_0x0552('0x26')](config[_0x0552('0x27')],'server','migrations'),'pattern':/\.js$/}});_0x1c5e83['up']({'migrations':_[_0x0552('0x31')](_0x48f00b,function(_0x3490a9){return _0x3490a9+_0x0552('0x2a');})})[_0x0552('0x20')](function(){return _0x52bbd1[_0x0552('0x12')](0xc8)[_0x0552('0x13')]({'output':_0x0552('0x32')+module['exports']['version']+_0x0552('0x33')+_['last'](_0x48f00b),'migrations':_[_0x0552('0x26')](_0x48f00b)});})[_0x0552('0x23')](function(_0x3a8e49){if(_0x3a8e49 instanceof db[_0x0552('0x2d')][_0x0552('0x34')]){return _0x52bbd1[_0x0552('0x12')](0xc8)[_0x0552('0x13')]({'output':'Database\x20already\x20up-to-date'});}else{return _0x52bbd1[_0x0552('0x12')](0x1f4)['json'](_0x3a8e49);}});}else{return _0x52bbd1['status'](0xc8)[_0x0552('0x13')]({'output':_0x0552('0x35')});}};