var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.configureProject=exports.configureTizenProject=exports.buildTizenProject=exports.runTizen=exports.addDevelopTizenCertificate=exports.createDevelopTizenCertificate=exports.listTizenTargets=exports.launchTizenSimulator=exports.configureTizenGlobal=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _path=_interopRequireDefault(require("path"));
var _semver=_interopRequireDefault(require("semver"));
var _inquirer=_interopRequireDefault(require("inquirer"));
var _net=_interopRequireDefault(require("net"));

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








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













var _logger=require("../core/systemManager/logger");









var _targetManager=require("../core/targetManager");
var _platformManager=require("../core/platformManager");
var _fileutils=require("../core/systemManager/fileutils");
var _sdkWebpack=require("../sdk-webpack");

var _projectParser=require("../core/projectManager/projectParser");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 xml2js=require('xml2js');

var parser=new xml2js.Parser();


var formatXMLObject=function formatXMLObject(obj){var _obj$modelConfig,_platArr$;
var platArr=(_obj$modelConfig=obj['model-config'])==null?void 0:_obj$modelConfig.platform;
var platKeyArr=(platArr==null?void 0:(_platArr$=platArr[0])==null?void 0:_platArr$.key)||(platArr==null?void 0:platArr.key);
if(platKeyArr){
return _objectSpread({},
platKeyArr.reduce(function(acc,cur){
acc[cur.name]=cur.$t;
return acc;
},{}));

}
(0,_logger.logWarning)('Invalid object received from shell cat /etc/config/model-config.xml');
return{};
};

var DEFAULT_SECURITY_PROFILE_NAME='RNVanillaCert';
var DEFAULT_CERTIFICATE_NAME='tizen_author';
var DEFAULT_CERTIFICATE_NAME_WITH_EXTENSION=DEFAULT_CERTIFICATE_NAME+".p12";

var configureTizenGlobal=function configureTizenGlobal(c){return new Promise(function(resolve,reject){
(0,_logger.logTask)('configureTizenGlobal');


var tizenAuthorCert=_path.default.join(c.paths.workspace.dir,DEFAULT_CERTIFICATE_NAME_WITH_EXTENSION);
if((0,_fileutils.fsExistsSync)(tizenAuthorCert)){
(0,_logger.logDebug)(DEFAULT_CERTIFICATE_NAME_WITH_EXTENSION+" file exists!");
resolve();
}else{
(0,_logger.logWarning)(
DEFAULT_CERTIFICATE_NAME_WITH_EXTENSION+" file missing! Creating one for you...");

createDevelopTizenCertificate(c).
then(function(){return resolve();}).
catch(function(e){return reject(e);});
}

});};exports.configureTizenGlobal=configureTizenGlobal;

var launchTizenSimulator=function launchTizenSimulator(c,name){
(0,_logger.logTask)("launchTizenSimulator:"+name);

if(name){
return(0,_exec.execCLI)(c,_constants.CLI_TIZEN_EMULATOR,"launch --name "+name,{
detached:true});

}
return Promise.reject('No simulator -t target name specified!');
};exports.launchTizenSimulator=launchTizenSimulator;

var listTizenTargets=function listTizenTargets(c){var targets,targetArr,targetStr;return _regenerator.default.async(function listTizenTargets$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return _regenerator.default.awrap(
(0,_exec.execCLI)(c,_constants.CLI_TIZEN_EMULATOR,'list-vm',{
detached:true}));case 2:targets=_context.sent;

targetArr=targets.split('\n');
targetStr='';
Object.keys(targetArr).forEach(function(i){
targetStr+="["+i+"]> "+targetArr[i]+"\n";
});
(0,_logger.logToSummary)("Tizen Targets:\n"+targetStr);case 7:case"end":return _context.stop();}}},null,null,null,Promise);};exports.listTizenTargets=listTizenTargets;


var createDevelopTizenCertificate=function createDevelopTizenCertificate(c){return new Promise(function(resolve){
(0,_logger.logTask)('createDevelopTizenCertificate');

var certDirPath=c.paths.workspace.dir;
var certFilename=DEFAULT_CERTIFICATE_NAME;
var certPassword='1234';

(0,_exec.execCLI)(
c,
_constants.CLI_TIZEN,"certificate -- "+
certDirPath+" -a rnv -f "+certFilename+" -p "+certPassword,
{privateParams:[certPassword]}).

then(function(){return addDevelopTizenCertificate(c,{
profileName:DEFAULT_SECURITY_PROFILE_NAME,
certPath:_path.default.join(certDirPath,certFilename+".p12"),
certPassword:certPassword});}).

then(function(){return resolve();}).
catch(function(e){
(0,_logger.logError)(e);
resolve();
});
});};exports.createDevelopTizenCertificate=createDevelopTizenCertificate;

