Skip to content

Commit

Permalink
Rollback last changes
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-rr committed Dec 11, 2023
1 parent 4053bc5 commit c9a8582
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 34 deletions.
24 changes: 0 additions & 24 deletions src/base.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Specification[]> {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ export default class Convert extends Command {
}
}

// await this.recordActionExecuted('convert', metadata);
await this.recordActionExecuted('convert', metadata);
}
}
4 changes: 2 additions & 2 deletions src/commands/generate/fromTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/optimize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/commands/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit c9a8582

Please sign in to comment.