-
-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: create initial modelina cli #1785
Conversation
✅ Deploy Preview for modelina canceled.
|
@jonaslagoni I have generated a CLI using OCLIF. I will be working next to add some basic commands. |
@devilkiller-ag you could just copy paste the command from the AsyncAPI CLI as a baseline ✌️ |
Okay Sure I will do that 👍🏼 |
Hey @jonaslagoni, Do I need to install modelina as a dependency in modelina-cli or should I generate these generators from the build of modelina? import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, CSHARP_NEWTONSOFT_SERIALIZER_PRESET, CSHARP_COMMON_PRESET, CSHARP_JSON_SERIALIZER_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator, JAVA_CONSTRAINTS_PRESET, JAVA_JACKSON_PRESET, JAVA_COMMON_PRESET, JAVA_DESCRIPTION_PRESET } from '@modelina/generators';
import type { AbstractGenerator, AbstractFileGenerator } from '@asyncapi/modelina'; |
@devilkiller-ag I would say use dependency and use |
@jonaslagoni Okay I will do that. |
Hey @jonaslagoni, can you elaborate a little more about it? I am sorry I couldn't understand it. If we install modelina as a dependency in the |
I think you are gonna run into problems when you have to pack and build the cli if you dont use dependency, but I might be wrong 🙂 So yea, do what ever is easiest and straight forward for you now, we can easily change it |
Hey @devilkiller-ag are you stuck on anything? 🙂 |
Hi @jonaslagoni, yeah I was stuck with some type errors that I can't find why they are happening. I got busy with my class assignments before I could further investigate. I will resume working on this tomorrow. Here is the issues that I am currently facing:
In this function, when we are passing
When I checked the original code from |
I have pushed my latest code for your review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments, hope it unblocks you ✌️
Looks like you are nearly there 💪
Hey @jonaslagoni, I made the changes you suggested, can you please checkout the code? |
This reverts commit ef7038b6d873b4e6cb6dc245908648787530f27b.
@jonaslagoni Do I need to add tests for cli? |
Pull Request Test Coverage Report for Build 8081649738Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
I have disabled some eslit rules as they were asking unnecessary changes in existing code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to add the modelina-cli
to the list in the root .eslintignore
otherwise it will try to run it there without the proper plugins.
Otherwise it looks fine to me 👌 Lets focus on getting a bare minimum working CLI here first and then we can experiment with embedding it into the AsyncAPI CLI 🙂
Hi @jonaslagoni, can you please review this PR? |
@jonaslagoni Do I need to resolve sonar cloud code duplication check fail?This check was passing before the merge from the master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got some small changes that is needed to set this up better for release and running it locally. Basically just grabbing all the good stuff from the AsyncAPI CLI, no need to reinvent the wheel ✌️
- Grab all the files in https://github.com/asyncapi/cli/tree/master/bin
- Grab the following script: https://github.com/asyncapi/cli/blob/master/scripts/releasePackagesRename.js
- Grab the following script: https://github.com/asyncapi/cli/blob/master/scripts/updateUsageDocs.js
- Adapt the files which has suggestions
- Grab the AsyncAPI CLI testing setup: https://github.com/asyncapi/cli/blob/master/test/
- Take the Modelina test which can be found here (make sure to grab all related testing files): https://github.com/asyncapi/cli/blob/master/test/integration/generate/models.test.ts
No, completely ignore the sonarcloud ✌️ |
|
||
if (output) { | ||
const models = await fileGenerator.generateToFiles( | ||
document, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jonaslagoni,
What should I pass in place of document
here (Line no. 387 & 396):
const models = await fileGenerator.generateToFiles(
document,
output,
{ ...fileOptions, });
In Async API CLI, document
was generated by the parser as
// Ref: Line no. 177-187 -> https://github.com/asyncapi/cli/blob/master/src/commands/generate/models.ts
const { document, diagnostics ,status } = await parse(this, inputFile, flags);
if (!document || status === 'invalid') {
const severityErrors = diagnostics.filter((obj) => obj.severity === 0);
this.log(`Input is not a correct AsyncAPI document so it cannot be processed.${formatOutput(severityErrors,'stylish','error')}`);
return;
}
// Modelina, atm, is not using @asyncapi/parser@v3.x but @asyncapi/parser@v2.x, so it still uses Parser-API v1.0.0.
// 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)
// This is needed until https://github.com/asyncapi/modelina/issues/1493 gets fixed.
const convertedDoc = ConvertDocumentParserAPIVersion(document.json(), 1);
And this convertedDoc
was passed here in place of document
:
const models = await fileGenerator.generateToFiles(
convertedDoc as any,
output,
{ ...fileOptions, });
But here we have removed the parser, so what should we use in place of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The content of the file in question as a string 🙂
Quality Gate failedFailed conditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nearly there 💪
@@ -0,0 +1,3 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add this to ignore list 🙂
@@ -0,0 +1,19 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the entire minitemplate directory 🙂
@@ -0,0 +1,102 @@ | |||
import { expect, test } from '@oclif/test'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these non existing commands can just be removed completely 🙂 Only need the Modelina test and generic tests for context ✌️
@devilkiller-ag as we discussed, I created a specific branch we can slowly work on, a bunch of good stuff in this PR so let's merge what we have, and I can do a little bit of cleanup 💪 |
@devilkiller-ag do you mind creating a draft PR that targets master from the |
Okay sure |
Description
Create a CLI for Modelina and integrate it with AsyncAPI CLI
Related Issue
Related to issue #1724
Checklist
npm run lint
).npm run test
).