UNPKG

@ordino.ai/cli

Version:
617 lines (614 loc) 29.8 kB
"use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } Object.defineProperty(exports, "__esModule", { value: true }); exports.convertToValidPackageName = convertToValidPackageName; exports.getInitialPrompts = getInitialPrompts; exports.getLoginPrompts = getLoginPrompts; exports.getMicroFrontendPrompts = getMicroFrontendPrompts; exports.getProjectName = getProjectName; exports.getProjectsList = getProjectsList; exports.getStandardPrompts = getStandardPrompts; exports.getTestPrompt = getTestPrompt; exports.handleGitAndYml = handleGitAndYml; exports.projectType = projectType; var _inquirer = _interopRequireDefault(require("inquirer")); var _ordinoSystemApiKey = require("../service/ordino.systemApiKey.service"); var _ordinoUserApiKey = require("../service/ordino.userApiKey.service"); var _printMessage = require("../utils/printMessage.util"); var _ordinoUser = require("../service/ordino.user.service"); var _ordinoTeam = require("../service/ordino.team.service"); var _ordinoProject = require("../service/ordino.project.service"); var _models = require("../models/models"); var _serviceFactory = require("../config/service-factory"); var _apiEndpoints = require("../config/api-endpoints"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; } function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { "throw": 1, "return": 2, "break": 3, "continue": 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, "catch": function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); } function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); } function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; } function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); } function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); } function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); } function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); } function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); } function _OverloadYield(e, d) { this.v = e, this.k = d; } function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } // Types for the prompts // Functions // Initial prompt to ask if the company ID is available function getInitialPrompts() { return _getInitialPrompts.apply(this, arguments); } // Validate the provided API key function _getInitialPrompts() { _getInitialPrompts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() { return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: return _context.abrupt("return", _inquirer["default"].prompt([{ type: "confirm", name: "isCompanyIDAvailable", message: "Do you have a company ID?", "default": true }])); case 1: case "end": return _context.stop(); } }, _callee); })); return _getInitialPrompts.apply(this, arguments); } function validateApiKey(_x) { return _validateApiKey.apply(this, arguments); } // Prompt for project type and company ID function _validateApiKey() { _validateApiKey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(apiKey) { var frameworkVersion, currentEnvironment, endpoints, response, data; return _regeneratorRuntime().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: frameworkVersion = "1.0.0"; if (!(apiKey.trim() === "")) { _context2.next = 3; break; } return _context2.abrupt("return", "API key is required!!!"); case 3: _context2.prev = 3; // Get the current environment and corresponding endpoints currentEnvironment = _serviceFactory.serviceFactory.getEnvironment(); endpoints = (0, _apiEndpoints.getApiEndpoints)(currentEnvironment); _context2.next = 8; return fetch(endpoints.authentication, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ apiKey: apiKey, frameworkVersion: frameworkVersion }) }); case 8: response = _context2.sent; if (response.ok) { _context2.next = 11; break; } return _context2.abrupt("return", "Use a valid key."); case 11: _context2.next = 13; return response.json(); case 13: data = _context2.sent; _context2.t0 = data.status; _context2.next = _context2.t0 === "INVALID" ? 17 : _context2.t0 === "FRAMEWORK_OUT_DATED" ? 18 : _context2.t0 === "VALID" ? 19 : 20; break; case 17: return _context2.abrupt("return", "Use a valid key."); case 18: return _context2.abrupt("return", "Update your CLI."); case 19: return _context2.abrupt("return", true); case 20: return _context2.abrupt("return", "Unexpected response. Please try again."); case 21: _context2.next = 26; break; case 23: _context2.prev = 23; _context2.t1 = _context2["catch"](3); return _context2.abrupt("return", "Use a valid key. ".concat(_context2.t1)); case 26: case "end": return _context2.stop(); } }, _callee2, null, [[3, 23]]); })); return _validateApiKey.apply(this, arguments); } function projectType() { return _projectType.apply(this, arguments); } // Get prompts for Micro Frontend project URLs function _projectType() { _projectType = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() { return _regeneratorRuntime().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: return _context3.abrupt("return", _inquirer["default"].prompt([{ type: "input", name: "authToken", message: "Provide the Company ID:", validate: validateApiKey }, { type: "list", name: "projectType", message: "What is the type of your project? (Choose one: UI / API):", choices: mapEnumToChoices() }])); case 1: case "end": return _context3.stop(); } }, _callee3); })); return _projectType.apply(this, arguments); } function getMicroFrontendPrompts() { return _getMicroFrontendPrompts.apply(this, arguments); } // Get prompts for project name and company function _getMicroFrontendPrompts() { _getMicroFrontendPrompts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() { return _regeneratorRuntime().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: return _context4.abrupt("return", _inquirer["default"].prompt([{ type: "input", name: "clientTestProjectURL", message: "Please add the Client Test Project URL:" }, { type: "input", name: "testProjectURL", message: "Please add the Test Project URL:" }])); case 1: case "end": return _context4.stop(); } }, _callee4); })); return _getMicroFrontendPrompts.apply(this, arguments); } function getStandardPrompts(_x2, _x3) { return _getStandardPrompts.apply(this, arguments); } // Get project details based on API key and project type function _getStandardPrompts() { _getStandardPrompts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(projectName, companyName) { var suggestedName, nameConfirmation, customName; return _regeneratorRuntime().wrap(function _callee5$(_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: suggestedName = "".concat(companyName, "-").concat(projectName, "-test"); _context5.next = 3; return _inquirer["default"].prompt([{ type: "confirm", name: "useSuggestedName", message: "Would you like the tool to suggest a project name (".concat(suggestedName, ")?"), "default": true }]); case 3: nameConfirmation = _context5.sent; if (nameConfirmation.useSuggestedName) { _context5.next = 9; break; } _context5.next = 7; return _inquirer["default"].prompt([{ type: "input", name: "customProjectName", message: "Please enter a project name:", validate: function validate(input) { return input.trim() !== "" || "Project name cannot be empty."; } }]); case 7: customName = _context5.sent; return _context5.abrupt("return", customName.customProjectName); case 9: return _context5.abrupt("return", suggestedName); case 10: case "end": return _context5.stop(); } }, _callee5); })); return _getStandardPrompts.apply(this, arguments); } function getProjectName(_x4, _x5) { return _getProjectName.apply(this, arguments); } // Prompt for whether to include a sample test function _getProjectName() { _getProjectName = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(apiKey, projectType) { var partnerId, users, teams, projects, _projects$find, _yield$inquirer$promp, projectId, _yield$inquirer$promp2, teamId, _yield$inquirer$promp3, projectName, _yield$inquirer$promp4, userId, project, _yield$inquirer$promp5, teamName, _projectName, team, _yield$inquirer$promp6, _userId, _project; return _regeneratorRuntime().wrap(function _callee6$(_context6) { while (1) switch (_context6.prev = _context6.next) { case 0: _context6.next = 2; return getPartnerId(apiKey); case 2: partnerId = _context6.sent; if (partnerId) { _context6.next = 5; break; } return _context6.abrupt("return", null); case 5: _context6.next = 7; return _ordinoUser.userService.getAllUsers(partnerId); case 7: users = _context6.sent; _context6.next = 10; return _ordinoTeam.teamService.getAllTeams(partnerId); case 10: teams = _context6.sent; _context6.next = 13; return _ordinoProject.projectService.getAllProjects(); case 13: projects = _context6.sent; if (!(projects.length > 0)) { _context6.next = 22; break; } _context6.next = 17; return _inquirer["default"].prompt({ type: "list", name: "projectId", message: "Select a project:", choices: projects.map(function (project) { return { name: project.name, value: project.id }; }) }); case 17: _yield$inquirer$promp = _context6.sent; projectId = _yield$inquirer$promp.projectId; return _context6.abrupt("return", (_projects$find = projects.find(function (_ref) { var id = _ref.id; return id === projectId; })) !== null && _projects$find !== void 0 ? _projects$find : null); case 22: if (!(teams.length > 0)) { _context6.next = 41; break; } _context6.next = 25; return _inquirer["default"].prompt({ type: "list", name: "teamId", message: "Select a team:", choices: teams.map(function (team) { return { name: team.name, value: team.id }; }) }); case 25: _yield$inquirer$promp2 = _context6.sent; teamId = _yield$inquirer$promp2.teamId; _context6.next = 29; return _inquirer["default"].prompt([{ type: "input", name: "projectName", message: "Enter the project name:" }]); case 29: _yield$inquirer$promp3 = _context6.sent; projectName = _yield$inquirer$promp3.projectName; _context6.next = 33; return _inquirer["default"].prompt({ type: "list", name: "userId", message: "Select a user:", choices: users.map(function (user) { return { name: user.information.email, value: user.id }; }) }); case 33: _yield$inquirer$promp4 = _context6.sent; userId = _yield$inquirer$promp4.userId; _context6.next = 37; return _ordinoProject.projectService.cerateProject({ partnerId: partnerId, teamId: teamId, name: projectName, applicationTypes: getApplicationType(projectType), qaLeadId: userId, isRegressionSuite: false, isCloudEnabled: false }); case 37: project = _context6.sent; return _context6.abrupt("return", project !== null && project !== void 0 ? project : null); case 41: _context6.next = 43; return _inquirer["default"].prompt([{ type: "input", name: "teamName", message: "Enter the team name:" }, { type: "input", name: "projectName", message: "Enter the project name:" }]); case 43: _yield$inquirer$promp5 = _context6.sent; teamName = _yield$inquirer$promp5.teamName; _projectName = _yield$inquirer$promp5.projectName; _context6.next = 48; return _ordinoTeam.teamService.createTeam({ partnerId: partnerId, name: teamName, description: "", applicationTypes: getApplicationType(projectType), integrationDefinitionIds: ["TEST_INTEGRATION"] }); case 48: team = _context6.sent; _context6.next = 51; return _inquirer["default"].prompt({ type: "list", name: "userId", message: "Select a user:", choices: users.map(function (user) { return { name: user.information.email, value: user.id }; }) }); case 51: _yield$inquirer$promp6 = _context6.sent; _userId = _yield$inquirer$promp6.userId; _context6.next = 55; return _ordinoProject.projectService.cerateProject({ partnerId: partnerId, teamId: team.id, name: _projectName, applicationTypes: getApplicationType(projectType), qaLeadId: _userId, isRegressionSuite: false, isCloudEnabled: false }); case 55: _project = _context6.sent; return _context6.abrupt("return", _project !== null && _project !== void 0 ? _project : null); case 57: case "end": return _context6.stop(); } }, _callee6); })); return _getProjectName.apply(this, arguments); } function getTestPrompt() { return _getTestPrompt.apply(this, arguments); } // Map project types to choices for user selection function _getTestPrompt() { _getTestPrompt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() { return _regeneratorRuntime().wrap(function _callee7$(_context7) { while (1) switch (_context7.prev = _context7.next) { case 0: return _context7.abrupt("return", _inquirer["default"].prompt([{ type: "confirm", name: "includeSampleTest", message: "Do you want to add a sample test? (yes/no):", "default": true }])); case 1: case "end": return _context7.stop(); } }, _callee7); })); return _getTestPrompt.apply(this, arguments); } function mapEnumToChoices() { return Object.keys(_models.projectTypes).filter(function (key) { return isNaN(Number(key)); }).map(function (key) { return { name: key, value: _models.projectTypes[key] }; }); } // Get application types based on project type function getApplicationType(projectType) { switch (projectType) { case _models.projectTypes.UI: return [_models.ApplicationType.WEB_UI]; case _models.projectTypes.API: return [_models.ApplicationType.API]; case _models.projectTypes.UI_AND_API: return [_models.ApplicationType.WEB_UI, _models.ApplicationType.API]; default: throw new Error("Invalid project type"); } } // Get the partner ID based on the API key function getPartnerId(_x6) { return _getPartnerId.apply(this, arguments); } // Convert project name to a valid package name function _getPartnerId() { _getPartnerId = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(apiKey) { var partnerId, res, _res; return _regeneratorRuntime().wrap(function _callee8$(_context8) { while (1) switch (_context8.prev = _context8.next) { case 0: partnerId = null; _context8.prev = 1; if (!apiKey.startsWith("SYS:")) { _context8.next = 7; break; } _context8.next = 5; return _ordinoSystemApiKey.systemApiKeyService.getBySystemApiKey(apiKey); case 5: res = _context8.sent; return _context8.abrupt("return", res.partnerId); case 7: if (!apiKey.startsWith("USR:")) { _context8.next = 12; break; } _context8.next = 10; return _ordinoUserApiKey.userApiKeyService.getByUserApiKey(apiKey); case 10: _res = _context8.sent; return _context8.abrupt("return", _res.partnerId); case 12: _context8.next = 18; break; case 14: _context8.prev = 14; _context8.t0 = _context8["catch"](1); (0, _printMessage.printMessage)("Please check you api key is valid. If it's valid please contact support team https://www.ordino.ai/support", "35", true, true); return _context8.abrupt("return", partnerId); case 18: return _context8.abrupt("return", partnerId); case 19: case "end": return _context8.stop(); } }, _callee8, null, [[1, 14]]); })); return _getPartnerId.apply(this, arguments); } function convertToValidPackageName(projectName) { var validName = projectName.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/^-+/, "").replace(/-+$/, ""); return validName; } function handleGitAndYml() { return _handleGitAndYml.apply(this, arguments); } //Initial prompt to ask login credentials function _handleGitAndYml() { _handleGitAndYml = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() { var gitUrlResponse, gitUrl, needGitActionSetup, gitUrlInput; return _regeneratorRuntime().wrap(function _callee9$(_context9) { while (1) switch (_context9.prev = _context9.next) { case 0: _context9.next = 2; return _inquirer["default"].prompt([{ type: "confirm", name: "gitUrl", message: "Do you want to set up a Git repository?", "default": true }]); case 2: gitUrlResponse = _context9.sent; gitUrl = null; needGitActionSetup = false; if (!gitUrlResponse.gitUrl) { _context9.next = 11; break; } _context9.next = 8; return _inquirer["default"].prompt([{ type: "input", name: "gitUrl", message: "Please provide the Git repository URL:", validate: function validate(input) { return input.trim() !== "" ? true : "Git URL cannot be empty."; } }, { type: "confirm", name: "needGitActionSetup", message: "Do you want to use GitHub Actions for CI/CD?", "default": true }]); case 8: gitUrlInput = _context9.sent; gitUrl = gitUrlInput.gitUrl; needGitActionSetup = gitUrlInput.needGitActionSetup; case 11: return _context9.abrupt("return", { gitUrl: gitUrl, needGitActionSetup: needGitActionSetup }); case 12: case "end": return _context9.stop(); } }, _callee9); })); return _handleGitAndYml.apply(this, arguments); } function getLoginPrompts() { return _getLoginPrompts.apply(this, arguments); } //Get projects list function _getLoginPrompts() { _getLoginPrompts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10() { return _regeneratorRuntime().wrap(function _callee10$(_context10) { while (1) switch (_context10.prev = _context10.next) { case 0: return _context10.abrupt("return", _inquirer["default"].prompt([{ type: "input", name: "username", message: "Ordino portal login username?", validate: function validate(input) { return input.trim() !== "" ? true : "Username cannot be empty."; } }, { type: "password", name: "password", message: "Ordino portal login password?", validate: function validate(input) { return input.trim() !== "" ? true : "password cannot be empty."; } }])); case 1: case "end": return _context10.stop(); } }, _callee10); })); return _getLoginPrompts.apply(this, arguments); } function getProjectsList(_x7) { return _getProjectsList.apply(this, arguments); } //Map projects list. function _getProjectsList() { _getProjectsList = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(projectsList) { return _regeneratorRuntime().wrap(function _callee11$(_context11) { while (1) switch (_context11.prev = _context11.next) { case 0: return _context11.abrupt("return", _inquirer["default"].prompt([{ type: "list", name: "project", message: "Please select the project?", choices: mapProjectsList(projectsList) }])); case 1: case "end": return _context11.stop(); } }, _callee11); })); return _getProjectsList.apply(this, arguments); } function mapProjectsList(projectsList) { return projectsList.map(function (project) { return { name: project.name, value: project }; }); }