"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.taskRnvNew = exports["default"] = void 0;var _inquirer = _interopRequireDefault(require("inquirer"));
var _lodash = _interopRequireDefault(require("lodash.set"));
var _path = _interopRequireDefault(require("path"));
var _semver = _interopRequireDefault(require("semver"));
var _constants = require("../../core/constants");
var _templateManager = require("../../core/templateManager");
var _fileutils = require("../../core/systemManager/fileutils");


var _projectManager = require("../../core/projectManager");
var _workspace = require("../../core/projectManager/workspace");
var _runtimeManager = require("../../core/runtimeManager");
var _analytics = _interopRequireDefault(require("../../core/systemManager/analytics"));
var _exec = require("../../core/systemManager/exec");

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












var _npmUtils = require("../../core/systemManager/npmUtils");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { "default": obj };}function ownKeys(object, enumerableOnly) {var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {var symbols = Object.getOwnPropertySymbols(object);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 = null != arguments[i] ? arguments[i] : {};i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {_defineProperty(target, key, source[key]);}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));});}return target;}function _defineProperty(obj, key, value) {if (key in obj) {Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });} else {obj[key] = value;}return 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 highlight = (0, _logger.chalk)().green;

var _prepareProjectOverview = function _prepareProjectOverview(c, data) {
  data.appTitle = data.inputAppTitle || data.defaultAppTitle;
  data.teamID = '';
  data.appID = data.inputAppID ?
  data.inputAppID.replace(/\s+/g, '-').toLowerCase() :
  data.appID;
  data.version = data.inputVersion || data.defaultVersion;
  var tempString = "".concat(data.optionTemplates.selectedOption, "@").concat(
  data.optionTemplates.selectedVersion);


  var str = (0, _logger.printBoxStart)('🚀  ReNative Project Generator');
  str += (0, _logger.printIntoBox)('');
  str += (0, _logger.printIntoBox)("Project Name (folder): ".concat(
  highlight(data.projectName)),
  1);

  str += (0, _logger.printIntoBox)("Workspace: ".concat(
  highlight(data.optionWorkspaces.selectedOption)),
  1);

  str += (0, _logger.printIntoBox)("Project Title: ".concat(highlight(data.appTitle)), 1);
  str += (0, _logger.printIntoBox)("Project Version: ".concat(highlight(data.version)), 1);
  str += (0, _logger.printIntoBox)("App ID: ".concat(highlight(data.appID)), 1);
  str += (0, _logger.printIntoBox)("Project Template: ".concat(highlight(tempString)), 1);
  str += (0, _logger.printIntoBox)("Git Enabled: ".concat(highlight(data.gitEnabled)), 1);
  str += (0, _logger.printIntoBox)('');
  str += (0, _logger.printIntoBox)('Project Platforms:');
  str += (0, _logger.printArrIntoBox)(data.optionPlatforms.selectedOptions);
  str += (0, _logger.printIntoBox)('');
  str += (0, _logger.printIntoBox)('Project Structure:');
  str += (0, _logger.printIntoBox)('');
  str += (0, _logger.printIntoBox)(data.projectName);
  str += (0, _logger.chalk)().
  gray("\u2502   \u251C\u2500\u2500 appConfigs            # Application flavour configuration files/assets \u2502\n\u2502   \u2502   \u2514\u2500\u2500 [APP_ID]          # Example application flavour                    \u2502\n\u2502   \u2502       \u251C\u2500\u2500 assets        # Platform assets injected to ./platformAssets   \u2502\n\u2502   \u2502       \u251C\u2500\u2500 builds        # Platform files injected to ./platformBuilds    \u2502\n\u2502   \u2502       \u251C\u2500\u2500 fonts             # Folder for all custom fonts                \u2502\n\u2502   \u2502       \u251C\u2500\u2500 plugins           # Multi-platform plugins injections          \u2502\n\u2502   \u2502       \u2514\u2500\u2500 renative.json # Application flavour config                     \u2502\n\u2502   \u251C\u2500\u2500 platformAssets        # Generated cross-platform assets                \u2502\n\u2502   \u251C\u2500\u2500 platformBuilds        # Generated platform app projects                \u2502\n\u2502   \u251C\u2500\u2500 src                   # Source code files                              \u2502\n\u2502   \u251C\u2500\u2500 index.*.js            # Entry files                                    \u2502\n\u2502   \u2514\u2500\u2500 renative.json         # ReNative project configuration                 \u2502\n");












  str += (0, _logger.printIntoBox)('');
  str += (0, _logger.printBoxEnd)();
  str += '\n';

  data.confirmString = str;
};

