Built motion from commit cb845558.|2.6.34
[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 _0xad67=['fs-extra','path','root','resolve','legacy-libs','apps','name','NODE_PATH','env','then','Updating\x20app.json','writeJSON'];(function(_0x47a12a,_0x70f591){var _0x30cd40=function(_0x46b68f){while(--_0x46b68f){_0x47a12a['push'](_0x47a12a['shift']());}};_0x30cd40(++_0x70f591);}(_0xad67,0x15c));var _0x7ad6=function(_0x16066e,_0x31e151){_0x16066e=_0x16066e-0x0;var _0x52a12e=_0xad67[_0x16066e];return _0x52a12e;};var fs=require(_0x7ad6('0x0'));var path=require(_0x7ad6('0x1'));var config=require('../config/environment');var root=config[_0x7ad6('0x2')];var APP_JSON_PATH=path[_0x7ad6('0x3')](root,'server/app.json');var NODEPATH=path[_0x7ad6('0x3')](root,_0x7ad6('0x4'));function setLegacyLibsNodeEnvPath(_0x5cfaf5){let _0x426cf0=![];if(Array['isArray'](_0x5cfaf5[_0x7ad6('0x5')])){var _0x22ea83=_0x5cfaf5[_0x7ad6('0x5')]['findIndex'](function(_0x255ef5){return _0x255ef5[_0x7ad6('0x6')]==='motion2';});if(_0x22ea83>-0x1){var _0x58ec9f=_0x5cfaf5[_0x7ad6('0x5')][_0x22ea83];if(typeof _0x58ec9f['env'][_0x7ad6('0x7')]!=='string'){_0x58ec9f[_0x7ad6('0x8')][_0x7ad6('0x7')]=NODEPATH;_0x426cf0=!![];}}return{'appConfig':_0x5cfaf5,'updated':_0x426cf0};}}function updateAppConfig(_0x10cb24){return fs['pathExists'](APP_JSON_PATH)[_0x7ad6('0x9')](function(_0x347271){if(_0x347271){return fs['readJSON'](APP_JSON_PATH)[_0x7ad6('0x9')](function(_0x41605e){var _0xc91be7=setLegacyLibsNodeEnvPath(_0x41605e);if(_0xc91be7['updated']){_0x10cb24['info'](_0x7ad6('0xa'));return fs[_0x7ad6('0xb')](APP_JSON_PATH,_0x41605e,{'spaces':0x2});}else{return Promise[_0x7ad6('0x3')]();}});}else{return Promise[_0x7ad6('0x3')]();}});}module['exports']=updateAppConfig;