@asyncapi/cli 1.17.0 → 2.0.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.
- package/lib/commands/bundle.d.ts +1 -1
- package/lib/commands/bundle.js +4 -10
- package/lib/commands/config/analytics.d.ts +1 -1
- package/lib/commands/config/analytics.js +3 -8
- package/lib/commands/config/context/add.d.ts +1 -1
- package/lib/commands/config/context/add.js +5 -12
- package/lib/commands/config/context/current.d.ts +1 -1
- package/lib/commands/config/context/current.js +5 -7
- package/lib/commands/config/context/edit.d.ts +1 -1
- package/lib/commands/config/context/edit.js +5 -6
- package/lib/commands/config/context/index.d.ts +1 -1
- package/lib/commands/config/context/index.js +1 -1
- package/lib/commands/config/context/init.d.ts +1 -1
- package/lib/commands/config/context/init.js +4 -5
- package/lib/commands/config/context/list.d.ts +1 -1
- package/lib/commands/config/context/list.js +5 -7
- package/lib/commands/config/context/remove.d.ts +1 -1
- package/lib/commands/config/context/remove.js +5 -6
- package/lib/commands/config/context/use.d.ts +1 -1
- package/lib/commands/config/context/use.js +5 -6
- package/lib/commands/config/index.d.ts +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/versions.d.ts +1 -1
- package/lib/commands/config/versions.js +3 -5
- package/lib/commands/convert.d.ts +1 -1
- package/lib/commands/convert.js +6 -9
- package/lib/commands/diff.d.ts +1 -1
- package/lib/commands/diff.js +9 -28
- package/lib/commands/generate/fromTemplate.d.ts +1 -1
- package/lib/commands/generate/fromTemplate.js +7 -59
- package/lib/commands/generate/index.d.ts +1 -1
- package/lib/commands/generate/index.js +1 -1
- package/lib/commands/generate/models.d.ts +13 -31
- package/lib/commands/generate/models.js +18 -306
- package/lib/commands/new/file.d.ts +1 -1
- package/lib/commands/new/file.js +5 -12
- package/lib/commands/new/glee.d.ts +2 -2
- package/lib/commands/new/glee.js +6 -26
- package/lib/commands/optimize.d.ts +1 -1
- package/lib/commands/optimize.js +5 -9
- package/lib/commands/start/index.d.ts +1 -1
- package/lib/commands/start/index.js +2 -2
- package/lib/commands/start/studio.d.ts +1 -1
- package/lib/commands/start/studio.js +5 -9
- package/lib/commands/validate.d.ts +1 -1
- package/lib/commands/validate.js +6 -6
- package/lib/{base.d.ts → core/base.d.ts} +1 -1
- package/lib/core/flags/bundle.flags.d.ts +7 -0
- package/lib/core/flags/bundle.flags.js +14 -0
- package/lib/core/flags/config/analytics.flags.d.ts +6 -0
- package/lib/core/flags/config/analytics.flags.js +13 -0
- package/lib/core/flags/config/context.flags.d.ts +4 -0
- package/lib/core/flags/config/context.flags.js +16 -0
- package/lib/core/flags/convert.flags.d.ts +5 -0
- package/lib/core/flags/convert.flags.js +12 -0
- package/lib/core/flags/diff.flags.d.ts +12 -0
- package/lib/core/flags/diff.flags.js +29 -0
- package/lib/core/flags/generate/fromTemplate.flags.d.ts +16 -0
- package/lib/core/flags/generate/fromTemplate.flags.js +61 -0
- package/lib/core/flags/generate/models.flags.d.ts +28 -0
- package/lib/core/flags/generate/models.flags.js +14 -0
- package/lib/{flags.d.ts → core/flags/global.flags.d.ts} +3 -0
- package/lib/{flags.js → core/flags/global.flags.js} +7 -1
- package/lib/core/flags/new/file.flags.d.ts +8 -0
- package/lib/core/flags/new/file.flags.js +15 -0
- package/lib/core/flags/new/glee.flags.d.ts +7 -0
- package/lib/core/flags/new/glee.flags.js +28 -0
- package/lib/core/flags/optimize.flags.d.ts +17 -0
- package/lib/core/flags/optimize.flags.js +26 -0
- package/lib/core/flags/start/studio.flags.d.ts +5 -0
- package/lib/core/flags/start/studio.flags.js +12 -0
- package/lib/core/flags/validate.flags.d.ts +7 -0
- package/lib/core/flags/validate.flags.js +10 -0
- package/oclif.manifest.json +49 -48
- package/package.json +2 -2
- /package/lib/{base.js → core/base.js} +0 -0
- /package/lib/{errors → core/errors}/context-error.d.ts +0 -0
- /package/lib/{errors → core/errors}/context-error.js +0 -0
- /package/lib/{errors → core/errors}/diff-error.d.ts +0 -0
- /package/lib/{errors → core/errors}/diff-error.js +0 -0
- /package/lib/{errors → core/errors}/generator-error.d.ts +0 -0
- /package/lib/{errors → core/errors}/generator-error.js +0 -0
- /package/lib/{errors → core/errors}/specification-file.d.ts +0 -0
- /package/lib/{errors → core/errors}/specification-file.js +0 -0
- /package/lib/{errors → core/errors}/validation-error.d.ts +0 -0
- /package/lib/{errors → core/errors}/validation-error.js +0 -0
- /package/lib/{globals.d.ts → core/globals.d.ts} +0 -0
- /package/lib/{globals.js → core/globals.js} +0 -0
- /package/lib/{hooks → core/hooks}/command_not_found/myhook.d.ts +0 -0
- /package/lib/{hooks → core/hooks}/command_not_found/myhook.js +0 -0
- /package/lib/{models → core/models}/Context.d.ts +0 -0
- /package/lib/{models → core/models}/Context.js +0 -0
- /package/lib/{models → core/models}/SpecificationFile.d.ts +0 -0
- /package/lib/{models → core/models}/SpecificationFile.js +0 -0
- /package/lib/{models → core/models}/Studio.d.ts +0 -0
- /package/lib/{models → core/models}/Studio.js +0 -0
- /package/lib/{parser.d.ts → core/parser.d.ts} +0 -0
- /package/lib/{parser.js → core/parser.js} +0 -0
- /package/lib/{utils → core/utils}/generator.d.ts +0 -0
- /package/lib/{utils → core/utils}/generator.js +0 -0
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import Command from '../../base';
|
|
1
|
+
import Command from '../../core/base';
|
|
2
2
|
export default class Models extends Command {
|
|
3
3
|
static description: string;
|
|
4
|
-
static args:
|
|
5
|
-
language: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
-
file: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
-
};
|
|
4
|
+
static readonly args: any;
|
|
8
5
|
static flags: {
|
|
9
6
|
'log-diagnostics': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
7
|
'diagnostics-format': import("@oclif/core/lib/interfaces").OptionFlag<import("@stoplight/spectral-cli/dist/services/config").OutputFormat, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
8
|
'fail-severity': import("@oclif/core/lib/interfaces").OptionFlag<"error" | "warn" | "info" | "hint", import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
-
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
13
9
|
'no-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
javaIncludeComments: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
javaJackson: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
javaConstraints: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
csharpAutoImplement: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
csharpNewtonsoft: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
csharpArrayType: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
16
|
+
csharpHashcode: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
csharpEqual: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
csharpSystemJson: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
18
19
|
tsModelType: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
19
20
|
tsEnumType: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
20
21
|
tsModuleSystem: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
@@ -24,29 +25,10 @@ export default class Models extends Command {
|
|
|
24
25
|
tsMarshalling: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
25
26
|
tsExampleInstance: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
26
27
|
tsRawPropertyNames: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
28
|
+
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
29
|
+
output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
30
30
|
packageName: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
31
|
-
/**
|
|
32
|
-
* Java specific options
|
|
33
|
-
*/
|
|
34
|
-
javaIncludeComments: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
35
|
-
javaJackson: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
36
|
-
javaConstraints: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
37
|
-
/**
|
|
38
|
-
* C++ and C# and PHP specific namespace to use for the generated models
|
|
39
|
-
*/
|
|
40
31
|
namespace: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
41
|
-
/**
|
|
42
|
-
* C# specific options
|
|
43
|
-
*/
|
|
44
|
-
csharpAutoImplement: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
45
|
-
csharpNewtonsoft: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
46
|
-
csharpArrayType: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
47
|
-
csharpHashcode: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
48
|
-
csharpEqual: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
49
|
-
csharpSystemJson: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
50
32
|
};
|
|
51
33
|
run(): Promise<void>;
|
|
52
34
|
private parseArgs;
|
|
@@ -1,37 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
8
|
-
const SpecificationFile_1 = require("../../models/SpecificationFile");
|
|
9
|
-
const parser_1 = require("../../parser");
|
|
4
|
+
const base_1 = tslib_1.__importDefault(require("../../core/base"));
|
|
5
|
+
const SpecificationFile_1 = require("../../core/models/SpecificationFile");
|
|
6
|
+
const parser_1 = require("../../core/parser");
|
|
10
7
|
const prompts_1 = require("@clack/prompts");
|
|
11
8
|
const picocolors_1 = require("picocolors");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Languages["typescript"] = "typescript";
|
|
15
|
-
Languages["csharp"] = "csharp";
|
|
16
|
-
Languages["golang"] = "golang";
|
|
17
|
-
Languages["java"] = "java";
|
|
18
|
-
Languages["javascript"] = "javascript";
|
|
19
|
-
Languages["dart"] = "dart";
|
|
20
|
-
Languages["python"] = "python";
|
|
21
|
-
Languages["rust"] = "rust";
|
|
22
|
-
Languages["kotlin"] = "kotlin";
|
|
23
|
-
Languages["php"] = "php";
|
|
24
|
-
Languages["cplusplus"] = "cplusplus";
|
|
25
|
-
})(Languages || (Languages = {}));
|
|
26
|
-
const possibleLanguageValues = Object.values(Languages).join(', ');
|
|
9
|
+
const modelina_cli_1 = require("@asyncapi/modelina-cli");
|
|
10
|
+
const models_flags_1 = require("../../core/flags/generate/models.flags");
|
|
27
11
|
class Models extends base_1.default {
|
|
28
|
-
/* eslint-disable sonarjs/cognitive-complexity */
|
|
29
12
|
run() {
|
|
30
13
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
14
|
const { args, flags } = yield this.parse(Models);
|
|
32
|
-
const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, tsMarshalling, tsExampleInstance, tsRawPropertyNames, namespace, csharpAutoImplement, csharpArrayType, csharpNewtonsoft, csharpHashcode, csharpEqual, csharpSystemJson, packageName, javaIncludeComments, javaJackson, javaConstraints } = flags;
|
|
33
15
|
let { language, file } = args;
|
|
34
|
-
let output = flags
|
|
16
|
+
let { output } = flags;
|
|
35
17
|
const interactive = !flags['no-interactive'];
|
|
36
18
|
if (!interactive) {
|
|
37
19
|
(0, prompts_1.intro)((0, picocolors_1.inverse)('AsyncAPI Generate Models'));
|
|
@@ -50,11 +32,7 @@ class Models extends base_1.default {
|
|
|
50
32
|
this.log(`Input is not a correct AsyncAPI document so it cannot be processed.${(0, parser_1.formatOutput)(severityErrors, 'stylish', 'error')}`);
|
|
51
33
|
return;
|
|
52
34
|
}
|
|
53
|
-
|
|
54
|
-
// This call converts the parsed document object using @asyncapi/parser@v3.x (Parser-API v2) to a document compatible with the Parser-API version in use in @asyncapi/parser@v2.x (v1)
|
|
55
|
-
// This is needed until https://github.com/asyncapi/modelina/issues/1493 gets fixed.
|
|
56
|
-
const convertedDoc = (0, multi_parser_1.ConvertDocumentParserAPIVersion)(document.json(), 1);
|
|
57
|
-
modelina_1.Logger.setLogger({
|
|
35
|
+
const logger = {
|
|
58
36
|
info: (message) => {
|
|
59
37
|
this.log(message);
|
|
60
38
|
},
|
|
@@ -67,169 +45,22 @@ class Models extends base_1.default {
|
|
|
67
45
|
error: (message) => {
|
|
68
46
|
this.error(message);
|
|
69
47
|
},
|
|
70
|
-
});
|
|
71
|
-
let fileGenerator;
|
|
72
|
-
let fileOptions = {};
|
|
73
|
-
const presets = [];
|
|
74
|
-
const options = {
|
|
75
|
-
marshalling: tsMarshalling,
|
|
76
|
-
example: tsExampleInstance,
|
|
77
48
|
};
|
|
78
|
-
switch (language) {
|
|
79
|
-
case Languages.typescript:
|
|
80
|
-
presets.push({
|
|
81
|
-
preset: modelina_1.TS_COMMON_PRESET,
|
|
82
|
-
options
|
|
83
|
-
});
|
|
84
|
-
if (tsIncludeComments) {
|
|
85
|
-
presets.push(modelina_1.TS_DESCRIPTION_PRESET);
|
|
86
|
-
}
|
|
87
|
-
if (tsJsonBinPack) {
|
|
88
|
-
presets.push({
|
|
89
|
-
preset: modelina_1.TS_COMMON_PRESET,
|
|
90
|
-
options
|
|
91
|
-
}, modelina_1.TS_JSONBINPACK_PRESET);
|
|
92
|
-
}
|
|
93
|
-
fileGenerator = new modelina_1.TypeScriptFileGenerator({
|
|
94
|
-
modelType: tsModelType,
|
|
95
|
-
enumType: tsEnumType,
|
|
96
|
-
rawPropertyNames: tsRawPropertyNames,
|
|
97
|
-
presets
|
|
98
|
-
});
|
|
99
|
-
fileOptions = {
|
|
100
|
-
moduleSystem: tsModuleSystem,
|
|
101
|
-
exportType: tsExportType
|
|
102
|
-
};
|
|
103
|
-
break;
|
|
104
|
-
case Languages.python:
|
|
105
|
-
fileGenerator = new modelina_1.PythonFileGenerator();
|
|
106
|
-
break;
|
|
107
|
-
case Languages.rust:
|
|
108
|
-
fileGenerator = new modelina_1.RustFileGenerator();
|
|
109
|
-
break;
|
|
110
|
-
case Languages.csharp:
|
|
111
|
-
if (namespace === undefined) {
|
|
112
|
-
throw new Error('In order to generate models to C#, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.');
|
|
113
|
-
}
|
|
114
|
-
if (csharpAutoImplement) {
|
|
115
|
-
presets.push({
|
|
116
|
-
preset: modelina_1.CSHARP_DEFAULT_PRESET,
|
|
117
|
-
options: {
|
|
118
|
-
autoImplementedProperties: true
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
if (csharpNewtonsoft) {
|
|
123
|
-
presets.push(modelina_1.CSHARP_NEWTONSOFT_SERIALIZER_PRESET);
|
|
124
|
-
}
|
|
125
|
-
if (csharpSystemJson) {
|
|
126
|
-
presets.push(modelina_1.CSHARP_JSON_SERIALIZER_PRESET);
|
|
127
|
-
}
|
|
128
|
-
if (csharpHashcode || csharpEqual) {
|
|
129
|
-
presets.push({
|
|
130
|
-
preset: modelina_1.CSHARP_COMMON_PRESET,
|
|
131
|
-
options: {
|
|
132
|
-
hashCode: csharpHashcode,
|
|
133
|
-
equals: csharpEqual
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
fileGenerator = new modelina_1.CSharpFileGenerator({
|
|
138
|
-
presets,
|
|
139
|
-
collectionType: csharpArrayType
|
|
140
|
-
});
|
|
141
|
-
fileOptions = {
|
|
142
|
-
namespace
|
|
143
|
-
};
|
|
144
|
-
break;
|
|
145
|
-
case Languages.cplusplus:
|
|
146
|
-
if (namespace === undefined) {
|
|
147
|
-
throw new Error('In order to generate models to C++, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.');
|
|
148
|
-
}
|
|
149
|
-
fileGenerator = new modelina_1.CplusplusFileGenerator({
|
|
150
|
-
namespace
|
|
151
|
-
});
|
|
152
|
-
break;
|
|
153
|
-
case Languages.golang:
|
|
154
|
-
if (packageName === undefined) {
|
|
155
|
-
throw new Error('In order to generate models to Go, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.');
|
|
156
|
-
}
|
|
157
|
-
fileGenerator = new modelina_1.GoFileGenerator();
|
|
158
|
-
fileOptions = {
|
|
159
|
-
packageName
|
|
160
|
-
};
|
|
161
|
-
break;
|
|
162
|
-
case Languages.java:
|
|
163
|
-
if (packageName === undefined) {
|
|
164
|
-
throw new Error('In order to generate models to Java, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.');
|
|
165
|
-
}
|
|
166
|
-
presets.push({
|
|
167
|
-
preset: modelina_1.JAVA_COMMON_PRESET,
|
|
168
|
-
options
|
|
169
|
-
});
|
|
170
|
-
if (javaIncludeComments) {
|
|
171
|
-
presets.push(modelina_1.JAVA_DESCRIPTION_PRESET);
|
|
172
|
-
}
|
|
173
|
-
if (javaJackson) {
|
|
174
|
-
presets.push(modelina_1.JAVA_JACKSON_PRESET);
|
|
175
|
-
}
|
|
176
|
-
if (javaConstraints) {
|
|
177
|
-
presets.push(modelina_1.JAVA_CONSTRAINTS_PRESET);
|
|
178
|
-
}
|
|
179
|
-
fileGenerator = new modelina_1.JavaFileGenerator({ presets });
|
|
180
|
-
fileOptions = {
|
|
181
|
-
packageName
|
|
182
|
-
};
|
|
183
|
-
break;
|
|
184
|
-
case Languages.javascript:
|
|
185
|
-
fileGenerator = new modelina_1.JavaScriptFileGenerator();
|
|
186
|
-
break;
|
|
187
|
-
case Languages.dart:
|
|
188
|
-
if (packageName === undefined) {
|
|
189
|
-
throw new Error('In order to generate models to Dart, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.');
|
|
190
|
-
}
|
|
191
|
-
fileGenerator = new modelina_1.DartFileGenerator();
|
|
192
|
-
fileOptions = {
|
|
193
|
-
packageName
|
|
194
|
-
};
|
|
195
|
-
break;
|
|
196
|
-
case Languages.kotlin:
|
|
197
|
-
if (packageName === undefined) {
|
|
198
|
-
throw new Error('In order to generate models to Kotlin, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.');
|
|
199
|
-
}
|
|
200
|
-
fileGenerator = new modelina_1.KotlinFileGenerator();
|
|
201
|
-
fileOptions = {
|
|
202
|
-
packageName
|
|
203
|
-
};
|
|
204
|
-
break;
|
|
205
|
-
case Languages.php:
|
|
206
|
-
if (namespace === undefined) {
|
|
207
|
-
throw new Error('In order to generate models to PHP, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.');
|
|
208
|
-
}
|
|
209
|
-
fileGenerator = new modelina_1.PhpFileGenerator();
|
|
210
|
-
fileOptions = {
|
|
211
|
-
namespace
|
|
212
|
-
};
|
|
213
|
-
break;
|
|
214
|
-
default:
|
|
215
|
-
throw new Error(`Could not determine generator for language ${language}, are you using one of the following values ${possibleLanguageValues}?`);
|
|
216
|
-
}
|
|
217
49
|
const s = (0, prompts_1.spinner)();
|
|
218
50
|
s.start('Generating models...');
|
|
51
|
+
const generatedModels = yield (0, modelina_cli_1.generateModels)(Object.assign(Object.assign({}, flags), { output }), document, logger, language);
|
|
219
52
|
if (output !== 'stdout') {
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
s.stop((0, picocolors_1.green)(`Successfully generated the following models: ${generatedModels.join(', ')}`));
|
|
53
|
+
const generatedModelStrings = generatedModels.map((model) => { return model.modelName; });
|
|
54
|
+
s.stop((0, picocolors_1.green)(`Successfully generated the following models: ${generatedModelStrings.join(', ')}`));
|
|
223
55
|
return;
|
|
224
56
|
}
|
|
225
|
-
const
|
|
226
|
-
const generatedModels = models.map((model) => {
|
|
57
|
+
const generatedModelStrings = generatedModels.map((model) => {
|
|
227
58
|
return `
|
|
228
|
-
|
|
229
|
-
|
|
59
|
+
## Model name: ${model.modelName}
|
|
60
|
+
${model.result}
|
|
230
61
|
`;
|
|
231
62
|
});
|
|
232
|
-
s.stop((0, picocolors_1.green)(`Successfully generated the following models: ${
|
|
63
|
+
s.stop((0, picocolors_1.green)(`Successfully generated the following models: ${generatedModelStrings.join('\n')}`));
|
|
233
64
|
});
|
|
234
65
|
}
|
|
235
66
|
parseArgs(args, output) {
|
|
@@ -240,7 +71,7 @@ class Models extends base_1.default {
|
|
|
240
71
|
if (!language) {
|
|
241
72
|
language = yield (0, prompts_1.select)({
|
|
242
73
|
message: 'Select the language you want to generate models for',
|
|
243
|
-
options: Object.keys(Languages).map((key) => ({ value: key, label: key, hint: Languages[key] })),
|
|
74
|
+
options: Object.keys(modelina_cli_1.Languages).map((key) => ({ value: key, label: key, hint: modelina_cli_1.Languages[key] })),
|
|
244
75
|
});
|
|
245
76
|
askForOutput = true;
|
|
246
77
|
}
|
|
@@ -271,130 +102,11 @@ class Models extends base_1.default {
|
|
|
271
102
|
(0, prompts_1.cancel)(operationCancelled);
|
|
272
103
|
this.exit();
|
|
273
104
|
}
|
|
274
|
-
return { language, file, output: output
|
|
105
|
+
return { language, file, output: output !== null && output !== void 0 ? output : 'stdout' };
|
|
275
106
|
});
|
|
276
107
|
}
|
|
277
108
|
}
|
|
278
109
|
exports.default = Models;
|
|
279
110
|
Models.description = 'Generates typed models';
|
|
280
|
-
Models.args =
|
|
281
|
-
|
|
282
|
-
file: core_1.Args.string({ description: 'Path or URL to the AsyncAPI document, or context-name', required: true }),
|
|
283
|
-
};
|
|
284
|
-
Models.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), 'no-interactive': core_1.Flags.boolean({
|
|
285
|
-
description: 'Disable interactive mode and run with the provided flags.',
|
|
286
|
-
required: false,
|
|
287
|
-
default: false,
|
|
288
|
-
}), output: core_1.Flags.string({
|
|
289
|
-
char: 'o',
|
|
290
|
-
description: 'The output directory where the models should be written to. Omitting this flag will write the models to `stdout`.',
|
|
291
|
-
required: false
|
|
292
|
-
}),
|
|
293
|
-
/**
|
|
294
|
-
* TypeScript specific options
|
|
295
|
-
*/
|
|
296
|
-
tsModelType: core_1.Flags.string({
|
|
297
|
-
type: 'option',
|
|
298
|
-
options: ['class', 'interface'],
|
|
299
|
-
description: 'TypeScript specific, define which type of model needs to be generated.',
|
|
300
|
-
required: false,
|
|
301
|
-
default: 'class',
|
|
302
|
-
}), tsEnumType: core_1.Flags.string({
|
|
303
|
-
type: 'option',
|
|
304
|
-
options: ['enum', 'union'],
|
|
305
|
-
description: 'TypeScript specific, define which type of enums needs to be generated.',
|
|
306
|
-
required: false,
|
|
307
|
-
default: 'enum',
|
|
308
|
-
}), tsModuleSystem: core_1.Flags.string({
|
|
309
|
-
type: 'option',
|
|
310
|
-
options: ['ESM', 'CJS'],
|
|
311
|
-
description: 'TypeScript specific, define the module system to be used.',
|
|
312
|
-
required: false,
|
|
313
|
-
default: 'ESM',
|
|
314
|
-
}), tsIncludeComments: core_1.Flags.boolean({
|
|
315
|
-
description: 'TypeScript specific, if enabled add comments while generating models.',
|
|
316
|
-
required: false,
|
|
317
|
-
default: false,
|
|
318
|
-
}), tsExportType: core_1.Flags.string({
|
|
319
|
-
type: 'option',
|
|
320
|
-
options: ['default', 'named'],
|
|
321
|
-
description: 'TypeScript specific, define which type of export needs to be generated.',
|
|
322
|
-
required: false,
|
|
323
|
-
default: 'default',
|
|
324
|
-
}), tsJsonBinPack: core_1.Flags.boolean({
|
|
325
|
-
description: 'TypeScript specific, define basic support for serializing to and from binary with jsonbinpack.',
|
|
326
|
-
required: false,
|
|
327
|
-
default: false,
|
|
328
|
-
}), tsMarshalling: core_1.Flags.boolean({
|
|
329
|
-
description: 'TypeScript specific, generate the models with marshalling functions.',
|
|
330
|
-
required: false,
|
|
331
|
-
default: false,
|
|
332
|
-
}), tsExampleInstance: core_1.Flags.boolean({
|
|
333
|
-
description: 'Typescript specific, generate example of the model',
|
|
334
|
-
required: false,
|
|
335
|
-
default: false,
|
|
336
|
-
}), tsRawPropertyNames: core_1.Flags.boolean({
|
|
337
|
-
description: 'Typescript specific, generate the models using raw property names.',
|
|
338
|
-
required: false,
|
|
339
|
-
default: false,
|
|
340
|
-
}),
|
|
341
|
-
/**
|
|
342
|
-
* Go and Java specific package name to use for the generated models
|
|
343
|
-
*/
|
|
344
|
-
packageName: core_1.Flags.string({
|
|
345
|
-
description: 'Go, Java and Kotlin specific, define the package to use for the generated models. This is required when language is `go`, `java` or `kotlin`.',
|
|
346
|
-
required: false
|
|
347
|
-
}),
|
|
348
|
-
/**
|
|
349
|
-
* Java specific options
|
|
350
|
-
*/
|
|
351
|
-
javaIncludeComments: core_1.Flags.boolean({
|
|
352
|
-
description: 'Java specific, if enabled add comments while generating models.',
|
|
353
|
-
required: false,
|
|
354
|
-
default: false
|
|
355
|
-
}), javaJackson: core_1.Flags.boolean({
|
|
356
|
-
description: 'Java specific, generate the models with Jackson serialization support',
|
|
357
|
-
required: false,
|
|
358
|
-
default: false
|
|
359
|
-
}), javaConstraints: core_1.Flags.boolean({
|
|
360
|
-
description: 'Java specific, generate the models with constraints',
|
|
361
|
-
required: false,
|
|
362
|
-
default: false
|
|
363
|
-
}),
|
|
364
|
-
/**
|
|
365
|
-
* C++ and C# and PHP specific namespace to use for the generated models
|
|
366
|
-
*/
|
|
367
|
-
namespace: core_1.Flags.string({
|
|
368
|
-
description: 'C#, C++ and PHP specific, define the namespace to use for the generated models. This is required when language is `csharp`,`c++` or `php`.',
|
|
369
|
-
required: false
|
|
370
|
-
}),
|
|
371
|
-
/**
|
|
372
|
-
* C# specific options
|
|
373
|
-
*/
|
|
374
|
-
csharpAutoImplement: core_1.Flags.boolean({
|
|
375
|
-
description: 'C# specific, define whether to generate auto-implemented properties or not.',
|
|
376
|
-
required: false,
|
|
377
|
-
default: false
|
|
378
|
-
}), csharpNewtonsoft: core_1.Flags.boolean({
|
|
379
|
-
description: 'C# specific, generate the models with newtonsoft serialization support',
|
|
380
|
-
required: false,
|
|
381
|
-
default: false
|
|
382
|
-
}), csharpArrayType: core_1.Flags.string({
|
|
383
|
-
type: 'option',
|
|
384
|
-
description: 'C# specific, define which type of array needs to be generated.',
|
|
385
|
-
options: ['Array', 'List'],
|
|
386
|
-
required: false,
|
|
387
|
-
default: 'Array'
|
|
388
|
-
}), csharpHashcode: core_1.Flags.boolean({
|
|
389
|
-
description: 'C# specific, generate the models with the GetHashCode method overwritten',
|
|
390
|
-
required: false,
|
|
391
|
-
default: false
|
|
392
|
-
}), csharpEqual: core_1.Flags.boolean({
|
|
393
|
-
description: 'C# specific, generate the models with the Equal method overwritten',
|
|
394
|
-
required: false,
|
|
395
|
-
default: false
|
|
396
|
-
}), csharpSystemJson: core_1.Flags.boolean({
|
|
397
|
-
description: 'C# specific, generate the models with System.Text.Json serialization support',
|
|
398
|
-
required: false,
|
|
399
|
-
default: false
|
|
400
|
-
}) }, (0, parser_1.validationFlags)({ logDiagnostics: false }));
|
|
111
|
+
Models.args = modelina_cli_1.ModelinaArgs;
|
|
112
|
+
Models.flags = (0, models_flags_1.modelsFlags)();
|
package/lib/commands/new/file.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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");
|
|
5
4
|
const fs_1 = require("fs");
|
|
6
|
-
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
5
|
+
const base_1 = tslib_1.__importDefault(require("../../core/base"));
|
|
7
6
|
const inquirer = tslib_1.__importStar(require("inquirer"));
|
|
8
|
-
const Studio_1 = require("../../models/Studio");
|
|
7
|
+
const Studio_1 = require("../../core/models/Studio");
|
|
9
8
|
const path_1 = require("path");
|
|
10
|
-
const SpecificationFile_1 = require("../../models/SpecificationFile");
|
|
9
|
+
const SpecificationFile_1 = require("../../core/models/SpecificationFile");
|
|
11
10
|
const picocolors_1 = require("picocolors");
|
|
11
|
+
const file_flags_1 = require("../../core/flags/new/file.flags");
|
|
12
12
|
const { writeFile, readFile } = fs_1.promises;
|
|
13
13
|
const DEFAULT_ASYNCAPI_FILE_NAME = 'asyncapi.yaml';
|
|
14
14
|
const DEFAULT_ASYNCAPI_TEMPLATE = 'default-example.yaml';
|
|
@@ -152,14 +152,7 @@ class NewFile extends base_1.default {
|
|
|
152
152
|
}
|
|
153
153
|
exports.default = NewFile;
|
|
154
154
|
NewFile.description = 'Creates a new asyncapi file';
|
|
155
|
-
NewFile.flags =
|
|
156
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
157
|
-
'file-name': core_1.Flags.string({ char: 'n', description: 'name of the file' }),
|
|
158
|
-
example: core_1.Flags.string({ char: 'e', description: getExamplesFlagDescription() }),
|
|
159
|
-
studio: core_1.Flags.boolean({ char: 's', description: 'open in Studio' }),
|
|
160
|
-
port: core_1.Flags.integer({ char: 'p', description: 'port in which to start Studio' }),
|
|
161
|
-
'no-tty': core_1.Flags.boolean({ description: 'do not use an interactive terminal' }),
|
|
162
|
-
};
|
|
155
|
+
NewFile.flags = (0, file_flags_1.fileFlags)(getExamplesFlagDescription());
|
|
163
156
|
NewFile.examples = [
|
|
164
157
|
'asyncapi new\t - start creation of a file in interactive mode',
|
|
165
158
|
'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'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Command from '../../base';
|
|
2
|
-
import { Specification } from '../../models/SpecificationFile';
|
|
1
|
+
import Command from '../../core/base';
|
|
2
|
+
import { Specification } from '../../core/models/SpecificationFile';
|
|
3
3
|
export declare const successMessage: (projectName: string) => string;
|
|
4
4
|
export default class NewGlee extends Command {
|
|
5
5
|
static description: string;
|
package/lib/commands/new/glee.js
CHANGED
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.successMessage = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const core_1 = require("@oclif/core");
|
|
6
5
|
const fs_1 = require("fs");
|
|
7
|
-
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
6
|
+
const base_1 = tslib_1.__importDefault(require("../../core/base"));
|
|
8
7
|
const path_1 = tslib_1.__importStar(require("path"));
|
|
9
8
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
10
|
-
const SpecificationFile_1 = require("../../models/SpecificationFile");
|
|
9
|
+
const SpecificationFile_1 = require("../../core/models/SpecificationFile");
|
|
11
10
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
12
11
|
const inquirer_1 = require("inquirer");
|
|
13
12
|
// eslint-disable-next-line
|
|
14
13
|
// @ts-ignore
|
|
15
14
|
const generator_1 = tslib_1.__importDefault(require("@asyncapi/generator"));
|
|
16
15
|
const picocolors_1 = require("picocolors");
|
|
16
|
+
const glee_flags_1 = require("../../core/flags/new/glee.flags");
|
|
17
17
|
const successMessage = (projectName) => `🎉 Your Glee project has been successfully created!
|
|
18
18
|
⏩ Next steps: follow the instructions ${(0, picocolors_1.cyan)('below')} to manage your project:
|
|
19
19
|
|
|
20
20
|
cd ${projectName}\t\t ${(0, picocolors_1.gray)('# Navigate to the project directory')}
|
|
21
21
|
npm install\t\t ${(0, picocolors_1.gray)('# Install the project dependencies')}
|
|
22
|
-
npm run dev\t\t ${(0, picocolors_1.gray)('# Start the project in development mode')}
|
|
22
|
+
npm run dev\t\t ${(0, picocolors_1.gray)('# Start the project in development mode')}
|
|
23
23
|
|
|
24
24
|
You can also open the project in your favourite editor and start tweaking it.
|
|
25
25
|
`;
|
|
26
26
|
exports.successMessage = successMessage;
|
|
27
27
|
const errorMessages = {
|
|
28
|
-
alreadyExists: (projectName) => `Unable to create the project because the directory "${(0, picocolors_1.cyan)(projectName)}" already exists at "${process.cwd()}/${projectName}".
|
|
28
|
+
alreadyExists: (projectName) => `Unable to create the project because the directory "${(0, picocolors_1.cyan)(projectName)}" already exists at "${process.cwd()}/${projectName}".
|
|
29
29
|
To specify a different name for the new project, please run the command below with a unique project name:
|
|
30
30
|
|
|
31
31
|
${(0, picocolors_1.gray)('asyncapi new glee --name ') + (0, picocolors_1.gray)(projectName) + (0, picocolors_1.gray)('-1')}`,
|
|
@@ -174,24 +174,4 @@ exports.default = NewGlee;
|
|
|
174
174
|
NewGlee.description = 'Creates a new Glee project';
|
|
175
175
|
NewGlee.successMessage = exports.successMessage;
|
|
176
176
|
NewGlee.errorMessages = errorMessages;
|
|
177
|
-
NewGlee.flags =
|
|
178
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
179
|
-
name: core_1.Flags.string({
|
|
180
|
-
char: 'n',
|
|
181
|
-
description: 'Name of the Project',
|
|
182
|
-
default: 'project',
|
|
183
|
-
}),
|
|
184
|
-
template: core_1.Flags.string({
|
|
185
|
-
char: 't',
|
|
186
|
-
description: 'Name of the Template',
|
|
187
|
-
default: 'default',
|
|
188
|
-
}),
|
|
189
|
-
file: core_1.Flags.string({
|
|
190
|
-
char: 'f',
|
|
191
|
-
description: 'The path to the AsyncAPI file for generating a Glee project.',
|
|
192
|
-
}),
|
|
193
|
-
'force-write': core_1.Flags.boolean({
|
|
194
|
-
default: false,
|
|
195
|
-
description: 'Force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)',
|
|
196
|
-
}),
|
|
197
|
-
};
|
|
177
|
+
NewGlee.flags = (0, glee_flags_1.gleeFlags)();
|
package/lib/commands/optimize.js
CHANGED
|
@@ -4,13 +4,14 @@ exports.Outputs = exports.Optimizations = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
6
|
const optimizer_1 = require("@asyncapi/optimizer");
|
|
7
|
-
const base_1 = tslib_1.__importDefault(require("../base"));
|
|
8
|
-
const validation_error_1 = require("../errors/validation-error");
|
|
9
|
-
const SpecificationFile_1 = require("../models/SpecificationFile");
|
|
7
|
+
const base_1 = tslib_1.__importDefault(require("../core/base"));
|
|
8
|
+
const validation_error_1 = require("../core/errors/validation-error");
|
|
9
|
+
const SpecificationFile_1 = require("../core/models/SpecificationFile");
|
|
10
10
|
const inquirer = tslib_1.__importStar(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");
|
|
14
|
+
const optimize_flags_1 = require("../core/flags/optimize.flags");
|
|
14
15
|
const { writeFile } = fs_1.promises;
|
|
15
16
|
var Optimizations;
|
|
16
17
|
(function (Optimizations) {
|
|
@@ -195,12 +196,7 @@ Optimize.examples = [
|
|
|
195
196
|
'asyncapi optimize ./asyncapi.yaml --optimization=remove-components --optimization=reuse-components --optimization=move-all-to-components --no-tty',
|
|
196
197
|
'asyncapi optimize ./asyncapi.yaml --optimization=remove-components --output=terminal --no-tty',
|
|
197
198
|
];
|
|
198
|
-
Optimize.flags =
|
|
199
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
200
|
-
optimization: core_1.Flags.string({ char: 'p', default: Object.values(Optimizations), options: Object.values(Optimizations), multiple: true, description: 'select the type of optimizations that you want to apply.' }),
|
|
201
|
-
output: core_1.Flags.string({ char: 'o', default: Outputs.TERMINAL, options: Object.values(Outputs), description: 'select where you want the output.' }),
|
|
202
|
-
'no-tty': core_1.Flags.boolean({ description: 'do not use an interactive terminal', default: false }),
|
|
203
|
-
};
|
|
199
|
+
Optimize.flags = (0, optimize_flags_1.optimizeFlags)();
|
|
204
200
|
Optimize.args = {
|
|
205
201
|
'spec-file': core_1.Args.string({ description: 'spec path, url, or context-name', required: false }),
|
|
206
202
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
4
|
+
const base_1 = tslib_1.__importDefault(require("../../core/base"));
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
6
|
class Start extends base_1.default {
|
|
7
7
|
run() {
|
|
@@ -12,4 +12,4 @@ class Start extends base_1.default {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
exports.default = Start;
|
|
15
|
-
Start.description = '
|
|
15
|
+
Start.description = '';
|
|
@@ -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
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
const base_1 = tslib_1.__importDefault(require("../../core/base"));
|
|
5
|
+
const Studio_1 = require("../../core/models/Studio");
|
|
6
|
+
const SpecificationFile_1 = require("../../core/models/SpecificationFile");
|
|
7
|
+
const studio_flags_1 = require("../../core/flags/start/studio.flags");
|
|
8
8
|
class StartStudio extends base_1.default {
|
|
9
9
|
run() {
|
|
10
10
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -19,8 +19,4 @@ class StartStudio extends base_1.default {
|
|
|
19
19
|
}
|
|
20
20
|
exports.default = StartStudio;
|
|
21
21
|
StartStudio.description = 'starts a new local instance of Studio';
|
|
22
|
-
StartStudio.flags =
|
|
23
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
24
|
-
file: core_1.Flags.string({ char: 'f', description: 'path to the AsyncAPI file to link with Studio' }),
|
|
25
|
-
port: core_1.Flags.integer({ char: 'p', description: 'port in which to start Studio' }),
|
|
26
|
-
};
|
|
22
|
+
StartStudio.flags = (0, studio_flags_1.studioFlags)();
|