From c9a8582d9062106d8204f3e6acc9bf10a094ee65 Mon Sep 17 00:00:00 2001 From: Pedro Ramos Date: Mon, 11 Dec 2023 15:32:51 +0100 Subject: [PATCH] Rollback last changes --- src/base.ts | 24 ------------------------ src/commands/bundle.ts | 4 ++-- src/commands/convert.ts | 2 +- src/commands/generate/fromTemplate.ts | 4 ++-- src/commands/optimize.ts | 4 ++-- src/commands/validate.ts | 6 +++--- 6 files changed, 10 insertions(+), 34 deletions(-) diff --git a/src/base.ts b/src/base.ts index 70e3105d5d7..c7c60672594 100644 --- a/src/base.ts +++ b/src/base.ts @@ -1,8 +1,6 @@ import { Command } from '@oclif/core'; import { MetadataFromDocument, MetricMetadata, NewRelicSink, Recorder, Sink, StdOutSink } from '@smoya/asyncapi-adoption-metrics'; import { Parser } from '@asyncapi/parser'; -import validate from '@asyncapi/parser'; -import template from 'lodash.template'; class DiscardSink implements Sink { async send() { @@ -31,28 +29,6 @@ export default abstract class extends Command { const {document} = await this.parser.parse(rawDocument); if (document !== undefined) { metadata = MetadataFromDocument(document, metadata); - const commandName : string = this.id || ''; - switch (commandName) { - case 'validate': - metadata['success'] = true; - metadata['validation_result'] = await validate(this, specFile, flags); - break; - case 'convert': - metadata['from_version'] = document.version(); - break; - case 'bundle': - metadata['success'] = true; - metadata['files'] = AsyncAPIFiles.length; - break; - case 'template': - metadata['success'] = true; - metadata['template'] = template; - break; - case 'optimize': - metadata['success'] = true; - metadata['optimizations'] = this.optimizations; - break; - } } } catch (e: any) { if (e instanceof Error) { diff --git a/src/commands/bundle.ts b/src/commands/bundle.ts index afdf359365e..d0164ac61d1 100644 --- a/src/commands/bundle.ts +++ b/src/commands/bundle.ts @@ -80,8 +80,8 @@ export default class Bundle extends Command { const result = await load(output); - // // Metrics recording. - // await this.recordActionExecuted(result.text(), {success: true, files: AsyncAPIFiles.length}); + // Metrics recording. + await this.recordActionExecuted(result.text(), {success: true, files: AsyncAPIFiles.length}); } async loadFiles(filepaths: string[]): Promise { diff --git a/src/commands/convert.ts b/src/commands/convert.ts index 5c8ed0c2521..2b46084bc79 100644 --- a/src/commands/convert.ts +++ b/src/commands/convert.ts @@ -85,6 +85,6 @@ export default class Convert extends Command { } } - // await this.recordActionExecuted('convert', metadata); + await this.recordActionExecuted('convert', metadata); } } diff --git a/src/commands/generate/fromTemplate.ts b/src/commands/generate/fromTemplate.ts index 489351950a1..0fd962bb0ac 100644 --- a/src/commands/generate/fromTemplate.ts +++ b/src/commands/generate/fromTemplate.ts @@ -147,8 +147,8 @@ export default class Template extends Command { await this.runWatchMode(asyncapi, template, output, watcherHandler); } - // // Metrics recording. - // await this.recordActionExecuted('generate_from_template', {success: true, template}, asyncapiInput.text()); + // Metrics recording. + await this.recordActionExecuted('generate_from_template', {success: true, template}, asyncapiInput.text()); } private parseFlags(disableHooks?: string[], params?: string[], mapBaseUrl?: string): ParsedFlags { diff --git a/src/commands/optimize.ts b/src/commands/optimize.ts index 4d486247c8d..274dccbfdd8 100644 --- a/src/commands/optimize.ts +++ b/src/commands/optimize.ts @@ -129,8 +129,8 @@ export default class Optimize extends Command { }); } - // // Metrics recording. - // await this.recordActionExecuted('optimize', {success: true, optimizations: this.optimizations}, specFile.text()); + // Metrics recording. + await this.recordActionExecuted('optimize', {success: true, optimizations: this.optimizations}, specFile.text()); } private showOptimizations(elements: ReportElement[] | undefined) { diff --git a/src/commands/validate.ts b/src/commands/validate.ts index 89dc53d0deb..5757cbaffa3 100644 --- a/src/commands/validate.ts +++ b/src/commands/validate.ts @@ -29,9 +29,9 @@ export default class Validate extends Command { specWatcher({ spec: specFile, handler: this, handlerName: 'validate' }); } - // const result = await validate(this, specFile, flags); + const result = await validate(this, specFile, flags); - // // Metrics recording. - // await this.recordActionExecuted('validate', {success: true, validation_result: result}, specFile.text()); + // Metrics recording. + await this.recordActionExecuted('validate', {success: true, validation_result: result}, specFile.text()); } }