@asyncapi/cli 1.11.0 → 1.12.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.
@@ -9,11 +9,13 @@ const validation_error_1 = require("../errors/validation-error");
9
9
  const SpecificationFile_1 = require("../models/SpecificationFile");
10
10
  const specification_file_1 = require("../errors/specification-file");
11
11
  const converter_1 = require("@asyncapi/converter");
12
+ const picocolors_1 = require("picocolors");
12
13
  // @ts-ignore
13
14
  const specs_1 = tslib_1.__importDefault(require("@asyncapi/specs"));
14
15
  const latestVersion = Object.keys(specs_1.default.schemas).pop();
15
16
  class Convert extends base_1.default {
16
17
  run() {
18
+ var _a;
17
19
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
18
20
  const { args, flags } = yield this.parse(Convert);
19
21
  const filePath = args['spec-file'];
@@ -22,15 +24,16 @@ class Convert extends base_1.default {
22
24
  try {
23
25
  // LOAD FILE
24
26
  this.specFile = yield (0, SpecificationFile_1.load)(filePath);
27
+ // eslint-disable-next-line sonarjs/no-duplicate-string
25
28
  this.metricsMetadata.to_version = flags['target-version'];
26
29
  // CONVERSION
27
30
  convertedFile = (0, converter_1.convert)(this.specFile.text(), flags['target-version']);
28
31
  if (convertedFile) {
29
32
  if (this.specFile.getFilePath()) {
30
- this.log(`File ${this.specFile.getFilePath()} successfully converted!`);
33
+ this.log(`🎉 The ${(0, picocolors_1.cyan)(this.specFile.getFilePath())} file has been successfully converted to version ${(0, picocolors_1.green)(flags['target-version'])}!!`);
31
34
  }
32
35
  else if (this.specFile.getFileURL()) {
33
- this.log(`URL ${this.specFile.getFileURL()} successfully converted!`);
36
+ this.log(`🎉 The URL ${(0, picocolors_1.cyan)(this.specFile.getFileURL())} has been successfully converted to version ${(0, picocolors_1.green)(flags['target-version'])}!!`);
34
37
  }
35
38
  }
36
39
  if (typeof convertedFile === 'object') {
@@ -53,6 +56,9 @@ class Convert extends base_1.default {
53
56
  filepath: filePath
54
57
  }));
55
58
  }
59
+ else if (((_a = this.specFile) === null || _a === void 0 ? void 0 : _a.toJson().asyncapi) > flags['target-version']) {
60
+ this.error(`The ${(0, picocolors_1.cyan)(filePath)} file cannot be converted to an older version. Downgrading is not supported.`);
61
+ }
56
62
  else {
57
63
  this.error(err);
58
64
  }
@@ -26,8 +26,6 @@ const templatesNotSupportingV3 = {
26
26
  '@asyncapi/java-spring-cloud-stream-template': 'https://github.com/asyncapi/java-spring-cloud-stream-template/issues/336',
27
27
  '@asyncapi/go-watermill-template': 'https://github.com/asyncapi/go-watermill-template/issues/243',
28
28
  '@asyncapi/java-spring-template': 'https://github.com/asyncapi/java-spring-template/issues/308',
29
- '@asyncapi/nodejs-template': 'https://github.com/asyncapi/nodejs-template/issues/215',
30
- '@asyncapi/java-template': 'https://github.com/asyncapi/java-template/issues/118',
31
29
  '@asyncapi/php-template': 'https://github.com/asyncapi/php-template/issues/191'
32
30
  };
33
31
  /**
@@ -8,6 +8,7 @@ const inquirer = tslib_1.__importStar(require("inquirer"));
8
8
  const Studio_1 = require("../../models/Studio");
9
9
  const path_1 = require("path");
10
10
  const SpecificationFile_1 = require("../../models/SpecificationFile");
11
+ const picocolors_1 = require("picocolors");
11
12
  const { writeFile, readFile } = fs_1.promises;
12
13
  const DEFAULT_ASYNCAPI_FILE_NAME = 'asyncapi.yaml';
13
14
  const DEFAULT_ASYNCAPI_TEMPLATE = 'default-example.yaml';
@@ -133,17 +134,17 @@ class NewFile extends base_1.default {
133
134
  try {
134
135
  const content = yield readFile(fileNameToWriteToDisk, { encoding: 'utf8' });
135
136
  if (content !== undefined) {
136
- console.log(`File ${fileNameToWriteToDisk} already exists. Ignoring...`);
137
+ console.log(`A file named ${fileNameToWriteToDisk} already exists. Please choose a different name.`);
137
138
  return;
138
139
  }
139
140
  }
140
141
  catch (e) {
141
142
  if (e.code === 'EACCES') {
142
- this.error('Permission denied to read the file. You do not have the necessary permissions.');
143
+ this.error('Permission has been denied to access the file.');
143
144
  }
144
145
  }
145
146
  yield writeFile(fileNameToWriteToDisk, asyncApiFile, { encoding: 'utf8' });
146
- console.log(`Created file ${fileNameToWriteToDisk}...`);
147
+ console.log(`The ${(0, picocolors_1.cyan)(fileNameToWriteToDisk)} has been successfully created.`);
147
148
  this.specFile = yield (0, SpecificationFile_1.load)(fileNameToWriteToDisk);
148
149
  this.metricsMetadata.selected_template = selectedTemplate;
149
150
  });
@@ -1,8 +1,13 @@
1
1
  import Command from '../../base';
2
2
  import { Specification } from '../../models/SpecificationFile';
3
+ export declare const successMessage: (projectName: string) => string;
3
4
  export default class NewGlee extends Command {
4
5
  static description: string;
5
6
  protected commandName: string;
7
+ static readonly successMessage: (projectName: string) => string;
8
+ static readonly errorMessages: {
9
+ alreadyExists: (projectName: string) => string;
10
+ };
6
11
  static flags: {
7
12
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
8
13
  name: import("@oclif/core/lib/interfaces").OptionFlag<string>;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.successMessage = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const core_1 = require("@oclif/core");
5
6
  const fs_1 = require("fs");
@@ -12,6 +13,23 @@ const inquirer_1 = require("inquirer");
12
13
  // eslint-disable-next-line
13
14
  // @ts-ignore
14
15
  const generator_1 = tslib_1.__importDefault(require("@asyncapi/generator"));
16
+ const picocolors_1 = require("picocolors");
17
+ const successMessage = (projectName) => `🎉 Your Glee project has been successfully created!
18
+ ⏩ Next steps: follow the instructions ${(0, picocolors_1.cyan)('below')} to manage your project:
19
+
20
+ cd ${projectName}\t\t ${(0, picocolors_1.gray)('# Navigate to the project directory')}
21
+ npm install\t\t ${(0, picocolors_1.gray)('# Install the project dependencies')}
22
+ npm run dev\t\t ${(0, picocolors_1.gray)('# Start the project in development mode')}
23
+
24
+ You can also open the project in your favourite editor and start tweaking it.
25
+ `;
26
+ exports.successMessage = successMessage;
27
+ const errorMessages = {
28
+ alreadyExists: (projectName) => `Unable to create the project because the directory "${(0, picocolors_1.cyan)(projectName)}" already exists at "${process.cwd()}/${projectName}".
29
+ To specify a different name for the new project, please run the command below with a unique project name:
30
+
31
+ ${(0, picocolors_1.gray)('asyncapi new glee --name ') + (0, picocolors_1.gray)(projectName) + (0, picocolors_1.gray)('-1')}`,
32
+ };
15
33
  class NewGlee extends base_1.default {
16
34
  constructor() {
17
35
  super(...arguments);
@@ -58,11 +76,11 @@ class NewGlee extends base_1.default {
58
76
  }
59
77
  if (fs_extra_1.default.existsSync(PROJECT_DIRECTORY) &&
60
78
  fs_extra_1.default.readdirSync(PROJECT_DIRECTORY).length > 0) {
61
- throw new Error(`Unable to create the project. We tried to use "${projectName}" as the directory of your new project but it already exists (${PROJECT_DIRECTORY}). Please specify a different name for the new project. For example, run the following command instead:\n\n asyncapi new ${this.commandName} -f ${file} --name ${projectName}-1\n`);
79
+ throw new Error(errorMessages.alreadyExists(projectName));
62
80
  }
63
81
  }
64
82
  catch (error) {
65
- this.error(error.message);
83
+ this.log(error.message);
66
84
  }
67
85
  });
68
86
  }
@@ -122,7 +140,7 @@ class NewGlee extends base_1.default {
122
140
  catch (err) {
123
141
  switch (err.code) {
124
142
  case 'EEXIST':
125
- this.error(`Unable to create the project. We tried to use "${projectName}" as the directory of your new project but it already exists (${PROJECT_DIRECTORY}). Please specify a different name for the new project. For example, run the following command instead:\n\n asyncapi new ${this.commandName} --name ${projectName}-1\n`);
143
+ this.error(errorMessages.alreadyExists(projectName));
126
144
  break;
127
145
  case 'EACCES':
128
146
  this.error(`Unable to create the project. We tried to access the "${PROJECT_DIRECTORY}" directory but it was not possible due to file access permissions. Please check the write permissions of your current working directory ("${process.cwd()}").`);
@@ -139,7 +157,7 @@ class NewGlee extends base_1.default {
139
157
  yield fs_1.promises.rename(`${PROJECT_DIRECTORY}/env`, `${PROJECT_DIRECTORY}/.env`);
140
158
  yield fs_1.promises.rename(`${PROJECT_DIRECTORY}/gitignore`, `${PROJECT_DIRECTORY}/.gitignore`);
141
159
  yield fs_1.promises.rename(`${PROJECT_DIRECTORY}/README-template.md`, `${PROJECT_DIRECTORY}/README.md`);
142
- this.log(`Your project "${projectName}" has been created successfully!\n\nNext steps:\n\n cd ${projectName}\n npm install\n npm run dev\n\nAlso, you can already open the project in your favorite editor and start tweaking it.`);
160
+ this.log((0, exports.successMessage)(projectName));
143
161
  }
144
162
  catch (err) {
145
163
  this.error(`Unable to create the project. Please check the following message for further info about the error:\n\n${err}`);
@@ -150,6 +168,8 @@ class NewGlee extends base_1.default {
150
168
  }
151
169
  exports.default = NewGlee;
152
170
  NewGlee.description = 'Creates a new Glee project';
171
+ NewGlee.successMessage = exports.successMessage;
172
+ NewGlee.errorMessages = errorMessages;
153
173
  NewGlee.flags = {
154
174
  help: core_1.Flags.help({ char: 'h' }),
155
175
  name: core_1.Flags.string({
@@ -4,7 +4,8 @@ import { Parser } from '@asyncapi/parser';
4
4
  export declare enum Optimizations {
5
5
  REMOVE_COMPONENTS = "remove-components",
6
6
  REUSE_COMPONENTS = "reuse-components",
7
- MOVE_TO_COMPONENTS = "move-to-components"
7
+ MOVE_DUPLICATES_TO_COMPONENTS = "move-duplicates-to-components",
8
+ MOVE_ALL_TO_COMPONENTS = "move-all-to-components"
8
9
  }
9
10
  export declare enum Outputs {
10
11
  TERMINAL = "terminal",
@@ -16,7 +16,8 @@ var Optimizations;
16
16
  (function (Optimizations) {
17
17
  Optimizations["REMOVE_COMPONENTS"] = "remove-components";
18
18
  Optimizations["REUSE_COMPONENTS"] = "reuse-components";
19
- Optimizations["MOVE_TO_COMPONENTS"] = "move-to-components";
19
+ Optimizations["MOVE_DUPLICATES_TO_COMPONENTS"] = "move-duplicates-to-components";
20
+ Optimizations["MOVE_ALL_TO_COMPONENTS"] = "move-all-to-components";
20
21
  })(Optimizations = exports.Optimizations || (exports.Optimizations = {}));
21
22
  var Outputs;
22
23
  (function (Outputs) {
@@ -44,9 +45,6 @@ class Optimize extends base_1.default {
44
45
  filepath: filePath,
45
46
  }));
46
47
  }
47
- if (this.specFile.isAsyncAPI3()) {
48
- this.error('Optimize command does not support AsyncAPI v3 yet, please checkout https://github.com/asyncapi/optimizer/issues/168');
49
- }
50
48
  let optimizer;
51
49
  let report;
52
50
  try {
@@ -63,7 +61,7 @@ class Optimize extends base_1.default {
63
61
  this.selectedOptimizations = flags.optimization;
64
62
  this.outputMethod = flags.output;
65
63
  this.metricsMetadata.optimized = false;
66
- if (!(((_a = report.moveToComponents) === 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))) {
64
+ 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))) {
67
65
  this.log(`No optimization has been applied since ${(_d = this.specFile.getFilePath()) !== null && _d !== void 0 ? _d : this.specFile.getFileURL()} looks optimized!`);
68
66
  return;
69
67
  }
@@ -73,7 +71,8 @@ class Optimize extends base_1.default {
73
71
  }
74
72
  try {
75
73
  const optimizedDocument = optimizer.getOptimizedDocument({ rules: {
76
- moveToComponents: this.selectedOptimizations.includes(Optimizations.MOVE_TO_COMPONENTS),
74
+ moveDuplicatesToComponents: this.selectedOptimizations.includes(Optimizations.MOVE_DUPLICATES_TO_COMPONENTS),
75
+ moveAllToComponents: this.selectedOptimizations.includes(Optimizations.MOVE_ALL_TO_COMPONENTS),
77
76
  removeComponents: this.selectedOptimizations.includes(Optimizations.REMOVE_COMPONENTS),
78
77
  reuseComponents: this.selectedOptimizations.includes(Optimizations.REUSE_COMPONENTS)
79
78
  }, output: optimizer_1.Output.YAML });
@@ -128,26 +127,33 @@ class Optimize extends base_1.default {
128
127
  this.log('\n');
129
128
  }
130
129
  interactiveRun(report) {
131
- var _a, _b, _c, _d, _e, _f;
130
+ var _a, _b, _c, _d, _e, _f, _g, _h;
132
131
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
133
- const canMove = (_a = report.moveToComponents) === null || _a === void 0 ? void 0 : _a.length;
134
- const canRemove = (_b = report.removeComponents) === null || _b === void 0 ? void 0 : _b.length;
135
- const canReuse = (_c = report.reuseComponents) === null || _c === void 0 ? void 0 : _c.length;
132
+ const canMoveDuplicates = (_a = report.moveDuplicatesToComponents) === null || _a === void 0 ? void 0 : _a.length;
133
+ const canMoveAll = (_b = report.moveAllToComponents) === null || _b === void 0 ? void 0 : _b.length;
134
+ const canRemove = (_c = report.removeComponents) === null || _c === void 0 ? void 0 : _c.length;
135
+ const canReuse = (_d = report.reuseComponents) === null || _d === void 0 ? void 0 : _d.length;
136
136
  const choices = [];
137
- if (canMove) {
138
- const totalMove = (_d = report.moveToComponents) === null || _d === void 0 ? void 0 : _d.filter((e) => e.action === 'move').length;
137
+ if (canMoveAll) {
138
+ const totalMove = (_e = report.moveAllToComponents) === null || _e === void 0 ? void 0 : _e.filter((e) => e.action === 'move').length;
139
+ this.log(`${chalk_1.default.green(totalMove)} components can be moved to the components sections.\nthe following changes will be made:`);
140
+ this.showOptimizations(report.moveAllToComponents);
141
+ choices.push({ name: 'move all $refs to components section', value: Optimizations.MOVE_ALL_TO_COMPONENTS });
142
+ }
143
+ if (canMoveDuplicates) {
144
+ const totalMove = (_f = report.moveDuplicatesToComponents) === null || _f === void 0 ? void 0 : _f.filter((e) => e.action === 'move').length;
139
145
  this.log(`\n${chalk_1.default.green(totalMove)} components can be moved to the components sections.\nthe following changes will be made:`);
140
- this.showOptimizations(report.moveToComponents);
141
- choices.push({ name: 'move to components section', value: Optimizations.MOVE_TO_COMPONENTS });
146
+ this.showOptimizations(report.moveDuplicatesToComponents);
147
+ choices.push({ name: 'move to components section', value: Optimizations.MOVE_DUPLICATES_TO_COMPONENTS });
142
148
  }
143
149
  if (canRemove) {
144
- const totalMove = (_e = report.removeComponents) === null || _e === void 0 ? void 0 : _e.length;
150
+ const totalMove = (_g = report.removeComponents) === null || _g === void 0 ? void 0 : _g.length;
145
151
  this.log(`${chalk_1.default.green(totalMove)} unused components can be removed.\nthe following changes will be made:`);
146
152
  this.showOptimizations(report.removeComponents);
147
153
  choices.push({ name: 'remove components', value: Optimizations.REMOVE_COMPONENTS });
148
154
  }
149
155
  if (canReuse) {
150
- const totalMove = (_f = report.reuseComponents) === null || _f === void 0 ? void 0 : _f.length;
156
+ const totalMove = (_h = report.reuseComponents) === null || _h === void 0 ? void 0 : _h.length;
151
157
  this.log(`${chalk_1.default.green(totalMove)} components can be reused.\nthe following changes will be made:`);
152
158
  this.showOptimizations(report.reuseComponents);
153
159
  choices.push({ name: 'reuse components', value: Optimizations.REUSE_COMPONENTS });
@@ -186,7 +192,7 @@ Optimize.description = 'optimize asyncapi specification file';
186
192
  Optimize.examples = [
187
193
  'asyncapi optimize ./asyncapi.yaml',
188
194
  'asyncapi optimize ./asyncapi.yaml --no-tty',
189
- 'asyncapi optimize ./asyncapi.yaml --optimization=remove-components --optimization=reuse-components --optimization=move-to-components --no-tty',
195
+ 'asyncapi optimize ./asyncapi.yaml --optimization=remove-components --optimization=reuse-components --optimization=move-all-to-components --no-tty',
190
196
  'asyncapi optimize ./asyncapi.yaml --optimization=remove-components --output=terminal --no-tty',
191
197
  ];
192
198
  Optimize.flags = {
@@ -11,6 +11,7 @@ const chokidar_1 = tslib_1.__importDefault(require("chokidar"));
11
11
  const open_1 = tslib_1.__importDefault(require("open"));
12
12
  const path_1 = tslib_1.__importDefault(require("path"));
13
13
  const package_json_1 = require("@asyncapi/studio/package.json");
14
+ const picocolors_1 = require("picocolors");
14
15
  const { readFile, writeFile } = fs_1.promises;
15
16
  const sockets = [];
16
17
  const messageQueue = [];
@@ -94,7 +95,8 @@ function start(filePath, port = exports.DEFAULT_PORT) {
94
95
  });
95
96
  server.listen(port, () => {
96
97
  const url = `http://localhost:${port}?liveServer=${port}&studio-version=${package_json_1.version}`;
97
- console.log(`Studio is running at ${url}`);
98
+ console.log(`Studio is now running at ${url}.`);
99
+ console.log(`You can open this URL in your web browser, and if needed, press ${(0, picocolors_1.gray)('Ctrl + C')} to stop the process.`);
98
100
  console.log(`Watching changes on file ${filePath}`);
99
101
  (0, open_1.default)(url);
100
102
  });
package/lib/parser.js CHANGED
@@ -12,6 +12,7 @@ const protobuf_schema_parser_1 = require("@asyncapi/protobuf-schema-parser");
12
12
  const spectral_core_1 = require("@stoplight/spectral-core");
13
13
  const config_1 = require("@stoplight/spectral-cli/dist/services/config");
14
14
  const spectral_formatters_1 = require("@stoplight/spectral-formatters");
15
+ const chalk_1 = require("chalk");
15
16
  const parser = new cjs_1.Parser({
16
17
  __unstable: {
17
18
  resolver: {
@@ -88,9 +89,10 @@ function logDiagnostics(diagnostics, command, specFile, options = {}) {
88
89
  return ValidationStatus.VALID;
89
90
  }
90
91
  function formatOutput(diagnostics, format, failSeverity) {
91
- const options = { failSeverity: (0, spectral_core_1.getDiagnosticSeverity)(failSeverity) };
92
+ const diagnosticSeverity = (0, spectral_core_1.getDiagnosticSeverity)(failSeverity);
93
+ const options = { failSeverity: diagnosticSeverity !== -1 ? diagnosticSeverity : cjs_1.DiagnosticSeverity.Error };
92
94
  switch (format) {
93
- case 'stylish': return (0, spectral_formatters_1.stylish)(diagnostics, options);
95
+ case 'stylish': return formatStylish(diagnostics, options);
94
96
  case 'json': return (0, spectral_formatters_1.json)(diagnostics, options);
95
97
  case 'junit': return (0, spectral_formatters_1.junit)(diagnostics, options);
96
98
  case 'html': return (0, spectral_formatters_1.html)(diagnostics, options);
@@ -101,6 +103,27 @@ function formatOutput(diagnostics, format, failSeverity) {
101
103
  }
102
104
  }
103
105
  exports.formatOutput = formatOutput;
106
+ function formatStylish(diagnostics, options) {
107
+ const groupedDiagnostics = diagnostics.reduce((acc, diagnostic) => {
108
+ const severity = diagnostic.severity;
109
+ if (!acc[severity]) {
110
+ acc[severity] = [];
111
+ }
112
+ acc[severity].push(diagnostic);
113
+ return acc;
114
+ }, {});
115
+ return Object.entries(groupedDiagnostics).map(([severity, diagnostics]) => {
116
+ return `${getSeverityTitle(Number(severity))} ${(0, spectral_formatters_1.stylish)(diagnostics, options)}`;
117
+ }).join('\n');
118
+ }
119
+ function getSeverityTitle(severity) {
120
+ switch (severity) {
121
+ case cjs_1.DiagnosticSeverity.Error: return (0, chalk_1.red)('Errors');
122
+ case cjs_1.DiagnosticSeverity.Warning: return (0, chalk_1.yellow)('Warnings');
123
+ case cjs_1.DiagnosticSeverity.Information: return (0, chalk_1.cyan)('Information');
124
+ case cjs_1.DiagnosticSeverity.Hint: return (0, chalk_1.green)('Hints');
125
+ }
126
+ }
104
127
  function hasFailSeverity(diagnostics, failSeverity) {
105
128
  const diagnosticSeverity = (0, spectral_core_1.getDiagnosticSeverity)(failSeverity);
106
129
  return diagnostics.some(diagnostic => diagnostic.severity <= diagnosticSeverity);
@@ -259,7 +259,7 @@
259
259
  "examples": [
260
260
  "asyncapi optimize ./asyncapi.yaml",
261
261
  "asyncapi optimize ./asyncapi.yaml --no-tty",
262
- "asyncapi optimize ./asyncapi.yaml --optimization=remove-components --optimization=reuse-components --optimization=move-to-components --no-tty",
262
+ "asyncapi optimize ./asyncapi.yaml --optimization=remove-components --optimization=reuse-components --optimization=move-all-to-components --no-tty",
263
263
  "asyncapi optimize ./asyncapi.yaml --optimization=remove-components --output=terminal --no-tty"
264
264
  ],
265
265
  "flags": {
@@ -277,14 +277,16 @@
277
277
  "default": [
278
278
  "remove-components",
279
279
  "reuse-components",
280
- "move-to-components"
280
+ "move-duplicates-to-components",
281
+ "move-all-to-components"
281
282
  ],
282
283
  "hasDynamicHelp": false,
283
284
  "multiple": true,
284
285
  "options": [
285
286
  "remove-components",
286
287
  "reuse-components",
287
- "move-to-components"
288
+ "move-duplicates-to-components",
289
+ "move-all-to-components"
288
290
  ],
289
291
  "type": "option"
290
292
  },
@@ -499,203 +501,6 @@
499
501
  "versions.js"
500
502
  ]
501
503
  },
502
- "new:file": {
503
- "aliases": [],
504
- "args": {},
505
- "description": "Creates a new asyncapi file",
506
- "examples": [
507
- "asyncapi new\t - start creation of a file in interactive mode",
508
- "asyncapi new --file-name=my-asyncapi.yml --example=default-example.yml --no-tty\t - create a new file with a specific name, using one of the examples and without interactive mode"
509
- ],
510
- "flags": {
511
- "help": {
512
- "char": "h",
513
- "description": "Show CLI help.",
514
- "name": "help",
515
- "allowNo": false,
516
- "type": "boolean"
517
- },
518
- "file-name": {
519
- "char": "n",
520
- "description": "name of the file",
521
- "name": "file-name",
522
- "hasDynamicHelp": false,
523
- "multiple": false,
524
- "type": "option"
525
- },
526
- "example": {
527
- "char": "e",
528
- "description": "name of the example to use. Available examples are:\n\t - simple-asyncapi.yml\n\t - anyof-asyncapi.yml\n\t - application-headers-asyncapi.yml\n\t - correlation-id-asyncapi.yml\n\t - websocket-gemini-asyncapi.yml\n\t - gitter-streaming-asyncapi.yml\n\t - kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml\n\t - kraken-websocket-request-reply-multiple-channels-asyncapi.yml\n\t - mercure-asyncapi.yml\n\t - not-asyncapi.yml\n\t - operation-security-asyncapi.yml\n\t - oneof-asyncapi.yml\n\t - rpc-client-asyncapi.yml\n\t - rpc-server-asyncapi.yml\n\t - slack-rtm-asyncapi.yml\n\t - tutorial.yml\n\t - streetlights-kafka-asyncapi.yml\n\t - streetlights-operation-security-asyncapi.yml\n\t - streetlights-mqtt-asyncapi.yml",
529
- "name": "example",
530
- "hasDynamicHelp": false,
531
- "multiple": false,
532
- "type": "option"
533
- },
534
- "studio": {
535
- "char": "s",
536
- "description": "open in Studio",
537
- "name": "studio",
538
- "allowNo": false,
539
- "type": "boolean"
540
- },
541
- "port": {
542
- "char": "p",
543
- "description": "port in which to start Studio",
544
- "name": "port",
545
- "hasDynamicHelp": false,
546
- "multiple": false,
547
- "type": "option"
548
- },
549
- "no-tty": {
550
- "description": "do not use an interactive terminal",
551
- "name": "no-tty",
552
- "allowNo": false,
553
- "type": "boolean"
554
- }
555
- },
556
- "hasDynamicHelp": false,
557
- "hiddenAliases": [],
558
- "id": "new:file",
559
- "pluginAlias": "@asyncapi/cli",
560
- "pluginName": "@asyncapi/cli",
561
- "pluginType": "core",
562
- "strict": true,
563
- "isESM": false,
564
- "relativePath": [
565
- "lib",
566
- "commands",
567
- "new",
568
- "file.js"
569
- ]
570
- },
571
- "new:glee": {
572
- "aliases": [],
573
- "args": {},
574
- "description": "Creates a new Glee project",
575
- "flags": {
576
- "help": {
577
- "char": "h",
578
- "description": "Show CLI help.",
579
- "name": "help",
580
- "allowNo": false,
581
- "type": "boolean"
582
- },
583
- "name": {
584
- "char": "n",
585
- "description": "Name of the Project",
586
- "name": "name",
587
- "default": "project",
588
- "hasDynamicHelp": false,
589
- "multiple": false,
590
- "type": "option"
591
- },
592
- "template": {
593
- "char": "t",
594
- "description": "Name of the Template",
595
- "name": "template",
596
- "default": "default",
597
- "hasDynamicHelp": false,
598
- "multiple": false,
599
- "type": "option"
600
- },
601
- "file": {
602
- "char": "f",
603
- "description": "The path to the AsyncAPI file for generating a Glee project.",
604
- "name": "file",
605
- "hasDynamicHelp": false,
606
- "multiple": false,
607
- "type": "option"
608
- },
609
- "force-write": {
610
- "description": "Force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)",
611
- "name": "force-write",
612
- "allowNo": false,
613
- "type": "boolean"
614
- }
615
- },
616
- "hasDynamicHelp": false,
617
- "hiddenAliases": [],
618
- "id": "new:glee",
619
- "pluginAlias": "@asyncapi/cli",
620
- "pluginName": "@asyncapi/cli",
621
- "pluginType": "core",
622
- "strict": true,
623
- "isESM": false,
624
- "relativePath": [
625
- "lib",
626
- "commands",
627
- "new",
628
- "glee.js"
629
- ]
630
- },
631
- "new": {
632
- "aliases": [],
633
- "args": {},
634
- "description": "Creates a new asyncapi file",
635
- "examples": [
636
- "asyncapi new\t - start creation of a file in interactive mode",
637
- "asyncapi new --file-name=my-asyncapi.yml --example=default-example.yml --no-tty\t - create a new file with a specific name, using one of the examples and without interactive mode"
638
- ],
639
- "flags": {
640
- "help": {
641
- "char": "h",
642
- "description": "Show CLI help.",
643
- "name": "help",
644
- "allowNo": false,
645
- "type": "boolean"
646
- },
647
- "file-name": {
648
- "char": "n",
649
- "description": "name of the file",
650
- "name": "file-name",
651
- "hasDynamicHelp": false,
652
- "multiple": false,
653
- "type": "option"
654
- },
655
- "example": {
656
- "char": "e",
657
- "description": "name of the example to use. Available examples are:\n\t - simple-asyncapi.yml\n\t - anyof-asyncapi.yml\n\t - application-headers-asyncapi.yml\n\t - correlation-id-asyncapi.yml\n\t - websocket-gemini-asyncapi.yml\n\t - gitter-streaming-asyncapi.yml\n\t - kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml\n\t - kraken-websocket-request-reply-multiple-channels-asyncapi.yml\n\t - mercure-asyncapi.yml\n\t - not-asyncapi.yml\n\t - operation-security-asyncapi.yml\n\t - oneof-asyncapi.yml\n\t - rpc-client-asyncapi.yml\n\t - rpc-server-asyncapi.yml\n\t - slack-rtm-asyncapi.yml\n\t - tutorial.yml\n\t - streetlights-kafka-asyncapi.yml\n\t - streetlights-operation-security-asyncapi.yml\n\t - streetlights-mqtt-asyncapi.yml",
658
- "name": "example",
659
- "hasDynamicHelp": false,
660
- "multiple": false,
661
- "type": "option"
662
- },
663
- "studio": {
664
- "char": "s",
665
- "description": "open in Studio",
666
- "name": "studio",
667
- "allowNo": false,
668
- "type": "boolean"
669
- },
670
- "port": {
671
- "char": "p",
672
- "description": "port in which to start Studio",
673
- "name": "port",
674
- "hasDynamicHelp": false,
675
- "multiple": false,
676
- "type": "option"
677
- },
678
- "no-tty": {
679
- "description": "do not use an interactive terminal",
680
- "name": "no-tty",
681
- "allowNo": false,
682
- "type": "boolean"
683
- }
684
- },
685
- "hasDynamicHelp": false,
686
- "hiddenAliases": [],
687
- "id": "new",
688
- "pluginAlias": "@asyncapi/cli",
689
- "pluginName": "@asyncapi/cli",
690
- "pluginType": "core",
691
- "isESM": false,
692
- "relativePath": [
693
- "lib",
694
- "commands",
695
- "new",
696
- "index.js"
697
- ]
698
- },
699
504
  "generate:fromTemplate": {
700
505
  "aliases": [],
701
506
  "args": {
@@ -1098,6 +903,204 @@
1098
903
  "models.js"
1099
904
  ]
1100
905
  },
906
+ "new:file": {
907
+ "aliases": [],
908
+ "args": {},
909
+ "description": "Creates a new asyncapi file",
910
+ "examples": [
911
+ "asyncapi new\t - start creation of a file in interactive mode",
912
+ "asyncapi new --file-name=my-asyncapi.yml --example=default-example.yml --no-tty\t - create a new file with a specific name, using one of the examples and without interactive mode"
913
+ ],
914
+ "flags": {
915
+ "help": {
916
+ "char": "h",
917
+ "description": "Show CLI help.",
918
+ "name": "help",
919
+ "allowNo": false,
920
+ "type": "boolean"
921
+ },
922
+ "file-name": {
923
+ "char": "n",
924
+ "description": "name of the file",
925
+ "name": "file-name",
926
+ "hasDynamicHelp": false,
927
+ "multiple": false,
928
+ "type": "option"
929
+ },
930
+ "example": {
931
+ "char": "e",
932
+ "description": "name of the example to use. Available examples are:\n\t - simple-asyncapi.yml\n\t - anyof-asyncapi.yml\n\t - application-headers-asyncapi.yml\n\t - correlation-id-asyncapi.yml\n\t - websocket-gemini-asyncapi.yml\n\t - gitter-streaming-asyncapi.yml\n\t - kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml\n\t - kraken-websocket-request-reply-multiple-channels-asyncapi.yml\n\t - mercure-asyncapi.yml\n\t - not-asyncapi.yml\n\t - operation-security-asyncapi.yml\n\t - oneof-asyncapi.yml\n\t - rpc-client-asyncapi.yml\n\t - rpc-server-asyncapi.yml\n\t - slack-rtm-asyncapi.yml\n\t - tutorial.yml\n\t - streetlights-kafka-asyncapi.yml\n\t - streetlights-operation-security-asyncapi.yml\n\t - streetlights-mqtt-asyncapi.yml",
933
+ "name": "example",
934
+ "hasDynamicHelp": false,
935
+ "multiple": false,
936
+ "type": "option"
937
+ },
938
+ "studio": {
939
+ "char": "s",
940
+ "description": "open in Studio",
941
+ "name": "studio",
942
+ "allowNo": false,
943
+ "type": "boolean"
944
+ },
945
+ "port": {
946
+ "char": "p",
947
+ "description": "port in which to start Studio",
948
+ "name": "port",
949
+ "hasDynamicHelp": false,
950
+ "multiple": false,
951
+ "type": "option"
952
+ },
953
+ "no-tty": {
954
+ "description": "do not use an interactive terminal",
955
+ "name": "no-tty",
956
+ "allowNo": false,
957
+ "type": "boolean"
958
+ }
959
+ },
960
+ "hasDynamicHelp": false,
961
+ "hiddenAliases": [],
962
+ "id": "new:file",
963
+ "pluginAlias": "@asyncapi/cli",
964
+ "pluginName": "@asyncapi/cli",
965
+ "pluginType": "core",
966
+ "strict": true,
967
+ "isESM": false,
968
+ "relativePath": [
969
+ "lib",
970
+ "commands",
971
+ "new",
972
+ "file.js"
973
+ ]
974
+ },
975
+ "new:glee": {
976
+ "aliases": [],
977
+ "args": {},
978
+ "description": "Creates a new Glee project",
979
+ "flags": {
980
+ "help": {
981
+ "char": "h",
982
+ "description": "Show CLI help.",
983
+ "name": "help",
984
+ "allowNo": false,
985
+ "type": "boolean"
986
+ },
987
+ "name": {
988
+ "char": "n",
989
+ "description": "Name of the Project",
990
+ "name": "name",
991
+ "default": "project",
992
+ "hasDynamicHelp": false,
993
+ "multiple": false,
994
+ "type": "option"
995
+ },
996
+ "template": {
997
+ "char": "t",
998
+ "description": "Name of the Template",
999
+ "name": "template",
1000
+ "default": "default",
1001
+ "hasDynamicHelp": false,
1002
+ "multiple": false,
1003
+ "type": "option"
1004
+ },
1005
+ "file": {
1006
+ "char": "f",
1007
+ "description": "The path to the AsyncAPI file for generating a Glee project.",
1008
+ "name": "file",
1009
+ "hasDynamicHelp": false,
1010
+ "multiple": false,
1011
+ "type": "option"
1012
+ },
1013
+ "force-write": {
1014
+ "description": "Force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)",
1015
+ "name": "force-write",
1016
+ "allowNo": false,
1017
+ "type": "boolean"
1018
+ }
1019
+ },
1020
+ "hasDynamicHelp": false,
1021
+ "hiddenAliases": [],
1022
+ "id": "new:glee",
1023
+ "pluginAlias": "@asyncapi/cli",
1024
+ "pluginName": "@asyncapi/cli",
1025
+ "pluginType": "core",
1026
+ "strict": true,
1027
+ "errorMessages": {},
1028
+ "isESM": false,
1029
+ "relativePath": [
1030
+ "lib",
1031
+ "commands",
1032
+ "new",
1033
+ "glee.js"
1034
+ ]
1035
+ },
1036
+ "new": {
1037
+ "aliases": [],
1038
+ "args": {},
1039
+ "description": "Creates a new asyncapi file",
1040
+ "examples": [
1041
+ "asyncapi new\t - start creation of a file in interactive mode",
1042
+ "asyncapi new --file-name=my-asyncapi.yml --example=default-example.yml --no-tty\t - create a new file with a specific name, using one of the examples and without interactive mode"
1043
+ ],
1044
+ "flags": {
1045
+ "help": {
1046
+ "char": "h",
1047
+ "description": "Show CLI help.",
1048
+ "name": "help",
1049
+ "allowNo": false,
1050
+ "type": "boolean"
1051
+ },
1052
+ "file-name": {
1053
+ "char": "n",
1054
+ "description": "name of the file",
1055
+ "name": "file-name",
1056
+ "hasDynamicHelp": false,
1057
+ "multiple": false,
1058
+ "type": "option"
1059
+ },
1060
+ "example": {
1061
+ "char": "e",
1062
+ "description": "name of the example to use. Available examples are:\n\t - simple-asyncapi.yml\n\t - anyof-asyncapi.yml\n\t - application-headers-asyncapi.yml\n\t - correlation-id-asyncapi.yml\n\t - websocket-gemini-asyncapi.yml\n\t - gitter-streaming-asyncapi.yml\n\t - kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml\n\t - kraken-websocket-request-reply-multiple-channels-asyncapi.yml\n\t - mercure-asyncapi.yml\n\t - not-asyncapi.yml\n\t - operation-security-asyncapi.yml\n\t - oneof-asyncapi.yml\n\t - rpc-client-asyncapi.yml\n\t - rpc-server-asyncapi.yml\n\t - slack-rtm-asyncapi.yml\n\t - tutorial.yml\n\t - streetlights-kafka-asyncapi.yml\n\t - streetlights-operation-security-asyncapi.yml\n\t - streetlights-mqtt-asyncapi.yml",
1063
+ "name": "example",
1064
+ "hasDynamicHelp": false,
1065
+ "multiple": false,
1066
+ "type": "option"
1067
+ },
1068
+ "studio": {
1069
+ "char": "s",
1070
+ "description": "open in Studio",
1071
+ "name": "studio",
1072
+ "allowNo": false,
1073
+ "type": "boolean"
1074
+ },
1075
+ "port": {
1076
+ "char": "p",
1077
+ "description": "port in which to start Studio",
1078
+ "name": "port",
1079
+ "hasDynamicHelp": false,
1080
+ "multiple": false,
1081
+ "type": "option"
1082
+ },
1083
+ "no-tty": {
1084
+ "description": "do not use an interactive terminal",
1085
+ "name": "no-tty",
1086
+ "allowNo": false,
1087
+ "type": "boolean"
1088
+ }
1089
+ },
1090
+ "hasDynamicHelp": false,
1091
+ "hiddenAliases": [],
1092
+ "id": "new",
1093
+ "pluginAlias": "@asyncapi/cli",
1094
+ "pluginName": "@asyncapi/cli",
1095
+ "pluginType": "core",
1096
+ "isESM": false,
1097
+ "relativePath": [
1098
+ "lib",
1099
+ "commands",
1100
+ "new",
1101
+ "index.js"
1102
+ ]
1103
+ },
1101
1104
  "start": {
1102
1105
  "aliases": [],
1103
1106
  "args": {},
@@ -1436,5 +1439,5 @@
1436
1439
  ]
1437
1440
  }
1438
1441
  },
1439
- "version": "1.11.0"
1442
+ "version": "1.12.1"
1440
1443
  }
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": "1.11.0",
4
+ "version": "1.12.1",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run_bin"
@@ -15,7 +15,7 @@
15
15
  "@asyncapi/generator": "^1.17.25",
16
16
  "@asyncapi/modelina": "^3.4.9",
17
17
  "@asyncapi/openapi-schema-parser": "^3.0.22",
18
- "@asyncapi/optimizer": "^0.2.7",
18
+ "@asyncapi/optimizer": "^1.0.2",
19
19
  "@asyncapi/parser": "^3.0.14",
20
20
  "@asyncapi/protobuf-schema-parser": "^3.2.12",
21
21
  "@asyncapi/raml-dt-schema-parser": "^4.0.22",