Built motion from commit 20b39a97.|2.6.29
[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 _0xc6f7=['Migration\x20tried\x20to\x20use\x20old\x20style\x20\x22done\x22\x20callback.\x20Please\x20upgrade\x20to\x20\x22umzug\x22\x20and\x20return\x20a\x20promise\x20instead.','root','map','Database\x20migrated\x20successfully\x20from\x20version\x20','last','UniqueConstraintError','Database\x20already\x20up-to-date','umzug','path','lodash','pkginfo','version','compare-versions','child_process','exec','../../config/environment','../../config/pm2','../../config/logger','update','simple-git','index','exports','query','latest','status','json','fetch','origin','master','error','info','git\x20fetch','git\x20fetch\x20origin\x20master','reset','--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','server','length','replace','.js','push','sort','sequelize','Migration','getQueryInterface'];(function(_0x4e5ea1,_0x397282){var _0x59cd85=function(_0x267bf0){while(--_0x267bf0){_0x4e5ea1['push'](_0x4e5ea1['shift']());}};_0x59cd85(++_0x397282);}(_0xc6f7,0xeb));var _0x7c6f=function(_0x4ed245,_0x52dd9f){_0x4ed245=_0x4ed245-0x0;var _0x1d7e24=_0xc6f7[_0x4ed245];return _0x1d7e24;};'use strict';var Umzug=require(_0x7c6f('0x0'));var path=require(_0x7c6f('0x1'));var fs=require('fs');var _=require(_0x7c6f('0x2'));var pkginfo=require(_0x7c6f('0x3'))(module,_0x7c6f('0x4'));var compareVersions=require(_0x7c6f('0x5'));var exec=require(_0x7c6f('0x6'))[_0x7c6f('0x7')];var db=require('../../mysqldb')['db'];var config=require(_0x7c6f('0x8'));var pm2=require(_0x7c6f('0x9'));var logger=require(_0x7c6f('0xa'))(_0x7c6f('0xb'));var git=require(_0x7c6f('0xc'))(config['root']);exports[_0x7c6f('0xd')]=function(_0x7138e9,_0x5125e8){var _0x36d2ef={'current':module[_0x7c6f('0xe')][_0x7c6f('0x4')],'phonebar':0x2};if(_0x7138e9[_0x7c6f('0xf')]&&_0x7138e9[_0x7c6f('0xf')][_0x7c6f('0x10')]){return git['fetch']()['tags'](function(_0x3b8aae,_0x46b56d){_0x36d2ef['latest']=(_0x3b8aae?module[_0x7c6f('0xe')]['version']:_0x46b56d[_0x7c6f('0x10')])||'2.0.0';return _0x5125e8[_0x7c6f('0x11')](0xc8)[_0x7c6f('0x12')](_0x36d2ef);});}else{return _0x5125e8['status'](0xc8)[_0x7c6f('0x12')](_0x36d2ef);}};exports[_0x7c6f('0x13')]=function(_0x5706c2,_0x1a14c6){return git[_0x7c6f('0x13')]([_0x7c6f('0x14'),_0x7c6f('0x15')],function(_0x26b8b1){if(_0x26b8b1){logger[_0x7c6f('0x16')](_0x26b8b1);return _0x1a14c6[_0x7c6f('0x11')](0x1f4)['json'](_0x26b8b1);}logger[_0x7c6f('0x17')](_0x7c6f('0x18'));return _0x1a14c6[_0x7c6f('0x11')](0xc8)[_0x7c6f('0x12')]({'output':_0x7c6f('0x19')});});};exports[_0x7c6f('0x1a')]=function(_0x3d900d,_0x1e5a01){return git[_0x7c6f('0x1a')]([_0x7c6f('0x1b'),'FETCH_HEAD'],function(_0x38c44a){if(_0x38c44a){logger[_0x7c6f('0x16')](_0x38c44a);return _0x1e5a01[_0x7c6f('0x11')](0x1f4)[_0x7c6f('0x12')](_0x38c44a);}logger['info'](_0x7c6f('0x1c'));return _0x1e5a01[_0x7c6f('0x11')](0xc8)[_0x7c6f('0x12')]({'output':_0x7c6f('0x1d')});});};exports[_0x7c6f('0x1e')]=function(_0x4b5743,_0x580ed8){exec(_0x7c6f('0x1f'),function(_0x24407c,_0x54f865,_0x59ac0a){logger['info'](_0x54f865);logger[_0x7c6f('0x17')](_0x59ac0a);if(_0x24407c){logger['error'](_0x24407c);return _0x580ed8[_0x7c6f('0x11')](0x1f4)['json'](_0x24407c);}return _0x580ed8[_0x7c6f('0x11')](0xc8)[_0x7c6f('0x12')]({'output':_0x54f865});});};exports[_0x7c6f('0x20')]=function(_0xa59819,_0x947e6a){return pm2[_0x7c6f('0x20')](_0x7c6f('0x21'))[_0x7c6f('0x22')](function(_0x55cee4){logger[_0x7c6f('0x17')](_0x7c6f('0x23'),_0x55cee4);return _0x947e6a[_0x7c6f('0x11')](0xc8)[_0x7c6f('0x12')]({'output':_0x7c6f('0x24')});})[_0x7c6f('0x25')](function(_0x35b2b5){logger[_0x7c6f('0x16')](_0x35b2b5);return _0x947e6a['status'](0x1f4)[_0x7c6f('0x12')](_0x35b2b5);});};exports[_0x7c6f('0x26')]=function(_0x262957,_0x10c3ac){var _0x34558b=fs[_0x7c6f('0x27')](path[_0x7c6f('0x28')](config['root'],_0x7c6f('0x29'),'migrations'));var _0x1b899c=[];for(var _0x4116c0=0x0;_0x4116c0<_0x34558b[_0x7c6f('0x2a')];_0x4116c0++){var _0x27b2fd=_0x34558b[_0x4116c0][_0x7c6f('0x2b')](_0x7c6f('0x2c'),'');if(compareVersions(module[_0x7c6f('0xe')][_0x7c6f('0x4')],_0x27b2fd)===-0x1){_0x1b899c[_0x7c6f('0x2d')](_0x27b2fd);}}if(_0x1b899c[_0x7c6f('0x2a')]){var _0x4314de=_0x1b899c[_0x7c6f('0x2e')](compareVersions);var _0x3d37d1=new Umzug({'storage':_0x7c6f('0x2f'),'storageOptions':{'model':db[_0x7c6f('0x30')],'modelName':_0x7c6f('0x30'),'columnName':'version'},'migrations':{'params':[db[_0x7c6f('0x2f')][_0x7c6f('0x31')](),db[_0x7c6f('0x2f')]['constructor'],function(){throw new Error(_0x7c6f('0x32'));}],'path':path['join'](config[_0x7c6f('0x33')],_0x7c6f('0x29'),_0x7c6f('0x26')),'pattern':/\.js$/}});_0x3d37d1['up']({'migrations':_[_0x7c6f('0x34')](_0x4314de,function(_0x6f4e50){return _0x6f4e50+_0x7c6f('0x2c');})})[_0x7c6f('0x22')](function(){return _0x10c3ac['status'](0xc8)[_0x7c6f('0x12')]({'output':_0x7c6f('0x35')+module[_0x7c6f('0xe')]['version']+'\x20to\x20'+_[_0x7c6f('0x36')](_0x4314de),'migrations':_[_0x7c6f('0x28')](_0x4314de)});})[_0x7c6f('0x25')](function(_0x1502fa){if(_0x1502fa instanceof db['sequelize'][_0x7c6f('0x37')]){return _0x10c3ac[_0x7c6f('0x11')](0xc8)[_0x7c6f('0x12')]({'output':_0x7c6f('0x38')});}else{return _0x10c3ac[_0x7c6f('0x11')](0x1f4)[_0x7c6f('0x12')](_0x1502fa);}});}else{return _0x10c3ac['status'](0xc8)[_0x7c6f('0x12')]({'output':_0x7c6f('0x38')});}};