Skip to content

Commit

Permalink
feat(core): add ability to select multiple schemas
Browse files Browse the repository at this point in the history
Refs #8
  • Loading branch information
MHCYR committed Oct 20, 2023
1 parent 92d55d5 commit 4e1f97f
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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();

0 comments on commit 4e1f97f

Please # to comment.