@asyncapi/cli 2.2.0 → 2.3.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.
@@ -6,6 +6,9 @@ export declare enum Optimizations {
6
6
  MOVE_DUPLICATES_TO_COMPONENTS = "move-duplicates-to-components",
7
7
  MOVE_ALL_TO_COMPONENTS = "move-all-to-components"
8
8
  }
9
+ export declare enum DisableOptimizations {
10
+ SCHEMA = "schema"
11
+ }
9
12
  export declare enum Outputs {
10
13
  TERMINAL = "terminal",
11
14
  NEW_FILE = "new-file",
@@ -15,11 +18,13 @@ export default class Optimize extends Command {
15
18
  static description: string;
16
19
  isInteractive: boolean;
17
20
  selectedOptimizations?: Optimizations[];
21
+ disableOptimizations?: DisableOptimizations[];
18
22
  outputMethod?: Outputs;
19
23
  static examples: string[];
20
24
  static flags: {
21
25
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
22
26
  optimization: import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
27
+ ignore: import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
23
28
  output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
24
29
  'no-tty': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
25
30
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Outputs = exports.Optimizations = void 0;
3
+ exports.Outputs = exports.DisableOptimizations = exports.Optimizations = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const core_1 = require("@oclif/core");
6
6
  const optimizer_1 = require("@asyncapi/optimizer");
@@ -20,6 +20,10 @@ var Optimizations;
20
20
  Optimizations["MOVE_DUPLICATES_TO_COMPONENTS"] = "move-duplicates-to-components";
21
21
  Optimizations["MOVE_ALL_TO_COMPONENTS"] = "move-all-to-components";
22
22
  })(Optimizations = exports.Optimizations || (exports.Optimizations = {}));
23
+ var DisableOptimizations;
24
+ (function (DisableOptimizations) {
25
+ DisableOptimizations["SCHEMA"] = "schema";
26
+ })(DisableOptimizations = exports.DisableOptimizations || (exports.DisableOptimizations = {}));
23
27
  var Outputs;
24
28
  (function (Outputs) {
25
29
  Outputs["TERMINAL"] = "terminal";
@@ -60,6 +64,7 @@ class Optimize extends base_1.default {
60
64
  }
61
65
  this.isInteractive = !flags['no-tty'];
62
66
  this.selectedOptimizations = flags.optimization;
67
+ this.disableOptimizations = flags.ignore;
63
68
  this.outputMethod = flags.output;
64
69
  this.metricsMetadata.optimized = false;
65
70
  if (!(((_a = report.moveDuplicatesToComponents) === null || _a === void 0 ? void 0 : _a.length) || ((_b = report.removeComponents) === null || _b === void 0 ? void 0 : _b.length) || ((_c = report.reuseComponents) === null || _c === void 0 ? void 0 : _c.length))) {
@@ -76,7 +81,11 @@ class Optimize extends base_1.default {
76
81
  moveAllToComponents: this.selectedOptimizations.includes(Optimizations.MOVE_ALL_TO_COMPONENTS),
77
82
  removeComponents: this.selectedOptimizations.includes(Optimizations.REMOVE_COMPONENTS),
78
83
  reuseComponents: this.selectedOptimizations.includes(Optimizations.REUSE_COMPONENTS)
79
- }, output: optimizer_1.Output.YAML });
84
+ },
85
+ disableOptimizationFor: {
86
+ schema: this.disableOptimizations.includes(DisableOptimizations.SCHEMA)
87
+ },
88
+ output: optimizer_1.Output.YAML });
80
89
  this.collectMetricsData(report);
81
90
  const specPath = this.specFile.getFilePath();
82
91
  let newPath = '';
@@ -128,7 +137,7 @@ class Optimize extends base_1.default {
128
137
  this.log('\n');
129
138
  }
