feat: integrate asyncapi diff library using the diff command#135
Conversation
There was a problem hiding this comment.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
derberg
left a comment
There was a problem hiding this comment.
Awesome to see it comming!
Please have a look at some possible improvements to developer experience
|
Thanks for the reviews. Will make the changes ASAP. |
16323b5 to
f0eb835
Compare
|
@aayushmau5 hey, tests are failing because of linter. |
|
Yeah, confused as to why this is happening. Let me check if this has something to do with the context I'm setting in the tests. |
|
@aayushmau5 you need a hand? or two? 😄 |
|
Yeah 😅 Not sure why the test fails in windows even though I have not used any context in the tests for diff command 😕 |
|
looking at logs super strange that it is happening right now, they had to do some updates to VM or something. The problem is I have no idea how to solve it, other than adding a NODE_ENV that you can use in tests to override default context location. This way you could provide location that can be easily modified by the workflow. @Souvikns @boyney123 @magicmatatjahu thoughts? to summarize, I'm thinking about modifying these 3 lines -> https://github.com/asyncapi/cli/blob/master/src/models/Context.ts#L8-L10 with something like and then just update |
we have this so that while testing we don't overwrite the global config file. I think we should just check if it is test env then we should choose maybe something like this |
|
@Souvikns the thing is that we should have no test-related logic in library, this is why I propose that we have all customizable and we just override it in the |
Oh now I get it, yeah that would be better |
|
@aayushmau5 your test still runs outside |
Oops, I don't think we have discussed this 🤔 . I completely forgot about passing custom standard. What flag should we go with? Also, I'm assuming this file will be a json file(or we should treat it as such)? |
|
yeah, just enable what API of the diff library allows you to do. So definitely a json file, and I think |
| async function readOverrideFile(path: string): Promise<diff.OverrideObject> { | ||
| const overrideStringData = await readFile(path, { encoding: 'utf8' }); | ||
| return JSON.parse(overrideStringData); | ||
| } |
There was a problem hiding this comment.
Not sure where to put this function.
There was a problem hiding this comment.
imho it is fine if it just stays here, just add js doc
most important is to have proper error handling, awaits should be wrapped in try/catch and we need test, what error goes out when user passed path to not existing file and what error goes out when user passed path to not json file and JSON.parse fails
|
@derberg It seems adding tests like results in the tests passing no more whether it really fails or not. But seems to work fine. Found this bug when trying to test an error, but the test passed for the wrong error. |
|
@aayushmau5 yes, go ahead with |
…i-diff-integration
|
Kudos, SonarCloud Quality Gate passed!
|
|
@aayushmau5 lgtm 🚀 I guess I can merge, right? |
|
Yes! 🚀 |
|
/rtm |
|
🎉 This PR is included in version 0.13.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |









Description
This PR integrates the
asyncapi-dfflibrary using thediffcommand.At the moment, the command looks something like this.
And it has two flags:
--format(default and only acceptable right now value:json) which determines the format of the output.--type(all(default) ,breaking,non-breaking,unclassified) which determines the type of the output we want.At the moment, the output is being logged to
stdout. The support for outputting data into files is to be added(which is most likely to be done by me, whether in this PR or another one depends on the review :) ).Related issue(s)
See #58