@asyncapi/cli 0.52.5 → 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.
|
@@ -3,6 +3,7 @@ export default class ContextAdd extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
5
|
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
6
|
+
'set-current': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
6
7
|
};
|
|
7
8
|
static args: {
|
|
8
9
|
name: string;
|
|
@@ -8,12 +8,17 @@ const context_error_1 = require("../../../errors/context-error");
|
|
|
8
8
|
class ContextAdd extends base_1.default {
|
|
9
9
|
run() {
|
|
10
10
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
-
const { args } = yield this.parse(ContextAdd);
|
|
11
|
+
const { args, flags } = yield this.parse(ContextAdd);
|
|
12
12
|
const contextName = args['context-name'];
|
|
13
13
|
const specFilePath = args['spec-file-path'];
|
|
14
|
+
const setAsCurrent = flags['set-current'];
|
|
14
15
|
try {
|
|
15
16
|
yield (0, Context_1.addContext)(contextName, specFilePath);
|
|
16
17
|
this.log(`Added context "${contextName}".\n\nYou can set it as your current context: asyncapi config context use ${contextName}\nYou can use this context when needed by passing ${contextName} as a parameter: asyncapi validate ${contextName}`);
|
|
18
|
+
if (setAsCurrent) {
|
|
19
|
+
yield (0, Context_1.setCurrentContext)(contextName);
|
|
20
|
+
this.log(`The newly added context "${contextName}", is set as your current context!`);
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
catch (e) {
|
|
19
24
|
if (e instanceof (context_error_1.MissingContextFileError || context_error_1.ContextFileWrongFormatError)) {
|
|
@@ -31,6 +36,12 @@ exports.default = ContextAdd;
|
|
|
31
36
|
ContextAdd.description = 'Add a context to the store';
|
|
32
37
|
ContextAdd.flags = {
|
|
33
38
|
help: core_1.Flags.help({ char: 'h' }),
|
|
39
|
+
'set-current': core_1.Flags.boolean({
|
|
40
|
+
char: 's',
|
|
41
|
+
description: 'Set context being added as the current context',
|
|
42
|
+
default: false,
|
|
43
|
+
required: false,
|
|
44
|
+
})
|
|
34
45
|
};
|
|
35
46
|
ContextAdd.args = [
|
|
36
47
|
{ name: 'context-name', description: 'context name', required: true },
|
|
@@ -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>;
|
package/lib/commands/new/file.js
CHANGED
|
@@ -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:
|
|
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
|
+
];
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "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": {
|
|
@@ -927,6 +935,14 @@
|
|
|
927
935
|
"char": "h",
|
|
928
936
|
"description": "Show CLI help.",
|
|
929
937
|
"allowNo": false
|
|
938
|
+
},
|
|
939
|
+
"set-current": {
|
|
940
|
+
"name": "set-current",
|
|
941
|
+
"type": "boolean",
|
|
942
|
+
"char": "s",
|
|
943
|
+
"description": "Set context being added as the current context",
|
|
944
|
+
"required": false,
|
|
945
|
+
"allowNo": false
|
|
930
946
|
}
|
|
931
947
|
},
|
|
932
948
|
"args": {
|