var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.runAndroidLog=exports.configureProject=exports.configureGradleProject=exports.configureAndroidProperties=exports.buildAndroid=exports.runAndroid=exports.packageAndroid=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _path=_interopRequireDefault(require("path"));
var _net=_interopRequireDefault(require("net"));
var _shelljs=_interopRequireDefault(require("shelljs"));
var _inquirer=_interopRequireDefault(require("inquirer"));
var _execa=_interopRequireDefault(require("execa"));
var _fileutils=require("../core/systemManager/fileutils");








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




var _platformManager=require("../core/platformManager");
var _engineManager=require("../core/engineManager");
var _utils=require("../core/systemManager/utils");
var _prompt=require("../cli/prompt");
var _logger=require("../core/systemManager/logger");









var _projectManager=require("../core/projectManager");




var _constants=require("../core/constants");





var _pluginManager=require("../core/pluginManager");
var _manifestParser=require("./manifestParser");



var _kotlinParser=require("./kotlinParser");





var _gradleParser=require("./gradleParser");






var _xmlValuesParser=require("./xmlValuesParser");




var _deviceManager=require("./deviceManager");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 _getEntryOutputName=function _getEntryOutputName(c){var

entryFile=c.buildConfig.platforms[c.platform].entryFile;

var outputFile;
if(c.platform===_constants.ANDROID_WEAR){
outputFile=entryFile;
}else{
outputFile='index.android';
}
return outputFile;
};

var packageAndroid=function packageAndroid(c){var platform,bundleAssets,outputFile,appFolder,reactNative,_c$buildConfig$platfo;return _regenerator.default.async(function packageAndroid$(_context){while(1){switch(_context.prev=_context.next){case 0:
(0,_logger.logTask)('packageAndroid');
platform=c.platform;

bundleAssets=(0,_common.getConfigProp)(c,platform,'bundleAssets',false)===true;if(!(

!bundleAssets&&platform!==_constants.ANDROID_WEAR)){_context.next=5;break;}return _context.abrupt("return",
true);case 5:


outputFile=_getEntryOutputName(c);

appFolder=(0,_common.getAppFolder)(c);
reactNative='react-native';

if(_utils.isSystemWin){
reactNative=_path.default.normalize(
process.cwd()+"/node_modules/.bin/react-native.cmd");

}

(0,_logger.logInfo)('ANDROID PACKAGE STARTING...');_context.prev=10;_context.next=13;return _regenerator.default.awrap(


(0,_exec.executeAsync)(c,reactNative+" bundle --platform android --dev false --assets-dest "+
appFolder+"/app/src/main/res --entry-file "+((_c$buildConfig$platfo=

c.buildConfig.platforms[c.platform])==null?void 0:_c$buildConfig$platfo.entryFile)+".js --bundle-output "+
appFolder+"/app/src/main/assets/"+
outputFile+".bundle --config=metro.config.js",
{env:_objectSpread({},(0,_engineManager.generateEnvVars)(c))}));case 13:

(0,_logger.logInfo)('ANDROID PACKAGE FINISHED');return _context.abrupt("return",
true);case 17:_context.prev=17;_context.t0=_context["catch"](10);

(0,_logger.logInfo)('ANDROID PACKAGE FAILED');return _context.abrupt("return",
Promise.reject(_context.t0));case 21:case"end":return _context.stop();}}},null,null,[[10,17]],Promise);};exports.packageAndroid=packageAndroid;



