Built motion from commit 06eb8eb0.|2.6.31
[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 _0xe911=['writeJSON','fs-extra','path','../config/environment','resolve','legacy-libs','name','apps','env','NODE_PATH','string','pathExists','then','readJSON','updated','info','Updating\x20app.json'];(function(_0x3a36aa,_0x34ec23){var _0x54501a=function(_0x738ca6){while(--_0x738ca6){_0x3a36aa['push'](_0x3a36aa['shift']());}};_0x54501a(++_0x34ec23);}(_0xe911,0x166));var _0x1e91=function(_0x101a91,_0x1b77e8){_0x101a91=_0x101a91-0x0;var _0x3dc2eb=_0xe911[_0x101a91];return _0x3dc2eb;};var fs=require(_0x1e91('0x0'));var path=require(_0x1e91('0x1'));var config=require(_0x1e91('0x2'));var root=config['root'];var APP_JSON_PATH=path[_0x1e91('0x3')](root,'server/app.json');var NODEPATH=path[_0x1e91('0x3')](root,_0x1e91('0x4'));function setLegacyLibsNodeEnvPath(_0x4f2a2c){let _0x5cb2f3=![];if(Array['isArray'](_0x4f2a2c['apps'])){var _0x3e42f9=_0x4f2a2c['apps']['findIndex'](function(_0x5f432e){return _0x5f432e[_0x1e91('0x5')]==='motion2';});if(_0x3e42f9>-0x1){var _0x15ad90=_0x4f2a2c[_0x1e91('0x6')][_0x3e42f9];if(typeof _0x15ad90[_0x1e91('0x7')][_0x1e91('0x8')]!==_0x1e91('0x9')){_0x15ad90['env'][_0x1e91('0x8')]=NODEPATH;_0x5cb2f3=!![];}}return{'appConfig':_0x4f2a2c,'updated':_0x5cb2f3};}}function updateAppConfig(_0x4f9d32){return fs[_0x1e91('0xa')](APP_JSON_PATH)[_0x1e91('0xb')](function(_0x12c2b5){if(_0x12c2b5){return fs[_0x1e91('0xc')](APP_JSON_PATH)[_0x1e91('0xb')](function(_0x27c6a7){var _0x185850=setLegacyLibsNodeEnvPath(_0x27c6a7);if(_0x185850[_0x1e91('0xd')]){_0x4f9d32[_0x1e91('0xe')](_0x1e91('0xf'));return fs[_0x1e91('0x10')](APP_JSON_PATH,_0x27c6a7,{'spaces':0x2});}else{return Promise[_0x1e91('0x3')]();}});}else{return Promise[_0x1e91('0x3')]();}});}module['exports']=updateAppConfig;