@asyncapi/cli 0.40.9 → 0.42.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/README.md CHANGED
@@ -76,6 +76,8 @@ Thanks go to these wonderful people ([emoji key](https://allcontributors.org/doc
76
76
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/sambhavgupta0705"><img src="https://avatars.githubusercontent.com/u/81870866?v=4?s=100" width="100px;" alt="Sambhav Gupta"/><br /><sub><b>Sambhav Gupta</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=sambhavgupta0705" title="Code">💻</a> <a href="https://github.com/asyncapi/cli/commits?author=sambhavgupta0705" title="Tests">⚠️</a></td>
77
77
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/CyberHippo"><img src="https://avatars.githubusercontent.com/u/18269437?v=4?s=100" width="100px;" alt="Hippolyte Vergnol"/><br /><sub><b>Hippolyte Vergnol</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=CyberHippo" title="Code">💻</a> <a href="#infra-CyberHippo" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
78
78
  <td align="center" valign="top" width="14.28%"><a href="https://www.jentevets.com"><img src="https://avatars.githubusercontent.com/u/22449126?v=4?s=100" width="100px;" alt="Jente Vets"/><br /><sub><b>Jente Vets</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=Vetsoo" title="Code">💻</a></td>
79
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/kaushik-rishi"><img src="https://avatars.githubusercontent.com/u/52498617?v=4?s=100" width="100px;" alt="Rishi"/><br /><sub><b>Rishi</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=kaushik-rishi" title="Code">💻</a></td>
80
+ <td align="center" valign="top" width="14.28%"><a href="http://ashishpadhy.live"><img src="https://avatars.githubusercontent.com/u/100484401?v=4?s=100" width="100px;" alt="Ashish Padhy"/><br /><sub><b>Ashish Padhy</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=Shurtu-gal" title="Code">💻</a></td>
79
81
  </tr>
80
82
  </tbody>
81
83
  </table>
@@ -32,11 +32,16 @@ export default class Models extends Command {
32
32
  */
33
33
  packageName: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
34
34
  /**
35
- * C# specific options
35
+ * C++ and C# and PHP specific namespace to use for the generated models
36
36
  */
37
37
  namespace: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
38
+ /**
39
+ * C# specific options
40
+ */
38
41
  csharpAutoImplement: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
39
42
  csharpArrayType: import("@oclif/core/lib/interfaces").OptionFlag<string>;
43
+ csharpHashcode: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
44
+ csharpEqual: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
40
45
  };
41
46
  run(): Promise<void>;
42
47
  }
@@ -17,6 +17,8 @@ var Languages;
17
17
  Languages["python"] = "python";
18
18
  Languages["rust"] = "rust";
19
19
  Languages["kotlin"] = "kotlin";
20
+ Languages["php"] = "php";
21
+ Languages["cplusplus"] = "cplusplus";
20
22
  })(Languages || (Languages = {}));
21
23
  const possibleLanguageValues = Object.values(Languages).join(', ');
