@asyncapi/cli 0.56.3 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -93,7 +93,7 @@ class Optimize extends base_1.default {
93
93
  }
94
94
  else if (this.outputMethod === Outputs.OVERWRITE) {
95
95
  yield writeFile(specPath !== null && specPath !== void 0 ? specPath : 'asyncapi.yaml', optimizedDocument, { encoding: 'utf8' });
96
- this.log(`Created file ${newPath}...`);
96
+ this.log(`Updated file ${specPath}...`);
97
97
  }
98
98
  }
99
99
  catch (error) {
@@ -7,7 +7,7 @@ export declare class SpecificationFileNotFound extends SpecificationFileError {
7
7
  export declare class SpecificationURLNotFound extends SpecificationFileError {
8
8
  constructor(URL: string);
9
9
  }
10
- declare type From = 'file' | 'url' | 'context';
10
+ declare type From = 'file' | 'url' | 'context' | 'invalid file';
11
11
  export declare class ErrorLoadingSpec extends Error {
12
12
  private readonly errorMessages;
13
13
  constructor(from?: From, param?: string);
@@ -45,6 +45,10 @@ class ErrorLoadingSpec extends Error {
45
45
  this.name = 'error loading AsyncAPI document from context';
46
46
  this.message = `${param} context name does not exist.`;
47
47
  }
48
+ if (from === 'invalid file') {
49
+ this.name = 'Invalid AsyncAPI file type';
50
+ this.message = 'cli only supports yml ,yaml ,json extension';
51
+ }
48
52
  if (!from) {
49
53
  this.name = 'error locating AsyncAPI document';
50
54
  this.message = this.errorMessages.default;
@@ -184,6 +184,11 @@ function fileExists(name) {
184
184
  if ((yield lstat(name)).isFile()) {
185
185
  return true;
186
186
  }
187
+ const extension = name.split('.')[1];
188
+ const allowedExtenstion = ['yml', 'yaml', 'json'];
189
+ if (!allowedExtenstion.includes(extension)) {
190
+ throw new specification_file_1.ErrorLoadingSpec('invalid file', name);
191
+ }
187
192
  throw new specification_file_1.ErrorLoadingSpec('file', name);
188
193
  }
189
194
  catch (e) {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.56.3",
2
+ "version": "0.58.0",
3
3
  "commands": {
4
4
  "bundle": {
5
5
  "id": "bundle",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@asyncapi/cli",
3
3
  "description": "All in one CLI for all AsyncAPI tools",
4
- "version": "0.56.3",
4
+ "version": "0.58.0",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run"