@asyncapi/cli 2.16.6 → 2.16.7

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.
Files changed (40) hide show
  1. package/lib/commands/bundle.js +4 -4
  2. package/lib/commands/config/analytics.js +1 -1
  3. package/lib/commands/config/context/add.js +1 -1
  4. package/lib/commands/config/context/current.js +1 -1
  5. package/lib/commands/config/context/edit.js +1 -1
  6. package/lib/commands/config/context/index.js +1 -1
  7. package/lib/commands/config/context/init.js +1 -1
  8. package/lib/commands/config/context/list.js +1 -1
  9. package/lib/commands/config/context/remove.js +1 -1
  10. package/lib/commands/config/context/use.js +1 -1
  11. package/lib/commands/config/index.js +1 -1
  12. package/lib/commands/config/versions.js +2 -3
  13. package/lib/commands/convert.js +1 -1
  14. package/lib/commands/diff.js +2 -2
  15. package/lib/commands/format.js +1 -1
  16. package/lib/commands/generate/fromTemplate.js +6 -7
  17. package/lib/commands/generate/index.js +1 -1
  18. package/lib/commands/generate/models.js +1 -1
  19. package/lib/commands/new/file.js +1 -1
  20. package/lib/commands/new/glee.js +2 -2
  21. package/lib/commands/new/index.js +1 -1
  22. package/lib/commands/new/template.js +1 -1
  23. package/lib/commands/optimize.js +6 -6
  24. package/lib/commands/pretty.js +1 -1
  25. package/lib/commands/start/index.js +1 -1
  26. package/lib/commands/start/studio.js +2 -2
  27. package/lib/commands/validate.js +1 -1
  28. package/lib/core/base.js +4 -4
  29. package/lib/core/flags/optimize.flags.js +3 -3
  30. package/lib/core/hooks/command_not_found/myhook.js +1 -1
  31. package/lib/core/models/Context.js +10 -10
  32. package/lib/core/models/SpecificationFile.js +10 -11
  33. package/lib/core/models/Studio.js +2 -2
  34. package/lib/core/parser.d.ts +2 -2
  35. package/lib/core/parser.js +10 -10
  36. package/lib/core/utils/generator.js +2 -2
  37. package/lib/core/utils/scoreCalculator.js +1 -2
  38. package/lib/index.js +0 -1
  39. package/oclif.manifest.json +15 -1
  40. package/package.json +8 -11
@@ -33,12 +33,12 @@ class Bundle extends base_1.default {
33
33
  else {
34
34
  const format = path_1.default.extname(output);
35
35
  if (format === '.yml' || format === '.yaml') {
36
- yield writeFile(path_1.default.resolve(process.cwd(), output), document.yml(), {
36
+ yield writeFile(path_1.default.resolve(process.cwd(), output), document.yml() || '', {
37
37
  encoding: 'utf-8',
38
38
  });
39
39
  }
40
40
  if (format === '.json') {
41
- yield writeFile(path_1.default.resolve(process.cwd(), output), document.string(), {
41
+ yield writeFile(path_1.default.resolve(process.cwd(), output), document.string() || '', {
42
42
  encoding: 'utf-8',
43
43
  });
44
44
  }
@@ -47,8 +47,8 @@ class Bundle extends base_1.default {
47
47
  });
48
48
  }
49
49
  collectMetricsData(document) {
50
- var _a;
51
50
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
51
+ var _a;
52
52
  try {
53
53
  // We collect the metadata from the final output so it contains all the files
54
54
  this.specFile = new SpecificationFile_1.Specification((_a = document.string()) !== null && _a !== void 0 ? _a : '');
@@ -61,7 +61,6 @@ class Bundle extends base_1.default {
61
61
  });
62
62
  }
63
63
  }
64
- exports.default = Bundle;
65
64
  Bundle.description = 'Bundle one or multiple AsyncAPI Documents and their references together.';
66
65
  Bundle.strict = false;
67
66
  Bundle.examples = [
@@ -73,3 +72,4 @@ Bundle.examples = [
73
72
  'asyncapi bundle ./asyncapi.yaml -o final-asyncapi.yaml --base ../public-api/main.yaml --baseDir ./social-media/comments-service',
74
73
  ];
75
74
  Bundle.flags = (0, bundle_flags_1.bundleFlags)();
75
+ exports.default = Bundle;
@@ -55,6 +55,6 @@ class Analytics extends base_1.default {
55
55
  });
56
56
  }
57
57
  }
58
- exports.default = Analytics;
59
58
  Analytics.description = 'Enable or disable analytics for metrics collection';
60
59
  Analytics.flags = (0, analytics_flags_1.analyticsFlags)();
60
+ exports.default = Analytics;
@@ -31,10 +31,10 @@ class ContextAdd extends base_1.default {
31
31
  });
32
32
  }
33
33
  }
34
- exports.default = ContextAdd;
35
34
  ContextAdd.description = 'Add a context to the store';
36
35
  ContextAdd.flags = (0, context_flags_1.addFlags)();
37
36
  ContextAdd.args = {
38
37
  'context-name': core_1.Args.string({ description: 'context name', required: true }),
39
38
  'spec-file-path': core_1.Args.string({ description: 'file path of the spec file', required: true }),
40
39
  };
40
+ exports.default = ContextAdd;
@@ -32,6 +32,6 @@ class ContextCurrent extends base_1.default {
32
32
  });
33
33
  }
34
34
  }
35
- exports.default = ContextCurrent;
36
35
  ContextCurrent.description = 'Shows the current context that is being used';
37
36
  ContextCurrent.flags = (0, global_flags_1.helpFlag)();
37
+ exports.default = ContextCurrent;
@@ -29,10 +29,10 @@ class ContextEdit extends base_1.default {
29
29
  });
30
30
  }