var runAndroid=function runAndroid(c,defaultTarget){var target,platform,outputAab,devicesAndEmulators,activeDevices,inactiveDevices,askWhereToRun,foundDevice,device,dv,_foundDevice,_device;return _regenerator.default.async(function runAndroid$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:
target=c.program.target;
platform=c.platform;
(0,_logger.logTask)('runAndroid',"target:"+target+" default:"+defaultTarget);

outputAab=(0,_common.getConfigProp)(c,platform,'aab',false);if(!

outputAab){_context3.next=6;break;}return _context3.abrupt("return",_runGradleApp(c,platform,{}));case 6:_context3.next=8;return _regenerator.default.awrap(

(0,_deviceManager.resetAdb)(c));case 8:if(!(

target&&_net.default.isIP(target))){_context3.next=11;break;}_context3.next=11;return _regenerator.default.awrap(
(0,_deviceManager.connectToWifiDevice)(c,target));case 11:_context3.prev=11;_context3.next=14;return _regenerator.default.awrap(




(0,_deviceManager.getAndroidTargets)(
c,
false,
false,
c.program.device!==undefined));case 14:devicesAndEmulators=_context3.sent;_context3.next=20;break;case 17:_context3.prev=17;_context3.t0=_context3["catch"](11);return _context3.abrupt("return",


Promise.reject(_context3.t0));case 20:


activeDevices=devicesAndEmulators.filter(function(d){return d.isActive;});
inactiveDevices=devicesAndEmulators.filter(function(d){return!d.isActive;});

askWhereToRun=function askWhereToRun(){var devicesString,choices,response,devices,_devicesString,_choices,_response,dev,_devices;return _regenerator.default.async(function askWhereToRun$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:if(!(
activeDevices.length===0&&inactiveDevices.length>0)){_context2.next=16;break;}

devicesString=(0,_deviceManager.composeDevicesString)(inactiveDevices,true);
choices=devicesString;_context2.next=5;return _regenerator.default.awrap(
_inquirer.default.prompt([
{
name:'chosenEmulator',
type:'list',
message:'What emulator would you like to start?',
choices:choices}]));case 5:response=_context2.sent;if(!


response.chosenEmulator){_context2.next=14;break;}_context2.next=9;return _regenerator.default.awrap(
(0,_deviceManager.launchAndroidSimulator)(c,response.chosenEmulator,true));case 9:_context2.next=11;return _regenerator.default.awrap(
(0,_deviceManager.checkForActiveEmulator)(c));case 11:devices=_context2.sent;_context2.next=14;return _regenerator.default.awrap(
_runGradleApp(c,platform,devices));case 14:_context2.next=35;break;case 16:if(!(

activeDevices.length>1)){_context2.next=28;break;}
_devicesString=(0,_deviceManager.composeDevicesString)(activeDevices,true);
_choices=_devicesString;_context2.next=21;return _regenerator.default.awrap(
_inquirer.default.prompt([
{
name:'chosenEmulator',
type:'list',
message:'Where would you like to run your app?',
choices:_choices}]));case 21:_response=_context2.sent;if(!


_response.chosenEmulator){_context2.next=26;break;}
dev=activeDevices.find(
function(d){return d.name===_response.chosenEmulator;});_context2.next=26;return _regenerator.default.awrap(

_runGradleApp(c,platform,dev));case 26:_context2.next=35;break;case 28:_context2.next=30;return _regenerator.default.awrap(


(0,_deviceManager.askForNewEmulator)(c,platform));case 30:_context2.next=32;return _regenerator.default.awrap(
(0,_deviceManager.checkForActiveEmulator)(c));case 32:_devices=_context2.sent;_context2.next=35;return _regenerator.default.awrap(
_runGradleApp(c,platform,_devices));case 35:case"end":return _context2.stop();}}},null,null,null,Promise);};if(!



target){_context3.next=45;break;}

(0,_logger.logDebug)('Target provided',target);
foundDevice=devicesAndEmulators.find(
function(d){return d.udid.includes(target)||d.name.includes(target);});if(!

foundDevice){_context3.next=41;break;}if(!
foundDevice.isActive){_context3.next=32;break;}_context3.next=30;return _regenerator.default.awrap(
_runGradleApp(c,platform,foundDevice));case 30:_context3.next=39;break;case 32:_context3.next=34;return _regenerator.default.awrap(

(0,_deviceManager.launchAndroidSimulator)(c,foundDevice,true));case 34:_context3.next=36;return _regenerator.default.awrap(
(0,_deviceManager.checkForActiveEmulator)(c));case 36:device=_context3.sent;_context3.next=39;return _regenerator.default.awrap(
_runGradleApp(c,platform,device));case 39:_context3.next=43;break;case 41:_context3.next=43;return _regenerator.default.awrap(


askWhereToRun());case 43:_context3.next=73;break;case 45:if(!(

activeDevices.length===1)){_context3.next=52;break;}

