var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.taskRnvWorkspaceAdd=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _path=_interopRequireDefault(require("path"));
var _prompt=require("../cli/prompt");
var _logger=require("../core/systemManager/logger");
var _workspace=require("../core/projectManager/workspace");
var _fileutils=require("../core/systemManager/fileutils");
var _engineManager=require("../core/engineManager");
var _constants=require("../core/constants");

var taskRnvWorkspaceAdd=function taskRnvWorkspaceAdd(c,parentTask,originTask){var _await$inquirerPrompt,workspace,workspacePath,_await$inquirerPrompt2,confirm,workspaceID,_await$inquirerPrompt3,workspaceIDInput;return _regenerator.default.async(function taskRnvWorkspaceAdd$(_context){while(1){switch(_context.prev=_context.next){case 0:
(0,_logger.logTask)('taskRnvWorkspaceAdd');_context.next=3;return _regenerator.default.awrap(

(0,_engineManager.executeTask)(c,_constants.TASK_PROJECT_CONFIGURE,_constants.TASK_WORKSPACE_ADD,originTask));case 3:_context.next=5;return _regenerator.default.awrap(

(0,_prompt.inquirerPrompt)({
name:'workspace',
type:'input',
message:'absolute path to new workspace',
validate:function validate(i){return!!i||'No path provided';}}));case 5:_await$inquirerPrompt=_context.sent;workspace=_await$inquirerPrompt.workspace;


workspacePath=_path.default.join(workspace);if(!

(0,_fileutils.fsExistsSync)(workspacePath)){_context.next=15;break;}_context.next=11;return _regenerator.default.awrap(
(0,_prompt.inquirerPrompt)({
name:'confirm',
type:'confirm',
message:"Folder "+workspacePath+" already exists are you sure you want to override it?"}));case 11:_await$inquirerPrompt2=_context.sent;confirm=_await$inquirerPrompt2.confirm;if(

confirm){_context.next=15;break;}return _context.abrupt("return");case 15:


workspaceID=workspacePath.
split('/').
pop().
replace(/@|\./g,'');_context.next=18;return _regenerator.default.awrap(

(0,_prompt.inquirerPrompt)({
name:'workspaceIDInput',
type:'input',
message:"ID of the workspace ("+workspaceID+")"}));case 18:_await$inquirerPrompt3=_context.sent;workspaceIDInput=_await$inquirerPrompt3.workspaceIDInput;


workspaceID=workspaceIDInput||workspaceID;
(0,_workspace.createWorkspace)(c,workspaceID,workspacePath);case 22:case"end":return _context.stop();}}},null,null,null,Promise);};exports.taskRnvWorkspaceAdd=taskRnvWorkspaceAdd;var _default=


{
description:'Add new workspace',
fn:taskRnvWorkspaceAdd,
task:_constants.TASK_WORKSPACE_ADD,
params:_constants.PARAMS.withBase(),
platforms:[],
isGlobalScope:true};exports.default=_default;
//# sourceMappingURL=task.rnv.workspace.add.js.map