Built motion from commit c738b9ac.|2.6.25
[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 _0x6200=['../config/environment','root','resolve','server/app.json','legacy-libs','isArray','apps','findIndex','name','motion2','env','string','NODE_PATH','pathExists','readJSON','then','updated','info','Updating\x20app.json','writeJSON','fs-extra','path'];(function(_0x5333d8,_0x4cbe38){var _0x3e8edb=function(_0x26fc36){while(--_0x26fc36){_0x5333d8['push'](_0x5333d8['shift']());}};_0x3e8edb(++_0x4cbe38);}(_0x6200,0x82));var _0x0620=function(_0x1d8170,_0x459855){_0x1d8170=_0x1d8170-0x0;var _0x3ca267=_0x6200[_0x1d8170];return _0x3ca267;};var fs=require(_0x0620('0x0'));var path=require(_0x0620('0x1'));var config=require(_0x0620('0x2'));var root=config[_0x0620('0x3')];var APP_JSON_PATH=path[_0x0620('0x4')](root,_0x0620('0x5'));var NODEPATH=path[_0x0620('0x4')](root,_0x0620('0x6'));function setLegacyLibsNodeEnvPath(_0x7e6563){let _0x1595f7=![];if(Array[_0x0620('0x7')](_0x7e6563['apps'])){var _0x47efa0=_0x7e6563[_0x0620('0x8')][_0x0620('0x9')](function(_0x497b8f){return _0x497b8f[_0x0620('0xa')]===_0x0620('0xb');});if(_0x47efa0>-0x1){var _0x4cf67c=_0x7e6563[_0x0620('0x8')][_0x47efa0];if(typeof _0x4cf67c[_0x0620('0xc')]['NODE_PATH']!==_0x0620('0xd')){_0x4cf67c['env'][_0x0620('0xe')]=NODEPATH;_0x1595f7=!![];}}return{'appConfig':_0x7e6563,'updated':_0x1595f7};}}function updateAppConfig(_0x50706a){return fs[_0x0620('0xf')](APP_JSON_PATH)['then'](function(_0x475267){if(_0x475267){return fs[_0x0620('0x10')](APP_JSON_PATH)[_0x0620('0x11')](function(_0x170026){var _0x28d3ba=setLegacyLibsNodeEnvPath(_0x170026);if(_0x28d3ba[_0x0620('0x12')]){_0x50706a[_0x0620('0x13')](_0x0620('0x14'));return fs[_0x0620('0x15')](APP_JSON_PATH,_0x170026,{'spaces':0x2});}else{return Promise[_0x0620('0x4')]();}});}else{return Promise[_0x0620('0x4')]();}});}module['exports']=updateAppConfig;