Built motion from commit d1eab355.|2.6.28
[motion2.git] / server / utils / update-app-config.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 _0xbac4=['exports','fs-extra','../config/environment','root','resolve','apps','findIndex','name','motion2','env','NODE_PATH','pathExists','readJSON','then','updated','info','Updating\x20app.json','writeJSON'];(function(_0x465a0c,_0x19d4d5){var _0x1e202e=function(_0x27bd8a){while(--_0x27bd8a){_0x465a0c['push'](_0x465a0c['shift']());}};_0x1e202e(++_0x19d4d5);}(_0xbac4,0x1b1));var _0x4bac=function(_0x38ffe6,_0x3d4629){_0x38ffe6=_0x38ffe6-0x0;var _0x3a2362=_0xbac4[_0x38ffe6];return _0x3a2362;};var fs=require(_0x4bac('0x0'));var path=require('path');var config=require(_0x4bac('0x1'));var root=config[_0x4bac('0x2')];var APP_JSON_PATH=path[_0x4bac('0x3')](root,'server/app.json');var NODEPATH=path[_0x4bac('0x3')](root,'legacy-libs');function setLegacyLibsNodeEnvPath(_0x48aa52){let _0x2d4f4d=![];if(Array['isArray'](_0x48aa52[_0x4bac('0x4')])){var _0x158f1c=_0x48aa52['apps'][_0x4bac('0x5')](function(_0x36835e){return _0x36835e[_0x4bac('0x6')]===_0x4bac('0x7');});if(_0x158f1c>-0x1){var _0x2905f4=_0x48aa52[_0x4bac('0x4')][_0x158f1c];if(typeof _0x2905f4[_0x4bac('0x8')][_0x4bac('0x9')]!=='string'){_0x2905f4[_0x4bac('0x8')][_0x4bac('0x9')]=NODEPATH;_0x2d4f4d=!![];}}return{'appConfig':_0x48aa52,'updated':_0x2d4f4d};}}function updateAppConfig(_0x5a3849){return fs[_0x4bac('0xa')](APP_JSON_PATH)['then'](function(_0x350be6){if(_0x350be6){return fs[_0x4bac('0xb')](APP_JSON_PATH)[_0x4bac('0xc')](function(_0xed1b4b){var _0xe4d041=setLegacyLibsNodeEnvPath(_0xed1b4b);if(_0xe4d041[_0x4bac('0xd')]){_0x5a3849[_0x4bac('0xe')](_0x4bac('0xf'));return fs[_0x4bac('0x10')](APP_JSON_PATH,_0xed1b4b,{'spaces':0x2});}else{return Promise['resolve']();}});}else{return Promise[_0x4bac('0x3')]();}});}module[_0x4bac('0x11')]=updateAppConfig;