31
31
  }
32
- exports.default = ContextEdit;
33
32
  ContextEdit.description = 'Edit a context in the store';
34
33
  ContextEdit.flags = (0, global_flags_1.helpFlag)();
35
34
  ContextEdit.args = {
36
35
  'context-name': core_1.Args.string({ description: 'context name', required: true }),
37
36
  'new-spec-file-path': core_1.Args.string({ description: 'file path of the spec file', required: true }),
38
37
  };
38
+ exports.default = ContextEdit;
@@ -12,5 +12,5 @@ class Context extends base_1.default {
12
12
  });
13
13
  }
14
14
  }
15
- exports.default = Context;
16
15
  Context.description = 'Manage short aliases for full paths to AsyncAPI documents';
16
+ exports.default = Context;
@@ -16,7 +16,6 @@ class ContextInit extends base_1.default {
16
16
  });
17
17
  }
18
18
  }
19
- exports.default = ContextInit;
20
19
  ContextInit.description = 'Initialize context';
21
20
  ContextInit.flags = (0, global_flags_1.helpFlag)();
22
21
  ContextInit.contextFilePathMessage = `Specify directory in which context file should be created:
@@ -26,3 +25,4 @@ ContextInit.contextFilePathMessage = `Specify directory in which context file sh
26
25
  ContextInit.args = {
27
26
  'context-file-path': core_1.Args.string({ description: `${ContextInit.contextFilePathMessage}`, required: false })
28
27
  };
28
+ exports.default = ContextInit;
@@ -31,6 +31,6 @@ class ContextList extends base_1.default {
31
31
  });
32
32
  }
33
33
  }
34
- exports.default = ContextList;
35
34
  ContextList.description = 'List all the stored contexts in the store';
36
35
  ContextList.flags = (0, global_flags_1.helpFlag)();
36
+ exports.default = ContextList;
@@ -28,9 +28,9 @@ class ContextRemove extends base_1.default {
28
28
  });
29
29
  }
30
30
  }
31
- exports.default = ContextRemove;
32
31
  ContextRemove.description = 'Delete a context from the store';
33
32
  ContextRemove.flags = (0, global_flags_1.helpFlag)();
34
33
  ContextRemove.args = {
35
34
  'context-name': core_1.Args.string({ description: 'Name of the context to delete', required: true }),
36
35
  };
36
+ exports.default = ContextRemove;
@@ -29,9 +29,9 @@ class ContextUse extends base_1.default {
29
29
  });
30
30
  }
31
31
  }
32
- exports.default = ContextUse;
33
32
  ContextUse.description = 'Set a context as current';
34
33
  ContextUse.flags = (0, global_flags_1.helpFlag)();
35
34
  ContextUse.args = {
36
35
  'context-name': core_1.Args.string({ description: 'name of the saved context', required: true }),
37
36
  };
37
+ exports.default = ContextUse;
@@ -12,5 +12,5 @@ class Config extends base_1.default {
12
12
  });
13
13
  }
14
14
  }
15
- exports.default = Config;
16
15
  Config.description = 'CLI config settings';
16
+ exports.default = Config;
@@ -7,7 +7,6 @@ const picocolors_1 = require("picocolors");
7
7
  class Versions extends base_1.default {
8
8
  run() {
9
9
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- var _a;
11
10
  const dependencies = [];
12
11
  let dependency = '';
13
12
  // Preparation of the array with all dependencies '@asyncapi/*' along with
@@ -21,7 +20,7 @@ class Versions extends base_1.default {
21
20
  try {
22
21
  // Goofy name `importedPJSON` is chosen to distinguish from name `pjson`
23
22
  // used in `@oclif` source code.
24
- const importedPJSON = yield (_a = `${key}/package.json`, Promise.resolve().then(() => tslib_1.__importStar(require(_a))));
23
+ const importedPJSON = yield Promise.resolve(`${`${key}/package.json`}`).then(s => tslib_1.__importStar(require(s)));
25
24
  dependencies.push(`${key}/${importedPJSON.default.version}`);
26
25
  }
27
26
  catch (e) {
@@ -52,6 +51,6 @@ class Versions extends base_1.default {
52
51
  });
53
52
  }
54
53
  }
55
- exports.default = Versions;
56
54
  Versions.description = 'Show versions of AsyncAPI tools used';
57
55
  Versions.flags = (0, global_flags_1.helpFlag)();
56
+ exports.default = Versions;
@@ -123,10 +123,10 @@ class Convert extends base_1.default {
123
123
  }
124
124
  }
125
125
  }
126
- exports.default = Convert;
127
126
  Convert.metricsMetadata = {};
128
127
  Convert.description = 'Convert asyncapi documents older to newer versions or OpenAPI/postman-collection documents to AsyncAPI';
129
128
  Convert.flags = Object.assign(Object.assign({}, (0, convert_flags_1.convertFlags)(latestVersion)), (0, proxy_flags_1.proxyFlags)());
130
129
  Convert.args = {
131
130
  'spec-file': core_1.Args.string({ description: 'spec path, url, or context-name', required: false }),
132
131
  };
132
+ exports.default = Convert;
@@ -90,7 +90,7 @@ class Diff extends base_1.default {
90
90
  }
91
91
  const diffOutput = diff.diff(parsed.firstDocumentParsed.json(), parsed.secondDocumentParsed.json(), {
92
92
  override: overrides,
93
- outputType: outputFormat,
93
+ outputType: outputFormat, // NOSONAR
94
94
  markdownSubtype: markdownSubtype
95
95
  });
96
96
  if (outputFormat === 'json') {
@@ -144,13 +144,13 @@ class Diff extends base_1.default {
144
144
  this.log(genericOutput(diffOutput, outputType));
145
145
  }
146
146
  }
