@asyncapi/cli 0.45.8 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,8 +29,10 @@ class Models extends base_1.default {
29
29
  const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, namespace, csharpAutoImplement, csharpArrayType, csharpNewtonsoft, csharpHashcode, csharpEqual, csharpSystemJson, packageName, output } = flags;
30
30
  const { language, file } = args;
31
31
  const inputFile = (yield (0, SpecificationFile_1.load)(file)) || (yield (0, SpecificationFile_1.load)());
32
- const { document, status } = yield (0, parser_1.parse)(this, inputFile, flags);
32
+ const { document, diagnostics, status } = yield (0, parser_1.parse)(this, inputFile, flags);
33
33
  if (!document || status === 'invalid') {
34
+ const severityErrors = diagnostics.filter((obj) => obj.severity === 0);
35
+ this.log(`Input is not a correct AsyncAPI document so it cannot be processed.${(0, parser_1.formatOutput)(severityErrors, 'stylish', 'error')}`);
34
36
  return;
35
37
  }
36
38
  modelina_1.Logger.setLogger({
package/lib/parser.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { convertToOldAPI } from '@asyncapi/parser/cjs';
2
2
  import { OutputFormat } from '@stoplight/spectral-cli/dist/services/config';
3
3
  import type Command from './base';
4
+ import type { Diagnostic } from '@asyncapi/parser/cjs';
4
5
  import type { Specification } from './models/SpecificationFile';
5
6
  export declare type SeveritytKind = 'error' | 'warn' | 'info' | 'hint';
6
7
  export { convertToOldAPI };
@@ -23,3 +24,4 @@ export declare function parse(command: Command, specFile: Specification, options
23
24
  diagnostics: import("@stoplight/spectral-core").ISpectralDiagnostic[];
24
25
  status: "valid" | "invalid";
25
26
  }>;
27
+ export declare function formatOutput(diagnostics: Diagnostic[], format: `${OutputFormat}`, failSeverity: SeveritytKind): string;
package/lib/parser.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parse = exports.validate = exports.validationFlags = exports.convertToOldAPI = void 0;
3
+ exports.formatOutput = exports.parse = exports.validate = exports.validationFlags = exports.convertToOldAPI = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const core_1 = require("@oclif/core");
6
6
  const cjs_1 = require("@asyncapi/parser/cjs");
@@ -68,7 +68,6 @@ function logDiagnostics(diagnostics, command, specFile, options = {}) {
68
68
  command.logToStderr(`\n${sourceString} and/or referenced documents have governance issues.`);
69
69
  command.logToStderr(formatOutput(diagnostics, diagnosticsFormat, failSeverity));
70
70
  }
71
- command.exit(1);
72
71
  return 'invalid';
73
72
  }
74
73
  if (logDiagnostics) {
@@ -94,6 +93,7 @@ function formatOutput(diagnostics, format, failSeverity) {
94
93
  default: return (0, formatters_1.stylish)(diagnostics, options);
95
94
  }
96
95
  }
96
+ exports.formatOutput = formatOutput;
97
97
  function hasFailSeverity(diagnostics, failSeverity) {
98
98
  const diagnosticSeverity = (0, spectral_core_1.getDiagnosticSeverity)(failSeverity);
99
99
  return diagnostics.some(diagnostic => diagnostic.severity <= diagnosticSeverity);
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.45.8",
2
+ "version": "0.46.0",
3
3
  "commands": {
4
4
  "bundle": {
5
5
  "id": "bundle",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@asyncapi/cli",
3
3
  "description": "All in one CLI for all AsyncAPI tools",
4
- "version": "0.45.8",
4
+ "version": "0.46.0",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run"