var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.taskRnvStart=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _common=require("../core/common");
var _resolve=require("../core/resolve");
var _platformManager=require("../core/platformManager");
var _engineManager=require("../core/engineManager");
var _logger=require("../core/systemManager/logger");
var _constants=require("../core/constants");







var _exec=require("../core/systemManager/exec");


var BUNDLER_PLATFORMS={};

BUNDLER_PLATFORMS[_constants.IOS]=_constants.IOS;
BUNDLER_PLATFORMS[_constants.TVOS]=_constants.IOS;
BUNDLER_PLATFORMS[_constants.ANDROID]=[_constants.ANDROID];
BUNDLER_PLATFORMS[_constants.ANDROID_TV]=[_constants.ANDROID];
BUNDLER_PLATFORMS[_constants.ANDROID_WEAR]=[_constants.ANDROID];

var taskRnvStart=function taskRnvStart(c,parentTask,originTask){var platform,hosted,startCmd,url;return _regenerator.default.async(function taskRnvStart$(_context){while(1){switch(_context.prev=_context.next){case 0:
platform=c.platform;
hosted=c.program.hosted;

(0,_logger.logTask)('taskRnvStart',"parent:"+parentTask+" port:"+c.runtime.port+" hosted:"+!!hosted);if(!

hosted){_context.next=5;break;}return _context.abrupt("return",
(0,_logger.logError)(
'This platform does not support hosted mode',
true));case 5:if(


parentTask){_context.next=8;break;}_context.next=8;return _regenerator.default.awrap(
(0,_engineManager.executeTask)(c,_constants.TASK_CONFIGURE,_constants.TASK_START,originTask));case 8:_context.t0=



platform;_context.next=_context.t0===
_constants.IOS?11:_context.t0===
_constants.TVOS?11:_context.t0===
_constants.ANDROID?11:_context.t0===
_constants.ANDROID_TV?11:_context.t0===
_constants.ANDROID_WEAR?11:19;break;case 11:
startCmd="node "+(0,_resolve.doResolve)(
'react-native')+"/local-cli/cli.js start --port "+

c.runtime.port+" --config=metro.config.js";


if(c.program.resetHard){
startCmd+=' --reset-cache';
}else if(c.program.reset&&c.command==='start'){
startCmd+=' --reset-cache';
}

url=(0,_logger.chalk)().cyan("http://"+c.runtime.localhost+":"+c.runtime.port+"/"+
(0,_common.getEntryFile)(c,c.platform)+".bundle?platform="+BUNDLER_PLATFORMS[platform]);
(0,_logger.logRaw)("\n\nDev server running at: "+

url+"\n\n");if(


parentTask){_context.next=17;break;}return _context.abrupt("return",
(0,_exec.executeAsync)(c,startCmd,{stdio:'inherit',silent:true,env:{RNV_EXTENSIONS:(0,_engineManager.getPlatformExtensions)(c)}}));case 17:

(0,_exec.executeAsync)(c,startCmd,{stdio:'inherit',silent:true,env:{RNV_EXTENSIONS:(0,_engineManager.getPlatformExtensions)(c)}});return _context.abrupt("return",
true);case 19:return _context.abrupt("return",



(0,_platformManager.logErrorPlatform)(c));case 20:case"end":return _context.stop();}}},null,null,null,Promise);};exports.taskRnvStart=taskRnvStart;var _default=



{
description:'Starts bundler / server',
fn:taskRnvStart,
task:'start',
params:_constants.PARAMS.withBase(_constants.PARAMS.withConfigure()),
platforms:[
_constants.IOS,
_constants.TVOS,
_constants.ANDROID,
_constants.ANDROID_TV,
_constants.ANDROID_WEAR]};exports.default=_default;
//# sourceMappingURL=task.rnv.start.js.map