diff --git a/src/index.mjs b/src/index.mjs index 7d5ac3e..0d7f0a3 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -1,3 +1,5 @@ +import OpenApiMocker from "open-api-mocker"; +import cloneGitRepository from "./services/clone-git-repository.js"; import { input, confirm } from "@inquirer/prompts"; import * as fs from "node:fs"; import path from "path"; @@ -7,7 +9,7 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); -const run = async () => { +const main = async () => { const config = { repoUrl: await input({ message: "Enter the repo url" }), dirPath: await input({ message: "Enter the directory path" }), @@ -20,17 +22,29 @@ const run = async () => { console.table(config); if (config.saveConfig) { - // Save config - // create an .apimockrc file on the root of the project const filePath = `${__dirname}/.apimockrc`; fs.writeFile(filePath, JSON.stringify(config), (err) => { if (err) { - console.log(err); + console.error(err); } else { console.log("Config saved"); } }); } + + const testRepoSSH = "git@gitlab.sngular.com:os3/manatee/sirenia.git"; // TODO: replace by user input + const testRepoHTTPS = "https://gitlab.sngular.com/os3/manatee/sirenia.git"; // TODO: replace by user input + await cloneGitRepository(config.repoUrl || testRepoSSH); + + const openApiMocker = new OpenApiMocker({ + port: 5000, + schema: schemas[0].filePath, + watch: true, + }); + + await openApiMocker.validate(); + + await openApiMocker.mock(); }; -run(); +main();