@asyncapi/cli 0.47.9 → 0.48.1

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.
@@ -10,6 +10,7 @@ export default class Diff extends Command {
10
10
  format: import("@oclif/core/lib/interfaces").OptionFlag<string>;
11
11
  type: import("@oclif/core/lib/interfaces").OptionFlag<string>;
12
12
  overrides: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
13
+ 'no-error': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
14
  watch: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
15
  };
15
16
  static args: {
@@ -15,6 +15,7 @@ const flags_1 = require("../flags");
15
15
  const parser_1 = require("../parser");
16
16
  const { readFile } = fs_1.promises;
17
17
  class Diff extends base_1.default {
18
+ /* eslint-disable sonarjs/cognitive-complexity */
18
19
  run() {
19
20
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
21
  const { args, flags } = yield this.parse(Diff); // NOSONAR
@@ -24,6 +25,7 @@ class Diff extends base_1.default {
24
25
  const outputType = flags['type'];
25
26
  const overrideFilePath = flags['overrides'];
26
27
  const watchMode = flags['watch'];
28
+ const noError = flags['no-error'];
27
29
  let firstDocument, secondDocument;
28
30
  try {
29
31
  firstDocument = yield (0, SpecificationFile_1.load)(firstDocumentPath);
@@ -90,8 +92,14 @@ class Diff extends base_1.default {
90
92
  else {
91
93
  this.log(`The output format ${outputFormat} is not supported at the moment.`);
92
94
  }
95
+ if (!noError) {
96
+ throwOnBreakingChange(diffOutput);
97
+ }
93
98
  }
94
99
  catch (error) {
100
+ if (error instanceof diff_error_1.DiffBreakingChangeError) {
101
+ throw error;
102
+ }
95
103
  throw new validation_error_1.ValidationError({
96
104
  type: 'parser-error',
97
105
  err: error,
@@ -149,6 +157,8 @@ Diff.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), format: cor
149
157
  }), overrides: core_1.Flags.string({
150
158
  char: 'o',
151
159
  description: 'path to JSON file containing the override properties',
160
+ }), 'no-error': core_1.Flags.boolean({
161
+ description: 'don\'t show error on breaking changes',
152
162
  }), watch: (0, flags_1.watchFlag)() }, (0, parser_1.validationFlags)({ logDiagnostics: false }));
153
163
  Diff.args = [
154
164
  {
@@ -205,3 +215,12 @@ const enableWatch = (status, watcher) => {
205
215
  (0, globals_1.specWatcher)(watcher);
206
216
  }
207
217
  };
218
+ /**
219
+ * Throws `DiffBreakingChangeError` when breaking changes are detected
220
+ */
221
+ function throwOnBreakingChange(diffOutput) {
222
+ const breakingChanges = diffOutput.breaking();
223
+ if (breakingChanges.length !== 0) {
224
+ throw new diff_error_1.DiffBreakingChangeError();
225
+ }
226
+ }
@@ -4,3 +4,6 @@ export declare class DiffOverrideFileError extends Error {
4
4
  export declare class DiffOverrideJSONError extends Error {
5
5
  constructor();
6
6
  }
7
+ export declare class DiffBreakingChangeError extends Error {
8
+ constructor();
9
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DiffOverrideJSONError = exports.DiffOverrideFileError = void 0;
3
+ exports.DiffBreakingChangeError = exports.DiffOverrideJSONError = exports.DiffOverrideFileError = void 0;
4
4
  class DiffOverrideFileError extends Error {
5
5
  constructor() {
6
6
  super();
@@ -17,3 +17,11 @@ class DiffOverrideJSONError extends Error {
17
17
  }
18
18
  }
19
19
  exports.DiffOverrideJSONError = DiffOverrideJSONError;
20
+ class DiffBreakingChangeError extends Error {
21
+ constructor() {
22
+ super();
23
+ this.name = 'DiffBreakingChangeError';
24
+ this.message = 'Breaking changes detected';
25
+ }
26
+ }
27
+ exports.DiffBreakingChangeError = DiffBreakingChangeError;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.47.9",
2
+ "version": "0.48.1",
3
3
  "commands": {
4
4
  "bundle": {
5
5
  "id": "bundle",
@@ -137,6 +137,12 @@
137
137
  "description": "path to JSON file containing the override properties",
138
138
  "multiple": false
139
139
  },
140
+ "no-error": {
141
+ "name": "no-error",
142
+ "type": "boolean",
143
+ "description": "don't show error on breaking changes",
144
+ "allowNo": false
145
+ },
140
146
  "watch": {
141
147
  "name": "watch",
142
148
  "type": "boolean",
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.47.9",
4
+ "version": "0.48.1",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run"
@@ -16,7 +16,7 @@
16
16
  "@asyncapi/modelina": "^1.8.4",
17
17
  "@asyncapi/openapi-schema-parser": "^3.0.0",
18
18
  "@asyncapi/optimizer": "^0.1.18",
19
- "@asyncapi/parser": "^2.0.2",
19
+ "@asyncapi/parser": "^2.0.3",
20
20
  "@asyncapi/raml-dt-schema-parser": "^4.0.2",
21
21
  "@asyncapi/studio": "^0.17.3",
22
22
  "@oclif/core": "^1.26.2",