dv=activeDevices[0];
(0,_logger.logInfo)("Found device "+dv.name+":"+dv.udid+"!");_context3.next=50;return _regenerator.default.awrap(
_runGradleApp(c,platform,dv));case 50:_context3.next=73;break;case 52:if(!
defaultTarget){_context3.next=70;break;}

(0,_logger.logDebug)('Default target used',defaultTarget);
_foundDevice=devicesAndEmulators.find(
function(d){return d.udid.includes(defaultTarget)||d.name.includes(defaultTarget);});if(

_foundDevice){_context3.next=61;break;}
(0,_logger.logDebug)('Target not provided, asking where to run');_context3.next=59;return _regenerator.default.awrap(
askWhereToRun());case 59:_context3.next=68;break;case 61:_context3.next=63;return _regenerator.default.awrap(

(0,_deviceManager.launchAndroidSimulator)(c,_foundDevice,true));case 63:_context3.next=65;return _regenerator.default.awrap(
(0,_deviceManager.checkForActiveEmulator)(c));case 65:_device=_context3.sent;_context3.next=68;return _regenerator.default.awrap(
_runGradleApp(c,platform,_device));case 68:_context3.next=73;break;case 70:



(0,_logger.logDebug)('Target not provided, asking where to run');_context3.next=73;return _regenerator.default.awrap(
askWhereToRun());case 73:case"end":return _context3.stop();}}},null,null,[[11,17]],Promise);};exports.runAndroid=runAndroid;



var _checkSigningCerts=function _checkSigningCerts(c){var _c$files$workspace$ap;var signingConfig,isRelease,privateConfig,_await$inquirer$promp,confirm,confirmCopy,platCandidate,_await$inquirerPrompt,confirmNewKeystore,platCandidates,resultCopy,storeFile,result,_await$inquirer$promp2,storePassword,keyAlias,keyPassword,keystorePath,keytoolCmd;return _regenerator.default.async(function _checkSigningCerts$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:
(0,_logger.logTask)('_checkSigningCerts');
signingConfig=(0,_common.getConfigProp)(
c,
c.platform,
'signingConfig',
'Debug');

isRelease=signingConfig==='Release';
privateConfig=(_c$files$workspace$ap=c.files.workspace.appConfig.configPrivate)==null?void 0:_c$files$workspace$ap[c.platform];if(!(

isRelease&&!privateConfig)){_context4.next=54;break;}
(0,_logger.logWarning)("You're attempting to "+

c.command+" app in release mode but you have't configured your "+
(0,_logger.chalk)().white(
c.paths.workspace.appConfig.configPrivate)+" for "+
(0,_logger.chalk)().white(c.platform)+" platform yet.");_context4.next=8;return _regenerator.default.awrap(


_inquirer.default.prompt({
type:'confirm',
name:'confirm',
message:'Do you want to configure it now?'}));case 8:_await$inquirer$promp=_context4.sent;confirm=_await$inquirer$promp.confirm;if(!


confirm){_context4.next=53;break;}
confirmCopy=false;_context4.next=14;return _regenerator.default.awrap(

(0,_prompt.inquirerPrompt)({
type:'confirm',
name:'confirmNewKeystore',
message:'Do you want to generate new keystore as well?'}));case 14:_await$inquirerPrompt=_context4.sent;confirmNewKeystore=_await$inquirerPrompt.confirmNewKeystore;if(!


c.files.workspace.appConfig.configPrivate){_context4.next=24;break;}
platCandidates=[_constants.ANDROID_WEAR,_constants.ANDROID_TV,_constants.ANDROID];

platCandidates.forEach(function(v){
if(c.files.workspace.appConfig.configPrivate[v]){
platCandidate=v;
}
});if(!
platCandidate){_context4.next=24;break;}_context4.next=22;return _regenerator.default.awrap(
(0,_prompt.inquirerPrompt)({
type:'confirm',
name:'confirmCopy',
message:"Found existing keystore configuration for "+platCandidate+". do you want to reuse it?"}));case 22:resultCopy=_context4.sent;

confirmCopy=resultCopy==null?void 0:resultCopy.confirmCopy;case 24:if(!



confirmCopy){_context4.next=28;break;}
c.files.workspace.appConfig.
configPrivate[c.platform]=c.files.workspace.
appConfig.configPrivate[platCandidate];_context4.next=47;break;case 28:if(



confirmNewKeystore){_context4.next=33;break;}_context4.next=31;return _regenerator.default.awrap(
(0,_prompt.inquirerPrompt)({
type:'input',
name:'storeFile',
message:"Paste asolute or relative path to "+(0,_logger.chalk)().white(
c.paths.workspace.appConfig.dir)+" of your existing "+
(0,_logger.chalk)().white(
'release.keystore')+" file"}));case 31:result=_context4.sent;


storeFile=result==null?void 0:result.storeFile;case 33:_context4.next=35;return _regenerator.default.awrap(






_inquirer.default.prompt([
{
type:'password',
name:'storePassword',
message:'storePassword'},

{
type:'input',
name:'keyAlias',
message:'keyAlias'},

{
type:'password',
name:'keyPassword',
message:'keyPassword'}]));case 35:_await$inquirer$promp2=_context4.sent;storePassword=_await$inquirer$promp2.storePassword;keyAlias=_await$inquirer$promp2.keyAlias;keyPassword=_await$inquirer$promp2.keyPassword;if(!



confirmNewKeystore){_context4.next=46;break;}
keystorePath=c.paths.workspace.appConfig.dir+"/release.keystore";
(0,_fileutils.mkdirSync)(c.paths.workspace.appConfig.dir);
keytoolCmd="keytool -genkey -v -keystore "+
keystorePath+" -alias "+
keyAlias+" -keypass "+keyPassword+" -storepass "+
storePassword+" -keyalg RSA -keysize 2048 -validity 10000";_context4.next=45;return _regenerator.default.awrap(

(0,_exec.executeAsync)(c,keytoolCmd,{
env:process.env,
shell:true,
stdio:'inherit',
silent:true}));case 45:

storeFile='./release.keystore';case 46:


if(c.paths.workspace.appConfig.dir){
(0,_fileutils.mkdirSync)(c.paths.workspace.appConfig.dir);
c.files.workspace.appConfig.configPrivate={};
c.files.workspace.appConfig.configPrivate[c.platform]={
storeFile:storeFile,
storePassword:storePassword,
keyAlias:keyAlias,
keyPassword:keyPassword};

}case 47:


(0,_fileutils.updateObjectSync)(
c.paths.workspace.appConfig.configPrivate,
c.files.workspace.appConfig.configPrivate);

(0,_logger.logSuccess)("Successfully updated private config file at "+
(0,_logger.chalk)().white(
c.paths.workspace.appConfig.dir)+".");_context4.next=51;return _regenerator.default.awrap(


configureProject(c));case 51:_context4.next=54;break;case 53:return _context4.abrupt("return",

Promise.reject("You selected no. Can't proceed"));case 54:case"end":return _context4.stop();}}},null,null,null,Promise);};