var addDevelopTizenCertificate=function addDevelopTizenCertificate(c,secureProfileConfig){return new Promise(function(resolve){
(0,_logger.logTask)('addDevelopTizenCertificate');var _ref=

secureProfileConfig||{},profileName=_ref.profileName,certPath=_ref.certPath,certPassword=_ref.certPassword;
(0,_exec.execCLI)(
c,
_constants.CLI_TIZEN,"security-profiles add -n "+
profileName+" -a "+certPath+" -p "+certPassword,
{privateParams:[certPassword]}).

then(function(){return resolve();}).
catch(function(e){
(0,_logger.logError)(e);
resolve();
});
});};exports.addDevelopTizenCertificate=addDevelopTizenCertificate;

var _getDeviceID=function _getDeviceID(c,target){var device,connectResponse,devicesList,lines,devices,deviceID;return _regenerator.default.async(function _getDeviceID$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:
device=c.program.device;if(!

device){_context2.next=17;break;}_context2.prev=2;_context2.next=5;return _regenerator.default.awrap(


(0,_exec.execCLI)(
c,
_constants.CLI_SDB_TIZEN,"connect "+
target));case 5:connectResponse=_context2.sent;_context2.next=11;break;case 8:_context2.prev=8;_context2.t0=_context2["catch"](2);


connectResponse=_context2.t0;case 11:if(!

connectResponse.includes('EPERM')){_context2.next=13;break;}throw(
new Error(
"We can't connect to this device even though it is reachable. Please make sure you have enabled Developer Mode and you have added your IP in the Host PC IP section. For more information consult https://developer.samsung.com/tv/develop/getting-started/using-sdk/tv-device"));case 13:if(!


connectResponse.includes('failed to connect to remote target')){_context2.next=15;break;}throw(
new Error("Failed to connect to "+
target+". Make sure the IP is correct and you are connected on the same network."));case 15:if(!


connectResponse.includes('error')){_context2.next=17;break;}throw new Error(connectResponse);case 17:_context2.next=19;return _regenerator.default.awrap(


(0,_exec.execCLI)(c,_constants.CLI_SDB_TIZEN,'devices'));case 19:devicesList=_context2.sent;if(!
devicesList.includes(target)){_context2.next=26;break;}
lines=devicesList.trim().split(/\r?\n/);
devices=lines.filter(function(line){return line.includes(target);});

if(devices.length>1){

}

deviceID=devices[0].split('device')[1].trim();return _context2.abrupt("return",
deviceID);case 26:return _context2.abrupt("return",

Promise.reject("No device matching "+target+" could be found."));case 27:case"end":return _context2.stop();}}},null,null,[[2,8]],Promise);};


var _getRunningDevices=function _getRunningDevices(c){var platform,devicesList,lines,devices;return _regenerator.default.async(function _getRunningDevices$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:
platform=c.program.platform;_context4.next=3;return _regenerator.default.awrap(
(0,_exec.execCLI)(c,_constants.CLI_SDB_TIZEN,'devices'));case 3:devicesList=_context4.sent;
lines=devicesList.
trim().
split(/\r?\n/).
filter(function(line){return!line.includes('List of devices');});
devices=[];_context4.next=8;return _regenerator.default.awrap(

Promise.all(
lines.map(function _callee(line){var words,name,deviceInfoXML,deviceInfo,deviceType,parseObj;return _regenerator.default.async(function _callee$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:
words=line.replace(/\t/g,'').split('    ');if(!(
words.length>=3)){_context3.next=13;break;}
name=words[0].trim();_context3.next=5;return _regenerator.default.awrap(
(0,_exec.execCLI)(
c,
_constants.CLI_SDB_TIZEN,"-s "+
name+" shell cat /etc/config/model-config.xml",
{ignoreErrors:true}));case 5:deviceInfoXML=_context3.sent;if(!(





deviceInfoXML!==true&&deviceInfoXML!=='')){_context3.next=12;break;}_context3.next=9;return _regenerator.default.awrap(


parser.parseStringPromise(deviceInfoXML));case 9:parseObj=_context3.sent;

deviceInfo=formatXMLObject(parseObj);
deviceType=deviceInfo['tizen.org/feature/profile'];case 12:


if(
platform==='tizenmobile'&&deviceType==='mobile'||
platform==='tizenwatch'&&deviceType==='wearable'||
platform==='tizen'&&!deviceType)
{
devices.push({
name:name,
type:words[1].trim(),
id:words[2].trim(),
deviceType:deviceType});

}case 13:case"end":return _context3.stop();}}},null,null,null,Promise);})));case 8:return _context4.abrupt("return",




devices);case 9:case"end":return _context4.stop();}}},null,null,null,Promise);};


