"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.promptSeederTemplate = exports.promptSeedersFolder = void 0;

var _inquirer = _interopRequireDefault(require("inquirer"));

var _lodash = require("lodash");

var _helpers = require("../../utils/helpers");

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 promptSeedersFolder =
/*#__PURE__*/
function () {
  var _ref = _asyncToGenerator(
  /*#__PURE__*/
  regeneratorRuntime.mark(function _callee() {
    var _ref2, seedersFolderName;

    return regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.next = 2;
            return _inquirer["default"].prompt([{
              name: 'seedersFolderName',
              type: 'input',
              message: 'Choose your seeders folder name',
              "default": './seeders',
              filter: function filter(input) {
                return (0, _lodash.trim)(input);
              },
              validate: function validate(input) {
                return (0, _helpers.validateSeedersFolderName)(input);
              }
            }]);

          case 2:
            _ref2 = _context.sent;
            seedersFolderName = _ref2.seedersFolderName;
            return _context.abrupt("return", seedersFolderName);

          case 5:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));

  return function promptSeedersFolder() {
    return _ref.apply(this, arguments);
  };
}();

exports.promptSeedersFolder = promptSeedersFolder;

var promptSeederTemplate =
/*#__PURE__*/
function () {
  var _ref3 = _asyncToGenerator(
  /*#__PURE__*/
  regeneratorRuntime.mark(function _callee2() {
    var _ref4, useCustomSeeder, _ref5, seederTemplatePath;

    return regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            _context2.next = 2;
            return _inquirer["default"].prompt([{
              name: 'useCustomSeeder',
              type: 'confirm',
              message: 'Would you like to use your own custom template for your seeders?',
              "default": false
            }]);

          case 2:
            _ref4 = _context2.sent;
            useCustomSeeder = _ref4.useCustomSeeder;

            if (useCustomSeeder) {
              _context2.next = 6;
              break;
            }

            return _context2.abrupt("return");

          case 6:
            _context2.next = 8;
            return _inquirer["default"].prompt([{
              name: 'seederTemplatePath',
              type: 'input',
              message: 'Choose a path for your seeder template',
              "default": './md-seed-template.ejs',
              filter: function filter(input) {
                return (0, _lodash.trim)(input);
              },
              validate: function validate(input) {
                return (0, _helpers.validateSeederTemplatePath)(input);
              }
            }]);

          case 8:
            _ref5 = _context2.sent;
            seederTemplatePath = _ref5.seederTemplatePath;
            return _context2.abrupt("return", seederTemplatePath);

          case 11:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));

  return function promptSeederTemplate() {
    return _ref3.apply(this, arguments);
  };
}();

exports.promptSeederTemplate = promptSeederTemplate;