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 _configParser=require("../../core/configManager/configParser");
var _runtimeParser=require("../../core/configManager/runtimeParser");
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 _projectParser=require("../../core/projectManager/projectParser");
var _engineManager=require("../../core/engineManager");


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,_configParser.parseRenativeConfigs)(c));case 6:_context.next=8;return _regenerator.default.awrap(
(0,_configParser.checkIsRenativeProject)(c));case 8:_context.next=10;return _regenerator.default.awrap(
(0,_projectParser.checkAndCreateProjectPackage)(c));case 10:_context.next=12;return _regenerator.default.awrap(
(0,_engineManager.executeTask)(c,_constants.TASK_WORKSPACE_CONFIGURE,_constants.TASK_PROJECT_CONFIGURE,originTask));case 12:if(!(

c.program.only&&!!parentTask)){_context.next=20;break;}_context.next=15;return _regenerator.default.awrap(
(0,_runtimeParser.configureRuntimeDefaults)(c));case 15:_context.next=17;return _regenerator.default.awrap(
(0,_engineManager.executeTask)(c,_constants.TASK_APP_CONFIGURE,_constants.TASK_PROJECT_CONFIGURE,originTask));case 17:_context.next=19;return _regenerator.default.awrap(
(0,_configParser.generateRuntimeConfig)(c));case 19:return _context.abrupt("return",
true);case 20:_context.next=22;return _regenerator.default.awrap(


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

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

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

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

(0,_templateManager.applyTemplate)(c));case 40:_context.next=42;return _regenerator.default.awrap(
(0,_runtimeParser.configureRuntimeDefaults)(c));case 42:_context.next=44;return _regenerator.default.awrap(
(0,_engineManager.executeTask)(c,_constants.TASK_INSTALL,_constants.TASK_PROJECT_CONFIGURE,originTask));case 44:_context.next=46;return _regenerator.default.awrap(
(0,_engineManager.executeTask)(c,_constants.TASK_APP_CONFIGURE,_constants.TASK_PROJECT_CONFIGURE,originTask));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,_runtimeParser.configureRuntimeDefaults)(c));case 54:if(!(
c.program.resetHard&&!c.runtime.disableReset)){_context.next=58;break;}
(0,_logger.logInfo)("You passed "+
(0,_logger.chalk)().white('-R')+" argument. \""+(0,_logger.chalk)().white('./platformAssets')+"\" will be cleaned up first");_context.next=58;return _regenerator.default.awrap(


(0,_projectParser.cleanPlaformAssets)(c));case 58:_context.next=60;return _regenerator.default.awrap(

(0,_projectParser.copyRuntimeAssets)(c));case 60:_context.next=62;return _regenerator.default.awrap(
(0,_templateManager.configureTemplateFiles)(c));case 62:_context.next=64;return _regenerator.default.awrap(
(0,_projectParser.checkAndCreateGitignore)(c));case 64:_context.next=66;return _regenerator.default.awrap(
(0,_templateManager.checkAndCreateBabelConfig)(c));case 66:_context.next=68;return _regenerator.default.awrap(
(0,_templateManager.configureEntryPoints)(c));case 68:_context.next=70;return _regenerator.default.awrap(
(0,_configParser.generateRuntimeConfig)(c));case 70:_context.next=72;return _regenerator.default.awrap(
(0,_pluginManager.overrideTemplatePlugins)(c));case 72:return _context.abrupt("return",


true);case 73: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