var _waitForEmulatorToBeReady=function _waitForEmulatorToBeReady(c,target){return(0,_targetManager.waitForEmulator)(c,_constants.CLI_SDB_TIZEN,'devices',function(res){
var lines=res.trim().split(/\r?\n/);
var devices=lines.filter(
function(line){return line.includes(target)&&line.includes('device');});

return devices.length>0;
});};

var _composeDevicesString=function _composeDevicesString(devices){return devices.map(function(device){return{
key:device.id,
name:device.name,
value:device.id};});};








var _runTizenSimOrDevice=function _runTizenSimOrDevice(c){var _platformConfig$certi;var hosted,target,platform,platformConfig,bundleAssets,isHosted,tDir,tBuild,tOut,tId,wgt,certProfile,deviceID,askForEmulator,continueLaunching,isTargetSpecified,devices,targetDevice,choices,_await$inquirer$promp2,chosenEmulator;return _regenerator.default.async(function _runTizenSimOrDevice$(_context7){while(1){switch(_context7.prev=_context7.next){case 0:
hosted=c.program.hosted;
target=c.runtime.target;
platform=c.platform;

platformConfig=c.buildConfig.platforms[platform];
bundleAssets=(0,_common.getConfigProp)(c,platform,'bundleAssets');
isHosted=hosted!=null?hosted:!bundleAssets;

if(!bundleAssets&&!hosted){

}if(

platformConfig){_context7.next=9;break;}throw(
new Error("runTizen: "+
(0,_logger.chalk)().grey(
platform)+" not defined in your "+
(0,_logger.chalk)().white(c.paths.appConfig.config)));case 9:if(


platformConfig.appName){_context7.next=11;break;}throw(
new Error("runTizen: "+
(0,_logger.chalk)().grey(
platform)+".appName not defined in your "+
(0,_logger.chalk)().white(
c.paths.appConfig.config)));case 11:




tDir=(0,_common.getPlatformProjectDir)(c);
tBuild=_path.default.join(tDir,'build');
tOut=_path.default.join(tDir,'output');
tId=platformConfig.id;
wgt=platformConfig.appName+".wgt";
certProfile=(_platformConfig$certi=platformConfig.certificateProfile)!=null?_platformConfig$certi:DEFAULT_SECURITY_PROFILE_NAME;



askForEmulator=function askForEmulator(){var _await$inquirer$promp,startEmulator,defaultTarget;return _regenerator.default.async(function askForEmulator$(_context5){while(1){switch(_context5.prev=_context5.next){case 0:_context5.next=2;return _regenerator.default.awrap(
_inquirer.default.prompt([
{
name:'startEmulator',
type:'confirm',
message:"Could not find or connect to the specified target ("+
target+"). Would you like to start an emulator?"}]));case 2:_await$inquirer$promp=_context5.sent;startEmulator=_await$inquirer$promp.startEmulator;if(!




startEmulator){_context5.next=33;break;}
defaultTarget=c.files.workspace.config.defaultTargets[platform];_context5.prev=6;_context5.next=9;return _regenerator.default.awrap(

launchTizenSimulator(c,defaultTarget));case 9:
deviceID=defaultTarget;_context5.next=12;return _regenerator.default.awrap(
_waitForEmulatorToBeReady(c,defaultTarget));case 12:return _context5.abrupt("return",
continueLaunching());case 15:_context5.prev=15;_context5.t0=_context5["catch"](6);

(0,_logger.logDebug)("askForEmulator:ERRROR: "+_context5.t0);_context5.prev=18;_context5.next=21;return _regenerator.default.awrap(

(0,_exec.execCLI)(
c,
_constants.CLI_TIZEN_EMULATOR,"create -n "+
defaultTarget+" -p tv-samsung-5.0-x86"));case 21:_context5.next=23;return _regenerator.default.awrap(

launchTizenSimulator(c,defaultTarget));case 23:
deviceID=defaultTarget;_context5.next=26;return _regenerator.default.awrap(
_waitForEmulatorToBeReady(c,defaultTarget));case 26:return _context5.abrupt("return",
continueLaunching());case 29:_context5.prev=29;_context5.t1=_context5["catch"](18);

(0,_logger.logDebug)(_context5.t1);
(0,_logger.logError)("Could not find the specified target and could not create the emulator automatically.\nPlease create one and then edit the default target from "+

c.paths.workspace.dir+"/"+_constants.RENATIVE_CONFIG_NAME);case 33:case"end":return _context5.stop();}}},null,null,[[6,15],[18,29]],Promise);};






continueLaunching=function continueLaunching(){var hasDevice,packageID,toReturn,_packageID;return _regenerator.default.async(function continueLaunching$(_context6){while(1){switch(_context6.prev=_context6.next){case 0:
hasDevice=false;_context6.t0=

!isHosted;if(!_context6.t0){_context6.next=5;break;}_context6.next=5;return _regenerator.default.awrap((0,_sdkWebpack.buildWeb)(c));case 5:_context6.next=7;return _regenerator.default.awrap(
(0,_exec.execCLI)(c,_constants.CLI_TIZEN,"build-web -- "+tDir+" -out "+tBuild));case 7:_context6.next=9;return _regenerator.default.awrap(
(0,_exec.execCLI)(
c,
_constants.CLI_TIZEN,"package -- "+
tBuild+" -s "+certProfile+" -t wgt -o "+tOut));case 9:_context6.prev=9;



packageID=platform==='tizenwatch'||platform==='tizenmobile'?
tId.split('.')[0]:
tId;_context6.next=13;return _regenerator.default.awrap(
(0,_exec.execCLI)(
c,
_constants.CLI_TIZEN,"uninstall -p "+
packageID+" -t "+deviceID,
{ignoreErrors:true}));case 13:

hasDevice=true;_context6.next=24;break;case 16:_context6.prev=16;_context6.t1=_context6["catch"](9);if(!(

_context6.t1&&_context6.t1.includes&&_context6.t1.includes('No device matching'))){_context6.next=24;break;}_context6.next=21;return _regenerator.default.awrap(
launchTizenSimulator(c,target));case 21:_context6.next=23;return _regenerator.default.awrap(
_waitForEmulatorToBeReady(c,target));case 23:hasDevice=_context6.sent;case 24:_context6.prev=24;_context6.next=27;return _regenerator.default.awrap(



(0,_exec.execCLI)(
c,
_constants.CLI_TIZEN,"install -- "+
tOut+" -n "+wgt+" -t "+deviceID));case 27:

hasDevice=true;_context6.next=39;break;case 30:_context6.prev=30;_context6.t2=_context6["catch"](24);

(0,_logger.logError)(_context6.t2);
(0,_logger.logWarning)("There is no emulator or device connected! Let's try to launch it. \""+
(0,_logger.chalk)().white.bold("rnv target launch -p "+
platform+" -t "+target)+"\"");_context6.next=36;return _regenerator.default.awrap(



launchTizenSimulator(c,target));case 36:_context6.next=38;return _regenerator.default.awrap(
_waitForEmulatorToBeReady(c,target));case 38:hasDevice=_context6.sent;case 39:


toReturn=true;if(!(







platform!=='tizenwatch'&&
platform!=='tizenmobile'&&
hasDevice)){_context6.next=45;break;}_context6.next=43;return _regenerator.default.awrap(

(0,_exec.execCLI)(c,_constants.CLI_TIZEN,"run -p "+tId+" -t "+deviceID));case 43:_context6.next=49;break;case 45:if(!(

(platform==='tizenwatch'||platform==='tizenmobile')&&
hasDevice)){_context6.next=49;break;}

_packageID=tId.split('.');_context6.next=49;return _regenerator.default.awrap(
(0,_exec.execCLI)(
c,
_constants.CLI_TIZEN,"run -p "+
_packageID[0]+" -t "+deviceID));case 49:return _context6.abrupt("return",


toReturn);case 50:case"end":return _context6.stop();}}},null,null,[[9,16],[24,30]],Promise);};



isTargetSpecified=c.program.target;_context7.next=22;return _regenerator.default.awrap(


_getRunningDevices(c));case 22:devices=_context7.sent;if(!

isTargetSpecified){_context7.next=48;break;}if(!

_net.default.isIP(target)){_context7.next=29;break;}_context7.next=27;return _regenerator.default.awrap(
_getDeviceID(c,target));case 27:deviceID=_context7.sent;return _context7.abrupt("return",
continueLaunching());case 29:if(!(


devices.length>0)){_context7.next=34;break;}
targetDevice=devices.find(
function(device){return device.id===target||device.name===target;});if(!

targetDevice){_context7.next=34;break;}
deviceID=targetDevice.id;return _context7.abrupt("return",
continueLaunching());case 34:_context7.prev=34;_context7.next=37;return _regenerator.default.awrap(




launchTizenSimulator(c,target));case 37:_context7.next=39;return _regenerator.default.awrap(
_waitForEmulatorToBeReady(c,target));case 39:
deviceID=target;return _context7.abrupt("return",
continueLaunching());case 43:_context7.prev=43;_context7.t0=_context7["catch"](34);return _context7.abrupt("return",

askForEmulator());case 46:_context7.next=60;break;case 48:if(!(


devices.length===1)){_context7.next=51;break;}
deviceID=devices[0].id;return _context7.abrupt("return",
continueLaunching());case 51:if(!(

devices.length>1)){_context7.next=59;break;}
choices=_composeDevicesString(devices);_context7.next=55;return _regenerator.default.awrap(
_inquirer.default.prompt([
{
name:'chosenEmulator',
type:'list',
message:'On what emulator would you like to run the app?',
choices:choices}]));case 55:_await$inquirer$promp2=_context7.sent;chosenEmulator=_await$inquirer$promp2.chosenEmulator;


deviceID=chosenEmulator;return _context7.abrupt("return",
continueLaunching());case 59:return _context7.abrupt("return",

askForEmulator());case 60:case"end":return _context7.stop();}}},null,null,[[34,43]],Promise);};



