@asyncapi/cli 0.15.0 → 0.18.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.
Files changed (49) hide show
  1. package/README.md +17 -20
  2. package/assets/logo.png +0 -0
  3. package/bin/dev +18 -0
  4. package/bin/dev.cmd +3 -0
  5. package/bin/run +2 -4
  6. package/lib/base.d.ts +1 -1
  7. package/lib/base.js +2 -3
  8. package/lib/commands/config/context/add.d.ts +1 -1
  9. package/lib/commands/config/context/add.js +5 -5
  10. package/lib/commands/config/context/current.d.ts +1 -1
  11. package/lib/commands/config/context/current.js +4 -4
  12. package/lib/commands/config/context/index.d.ts +4 -0
  13. package/lib/commands/config/context/index.js +13 -0
  14. package/lib/commands/config/context/list.d.ts +1 -1
  15. package/lib/commands/config/context/list.js +4 -4
  16. package/lib/commands/config/context/remove.d.ts +1 -1
  17. package/lib/commands/config/context/remove.js +5 -5
  18. package/lib/commands/config/context/use.d.ts +1 -1
  19. package/lib/commands/config/context/use.js +5 -5
  20. package/lib/commands/config/index.d.ts +4 -0
  21. package/lib/commands/config/index.js +13 -0
  22. package/lib/commands/convert.d.ts +15 -0
  23. package/lib/commands/convert.js +64 -0
  24. package/lib/commands/diff.d.ts +7 -7
  25. package/lib/commands/diff.js +54 -25
  26. package/lib/commands/new.d.ts +6 -7
  27. package/lib/commands/new.js +15 -15
  28. package/lib/commands/start/index.d.ts +4 -0
  29. package/lib/commands/start/index.js +13 -0
  30. package/lib/commands/start/studio.d.ts +3 -4
  31. package/lib/commands/start/studio.js +8 -8
  32. package/lib/commands/validate.d.ts +2 -2
  33. package/lib/commands/validate.js +7 -7
  34. package/lib/flags.d.ts +1 -1
  35. package/lib/flags.js +2 -2
  36. package/lib/globals.js +4 -3
  37. package/lib/index.d.ts +1 -1
  38. package/lib/index.js +3 -2
  39. package/lib/models/Context.js +2 -2
  40. package/lib/models/SpecificationFile.js +4 -4
  41. package/lib/models/Studio.js +7 -7
  42. package/oclif.manifest.json +1 -1
  43. package/package.json +21 -21
  44. package/lib/commands/config/context.d.ts +0 -7
  45. package/lib/commands/config/context.js +0 -14
  46. package/lib/commands/config.d.ts +0 -8
  47. package/lib/commands/config.js +0 -16
  48. package/lib/commands/start.d.ts +0 -8
  49. package/lib/commands/start.js +0 -16
