diff --git a/src/index.js b/src/index.js index 0cae047..8617f15 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ -import { select } from '@inquirer/prompts'; +import { checkbox } from '@inquirer/prompts'; import * as fs from 'node:fs'; import { initWithConfigFile, initNoConfigFile, getSchemas, startMockServer } from './services/user-flow-steps.js'; import { RC_FILE_NAME } from './services/utils.js'; @@ -16,23 +16,13 @@ const main = async () => { const schemas = await getSchemas(config.schemasOrigin); - if (schemas.length > 0) { - // TODO: change to checkboxes when multiple schemas are supported - const selectedSchema = await select({ - message: 'Select a schema', - choices: schemas.map((schema) => { - return { name: schema.fileName, value: schema.filePath }; - }), - }); - - // Create .apimockrc file - const filePath = `${process.cwd()}/${RC_FILE_NAME}`; - fs.writeFileSync(filePath, JSON.stringify(config)); - - await startMockServer(config.initialPort, selectedSchema); - } else { - console.log(`No OpenApi schemas found at ${config.schemasOrigin}`); - } + const selectedSchemas = await checkbox({ + message: 'Select a schema', + choices: schemas.map((schema) => { + return { name: schema.fileName, value: schema.filePath }; + }), + }); + await startMockServer(config.initialPort, selectedSchemas); }; main();