var runTizen=function runTizen(c,target){var platform,hosted,isHosted,isPortActive,resetCompleted,bundleAssets,_isPortActive,isWeinreEnabled,_resetCompleted;return _regenerator.default.async(function runTizen$(_context8){while(1){switch(_context8.prev=_context8.next){case 0:
(0,_logger.logTask)('runTizen',"target:"+target);
platform=c.platform;
hosted=c.program.hosted;


isHosted=hosted&&!(0,_common.getConfigProp)(c,platform,'bundleAssets');if(!

isHosted){_context8.next=13;break;}_context8.next=7;return _regenerator.default.awrap(
(0,_common.checkPortInUse)(c,platform,c.runtime.port));case 7:isPortActive=_context8.sent;if(!
isPortActive){_context8.next=13;break;}_context8.next=11;return _regenerator.default.awrap(
(0,_common.confirmActiveBundler)(c));case 11:resetCompleted=_context8.sent;
c.runtime.skipActiveServerCheck=!resetCompleted;case 13:



(0,_logger.logTask)('runWebOS',"target:"+target+" hosted:"+!!isHosted);if(!
isHosted){_context8.next=16;break;}return _context8.abrupt("return");case 16:

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

bundleAssets){_context8.next=24;break;}_context8.next=20;return _regenerator.default.awrap(
(0,_sdkWebpack.buildWeb)(c));case 20:_context8.next=22;return _regenerator.default.awrap(
_runTizenSimOrDevice(c));case 22:_context8.next=46;break;case 24:_context8.next=26;return _regenerator.default.awrap(

(0,_common.checkPortInUse)(c,platform,c.runtime.port));case 26:_isPortActive=_context8.sent;
isWeinreEnabled=_constants.WEINRE_ENABLED_PLATFORMS.includes(platform)&&!bundleAssets&&!hosted;if(

_isPortActive){_context8.next=35;break;}
(0,_logger.logInfo)("Your "+
(0,_logger.chalk)().white(
platform)+" devServer at port "+
(0,_logger.chalk)().white(
c.runtime.port)+" is not running. Starting it up for you...");


(0,_sdkWebpack.waitForWebpack)(c).
then(function(){return _runTizenSimOrDevice(c);}).
catch(_logger.logError);_context8.next=33;return _regenerator.default.awrap(
(0,_sdkWebpack.runWebpackServer)(c,isWeinreEnabled));case 33:_context8.next=46;break;case 35:_context8.next=37;return _regenerator.default.awrap(

(0,_common.confirmActiveBundler)(c));case 37:_resetCompleted=_context8.sent;if(!

_resetCompleted){_context8.next=44;break;}
(0,_sdkWebpack.waitForWebpack)(c).
then(function(){return _runTizenSimOrDevice(c);}).
catch(_logger.logError);_context8.next=42;return _regenerator.default.awrap(
(0,_sdkWebpack.runWebpackServer)(c,isWeinreEnabled));case 42:_context8.next=46;break;case 44:_context8.next=46;return _regenerator.default.awrap(

_runTizenSimOrDevice(c));case 46:case"end":return _context8.stop();}}},null,null,null,Promise);};exports.runTizen=runTizen;