147
- exports.default = Diff;
148
147
  Diff.description = 'Find diff between two asyncapi files';
149
148
  Diff.flags = (0, diff_flags_1.diffFlags)();
150
149
  Diff.args = {
151
150
  old: core_1.Args.string({ description: 'old spec path, URL or context-name', required: true }),
152
151
  new: core_1.Args.string({ description: 'new spec path, URL or context-name', required: true }),
153
152
  };
153
+ exports.default = Diff;
154
154
  /**
155
155
  * A generic output function for diff output
156
156
  * @param diffOutput The diff output data
@@ -85,7 +85,6 @@ class Convert extends base_1.default {
85
85
  return filename;
86
86
  }
87
87
  }
88
- exports.default = Convert;
89
88
  Convert.metricsMetadata = {};
90
89
  Convert.description = 'Convert asyncapi documents from any format to yaml, yml or JSON';
91
90
  Convert.flags = (0, format_flags_1.convertFormatFlags)();
@@ -95,3 +94,4 @@ Convert.args = {
95
94
  required: false,
96
95
  }),
97
96
  };
97
+ exports.default = Convert;
@@ -17,11 +17,10 @@ const generator_error_1 = require("../../core/errors/generator-error");
17
17
  const parser_1 = require("@asyncapi/parser");
18
18
  const prompts_1 = require("@clack/prompts");
19
19
  const picocolors_1 = require("picocolors");
20
- const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
21
20
  const fromTemplate_flags_1 = require("../../core/flags/generate/fromTemplate.flags");
22
21
  const proxy_flags_1 = require("../../core/flags/proxy.flags");
23
22
  const templatesNotSupportingV3 = {
24
- '@asyncapi/minimaltemplate': 'some link',
23
+ '@asyncapi/minimaltemplate': 'some link', // For testing purpose
25
24
  '@asyncapi/dotnet-nats-template': 'https://github.com/asyncapi/dotnet-nats-template/issues/384',
26
25
  '@asyncapi/ts-nats-template': 'https://github.com/asyncapi/ts-nats-template/issues/545',
27
26
  '@asyncapi/python-paho-template': 'https://github.com/asyncapi/python-paho-template/issues/189',
@@ -75,8 +74,8 @@ class Template extends base_1.default {
75
74
  };
76
75
  }
77
76
  run() {
78
- var _a, _b;
79
77
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
78
+ var _a, _b;
80
79
  const { args, flags } = yield this.parse(Template); // NOSONAR
81
80
  const interactive = !flags['no-interactive'];
82
81
  let asyncapi = (_a = args['asyncapi']) !== null && _a !== void 0 ? _a : '';
@@ -209,7 +208,7 @@ class Template extends base_1.default {
209
208
  return;
210
209
  }
211
210
  try {
212
- const response = yield (0, node_fetch_1.default)(registryUrl);
211
+ const response = yield fetch(registryUrl);
213
212
  if (response.status === 401 && !registryAuth && !registryToken) {
214
213
  this.error('You Need to pass either registryAuth in username:password encoded in Base64 or need to pass registryToken', { exit: 1 });
215
214
  }
@@ -270,8 +269,8 @@ class Template extends base_1.default {
270
269
  }
271
270
  return mapBaseURLToFolder;
272
271
  }
273
- generate(asyncapi, template, output, options, genOption, interactive = true) {
274
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
272
+ generate(asyncapi_1, template_1, output_1, options_1, genOption_1) {
273
+ return tslib_1.__awaiter(this, arguments, void 0, function* (asyncapi, template, output, options, genOption, interactive = true) {
275
274
  let specification;
276
275
  try {
277
276
  specification = yield (0, SpecificationFile_1.load)(asyncapi);
@@ -387,7 +386,6 @@ class Template extends base_1.default {
387
386
  });
388
387
  }
389
388
  }
390
- exports.default = Template;
391
389
  Template.description = 'Generates whatever you want using templates compatible with AsyncAPI Generator.';
392
390
  Template.examples = [
393
391
  'asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --param version=1.0.0 singleFile=true --output ./docs --force-write'
@@ -397,3 +395,4 @@ Template.args = {
397
395
  asyncapi: core_1.Args.string({ description: '- Local path, url or context-name pointing to AsyncAPI file', required: false }),
398
396
  template: core_1.Args.string({ description: '- Name of the generator template like for example @asyncapi/html-template or https://github.com/asyncapi/html-template', required: false }),
399
397
  };
398
+ exports.default = Template;
@@ -11,5 +11,5 @@ class Generate extends base_1.default {
11
11
  });
12
12
  }
13
13
  }
14
- exports.default = Generate;
15
14
  Generate.description = 'Generate typed models or other things like clients, applications or docs using AsyncAPI Generator templates.';
15
+ exports.default = Generate;
@@ -120,7 +120,7 @@ class Models extends base_1.default {
120
120
  });
121
121
  }
122
122
  }
123
- exports.default = Models;
124
123
  Models.description = 'Generates typed models';
125
124
  Models.args = modelina_cli_1.ModelinaArgs;
126
125
  Models.flags = Object.assign(Object.assign({}, (0, models_flags_1.modelsFlags)()), (0, proxy_flags_1.proxyFlags)());
126
+ exports.default = Models;
@@ -151,10 +151,10 @@ class NewFile extends base_1.default {
151
151
  });
152
152
  }
153
153
  }
154
- exports.default = NewFile;
155
154
  NewFile.description = 'Creates a new asyncapi file';
156
155
  NewFile.flags = (0, file_flags_1.fileFlags)(getExamplesFlagDescription());
157
156
  NewFile.examples = [
158
157
  'asyncapi new\t - start creation of a file in interactive mode',
159
158
  'asyncapi new --file-name=my-asyncapi.yaml --example=default-example.yaml --no-tty\t - create a new file with a specific name, using one of the examples and without interactive mode'
160
159
  ];
160
+ exports.default = NewFile;
@@ -85,8 +85,8 @@ class NewGlee extends base_1.default {
85
85
  });
86
86
  }
87
87
  handleGenerateProjectWithFile(file, CURRENT_GLEE_TEMPLATE, projectName, forceWrite) {
88
- var _a;
89
88
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
89
+ var _a;
90
90
  const PROJECT_DIRECTORY = path_1.default.join(process.cwd(), projectName);
91
91
  yield this.validateFile(file, projectName, PROJECT_DIRECTORY);
92
92
  try {
@@ -170,8 +170,8 @@ class NewGlee extends base_1.default {
170
170
  });
171
171
  }
172
172
  }
173
- exports.default = NewGlee;
174
173
  NewGlee.description = 'Creates a new Glee project';
175
174
  NewGlee.successMessage = exports.successMessage;
176
175
  NewGlee.errorMessages = errorMessages;
177
176
  NewGlee.flags = (0, glee_flags_1.gleeFlags)();
177
+ exports.default = NewGlee;
@@ -11,5 +11,5 @@ class New extends base_1.default {
11
11
  });
12
12
  }
13
13
  }
14
- exports.default = New;
15
14
  New.description = 'Create a new AsyncAPI project, specification files, or templates for clients and applications.';
15
+ exports.default = New;
@@ -73,11 +73,11 @@ class template extends base_1.default {
73
73
  });
74
74
  }
75
75
  }
76
- exports.default = template;
77
76
  template.description = 'Creates a new template';
78
77
  template.successMessage = exports.successMessage;
79
78
  template.errorMessages = errorMessages;
80
79
  template.flags = (0, template_flags_1.templateFlags)();
80
+ exports.default = template;
81
81
  function copyAndModify(templateDirectory, PROJECT_DIRECTORY, rendererName, projectName) {
82
82
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
83
83
  const packageJsonPath = path_2.default.join(templateDirectory, 'package.json');
@@ -20,17 +20,17 @@ var Optimizations;
20
20
  Optimizations["REUSE_COMPONENTS"] = "reuse-components";
21
21
  Optimizations["MOVE_DUPLICATES_TO_COMPONENTS"] = "move-duplicates-to-components";
22
22
  Optimizations["MOVE_ALL_TO_COMPONENTS"] = "move-all-to-components";
23
- })(Optimizations = exports.Optimizations || (exports.Optimizations = {}));
23
+ })(Optimizations || (exports.Optimizations = Optimizations = {}));
24
24
  var DisableOptimizations;
25
25
  (function (DisableOptimizations) {
26
26
  DisableOptimizations["SCHEMA"] = "schema";
27
- })(DisableOptimizations = exports.DisableOptimizations || (exports.DisableOptimizations = {}));
27
+ })(DisableOptimizations || (exports.DisableOptimizations = DisableOptimizations = {}));
28
28
  var Outputs;
29
29
  (function (Outputs) {
30
30
  Outputs["TERMINAL"] = "terminal";
31
31
  Outputs["NEW_FILE"] = "new-file";
32
32
  Outputs["OVERWRITE"] = "overwrite";
33
- })(Outputs = exports.Outputs || (exports.Outputs = {}));
33
+ })(Outputs || (exports.Outputs = Outputs = {}));
34
34
  class Optimize extends base_1.default {
35
35
  constructor() {
36
36
  super(...arguments);
@@ -38,8 +38,8 @@ class Optimize extends base_1.default {
38
38
  this.parser = new parser_1.Parser();
39
39
  }
40
40
  run() {
41
- var _a, _b, _c, _d;
42
41
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
42
+ var _a, _b, _c, _d;
43
43
  const { args, flags } = yield this.parse(Optimize); //NOSONAR
44
44
  let filePath = args['spec-file'];
45
45
  const proxyHost = flags['proxyHost'];
@@ -155,8 +155,8 @@ class Optimize extends base_1.default {
155
155
  this.log('\n');
156
156
  }
157
157
  interactiveRun(report) {
158
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
159
158
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
159
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
160
160
  const canMoveDuplicates = (_a = report.moveDuplicatesToComponents) === null || _a === void 0 ? void 0 : _a.length;
161
161
  const canMoveAll = (_b = report.moveAllToComponents) === null || _b === void 0 ? void 0 : _b.length;
162
162
  const canRemove = (_c = report.removeComponents) === null || _c === void 0 ? void 0 : _c.length;
@@ -229,7 +229,6 @@ class Optimize extends base_1.default {
229
229
  }
230
230
  }
231
231
  }
232
- exports.default = Optimize;
233
232
  Optimize.description = 'optimize asyncapi specification file';
234
233
  Optimize.examples = [
235
234
  'asyncapi optimize ./asyncapi.yaml',
@@ -242,3 +241,4 @@ Optimize.flags = Object.assign(Object.assign({}, (0, optimize_flags_1.optimizeFl
242
241
  Optimize.args = {
243
242
  'spec-file': core_1.Args.string({ description: 'spec path, url, or context-name', required: false }),
244
243
  };
244
+ exports.default = Optimize;
@@ -55,7 +55,6 @@ class Pretty extends base_1.default {
55
55
  });
56
56
  }
57
57
  }
58
- exports.default = Pretty;
59
58
  Pretty.description = 'Beautify the AsyncAPI spec file (indentation, styling) in place or output the formatted spec to a new file.';
60
59
  Pretty.examples = [
61
60
  'asyncapi pretty ./asyncapi.yaml',
@@ -65,3 +64,4 @@ Pretty.flags = (0, pretty_flags_1.prettyFlags)();
65
64
  Pretty.args = {
66
65
  'spec-file': core_1.Args.string({ description: 'spec path, url, or context-name', required: true }),
67
66
  };
67
+ exports.default = Pretty;
@@ -11,5 +11,5 @@ class Start extends base_1.default {
11
11
  });
12
12
  }
13
13
  }
14
- exports.default = Start;
15
14
  Start.description = 'Starts AsyncAPI-related services. Currently, it supports launching the AsyncAPI Studio';
15
+ exports.default = Start;
@@ -8,8 +8,8 @@ const studio_flags_1 = require("../../core/flags/start/studio.flags");
8
8
  const core_1 = require("@oclif/core");
9
9
  class StartStudio extends base_1.default {
10
10
  run() {
11
- var _a;
12
11
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ var _a;
13
13
  const { args, flags } = yield this.parse(StartStudio);
14
14
  if (flags.file) {
15
15
  this.warn('The file flag has been removed and is being replaced by the argument spec-file. Please pass the filename directly like `asyncapi start studio asyncapi.yml`');
@@ -39,9 +39,9 @@ class StartStudio extends base_1.default {
39
39
  });
40
40
  }
41
41
  }
42
- exports.default = StartStudio;
43
42
  StartStudio.description = 'starts a new local instance of Studio';
44
43
  StartStudio.flags = (0, studio_flags_1.studioFlags)();
45
44
  StartStudio.args = {
46
45
  'spec-file': core_1.Args.string({ description: 'spec path, url, or context-name', required: false }),
47
46
  };
47
+ exports.default = StartStudio;
@@ -37,9 +37,9 @@ class Validate extends base_1.default {
37
37
  });
38
38
  }
39
39
  }
40
- exports.default = Validate;
41
40
  Validate.description = 'validate asyncapi file';
42
41
  Validate.flags = Object.assign(Object.assign({}, (0, validate_flags_1.validateFlags)()), (0, proxy_flags_1.proxyFlags)());
43
42
  Validate.args = {
44
43
  'spec-file': core_1.Args.string({ description: 'spec path, url, or context-name', required: false }),
45
44
  };
45
+ exports.default = Validate;
package/lib/core/base.js CHANGED
@@ -54,8 +54,8 @@ class default_1 extends core_1.Command {
54
54
  }
55
55
  });
56
56
  }
57
- recordActionFinished(action, metadata = {}, rawDocument) {
58
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
57
+ recordActionFinished(action_1) {
58
+ return tslib_1.__awaiter(this, arguments, void 0, function* (action, metadata = {}, rawDocument) {
59
59
  if (rawDocument !== undefined) {
60
60
  try {
61
61
  const { document } = yield this.parser.parse(rawDocument);
@@ -103,8 +103,8 @@ class default_1 extends core_1.Command {
103
103
  });
104
104
  }
105
105
  setSource() {
106
- var _a;
107
106
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
107
+ var _a;
108
108
  const specFilePath = (_a = this.specFile) === null || _a === void 0 ? void 0 : _a.getFilePath();
109
109
  if (!specFilePath) {
110
110
  return;
@@ -122,8 +122,8 @@ class default_1 extends core_1.Command {
122
122
  const _super = Object.create(null, {
123
123
  finally: { get: () => super.finally }
124
124
  });
125
- var _a;
126
125
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
126
+ var _a;
127
127
  yield _super.finally.call(this, error);
128
128
  this.metricsMetadata['success'] = error === undefined;
129
129
  yield this.recordActionFinished(this.id, this.metricsMetadata, (_a = this.specFile) === null || _a === void 0 ? void 0 : _a.text());
@@ -8,17 +8,17 @@ var Optimizations;
8
8
  Optimizations["REUSE_COMPONENTS"] = "reuse-components";
9
9
  Optimizations["MOVE_DUPLICATES_TO_COMPONENTS"] = "move-duplicates-to-components";
10
10
  Optimizations["MOVE_ALL_TO_COMPONENTS"] = "move-all-to-components";
11
- })(Optimizations = exports.Optimizations || (exports.Optimizations = {}));
11
+ })(Optimizations || (exports.Optimizations = Optimizations = {}));
12
12
  var DisableOptimizations;
13
13
  (function (DisableOptimizations) {
14
14
  DisableOptimizations["SCHEMA"] = "schema";
15
- })(DisableOptimizations = exports.DisableOptimizations || (exports.DisableOptimizations = {}));
15
+ })(DisableOptimizations || (exports.DisableOptimizations = DisableOptimizations = {}));
16
16
  var Outputs;
17
17
  (function (Outputs) {
18
18
  Outputs["TERMINAL"] = "terminal";
19
19
  Outputs["NEW_FILE"] = "new-file";
20
20
  Outputs["OVERWRITE"] = "overwrite";
21
- })(Outputs = exports.Outputs || (exports.Outputs = {}));
21
+ })(Outputs || (exports.Outputs = Outputs = {}));
22
22
  const optimizeFlags = () => {
23
23
  return {
24
24
  help: core_1.Flags.help({ char: 'h' }),
@@ -14,8 +14,8 @@ const closest = (target, possibilities) => {
14
14
  };
15
15
  exports.closest = closest;
16
16
  const hook = function (opts) {
17
- var _a;
18
17
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
18
+ var _a;
19
19
  if (opts.id === '--help') {
20
20
  const help = new core_1.Help(this.config);
21
21
  help.showHelp(['--help']);
@@ -1,6 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isContextFileEmpty = exports.loadContextFile = exports.editContext = exports.setCurrentContext = exports.getCurrentContext = exports.removeContext = exports.addContext = exports.loadContext = exports.initContext = exports.CONTEXT_FILE_PATH = exports.DEFAULT_CONTEXT_FILE_PATH = void 0;
3
+ exports.CONTEXT_FILE_PATH = exports.DEFAULT_CONTEXT_FILE_PATH = void 0;
4
+ exports.initContext = initContext;
5
+ exports.loadContext = loadContext;
6
+ exports.addContext = addContext;
7
+ exports.removeContext = removeContext;
8
+ exports.getCurrentContext = getCurrentContext;
9
+ exports.setCurrentContext = setCurrentContext;
10
+ exports.editContext = editContext;
11
+ exports.loadContextFile = loadContextFile;
12
+ exports.isContextFileEmpty = isContextFileEmpty;
4
13
  const tslib_1 = require("tslib");
5
14
  const fs_1 = require("fs");
6
15
  const path = tslib_1.__importStar(require("path"));
@@ -90,7 +99,6 @@ function initContext(contextFilePath) {
90
99
  return contextWritePath;
91
100
  });
92
101
  }
93
- exports.initContext = initContext;
94
102
  function loadContext(contextName) {
95
103
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
96
104
  const fileContent = yield loadContextFile();
@@ -111,7 +119,6 @@ function loadContext(contextName) {
111
119
  throw new context_error_1.MissingCurrentContextError();
112
120
  });
113
121
  }
114
- exports.loadContext = loadContext;
115
122
  function addContext(contextName, pathToFile) {
116
123
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
117
124
  const fileContent = yield loadContextFile();
@@ -125,7 +132,6 @@ function addContext(contextName, pathToFile) {
125
132
  yield saveContextFile(fileContent);
126
133
  });
127
134
  }
128
- exports.addContext = addContext;
129
135
  function removeContext(contextName) {
130
136
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
131
137
  const fileContent = yield loadContextFile();
@@ -142,7 +148,6 @@ function removeContext(contextName) {
142
148
  yield saveContextFile(fileContent);
143
149
  });
144
150
  }
145
- exports.removeContext = removeContext;
146
151
  function getCurrentContext() {
147
152
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
148
153
  const fileContent = yield loadContextFile();
@@ -156,7 +161,6 @@ function getCurrentContext() {
156
161
  };
157
162
  });
158
163
  }
159
- exports.getCurrentContext = getCurrentContext;
160
164
  function setCurrentContext(contextName) {
161
165
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
162
166
  const fileContent = yield loadContextFile();
@@ -170,7 +174,6 @@ function setCurrentContext(contextName) {
170
174
  yield saveContextFile(fileContent);
171
175
  });
172
176
  }
173
- exports.setCurrentContext = setCurrentContext;
174
177
  function editContext(contextName, pathToFile) {
175
178
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
176
179
  // The expression is not wrapped in a `try...catch` block and is allowed to
@@ -185,7 +188,6 @@ function editContext(contextName, pathToFile) {
185
188
  yield saveContextFile(fileContent);
186
189
  });
187
190
  }
188
- exports.editContext = editContext;
189
191
  function loadContextFile() {
190
192
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
191
193
  let fileContent;
@@ -214,7 +216,6 @@ function loadContextFile() {
214
216
  return fileContent;
215
217
  });
216
218
  }
217
- exports.loadContextFile = loadContextFile;
218
219
  function saveContextFile(fileContent) {
219
220
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
220
221
  try {
@@ -318,4 +319,3 @@ function isContextFileEmpty(fileContent) {
318
319
  Object.keys(fileContent.store).length === 0);
319
320
  });
320
321
  }
321
- exports.isContextFileEmpty = isContextFileEmpty;
@@ -1,11 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertToJSON = exports.convertToYaml = exports.retrieveFileFormat = exports.fileExists = exports.isURL = exports.nameType = exports.load = exports.Specification = void 0;
3
+ exports.Specification = void 0;
4
+ exports.load = load;
5
+ exports.nameType = nameType;
6
+ exports.isURL = isURL;
7
+ exports.fileExists = fileExists;
8
+ exports.retrieveFileFormat = retrieveFileFormat;
9
+ exports.convertToYaml = convertToYaml;
10
+ exports.convertToJSON = convertToJSON;
4
11
  const tslib_1 = require("tslib");
5
12
  const fs_1 = require("fs");
6
13
  const path_1 = tslib_1.__importDefault(require("path"));
7
14
  const url_1 = require("url");
8
- const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
9
15
  const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
10
16
  const Context_1 = require("./Context");
11
17
  const specification_file_1 = require("../errors/specification-file");
@@ -98,14 +104,14 @@ class Specification {
98
104
  new url_1.URL(proxyUrl);
99
105
  const proxyAgent = new https_proxy_agent_1.HttpsProxyAgent(proxyUrl);
100
106
  fetchOptions.agent = proxyAgent;
101
- response = yield (0, node_fetch_1.default)(targetUrl, fetchOptions);
107
+ response = yield fetch(targetUrl, fetchOptions);
102
108
  }
103
109
  catch (err) {
104
110
  throw new Error('Proxy Connection Error: Unable to establish a connection to the proxy check hostName or PortNumber');
105
111
  }
106
112
  }
107
113
  else {
108
- response = yield (0, node_fetch_1.default)(targetUrl);
114
+ response = yield fetch(targetUrl);
109
115
  if (!response.ok) {
110
116
  throw new specification_file_1.ErrorLoadingSpec('url', targetUrl);
111
117
  }
@@ -172,7 +178,6 @@ function load(filePathOrContextName, loadType) {
172
178
  }
173
179
  });
174
180
  }
175
- exports.load = load;
176
181
  function nameType(name) {
177
182
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
178
183
  if (name.startsWith('.')) {
@@ -192,7 +197,6 @@ function nameType(name) {
192
197
  }
193
198
  });
194
199
  }
195
- exports.nameType = nameType;
196
200
  function isURL(urlpath) {
197
201
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
198
202
  try {
@@ -204,7 +208,6 @@ function isURL(urlpath) {
204
208
  }
205
209
  });
206
210
  }
207
- exports.isURL = isURL;
208
211
  function fileExists(name) {
209
212
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
210
213
  try {
@@ -223,7 +226,6 @@ function fileExists(name) {
223
226
  }
224
227
  });
225
228
  }
226
- exports.fileExists = fileExists;
227
229
  function loadFromContext(contextName) {
228
230
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
229
231
  try {
@@ -267,7 +269,6 @@ function retrieveFileFormat(content) {
267
269
  return undefined;
268
270
  }
269
271
  }
270
- exports.retrieveFileFormat = retrieveFileFormat;
271
272
  function convertToYaml(spec) {
272
273
  try {
273
274
  // JS object -> YAML string
@@ -278,7 +279,6 @@ function convertToYaml(spec) {
278
279
  console.error(err);
279
280
  }
280
281
  }
281
- exports.convertToYaml = convertToYaml;
282
282
  function convertToJSON(spec) {
283
283
  try {
284
284
  // JSON or YAML String -> JS object
@@ -290,4 +290,3 @@ function convertToJSON(spec) {
290
290
  console.error(err);
291
291
  }
292
292
  }
293
- exports.convertToJSON = convertToJSON;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.start = exports.DEFAULT_PORT = void 0;
3
+ exports.DEFAULT_PORT = void 0;
4
+ exports.start = start;
4
5
  const tslib_1 = require("tslib");
5
6
  const fs_1 = require("fs");
6
7
  const specification_file_1 = require("../errors/specification-file");
@@ -118,7 +119,6 @@ function start(filePath, port = exports.DEFAULT_PORT) {
118
119
  (0, open_1.default)(url);
119
120
  });
120
121
  }
121
- exports.start = start;
122
122
  function sendQueuedMessages() {
123
123
  while (messageQueue.length && sockets.length) {
124
124
  const nextMessage = messageQueue.shift();
@@ -24,10 +24,10 @@ export interface ValidateOptions {
24
24
  'fail-severity'?: SeverityKind;
25
25
  'output'?: string;
26
26
  }
27
- export declare function validate(command: Command, specFile: Specification, options?: ValidateOptions): Promise<"valid" | "invalid">;
27
+ export declare function validate(command: Command, specFile: Specification, options?: ValidateOptions): Promise<"invalid" | "valid">;
28
28
  export declare function parse(command: Command, specFile: Specification, options?: ValidateOptions): Promise<{
29
29
  document: import("@asyncapi/parser/cjs").AsyncAPIDocumentInterface | undefined;
30
30
  diagnostics: import("@stoplight/spectral-core").ISpectralDiagnostic[];
31
- status: "valid" | "invalid";
31
+ status: "invalid" | "valid";
32
32
  }>;
33
33
  export declare function formatOutput(diagnostics: Diagnostic[], format: `${OutputFormat}`, failSeverity: SeverityKind): string;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatOutput = exports.parse = exports.validate = exports.validationFlags = exports.ValidationStatus = exports.convertToOldAPI = void 0;
3
+ exports.ValidationStatus = exports.convertToOldAPI = void 0;
4
+ exports.validationFlags = validationFlags;
5
+ exports.validate = validate;
6
+ exports.parse = parse;
7
+ exports.formatOutput = formatOutput;
4
8
  const tslib_1 = require("tslib");
5
9
  const avro_schema_parser_1 = require("@asyncapi/avro-schema-parser");
6
10
  const openapi_schema_parser_1 = require("@asyncapi/openapi-schema-parser");
@@ -41,7 +45,7 @@ var ValidationStatus;
41
45
  (function (ValidationStatus) {
42
46
  ValidationStatus["INVALID"] = "invalid";
43
47
  ValidationStatus["VALID"] = "valid";
44
- })(ValidationStatus = exports.ValidationStatus || (exports.ValidationStatus = {}));
48
+ })(ValidationStatus || (exports.ValidationStatus = ValidationStatus = {}));
45
49
  function validationFlags({ logDiagnostics = true } = {}) {
46
50
  return {
47
51
  'log-diagnostics': core_1.Flags.boolean({
@@ -65,22 +69,19 @@ function validationFlags({ logDiagnostics = true } = {}) {
65
69
  })
66
70
  };
67
71
  }
68
- exports.validationFlags = validationFlags;
69
- function validate(command, specFile, options = {}) {
70
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
72
+ function validate(command_1, specFile_1) {
73
+ return tslib_1.__awaiter(this, arguments, void 0, function* (command, specFile, options = {}) {
71
74
  const diagnostics = yield parser.validate(specFile.text(), { source: specFile.getSource() });
72
75
  return logDiagnostics(diagnostics, command, specFile, options);
73
76
  });
74
77
  }
75
- exports.validate = validate;
76
- function parse(command, specFile, options = {}) {
77
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
78
+ function parse(command_1, specFile_1) {
79
+ return tslib_1.__awaiter(this, arguments, void 0, function* (command, specFile, options = {}) {
78
80
  const { document, diagnostics } = yield parser.parse(specFile.text(), { source: specFile.getSource() });
79
81
  const status = logDiagnostics(diagnostics, command, specFile, options);
80
82
  return { document, diagnostics, status };
81
83
  });
82
84
  }
83
- exports.parse = parse;
84
85
  function logDiagnostics(diagnostics, command, specFile, options = {}) {
85
86
  var _a, _b;
86
87
  const logDiagnostics = options['log-diagnostics'];
@@ -129,7 +130,6 @@ function formatOutput(diagnostics, format, failSeverity) {
129
130
  default: return (0, spectral_formatters_1.stylish)(diagnostics, options);
130
131
  }
131
132
  }
132
- exports.formatOutput = formatOutput;
133
133
  function formatStylish(diagnostics, options) {
134
134
  const groupedDiagnostics = diagnostics.reduce((acc, diagnostic) => {
135
135
  const severity = diagnostic.severity;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Watcher = exports.isLocalTemplate = void 0;
3
+ exports.Watcher = void 0;
4
+ exports.isLocalTemplate = isLocalTemplate;
4
5
  const tslib_1 = require("tslib");
5
6
  // eslint-disable security/detect-object-injection
6
7
  const fs = tslib_1.__importStar(require("fs"));
@@ -13,7 +14,6 @@ function isLocalTemplate(templatePath) {
13
14
  return stats.isSymbolicLink();
14
15
  });
15
16
  }
16
- exports.isLocalTemplate = isLocalTemplate;
17
17
  class Watcher {
18
18
  constructor(paths, ignorePaths) {
19
19
  if (Array.isArray(paths)) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateScore = void 0;
3
+ exports.calculateScore = calculateScore;
4
4
  const tslib_1 = require("tslib");
5
5
  function calculateScore(document) {
6
6
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -20,4 +20,3 @@ function calculateScore(document) {
20
20
  return (scoreEvaluate / 1) * 100;
21
21
  });
22
22
  }
23
- exports.calculateScore = calculateScore;
package/lib/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = void 0;
4
3
  var core_1 = require("@oclif/core");
5
4
  Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
6
5
  /**
@@ -1089,6 +1089,20 @@
1089
1089
  "allowNo": false,
1090
1090
  "type": "boolean"
1091
1091
  },
1092
+ "goIncludeComments": {
1093
+ "description": "Golang specific, if enabled add comments while generating models.",
1094
+ "name": "goIncludeComments",
1095
+ "required": false,
1096
+ "allowNo": false,
1097
+ "type": "boolean"
1098
+ },
1099
+ "goIncludeTags": {
1100
+ "description": "Golang specific, if enabled add tags while generating models.",
1101
+ "name": "goIncludeTags",
1102
+ "required": false,
1103
+ "allowNo": false,
1104
+ "type": "boolean"
1105
+ },
1092
1106
  "javaIncludeComments": {
1093
1107
  "description": "Java specific, if enabled add comments while generating models.",
1094
1108
  "name": "javaIncludeComments",
@@ -1771,5 +1785,5 @@
1771
1785
  ]
1772
1786
  }
1773
1787
  },
1774
- "version": "2.16.6"
1788
+ "version": "2.16.7"
1775
1789
  }
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.16.6",
4
+ "version": "2.16.7",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run_bin"
@@ -13,7 +13,7 @@
13
13
  "@asyncapi/converter": "^1.6.2",
14
14
  "@asyncapi/diff": "^0.5.0",
15
15
  "@asyncapi/generator": "^1.17.25",
16
- "@asyncapi/modelina-cli": "^4.0.0-next.48",
16
+ "@asyncapi/modelina-cli": "^4.0.4",
17
17
  "@asyncapi/openapi-schema-parser": "^3.0.24",
18
18
  "@asyncapi/optimizer": "^1.0.4",
19
19
  "@asyncapi/parser": "^3.3.0",
@@ -22,7 +22,7 @@
22
22
  "@asyncapi/studio": "^0.20.0",
23
23
  "@changesets/changelog-git": "^0.2.0",
24
24
  "@clack/prompts": "^0.7.0",
25
- "@oclif/core": "^4.2.8",
25
+ "@oclif/core": "^4.2.9",
26
26
  "@smoya/asyncapi-adoption-metrics": "^2.4.9",
27
27
  "@stoplight/spectral-cli": "6.9.0",
28
28
  "chalk": "^4.1.0",
@@ -33,15 +33,14 @@
33
33
  "https-proxy-agent": "^7.0.6",
34
34
  "inquirer": "^8.2.0",
35
35
  "js-yaml": "^4.1.0",
36
- "node-fetch": "^2.0.0",
37
- "oclif": "^4.2.0",
36
+ "oclif": "^4.17.34",
38
37
  "open": "^8.4.0",
39
38
  "picocolors": "^1.0.0",
40
39
  "reflect-metadata": "^0.1.13",
41
40
  "serve-handler": "^6.1.3",
42
41
  "strip-ansi": "^6.0.0",
43
42
  "unzipper": "^0.10.11",
44
- "uuid": "^9.0.1",
43
+ "uuid": "^11.1.0",
45
44
  "ws": "^8.2.3",
46
45
  "yaml": "^2.6.1"
47
46
  },
@@ -57,11 +56,11 @@
57
56
  "@types/inquirer": "^8.1.3",
58
57
  "@types/js-yaml": "^4.0.5",
59
58
  "@types/mocha": "^10.0.2",
60
- "@types/node": "^10.17.60",
59
+ "@types/node": "^22.13.10",
61
60
  "@types/node-fetch": "^2.5.12",
62
61
  "@types/rimraf": "^3.0.2",
63
62
  "@types/serve-handler": "^6.1.1",
64
- "@types/uuid": "^9.0.8",
63
+ "@types/uuid": "^10.0.0",
65
64
  "@types/wrap-ansi": "^8.0.1",
66
65
  "@types/ws": "^8.2.0",
67
66
  "@typescript-eslint/eslint-plugin": "^5.38.1",
@@ -79,13 +78,11 @@
79
78
  "markdown-toc": "^1.2.0",
80
79
  "mocha": "^10.2.0",
81
80
  "nyc": "^15.1.0",
82
- "react": "^16.14.0",
83
- "react-dom": "^16.14.0",
84
81
  "rimraf": "^3.0.2",
85
82
  "simple-git": "^3.16.0",
86
83
  "ts-node": "^10.9.1",
87
84
  "tslib": "^2.3.1",
88
- "typescript": "^4.6.4"
85
+ "typescript": "^5.8.2"
89
86
  },
90
87
  "engines": {
91
88
  "node": ">12.16"