var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.taskRnvProjectConfigure=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _pluginManager=require("../../core/pluginManager");
var _logger=require("../../core/systemManager/logger");
var _configManager=require("../../core/configManager");
var _runtimeManager=require("../../core/runtimeManager");
var _templateManager=require("../../core/templateManager");
var _fileutils=require("../../core/systemManager/fileutils");
var _crypto=require("../../core/systemManager/crypto");
var _migrator=require("../../core/projectManager/migrator");
var _constants=require("../../core/constants");
var _projectManager=require("../../core/projectManager");
var _engineManager=require("../../core/engineManager");
var _taskManager=require("../../core/taskManager");


var taskRnvProjectConfigure=function taskRnvProjectConfigure(c,parentTask,originTask){var taskInstance;return _regenerator.default.async(function taskRnvProjectConfigure$(_context){while(1){switch(_context.prev=_context.next){case 0:
(0,_logger.logTask)('taskRnvProjectConfigure');

if(c.paths.project.builds.dir&&!(0,_fileutils.fsExistsSync)(c.paths.project.builds.dir)){
(0,_logger.logInfo)("Creating folder "+c.paths.project.builds.dir+" ...DONE");
(0,_fileutils.fsMkdirSync)(c.paths.project.builds.dir);
}_context.next=4;return _regenerator.default.awrap(
(0,_migrator.checkAndMigrateProject)(c));case 4:_context.next=6;return _regenerator.default.awrap(
(0,_runtimeManager.updateRenativeConfigs)(c));case 6:_context.next=8;return _regenerator.default.awrap(
(0,_configManager.checkIsRenativeProject)(c));case 8:_context.next=10;return _regenerator.default.awrap(

(0,_taskManager.executeTask)(c,_constants.TASK_WORKSPACE_CONFIGURE,_constants.TASK_PROJECT_CONFIGURE,originTask));case 10:if(!(

c.program.only&&!!parentTask)){_context.next=18;break;}_context.next=13;return _regenerator.default.awrap(
(0,_runtimeManager.configureRuntimeDefaults)(c));case 13:_context.next=15;return _regenerator.default.awrap(
(0,_taskManager.executeTask)(c,_constants.TASK_APP_CONFIGURE,_constants.TASK_PROJECT_CONFIGURE,originTask));case 15:_context.next=17;return _regenerator.default.awrap(
(0,_configManager.generateRuntimeConfig)(c));case 17:return _context.abrupt("return",
true);case 18:_context.next=20;return _regenerator.default.awrap(


(0,_templateManager.checkIfTemplateConfigured)(c));case 20:_context.next=22;return _regenerator.default.awrap(
(0,_taskManager.executeTask)(c,_constants.TASK_INSTALL,_constants.TASK_PROJECT_CONFIGURE,originTask));case 22:_context.next=24;return _regenerator.default.awrap(
(0,_crypto.checkCrypto)(c,parentTask,originTask));case 24:_context.next=26;return _regenerator.default.awrap(
(0,_runtimeManager.configureRuntimeDefaults)(c));case 26:if(!(

originTask!==_constants.TASK_TEMPLATE_APPLY)){_context.next=80;break;}if(!(
c.runtime.requiresBootstrap||!(0,_templateManager.isTemplateInstalled)(c))){_context.next=36;break;}_context.next=30;return _regenerator.default.awrap(
(0,_templateManager.applyTemplate)(c));case 30:

(0,_logger.logInfo)('Your template has been bootstraped. Command reset is required. RESTRATING...DONE');_context.next=33;return _regenerator.default.awrap(

(0,_taskManager.findSuitableTask)(c));case 33:taskInstance=_context.sent;
c.runtime.requiresBootstrap=false;return _context.abrupt("return",
(0,_taskManager.initializeTask)(c,taskInstance.task));case 36:_context.next=38;return _regenerator.default.awrap(

(0,_templateManager.applyTemplate)(c));case 38:_context.next=40;return _regenerator.default.awrap(
(0,_runtimeManager.configureRuntimeDefaults)(c));case 40:_context.next=42;return _regenerator.default.awrap(
(0,_taskManager.executeTask)(c,_constants.TASK_INSTALL,_constants.TASK_PROJECT_CONFIGURE,originTask));case 42:_context.next=44;return _regenerator.default.awrap(
(0,_taskManager.executeTask)(c,_constants.TASK_APP_CONFIGURE,_constants.TASK_PROJECT_CONFIGURE,originTask));case 44:_context.next=46;return _regenerator.default.awrap(

(0,_projectManager.versionCheck)(c));case 46:_context.next=48;return _regenerator.default.awrap(
(0,_engineManager.configureEngines)(c));case 48:_context.next=50;return _regenerator.default.awrap(
(0,_pluginManager.resolvePluginDependants)(c));case 50:_context.next=52;return _regenerator.default.awrap(
(0,_pluginManager.configurePlugins)(c));case 52:_context.next=54;return _regenerator.default.awrap(

(0,_runtimeManager.configureRuntimeDefaults)(c));case 54:if(
c.runtime.disableReset){_context.next=65;break;}if(!
c.program.resetHard){_context.next=61;break;}
(0,_logger.logInfo)("You passed "+
(0,_logger.chalk)().white('-R, --resetHard')+" argument. \""+(0,_logger.chalk)().white('./platformAssets')+"\" will be cleaned up first");_context.next=59;return _regenerator.default.awrap(

(0,_projectManager.cleanPlaformAssets)(c));case 59:_context.next=65;break;case 61:if(!
c.program.resetAssets){_context.next=65;break;}
(0,_logger.logInfo)("You passed "+
(0,_logger.chalk)().white('-a, --resetAssets')+" argument. \""+(0,_logger.chalk)().white('./platformAssets')+"\" will be cleaned up first");_context.next=65;return _regenerator.default.awrap(

(0,_projectManager.cleanPlaformAssets)(c));case 65:_context.next=67;return _regenerator.default.awrap(



(0,_projectManager.copyRuntimeAssets)(c));case 67:_context.next=69;return _regenerator.default.awrap(
(0,_templateManager.configureTemplateFiles)(c));case 69:_context.next=71;return _regenerator.default.awrap(
(0,_projectManager.checkAndCreateGitignore)(c));case 71:_context.next=73;return _regenerator.default.awrap(
(0,_projectManager.checkAndCreateBabelConfig)(c));case 73:if(
c.buildConfig.platforms){_context.next=76;break;}_context.next=76;return _regenerator.default.awrap(
(0,_runtimeManager.updateRenativeConfigs)(c));case 76:_context.next=78;return _regenerator.default.awrap(



(0,_configManager.generateRuntimeConfig)(c));case 78:_context.next=80;return _regenerator.default.awrap(
(0,_pluginManager.overrideTemplatePlugins)(c));case 80:return _context.abrupt("return",


true);case 81:case"end":return _context.stop();}}},null,null,null,Promise);};exports.taskRnvProjectConfigure=taskRnvProjectConfigure;var _default=


{
description:'Configure current project',
fn:taskRnvProjectConfigure,
task:_constants.TASK_PROJECT_CONFIGURE,
params:_constants.PARAMS.withBase(),
platforms:[]};exports.default=_default;
//# sourceMappingURL=task.rnv.project.configure.js.map