@asyncapi/cli 5.0.1 → 5.0.3

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,30 +6,42 @@ const express_1 = require("express");
6
6
  const problem_exception_1 = require("../exceptions/problem.exception");
7
7
  const app_openapi_1 = require("../../../utils/app-openapi");
8
8
  const getCommandsFromRequest = (req) => {
9
- return req.params.command
10
- ? req.params.command.split('/').filter((cmd) => cmd.trim())
11
- : [];
12
- };
13
- const isKeyValid = (key, obj) => {
14
- return Object.keys(obj).includes(key);
9
+ var _a, _b;
10
+ const param = (_b = (_a = req.params.command) !== null && _a !== void 0 ? _a : req.params[0]) !== null && _b !== void 0 ? _b : '';
11
+ if (Array.isArray(param)) {
12
+ return param.filter((cmd) => cmd.trim());
13
+ }
14
+ return param.split('/').filter((cmd) => cmd.trim());
15
15
  };
16
16
  const getPathKeysMatchingCommands = (commands, pathKeys) => {
17
- if (!Array.isArray(pathKeys) ||
18
- !pathKeys.every((key) => typeof key === 'string')) {
19
- return undefined;
17
+ const exactPath = `/${commands.join('/')}`;
18
+ if (pathKeys.includes(exactPath)) {
19
+ return exactPath;
20
20
  }
21
21
  return pathKeys.find((pathKey) => {
22
22
  const pathParts = pathKey.split('/').filter((part) => part !== '');
23
- return pathParts.every((pathPart, i) => {
24
- const command = commands[Number(i)];
25
- return pathPart === command || pathPart.startsWith('{');
26
- });
23
+ if (pathParts.length !== commands.length) {
24
+ return false;
25
+ }
26
+ return pathParts.every((pathPart, i) => pathPart === commands[i] || pathPart.startsWith('{') || pathPart.startsWith(':'));
27
27
  });
28
28
  };
29
29
  const getFullRequestBodySpec = (operationDetails) => {
30
- return isKeyValid('requestBody', operationDetails)
31
- ? operationDetails.requestBody.content['application/json'].schema
32
- : null;
30
+ var _a, _b, _c, _d;
31
+ const schema = (_d = (_c = (_b = (_a = operationDetails === null || operationDetails === void 0 ? void 0 : operationDetails.requestBody) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b['application/json']) === null || _c === void 0 ? void 0 : _c.schema) !== null && _d !== void 0 ? _d : null;
32
+ if (!schema) {
33
+ return null;
34
+ }
35
+ const seen = new WeakSet();
36
+ return JSON.parse(JSON.stringify(schema, (_key, value) => {
37
+ if (typeof value === 'object' && value !== null) {
38
+ if (seen.has(value)) {
39
+ return '[Circular]';
40
+ }
41
+ seen.add(value);
42
+ }
43
+ return value;
44
+ }));
33
45
  };
34
46
  const buildResponseObject = (matchedPathKey, method, operationDetails, requestBodySchema) => {
35
47
  return {
@@ -46,54 +58,47 @@ class HelpController {
46
58
  boot() {
47
59
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
48
60
  const router = (0, express_1.Router)();
49
- router.get('/help/:command*?', (req, res, next) => tslib_1.__awaiter(this, void 0, void 0, function* () {
50
- const commands = getCommandsFromRequest(req);
51
- let openapiSpec;
61
+ const helpHandler = (req, res, next) => tslib_1.__awaiter(this, void 0, void 0, function* () {
62
+ var _a;
52
63
  try {
53
- openapiSpec = yield (0, app_openapi_1.getAppOpenAPI)();
54
- }
55
- catch (err) {
56
- return next(err);
57
- }
58
- if (commands.length === 0) {
59
- const routes = isKeyValid('paths', openapiSpec)
60
- ? Object.keys(openapiSpec.paths).map((path) => ({
64
+ const openapiSpec = yield (0, app_openapi_1.getAppOpenAPI)();
65
+ const paths = (_a = openapiSpec === null || openapiSpec === void 0 ? void 0 : openapiSpec.paths) !== null && _a !== void 0 ? _a : {};
66
+ const pathKeys = Object.keys(paths);
67
+ const commands = getCommandsFromRequest(req);
68
+ if (commands.length === 0) {
69
+ return res.json(pathKeys.map((path) => ({
61
70
  command: path.replace(/^\//, ''),
62
71
  url: `${this.basepath}${path}`,
63
- }))
64
- : [];
65
- return res.json(routes);
66
- }
67
- const pathKeys = isKeyValid('paths', openapiSpec)
68
- ? Object.keys(openapiSpec.paths)
69
- : [];
70
- const matchedPathKey = getPathKeysMatchingCommands(commands, pathKeys);
71
- if (!matchedPathKey) {
72
- return next(new problem_exception_1.ProblemException({
73
- type: 'invalid-asyncapi-command',
74
- title: 'Invalid AsyncAPI Command',
75
- status: 404,
76
- detail: 'The given AsyncAPI command is not valid.',
77
- }));
72
+ })));
73
+ }
74
+ const matchedPathKey = getPathKeysMatchingCommands(commands, pathKeys);
75
+ if (!matchedPathKey) {
76
+ return next(new problem_exception_1.ProblemException({
77
+ type: 'invalid-asyncapi-command',
78
+ title: 'Invalid AsyncAPI Command',
79
+ status: 404,
80
+ detail: 'The given AsyncAPI command is not valid.',
81
+ }));
82
+ }
83
+ const pathInfo = paths[matchedPathKey];
84
+ const method = pathInfo.get ? 'get' : 'post';
85
+ const operationDetails = pathInfo[method];
86
+ if (!operationDetails) {
87
+ return next(new problem_exception_1.ProblemException({
88
+ type: 'invalid-asyncapi-command',
89
+ title: 'Invalid AsyncAPI Command',
90
+ status: 404,
91
+ detail: 'The given AsyncAPI command is not valid.',
92
+ }));
93
+ }
94
+ const requestBodySchema = getFullRequestBodySpec(operationDetails);
95
+ return res.json(buildResponseObject(matchedPathKey, method, operationDetails, requestBodySchema));
78
96
  }
79
- const pathInfo = isKeyValid(matchedPathKey, openapiSpec.paths)
80
- ? openapiSpec.paths[String(matchedPathKey)]
81
- : undefined;
82
- const method = commands.length > 1 ? 'get' : 'post';
83
- const operationDetails = isKeyValid(method, pathInfo)
84
- ? pathInfo[String(method)]
85
- : undefined;
86
- if (!operationDetails) {
87
- return next(new problem_exception_1.ProblemException({
88
- type: 'invalid-asyncapi-command',
89
- title: 'Invalid AsyncAPI Command',
90
- status: 404,
91
- detail: 'The given AsyncAPI command is not valid.',
92
- }));
97
+ catch (err) {
98
+ return next(err);
93
99
  }
94
- const requestBodySchema = getFullRequestBodySpec(operationDetails);
95
- return res.json(buildResponseObject(matchedPathKey, method, operationDetails, requestBodySchema));
96
- }));
100
+ });
101
+ router.get(`${this.basepath}{/*command}`, helpHandler);
97
102
  return router;
98
103
  });
99
104
  }
@@ -9,6 +9,7 @@ const picocolors_1 = require("picocolors");
9
9
  class ContextCurrent extends base_1.default {
10
10
  run() {
11
11
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ yield this.parse(ContextCurrent);
12
13
  let fileContent;
13
14
  try {
14
15
  fileContent = yield (0, Context_1.getCurrentContext)();
@@ -9,6 +9,7 @@ const picocolors_1 = require("picocolors");
9
9
  class ContextList extends base_1.default {
10
10
  run() {
11
11
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ yield this.parse(ContextList);
12
13
  try {
13
14
  const fileContent = yield (0, Context_1.loadContextFile)();
14
15
  if (yield (0, Context_1.isContextFileEmpty)(fileContent)) {
@@ -23,7 +23,7 @@ class Versions extends base_1.default {
23
23
  const importedPJSON = yield Promise.resolve(`${`${key}/package.json`}`).then(s => tslib_1.__importStar(require(s)));
24
24
  dependencies.push(`${key}/${importedPJSON.default.version}`);
25
25
  }
26
- catch (e) {
26
+ catch (_a) {
27
27
  dependencies.push(`${key}/` + '`package.json` not found');
28
28
  }
29
29
  }
@@ -39,7 +39,7 @@ class Versions extends base_1.default {
39
39
  // https://github.com/eslint-community/eslint-plugin-security/issues/21#issuecomment-530184612
40
40
  // https://github.com/eslint-community/eslint-plugin-security/issues/21#issuecomment-1157887653
41
41
  // https://web.archive.org/web/20150430062816/https://blog.liftsecurity.io/2015/01/15/the-dangers-of-square-bracket-notation
42
- dependency = dependencies[i]; // eslint-disable-line
42
+ dependency = dependencies[i];
43
43
  if (i !== dependencies.length - 1) {
44
44
  this.log(` ├${dependency}`);
45
45
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- /* eslint-disable sonarjs/no-duplicate-string */
5
4
  const core_1 = require("@oclif/core");
6
5
  const diff = tslib_1.__importStar(require("@asyncapi/diff"));
7
6
  const fs_1 = require("fs");
@@ -284,13 +283,13 @@ function readOverrideFile(path) {
284
283
  try {
285
284
  overrideStringData = yield readFile(path, { encoding: 'utf8' });
286
285
  }
287
- catch (err) {
286
+ catch (_a) {
288
287
  throw new diff_error_1.DiffOverrideFileError();
289
288
  }
290
289
  try {
291
290
  return JSON.parse(overrideStringData);
292
291
  }
293
- catch (err) {
292
+ catch (_b) {
294
293
  throw new diff_error_1.DiffOverrideJSONError();
295
294
  }
296
295
  });
@@ -12,7 +12,6 @@ const fromTemplate_flags_1 = require("../../internal/flags/generate/fromTemplate
12
12
  const flags_1 = require("../../../../utils/generate/flags");
13
13
  const prompts_2 = require("../../../../utils/generate/prompts");
14
14
  class Template extends BaseGeneratorCommand_1.BaseGeneratorCommand {
15
- // eslint-disable-next-line sonarjs/cognitive-complexity
16
15
  run() {
17
16
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
18
17
  var _a, _b, _c;
@@ -42,9 +41,8 @@ class Template extends BaseGeneratorCommand_1.BaseGeneratorCommand {
42
41
  try {
43
42
  specification = yield (0, SpecificationFile_1.load)(asyncapi);
44
43
  }
45
- catch (err) {
44
+ catch (_d) {
46
45
  return this.error(new validation_error_1.ValidationError({
47
- // eslint-disable-next-line sonarjs/no-duplicate-string
48
46
  type: 'invalid-file',
49
47
  filepath: asyncapi,
50
48
  }), { exit: 1 });
@@ -15,7 +15,6 @@ class Models extends base_1.default {
15
15
  super(...arguments);
16
16
  this.validationService = new validation_service_1.ValidationService();
17
17
  }
18
- // eslint-disable-next-line sonarjs/cognitive-complexity
19
18
  run() {
20
19
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
20
  const { args, flags } = yield this.parse(Models);
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const fs_1 = require("fs");
5
5
  const base_1 = tslib_1.__importDefault(require("../../internal/base"));
6
- const inquirer = tslib_1.__importStar(require("inquirer"));
6
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
7
7
  const Studio_1 = require("../../../../domains/models/Studio");
8
8
  const path_1 = require("path");
9
9
  const SpecificationFile_1 = require("../../../../domains/models/SpecificationFile");
@@ -76,7 +76,7 @@ class NewFile extends base_1.default {
76
76
  const exampleFiles = yield readFile((0, path_1.resolve)(__dirname, '../../assets/examples/examples.json'), { encoding: 'utf8' });
77
77
  examples = JSON.parse(exampleFiles);
78
78
  }
79
- catch (error) {
79
+ catch (_a) {
80
80
  // no examples found
81
81
  }
82
82
  if (!selectedTemplate && examples.length > 0) {
@@ -105,7 +105,7 @@ class NewFile extends base_1.default {
105
105
  });
106
106
  }
107
107
  if (questions.length) {
108
- const answers = yield inquirer.prompt(questions);
108
+ const answers = yield inquirer_1.default.prompt(questions);
109
109
  if (!fileName) {
110
110
  fileName = answers.filename;
111
111
  }
@@ -7,7 +7,7 @@ const optimizer_1 = require("@asyncapi/optimizer");
7
7
  const base_1 = tslib_1.__importDefault(require("../internal/base"));
8
8
  const validation_error_1 = require("../../../errors/validation-error");
9
9
  const SpecificationFile_1 = require("../../../domains/models/SpecificationFile");
10
- const inquirer = tslib_1.__importStar(require("inquirer"));
10
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
11
11
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
12
12
  const fs_1 = require("fs");
13
13
  const parser_1 = require("@asyncapi/parser");
@@ -68,7 +68,7 @@ class Optimize extends base_1.default {
68
68
  optimizer = new optimizer_1.Optimizer(this.specFile.text());
69
69
  report = yield optimizer.getReport();
70
70
  }
71
- catch (err) {
71
+ catch (_e) {
72
72
  this.error(new validation_error_1.ValidationError({
73
73
  type: 'invalid-syntax-file',
74
74
  filepath: this.specFile.getFilePath(),
@@ -215,7 +215,7 @@ class Optimize extends base_1.default {
215
215
  value: DisableOptimizations.SCHEMA,
216
216
  });
217
217
  }
218
- const optimizationRes = yield inquirer.prompt([
218
+ const optimizationRes = yield inquirer_1.default.prompt([
219
219
  {
220
220
  name: 'optimization',
221
221
  message: 'select the type of optimization that you want to apply:',
@@ -236,7 +236,7 @@ class Optimize extends base_1.default {
236
236
  }
237
237
  }
238
238
  this.selectedOptimizations = optimizationRes.optimization;
239
- const outputRes = yield inquirer.prompt([
239
+ const outputRes = yield inquirer_1.default.prompt([
240
240
  {
241
241
  name: 'output',
242
242
  message: 'where do you want to save the result:',
@@ -17,7 +17,7 @@ class Pretty extends base_1.default {
17
17
  try {
18
18
  this.specFile = yield (0, SpecificationFile_1.load)(filePath);
19
19
  }
20
- catch (err) {
20
+ catch (_a) {
21
21
  this.error(new validation_error_1.ValidationError({
22
22
  type: 'invalid-file',
23
23
  filepath: filePath,
@@ -28,7 +28,7 @@ class StartStudio extends base_1.default {
28
28
  filePath = (yield (0, SpecificationFile_1.load)()).getFilePath();
29
29
  this.log(`Loaded specification from: ${filePath}`);
30
30
  }
31
- catch (error) {
31
+ catch (_c) {
32
32
  filePath = '';
33
33
  this.error('No file specified.');
34
34
  }
@@ -103,7 +103,7 @@ class BaseGeneratorCommand extends base_1.default {
103
103
  try {
104
104
  return yield (0, SpecificationFile_1.load)(asyncapi);
105
105
  }
106
- catch (err) {
106
+ catch (_a) {
107
107
  return this.error(new validation_error_1.ValidationError({
108
108
  type: 'invalid-file',
109
109
  filepath: asyncapi,
@@ -60,7 +60,6 @@ class default_1 extends core_1.Command {
60
60
  try {
61
61
  const { document } = yield this.parser.parse(rawDocument);
62
62
  if (document !== undefined) {
63
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
64
63
  // @ts-ignore
65
64
  metadata = (0, asyncapi_adoption_metrics_1.MetadataFromDocument)(document, metadata);
66
65
  }
@@ -115,8 +114,7 @@ class default_1 extends core_1.Command {
115
114
  this.metricsMetadata['file_creation_timestamp'] = stats.birthtimeMs;
116
115
  }
117
116
  catch (_b) {
118
- // If there's an error with the file, we don't handle it here
119
- // because it's expected to be handled and reported in the 'finally' method of the command.
117
+ // If there's an error with the file, we don't handle it here because it's expected to be handled and reported in the 'finally' method of the command.
120
118
  }
121
119
  });
122
120
  }
@@ -93,7 +93,7 @@ function initContext(contextFilePath) {
93
93
  encoding: 'utf8',
94
94
  });
95
95
  }
96
- catch (e) {
96
+ catch (_a) {
97
97
  throw new context_error_1.ContextFileWriteError(contextWritePath);
98
98
  }
99
99
  return contextWritePath;
@@ -196,7 +196,7 @@ function loadContextFile() {
196
196
  try {
197
197
  yield readFile(exports.CONTEXT_FILE_PATH, { encoding: 'utf8' });
198
198
  }
199
- catch (e) {
199
+ catch (_a) {
200
200
  throw new context_error_1.MissingContextFileError();
201
201
  }
202
202
  // If the context file cannot be parsed then it's a
@@ -204,7 +204,7 @@ function loadContextFile() {
204
204
  try {
205
205
  fileContent = JSON.parse(yield readFile(exports.CONTEXT_FILE_PATH, { encoding: 'utf8' }));
206
206
  }
207
- catch (e) {
207
+ catch (_b) {
208
208
  // https://stackoverflow.com/questions/29797946/handling-bad-json-parse-in-node-safely
209
209
  throw new context_error_1.ContextFileWrongFormatError(exports.CONTEXT_FILE_PATH);
210
210
  }
@@ -224,7 +224,7 @@ function saveContextFile(fileContent) {
224
224
  store: fileContent.store,
225
225
  }), { encoding: 'utf8' });
226
226
  }
227
- catch (e) {
227
+ catch (_a) {
228
228
  throw new context_error_1.ContextFileWriteError(exports.CONTEXT_FILE_PATH);
229
229
  }
230
230
  });
@@ -23,14 +23,13 @@ exports.DEFAULT_PORT = 0;
23
23
  function isValidFilePath(filePath) {
24
24
  return (0, fs_1.existsSync)(filePath);
25
25
  }
26
+ // Using require here is necessary for dynamic module resolution
26
27
  function resolveStudioNextInstance(studioPath) {
27
28
  var _a;
28
29
  const resolvedNextPath = require.resolve('next', { paths: [studioPath] });
29
- // eslint-disable-next-line @typescript-eslint/no-var-requires,security/detect-non-literal-require
30
30
  const nextModule = require(resolvedNextPath);
31
31
  return (_a = nextModule.default) !== null && _a !== void 0 ? _a : nextModule;
32
32
  }
33
- // eslint-disable-next-line sonarjs/cognitive-complexity
34
33
  function startPreview(filePath, base, baseDirectory, xOrigin, suppressLogs, port = exports.DEFAULT_PORT, noBrowser) {
35
34
  if (filePath && !isValidFilePath(filePath)) {
36
35
  throw new specification_file_1.SpecificationFileNotFound(filePath);
@@ -48,7 +48,7 @@ class Specification {
48
48
  try {
49
49
  return js_yaml_1.default.load(this.spec, { json: true });
50
50
  }
51
- catch (e) {
51
+ catch (_a) {
52
52
  return JSON.parse(this.spec);
53
53
  }
54
54
  }
@@ -80,7 +80,7 @@ class Specification {
80
80
  try {
81
81
  spec = yield readFile(filepath, { encoding: 'utf8' });
82
82
  }
83
- catch (error) {
83
+ catch (_a) {
84
84
  throw new specification_file_1.ErrorLoadingSpec('file', filepath);
85
85
  }
86
86
  return new Specification(spec, { filepath });
@@ -195,7 +195,7 @@ function nameType(name) {
195
195
  }
196
196
  return TYPE_CONTEXT_NAME;
197
197
  }
198
- catch (e) {
198
+ catch (_a) {
199
199
  if (yield isURL(name)) {
200
200
  return TYPE_URL;
201
201
  }
@@ -209,7 +209,7 @@ function isURL(urlpath) {
209
209
  const url = new url_1.URL(urlpath);
210
210
  return url.protocol === 'http:' || url.protocol === 'https:';
211
211
  }
212
- catch (error) {
212
+ catch (_a) {
213
213
  return false;
214
214
  }
215
215
  });
@@ -227,7 +227,7 @@ function fileExists(name) {
227
227
  }
228
228
  throw new specification_file_1.ErrorLoadingSpec('file', name);
229
229
  }
230
- catch (e) {
230
+ catch (_a) {
231
231
  throw new specification_file_1.ErrorLoadingSpec('file', name);
232
232
  }
233
233
  });
@@ -253,7 +253,7 @@ function detectSpecFile() {
253
253
  const exists = yield fileExists(path_1.default.resolve(process.cwd(), filename));
254
254
  return exists ? filename : undefined;
255
255
  }
256
- catch (e) {
256
+ catch (_a) {
257
257
  // We did our best...
258
258
  }
259
259
  })));
@@ -271,7 +271,7 @@ function retrieveFileFormat(content) {
271
271
  js_yaml_1.default.load(content);
272
272
  return 'yaml';
273
273
  }
274
- catch (err) {
274
+ catch (_a) {
275
275
  return undefined;
276
276
  }
277
277
  }
@@ -19,14 +19,13 @@ exports.DEFAULT_PORT = 0;
19
19
  function isValidFilePath(filePath) {
20
20
  return (0, fs_1.existsSync)(filePath);
21
21
  }
22
+ // Using require here is necessary for dynamic module resolution
22
23
  function resolveStudioNextInstance(studioPath) {
23
24
  var _a;
24
25
  const resolvedNextPath = require.resolve('next', { paths: [studioPath] });
25
- // eslint-disable-next-line @typescript-eslint/no-var-requires,security/detect-non-literal-require
26
26
  const nextModule = require(resolvedNextPath);
27
27
  return (_a = nextModule.default) !== null && _a !== void 0 ? _a : nextModule;
28
28
  }
29
- // eslint-disable-next-line sonarjs/cognitive-complexity
30
29
  function start(filePath, port = exports.DEFAULT_PORT, noBrowser) {
31
30
  if (filePath && !isValidFilePath(filePath)) {
32
31
  throw new specification_file_1.SpecificationFileNotFound(filePath);
@@ -72,7 +71,7 @@ function start(filePath, port = exports.DEFAULT_PORT, noBrowser) {
72
71
  console.log(json);
73
72
  }
74
73
  }
75
- catch (e) {
74
+ catch (_a) {
76
75
  console.error(`Live Server: An invalid event has been received. See details:\n${event}`);
77
76
  }
78
77
  });
@@ -88,7 +88,6 @@ class ConfigService {
88
88
  const regexStr = escaped
89
89
  .replace(/\*\*/g, '.*')
90
90
  .replace(/\*/g, '[^/]*');
91
- // eslint-disable-next-line security/detect-non-literal-regexp
92
91
  return new RegExp(`^${regexStr}`);
93
92
  }
94
93
  }
@@ -10,7 +10,7 @@ const raml_dt_schema_parser_1 = require("@asyncapi/raml-dt-schema-parser");
10
10
  const protobuf_schema_parser_1 = require("@asyncapi/protobuf-schema-parser");
11
11
  const spectral_core_1 = require("@stoplight/spectral-core");
12
12
  const spectral_formatters_1 = require("@stoplight/spectral-formatters");
13
- const chalk_1 = require("chalk");
13
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
14
14
  const fs_1 = require("fs");
15
15
  const path_1 = tslib_1.__importDefault(require("path"));
16
16
  const scoreCalculator_1 = require("../../utils/scoreCalculator");
@@ -24,7 +24,7 @@ const isValidGitHubBlobUrl = (url) => {
24
24
  return (parsedUrl.hostname === 'github.com' &&
25
25
  parsedUrl.pathname.split('/')[3] === 'blob');
26
26
  }
27
- catch (error) {
27
+ catch (_a) {
28
28
  return false;
29
29
  }
30
30
  };
@@ -374,13 +374,13 @@ class ValidationService extends base_service_1.BaseService {
374
374
  getSeverityTitle(severity) {
375
375
  switch (severity) {
376
376
  case cjs_1.DiagnosticSeverity.Error:
377
- return (0, chalk_1.red)('Errors');
377
+ return chalk_1.default.red('Errors');
378
378
  case cjs_1.DiagnosticSeverity.Warning:
379
- return (0, chalk_1.yellow)('Warnings');
379
+ return chalk_1.default.yellow('Warnings');
380
380
  case cjs_1.DiagnosticSeverity.Information:
381
- return (0, chalk_1.cyan)('Information');
381
+ return chalk_1.default.cyan('Information');
382
382
  case cjs_1.DiagnosticSeverity.Hint:
383
- return (0, chalk_1.green)('Hints');
383
+ return chalk_1.default.green('Hints');
384
384
  default:
385
385
  return 'Unknown';
386
386
  }
@@ -25,7 +25,7 @@ function getMapBaseUrlToFolderResolver(urlToFolder) {
25
25
  }
26
26
  });
27
27
  }
28
- catch (err) {
28
+ catch (_a) {
29
29
  reject(`Error opening file "${localpath}"`);
30
30
  }
31
31
  });
@@ -23,7 +23,7 @@ function registryValidation(registryUrl, registryAuth, registryToken) {
23
23
  throw new Error('You Need to pass either registryAuth in username:password encoded in Base64 or need to pass registryToken');
24
24
  }
25
25
  }
26
- catch (error) {
26
+ catch (_a) {
27
27
  throw new Error(`Can't fetch registryURL: ${registryUrl}`);
28
28
  }
29
29
  });
@@ -85,7 +85,7 @@ class Watcher {
85
85
  }), 500);
86
86
  }
87
87
  }
88
- catch (e) {
88
+ catch (_a) {
89
89
  // File was not, find all files that are missing..
90
90
  const unknownPaths = this.getAllNonExistingPaths();
91
91
  this.closeWatchers();
@@ -177,7 +177,7 @@ watchHandler) {
177
177
  // eslint-disable-next-line
178
178
  templateName = require(path_1.default.resolve(watchDir, 'package.json')).name;
179
179
  }
180
- catch (_) {
180
+ catch (_a) {
181
181
  // intentional
182
182
  }
183
183
  let watcher;
@@ -14,10 +14,9 @@ function createTempDirectory() {
14
14
  function removeTempDirectory(tmpDir) {
15
15
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
16
  try {
17
- // eslint-disable-next-line no-unused-expressions
18
- tmpDir &&
19
- fs_1.default.existsSync(tmpDir) &&
20
- (yield fs_1.promises.rm(tmpDir, { recursive: true }));
17
+ if (tmpDir && fs_1.default.existsSync(tmpDir)) {
18
+ yield fs_1.promises.rm(tmpDir, { recursive: true });
19
+ }
21
20
  }
22
21
  catch (e) {
23
22
  logger_1.logger.error(`An error has occurred while removing the temp folder at ${tmpDir}. Please remove it manually. Error: ${e}`);
@@ -269,7 +269,12 @@
269
269
  "html",
270
270
  "text",
271
271
  "teamcity",
272
- "pretty"
272
+ "pretty",
273
+ "github-actions",
274
+ "sarif",
275
+ "code-climate",
276
+ "gitlab",
277
+ "markdown"
273
278
  ],
274
279
  "type": "option"
275
280
  },
@@ -564,7 +569,12 @@
564
569
  "html",
565
570
  "text",
566
571
  "teamcity",
567
- "pretty"
572
+ "pretty",
573
+ "github-actions",
574
+ "sarif",
575
+ "code-climate",
576
+ "gitlab",
577
+ "markdown"
568
578
  ],
569
579
  "type": "option"
570
580
  },
@@ -1352,7 +1362,12 @@
1352
1362
  "html",
1353
1363
  "text",
1354
1364
  "teamcity",
1355
- "pretty"
1365
+ "pretty",
1366
+ "github-actions",
1367
+ "sarif",
1368
+ "code-climate",
1369
+ "gitlab",
1370
+ "markdown"
1356
1371
  ],
1357
1372
  "type": "option"
1358
1373
  },
@@ -2131,5 +2146,5 @@
2131
2146
  ]
2132
2147
  }
2133
2148
  },
2134
- "version": "5.0.1"
2149
+ "version": "5.0.3"
2135
2150
  }
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": "5.0.1",
4
+ "version": "5.0.3",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run_bin"
@@ -12,97 +12,94 @@
12
12
  },
13
13
  "bugs": "https://github.com/asyncapi/cli/issues",
14
14
  "dependencies": {
15
- "@asyncapi/avro-schema-parser": "^3.0.23",
15
+ "@asyncapi/avro-schema-parser": "^3.0.24",
16
16
  "@asyncapi/bundler": "^0.6.4",
17
17
  "@asyncapi/converter": "^1.6.2",
18
18
  "@asyncapi/diff": "^0.5.0",
19
19
  "@asyncapi/generator": "^3.0.1",
20
- "@asyncapi/modelina-cli": "^5.3.5",
20
+ "@asyncapi/modelina-cli": "^5.10.1",
21
21
  "@asyncapi/openapi-schema-parser": "^3.0.24",
22
22
  "@asyncapi/optimizer": "^1.0.4",
23
- "@asyncapi/parser": "^3.3.0",
23
+ "@asyncapi/parser": "^3.4.0",
24
24
  "@asyncapi/problem": "^1.0.0",
25
25
  "@asyncapi/protobuf-schema-parser": "^3.6.0",
26
26
  "@asyncapi/raml-dt-schema-parser": "^4.0.24",
27
27
  "@asyncapi/studio": "^1.1.0",
28
28
  "@changesets/changelog-git": "^0.2.0",
29
- "@clack/prompts": "^0.7.0",
30
- "@oclif/core": "^4.2.9",
31
- "@oclif/plugin-autocomplete": "^3.2.26",
29
+ "@clack/prompts": "^0.11.0",
30
+ "@oclif/core": "^4.8.0",
31
+ "@oclif/plugin-autocomplete": "^3.2.39",
32
32
  "@smoya/asyncapi-adoption-metrics": "^2.4.9",
33
- "@stoplight/spectral-cli": "6.9.0",
33
+ "@stoplight/spectral-cli": "6.15.0",
34
34
  "archiver": "^7.0.1",
35
- "body-parser": "^2.2.0",
36
- "chalk": "^4.1.0",
37
- "chokidar": "^3.5.2",
38
- "compression": "^1.8.0",
39
- "config": "^4.0.0",
35
+ "body-parser": "^2.2.1",
36
+ "chalk": "^4.1.2",
37
+ "chokidar": "^4.0.3",
38
+ "compression": "^1.8.1",
39
+ "config": "^4.1.1",
40
40
  "cors": "^2.8.5",
41
- "express": "^4.17.1",
41
+ "express": "^5.2.1",
42
42
  "fast-levenshtein": "^3.0.0",
43
- "fs-extra": "^11.1.0",
43
+ "fs-extra": "^11.3.2",
44
+ "generator-v2": "npm:@asyncapi/generator@3.0.1",
44
45
  "helmet": "^8.1.0",
45
46
  "https-proxy-agent": "^7.0.6",
46
- "inquirer": "^8.2.0",
47
- "js-yaml": "^4.1.0",
48
- "oclif": "^4.17.34",
49
- "open": "^8.4.0",
50
- "picocolors": "^1.1.0",
51
- "redoc-express": "^2.1.0",
52
- "unzipper": "^0.10.11",
53
- "uuid": "^11.1.0",
54
- "winston": "^3.17.0",
55
- "ws": "^8.2.3",
56
- "yaml": "^2.6.1"
47
+ "inquirer": "^8.2.6",
48
+ "js-yaml": "^4.1.1",
49
+ "oclif": "^4.22.57",
50
+ "open": "^8.4.2",
51
+ "picocolors": "^1.1.1",
52
+ "redoc-express": "^2.1.3",
53
+ "unzipper": "^0.12.3",
54
+ "uuid": "^11.0.3",
55
+ "winston": "^3.19.0",
56
+ "ws": "^8.18.3",
57
+ "yaml": "^2.8.2"
57
58
  },
58
59
  "devDependencies": {
59
60
  "@asyncapi/minimaltemplate": "./test/fixtures/minimaltemplate",
60
61
  "@asyncapi/newtemplate": "./test/fixtures/newtemplate",
61
- "@commitlint/cli": "^19.8.1",
62
- "@commitlint/config-conventional": "^19.8.1",
63
- "@oclif/test": "^2",
64
- "@types/archiver": "^6.0.3",
62
+ "@eslint/js": "^9.39.2",
63
+ "@oclif/test": "^3.2.15",
64
+ "@types/archiver": "^7.0.0",
65
65
  "@types/body-parser": "^1.19.6",
66
- "@types/chai": "^4.3.6",
66
+ "@types/chai": "^5.2.3",
67
67
  "@types/compression": "^1.8.1",
68
68
  "@types/config": "^3.3.5",
69
69
  "@types/cors": "^2.8.19",
70
- "@types/express": "^5.0.3",
71
- "@types/fast-levenshtein": "^0.0.2",
72
- "@types/fs-extra": "^11.0.1",
73
- "@types/inquirer": "^8.1.3",
74
- "@types/js-yaml": "^4.0.5",
75
- "@types/mocha": "^10.0.2",
76
- "@types/node": "^22.13.10",
77
- "@types/rimraf": "^3.0.2",
70
+ "@types/express": "^5.0.6",
71
+ "@types/fast-levenshtein": "^0.0.4",
72
+ "@types/fs-extra": "^11.0.4",
73
+ "@types/inquirer": "^9.0.9",
74
+ "@types/js-yaml": "^4.0.9",
75
+ "@types/mocha": "^10.0.10",
76
+ "@types/node": "^25.0.3",
78
77
  "@types/supertest": "^6.0.3",
79
- "@types/uuid": "^10.0.0",
80
- "@types/ws": "^8.2.0",
81
- "@typescript-eslint/eslint-plugin": "^5.38.1",
82
- "@typescript-eslint/parser": "^5.38.1",
83
- "chai": "^4.3.6",
84
- "cross-env": "^7.0.3",
85
- "eslint": "^8.24.0",
86
- "eslint-config-oclif": "^4",
87
- "eslint-config-oclif-typescript": "^1.0.3",
88
- "eslint-plugin-github": "^4.3.7",
89
- "eslint-plugin-security": "^1.4.0",
90
- "eslint-plugin-sonarjs": "^0.15.0",
78
+ "@types/ws": "^8.18.1",
79
+ "@typescript-eslint/eslint-plugin": "^8.50.0",
80
+ "@typescript-eslint/parser": "^8.50.0",
81
+ "c8": "^10.1.3",
82
+ "chai": "^6.2.1",
83
+ "cross-env": "^10.1.0",
84
+ "eslint": "^9.39.2",
85
+ "eslint-config-oclif": "^6",
86
+ "eslint-plugin-github": "^6.0.0",
87
+ "eslint-plugin-security": "^3.0.1",
88
+ "eslint-plugin-sonarjs": "^3.0.5",
91
89
  "markdown-toc": "^1.2.0",
92
- "mocha": "^10.2.0",
93
- "nodemon": "^3.1.10",
94
- "nyc": "^15.1.0",
95
- "puppeteer": "^24.17.0",
96
- "rimraf": "^3.0.2",
97
- "simple-git": "^3.16.0",
90
+ "mocha": "^11.7.5",
91
+ "nodemon": "^3.1.11",
92
+ "puppeteer": "^24.33.0",
93
+ "rimraf": "^6.1.2",
94
+ "simple-git": "^3.30.0",
98
95
  "supertest": "^7.1.4",
99
- "ts-node": "^10.9.1",
96
+ "ts-node": "^10.9.2",
100
97
  "tsc-alias": "^1.8.16",
101
98
  "tsconfig-paths": "^4.2.0",
102
- "typescript": "^5.8.2"
99
+ "typescript": "^5.9.3"
103
100
  },
104
101
  "engines": {
105
- "node": ">=24.0"
102
+ "node": ">=24.0.0"
106
103
  },
107
104
  "files": [
108
105
  "/bin",
@@ -157,7 +154,7 @@
157
154
  "access": "public"
158
155
  },
159
156
  "optionalDependencies": {
160
- "fsevents": "^2.3.2"
157
+ "fsevents": "^2.3.3"
161
158
  },
162
159
  "scripts": {
163
160
  "build": "rimraf lib && node scripts/fetch-asyncapi-example.js && npm run generate:languages && tsc && tsc-alias --project tsconfig.json && oclif manifest && echo \"Build Completed\"",
@@ -171,8 +168,8 @@
171
168
  "generate:commands": "npm run generate:readme:create && npm run generate:readme:commands && node ./scripts/updateUsageDocs.js && rimraf ./scripts/README.md",
172
169
  "generate:readme:toc": "markdown-toc -i README.md",
173
170
  "generate:languages": "node scripts/generateTypesForGenerateCommand.js",
174
- "lint": "eslint --max-warnings 5 --config .eslintrc .",
175
- "lint:fix": "eslint --max-warnings 5 --config .eslintrc . --fix",
171
+ "lint": "eslint --max-warnings 5 .",
172
+ "lint:fix": "eslint --max-warnings 5 . --fix",
176
173
  "pack:macos": "oclif pack macos && npm run pack:rename",
177
174
  "pack:linux": "oclif pack deb && npm run pack:rename",
178
175
  "pack:tarballs": "oclif pack tarballs -t linux-x64 && npm run pack:rename",
@@ -186,9 +183,9 @@
186
183
  "posttest": "rimraf ./test.asyncapi-cli",
187
184
  "postinstall": "node ./scripts/enableAutoComplete.js",
188
185
  "test": "npm run cli:test && npm run action:test",
189
- "cli:test": "cross-env NODE_ENV=development TEST=1 CUSTOM_CONTEXT_FILENAME=\"test.asyncapi-cli\" CUSTOM_CONTEXT_FILE_LOCATION=\"\" NODE_CONFIG_DIR=\"./src/apps/api/configs\" nyc --extension .ts mocha --require ts-node/register --require tsconfig-paths/register --require test/helpers/init.js --reporter spec --timeout 100000 \"test/**/*.test.ts\"",
190
- "unit:test": "cross-env NODE_ENV=development TEST=1 CUSTOM_CONTEXT_FILENAME=\"test.asyncapi-cli\" CUSTOM_CONTEXT_FILE_LOCATION=\"\" NODE_CONFIG_DIR=\"./src/apps/api/configs\" nyc --extension .ts mocha --require ts-node/register --require tsconfig-paths/register --require test/helpers/init.js --reporter spec --timeout 100000 \"test/unit/**/*.test.ts\"",
191
- "test:one": "cross-env NODE_ENV=development TEST=1 CUSTOM_CONTEXT_FILENAME=\"test.asyncapi-cli\" CUSTOM_CONTEXT_FILE_LOCATION=\"\" NODE_CONFIG_DIR=\"./src/apps/api/configs\" nyc --extension .ts mocha --require ts-node/register --require tsconfig-paths/register --require test/helpers/init.js --reporter spec --timeout 100000",
186
+ "cli:test": "cross-env NODE_ENV=development TEST=1 CUSTOM_CONTEXT_FILENAME=\"test.asyncapi-cli\" CUSTOM_CONTEXT_FILE_LOCATION=\"\" NODE_CONFIG_DIR=\"./src/apps/api/configs\" c8 mocha --require ts-node/register --require tsconfig-paths/register --require test/helpers/init.js --reporter spec --timeout 100000 \"test/**/*.test.ts\"",
187
+ "unit:test": "cross-env NODE_ENV=development TEST=1 CUSTOM_CONTEXT_FILENAME=\"test.asyncapi-cli\" CUSTOM_CONTEXT_FILE_LOCATION=\"\" NODE_CONFIG_DIR=\"./src/apps/api/configs\" c8 mocha --require ts-node/register --require tsconfig-paths/register --require test/helpers/init.js --reporter spec --timeout 100000 \"test/unit/**/*.test.ts\"",
188
+ "test:one": "cross-env NODE_ENV=development TEST=1 CUSTOM_CONTEXT_FILENAME=\"test.asyncapi-cli\" CUSTOM_CONTEXT_FILE_LOCATION=\"\" NODE_CONFIG_DIR=\"./src/apps/api/configs\" c8 mocha --require ts-node/register --require tsconfig-paths/register --require test/helpers/init.js --reporter spec --timeout 100000",
192
189
  "get-version": "echo $npm_package_version",
193
190
  "createhook": "oclif generate hook myhook --event=command_not_found",
194
191
  "createhookinit": "oclif generate hook inithook --event=init",
@@ -46,7 +46,7 @@ async function renameTar({version, name, sha, isAlpine}) {
46
46
  const tarDirectory = path.resolve(dist, 'tar');
47
47
  await createDirectory(tarDirectory);
48
48
 
49
- const fileName = isAlpine ? 'asyncapi-alpine.tar.gz' : 'asyncapi.tar.gz';
49
+ const fileName = isAlpine ? 'asyncapi.alpine.tar.gz' : 'asyncapi.tar.gz';
50
50
  const newPath = path.resolve(tarDirectory, fileName);
51
51
  await checkAndRenameFile(generatedPath, newPath);
52
52
  }