var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.DEPLOY_TARGET_NONE=exports.DEPLOY_TARGET_NOW=exports.DEPLOY_TARGET_FTP=exports.selectWebToolAndDeploy=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _chalk=_interopRequireDefault(require("chalk"));
var _minimist=_interopRequireDefault(require("minimist"));
var _inquirer=_interopRequireDefault(require("inquirer"));
var _path=_interopRequireDefault(require("path"));

var _now=require("./now");
var _ftp=require("./ftp");
var _common=require("../common");





var _configure=require("./configure");

var DEPLOY_TARGET_DOCKER='docker';
var DEPLOY_TARGET_FTP='ftp';exports.DEPLOY_TARGET_FTP=DEPLOY_TARGET_FTP;
var DEPLOY_TARGET_NOW='now';exports.DEPLOY_TARGET_NOW=DEPLOY_TARGET_NOW;
var DEPLOY_TARGET_NONE='none';exports.DEPLOY_TARGET_NONE=DEPLOY_TARGET_NONE;

var _runDeployment=function _runDeployment(c,platform,deployType){var deployToDocker;return _regenerator.default.async(function _runDeployment$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.t0=
deployType;_context.next=_context.t0===
DEPLOY_TARGET_FTP?3:_context.t0===

DEPLOY_TARGET_NOW?4:_context.t0===

DEPLOY_TARGET_NONE?5:_context.t0===

DEPLOY_TARGET_DOCKER?6:8;break;case 3:return _context.abrupt("return",(0,_ftp.deployToFtp)(c,platform));case 4:return _context.abrupt("return",(0,_now.deployToNow)(c,platform));case 5:return _context.abrupt("return",Promise.resolve());case 6:

deployToDocker=require(_path.default.join(c.paths.project.nodeModulesDir,'/@rnv/deploy-docker')).default;return _context.abrupt("return",
deployToDocker());case 8:return _context.abrupt("return",

Promise.reject(new Error("Deploy Type not supported "+deployType)));case 9:case"end":return _context.stop();}}});};



var selectWebToolAndDeploy=function selectWebToolAndDeploy(c,platform){var argv,deployType,targetConfig,choices,_ref,selectedDeployTarget;return _regenerator.default.async(function selectWebToolAndDeploy$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:
argv=(0,_minimist.default)(c.process.argv.slice(2));
deployType=argv.t;
targetConfig=c.buildConfig.platforms[platform];if(!(

deployType||targetConfig&&targetConfig.deploy&&targetConfig.deploy.type)){_context2.next=7;break;}_context2.next=6;return _regenerator.default.awrap(
(0,_configure.configureDeploymentIfRequired)(deployType||targetConfig.deploy.type));case 6:return _context2.abrupt("return",
_runDeployment(c,platform,deployType||targetConfig.deploy.type));case 7:

choices=[DEPLOY_TARGET_DOCKER,DEPLOY_TARGET_FTP,DEPLOY_TARGET_NOW,DEPLOY_TARGET_NONE];_context2.next=10;return _regenerator.default.awrap(

_inquirer.default.prompt({
name:'selectedDeployTarget',
type:'list',
choices:choices,
message:"Which type of deploy option would you like to use for "+_chalk.default.white(platform)+" deployment?"}));case 10:_ref=_context2.sent;selectedDeployTarget=_ref.selectedDeployTarget;_context2.next=14;return _regenerator.default.awrap(


(0,_configure.configureDeploymentIfRequired)(selectedDeployTarget));case 14:

(0,_common.logInfo)("Setting your appconfig for "+_chalk.default.white(platform)+" to include deploy type: "+_chalk.default.white(selectedDeployTarget)+" at "+_chalk.default.white(c.paths.appConfig.config));return _context2.abrupt("return",
_runDeployment(c,platform,selectedDeployTarget));case 16:case"end":return _context2.stop();}}});};exports.selectWebToolAndDeploy=selectWebToolAndDeploy;