package/README.md CHANGED
@@ -1,28 +1,25 @@
1
- <h5 align="center">
2
- <br>
3
- <a href="https://www.asyncapi.org"><img src="https://github.com/asyncapi/parser-nodejs/raw/master/assets/logo.png" alt="AsyncAPI logo" width="200"></a>
4
- <br>
5
- AsyncAPI CLI
6
- </h5>
7
- <p align="center">
8
- <em>CLI to work with your AsyncAPI files. Currently supports validation, but it is under development for more features.</em>
9
- </p>
10
-
11
- <p align="center">
12
- <a href="https://github.com/asyncapi/cli/blob/master/LICENSE"><img alt="GitHub license" src="https://img.shields.io/github/license/asyncapi/cli"></a>
13
- <a href="https://github.com/asyncapi/cli/actions/workflows/if-nodejs-pr-testing.yml">
14
- <img src="https://github.com/asyncapi/cli/actions/workflows/if-nodejs-pr-testing.yml/badge.svg" alt="PR testing - if Node project" />
15
- </a>
16
- <a href="https://www.npmjs.com/package/@asyncapi/cli">
17
- <img alt="npm" src="https://img.shields.io/npm/dw/@asyncapi/cli">
18
- </a>
19
-
20
- </p>
1
+ [![AsyncAPI CLI](./assets/logo.png)](https://www.asyncapi.com)
2
+
3
+ CLI to work with your AsyncAPI files. Currently supports validation, but it is under development for more features.
4
+
5
+ [![GitHub license](https://img.shields.io/github/license/asyncapi/cli)](https://github.com/asyncapi/cli/blob/master/LICENSE)
6
+ [![PR testing - if Node project](https://github.com/asyncapi/cli/actions/workflows/if-nodejs-pr-testing.yml/badge.svg)](https://github.com/asyncapi/cli/actions/workflows/if-nodejs-pr-testing.yml)
7
+ [![npm](https://img.shields.io/npm/dw/@asyncapi/cli)](https://www.npmjs.com/package/@asyncapi/cli)
8
+
9
+
21
10
 
22
11
  ## Table of contents
23
12
 
24
13
  <!-- toc -->
25
14
 
15
+ - [Requirements](#requirements)
16
+ * [Installation](#installation)
17
+ - [Usage](#usage)
18
+ - [Contributing](#contributing)
19
+ * [Set up development environment](#set-up-development-environment)
20
+ * [Command Structure and Patterns](#command-structure-and-patterns)
21
+ - [Contributors](#contributors)
22
+
26
23
  <!-- tocstop -->
27
24
 
28
25
  ## Requirements
Binary file
package/bin/dev ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env nod
2
+
3
+ const oclif = require('@oclif/core')
4
+
5
+ const path = require('path')
6
+ const project = path.join(__dirname, '..', 'tsconfig.json')
7
+
8
+ // In dev mode -> use ts-node and dev plugins
9
+ process.env.NODE_ENV = 'development'
10
+
11
+ require('ts-node').register({project})
12
+
13
+ // In dev mode, always show stack traces
14
+ oclif.settings.debug = true;
15
+
16
+ // Start the CLI
17
+ oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
18
+
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\dev" %*
package/bin/run CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- require('reflect-metadata');
3
+ const oclif = require('@oclif/core')
4
4
 
5
- require('@oclif/command').run()
6
- .then(require('@oclif/command/flush'))
7
- .catch(require('@oclif/errors/handle'))
5
+ oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))
package/lib/base.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import Command from '@oclif/command';
1
+ import { Command } from '@oclif/core';
2
2
  export default abstract class extends Command {
3
3
  catch(e: any): Promise<void>;
4
4
  }
package/lib/base.js CHANGED
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const command_1 = tslib_1.__importDefault(require("@oclif/command"));
5
- class default_1 extends command_1.default {
3
+ const core_1 = require("@oclif/core");
4
+ class default_1 extends core_1.Command {
6
5
  async catch(e) {
7
6
  console.error(`${e.name}: ${e.message}`);
8
7
  }
@@ -2,7 +2,7 @@ import Command from '../../../base';
2
2
  export default class ContextAdd extends Command {
3
3
  static description: string;
4
4
  static flags: {
5
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
6
  };
7
7
  static args: {
8
8
  name: string;
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const base_1 = tslib_1.__importDefault(require("../../../base"));
4
+ const core_1 = require("@oclif/core");
5
+ const base_1 = (0, tslib_1.__importDefault)(require("../../../base"));
6
6
  const Context_1 = require("../../../models/Context");
7
7
  class ContextAdd extends base_1.default {
8
8
  async run() {
9
- const { args } = this.parse(ContextAdd);
9
+ const { args } = await this.parse(ContextAdd);
10
10
  const contextName = args['context-name'];
11
11
  const specFilePath = args['spec-file-path'];
12
- await Context_1.addContext(contextName, specFilePath);
12
+ await (0, Context_1.addContext)(contextName, specFilePath);
13
13
  this.log(`Added context "${contextName}".\n\nYou can set it as your current context: asyncapi context use ${contextName}\nYou can use this context when needed by passing ${contextName} as a parameter: asyncapi validate ${contextName}`);
14
14
  }
15
15
  }
16
16
  exports.default = ContextAdd;
17
17
  ContextAdd.description = 'Add or modify a context in the store';
18
18
  ContextAdd.flags = {
19
- help: command_1.flags.help({ char: 'h' })
19
+ help: core_1.Flags.help({ char: 'h' })
20
20
  };
21
21
  ContextAdd.args = [
22
22
  { name: 'context-name', description: 'context name', required: true },
@@ -2,7 +2,7 @@ import Command from '../../../base';
2
2
  export default class ContextCurrent extends Command {
3
3
  static description: string;
4
4
  static flags: {
5
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
6
  };
7
7
  run(): Promise<void>;
8
8
  }
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const base_1 = tslib_1.__importDefault(require("../../../base"));
4
+ const core_1 = require("@oclif/core");
5
+ const base_1 = (0, tslib_1.__importDefault)(require("../../../base"));
6
6
  const Context_1 = require("../../../models/Context");
7
7
  class ContextCurrent extends base_1.default {
8
8
  async run() {
9
- const { current, context } = await Context_1.getCurrentContext();
9
+ const { current, context } = await (0, Context_1.getCurrentContext)();
10
10
  this.log(`${current}: ${context}`);
11
11
  }
12
12
  }
13
13
  exports.default = ContextCurrent;
14
14
  ContextCurrent.description = 'Shows the current context that is being used';
15
15
  ContextCurrent.flags = {
16
- help: command_1.flags.help({ char: 'h' })
16
+ help: core_1.Flags.help({ char: 'h' })
17
17
  };
@@ -0,0 +1,4 @@
1
+ import Command from '../../../base';
2
+ export default class Context extends Command {
3
+ run(): Promise<void>;
4
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const base_1 = (0, tslib_1.__importDefault)(require("../../../base"));
6
+ class Context extends base_1.default {
7
+ async run() {
8
+ const Help = await (0, core_1.loadHelpClass)(this.config);
9
+ const help = new Help(this.config);
10
+ help.showHelp(['config', 'context', '--help']);
11
+ }
12
+ }
13
+ exports.default = Context;
@@ -2,7 +2,7 @@ import Command from '../../../base';
2
2
  export default class ContextList extends Command {
3
3
  static description: string;
4
4
  static flags: {
5
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
6
  };
7
7
  run(): Promise<void>;
8
8
  }
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const base_1 = tslib_1.__importDefault(require("../../../base"));
4
+ const core_1 = require("@oclif/core");
5
+ const base_1 = (0, tslib_1.__importDefault)(require("../../../base"));
6
6
  const Context_1 = require("../../../models/Context");
7
7
  class ContextList extends base_1.default {
8
8
  async run() {
9
- const fileContent = await Context_1.loadContextFile();
9
+ const fileContent = await (0, Context_1.loadContextFile)();
10
10
  for (const [contextName, filePath] of Object.entries(fileContent.store)) {
11
11
  this.log(`${contextName}: ${filePath}`);
12
12
  }
@@ -15,5 +15,5 @@ class ContextList extends base_1.default {
15
15
  exports.default = ContextList;
16
16
  ContextList.description = 'List all the stored context in the store';
17
17
  ContextList.flags = {
18
- help: command_1.flags.help({ char: 'h' })
18
+ help: core_1.Flags.help({ char: 'h' })
19
19
  };
@@ -2,7 +2,7 @@ import Command from '../../../base';
2
2
  export default class ContextRemove extends Command {
3
3
  static description: string;
4
4
  static flags: {
5
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
6
  };
7
7
  static args: {
8
8
  name: string;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const base_1 = tslib_1.__importDefault(require("../../../base"));
4
+ const core_1 = require("@oclif/core");
5
+ const base_1 = (0, tslib_1.__importDefault)(require("../../../base"));
6
6
  const Context_1 = require("../../../models/Context");
7
7
  class ContextRemove extends base_1.default {
8
8
  async run() {
9
- const { args } = this.parse(ContextRemove);
9
+ const { args } = await this.parse(ContextRemove);
10
10
  const contextName = args['context-name'];
11
11
  try {
12
- await Context_1.removeContext(contextName);
12
+ await (0, Context_1.removeContext)(contextName);
13
13
  this.log(`${contextName} successfully deleted`);
14
14
  }
15
15
  catch (err) {
@@ -20,7 +20,7 @@ class ContextRemove extends base_1.default {
20
20
  exports.default = ContextRemove;
21
21
  ContextRemove.description = 'Delete a context from the store';
22
22
  ContextRemove.flags = {
23
- help: command_1.flags.help({ char: 'h' })
23
+ help: core_1.Flags.help({ char: 'h' })
24
24
  };
25
25
  ContextRemove.args = [
26
26
  { name: 'context-name', description: 'Name of the context to delete', required: true }
@@ -2,7 +2,7 @@ import Command from '../../../base';
2
2
  export default class ContextUse extends Command {
3
3
  static description: string;
4
4
  static flags: {
5
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
6
  };
7
7
  static args: {
8
8
  name: string;
@@ -1,21 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const base_1 = tslib_1.__importDefault(require("../../../base"));
4
+ const core_1 = require("@oclif/core");
5
+ const base_1 = (0, tslib_1.__importDefault)(require("../../../base"));
6
6
  const Context_1 = require("../../../models/Context");
7
7
  class ContextUse extends base_1.default {
8
8
  async run() {
9
- const { args } = this.parse(ContextUse);
9
+ const { args } = await this.parse(ContextUse);
10
10
  const contextName = args['context-name'];
11
- await Context_1.setCurrentContext(contextName);
11
+ await (0, Context_1.setCurrentContext)(contextName);
12
12
  this.log(`${contextName} is set as current`);
13
13
  }
14
14
  }
15
15
  exports.default = ContextUse;
16
16
  ContextUse.description = 'Set a context as current';
17
17
  ContextUse.flags = {
18
- help: command_1.flags.help({ char: 'h' })
18
+ help: core_1.Flags.help({ char: 'h' })
19
19
  };
20
20
  ContextUse.args = [
21
21
  { name: 'context-name', description: 'name of the saved context', required: true }
@@ -0,0 +1,4 @@
1
+ import Command from '../../base';
2
+ export default class Config extends Command {
3
+ run(): Promise<void>;
4
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const base_1 = (0, tslib_1.__importDefault)(require("../../base"));
5
+ const core_1 = require("@oclif/core");
6
+ class Config extends base_1.default {
7
+ async run() {
8
+ const Help = await (0, core_1.loadHelpClass)(this.config);
9
+ const help = new Help(this.config);
10
+ help.showHelp(['config', '--help']);
11
+ }
12
+ }
13
+ exports.default = Config;
@@ -0,0 +1,15 @@
1
+ import Command from '../base';
2
+ export default class Convert extends Command {
3
+ static description: string;
4
+ static flags: {
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
+ output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
7
+ 'target-version': import("@oclif/core/lib/interfaces").OptionFlag<string>;
8
+ };
9
+ static args: {
10
+ name: string;
11
+ description: string;
12
+ required: boolean;
13
+ }[];
14
+ run(): Promise<void>;
15
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
5
+ const fs_1 = require("fs");
6
+ const core_1 = require("@oclif/core");
7
+ const base_1 = (0, tslib_1.__importDefault)(require("../base"));
8
+ const validation_error_1 = require("../errors/validation-error");
9
+ const SpecificationFile_1 = require("../models/SpecificationFile");
10
+ const specification_file_1 = require("../errors/specification-file");
11
+ // @ts-ignore
12
+ const converter_1 = require("@asyncapi/converter");
13
+ // @ts-ignore
14
+ const specs_1 = (0, tslib_1.__importDefault)(require("@asyncapi/specs"));
15
+ const latestVersion = Object.keys(specs_1.default).pop();
16
+ class Convert extends base_1.default {
17
+ async run() {
18
+ const { args, flags } = await this.parse(Convert);
19
+ const filePath = args['spec-file'];
20
+ let specFile;
21
+ let convertedFile;
22
+ try {
23
+ // LOAD FILE
24
+ specFile = await (0, SpecificationFile_1.load)(filePath);
25
+ // CONVERSION
26
+ convertedFile = await (0, converter_1.convert)(specFile.text(), flags['target-version'], {});
27
+ if (convertedFile) {
28
+ if (specFile.getFilePath()) {
29
+ this.log(`File ${specFile.getFilePath()} successfully converted!`);
30
+ }
31
+ else if (specFile.getFileURL()) {
32
+ this.log(`URL ${specFile.getFileURL()} successfully converted!`);
33
+ }
34
+ }
35
+ if (flags.output) {
36
+ await fs_1.promises.writeFile(`${flags.output}`, convertedFile, { encoding: 'utf8' });
37
+ }
38
+ else {
39
+ this.log(convertedFile);
40
+ }
41
+ }
42
+ catch (err) {
43
+ if (err instanceof specification_file_1.SpecificationFileNotFound) {
44
+ this.error(new validation_error_1.ValidationError({
45
+ type: 'invalid-file',
46
+ filepath: filePath
47
+ }));
48
+ }
49
+ else {
50
+ this.error(err);
51
+ }
52
+ }
53
+ }
54
+ }
55
+ exports.default = Convert;
56
+ Convert.description = 'convert asyncapi documents older to newer versions';
57
+ Convert.flags = {
58
+ help: core_1.Flags.help({ char: 'h' }),
59
+ output: core_1.Flags.string({ char: 'o', description: 'path to the file where the result is saved' }),
60
+ 'target-version': core_1.Flags.string({ char: 't', description: 'asyncapi version to convert to', default: latestVersion })
61
+ };
62
+ Convert.args = [
63
+ { name: 'spec-file', description: 'spec path, url, or context-name', required: false },
64
+ ];
@@ -1,14 +1,13 @@
1
- import { flags } from '@oclif/command';
2
1
  import AsyncAPIDiff from '@asyncapi/diff/lib/asyncapidiff';
3
2
  import Command from '../base';
4
3
  export default class Diff extends Command {
5
4
  static description: string;
6
5
  static flags: {
7
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
8
- format: flags.IOptionFlag<string>;
9
- type: flags.IOptionFlag<string>;
10
- overrides: flags.IOptionFlag<string | undefined>;
11
- watch: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
6
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
7
+ format: import("@oclif/core/lib/interfaces").OptionFlag<string>;
8
+ type: import("@oclif/core/lib/interfaces").OptionFlag<string>;
9
+ overrides: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
10
+ watch: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
11
  };
13
12
  static args: {
14
13
  name: string;
@@ -16,5 +15,6 @@ export default class Diff extends Command {
16
15
  required: boolean;
17
16
  }[];
18
17
  run(): Promise<void>;
19
- outputJson(diffOutput: AsyncAPIDiff, outputType: string): void;
18
+ outputJSON(diffOutput: AsyncAPIDiff, outputType: string): void;
19
+ outputYAML(diffOutput: AsyncAPIDiff, outputType: string): void;
20
20
  }
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  /* eslint-disable sonarjs/no-duplicate-string */
5
- const command_1 = require("@oclif/command");
6
- const diff = tslib_1.__importStar(require("@asyncapi/diff"));
7
- const parser = tslib_1.__importStar(require("@asyncapi/parser"));
5
+ const core_1 = require("@oclif/core");
6
+ const diff = (0, tslib_1.__importStar)(require("@asyncapi/diff"));
7
+ const parser = (0, tslib_1.__importStar)(require("@asyncapi/parser"));
8
8
  const fs_1 = require("fs");
9
9
  const SpecificationFile_1 = require("../models/SpecificationFile");
10
- const base_1 = tslib_1.__importDefault(require("../base"));
10
+ const base_1 = (0, tslib_1.__importDefault)(require("../base"));
11
11
  const validation_error_1 = require("../errors/validation-error");
12
12
  const specification_file_1 = require("../errors/specification-file");
13
13
  const diff_error_1 = require("../errors/diff-error");
@@ -16,7 +16,7 @@ const flags_1 = require("../flags");
16
16
  const { readFile } = fs_1.promises;
17
17
  class Diff extends base_1.default {
18
18
  async run() {
19
- const { args, flags } = this.parse(Diff); // NOSONAR
19
+ const { args, flags } = await this.parse(Diff); // NOSONAR
20
20
  const firstDocumentPath = args['old'];
21
21
  const secondDocumentPath = args['new'];
22
22
  const outputFormat = flags['format'];
@@ -25,8 +25,14 @@ class Diff extends base_1.default {
25
25
  const watchMode = flags['watch'];
26
26
  let firstDocument, secondDocument;
27
27
  try {
28
- firstDocument = await SpecificationFile_1.load(firstDocumentPath);
29
- enableWatch(watchMode, { spec: firstDocument, handler: this, handlerName: 'diff', docVersion: 'old', label: 'DIFF_OLD' });
28
+ firstDocument = await (0, SpecificationFile_1.load)(firstDocumentPath);
29
+ enableWatch(watchMode, {
30
+ spec: firstDocument,
31
+ handler: this,
32
+ handlerName: 'diff',
33
+ docVersion: 'old',
34
+ label: 'DIFF_OLD',
35
+ });
30
36
  }
31
37
  catch (err) {
32
38
  if (err instanceof specification_file_1.SpecificationFileNotFound) {
@@ -35,13 +41,17 @@ class Diff extends base_1.default {
35
41
  filepath: firstDocumentPath,
36
42
  }));
37
43
  }
38
- else {
39
- this.error(err);
40
- }
44
+ this.error(err);
41
45
  }
42
46
  try {
43
- secondDocument = await SpecificationFile_1.load(secondDocumentPath);
44
- enableWatch(watchMode, { spec: secondDocument, handler: this, handlerName: 'diff', docVersion: 'new', label: 'DIFF_NEW' });
47
+ secondDocument = await (0, SpecificationFile_1.load)(secondDocumentPath);
48
+ enableWatch(watchMode, {
49
+ spec: secondDocument,
50
+ handler: this,
51
+ handlerName: 'diff',
52
+ docVersion: 'new',
53
+ label: 'DIFF_NEW',
54
+ });
45
55
  }
46
56
  catch (err) {
47
57
  if (err instanceof specification_file_1.SpecificationFileNotFound) {
@@ -50,9 +60,7 @@ class Diff extends base_1.default {
50
60
  filepath: secondDocumentPath,
51
61
  }));
52
62
  }
53
- else {
54
- this.error(err);
55
- }
63
+ this.error(err);
56
64
  }
57
65
  let overrides = {};
58
66
  if (overrideFilePath) {
@@ -68,9 +76,13 @@ class Diff extends base_1.default {
68
76
  const secondDocumentParsed = await parser.parse(secondDocument.text());
69
77
  const diffOutput = diff.diff(firstDocumentParsed.json(), secondDocumentParsed.json(), {
70
78
  override: overrides,
79
+ outputType: outputFormat, // NOSONAR
71
80
  });
72
81
  if (outputFormat === 'json') {
73
- this.outputJson(diffOutput, outputType);
82
+ this.outputJSON(diffOutput, outputType);
83
+ }
84
+ else if (outputFormat === 'yaml' || outputFormat === 'yml') {
85
+ this.outputYAML(diffOutput, outputType);
74
86
  }
75
87
  else {
76
88
  this.log(`The output format ${outputFormat} is not supported at the moment.`);
@@ -83,7 +95,7 @@ class Diff extends base_1.default {
83
95
  });
84
96
  }
85
97
  }
86
- outputJson(diffOutput, outputType) {
98
+ outputJSON(diffOutput, outputType) {
87
99
  if (outputType === 'breaking') {
88
100
  this.log(JSON.stringify(diffOutput.breaking(), null, 2));
89
101
  }
@@ -100,28 +112,45 @@ class Diff extends base_1.default {
100
112
  this.log(`The output type ${outputType} is not supported at the moment.`);
101
113
  }
102
114
  }
115
+ outputYAML(diffOutput, outputType) {
116
+ if (outputType === 'breaking') {
117
+ this.log(diffOutput.breaking());
118
+ }
119
+ else if (outputType === 'non-breaking') {
120
+ this.log(diffOutput.nonBreaking());
121
+ }
122
+ else if (outputType === 'unclassified') {
123
+ this.log(diffOutput.unclassified());
124
+ }
125
+ else if (outputType === 'all') {
126
+ this.log(diffOutput.getOutput());
127
+ }
128
+ else {
129
+ this.log(`The output type ${outputType} is not supported at the moment.`);
130
+ }
131
+ }
103
132
  }
104
133
  exports.default = Diff;
105
134
  Diff.description = 'find diff between two asyncapi files';
106
135
  Diff.flags = {
107
- help: command_1.flags.help({ char: 'h' }),
108
- format: command_1.flags.string({
136
+ help: core_1.Flags.help({ char: 'h' }),
137
+ format: core_1.Flags.string({
109
138
  char: 'f',
110
139
  description: 'format of the output',
111
- default: 'json',
112
- options: ['json'],
140
+ default: 'yaml',
141
+ options: ['json', 'yaml', 'yml'],
113
142
  }),
114
- type: command_1.flags.string({
143
+ type: core_1.Flags.string({
115
144
  char: 't',
116
145
  description: 'type of the output',
117
146
  default: 'all',
118
147
  options: ['breaking', 'non-breaking', 'unclassified', 'all'],
119
148
  }),
120
- overrides: command_1.flags.string({
149
+ overrides: core_1.Flags.string({
121
150
  char: 'o',
122
151
  description: 'path to JSON file containing the override properties',
123
152
  }),
124
- watch: flags_1.watchFlag
153
+ watch: flags_1.watchFlag,
125
154
  };
126
155
  Diff.args = [
127
156
  {
@@ -161,6 +190,6 @@ async function readOverrideFile(path) {
161
190
  */
162
191
  const enableWatch = (status, watcher) => {
163
192
  if (status) {
164
- globals_1.specWatcher(watcher);
193
+ (0, globals_1.specWatcher)(watcher);
165
194
  }
166
195
  };
@@ -1,14 +1,13 @@
1
- import { flags } from '@oclif/command';
2
1
  import Command from '../base';
3
2
  export default class New extends Command {
4
3
  static description: string;
5
4
  static flags: {
6
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
7
- 'file-name': flags.IOptionFlag<string | undefined>;
8
- example: flags.IOptionFlag<string | undefined>;
9
- studio: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
10
- port: import("@oclif/parser/lib/flags").IOptionFlag<number | undefined>;
11
- 'no-tty': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
+ 'file-name': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
7
+ example: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
8
+ studio: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ port: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
10
+ 'no-tty': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
11
  };
13
12
  static args: never[];
14
13
  run(): Promise<void>;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
4
5
  const fs_1 = require("fs");
5
- const command_1 = require("@oclif/command");
6
- const base_1 = tslib_1.__importDefault(require("../base"));
7
- const inquirer = tslib_1.__importStar(require("inquirer"));
6
+ const base_1 = (0, tslib_1.__importDefault)(require("../base"));
7
+ const inquirer = (0, tslib_1.__importStar)(require("inquirer"));
8
8
  const Studio_1 = require("../models/Studio");
9
9
  const path_1 = require("path");
10
10
  const { writeFile, readFile } = fs_1.promises;
@@ -12,7 +12,7 @@ const DEFAULT_ASYNCAPI_FILE_NAME = 'asyncapi.yaml';
12
12
  const DEFAULT_ASYNCAPI_TEMPLATE = 'default-example.yaml';
13
13
  class New extends base_1.default {
14
14
  async run() {
15
- const { flags } = this.parse(New); // NOSONAR
15
+ const { flags } = await this.parse(New); // NOSONAR
16
16
  const isTTY = process.stdout.isTTY;
17
17
  if (!flags['no-tty'] && isTTY) {
18
18
  return this.runInteractive();
@@ -22,7 +22,7 @@ class New extends base_1.default {
22
22
  await this.createAsyncapiFile(fileName, template);
23
23
  if (flags.studio) {
24
24
  if (isTTY) {
25
- Studio_1.start(fileName, flags.port || Studio_1.DEFAULT_PORT);
25
+ (0, Studio_1.start)(fileName, flags.port || Studio_1.DEFAULT_PORT);
26
26
  }
27
27
  else {
28
28
  this.warn('Warning: --studio flag was passed but the terminal is not interactive. Ignoring...');
@@ -31,7 +31,7 @@ class New extends base_1.default {
31
31
  }
32
32
  /* eslint-disable sonarjs/cognitive-complexity */
33
33
  async runInteractive() {
34
- const { flags } = this.parse(New); // NOSONAR
34
+ const { flags } = await this.parse(New); // NOSONAR
35
35
  let fileName = flags['file-name'];
36
36
  let selectedTemplate = flags['example'];
37
37
  let openStudio = flags.studio;
@@ -46,7 +46,7 @@ class New extends base_1.default {
46
46
  });
47
47
  }
48
48
  try {
49
- const exampleFiles = await readFile(path_1.resolve(__dirname, '../../assets/examples/examples.json'), { encoding: 'utf8' });
49
+ const exampleFiles = await readFile((0, path_1.resolve)(__dirname, '../../assets/examples/examples.json'), { encoding: 'utf8' });
50
50
  examples = JSON.parse(exampleFiles);
51
51
  }
52
52
  catch (error) {
@@ -93,11 +93,11 @@ class New extends base_1.default {
93
93
  selectedTemplate = selectedTemplate || DEFAULT_ASYNCAPI_TEMPLATE;
94
94
  await this.createAsyncapiFile(fileName, selectedTemplate);
95
95
  if (openStudio) {
96
- Studio_1.start(fileName, flags.port || Studio_1.DEFAULT_PORT);
96
+ (0, Studio_1.start)(fileName, flags.port || Studio_1.DEFAULT_PORT);
97
97
  }
98
98
  }
99
99
  async createAsyncapiFile(fileName, selectedTemplate) {
100
- const asyncApiFile = await readFile(path_1.resolve(__dirname, '../../assets/examples/', selectedTemplate), { encoding: 'utf8' });
100
+ const asyncApiFile = await readFile((0, path_1.resolve)(__dirname, '../../assets/examples/', selectedTemplate), { encoding: 'utf8' });
101
101
  const fileNameHasFileExtension = fileName.includes('.');
102
102
  const fileNameToWriteToDisk = fileNameHasFileExtension ? fileName : `${fileName}.yaml`;
103
103
  try {
@@ -117,11 +117,11 @@ class New extends base_1.default {
117
117
  exports.default = New;
118
118
  New.description = 'creates a new asyncapi file';
119
119
  New.flags = {
120
- help: command_1.flags.help({ char: 'h' }),
121
- 'file-name': command_1.flags.string({ char: 'n', description: 'name of the file' }),
122
- example: command_1.flags.string({ char: 'e', description: 'name of the example to use' }),
123
- studio: command_1.flags.boolean({ char: 's', description: 'open in Studio' }),
124
- port: command_1.flags.integer({ char: 'p', description: 'port in which to start Studio' }),
125
- 'no-tty': command_1.flags.boolean({ description: 'do not use an interactive terminal' }),
120
+ help: core_1.Flags.help({ char: 'h' }),
121
+ 'file-name': core_1.Flags.string({ char: 'n', description: 'name of the file' }),
122
+ example: core_1.Flags.string({ char: 'e', description: 'name of the example to use' }),
123
+ studio: core_1.Flags.boolean({ char: 's', description: 'open in Studio' }),
124
+ port: core_1.Flags.integer({ char: 'p', description: 'port in which to start Studio' }),
125
+ 'no-tty': core_1.Flags.boolean({ description: 'do not use an interactive terminal' }),
126
126
  };
127
127
  New.args = [];
@@ -0,0 +1,4 @@
1
+ import Command from '../../base';
2
+ export default class Start extends Command {
3
+ run(): Promise<void>;
4
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const base_1 = (0, tslib_1.__importDefault)(require("../../base"));
5
+ const core_1 = require("@oclif/core");
6
+ class Start extends base_1.default {
7
+ async run() {
8
+ const Help = await (0, core_1.loadHelpClass)(this.config);
9
+ const help = new Help(this.config);
10
+ help.showHelp(['start', '--help']);
11
+ }
12
+ }
13
+ exports.default = Start;
@@ -1,11 +1,10 @@
1
- import { flags } from '@oclif/command';
2
1
  import Command from '../../base';
3
2
  export default class StartStudio extends Command {
4
3
  static description: string;
5
4
  static flags: {
6
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
7
- file: flags.IOptionFlag<string | undefined>;
8
- port: import("@oclif/parser/lib/flags").IOptionFlag<number | undefined>;
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
+ file: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
7
+ port: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
9
8
  };
10
9
  static args: never[];
11
10
  run(): Promise<void>;
@@ -1,23 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const base_1 = tslib_1.__importDefault(require("../../base"));
4
+ const core_1 = require("@oclif/core");
5
+ const base_1 = (0, tslib_1.__importDefault)(require("../../base"));
6
6
  const Studio_1 = require("../../models/Studio");
7
7
  const SpecificationFile_1 = require("../../models/SpecificationFile");
8
8
  class StartStudio extends base_1.default {
9
9
  async run() {
10
- const { flags } = this.parse(StartStudio);
11
- const filePath = flags.file || (await SpecificationFile_1.load()).getFilePath();
10
+ const { flags } = await this.parse(StartStudio);
11
+ const filePath = flags.file || (await (0, SpecificationFile_1.load)()).getFilePath();
12
12
  const port = flags.port;
13
- Studio_1.start(filePath, port);
13
+ (0, Studio_1.start)(filePath, port);
14
14
  }
15
15
  }
16
16
  exports.default = StartStudio;
17
17
  StartStudio.description = 'starts a new local instance of Studio';
18
18
  StartStudio.flags = {
19
- help: command_1.flags.help({ char: 'h' }),
20
- file: command_1.flags.string({ char: 'f', description: 'path to the AsyncAPI file to link with Studio' }),
21
- port: command_1.flags.integer({ char: 'p', description: 'port in which to start Studio' }),
19
+ help: core_1.Flags.help({ char: 'h' }),
20
+ file: core_1.Flags.string({ char: 'f', description: 'path to the AsyncAPI file to link with Studio' }),
21
+ port: core_1.Flags.integer({ char: 'p', description: 'port in which to start Studio' }),
22
22
  };
23
23
  StartStudio.args = [];
@@ -2,8 +2,8 @@ import Command from '../base';
2
2
  export default class Validate extends Command {
3
3
  static description: string;
4
4
  static flags: {
5
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
6
- watch: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
+ watch: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
7
  };
8
8
  static args: {
9
9
  name: string;
@@ -1,21 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const parser = tslib_1.__importStar(require("@asyncapi/parser"));
6
- const base_1 = tslib_1.__importDefault(require("../base"));
4
+ const core_1 = require("@oclif/core");
5
+ const parser = (0, tslib_1.__importStar)(require("@asyncapi/parser"));
6
+ const base_1 = (0, tslib_1.__importDefault)(require("../base"));
7
7
  const validation_error_1 = require("../errors/validation-error");
8
8
  const SpecificationFile_1 = require("../models/SpecificationFile");
9
9
  const globals_1 = require("../globals");
10
10
  const flags_1 = require("../flags");
11
11
  class Validate extends base_1.default {
12
12
  async run() {
13
- const { args, flags } = this.parse(Validate); // NOSONAR
13
+ const { args, flags } = await this.parse(Validate); //NOSONAR
14
14
  const filePath = args['spec-file'];
15
15
  const watchMode = flags['watch'];
16
- const specFile = await SpecificationFile_1.load(filePath);
16
+ const specFile = await (0, SpecificationFile_1.load)(filePath);
17
17
  if (watchMode) {
18
- globals_1.specWatcher({ spec: specFile, handler: this, handlerName: 'validate' });
18
+ (0, globals_1.specWatcher)({ spec: specFile, handler: this, handlerName: 'validate' });
19
19
  }
20
20
  try {
21
21
  if (specFile.getFilePath()) {
@@ -38,7 +38,7 @@ class Validate extends base_1.default {
38
38
  exports.default = Validate;
39
39
  Validate.description = 'validate asyncapi file';
40
40
  Validate.flags = {
41
- help: command_1.flags.help({ char: 'h' }),
41
+ help: core_1.Flags.help({ char: 'h' }),
42
42
  watch: flags_1.watchFlag
43
43
  };
44
44
  Validate.args = [
package/lib/flags.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const watchFlag: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
1
+ export declare const watchFlag: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
package/lib/flags.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.watchFlag = void 0;
4
- const command_1 = require("@oclif/command");
5
- exports.watchFlag = command_1.flags.boolean({
4
+ const core_1 = require("@oclif/core");
5
+ exports.watchFlag = core_1.Flags.boolean({
6
6
  char: 'w',
7
7
  description: 'Enable watch mode'
8
8
  });
package/lib/globals.js CHANGED
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.specWatcher = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const chokidar_1 = tslib_1.__importDefault(require("chokidar"));
6
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
+ const chokidar_1 = (0, tslib_1.__importDefault)(require("chokidar"));
6
+ const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
7
7
  const GreenLog = chalk_1.default.hex('#00FF00');
8
8
  const OrangeLog = chalk_1.default.hex('#FFA500');
9
9
  const CHOKIDAR_CONFIG = {
@@ -15,7 +15,7 @@ const WATCH_MESSAGES = {
15
15
  logOnAutoDisable: (docVersion = '') => console.log(OrangeLog(`Watch mode for ${docVersion || 'AsyncAPI'} file was not enabled.`), OrangeLog('\nINFO: Watch works only with files from local file system\n'))
16
16
  };
17
17
  const CHOKIDAR_INSTANCE_STORE = new Map();
18
- exports.specWatcher = (params) => {
18
+ const specWatcher = (params) => {
19
19
  if (!params.spec.getFilePath()) {
20
20
  return WATCH_MESSAGES.logOnAutoDisable(params.docVersion);
21
21
  }
@@ -42,3 +42,4 @@ exports.specWatcher = (params) => {
42
42
  console.log(error);
43
43
  }
44
44
  };
45
+ exports.specWatcher = specWatcher;
package/lib/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { run } from '@oclif/command';
1
+ export { run } from '@oclif/core';
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var command_1 = require("@oclif/command");
4
- Object.defineProperty(exports, "run", { enumerable: true, get: function () { return command_1.run; } });
3
+ exports.run = void 0;
4
+ var core_1 = require("@oclif/core");
5
+ Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadContextFile = exports.setCurrentContext = exports.getCurrentContext = exports.removeContext = exports.addContext = exports.loadContext = exports.DEFAULT_CONTEXT_FILE_PATH = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fs_1 = require("fs");
6
- const path = tslib_1.__importStar(require("path"));
7
- const os = tslib_1.__importStar(require("os"));
6
+ const path = (0, tslib_1.__importStar)(require("path"));
7
+ const os = (0, tslib_1.__importStar)(require("os"));
8
8
  const context_error_1 = require("../errors/context-error");
9
9
  const { readFile, writeFile } = fs_1.promises;
10
10
  const CONTEXT_FILENAME = process.env.CONTEXT_FILENAME || '.asyncapi';
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fileExists = exports.isURL = exports.nameType = exports.load = exports.Specification = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fs_1 = require("fs");
6
- const path = tslib_1.__importStar(require("path"));
7
- const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
6
+ const path = (0, tslib_1.__importStar)(require("path"));
7
+ const node_fetch_1 = (0, tslib_1.__importDefault)(require("node-fetch"));
8
8
  const Context_1 = require("./Context");
9
9
  const specification_file_1 = require("../errors/specification-file");
10
10
  const context_error_1 = require("../errors/context-error");
@@ -45,7 +45,7 @@ class Specification {
45
45
  static async fromURL(URLpath) {
46
46
  let response;
47
47
  try {
48
- response = await node_fetch_1.default(URLpath, { method: 'GET' });
48
+ response = await (0, node_fetch_1.default)(URLpath, { method: 'GET' });
49
49
  if (!response.ok) {
50
50
  throw new specification_file_1.ErrorLoadingSpec('url', URLpath);
51
51
  }
@@ -148,7 +148,7 @@ async function fileExists(name) {
148
148
  exports.fileExists = fileExists;
149
149
  async function loadFromContext(contextName) {
150
150
  try {
151
- const context = await Context_1.loadContext(contextName);
151
+ const context = await (0, Context_1.loadContext)(contextName);
152
152
  return Specification.fromFile(context);
153
153
  }
154
154
  catch (error) {
@@ -5,10 +5,10 @@ const tslib_1 = require("tslib");
5
5
  const fs_1 = require("fs");
6
6
  const path_1 = require("path");
7
7
  const http_1 = require("http");
8
- const serve_handler_1 = tslib_1.__importDefault(require("serve-handler"));
8
+ const serve_handler_1 = (0, tslib_1.__importDefault)(require("serve-handler"));
9
9
  const ws_1 = require("ws");
10
- const chokidar_1 = tslib_1.__importDefault(require("chokidar"));
11
- const open_1 = tslib_1.__importDefault(require("open"));
10
+ const chokidar_1 = (0, tslib_1.__importDefault)(require("chokidar"));
11
+ const open_1 = (0, tslib_1.__importDefault)(require("open"));
12
12
  const { readFile, writeFile } = fs_1.promises;
13
13
  const sockets = [];
14
14
  const messageQueue = [];
@@ -35,9 +35,9 @@ function start(filePath, port = exports.DEFAULT_PORT) {
35
35
  break;
36
36
  }
37
37
  });
38
- const server = http_1.createServer((request, response) => {
39
- return serve_handler_1.default(request, response, {
40
- public: path_1.resolve(__dirname, '../../node_modules/@asyncapi/studio/build'),
38
+ const server = (0, http_1.createServer)((request, response) => {
39
+ return (0, serve_handler_1.default)(request, response, {
40
+ public: (0, path_1.resolve)(__dirname, '../../node_modules/@asyncapi/studio/build'),
41
41
  });
42
42
  });
43
43
  server.on('upgrade', (request, socket, head) => {
@@ -83,7 +83,7 @@ function start(filePath, port = exports.DEFAULT_PORT) {
83
83
  const url = `http://localhost:${port}?liveServer=${port}`;
84
84
  console.log(`Studio is running at ${url}`);
85
85
  console.log(`Watching changes on file ${filePath}`);
86
- open_1.default(url);
86
+ (0, open_1.default)(url);
87
87
  });
88
88
  }
89
89
  exports.start = start;
@@ -1 +1 @@
1
- {"version":"0.15.0","commands":{"config":{"id":"config","description":"access configs","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"diff":{"id":"diff","description":"find diff between two asyncapi files","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"format":{"name":"format","type":"option","char":"f","description":"format of the output","options":["json"],"default":"json"},"type":{"name":"type","type":"option","char":"t","description":"type of the output","options":["breaking","non-breaking","unclassified","all"],"default":"all"},"overrides":{"name":"overrides","type":"option","char":"o","description":"path to JSON file containing the override properties"},"watch":{"name":"watch","type":"boolean","char":"w","description":"Enable watch mode","allowNo":false}},"args":[{"name":"old","description":"old spec path, URL or context-name","required":true},{"name":"new","description":"new spec path, URL or context-name","required":true}]},"new":{"id":"new","description":"creates a new asyncapi file","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"file-name":{"name":"file-name","type":"option","char":"n","description":"name of the file"},"example":{"name":"example","type":"option","char":"e","description":"name of the example to use"},"studio":{"name":"studio","type":"boolean","char":"s","description":"open in Studio","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"port in which to start Studio"},"no-tty":{"name":"no-tty","type":"boolean","description":"do not use an interactive terminal","allowNo":false}},"args":[]},"start":{"id":"start","description":"starts a new local instance of Studio","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"validate":{"id":"validate","description":"validate asyncapi file","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Enable watch mode","allowNo":false}},"args":[{"name":"spec-file","description":"spec path, url, or context-name","required":false}]},"config:context":{"id":"config:context","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"start:studio":{"id":"start:studio","description":"starts a new local instance of Studio","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"file":{"name":"file","type":"option","char":"f","description":"path to the AsyncAPI file to link with Studio"},"port":{"name":"port","type":"option","char":"p","description":"port in which to start Studio"}},"args":[]},"config:context:add":{"id":"config:context:add","description":"Add or modify a context in the store","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"context-name","description":"context name","required":true},{"name":"spec-file-path","description":"file path of the spec file","required":true}]},"config:context:current":{"id":"config:context:current","description":"Shows the current context that is being used","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"config:context:list":{"id":"config:context:list","description":"List all the stored context in the store","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"config:context:remove":{"id":"config:context:remove","description":"Delete a context from the store","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"context-name","description":"Name of the context to delete","required":true}]},"config:context:use":{"id":"config:context:use","description":"Set a context as current","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"context-name","description":"name of the saved context","required":true}]}}}
1
+ {"version":"0.18.0","commands":{"convert":{"id":"convert","description":"convert asyncapi documents older to newer versions","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"output":{"name":"output","type":"option","char":"o","description":"path to the file where the result is saved","multiple":false},"target-version":{"name":"target-version","type":"option","char":"t","description":"asyncapi version to convert to","multiple":false,"default":"2.3.0"}},"args":[{"name":"spec-file","description":"spec path, url, or context-name","required":false}],"_globalFlags":{}},"diff":{"id":"diff","description":"find diff between two asyncapi files","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"format":{"name":"format","type":"option","char":"f","description":"format of the output","multiple":false,"options":["json","yaml","yml"],"default":"yaml"},"type":{"name":"type","type":"option","char":"t","description":"type of the output","multiple":false,"options":["breaking","non-breaking","unclassified","all"],"default":"all"},"overrides":{"name":"overrides","type":"option","char":"o","description":"path to JSON file containing the override properties","multiple":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Enable watch mode","allowNo":false}},"args":[{"name":"old","description":"old spec path, URL or context-name","required":true},{"name":"new","description":"new spec path, URL or context-name","required":true}],"_globalFlags":{}},"new":{"id":"new","description":"creates a new asyncapi file","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"file-name":{"name":"file-name","type":"option","char":"n","description":"name of the file","multiple":false},"example":{"name":"example","type":"option","char":"e","description":"name of the example to use","multiple":false},"studio":{"name":"studio","type":"boolean","char":"s","description":"open in Studio","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"port in which to start Studio","multiple":false},"no-tty":{"name":"no-tty","type":"boolean","description":"do not use an interactive terminal","allowNo":false}},"args":[],"_globalFlags":{}},"validate":{"id":"validate","description":"validate asyncapi file","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Enable watch mode","allowNo":false}},"args":[{"name":"spec-file","description":"spec path, url, or context-name","required":false}],"_globalFlags":{}},"config":{"id":"config","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"start":{"id":"start","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"start:studio":{"id":"start:studio","description":"starts a new local instance of Studio","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"file":{"name":"file","type":"option","char":"f","description":"path to the AsyncAPI file to link with Studio","multiple":false},"port":{"name":"port","type":"option","char":"p","description":"port in which to start Studio","multiple":false}},"args":[],"_globalFlags":{}},"config:context:add":{"id":"config:context:add","description":"Add or modify a context in the store","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"context-name","description":"context name","required":true},{"name":"spec-file-path","description":"file path of the spec file","required":true}],"_globalFlags":{}},"config:context:current":{"id":"config:context:current","description":"Shows the current context that is being used","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[],"_globalFlags":{}},"config:context":{"id":"config:context","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"config:context:list":{"id":"config:context:list","description":"List all the stored context in the store","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[],"_globalFlags":{}},"config:context:remove":{"id":"config:context:remove","description":"Delete a context from the store","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"context-name","description":"Name of the context to delete","required":true}],"_globalFlags":{}},"config:context:use":{"id":"config:context:use","description":"Set a context as current","strict":true,"pluginName":"@asyncapi/cli","pluginAlias":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[{"name":"context-name","description":"name of the saved context","required":true}],"_globalFlags":{}}}}
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@asyncapi/cli",
3
3
  "description": "All in one CLI for all AsyncAPI tools",
4
- "version": "0.15.0",
4
+ "version": "0.18.0",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run"
8
8
  },
9
9
  "bugs": "https://github.com/asyncapi/cli/issues",
10
10
  "dependencies": {
11
+ "@asyncapi/converter": "^0.9.0",
11
12
  "@asyncapi/diff": "^0.3.0",
12
13
  "@asyncapi/parser": "^1.14.0",
13
14
  "@asyncapi/studio": "^0.10.0",
14
- "@fmvilas/oclif-plugin-spaced-commands": "^1.0.4",
15
- "@oclif/command": "^1.8.0",
16
- "@oclif/config": "^1.17.0",
15
+ "@oclif/core": "^1.2.0",
16
+ "@oclif/plugin-not-found": "^2.3.1",
17
17
  "@types/inquirer": "^8.1.3",
18
18
  "@types/ws": "^8.2.0",
19
19
  "chalk": "^4.1.0",
@@ -27,14 +27,12 @@
27
27
  "request": "^2.88.2",
28
28
  "serve-handler": "^6.1.3",
29
29
  "strip-ansi": "^6.0.0",
30
- "tslib": "^1.14.1",
31
30
  "unzipper": "^0.10.11",
32
31
  "wrap-ansi": "^4.0.0",
33
32
  "ws": "^8.2.3"
34
33
  },
35
34
  "devDependencies": {
36
- "@oclif/dev-cli": "^1.26.0",
37
- "@oclif/test": "^1.2.8",
35
+ "@oclif/test": "^2",
38
36
  "@semantic-release/commit-analyzer": "^8.0.1",
39
37
  "@semantic-release/github": "^7.2.3",
40
38
  "@semantic-release/npm": "^7.1.3",
@@ -49,7 +47,7 @@
49
47
  "@typescript-eslint/eslint-plugin": "^4.28.4",
50
48
  "@typescript-eslint/parser": "^4.28.4",
51
49
  "acorn": "^8.5.0",
52
- "chai": "^4.3.4",
50
+ "chai": "^4",
53
51
  "conventional-changelog-conventionalcommits": "^4.4.0",
54
52
  "cross-env": "^7.0.3",
55
53
  "eslint": "^7.31.0",
@@ -60,13 +58,14 @@
60
58
  "eslint-plugin-sonarjs": "^0.10.0",
61
59
  "globby": "^10.0.2",
62
60
  "markdown-toc": "^1.2.0",
63
- "mocha": "^5.2.0",
61
+ "mocha": "^9",
64
62
  "nyc": "^14.1.1",
65
- "oclif": "^1.18.1",
66
63
  "rimraf": "^3.0.2",
67
64
  "semantic-release": "^17.4.3",
68
- "ts-node": "^8.10.2",
69
- "typescript": "^3.9.10"
65
+ "souvikns-oclif": "^2.5.0",
66
+ "ts-node": "^10.4.0",
67
+ "tslib": "^2.3.1",
68
+ "typescript": "^4.4.3"
70
69
  },
71
70
  "engines": {
72
71
  "node": ">12.16"
@@ -88,8 +87,13 @@
88
87
  "commands": "./lib/commands",
89
88
  "bin": "asyncapi",
90
89
  "plugins": [
91
- "@fmvilas/oclif-plugin-spaced-commands"
92
- ]
90
+ "@oclif/plugin-not-found"
91
+ ],
92
+ "topicSeparator": " ",
93
+ "topics": {
94
+ "config:context": {},
95
+ "config": {}
96
+ }
93
97
  },
94
98
  "publishConfig": {
95
99
  "access": "public"
@@ -120,7 +124,7 @@
120
124
  },
121
125
  "repository": "asyncapi/cli",
122
126
  "scripts": {
123
- "build": "node scripts/fetch-asyncapi-example.js && tsc",
127
+ "build": "rimraf lib && node scripts/fetch-asyncapi-example.js && tsc && echo \"Build Completed\"",
124
128
  "bump:version": "npm --no-git-tag-version --allow-same-version version $VERSION",
125
129
  "dev": "tsc --watch",
126
130
  "generate:assets": "npm run generate:readme:toc",
@@ -128,15 +132,11 @@
128
132
  "lint": "eslint --max-warnings 0 --config .eslintrc .",
129
133
  "lint:fix": "eslint --max-warnings 5 --config .eslintrc . --fix",
130
134
  "postpack": "rimraf oclif.manifest.json",
131
- "prepack": "rimraf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
132
- "prepublishOnly": "npm run build",
135
+ "prepublishOnly": "npm run build && oclif manifest",
133
136
  "pretest": "npm run build",
134
137
  "pretest:coverage": "npm run build",
135
138
  "release": "semantic-release",
136
- "start": "npm run build && node dist/cli.js",
137
- "test": "cross-env TEST=1 CONTEXT_FILENAME=\"./test.asyncapi\" CONTEXT_FILE_PATH=\"./\" nyc --extension .ts mocha --require ts-node/register --reporter spec --timeout 10000 \"test/**/*.test.ts\"",
138
- "version": "oclif-dev readme && git add README.md",
139
- "readme": "oclif readme"
139
+ "test": "cross-env TEST=1 CONTEXT_FILENAME=\"./test.asyncapi\" CONTEXT_FILE_PATH=\"./\" nyc --extension .ts mocha --require ts-node/register --require test/helpers/init.js --reporter spec --timeout 10000 \"test/**/*.test.ts\""
140
140
  },
141
141
  "types": "lib/index.d.ts"
142
142
  }
@@ -1,7 +0,0 @@
1
- import Command from '../../base';
2
- export default class ConfigContext extends Command {
3
- static flags: {
4
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
5
- };
6
- run(): Promise<void>;
7
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const base_1 = tslib_1.__importDefault(require("../../base"));
6
- class ConfigContext extends base_1.default {
7
- async run() {
8
- await this._help();
9
- }
10
- }
11
- exports.default = ConfigContext;
12
- ConfigContext.flags = {
13
- help: command_1.flags.help({ char: 'h' })
14
- };
@@ -1,8 +0,0 @@
1
- import Command from '../base';
2
- export declare class Config extends Command {
3
- static description: string;
4
- static flags: {
5
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
6
- };
7
- run(): Promise<void>;
8
- }
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Config = void 0;
4
- const tslib_1 = require("tslib");
5
- const command_1 = require("@oclif/command");
6
- const base_1 = tslib_1.__importDefault(require("../base"));
7
- class Config extends base_1.default {
8
- async run() {
9
- await this._help();
10
- }
11
- }
12
- exports.Config = Config;
13
- Config.description = 'access configs';
14
- Config.flags = {
15
- help: command_1.flags.help({ char: 'h' })
16
- };
@@ -1,8 +0,0 @@
1
- import Command from '../base';
2
- export declare class Start extends Command {
3
- static description: string;
4
- static flags: {
5
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
6
- };
7
- run(): Promise<void>;
8
- }
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Start = void 0;
4
- const tslib_1 = require("tslib");
5
- const command_1 = require("@oclif/command");
6
- const base_1 = tslib_1.__importDefault(require("../base"));
7
- class Start extends base_1.default {
8
- async run() {
9
- this._help();
10
- }
11
- }
12
- exports.Start = Start;
13
- Start.description = 'starts a new local instance of Studio';
14
- Start.flags = {
15
- help: command_1.flags.help({ char: 'h' })
16
- };