Built motion from commit 3c2ce842.|2.6.31
[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 _0xec70=['name','env','string','NODE_PATH','then','readJSON','info','Updating\x20app.json','writeJSON','exports','fs-extra','path','resolve','server/app.json','legacy-libs','apps'];(function(_0x48263c,_0x257104){var _0x47f899=function(_0x54bfc5){while(--_0x54bfc5){_0x48263c['push'](_0x48263c['shift']());}};_0x47f899(++_0x257104);}(_0xec70,0x1da));var _0x0ec7=function(_0x3beb1f,_0xc0567a){_0x3beb1f=_0x3beb1f-0x0;var _0x7ace5b=_0xec70[_0x3beb1f];return _0x7ace5b;};var fs=require(_0x0ec7('0x0'));var path=require(_0x0ec7('0x1'));var config=require('../config/environment');var root=config['root'];var APP_JSON_PATH=path[_0x0ec7('0x2')](root,_0x0ec7('0x3'));var NODEPATH=path['resolve'](root,_0x0ec7('0x4'));function setLegacyLibsNodeEnvPath(_0x2429a8){let _0x17ac04=![];if(Array['isArray'](_0x2429a8[_0x0ec7('0x5')])){var _0x38eb8e=_0x2429a8[_0x0ec7('0x5')]['findIndex'](function(_0x302f7a){return _0x302f7a[_0x0ec7('0x6')]==='motion2';});if(_0x38eb8e>-0x1){var _0x3cf420=_0x2429a8[_0x0ec7('0x5')][_0x38eb8e];if(typeof _0x3cf420[_0x0ec7('0x7')]['NODE_PATH']!==_0x0ec7('0x8')){_0x3cf420[_0x0ec7('0x7')][_0x0ec7('0x9')]=NODEPATH;_0x17ac04=!![];}}return{'appConfig':_0x2429a8,'updated':_0x17ac04};}}function updateAppConfig(_0x30ac37){return fs['pathExists'](APP_JSON_PATH)[_0x0ec7('0xa')](function(_0x3feebb){if(_0x3feebb){return fs[_0x0ec7('0xb')](APP_JSON_PATH)['then'](function(_0x2e4dd3){var _0x5e4ceb=setLegacyLibsNodeEnvPath(_0x2e4dd3);if(_0x5e4ceb['updated']){_0x30ac37[_0x0ec7('0xc')](_0x0ec7('0xd'));return fs[_0x0ec7('0xe')](APP_JSON_PATH,_0x2e4dd3,{'spaces':0x2});}else{return Promise[_0x0ec7('0x2')]();}});}else{return Promise['resolve']();}});}module[_0x0ec7('0xf')]=updateAppConfig;