var _runGradleApp=function _runGradleApp(c,platform,device){var signingConfig,appFolder,bundleId,outputAab,outputFolder,arch,name,stacktrace,aabPath,apkPath,_e$message,_await$inquirerPrompt2,confirm;return _regenerator.default.async(function _runGradleApp$(_context5){while(1){switch(_context5.prev=_context5.next){case 0:
(0,_logger.logTask)('_runGradleApp');

signingConfig=(0,_common.getConfigProp)(c,platform,'signingConfig','Debug');
appFolder=(0,_common.getAppFolder)(c);
bundleId=(0,_common.getAppId)(c,platform);
outputAab=(0,_common.getConfigProp)(c,platform,'aab',false);
outputFolder=signingConfig==='Debug'?'debug':'release';
arch=device.arch,name=device.name;
stacktrace=c.program.info?' --debug':'';

_shelljs.default.cd(""+appFolder);_context5.next=11;return _regenerator.default.awrap(

_checkSigningCerts(c));case 11:_context5.next=13;return _regenerator.default.awrap(
(0,_exec.executeAsync)(
c,(
_utils.isSystemWin?'gradlew.bat':'./gradlew')+" "+(
outputAab?'bundle':'assemble')+
signingConfig+stacktrace+" -x bundleReleaseJsAndAssets"));case 13:if(!


outputAab){_context5.next=17;break;}
aabPath=_path.default.join(
appFolder,"app/build/outputs/bundle/"+
outputFolder+"/app.aab");

(0,_logger.logInfo)("App built. Path "+aabPath);return _context5.abrupt("return",
true);case 17:

apkPath=_path.default.join(
appFolder,"app/build/outputs/apk/"+
outputFolder+"/app-"+outputFolder+".apk");

if(!(0,_fileutils.fsExistsSync)(apkPath)){
apkPath=_path.default.join(
appFolder,"app/build/outputs/apk/"+
outputFolder+"/app-"+outputFolder+"-unsigned.apk");

}
if(!(0,_fileutils.fsExistsSync)(apkPath)){
apkPath=_path.default.join(
appFolder,"app/build/outputs/apk/"+
outputFolder+"/app-"+arch+"-"+outputFolder+".apk");

}
(0,_logger.logInfo)("Installing "+apkPath+" on "+name);_context5.prev=21;_context5.next=24;return _regenerator.default.awrap(

(0,_exec.execCLI)(
c,
_constants.CLI_ANDROID_ADB,"-s "+
device.udid+" install -r -d -f "+apkPath));case 24:_context5.next=42;break;case 26:_context5.prev=26;_context5.t0=_context5["catch"](21);if(!(



(_context5.t0==null?void 0:_context5.t0.includes('INSTALL_FAILED'))||(_context5.t0==null?void 0:(_e$message=
_context5.t0.message)==null?void 0:_e$message.includes('INSTALL_FAILED')))){_context5.next=41;break;}_context5.next=31;return _regenerator.default.awrap(

(0,_prompt.inquirerPrompt)({
type:'confirm',
message:
"It seems you already have the app installed but RNV can't update it. Uninstall that one and try again?"}));case 31:_await$inquirerPrompt2=_context5.sent;confirm=_await$inquirerPrompt2.confirm;if(


confirm){_context5.next=35;break;}throw new Error('User canceled');case 35:_context5.next=37;return _regenerator.default.awrap(
(0,_exec.execCLI)(
c,
_constants.CLI_ANDROID_ADB,"-s "+
device.udid+" uninstall "+bundleId));case 37:_context5.next=39;return _regenerator.default.awrap(

(0,_exec.execCLI)(
c,
_constants.CLI_ANDROID_ADB,"-s "+
device.udid+" install -r -d -f "+apkPath));case 39:_context5.next=42;break;case 41:throw(


new Error(_context5.t0));case 42:if(



outputAab){_context5.next=45;break;}_context5.next=45;return _regenerator.default.awrap(
(0,_exec.execCLI)(
c,
_constants.CLI_ANDROID_ADB,"-s "+
device.udid+" shell am start -n "+bundleId+"/.MainActivity"));case 45:case"end":return _context5.stop();}}},null,null,[[21,26]],Promise);};




