Built motion from commit (unavailable).|2.5.23
[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 _0x508a=['pm2\x20restart\x20motion\x20%s','Your\x20system\x20has\x20been\x20restart\x20successfully','catch','migrations','readdirSync','join','server','length','sequelize','Migration','constructor','Migration\x20tried\x20to\x20use\x20old\x20style\x20\x22done\x22\x20callback.\x20Please\x20upgrade\x20to\x20\x22umzug\x22\x20and\x20return\x20a\x20promise\x20instead.','map','.js','Database\x20migrated\x20successfully\x20from\x20version\x20','\x20to\x20','UniqueConstraintError','Database\x20already\x20up-to-date','umzug','lodash','pkginfo','version','compare-versions','child_process','../../mysqldb','../../config/environment','../../config/pm2','update','simple-git','root','exports','query','latest','fetch','tags','2.0.0','status','master','error','info','git\x20fetch','json','reset','--hard','FETCH_HEAD','git\x20reset\x20--hard\x20FETCH_HEAD','git\x20reset\x20--hard','pull','restart','motion2','then'];(function(_0xa722b1,_0x215d96){var _0x367a21=function(_0x5e740d){while(--_0x5e740d){_0xa722b1['push'](_0xa722b1['shift']());}};_0x367a21(++_0x215d96);}(_0x508a,0x1aa));var _0xa508=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x508a[_0x3dd15e];return _0x231fd0;};'use strict';var Umzug=require(_0xa508('0x0'));var path=require('path');var fs=require('fs');var _=require(_0xa508('0x1'));var pkginfo=require(_0xa508('0x2'))(module,_0xa508('0x3'));var compareVersions=require(_0xa508('0x4'));var exec=require(_0xa508('0x5'))['exec'];var db=require(_0xa508('0x6'))['db'];var config=require(_0xa508('0x7'));var pm2=require(_0xa508('0x8'));var logger=require('../../config/logger')(_0xa508('0x9'));var git=require(_0xa508('0xa'))(config[_0xa508('0xb')]);exports['index']=function(_0x284fb1,_0x6f201c){var _0x4f6c23={'current':module[_0xa508('0xc')][_0xa508('0x3')],'phonebar':0x2};if(_0x284fb1['query']&&_0x284fb1[_0xa508('0xd')][_0xa508('0xe')]){return git[_0xa508('0xf')]()[_0xa508('0x10')](function(_0x2db254,_0x53e069){_0x4f6c23[_0xa508('0xe')]=(_0x2db254?module[_0xa508('0xc')]['version']:_0x53e069[_0xa508('0xe')])||_0xa508('0x11');return _0x6f201c[_0xa508('0x12')](0xc8)['json'](_0x4f6c23);});}else{return _0x6f201c[_0xa508('0x12')](0xc8)['json'](_0x4f6c23);}};exports[_0xa508('0xf')]=function(_0x673f18,_0x3085b2){return git[_0xa508('0xf')](['origin',_0xa508('0x13')],function(_0x45a0bc){if(_0x45a0bc){logger[_0xa508('0x14')](_0x45a0bc);return _0x3085b2[_0xa508('0x12')](0x1f4)['json'](_0x45a0bc);}logger[_0xa508('0x15')](_0xa508('0x16'));return _0x3085b2[_0xa508('0x12')](0xc8)[_0xa508('0x17')]({'output':'git\x20fetch\x20origin\x20master'});});};exports[_0xa508('0x18')]=function(_0x27d102,_0x5e29a8){return git['reset']([_0xa508('0x19'),_0xa508('0x1a')],function(_0x28f8bf){if(_0x28f8bf){logger[_0xa508('0x14')](_0x28f8bf);return _0x5e29a8[_0xa508('0x12')](0x1f4)[_0xa508('0x17')](_0x28f8bf);}logger[_0xa508('0x15')](_0xa508('0x1b'));return _0x5e29a8['status'](0xc8)[_0xa508('0x17')]({'output':_0xa508('0x1c')});});};exports[_0xa508('0x1d')]=function(_0x45b284,_0x464a76){exec('npm\x20install\x20--production',function(_0x274804,_0x5712ad,_0xf4f3f7){logger[_0xa508('0x15')](_0x5712ad);logger['info'](_0xf4f3f7);if(_0x274804){logger[_0xa508('0x14')](_0x274804);return _0x464a76[_0xa508('0x12')](0x1f4)[_0xa508('0x17')](_0x274804);}return _0x464a76[_0xa508('0x12')](0xc8)['json']({'output':_0x5712ad});});};exports['restart']=function(_0x5deb96,_0x41d751){return pm2[_0xa508('0x1e')](_0xa508('0x1f'))[_0xa508('0x20')](function(_0x276d0d){logger[_0xa508('0x15')](_0xa508('0x21'),_0x276d0d);return _0x41d751['status'](0xc8)['json']({'output':_0xa508('0x22')});})[_0xa508('0x23')](function(_0x47d93b){logger[_0xa508('0x14')](_0x47d93b);return _0x41d751['status'](0x1f4)[_0xa508('0x17')](_0x47d93b);});};exports[_0xa508('0x24')]=function(_0x528ae9,_0x370518){var _0x2ca53f=fs[_0xa508('0x25')](path[_0xa508('0x26')](config['root'],_0xa508('0x27'),_0xa508('0x24')));var _0x3eb26c=[];for(var _0x5d971d=0x0;_0x5d971d<_0x2ca53f[_0xa508('0x28')];_0x5d971d++){var _0x391ba7=_0x2ca53f[_0x5d971d]['replace']('.js','');if(compareVersions(module[_0xa508('0xc')]['version'],_0x391ba7)===-0x1){_0x3eb26c['push'](_0x391ba7);}}if(_0x3eb26c[_0xa508('0x28')]){var _0x5d40ad=_0x3eb26c['sort'](compareVersions);var _0xb542d7=new Umzug({'storage':_0xa508('0x29'),'storageOptions':{'model':db['Migration'],'modelName':_0xa508('0x2a'),'columnName':_0xa508('0x3')},'migrations':{'params':[db[_0xa508('0x29')]['getQueryInterface'](),db['sequelize'][_0xa508('0x2b')],function(){throw new Error(_0xa508('0x2c'));}],'path':path[_0xa508('0x26')](config[_0xa508('0xb')],_0xa508('0x27'),_0xa508('0x24')),'pattern':/\.js$/}});_0xb542d7['up']({'migrations':_[_0xa508('0x2d')](_0x5d40ad,function(_0x772e7b){return _0x772e7b+_0xa508('0x2e');})})[_0xa508('0x20')](function(){return _0x370518[_0xa508('0x12')](0xc8)['json']({'output':_0xa508('0x2f')+module[_0xa508('0xc')][_0xa508('0x3')]+_0xa508('0x30')+_['last'](_0x5d40ad),'migrations':_[_0xa508('0x26')](_0x5d40ad)});})[_0xa508('0x23')](function(_0x19019b){if(_0x19019b instanceof db['sequelize'][_0xa508('0x31')]){return _0x370518[_0xa508('0x12')](0xc8)[_0xa508('0x17')]({'output':'Database\x20already\x20up-to-date'});}else{return _0x370518['status'](0x1f4)[_0xa508('0x17')](_0x19019b);}});}else{return _0x370518[_0xa508('0x12')](0xc8)[_0xa508('0x17')]({'output':_0xa508('0x32')});}};