@asyncapi/cli 0.53.0 → 0.54.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.
@@ -9,6 +9,7 @@ export default class NewFile extends Command {
9
9
  port: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
10
10
  'no-tty': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
11
  };
12
+ static examples: string[];
12
13
  run(): Promise<void>;
13
14
  runInteractive(): Promise<void>;
14
15
  createAsyncapiFile(fileName: string, selectedTemplate: string): Promise<void>;
@@ -10,6 +10,18 @@ const path_1 = require("path");
10
10
  const { writeFile, readFile } = fs_1.promises;
11
11
  const DEFAULT_ASYNCAPI_FILE_NAME = 'asyncapi.yaml';
12
12
  const DEFAULT_ASYNCAPI_TEMPLATE = 'default-example.yaml';
13
+ function loadExampleFile() {
14
+ const exampleFiles = (0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '../../../assets/examples/examples.json'), { encoding: 'utf8' });
15
+ return JSON.parse(exampleFiles);
16
+ }
17
+ function getExamplesFlagDescription() {
18
+ const examples = loadExampleFile();
19
+ let description = 'name of the example to use. Available examples are:';
20
+ for (const example of examples) {
21
+ description += `\n\t - ${example.value}`;
22
+ }
23
+ return description;
24
+ }
13
25
  class NewFile extends base_1.default {
14
26
  run() {
15
27
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -125,8 +137,12 @@ NewFile.description = 'Creates a new asyncapi file';
125
137
  NewFile.flags = {
126
138
  help: core_1.Flags.help({ char: 'h' }),
127
139
  'file-name': core_1.Flags.string({ char: 'n', description: 'name of the file' }),
128
- example: core_1.Flags.string({ char: 'e', description: 'name of the example to use' }),
140
+ example: core_1.Flags.string({ char: 'e', description: getExamplesFlagDescription() }),
129
141
  studio: core_1.Flags.boolean({ char: 's', description: 'open in Studio' }),
130
142
  port: core_1.Flags.integer({ char: 'p', description: 'port in which to start Studio' }),
131
143
  'no-tty': core_1.Flags.boolean({ description: 'do not use an interactive terminal' }),
132
144
  };
145
+ NewFile.examples = [
146
+ 'asyncapi new\t - start creation of a file in interactive mode',
147
+ 'asyncapi new --file-name=my-asyncapi.yml --example=default-example.yml --no-tty\t - create a new file with a specific name, using one of the examples and without interactive mode'
148
+ ];
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.53.0",
2
+ "version": "0.54.0",
3
3
  "commands": {
4
4
  "bundle": {
5
5
  "id": "bundle",
@@ -716,6 +716,10 @@
716
716
  "pluginAlias": "@asyncapi/cli",
717
717
  "pluginType": "core",
718
718
  "aliases": [],
719
+ "examples": [
720
+ "asyncapi new\t - start creation of a file in interactive mode",
721
+ "asyncapi new --file-name=my-asyncapi.yml --example=default-example.yml --no-tty\t - create a new file with a specific name, using one of the examples and without interactive mode"
722
+ ],
719
723
  "flags": {
720
724
  "help": {
721
725
  "name": "help",
@@ -735,7 +739,7 @@
735
739
  "name": "example",
736
740
  "type": "option",
737
741
  "char": "e",
738
- "description": "name of the example to use",
742
+ "description": "name of the example to use. Available examples are:\n\t - simple.yml\n\t - anyof.yml\n\t - application-headers.yml\n\t - correlation-id.yml\n\t - websocket-gemini.yml\n\t - gitter-streaming.yml\n\t - mercure.yml\n\t - not.yml\n\t - operation-security.yml\n\t - oneof.yml\n\t - rpc-client.yml\n\t - rpc-server.yml\n\t - slack-rtm.yml\n\t - tutorial.yml\n\t - streetlights-kafka.yml\n\t - streetlights-operation-security.yml\n\t - streetlights-mqtt.yml",
739
743
  "multiple": false
740
744
  },
741
745
  "studio": {
@@ -796,6 +800,10 @@
796
800
  "pluginAlias": "@asyncapi/cli",
797
801
  "pluginType": "core",
798
802
  "aliases": [],
803
+ "examples": [
804
+ "asyncapi new\t - start creation of a file in interactive mode",
805
+ "asyncapi new --file-name=my-asyncapi.yml --example=default-example.yml --no-tty\t - create a new file with a specific name, using one of the examples and without interactive mode"
806
+ ],
799
807
  "flags": {
800
808
  "help": {
801
809
  "name": "help",
@@ -815,7 +823,7 @@
815
823
  "name": "example",
816
824
  "type": "option",
817
825
  "char": "e",
818
- "description": "name of the example to use",
826
+ "description": "name of the example to use. Available examples are:\n\t - simple.yml\n\t - anyof.yml\n\t - application-headers.yml\n\t - correlation-id.yml\n\t - websocket-gemini.yml\n\t - gitter-streaming.yml\n\t - mercure.yml\n\t - not.yml\n\t - operation-security.yml\n\t - oneof.yml\n\t - rpc-client.yml\n\t - rpc-server.yml\n\t - slack-rtm.yml\n\t - tutorial.yml\n\t - streetlights-kafka.yml\n\t - streetlights-operation-security.yml\n\t - streetlights-mqtt.yml",
819
827
  "multiple": false
820
828
  },
821
829
  "studio": {
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.53.0",
4
+ "version": "0.54.0",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run"