var buildAndroid=function buildAndroid(c){var platform,appFolder,signingConfig;return _regenerator.default.async(function buildAndroid$(_context6){while(1){switch(_context6.prev=_context6.next){case 0:
(0,_logger.logTask)('buildAndroid');
platform=c.platform;

appFolder=(0,_common.getAppFolder)(c);
signingConfig=(0,_common.getConfigProp)(
c,
platform,
'signingConfig',
'Debug');


_shelljs.default.cd(""+appFolder);_context6.next=7;return _regenerator.default.awrap(

_checkSigningCerts(c));case 7:_context6.next=9;return _regenerator.default.awrap(
(0,_exec.executeAsync)(c,(_utils.isSystemWin?'gradlew.bat':'./gradlew')+" assemble"+signingConfig+" -x bundleReleaseJsAndAssets"));case 9:

(0,_logger.logSuccess)("Your APK is located in "+
(0,_logger.chalk)().cyan(
_path.default.join(
appFolder,"app/build/outputs/apk/"+
signingConfig.toLowerCase()))+" .");return _context6.abrupt("return",



true);case 11:case"end":return _context6.stop();}}},null,null,null,Promise);};exports.buildAndroid=buildAndroid;


var configureAndroidProperties=function configureAndroidProperties(c){var _c$buildConfig,_c$buildConfig$sdks,_c$buildConfig2,_c$buildConfig2$sdks,_c$buildConfig3,_c$buildConfig3$sdks;var appFolder,addNDK,ndkString,sdkDir;return _regenerator.default.async(function configureAndroidProperties$(_context7){while(1){switch(_context7.prev=_context7.next){case 0:
(0,_logger.logTask)('configureAndroidProperties');

appFolder=(0,_common.getAppFolder)(c);

c.runtime.platformBuildsProjectPath=appFolder;


addNDK=((_c$buildConfig=c.buildConfig)==null?void 0:(_c$buildConfig$sdks=_c$buildConfig.sdks)==null?void 0:_c$buildConfig$sdks.ANDROID_NDK)&&
!c.buildConfig.sdks.ANDROID_NDK.includes('<USER>');
ndkString="ndk.dir="+(0,_fileutils.getRealPath)(
c,(_c$buildConfig2=
c.buildConfig)==null?void 0:(_c$buildConfig2$sdks=_c$buildConfig2.sdks)==null?void 0:_c$buildConfig2$sdks.ANDROID_NDK);

sdkDir=(0,_fileutils.getRealPath)(c,(_c$buildConfig3=c.buildConfig)==null?void 0:(_c$buildConfig3$sdks=_c$buildConfig3.sdks)==null?void 0:_c$buildConfig3$sdks.ANDROID_SDK);

if(_utils.isSystemWin){
sdkDir=sdkDir.replace(/\\/g,'/');
}

(0,_fileutils.fsWriteFileSync)(
_path.default.join(appFolder,'local.properties'),"#Generated by ReNative (https://renative.org)\n"+(

addNDK?ndkString:'')+"\nsdk.dir="+
sdkDir);return _context7.abrupt("return",


true);case 9:case"end":return _context7.stop();}}},null,null,null,Promise);};exports.configureAndroidProperties=configureAndroidProperties;


