2e18f94ae08a64861b0936b9ed7f3539799ce4ef
[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 _0xa9d0=['../config/environment','root','isArray','apps','findIndex','motion2','env','NODE_PATH','string','pathExists','then','readJSON','Updating\x20app.json','writeJSON','resolve','exports','fs-extra','path'];(function(_0x414806,_0x12a8c2){var _0x14e039=function(_0x40fb9c){while(--_0x40fb9c){_0x414806['push'](_0x414806['shift']());}};_0x14e039(++_0x12a8c2);}(_0xa9d0,0x178));var _0x0a9d=function(_0x293a1b,_0x4fbaac){_0x293a1b=_0x293a1b-0x0;var _0x4539b7=_0xa9d0[_0x293a1b];return _0x4539b7;};var fs=require(_0x0a9d('0x0'));var path=require(_0x0a9d('0x1'));var config=require(_0x0a9d('0x2'));var root=config[_0x0a9d('0x3')];var APP_JSON_PATH=path['resolve'](root,'server/app.json');var NODEPATH=path['resolve'](root,'legacy-libs');function setLegacyLibsNodeEnvPath(_0x444e02){let _0x499b11=![];if(Array[_0x0a9d('0x4')](_0x444e02['apps'])){var _0x40255a=_0x444e02[_0x0a9d('0x5')][_0x0a9d('0x6')](function(_0x2d9b95){return _0x2d9b95['name']===_0x0a9d('0x7');});if(_0x40255a>-0x1){var _0x23f8f1=_0x444e02['apps'][_0x40255a];if(typeof _0x23f8f1[_0x0a9d('0x8')][_0x0a9d('0x9')]!==_0x0a9d('0xa')){_0x23f8f1['env'][_0x0a9d('0x9')]=NODEPATH;_0x499b11=!![];}}return{'appConfig':_0x444e02,'updated':_0x499b11};}}function updateAppConfig(_0x33ffa0){return fs[_0x0a9d('0xb')](APP_JSON_PATH)[_0x0a9d('0xc')](function(_0x407ae6){if(_0x407ae6){return fs[_0x0a9d('0xd')](APP_JSON_PATH)[_0x0a9d('0xc')](function(_0x6ddf67){var _0x12753f=setLegacyLibsNodeEnvPath(_0x6ddf67);if(_0x12753f['updated']){_0x33ffa0['info'](_0x0a9d('0xe'));return fs[_0x0a9d('0xf')](APP_JSON_PATH,_0x6ddf67,{'spaces':0x2});}else{return Promise['resolve']();}});}else{return Promise[_0x0a9d('0x10')]();}});}module[_0x0a9d('0x11')]=updateAppConfig;