var interactiveQuestion = /*#__PURE__*/function () {var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(results, bootstrapQuestions) {var key,_loop,i,_args2 = arguments;return regeneratorRuntime.wrap(function _callee$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:key = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : '';if (!(
            bootstrapQuestions !== null && bootstrapQuestions !== void 0 && bootstrapQuestions.length)) {_context2.next = 9;break;}_loop = /*#__PURE__*/regeneratorRuntime.mark(function _loop(
            i) {var _choicesObj$result$qK, _choicesObj$result$qK2;var q, choicesObj, qKey, inqQuestion, result, val;return regeneratorRuntime.wrap(function _loop$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:
                      q = bootstrapQuestions[i];
                      choicesObj = {};
                      if (q.options) {
                        q.options.forEach(function (opt) {
                          choicesObj[opt.title] = opt;
                        });
                      }
                      qKey = "".concat(key, "q").concat(i);
                      // inquirerObj[qKey] = { ...q, choicesObj };
                      inqQuestion = {
                        name: qKey,
                        type: q.type,
                        message: q.title,
                        choices: Object.keys(choicesObj) };

                      // eslint-disable-next-line no-await-in-loop
                      _context.next = 7;return _inquirer["default"].prompt(inqQuestion);case 7:result = _context.sent;
                      val = q.type === 'list' ? (_choicesObj$result$qK = choicesObj[result[qKey]]) === null || _choicesObj$result$qK === void 0 ? void 0 : _choicesObj$result$qK.value : result[qKey];
                      results[qKey] = {
                        answer: result[qKey],
                        configProp: q.configProp,
                        value: val };if (!((_choicesObj$result$qK2 =

                      choicesObj[result[qKey]]) !== null && _choicesObj$result$qK2 !== void 0 && _choicesObj$result$qK2.bootstrapQuestions)) {_context.next = 13;break;}_context.next = 13;return (

                        interactiveQuestion(
                        results,
                        choicesObj[result[qKey]].bootstrapQuestions,
                        qKey));case 13:case "end":return _context.stop();}}}, _loop);});i = 0;case 4:if (!(i < bootstrapQuestions.length)) {_context2.next = 9;break;}return _context2.delegateYield(_loop(i), "t0", 6);case 6:i++;_context2.next = 4;break;case 9:case "end":return _context2.stop();}}}, _callee);}));return function interactiveQuestion(_x, _x2) {return _ref.apply(this, arguments);};}();






