UNPKG

@veecode-platform/safira-cli

Version:

Generate a microservice project from your spec.

43 lines (42 loc) 2.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const core_1 = require("@oclif/core"); const run_tests_1 = require("../../insomnia/run-tests"); const inquirer_1 = tslib_1.__importDefault(require("inquirer")); const insomnia_utils_1 = require("../../insomnia/insomnia-utils"); const file_system_utils_1 = require("../../utils/file-system-utils"); const color_1 = tslib_1.__importDefault(require("@oclif/color")); class InsomniaTest extends core_1.Command { async run() { const { args, flags } = await this.parse(InsomniaTest); const projectFolder = file_system_utils_1.FileSystemUtils.getCurrentPath(); if (!insomnia_utils_1.InsomniaUtils.instance.isInsomniaWorkspace(projectFolder)) { this.log(color_1.default.red("This is not an Insomnia workspace.")); return; } const answers = await inquirer_1.default.prompt([ { when: !flags["inso-spec-name"] && insomnia_utils_1.InsomniaUtils.instance.getListSpecName(projectFolder).length > 1, type: "list", name: "inso-spec-name", message: "The name of the spec in the workspace.", choices: insomnia_utils_1.InsomniaUtils.instance.getListSpecName(projectFolder), validate: (value) => value.length > 0 ? true : "Please enter a valid name for the spec", }, ]); try { await run_tests_1.RunTest.instance.runTests(flags["inso-spec-name"] || answers["inso-spec-name"] || insomnia_utils_1.InsomniaUtils.instance.getListSpecName(projectFolder)[0]); } catch (error) { this.log(color_1.default.red(error.message)); } } } exports.default = InsomniaTest; InsomniaTest.description = "Run your insomnia test"; InsomniaTest.flags = { help: core_1.Flags.help({ char: "h" }), "inso-spec-name": core_1.Flags.string({ description: "The name of the INSO specification." }), }; InsomniaTest.args = [];