Skip to content

Commit

Permalink
feat(main): connect input with clone repo function
Browse files Browse the repository at this point in the history
Refs #5
  • Loading branch information
MHCYR authored and adantoscano committed Oct 5, 2023
1 parent 341e61f commit 8590aa9
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/index.mjs
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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" }),
Expand All @@ -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();

0 comments on commit 8590aa9

Please # to comment.