var taskRnvNew = /*#__PURE__*/function () {var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(c) {var _renativeTemplateConf, _renativeTemplateConf2;var _c$program, ci, projectName, title, id, appVersion, workspace, projectTemplate, templateVersion, platform, _yield$inquirer$promp, confirmInRnvProject, _yield$inquirer$promp2, confirmDeleteNodeModules, data, inputProjectName, inputProjectNameObj, _yield$inquirer$promp3, confirm, inputAppTitle, inputAppID, inputVersion, answers, inputWorkspace, answer, customTemplate, selectedInputTemplate, _yield$inquirer$promp4, inputTemplate, _yield$inquirer$promp5, inputTemplateCustom, inputTemplateVersion, _yield$inquirer$promp6, confirmAddTemplate, _c$files$workspace$co, renativeTemplateConfig, supportedPlatforms, inputSupportedPlatforms, _answer, renativeTemplateConfigExt, bootstrapQuestions, results, _yield$inquirer$promp7, gitEnabled, _yield$inquirer$promp8, _confirm, templates, config, supPlats;return regeneratorRuntime.wrap(function _callee2$(_context3) {while (1) {switch (_context3.prev = _context3.next) {case 0:
            (0, _logger.logTask)('taskRnvNew');_c$program =










            c.program, ci = _c$program.ci, projectName = _c$program.projectName, title = _c$program.title, id = _c$program.id, appVersion = _c$program.appVersion, workspace = _c$program.workspace, projectTemplate = _c$program.projectTemplate, templateVersion = _c$program.templateVersion, platform = _c$program.platform;if (!

            (0, _fileutils.fsExistsSync)(c.paths.project.config)) {_context3.next = 10;break;}
            (0, _logger.logWarning)("You are in ReNative project. Found: ".concat(c.paths.project.config));_context3.next = 6;return (
              _inquirer["default"].prompt({
                name: 'confirmInRnvProject',
                type: 'confirm',
                message: 'Are you sure you want to continue?' }));case 6:_yield$inquirer$promp = _context3.sent;confirmInRnvProject = _yield$inquirer$promp.confirmInRnvProject;if (

            confirmInRnvProject) {_context3.next = 10;break;}return _context3.abrupt("return",
            Promise.reject('Cancelled'));case 10:if (!



            (0, _fileutils.fsExistsSync)(c.paths.project.nodeModulesDir)) {_context3.next = 19;break;}
            (0, _logger.logWarning)("Found node_modules directory at your location. If you continue it will be deleted: ".concat(

            c.paths.project.nodeModulesDir));_context3.next = 14;return (


              _inquirer["default"].prompt({
                name: 'confirmDeleteNodeModules',
                type: 'confirm',
                message: 'Are you sure you want to continue?' }));case 14:_yield$inquirer$promp2 = _context3.sent;confirmDeleteNodeModules = _yield$inquirer$promp2.confirmDeleteNodeModules;if (!

            confirmDeleteNodeModules) {_context3.next = 19;break;}_context3.next = 19;return (
              (0, _fileutils.removeDirs)([c.paths.project.nodeModulesDir]));case 19:



            data = {
              defaultVersion: '0.1.0',
              defaultTemplate: 'renative-template-hello-world',
              defaultProjectName: 'helloRenative',
              defaultAppTitle: 'Hello Renative',
              defaultWorkspace: 'rnv' };

            data.optionPlatforms = {};
            data.optionTemplates = {};
            data.optionWorkspaces = (0, _workspace.getWorkspaceOptions)(c);

            // ==================================================
            // INPUT: Project Name
            // ==================================================
            if (!(


            projectName && projectName !== '')) {_context3.next = 27;break;}
            inputProjectName = projectName;_context3.next = 31;break;case 27:_context3.next = 29;return (

              _inquirer["default"].prompt({
                name: 'inputProjectName',
                type: 'input',
                validate: function validate(value) {return !!value;},
                message:
                "What's your project Name? (no spaces, folder based on ID will be created in this directory)" }));case 29:inputProjectNameObj = _context3.sent;

            inputProjectName = inputProjectNameObj === null || inputProjectNameObj === void 0 ? void 0 : inputProjectNameObj.inputProjectName;case 31:


            data.projectName = inputProjectName;
            c.paths.project.dir = _path["default"].join(
            _constants.CURRENT_DIR,
            data.projectName.replace(/(\s+)/g, '_'));if (!


            (0, _fileutils.fsExistsSync)(c.paths.project.dir)) {_context3.next = 42;break;}_context3.next = 36;return (
              _inquirer["default"].prompt({
                type: 'confirm',
                name: 'confirm',
                message: "Folder ".concat(
                c.paths.project.dir, " already exists. RNV will override it. Continue?") }));case 36:_yield$inquirer$promp3 = _context3.sent;confirm = _yield$inquirer$promp3.confirm;if (



            confirm) {_context3.next = 40;break;}return _context3.abrupt("return",
            Promise.reject('Cancelled by user'));case 40:_context3.next = 42;return (

              (0, _fileutils.cleanFolder)(c.paths.project.dir));case 42:


            (0, _fileutils.mkdirSync)(c.paths.project.dir);

            // ==================================================
            // INPUT: Project Title, ID, Version
            // ==================================================
            if (!(



            title &&
            title !== '' &&
            id &&
            id !== '' &&
            appVersion &&
            appVersion !== '')) {_context3.next = 49;break;}

            inputAppTitle = title;
            inputAppID = id;
            inputVersion = appVersion;_context3.next = 55;break;case 49:_context3.next = 51;return (

              _inquirer["default"].prompt([
              {
                name: 'inputAppTitle',
                type: 'input',
                "default": data.defaultAppTitle,
                validate: function validate(val) {return !!val || 'Please enter a title';},
                message: "What's your project Title?" },

              {
                name: 'inputAppID',
                type: 'input',
                "default": function _default() {
                  data.appID = "com.mycompany.".concat(inputProjectName.
                  replace(/\s+/g, '').
                  toLowerCase());
                  return data.appID;
                },
                validate: function validate(appId) {return !!appId.match(/[a-z]+\.[a-z0-9]+\.[a-z0-9]+/) ||
                  'Please enter a valid appID (com.test.app)';},
                message: "What's your App ID?" },

              {
                name: 'inputVersion',
                type: 'input',
                "default": data.defaultVersion,
                validate: function validate(v) {return !!_semver["default"].valid(_semver["default"].coerce(v)) ||
                  'Please enter a valid semver version (1.0.0, 42.6.7.9.3-alpha, etc.)';},
                message: "What's your Version?" }]));case 51:answers = _context3.sent;


            inputAppTitle = answers === null || answers === void 0 ? void 0 : answers.inputAppTitle;
            inputAppID = answers === null || answers === void 0 ? void 0 : answers.inputAppID;
            inputVersion = answers === null || answers === void 0 ? void 0 : answers.inputVersion;case 55:if (!(






            workspace && workspace !== '')) {_context3.next = 59;break;}
            inputWorkspace = workspace;_context3.next = 63;break;case 59:_context3.next = 61;return (

              _inquirer["default"].prompt([
              {
                name: 'inputWorkspace',
                type: 'list',
                message: 'What workspace to use?',
                "default": data.defaultWorkspace,
                choices: data.optionWorkspaces.keysAsArray }]));case 61:answer = _context3.sent;



            inputWorkspace = answer === null || answer === void 0 ? void 0 : answer.inputWorkspace;case 63:

            data.optionWorkspaces.selectedOption = inputWorkspace;
            c.runtime.selectedWorkspace = inputWorkspace;_context3.next = 67;return (

              (0, _runtimeManager.updateRenativeConfigs)(c));case 67:
            data.optionTemplates = (0, _templateManager.getTemplateOptions)(c);

            // ==================================================
            // INPUT: Template
            // ==================================================
            customTemplate = 'Custom Template ...';

            data.optionTemplates.keysAsArray.push(customTemplate);if (!(

            projectTemplate && projectTemplate !== '')) {_context3.next = 74;break;}
            selectedInputTemplate = projectTemplate;_context3.next = 87;break;case 74:_context3.next = 76;return (

              _inquirer["default"].prompt({
                name: 'inputTemplate',
                type: 'list',
                message: 'What template to use?',
                "default": data.defaultTemplate,
                choices: data.optionTemplates.keysAsArray }));case 76:_yield$inquirer$promp4 = _context3.sent;inputTemplate = _yield$inquirer$promp4.inputTemplate;if (!(


            inputTemplate === customTemplate)) {_context3.next = 86;break;}_context3.next = 81;return (
              _inquirer["default"].prompt({
                name: 'inputTemplateCustom',
                type: 'input',
                message: 'Type exact name of your template NPM package.' }));case 81:_yield$inquirer$promp5 = _context3.sent;inputTemplateCustom = _yield$inquirer$promp5.inputTemplateCustom;

            selectedInputTemplate = inputTemplateCustom;_context3.next = 87;break;case 86:

            selectedInputTemplate = inputTemplate;case 87:



            data.optionTemplates.selectedOption = selectedInputTemplate;if (!(


            templateVersion && templateVersion !== '')) {_context3.next = 92;break;}
            inputTemplateVersion = templateVersion;_context3.next = 95;break;case 92:_context3.next = 94;return (

              (0, _npmUtils.listAndSelectNpmVersion)(
              c,
              data.optionTemplates.selectedOption,
              Object.keys(c.files.rnv.projectTemplates.config.projectTemplates)));case 94:inputTemplateVersion = _context3.sent;case 95:



            data.optionTemplates.selectedVersion = inputTemplateVersion;_context3.next = 98;return (

              (0, _npmUtils.checkNpxIsInstalled)());case 98:_context3.next = 100;return (

              (0, _exec.executeAsync)("npx yarn add ".concat(
              selectedInputTemplate, "@").concat(inputTemplateVersion),
              {
                cwd: c.paths.project.dir }));case 100:if (




            (0, _fileutils.fsExistsSync)(_path["default"].join(c.paths.project.dir, 'node_modules'))) {_context3.next = 103;break;}
            (0, _logger.logError)("npx yarn add ".concat(selectedInputTemplate, "@").concat(inputTemplateVersion, " : FAILED. this could happen if you have package.json accidentally created somewhere in parent directory"));return _context3.abrupt("return");case 103:if (




            data.optionTemplates.keysAsArray.includes(selectedInputTemplate)) {_context3.next = 115;break;}_context3.next = 106;return (
              _inquirer["default"].prompt({
                name: 'confirmAddTemplate',
                type: 'confirm',
                message: "Would you like to add ".concat((0, _logger.chalk)().white(
                selectedInputTemplate), " to your ").concat(
                c.runtime.selectedWorkspace, " workspace template list?") }));case 106:_yield$inquirer$promp6 = _context3.sent;confirmAddTemplate = _yield$inquirer$promp6.confirmAddTemplate;if (!


            confirmAddTemplate) {_context3.next = 115;break;}
            if (!((_c$files$workspace$co = c.files.workspace.config) !== null && _c$files$workspace$co !== void 0 && _c$files$workspace$co.projectTemplates)) {
              c.files.workspace.config.projectTemplates = {};
            }
            c.files.workspace.config.projectTemplates[selectedInputTemplate] = {};
            (0, _fileutils.writeFileSync)(c.paths.workspace.config, c.files.workspace.config);_context3.next = 114;return (
              (0, _runtimeManager.updateRenativeConfigs)(c));case 114:

            (0, _logger.logInfo)("Updating ".concat(c.paths.workspace.config, "...DONE"));case 115:



            renativeTemplateConfig = (0, _fileutils.readObjectSync)(
            _path["default"].join(
            c.paths.project.dir,
            'node_modules',
            selectedInputTemplate,
            'renative.template.json'));



            // ==================================================
            // INPUT: Supported Platforms
            // ==================================================

            supportedPlatforms = (renativeTemplateConfig === null || renativeTemplateConfig === void 0 ? void 0 : (_renativeTemplateConf = renativeTemplateConfig.defaults) === null || _renativeTemplateConf === void 0 ? void 0 : _renativeTemplateConf.supportedPlatforms) || [];if (!(


            platform && platform !== '')) {_context3.next = 121;break;}
            inputSupportedPlatforms = platform.split(',');_context3.next = 125;break;case 121:_context3.next = 123;return (

              _inquirer["default"].prompt({
                name: 'inputSupportedPlatforms',
                type: 'checkbox',
                pageSize: 20,
                message: 'What platforms would you like to use?',
                validate: function validate(val) {return !!val.length || 'Please select at least a platform';},
                "default": supportedPlatforms,
                choices: supportedPlatforms }));case 123:_answer = _context3.sent;

            inputSupportedPlatforms = _answer === null || _answer === void 0 ? void 0 : _answer.inputSupportedPlatforms;case 125:


            // ==================================================
            // INPUT: Custom Questions
            // ==================================================
            renativeTemplateConfigExt = {};
            bootstrapQuestions = renativeTemplateConfig === null || renativeTemplateConfig === void 0 ? void 0 : (_renativeTemplateConf2 = renativeTemplateConfig.templateConfig) === null || _renativeTemplateConf2 === void 0 ? void 0 : _renativeTemplateConf2.bootstrapQuestions;
            results = {};_context3.next = 130;return (
              interactiveQuestion(results, bootstrapQuestions));case 130:

            Object.keys(results).forEach(function (k) {
              var objValue = results[k].value;

              var targetKey = results[k].configProp.key;

              if (targetKey) {
                (0, _lodash["default"])(renativeTemplateConfigExt, targetKey, objValue);
              }
            });

            // ==================================================
            // INPUT: Git Enabled
            // ==================================================
            _context3.next = 133;return (
              _inquirer["default"].prompt({
                name: 'gitEnabled',
                type: 'confirm',
                message: 'Do you want to set-up git in your new project?' }));case 133:_yield$inquirer$promp7 = _context3.sent;gitEnabled = _yield$inquirer$promp7.gitEnabled;


            // ==================================================
            // INPUT: Confirm Overview
            // ==================================================
            data = _objectSpread(_objectSpread({},
            data), {}, {
              inputProjectName: inputProjectName,
              inputAppTitle: inputAppTitle,
              inputAppID: inputAppID,
              inputVersion: inputVersion,
              inputTemplate: selectedInputTemplate,
              inputSupportedPlatforms: inputSupportedPlatforms,
              inputWorkspace: inputWorkspace,
              gitEnabled: gitEnabled });

            data.optionPlatforms.selectedOptions = inputSupportedPlatforms;

            _prepareProjectOverview(c, data);if (
            ci) {_context3.next = 145;break;}_context3.next = 141;return (
              _inquirer["default"].prompt({
                type: 'confirm',
                name: 'confirm',
                message: "\n".concat(data.confirmString, "\nIs all this correct?") }));case 141:_yield$inquirer$promp8 = _context3.sent;_confirm = _yield$inquirer$promp8.confirm;if (


            _confirm) {_context3.next = 145;break;}return _context3.abrupt("return");case 145:_context3.prev = 145;_context3.next = 148;return (








              _analytics["default"].captureEvent({
                type: 'newProject',
                template: selectedInputTemplate,
                platforms: inputSupportedPlatforms }));case 148:_context3.next = 153;break;case 150:_context3.prev = 150;_context3.t0 = _context3["catch"](145);


            (0, _logger.logDebug)(_context3.t0);case 153:


            c.paths.project["package"] = _path["default"].join(c.paths.project.dir, 'package.json');
            c.paths.project.config = _path["default"].join(c.paths.project.dir, _constants.RENATIVE_CONFIG_NAME);

            data.packageName = data.appTitle.replace(/\s+/g, '-').toLowerCase();

            templates = {};

            (0, _logger.logTask)("_generateProject:".concat(
            data.optionTemplates.selectedOption, ":").concat(
            data.optionTemplates.selectedVersion),

            (0, _logger.chalk)().grey);


            templates[data.optionTemplates.selectedOption] = {
              version: data.optionTemplates.selectedVersion };


            config = _objectSpread(_objectSpread(_objectSpread({},
            renativeTemplateConfig),
            renativeTemplateConfigExt), {}, {
              projectName: data.projectName,
              workspaceID: data.optionWorkspaces.selectedOption,
              paths: {
                appConfigsDir: './appConfigs',
                entryDir: './',
                platformAssetsDir: './platformAssets',
                platformBuildsDir: './platformBuilds' },

              defaults: {
                title: data.appTitle,
                id: data.appID,
                supportedPlatforms: data.optionPlatforms.selectedOptions },

              engines: {},
              templates: templates,
              currentTemplate: data.optionTemplates.selectedOption,
              isNew: true,
              isMonorepo: false });


            supPlats = config.defaults.supportedPlatforms;

            // Remove unused platforms
            Object.keys(config.platforms).forEach(function (k) {
              if (!supPlats.includes(k)) {
                delete config.platforms[k];
              }
            });

            // Remove unused engines based on selected platforms
            supPlats.forEach(function (k) {var _config$platforms$k, _c$files$rnv$projectT;
              var selectedEngineId = ((_config$platforms$k = config.platforms[k]) === null || _config$platforms$k === void 0 ? void 0 : _config$platforms$k.engine) || ((_c$files$rnv$projectT =
              c.files.rnv.projectTemplates.config.platforms[k]) === null || _c$files$rnv$projectT === void 0 ? void 0 : _c$files$rnv$projectT.engine);
              if (selectedEngineId) {
                var selectedEngine = findEngineKeyById(c, selectedEngineId);
                config.engines[selectedEngine.key] = renativeTemplateConfig.engines[selectedEngine.key];
              }
            });

            delete config.templateConfig;

            (0, _fileutils.writeFileSync)(c.paths.project.config, config);if (!

            data.gitEnabled) {_context3.next = 170;break;}_context3.next = 168;return (
              (0, _projectManager.checkAndCreateGitignore)(c));case 168:_context3.next = 170;return (
              (0, _gitUtils.configureGit)(c));case 170:

            (0, _logger.logSuccess)("Your project is ready! navigate to project ".concat(
            (0, _logger.chalk)().white("cd ".concat(
            data.projectName)), " and run ").concat(
            (0, _logger.chalk)().white('rnv run'), " to see magic happen!"));case 171:case "end":return _context3.stop();}}}, _callee2, null, [[145, 150]]);}));return function taskRnvNew(_x3) {return _ref2.apply(this, arguments);};}();exports.taskRnvNew = taskRnvNew;



var findEngineKeyById = function findEngineKeyById(c, id) {
  var engineTemplates = c.files.rnv.projectTemplates.config.engineTemplates;
  var etk = Object.keys(engineTemplates);
  for (var i = 0; i < etk.length; i++) {
    var engine = engineTemplates[etk[i]];
    if (engine.id === id) {
      engine.key = etk[i];
      return engine;
    }
  }
};var _default2 =

{
  description: 'Create new ReNative project',
  fn: taskRnvNew,
  task: 'new',
  params: _constants.PARAMS.withBase(),
  platforms: [],
  isGlobalScope: true };exports["default"] = _default2;
//# sourceMappingURL=task.rnv.new.js.map