22
24
  class Models extends base_1.default {
@@ -24,7 +26,7 @@ class Models extends base_1.default {
24
26
  run() {
25
27
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
26
28
  const { args, flags } = yield this.parse(Models);
27
- const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, namespace, csharpAutoImplement, csharpArrayType, packageName, output } = flags;
29
+ const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, namespace, csharpAutoImplement, csharpArrayType, csharpHashcode, csharpEqual, packageName, output } = flags;
28
30
  const { language, file } = args;
29
31
  const inputFile = (yield (0, SpecificationFile_1.load)(file)) || (yield (0, SpecificationFile_1.load)());
30
32
  const { document, status } = yield (0, parser_1.parse)(this, inputFile, flags);
@@ -81,21 +83,39 @@ class Models extends base_1.default {
81
83
  if (namespace === undefined) {
82
84
  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.');
83
85
  }
84
- fileGenerator = new modelina_1.CSharpFileGenerator({
85
- presets: csharpAutoImplement ? [
86
- {
87
- preset: modelina_1.CSHARP_DEFAULT_PRESET,
88
- options: {
89
- autoImplementedProperties: true
90
- }
86
+ if (csharpAutoImplement) {
87
+ presets.push({
88
+ preset: modelina_1.CSHARP_DEFAULT_PRESET,
89
+ options: {
90
+ autoImplementedProperties: true
91
+ }
92
+ });
93
+ }
94
+ if (csharpHashcode || csharpEqual) {
95
+ presets.push({
96
+ preset: modelina_1.CSHARP_COMMON_PRESET,
97
+ options: {
98
+ hashCode: csharpHashcode,
99
+ equals: csharpEqual
91
100
  }
92
- ] : [],
101
+ });
102
+ }
103
+ fileGenerator = new modelina_1.CSharpFileGenerator({
104
+ presets,
93
105
  collectionType: csharpArrayType
94
106
  });
95
107
  fileOptions = {
96
108
  namespace
97
109
  };
98
110
  break;
111
+ case Languages.cplusplus:
112
+ if (namespace === undefined) {
113
+ 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.');
114
+ }
115
+ fileGenerator = new modelina_1.CplusplusFileGenerator({
116
+ namespace
117
+ });
118
+ break;
99
119
  case Languages.golang:
100
120
  if (packageName === undefined) {
101
121
  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.');
@@ -135,6 +155,15 @@ class Models extends base_1.default {
135
155
  packageName
136
156
  };
137
157
  break;
158
+ case Languages.php:
159
+ if (namespace === undefined) {
160
+ 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.');
161
+ }
162
+ fileGenerator = new modelina_1.PhpFileGenerator();
163
+ fileOptions = {
164
+ namespace
165
+ };
166
+ break;
138
167
  default:
139
168
  throw new Error(`Could not determine generator for language ${language}, are you using one of the following values ${possibleLanguageValues}?`);
140
169
  }
@@ -215,12 +244,16 @@ Models.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), output: c
215
244
  required: false
216
245
  }),
217
246
  /**
218
- * C# specific options
247
+ * C++ and C# and PHP specific namespace to use for the generated models
219
248
  */
220
249
  namespace: core_1.Flags.string({
221
- description: 'C# specific, define the namespace to use for the generated models. This is required when language is `csharp`.',
250
+ 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`.',
222
251
  required: false
223
- }), csharpAutoImplement: core_1.Flags.boolean({
252
+ }),
253
+ /**
254
+ * C# specific options
255
+ */
256
+ csharpAutoImplement: core_1.Flags.boolean({
224
257
  description: 'C# specific, define whether to generate auto-implemented properties or not.',
225
258
  required: false,
226
259
  default: false
@@ -230,4 +263,12 @@ Models.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), output: c
230
263
  options: ['Array', 'List'],
231
264
  required: false,
232
265
  default: 'Array'
266
+ }), csharpHashcode: core_1.Flags.boolean({
267
+ description: 'C# specific, generate the models with the GetHashCode method overwritten',
268
+ required: false,
269
+ default: false
270
+ }), csharpEqual: core_1.Flags.boolean({
271
+ description: 'C# specific, generate the models with the Equal method overwritten',
272
+ required: false,
273
+ default: false
233
274
  }) }, (0, parser_1.validationFlags)({ logDiagnostics: false }));
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.40.9",
2
+ "version": "0.42.0",
3
3
  "commands": {
4
4
  "bundle": {
5
5
  "id": "bundle",
@@ -542,7 +542,7 @@
542
542
  "namespace": {
543
543
  "name": "namespace",
544
544
  "type": "option",
545
- "description": "C# specific, define the namespace to use for the generated models. This is required when language is `csharp`.",
545
+ "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`.",
546
546
  "required": false,
547
547
  "multiple": false
548
548
  },
@@ -565,6 +565,20 @@
565
565
  ],
566
566
  "default": "Array"
567
567
  },
568
+ "csharpHashcode": {
569
+ "name": "csharpHashcode",
570
+ "type": "boolean",
571
+ "description": "C# specific, generate the models with the GetHashCode method overwritten",
572
+ "required": false,
573
+ "allowNo": false
574
+ },
575
+ "csharpEqual": {
576
+ "name": "csharpEqual",
577
+ "type": "boolean",
578
+ "description": "C# specific, generate the models with the Equal method overwritten",
579
+ "required": false,
580
+ "allowNo": false
581
+ },
568
582
  "log-diagnostics": {
569
583
  "name": "log-diagnostics",
570
584
  "type": "boolean",
@@ -617,7 +631,9 @@
617
631
  "dart",
618
632
  "python",
619
633
  "rust",
620
- "kotlin"
634
+ "kotlin",
635
+ "php",
636
+ "cplusplus"
621
637
  ]
622
638
  },
623
639
  "file": {
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.40.9",
4
+ "version": "0.42.0",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run"