var configureGradleProject=function configureGradleProject(c){var platform;return _regenerator.default.async(function configureGradleProject$(_context8){while(1){switch(_context8.prev=_context8.next){case 0:
platform=c.platform;
(0,_logger.logTask)('configureGradleProject');if(

(0,_platformManager.isPlatformActive)(c,platform)){_context8.next=4;break;}return _context8.abrupt("return");case 4:_context8.next=6;return _regenerator.default.awrap(

(0,_projectManager.copyAssetsFolder)(c,platform));case 6:_context8.next=8;return _regenerator.default.awrap(
configureAndroidProperties(c));case 8:_context8.next=10;return _regenerator.default.awrap(
configureProject(c));case 10:_context8.next=12;return _regenerator.default.awrap(
(0,_projectManager.copyBuildsFolder)(c,platform));case 12:return _context8.abrupt("return",
true);case 13:case"end":return _context8.stop();}}},null,null,null,Promise);};exports.configureGradleProject=configureGradleProject;


var configureProject=function configureProject(c){var platform,appFolder,gradlew,outputFile;return _regenerator.default.async(function configureProject$(_context9){while(1){switch(_context9.prev=_context9.next){case 0:
(0,_logger.logTask)('configureProject');
platform=c.platform;

appFolder=(0,_common.getAppFolder)(c);

gradlew=_path.default.join(appFolder,'gradlew');if(

(0,_fileutils.fsExistsSync)(gradlew)){_context9.next=11;break;}
(0,_logger.logWarning)("Your "+
(0,_logger.chalk)().white(
platform)+" platformBuild is misconfigured!. let's repair it.");_context9.next=8;return _regenerator.default.awrap(


(0,_platformManager.createPlatformBuild)(c,platform));case 8:_context9.next=10;return _regenerator.default.awrap(
configureGradleProject(c,platform));case 10:return _context9.abrupt("return",

true);case 11:


outputFile=_getEntryOutputName(c);

(0,_fileutils.mkdirSync)(_path.default.join(appFolder,'app/src/main/assets'));
(0,_fileutils.fsWriteFileSync)(
_path.default.join(appFolder,"app/src/main/assets/"+outputFile+".bundle"),
'{}');

(0,_fileutils.fsChmodSync)(gradlew,'755');


c.pluginConfigAndroid={
pluginIncludes:"include ':app'",
pluginPaths:'',
pluginImports:'',
pluginPackages:'MainReactPackage(),\n',
pluginActivityImports:'',
pluginActivityMethods:'',
pluginApplicationImports:'',
pluginApplicationMethods:'',
pluginApplicationCreateMethods:'',
pluginApplicationDebugServer:'',
applyPlugin:'',
defaultConfig:'',
pluginActivityCreateMethods:'',
pluginActivityResultMethods:'',
pluginSplashActivityImports:'',
manifestApplication:'',
buildGradleAllProjectsRepositories:'',
buildGradleBuildScriptRepositories:'',
buildGradleBuildScriptDependencies:'',
buildGradleBuildScriptDexOptions:'',
appBuildGradleSigningConfigs:'',
appBuildGradleImplementations:'',
resourceStrings:[],
appBuildGradleAfterEvaluate:''};



(0,_pluginManager.parsePlugins)(c,platform,function(plugin,pluginPlat,key){
(0,_gradleParser.injectPluginGradleSync)(c,pluginPlat,key,pluginPlat.package,plugin);
(0,_kotlinParser.injectPluginKotlinSync)(c,pluginPlat,key,pluginPlat.package,plugin);
(0,_manifestParser.injectPluginManifestSync)(c,pluginPlat,key,pluginPlat.package,plugin);
(0,_xmlValuesParser.injectPluginXmlValuesSync)(c,pluginPlat,key,pluginPlat.package,plugin);
});

c.pluginConfigAndroid.pluginPackages=c.pluginConfigAndroid.pluginPackages.substring(
0,
c.pluginConfigAndroid.pluginPackages.length-2);



(0,_projectManager.parseFonts)(c,function(font,dir){
if(font.includes('.ttf')||font.includes('.otf')){
var key=font.split('.')[0];var
includedFonts=c.buildConfig.common.includedFonts;
if(includedFonts){
if(
includedFonts.includes('*')||
includedFonts.includes(key))
{
if(font){
var fontSource=_path.default.join(dir,font);
if((0,_fileutils.fsExistsSync)(fontSource)){
var fontFolder=_path.default.join(
appFolder,
'app/src/main/assets/fonts');

(0,_fileutils.mkdirSync)(fontFolder);
var fontDest=_path.default.join(fontFolder,font);
(0,_fileutils.copyFileSync)(fontSource,fontDest);
}else{
(0,_logger.logWarning)("Font "+
(0,_logger.chalk)().white(
fontSource)+" doesn't exist! Skipping.");


}
}
}
}
}
});

(0,_gradleParser.parseSettingsGradleSync)(c);
(0,_gradleParser.parseAppBuildGradleSync)(c);
(0,_gradleParser.parseBuildGradleSync)(c);
(0,_kotlinParser.parseMainActivitySync)(c);
(0,_kotlinParser.parseMainApplicationSync)(c);
(0,_kotlinParser.parseSplashActivitySync)(c);
(0,_xmlValuesParser.parseValuesStringsSync)(c);
(0,_xmlValuesParser.parseValuesColorsSync)(c);
(0,_manifestParser.parseAndroidManifestSync)(c);
(0,_gradleParser.parseGradlePropertiesSync)(c);return _context9.abrupt("return",

true);case 30:case"end":return _context9.stop();}}},null,null,null,Promise);};exports.configureProject=configureProject;



var runAndroidLog=function runAndroidLog(c){var filter,child;return _regenerator.default.async(function runAndroidLog$(_context10){while(1){switch(_context10.prev=_context10.next){case 0:
(0,_logger.logTask)('runAndroidLog');
filter=c.program.filter||'';
child=_execa.default.command(c.cli[_constants.CLI_ANDROID_ADB]+" logcat");

child.stdout.on('data',function(data){
var d=data.toString().split('\n');
d.forEach(function(v){
if(v.includes(' E ')&&v.includes(filter)){
(0,_logger.logRaw)((0,_logger.chalk)().red(v));
}else if(v.includes(' W ')&&v.includes(filter)){
(0,_logger.logRaw)((0,_logger.chalk)().yellow(v));
}else if(v.includes(filter)){
(0,_logger.logRaw)(v);
}
});
});return _context10.abrupt("return",
child.
then(function(res){return res.stdout;}).
catch(function(err){return Promise.reject("Error: "+err);}));case 5:case"end":return _context10.stop();}}},null,null,null,Promise);};exports.runAndroidLog=runAndroidLog;
//# sourceMappingURL=index.js.map