69f7774fe66a316208dd011d0eaaadad1c0a54a7
[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 _0xd266=['info','Updating\x20app.json','writeJSON','exports','fs-extra','path','../config/environment','root','resolve','server/app.json','legacy-libs','isArray','apps','motion2','env','NODE_PATH','string','pathExists','then','readJSON'];(function(_0x5b08d3,_0x18ad2a){var _0x2b8446=function(_0xcb02cc){while(--_0xcb02cc){_0x5b08d3['push'](_0x5b08d3['shift']());}};_0x2b8446(++_0x18ad2a);}(_0xd266,0x7c));var _0x6d26=function(_0x36edad,_0x493944){_0x36edad=_0x36edad-0x0;var _0x48f7bf=_0xd266[_0x36edad];return _0x48f7bf;};var fs=require(_0x6d26('0x0'));var path=require(_0x6d26('0x1'));var config=require(_0x6d26('0x2'));var root=config[_0x6d26('0x3')];var APP_JSON_PATH=path[_0x6d26('0x4')](root,_0x6d26('0x5'));var NODEPATH=path[_0x6d26('0x4')](root,_0x6d26('0x6'));function setLegacyLibsNodeEnvPath(_0x45f16a){let _0x879ede=![];if(Array[_0x6d26('0x7')](_0x45f16a[_0x6d26('0x8')])){var _0x2a3445=_0x45f16a['apps']['findIndex'](function(_0x46b58a){return _0x46b58a['name']===_0x6d26('0x9');});if(_0x2a3445>-0x1){var _0x10bc9b=_0x45f16a[_0x6d26('0x8')][_0x2a3445];if(typeof _0x10bc9b[_0x6d26('0xa')][_0x6d26('0xb')]!==_0x6d26('0xc')){_0x10bc9b[_0x6d26('0xa')]['NODE_PATH']=NODEPATH;_0x879ede=!![];}}return{'appConfig':_0x45f16a,'updated':_0x879ede};}}function updateAppConfig(_0x4159f1){return fs[_0x6d26('0xd')](APP_JSON_PATH)[_0x6d26('0xe')](function(_0x4cc9bf){if(_0x4cc9bf){return fs[_0x6d26('0xf')](APP_JSON_PATH)['then'](function(_0x3fe363){var _0x4ef74b=setLegacyLibsNodeEnvPath(_0x3fe363);if(_0x4ef74b['updated']){_0x4159f1[_0x6d26('0x10')](_0x6d26('0x11'));return fs[_0x6d26('0x12')](APP_JSON_PATH,_0x3fe363,{'spaces':0x2});}else{return Promise[_0x6d26('0x4')]();}});}else{return Promise[_0x6d26('0x4')]();}});}module[_0x6d26('0x13')]=updateAppConfig;