Built motion from commit efa66e19.|2.6.22
[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 _0xbd2a=['env','NODE_PATH','string','then','readJSON','info','writeJSON','exports','fs-extra','root','resolve','apps','findIndex','name','motion2'];(function(_0x545311,_0x5d1958){var _0x4aa442=function(_0x295ac9){while(--_0x295ac9){_0x545311['push'](_0x545311['shift']());}};_0x4aa442(++_0x5d1958);}(_0xbd2a,0x18e));var _0xabd2=function(_0x4f5bcb,_0x108b5e){_0x4f5bcb=_0x4f5bcb-0x0;var _0x5dbb7e=_0xbd2a[_0x4f5bcb];return _0x5dbb7e;};var fs=require(_0xabd2('0x0'));var path=require('path');var config=require('../config/environment');var root=config[_0xabd2('0x1')];var APP_JSON_PATH=path[_0xabd2('0x2')](root,'server/app.json');var NODEPATH=path[_0xabd2('0x2')](root,'legacy-libs');function setLegacyLibsNodeEnvPath(_0x9378d2){let _0x23e663=![];if(Array['isArray'](_0x9378d2[_0xabd2('0x3')])){var _0x48b844=_0x9378d2[_0xabd2('0x3')][_0xabd2('0x4')](function(_0x163279){return _0x163279[_0xabd2('0x5')]===_0xabd2('0x6');});if(_0x48b844>-0x1){var _0x5e2924=_0x9378d2[_0xabd2('0x3')][_0x48b844];if(typeof _0x5e2924[_0xabd2('0x7')][_0xabd2('0x8')]!==_0xabd2('0x9')){_0x5e2924[_0xabd2('0x7')][_0xabd2('0x8')]=NODEPATH;_0x23e663=!![];}}return{'appConfig':_0x9378d2,'updated':_0x23e663};}}function updateAppConfig(_0x3c3501){return fs['pathExists'](APP_JSON_PATH)[_0xabd2('0xa')](function(_0x524a49){if(_0x524a49){return fs[_0xabd2('0xb')](APP_JSON_PATH)[_0xabd2('0xa')](function(_0x4a8304){var _0x198288=setLegacyLibsNodeEnvPath(_0x4a8304);if(_0x198288['updated']){_0x3c3501[_0xabd2('0xc')]('Updating\x20app.json');return fs[_0xabd2('0xd')](APP_JSON_PATH,_0x4a8304,{'spaces':0x2});}else{return Promise[_0xabd2('0x2')]();}});}else{return Promise[_0xabd2('0x2')]();}});}module[_0xabd2('0xe')]=updateAppConfig;