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 _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));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");function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly)symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;});keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);});}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}}return target;}


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:



c.runtime.disableReset=true;if(
parentTask){_context.next=9;break;}_context.next=9;return _regenerator.default.awrap(
(0,_engineManager.executeTask)(c,_constants.TASK_CONFIGURE_SOFT,_constants.TASK_START,originTask));case 9:_context.t0=



platform;_context.next=_context.t0===
_constants.IOS?12:_context.t0===
_constants.TVOS?12:_context.t0===
_constants.ANDROID?12:_context.t0===
_constants.ANDROID_TV?12:_context.t0===
_constants.ANDROID_WEAR?12:21;break;case 12:
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){
startCmd+=' --reset-cache';
}
if(c.program.resetHard||c.program.reset){
(0,_logger.logInfo)("You passed "+
(0,_logger.chalk)().white('-r')+" argument. --reset-cache will be applied to react-native");

}

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=19;break;}return _context.abrupt("return",
(0,_exec.executeAsync)(c,startCmd,{stdio:'inherit',silent:true,env:_objectSpread({},(0,_engineManager.generateEnvVars)(c))}));case 19:

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



(0,_platformManager.logErrorPlatform)(c));case 22: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