Built motion from commit e02f907f.|2.6.14
[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 _0x9451=['fs-extra','path','../config/environment','root','resolve','server/app.json','legacy-libs','isArray','apps','findIndex','name','motion2','env','NODE_PATH','string','pathExists','then','readJSON','updated','Updating\x20app.json','writeJSON','exports'];(function(_0x410dbe,_0x3cf158){var _0x20dfb1=function(_0x2e8658){while(--_0x2e8658){_0x410dbe['push'](_0x410dbe['shift']());}};_0x20dfb1(++_0x3cf158);}(_0x9451,0xdc));var _0x1945=function(_0xb86618,_0x379810){_0xb86618=_0xb86618-0x0;var _0x446e27=_0x9451[_0xb86618];return _0x446e27;};var fs=require(_0x1945('0x0'));var path=require(_0x1945('0x1'));var config=require(_0x1945('0x2'));var root=config[_0x1945('0x3')];var APP_JSON_PATH=path[_0x1945('0x4')](root,_0x1945('0x5'));var NODEPATH=path['resolve'](root,_0x1945('0x6'));function setLegacyLibsNodeEnvPath(_0xb05cd9){let _0x2b3887=![];if(Array[_0x1945('0x7')](_0xb05cd9['apps'])){var _0xed681a=_0xb05cd9[_0x1945('0x8')][_0x1945('0x9')](function(_0x4d64ce){return _0x4d64ce[_0x1945('0xa')]===_0x1945('0xb');});if(_0xed681a>-0x1){var _0x1e02ee=_0xb05cd9[_0x1945('0x8')][_0xed681a];if(typeof _0x1e02ee[_0x1945('0xc')][_0x1945('0xd')]!==_0x1945('0xe')){_0x1e02ee['env'][_0x1945('0xd')]=NODEPATH;_0x2b3887=!![];}}return{'appConfig':_0xb05cd9,'updated':_0x2b3887};}}function updateAppConfig(_0x2d4855){return fs[_0x1945('0xf')](APP_JSON_PATH)[_0x1945('0x10')](function(_0x2dc884){if(_0x2dc884){return fs[_0x1945('0x11')](APP_JSON_PATH)[_0x1945('0x10')](function(_0x1d0537){var _0x515e14=setLegacyLibsNodeEnvPath(_0x1d0537);if(_0x515e14[_0x1945('0x12')]){_0x2d4855['info'](_0x1945('0x13'));return fs[_0x1945('0x14')](APP_JSON_PATH,_0x1d0537,{'spaces':0x2});}else{return Promise['resolve']();}});}else{return Promise[_0x1945('0x4')]();}});}module[_0x1945('0x15')]=updateAppConfig;