Built motion from commit ff78e754.|2.6.29
[motion2.git] / server / api / version / version.controller.js
index cef652e..bb84d01 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1f0b=['umzug','path','pkginfo','version','../../config/environment','../../config/pm2','update','simple-git','root','exports','query','latest','fetch','tags','status','json','info','git\x20fetch\x20origin\x20master','reset','--hard','FETCH_HEAD','git\x20reset\x20--hard\x20FETCH_HEAD','git\x20reset\x20--hard','npm\x20install\x20--production','error','restart','motion2','then','pm2\x20restart\x20motion\x20%s','Your\x20system\x20has\x20been\x20restart\x20successfully','catch','migrations','readdirSync','server','replace','.js','push','sort','sequelize','Migration','getQueryInterface','constructor','Migration\x20tried\x20to\x20use\x20old\x20style\x20\x22done\x22\x20callback.\x20Please\x20upgrade\x20to\x20\x22umzug\x22\x20and\x20return\x20a\x20promise\x20instead.','join','Database\x20migrated\x20successfully\x20from\x20version\x20','\x20to\x20','UniqueConstraintError','Database\x20already\x20up-to-date'];(function(_0x4ceb13,_0x5e70f7){var _0x11f6e7=function(_0x1ffe46){while(--_0x1ffe46){_0x4ceb13['push'](_0x4ceb13['shift']());}};_0x11f6e7(++_0x5e70f7);}(_0x1f0b,0xc0));var _0xb1f0=function(_0x13c4eb,_0x5d218c){_0x13c4eb=_0x13c4eb-0x0;var _0x421546=_0x1f0b[_0x13c4eb];return _0x421546;};'use strict';var Umzug=require(_0xb1f0('0x0'));var path=require(_0xb1f0('0x1'));var fs=require('fs');var _=require('lodash');var pkginfo=require(_0xb1f0('0x2'))(module,_0xb1f0('0x3'));var compareVersions=require('compare-versions');var exec=require('child_process')['exec'];var db=require('../../mysqldb')['db'];var config=require(_0xb1f0('0x4'));var pm2=require(_0xb1f0('0x5'));var logger=require('../../config/logger')(_0xb1f0('0x6'));var git=require(_0xb1f0('0x7'))(config[_0xb1f0('0x8')]);exports['index']=function(_0x10b139,_0x4a1b15){var _0x58d0a6={'current':module[_0xb1f0('0x9')][_0xb1f0('0x3')],'phonebar':0x2};if(_0x10b139[_0xb1f0('0xa')]&&_0x10b139['query'][_0xb1f0('0xb')]){return git[_0xb1f0('0xc')]()[_0xb1f0('0xd')](function(_0x40417e,_0x585fa6){_0x58d0a6['latest']=(_0x40417e?module[_0xb1f0('0x9')]['version']:_0x585fa6[_0xb1f0('0xb')])||'2.0.0';return _0x4a1b15[_0xb1f0('0xe')](0xc8)[_0xb1f0('0xf')](_0x58d0a6);});}else{return _0x4a1b15[_0xb1f0('0xe')](0xc8)[_0xb1f0('0xf')](_0x58d0a6);}};exports[_0xb1f0('0xc')]=function(_0xccedb5,_0x18b93d){return git['fetch'](['origin','master'],function(_0x13f281){if(_0x13f281){logger['error'](_0x13f281);return _0x18b93d[_0xb1f0('0xe')](0x1f4)[_0xb1f0('0xf')](_0x13f281);}logger[_0xb1f0('0x10')]('git\x20fetch');return _0x18b93d[_0xb1f0('0xe')](0xc8)['json']({'output':_0xb1f0('0x11')});});};exports[_0xb1f0('0x12')]=function(_0x477e68,_0x39c094){return git[_0xb1f0('0x12')]([_0xb1f0('0x13'),_0xb1f0('0x14')],function(_0x1496ab){if(_0x1496ab){logger['error'](_0x1496ab);return _0x39c094[_0xb1f0('0xe')](0x1f4)['json'](_0x1496ab);}logger['info'](_0xb1f0('0x15'));return _0x39c094[_0xb1f0('0xe')](0xc8)[_0xb1f0('0xf')]({'output':_0xb1f0('0x16')});});};exports['pull']=function(_0x4bc343,_0x81d1fc){exec(_0xb1f0('0x17'),function(_0x45d4b0,_0x5b6f9f,_0x54ac96){logger['info'](_0x5b6f9f);logger[_0xb1f0('0x10')](_0x54ac96);if(_0x45d4b0){logger[_0xb1f0('0x18')](_0x45d4b0);return _0x81d1fc[_0xb1f0('0xe')](0x1f4)[_0xb1f0('0xf')](_0x45d4b0);}return _0x81d1fc[_0xb1f0('0xe')](0xc8)[_0xb1f0('0xf')]({'output':_0x5b6f9f});});};exports['restart']=function(_0x14be71,_0x430d39){return pm2[_0xb1f0('0x19')](_0xb1f0('0x1a'))[_0xb1f0('0x1b')](function(_0x4ee1bf){logger[_0xb1f0('0x10')](_0xb1f0('0x1c'),_0x4ee1bf);return _0x430d39['status'](0xc8)['json']({'output':_0xb1f0('0x1d')});})[_0xb1f0('0x1e')](function(_0x772211){logger[_0xb1f0('0x18')](_0x772211);return _0x430d39[_0xb1f0('0xe')](0x1f4)[_0xb1f0('0xf')](_0x772211);});};exports[_0xb1f0('0x1f')]=function(_0x3ba2dd,_0x1d8ce6){var _0x1ef1cb=fs[_0xb1f0('0x20')](path['join'](config[_0xb1f0('0x8')],_0xb1f0('0x21'),_0xb1f0('0x1f')));var _0x36c1ed=[];for(var _0x22cbbc=0x0;_0x22cbbc<_0x1ef1cb['length'];_0x22cbbc++){var _0x13d553=_0x1ef1cb[_0x22cbbc][_0xb1f0('0x22')](_0xb1f0('0x23'),'');if(compareVersions(module[_0xb1f0('0x9')][_0xb1f0('0x3')],_0x13d553)===-0x1){_0x36c1ed[_0xb1f0('0x24')](_0x13d553);}}if(_0x36c1ed['length']){var _0xe14521=_0x36c1ed[_0xb1f0('0x25')](compareVersions);var _0xfde398=new Umzug({'storage':_0xb1f0('0x26'),'storageOptions':{'model':db['Migration'],'modelName':_0xb1f0('0x27'),'columnName':_0xb1f0('0x3')},'migrations':{'params':[db[_0xb1f0('0x26')][_0xb1f0('0x28')](),db[_0xb1f0('0x26')][_0xb1f0('0x29')],function(){throw new Error(_0xb1f0('0x2a'));}],'path':path[_0xb1f0('0x2b')](config[_0xb1f0('0x8')],'server','migrations'),'pattern':/\.js$/}});_0xfde398['up']({'migrations':_['map'](_0xe14521,function(_0x2baa93){return _0x2baa93+_0xb1f0('0x23');})})[_0xb1f0('0x1b')](function(){return _0x1d8ce6[_0xb1f0('0xe')](0xc8)['json']({'output':_0xb1f0('0x2c')+module[_0xb1f0('0x9')][_0xb1f0('0x3')]+_0xb1f0('0x2d')+_['last'](_0xe14521),'migrations':_['join'](_0xe14521)});})[_0xb1f0('0x1e')](function(_0x506ab0){if(_0x506ab0 instanceof db['sequelize'][_0xb1f0('0x2e')]){return _0x1d8ce6['status'](0xc8)[_0xb1f0('0xf')]({'output':_0xb1f0('0x2f')});}else{return _0x1d8ce6[_0xb1f0('0xe')](0x1f4)[_0xb1f0('0xf')](_0x506ab0);}});}else{return _0x1d8ce6[_0xb1f0('0xe')](0xc8)[_0xb1f0('0xf')]({'output':_0xb1f0('0x2f')});}};
\ No newline at end of file
+var _0x316c=['version','compare-versions','exec','../../mysqldb','../../config/pm2','../../config/logger','update','index','exports','query','latest','tags','2.0.0','status','json','fetch','origin','master','error','git\x20fetch','git\x20fetch\x20origin\x20master','reset','--hard','FETCH_HEAD','info','git\x20reset\x20--hard\x20FETCH_HEAD','git\x20reset\x20--hard','pull','restart','motion2','then','Your\x20system\x20has\x20been\x20restart\x20successfully','catch','migrations','root','server','length','replace','.js','push','sort','sequelize','Migration','getQueryInterface','Migration\x20tried\x20to\x20use\x20old\x20style\x20\x22done\x22\x20callback.\x20Please\x20upgrade\x20to\x20\x22umzug\x22\x20and\x20return\x20a\x20promise\x20instead.','join','Database\x20migrated\x20successfully\x20from\x20version\x20','\x20to\x20','last','UniqueConstraintError','Database\x20already\x20up-to-date','path'];(function(_0x484286,_0x1d1adc){var _0x2f11b2=function(_0x2f7b95){while(--_0x2f7b95){_0x484286['push'](_0x484286['shift']());}};_0x2f11b2(++_0x1d1adc);}(_0x316c,0x1d3));var _0xc316=function(_0x2f4c73,_0x15ebc5){_0x2f4c73=_0x2f4c73-0x0;var _0x53fad6=_0x316c[_0x2f4c73];return _0x53fad6;};'use strict';var Umzug=require('umzug');var path=require(_0xc316('0x0'));var fs=require('fs');var _=require('lodash');var pkginfo=require('pkginfo')(module,_0xc316('0x1'));var compareVersions=require(_0xc316('0x2'));var exec=require('child_process')[_0xc316('0x3')];var db=require(_0xc316('0x4'))['db'];var config=require('../../config/environment');var pm2=require(_0xc316('0x5'));var logger=require(_0xc316('0x6'))(_0xc316('0x7'));var git=require('simple-git')(config['root']);exports[_0xc316('0x8')]=function(_0x21a0ed,_0x207bbe){var _0x309291={'current':module[_0xc316('0x9')][_0xc316('0x1')],'phonebar':0x2};if(_0x21a0ed[_0xc316('0xa')]&&_0x21a0ed['query'][_0xc316('0xb')]){return git['fetch']()[_0xc316('0xc')](function(_0x161dde,_0x3f00b9){_0x309291['latest']=(_0x161dde?module[_0xc316('0x9')]['version']:_0x3f00b9[_0xc316('0xb')])||_0xc316('0xd');return _0x207bbe[_0xc316('0xe')](0xc8)[_0xc316('0xf')](_0x309291);});}else{return _0x207bbe[_0xc316('0xe')](0xc8)['json'](_0x309291);}};exports['fetch']=function(_0x952c8a,_0x55ad07){return git[_0xc316('0x10')]([_0xc316('0x11'),_0xc316('0x12')],function(_0x5c8b65){if(_0x5c8b65){logger[_0xc316('0x13')](_0x5c8b65);return _0x55ad07[_0xc316('0xe')](0x1f4)[_0xc316('0xf')](_0x5c8b65);}logger['info'](_0xc316('0x14'));return _0x55ad07[_0xc316('0xe')](0xc8)[_0xc316('0xf')]({'output':_0xc316('0x15')});});};exports[_0xc316('0x16')]=function(_0x529154,_0x562a8d){return git[_0xc316('0x16')]([_0xc316('0x17'),_0xc316('0x18')],function(_0x3e4bee){if(_0x3e4bee){logger[_0xc316('0x13')](_0x3e4bee);return _0x562a8d[_0xc316('0xe')](0x1f4)['json'](_0x3e4bee);}logger[_0xc316('0x19')](_0xc316('0x1a'));return _0x562a8d[_0xc316('0xe')](0xc8)[_0xc316('0xf')]({'output':_0xc316('0x1b')});});};exports[_0xc316('0x1c')]=function(_0x15e354,_0x2b9671){exec('npm\x20install\x20--production',function(_0x1b3097,_0x1f4814,_0x2294b3){logger[_0xc316('0x19')](_0x1f4814);logger[_0xc316('0x19')](_0x2294b3);if(_0x1b3097){logger[_0xc316('0x13')](_0x1b3097);return _0x2b9671[_0xc316('0xe')](0x1f4)['json'](_0x1b3097);}return _0x2b9671[_0xc316('0xe')](0xc8)['json']({'output':_0x1f4814});});};exports[_0xc316('0x1d')]=function(_0x2b2a99,_0x5828bd){return pm2['restart'](_0xc316('0x1e'))[_0xc316('0x1f')](function(_0x5d55e8){logger['info']('pm2\x20restart\x20motion\x20%s',_0x5d55e8);return _0x5828bd[_0xc316('0xe')](0xc8)[_0xc316('0xf')]({'output':_0xc316('0x20')});})[_0xc316('0x21')](function(_0xdf88d6){logger['error'](_0xdf88d6);return _0x5828bd['status'](0x1f4)[_0xc316('0xf')](_0xdf88d6);});};exports[_0xc316('0x22')]=function(_0x3dadfb,_0x1e2e5e){var _0x5ad76a=fs['readdirSync'](path['join'](config[_0xc316('0x23')],_0xc316('0x24'),_0xc316('0x22')));var _0x4df5c0=[];for(var _0x45de77=0x0;_0x45de77<_0x5ad76a[_0xc316('0x25')];_0x45de77++){var _0x4b3895=_0x5ad76a[_0x45de77][_0xc316('0x26')](_0xc316('0x27'),'');if(compareVersions(module[_0xc316('0x9')]['version'],_0x4b3895)===-0x1){_0x4df5c0[_0xc316('0x28')](_0x4b3895);}}if(_0x4df5c0[_0xc316('0x25')]){var _0x726a19=_0x4df5c0[_0xc316('0x29')](compareVersions);var _0x415963=new Umzug({'storage':_0xc316('0x2a'),'storageOptions':{'model':db[_0xc316('0x2b')],'modelName':'Migration','columnName':_0xc316('0x1')},'migrations':{'params':[db[_0xc316('0x2a')][_0xc316('0x2c')](),db[_0xc316('0x2a')]['constructor'],function(){throw new Error(_0xc316('0x2d'));}],'path':path[_0xc316('0x2e')](config[_0xc316('0x23')],'server','migrations'),'pattern':/\.js$/}});_0x415963['up']({'migrations':_['map'](_0x726a19,function(_0x429e37){return _0x429e37+'.js';})})[_0xc316('0x1f')](function(){return _0x1e2e5e[_0xc316('0xe')](0xc8)[_0xc316('0xf')]({'output':_0xc316('0x2f')+module[_0xc316('0x9')][_0xc316('0x1')]+_0xc316('0x30')+_[_0xc316('0x31')](_0x726a19),'migrations':_[_0xc316('0x2e')](_0x726a19)});})[_0xc316('0x21')](function(_0x894a6f){if(_0x894a6f instanceof db[_0xc316('0x2a')][_0xc316('0x32')]){return _0x1e2e5e[_0xc316('0xe')](0xc8)[_0xc316('0xf')]({'output':_0xc316('0x33')});}else{return _0x1e2e5e[_0xc316('0xe')](0x1f4)[_0xc316('0xf')](_0x894a6f);}});}else{return _0x1e2e5e[_0xc316('0xe')](0xc8)[_0xc316('0xf')]({'output':_0xc316('0x33')});}};
\ No newline at end of file