var buildTizenProject=function buildTizenProject(c){var platform,platformConfig,tDir,_platformConfig$certi2,_tOut,_tBuild,_certProfile;return _regenerator.default.async(function buildTizenProject$(_context9){while(1){switch(_context9.prev=_context9.next){case 0:
(0,_logger.logTask)('buildTizenProject');

platform=c.platform;

platformConfig=c.buildConfig.platforms[platform];
tDir=(0,_common.getPlatformProjectDir)(c);_context9.next=6;return _regenerator.default.awrap(

(0,_sdkWebpack.buildWeb)(c));case 6:if(
c.program.hosted){_context9.next=15;break;}
_tOut=_path.default.join(tDir,'output');
_tBuild=_path.default.join(tDir,'build');
_certProfile=(_platformConfig$certi2=platformConfig.certificateProfile)!=null?_platformConfig$certi2:DEFAULT_SECURITY_PROFILE_NAME;_context9.next=12;return _regenerator.default.awrap(

(0,_exec.execCLI)(c,_constants.CLI_TIZEN,"build-web -- "+tDir+" -out "+_tBuild));case 12:_context9.next=14;return _regenerator.default.awrap(
(0,_exec.execCLI)(
c,
_constants.CLI_TIZEN,"package -- "+
_tBuild+" -s "+_certProfile+" -t wgt -o "+_tOut));case 14:


(0,_logger.logSuccess)("Your WGT package is located in "+
(0,_logger.chalk)().cyan(_tOut)+" .");case 15:return _context9.abrupt("return",



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


var _isGlobalConfigured=false;

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

platform=c.platform;

c.runtime.platformBuildsProjectPath=""+(0,_common.getPlatformProjectDir)(c);if(

(0,_platformManager.isPlatformActive)(c,platform)){_context10.next=5;break;}return _context10.abrupt("return");case 5:if(



_isGlobalConfigured){_context10.next=9;break;}
_isGlobalConfigured=true;_context10.next=9;return _regenerator.default.awrap(
configureTizenGlobal(c));case 9:


bundleAssets=(0,_common.getConfigProp)(c,platform,'bundleAssets')===true;_context10.next=12;return _regenerator.default.awrap(

(0,_projectParser.copyAssetsFolder)(c,platform));case 12:_context10.next=14;return _regenerator.default.awrap(
(0,_sdkWebpack.configureCoreWebProject)(c,bundleAssets?_constants.RNV_PROJECT_DIR_NAME:_constants.RNV_SERVER_DIR_NAME));case 14:_context10.next=16;return _regenerator.default.awrap(
configureProject(c));case 16:return _context10.abrupt("return",
(0,_projectParser.copyBuildsFolder)(c,platform));case 17:case"end":return _context10.stop();}}},null,null,null,Promise);};exports.configureTizenProject=configureTizenProject;


var configureProject=function configureProject(c){return new Promise(function(resolve){
(0,_logger.logTask)('configureProject');var
platform=c.platform;

var configFile='config.xml';
var p=c.buildConfig.platforms[platform];

var injects=[
{pattern:'{{PACKAGE}}',override:p.package},
{pattern:'{{ID}}',override:p.id},
{pattern:'{{APP_NAME}}',override:p.appName},
{pattern:'{{APP_VERSION}}',override:_semver.default.coerce((0,_common.getAppVersion)(c,platform))}];


(0,_common.addSystemInjects)(c,injects);

(0,_fileutils.writeCleanFile)(
_path.default.join((0,_common.getTemplateProjectDir)(c),configFile),
_path.default.join((0,_common.getPlatformProjectDir)(c),configFile),
injects,null,c);


resolve();
});};exports.configureProject=configureProject;
//# sourceMappingURL=index.js.map