Built motion from commit (unavailable).|2.5.16
[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 _0x6a0b=['simple-git','root','index','exports','latest','2.0.0','status','json','fetch','master','error','info','git\x20fetch','reset','--hard','FETCH_HEAD','git\x20reset\x20--hard\x20FETCH_HEAD','git\x20reset\x20--hard','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','Migration','sequelize','getQueryInterface','Migration\x20tried\x20to\x20use\x20old\x20style\x20\x22done\x22\x20callback.\x20Please\x20upgrade\x20to\x20\x22umzug\x22\x20and\x20return\x20a\x20promise\x20instead.','map','last','UniqueConstraintError','Database\x20already\x20up-to-date','umzug','pkginfo','version','child_process','exec','../../mysqldb','../../config/environment','../../config/pm2','update'];(function(_0x483e3a,_0x568361){var _0x43fca9=function(_0x273d7e){while(--_0x273d7e){_0x483e3a['push'](_0x483e3a['shift']());}};_0x43fca9(++_0x568361);}(_0x6a0b,0xf6));var _0xb6a0=function(_0x48a1da,_0x5e6a7b){_0x48a1da=_0x48a1da-0x0;var _0xaf6344=_0x6a0b[_0x48a1da];return _0xaf6344;};'use strict';var Umzug=require(_0xb6a0('0x0'));var path=require('path');var fs=require('fs');var _=require('lodash');var pkginfo=require(_0xb6a0('0x1'))(module,_0xb6a0('0x2'));var compareVersions=require('compare-versions');var exec=require(_0xb6a0('0x3'))[_0xb6a0('0x4')];var db=require(_0xb6a0('0x5'))['db'];var config=require(_0xb6a0('0x6'));var pm2=require(_0xb6a0('0x7'));var logger=require('../../config/logger')(_0xb6a0('0x8'));var git=require(_0xb6a0('0x9'))(config[_0xb6a0('0xa')]);exports[_0xb6a0('0xb')]=function(_0xb107bd,_0x434911){var _0x4357a5={'current':module[_0xb6a0('0xc')][_0xb6a0('0x2')],'phonebar':0x2};if(_0xb107bd['query']&&_0xb107bd['query']['latest']){return git['fetch']()['tags'](function(_0x3d6d0e,_0x5e7ad8){_0x4357a5[_0xb6a0('0xd')]=(_0x3d6d0e?module[_0xb6a0('0xc')]['version']:_0x5e7ad8[_0xb6a0('0xd')])||_0xb6a0('0xe');return _0x434911[_0xb6a0('0xf')](0xc8)[_0xb6a0('0x10')](_0x4357a5);});}else{return _0x434911[_0xb6a0('0xf')](0xc8)[_0xb6a0('0x10')](_0x4357a5);}};exports[_0xb6a0('0x11')]=function(_0x138b6c,_0x453a7e){return git[_0xb6a0('0x11')](['origin',_0xb6a0('0x12')],function(_0x40b199){if(_0x40b199){logger[_0xb6a0('0x13')](_0x40b199);return _0x453a7e[_0xb6a0('0xf')](0x1f4)[_0xb6a0('0x10')](_0x40b199);}logger[_0xb6a0('0x14')](_0xb6a0('0x15'));return _0x453a7e[_0xb6a0('0xf')](0xc8)[_0xb6a0('0x10')]({'output':'git\x20fetch\x20origin\x20master'});});};exports[_0xb6a0('0x16')]=function(_0x475a58,_0x1c6987){return git['reset']([_0xb6a0('0x17'),_0xb6a0('0x18')],function(_0x1708e4){if(_0x1708e4){logger[_0xb6a0('0x13')](_0x1708e4);return _0x1c6987[_0xb6a0('0xf')](0x1f4)['json'](_0x1708e4);}logger['info'](_0xb6a0('0x19'));return _0x1c6987[_0xb6a0('0xf')](0xc8)['json']({'output':_0xb6a0('0x1a')});});};exports['pull']=function(_0x2de5a2,_0x432984){exec(_0xb6a0('0x1b'),function(_0x5604c9,_0x2f7c95,_0x514f4c){logger[_0xb6a0('0x14')](_0x2f7c95);logger['info'](_0x514f4c);if(_0x5604c9){logger[_0xb6a0('0x13')](_0x5604c9);return _0x432984[_0xb6a0('0xf')](0x1f4)['json'](_0x5604c9);}return _0x432984[_0xb6a0('0xf')](0xc8)['json']({'output':_0x2f7c95});});};exports['restart']=function(_0xa40d72,_0x5ea3f1){return pm2[_0xb6a0('0x1c')](_0xb6a0('0x1d'))[_0xb6a0('0x1e')](function(_0x40e911){logger[_0xb6a0('0x14')](_0xb6a0('0x1f'),_0x40e911);return _0x5ea3f1[_0xb6a0('0xf')](0xc8)['json']({'output':_0xb6a0('0x20')});})[_0xb6a0('0x21')](function(_0xd6e536){logger[_0xb6a0('0x13')](_0xd6e536);return _0x5ea3f1[_0xb6a0('0xf')](0x1f4)['json'](_0xd6e536);});};exports[_0xb6a0('0x22')]=function(_0x5d8caf,_0x25ed03){var _0x261ed7=fs[_0xb6a0('0x23')](path[_0xb6a0('0x24')](config[_0xb6a0('0xa')],_0xb6a0('0x25'),'migrations'));var _0x5db09f=[];for(var _0x31ce9a=0x0;_0x31ce9a<_0x261ed7[_0xb6a0('0x26')];_0x31ce9a++){var _0x1fc80b=_0x261ed7[_0x31ce9a][_0xb6a0('0x27')](_0xb6a0('0x28'),'');if(compareVersions(module['exports']['version'],_0x1fc80b)===-0x1){_0x5db09f[_0xb6a0('0x29')](_0x1fc80b);}}if(_0x5db09f[_0xb6a0('0x26')]){var _0x2faba2=_0x5db09f[_0xb6a0('0x2a')](compareVersions);var _0x5a6a37=new Umzug({'storage':'sequelize','storageOptions':{'model':db[_0xb6a0('0x2b')],'modelName':_0xb6a0('0x2b'),'columnName':_0xb6a0('0x2')},'migrations':{'params':[db[_0xb6a0('0x2c')][_0xb6a0('0x2d')](),db['sequelize']['constructor'],function(){throw new Error(_0xb6a0('0x2e'));}],'path':path[_0xb6a0('0x24')](config[_0xb6a0('0xa')],_0xb6a0('0x25'),_0xb6a0('0x22')),'pattern':/\.js$/}});_0x5a6a37['up']({'migrations':_[_0xb6a0('0x2f')](_0x2faba2,function(_0x20436f){return _0x20436f+'.js';})})[_0xb6a0('0x1e')](function(){return _0x25ed03[_0xb6a0('0xf')](0xc8)[_0xb6a0('0x10')]({'output':'Database\x20migrated\x20successfully\x20from\x20version\x20'+module[_0xb6a0('0xc')][_0xb6a0('0x2')]+'\x20to\x20'+_[_0xb6a0('0x30')](_0x2faba2),'migrations':_[_0xb6a0('0x24')](_0x2faba2)});})[_0xb6a0('0x21')](function(_0x3aec7c){if(_0x3aec7c instanceof db[_0xb6a0('0x2c')][_0xb6a0('0x31')]){return _0x25ed03['status'](0xc8)[_0xb6a0('0x10')]({'output':_0xb6a0('0x32')});}else{return _0x25ed03[_0xb6a0('0xf')](0x1f4)['json'](_0x3aec7c);}});}else{return _0x25ed03['status'](0xc8)[_0xb6a0('0x10')]({'output':_0xb6a0('0x32')});}};