From 308446ef1d26fc1b3f97b09105923623e6ac105b Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Tue, 21 May 2024 10:31:42 +0200 Subject: [PATCH 1/3] change implementation --- modelina-cli/src/commands/generate.ts | 16 +++++++++++++++- modelina-cli/src/helpers/generate.ts | 12 ++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/modelina-cli/src/commands/generate.ts b/modelina-cli/src/commands/generate.ts index dd0be21383..92fb7f370a 100644 --- a/modelina-cli/src/commands/generate.ts +++ b/modelina-cli/src/commands/generate.ts @@ -32,6 +32,20 @@ export default class Models extends ModelinaCommand { }, } - await generateModels(flags, document, logger, language as Languages); + const generatedModels = await generateModels(flags, document, logger, language as Languages); + + if (flags.output) { + const generatedModelsString = generatedModels.map((model) => { return model.modelName; }); + logger.info(`Successfully generated the following models: ${generatedModelsString.join(', ')}`); + } else { + const generatedModelsString = generatedModels.map((model) => { + return `## Model name: ${model.modelName} +${model.result} +`; + }); + logger.info(`Successfully generated the following models: ${generatedModelsString.join('\n')}`); + } + + } } \ No newline at end of file diff --git a/modelina-cli/src/helpers/generate.ts b/modelina-cli/src/helpers/generate.ts index 0493a02569..6f9f26c956 100644 --- a/modelina-cli/src/helpers/generate.ts +++ b/modelina-cli/src/helpers/generate.ts @@ -114,19 +114,11 @@ export async function generateModels(flags: any, document: any, logger: any, lan document, output, { ...fileOptions, }); - const generatedModels = models.map((model) => { return model.modelName; }); - logger.info(`Successfully generated the following models: ${generatedModels.join(', ')}`); - return; + return models; } const models = await fileGenerator.generateCompleteModels( document, { ...fileOptions }); - const generatedModels = models.map((model) => { - return ` - ## Model name: ${model.modelName} - ${model.result} - `; - }); - logger.info(`Successfully generated the following models: ${generatedModels.join('\n')}`); + return models; } \ No newline at end of file From 1293deb51116eec9481ff974400f4dcedf74efdd Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Tue, 21 May 2024 11:27:28 +0200 Subject: [PATCH 2/3] fix lint error --- modelina-cli/src/helpers/generate.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modelina-cli/src/helpers/generate.ts b/modelina-cli/src/helpers/generate.ts index 6f9f26c956..acd03a1855 100644 --- a/modelina-cli/src/helpers/generate.ts +++ b/modelina-cli/src/helpers/generate.ts @@ -110,15 +110,13 @@ export async function generateModels(flags: any, document: any, logger: any, lan const { fileGenerator, fileOptions } = mapper(flags); if (output) { - const models = await fileGenerator.generateToFiles( + return await fileGenerator.generateToFiles( document, output, { ...fileOptions, }); - return models; } - const models = await fileGenerator.generateCompleteModels( + return await fileGenerator.generateCompleteModels( document, { ...fileOptions }); - return models; } \ No newline at end of file From f3dca1540a320f505247266e9183c725a640983f Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Tue, 21 May 2024 11:43:39 +0200 Subject: [PATCH 3/3] fix linting --- modelina-cli/src/helpers/generate.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modelina-cli/src/helpers/generate.ts b/modelina-cli/src/helpers/generate.ts index acd03a1855..f93a1f8d2b 100644 --- a/modelina-cli/src/helpers/generate.ts +++ b/modelina-cli/src/helpers/generate.ts @@ -110,13 +110,13 @@ export async function generateModels(flags: any, document: any, logger: any, lan const { fileGenerator, fileOptions } = mapper(flags); if (output) { - return await fileGenerator.generateToFiles( + return fileGenerator.generateToFiles( document, output, { ...fileOptions, }); } - return await fileGenerator.generateCompleteModels( + return fileGenerator.generateCompleteModels( document, { ...fileOptions }); } \ No newline at end of file