var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.parsePodFile=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _path=_interopRequireDefault(require("path"));
var _compareVersions=_interopRequireDefault(require("compare-versions"));
var _common=require("../../common");






var _logger=require("../../systemTools/logger");
var _pluginTools=require("../../pluginTools");
var _resolve=require("../../resolve");
var _exec=require("../../systemTools/exec");

var parsePodFile=function parsePodFile(c,platform){var _c$buildConfig,_c$buildConfig$platfo;var appFolder,pluginInject,ignoreWarnings,podWarnings,podfileObj,podfileSources,deploymentTarget,podVersion,isPodOld;return _regenerator.default.async(function parsePodFile$(_context){while(1){switch(_context.prev=_context.next){case 0:
(0,_logger.logTask)("parsePodFileSync:"+platform);

appFolder=(0,_common.getAppFolder)(c,platform);
pluginInject='';


c.pluginConfigiOS.podfileInject='';
(0,_pluginTools.parsePlugins)(c,platform,function(plugin,pluginPlat,key){
var podName=(0,_common.getFlavouredProp)(c,pluginPlat,'podName');
if(podName){
pluginInject+=_injectPod(podName,pluginPlat,plugin,key);
}
var podNames=(0,_common.getFlavouredProp)(c,pluginPlat,'podNames');
if(podNames){
podNames.forEach(function(v){
pluginInject+=_injectPod(v,pluginPlat,plugin,key);
});
}
var isStatic=(0,_common.getFlavouredProp)(c,pluginPlat,'isStatic');
if(isStatic===true){
if(!c.pluginConfigiOS.staticFrameworks.includes(podName)){
c.pluginConfigiOS.staticFrameworks.push("'"+podName+"'");
}
}
var reactSubSpecs=(0,_common.getFlavouredProp)(c,pluginPlat,'reactSubSpecs');
if(reactSubSpecs){
(0,_logger.logWarning)(
'reactSubSpecs prop is deprecated. yoy can safely remove it');

}

var podfile=(0,_common.getFlavouredProp)(c,pluginPlat,'Podfile');
if(podfile){var
injectLines=podfile.injectLines;

if(injectLines){
injectLines.forEach(function(v){
c.pluginConfigiOS.podfileInject+=v+"\n";
});
}
}
});


ignoreWarnings=(0,_common.getConfigProp)(c,platform,'ignoreWarnings');
podWarnings=ignoreWarnings?'inhibit_all_warnings!':'';


c.pluginConfigiOS.podfileSources='';
podfileObj=(0,_common.getFlavouredProp)(
c,(_c$buildConfig=
c.buildConfig)==null?void 0:(_c$buildConfig$platfo=_c$buildConfig.platforms)==null?void 0:_c$buildConfig$platfo[platform],
'Podfile');

podfileSources=podfileObj==null?void 0:podfileObj.sources;
if(podfileSources&&podfileSources.length){
podfileSources.forEach(function(v){
c.pluginConfigiOS.podfileSources+="source '"+v+"'\n";
});
}


deploymentTarget=(0,_common.getConfigProp)(
c,
platform,
'deploymentTarget',
'10.0');

c.pluginConfigiOS.deploymentTarget=deploymentTarget;


c.pluginConfigiOS.staticPodDefinition='Pod::BuildType.static_library';_context.prev=14;_context.next=17;return _regenerator.default.awrap(

(0,_exec.executeAsync)(c,'pod --version'));case 17:podVersion=_context.sent;
isPodOld=(0,_compareVersions.default)(podVersion,'1.9')<0;
if(isPodOld){
c.pluginConfigiOS.staticPodDefinition='Pod::Target::BuildType.static_library';
}_context.next=24;break;case 22:_context.prev=22;_context.t0=_context["catch"](14);case 24:




(0,_common.writeCleanFile)(
_path.default.join((0,_common.getAppTemplateFolder)(c,platform),'Podfile'),
_path.default.join(appFolder,'Podfile'),
[
{pattern:'{{PLUGIN_PATHS}}',override:pluginInject},
{pattern:'{{PLUGIN_WARNINGS}}',override:podWarnings},
{
pattern:'{{PLUGIN_PODFILE_INJECT}}',
override:c.pluginConfigiOS.podfileInject},

{
pattern:'{{PLUGIN_PODFILE_SOURCES}}',
override:c.pluginConfigiOS.podfileSources},

{
pattern:'{{PLUGIN_DEPLOYMENT_TARGET}}',
override:c.pluginConfigiOS.deploymentTarget},

{
pattern:'{{PLUGIN_STATIC_FRAMEWORKS}}',
override:c.pluginConfigiOS.staticFrameworks.join(',')},

{
pattern:'{{PATH_JSC_ANDROID}}',
override:(0,_resolve.doResolve)('jsc-android')},

{
pattern:'{{PATH_REACT_NATIVE}}',
override:(0,_resolve.doResolve)('react-native')},

{
pattern:'{{PLUGIN_STATIC_POD_DEFINITION}}',
override:c.pluginConfigiOS.staticPodDefinition}]);return _context.abrupt("return",



true);case 26:case"end":return _context.stop();}}},null,null,[[14,22]],Promise);};exports.parsePodFile=parsePodFile;


var _injectPod=function _injectPod(podName,pluginPlat,plugin,key){
var pluginInject='';
var isNpm=plugin['no-npm']!==true;
if(isNpm){var _pluginPlat$path;
var podPath=(0,_resolve.doResolvePath)((_pluginPlat$path=pluginPlat.path)!=null?_pluginPlat$path:key);
pluginInject+="  pod '"+podName+"', :path => '"+podPath+"'\n";
}else if(pluginPlat.git){
var commit=pluginPlat.commit?", :commit => '"+
pluginPlat.commit+"'":
'';
pluginInject+="  pod '"+podName+"', :git => '"+
pluginPlat.git+"'"+
commit+"\n";
}else if(pluginPlat.version){
pluginInject+="  pod '"+podName+"', '"+pluginPlat.version+"'\n";
}else{
pluginInject+="  pod '"+podName+"'\n";
}
return pluginInject;
};
//# sourceMappingURL=podfileParser.js.map