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






var _exec=require("../../systemTools/exec");
var _constants=require("../../constants");
var _configParser=require("../../configTools/configParser");

var updateProfile=function updateProfile(c,appConfigId){var _getConfigProp;var scheme,platform,appId,id,teamID,pMethod,runScheme,provisioning,certsPath,args;return _regenerator.default.async(function updateProfile$(_context){while(1){switch(_context.prev=_context.next){case 0:
(0,_common.logTask)("updateProfile:"+appConfigId,_chalk.default.grey);if(!








appConfigId){_context.next=4;break;}_context.next=4;return _regenerator.default.awrap((0,_configParser.setAppConfig)(c,appConfigId));case 4:if(!(

c.platform!==_constants.IOS&&c.platform!==_constants.TVOS)){_context.next=6;break;}return _context.abrupt("return",
Promise.reject("updateProfile:platform "+c.platform+" not supported"));case 6:

scheme=c.program.scheme;


platform=c.platform;

appId=c.runtime.appId;

id=(0,_common.getAppId)(c,platform);
teamID=(0,_common.getConfigProp)(c,platform,'teamID');
pMethod=(_getConfigProp=(0,_common.getConfigProp)(c,platform,'exportOptions'))==null?void 0:_getConfigProp.method;
runScheme=(0,_common.getConfigProp)(c,platform,'runScheme');

if(pMethod==='ad-hoc')provisioning='adhoc';
if(pMethod==='development'||runScheme==='Debug')provisioning='development';

certsPath=_path.default.join(c.paths.workspace.appConfig.dir,'certs');

args=[
'sigh',
'--app_identifier',
id,
'--team_id',
teamID,
'--output_path',
certsPath,
'--force',
'--platform',
platform];

if(process.env.APPLE_DEVELOPER_USERNAME){
args=args.concat([
'--username',
process.env.APPLE_DEVELOPER_USERNAME]);

}
if(provisioning){
args.push("--"+provisioning);
}_context.prev=19;_context.next=22;return _regenerator.default.awrap(


(0,_exec.executeAsync)(c,"fastlane "+args.join(' '),{shell:true,stdio:'inherit',silent:true}));case 22:
(0,_common.logSuccess)("Succesfully updated provisioning profile for "+appId+":"+scheme+":"+id);return _context.abrupt("return",
true);case 26:_context.prev=26;_context.t0=_context["catch"](19);

(0,_common.logWarning)(_context.t0);return _context.abrupt("return",
true);case 30:case"end":return _context.stop();}}},null,null,[[19,26]]);};exports.updateProfile=updateProfile;
//# sourceMappingURL=fastlane.js.map