c42c1d622029a5358057c214e1cb94c4a9eec32a
[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 _0x3bb8=['apps','findIndex','name','motion2','NODE_PATH','string','pathExists','then','readJSON','info','Updating\x20app.json','writeJSON','resolve','fs-extra','../config/environment','root','server/app.json','legacy-libs'];(function(_0x58b2d1,_0x4db546){var _0x37744c=function(_0x51c41d){while(--_0x51c41d){_0x58b2d1['push'](_0x58b2d1['shift']());}};_0x37744c(++_0x4db546);}(_0x3bb8,0x8b));var _0x83bb=function(_0x5c585d,_0x69819f){_0x5c585d=_0x5c585d-0x0;var _0x3fdd3b=_0x3bb8[_0x5c585d];return _0x3fdd3b;};var fs=require(_0x83bb('0x0'));var path=require('path');var config=require(_0x83bb('0x1'));var root=config[_0x83bb('0x2')];var APP_JSON_PATH=path['resolve'](root,_0x83bb('0x3'));var NODEPATH=path['resolve'](root,_0x83bb('0x4'));function setLegacyLibsNodeEnvPath(_0x32723e){let _0x207496=![];if(Array['isArray'](_0x32723e['apps'])){var _0x626132=_0x32723e[_0x83bb('0x5')][_0x83bb('0x6')](function(_0x18529f){return _0x18529f[_0x83bb('0x7')]===_0x83bb('0x8');});if(_0x626132>-0x1){var _0x132d16=_0x32723e[_0x83bb('0x5')][_0x626132];if(typeof _0x132d16['env'][_0x83bb('0x9')]!==_0x83bb('0xa')){_0x132d16['env'][_0x83bb('0x9')]=NODEPATH;_0x207496=!![];}}return{'appConfig':_0x32723e,'updated':_0x207496};}}function updateAppConfig(_0x38622f){return fs[_0x83bb('0xb')](APP_JSON_PATH)[_0x83bb('0xc')](function(_0x14b6f6){if(_0x14b6f6){return fs[_0x83bb('0xd')](APP_JSON_PATH)[_0x83bb('0xc')](function(_0x1d99fb){var _0x4c8ae5=setLegacyLibsNodeEnvPath(_0x1d99fb);if(_0x4c8ae5['updated']){_0x38622f[_0x83bb('0xe')](_0x83bb('0xf'));return fs[_0x83bb('0x10')](APP_JSON_PATH,_0x1d99fb,{'spaces':0x2});}else{return Promise[_0x83bb('0x11')]();}});}else{return Promise['resolve']();}});}module['exports']=updateAppConfig;