"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.taskRnvTemplateApply = exports["default"] = void 0;var _inquirer = _interopRequireDefault(require("inquirer"));
var _logger = require("../../core/systemManager/logger");
var _templateManager = require("../../core/templateManager");
var _taskManager = require("../../core/taskManager");
var _constants = require("../../core/constants");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { "default": obj };}function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {Promise.resolve(value).then(_next, _throw);}}function _asyncToGenerator(fn) {return function () {var self = this,args = arguments;return new Promise(function (resolve, reject) {var gen = fn.apply(self, args);function _next(value) {asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);}function _throw(err) {asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);}_next(undefined);});};}

var taskRnvTemplateApply = /*#__PURE__*/function () {var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(c, parentTask, originTask) {var opts, _yield$inquirer$promp, template;return regeneratorRuntime.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:
            (0, _logger.logTask)('taskRnvTemplateApply', "template: ".concat(c.program.template));_context.next = 3;return (

              (0, _taskManager.executeTask)(c, _constants.TASK_PROJECT_CONFIGURE, _constants.TASK_TEMPLATE_APPLY, originTask));case 3:if (!

            c.program.template) {_context.next = 10;break;}_context.next = 6;return (
              (0, _templateManager.applyTemplate)(c, c.program.template));case 6:if (!
            c.program.appConfigID) {_context.next = 9;break;}_context.next = 9;return (
              (0, _taskManager.executeTask)(c, _constants.TASK_APP_CONFIGURE, _constants.TASK_TEMPLATE_APPLY, originTask));case 9:return _context.abrupt("return",


            true);case 10:

            opts = (0, _templateManager.getInstalledTemplateOptions)(c);_context.next = 13;return (

              _inquirer["default"].prompt({
                type: 'list',
                message: 'Pick which template to install',
                name: 'template',
                choices: opts.keysAsArray }));case 13:_yield$inquirer$promp = _context.sent;template = _yield$inquirer$promp.template;_context.next = 17;return (


              (0, _templateManager.applyTemplate)(c, template));case 17:if (!
            c.program.appConfigID) {_context.next = 20;break;}_context.next = 20;return (
              (0, _taskManager.executeTask)(c, _constants.TASK_APP_CONFIGURE, _constants.TASK_TEMPLATE_APPLY, originTask));case 20:return _context.abrupt("return",

            true);case 21:case "end":return _context.stop();}}}, _callee);}));return function taskRnvTemplateApply(_x, _x2, _x3) {return _ref.apply(this, arguments);};}();exports.taskRnvTemplateApply = taskRnvTemplateApply;var _default =


{
  description: 'Reset project to specific template',
  fn: taskRnvTemplateApply,
  task: 'template apply',
  params: _constants.PARAMS.withBase(),
  platforms: [] };exports["default"] = _default;
//# sourceMappingURL=task.rnv.template.apply.js.map