130
139
  interactiveRun(report) {
131
- var _a, _b, _c, _d, _e, _f, _g, _h;
140
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
132
141
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
133
142
  const canMoveDuplicates = (_a = report.moveDuplicatesToComponents) === null || _a === void 0 ? void 0 : _a.length;
134
143
  const canMoveAll = (_b = report.moveAllToComponents) === null || _b === void 0 ? void 0 : _b.length;
@@ -159,6 +168,12 @@ class Optimize extends base_1.default {
159
168
  this.showOptimizations(report.reuseComponents);
160
169
  choices.push({ name: 'reuse components', value: Optimizations.REUSE_COMPONENTS });
161
170
  }
171
+ if ((_j = this.disableOptimizations) === null || _j === void 0 ? void 0 : _j.includes(DisableOptimizations.SCHEMA)) {
172
+ choices.push({ name: 'Do not ignore schema', value: DisableOptimizations.SCHEMA });
173
+ }
174
+ else {
175
+ choices.push({ name: 'Ignore schema', value: DisableOptimizations.SCHEMA });
176
+ }
162
177
  const optimizationRes = yield inquirer.prompt([{
163
178
  name: 'optimization',
164
179
  message: 'select the type of optimization that you want to apply:',
@@ -166,6 +181,14 @@ class Optimize extends base_1.default {
166
181
  default: 'all',
167
182
  choices
168
183
  }]);
184
+ if (optimizationRes.optimization.includes('schema')) {
185
+ if ((_k = this.disableOptimizations) === null || _k === void 0 ? void 0 : _k.includes(DisableOptimizations.SCHEMA)) {
186
+ this.disableOptimizations = (_l = this.disableOptimizations) === null || _l === void 0 ? void 0 : _l.filter(opt => opt !== DisableOptimizations.SCHEMA);
187
+ }
188
+ else {
189
+ this.disableOptimizations = [...(this.disableOptimizations || []), DisableOptimizations.SCHEMA];
190
+ }
191
+ }
169
192
  this.selectedOptimizations = optimizationRes.optimization;
170
193
  const outputRes = yield inquirer.prompt([{
171
194
  name: 'output',
@@ -195,6 +218,7 @@ Optimize.examples = [
195
218
  'asyncapi optimize ./asyncapi.yaml --no-tty',
196
219
  'asyncapi optimize ./asyncapi.yaml --optimization=remove-components --optimization=reuse-components --optimization=move-all-to-components --no-tty',
197
220
  'asyncapi optimize ./asyncapi.yaml --optimization=remove-components --output=terminal --no-tty',
221
+ 'asyncapi optimize ./asyncapi.yaml --ignore=schema'
198
222
  ];
199
223
  Optimize.flags = (0, optimize_flags_1.optimizeFlags)();
200
224
  Optimize.args = {
@@ -4,6 +4,9 @@ export declare enum Optimizations {
4
4
  MOVE_DUPLICATES_TO_COMPONENTS = "move-duplicates-to-components",
5
5
  MOVE_ALL_TO_COMPONENTS = "move-all-to-components"
6
6
  }
7
+ export declare enum DisableOptimizations {
8
+ SCHEMA = "schema"
9
+ }
7
10
  export declare enum Outputs {
8
11
  TERMINAL = "terminal",
9
12
  NEW_FILE = "new-file",
@@ -12,6 +15,7 @@ export declare enum Outputs {
12
15
  export declare const optimizeFlags: () => {
13
16
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
14
17
  optimization: import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
18
+ ignore: import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
15
19
  output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
16
20
  'no-tty': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
17
21
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optimizeFlags = exports.Outputs = exports.Optimizations = void 0;
3
+ exports.optimizeFlags = exports.Outputs = exports.DisableOptimizations = exports.Optimizations = void 0;
4
4
  const core_1 = require("@oclif/core");
5
5
  var Optimizations;
6
6
  (function (Optimizations) {
@@ -9,6 +9,10 @@ var Optimizations;
9
9
  Optimizations["MOVE_DUPLICATES_TO_COMPONENTS"] = "move-duplicates-to-components";
10
10
  Optimizations["MOVE_ALL_TO_COMPONENTS"] = "move-all-to-components";
11
11
  })(Optimizations = exports.Optimizations || (exports.Optimizations = {}));
12
+ var DisableOptimizations;
13
+ (function (DisableOptimizations) {
14
+ DisableOptimizations["SCHEMA"] = "schema";
15
+ })(DisableOptimizations = exports.DisableOptimizations || (exports.DisableOptimizations = {}));
12
16
  var Outputs;
13
17
  (function (Outputs) {
14
18
  Outputs["TERMINAL"] = "terminal";
@@ -19,6 +23,7 @@ const optimizeFlags = () => {
19
23
  return {
20
24
  help: core_1.Flags.help({ char: 'h' }),
21
25
  optimization: core_1.Flags.string({ char: 'p', default: Object.values(Optimizations), options: Object.values(Optimizations), multiple: true, description: 'select the type of optimizations that you want to apply.' }),
26
+ ignore: core_1.Flags.string({ char: 'i', default: [], options: Object.values(DisableOptimizations), multiple: true, description: 'list of components to be ignored from the optimization process' }),
22
27
  output: core_1.Flags.string({ char: 'o', default: Outputs.TERMINAL, options: Object.values(Outputs), description: 'select where you want the output.' }),
23
28
  'no-tty': core_1.Flags.boolean({ description: 'do not use an interactive terminal', default: false }),
24
29
  };
@@ -268,7 +268,8 @@
268
268
  "asyncapi optimize ./asyncapi.yaml",
269
269
  "asyncapi optimize ./asyncapi.yaml --no-tty",
270
270
  "asyncapi optimize ./asyncapi.yaml --optimization=remove-components --optimization=reuse-components --optimization=move-all-to-components --no-tty",
271
- "asyncapi optimize ./asyncapi.yaml --optimization=remove-components --output=terminal --no-tty"
271
+ "asyncapi optimize ./asyncapi.yaml --optimization=remove-components --output=terminal --no-tty",
272
+ "asyncapi optimize ./asyncapi.yaml --ignore=schema"
272
273
  ],
273
274
  "flags": {
274
275
  "help": {
@@ -298,6 +299,18 @@
298
299
  ],
299
300
  "type": "option"
300
301
  },
302
+ "ignore": {
303
+ "char": "i",
304
+ "description": "list of components to be ignored from the optimization process",
305
+ "name": "ignore",
306
+ "default": [],
307
+ "hasDynamicHelp": false,
308
+ "multiple": true,
309
+ "options": [
310
+ "schema"
311
+ ],
312
+ "type": "option"
313
+ },
301
314
  "output": {
302
315
  "char": "o",
303
316
  "description": "select where you want the output.",
@@ -1574,5 +1587,5 @@
1574
1587
  ]
1575
1588
  }
1576
1589
  },
1577
- "version": "2.2.0"
1590
+ "version": "2.3.0"
1578
1591
  }
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": "2.2.0",
4
+ "version": "2.3.0",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run_bin"