Skip to content
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: switch to new parser API #349

Merged
merged 16 commits into from
Aug 2, 2023

Conversation

jonaslagoni
Copy link
Member

Description
This PR is a continuum of #312, @magicmatatjahu did most of the work, I just finish the last details.

It updates the template to use the new parser API.

  • update components
  • update tests

Related issue(s)
Fixes #345

@jonaslagoni
Copy link
Member Author

The last two code-smells are not code-smells cause it's unrelated to templates as we don't re-render at any point in time. Dont know how to disable them though, think you have to manually ignore them in the platform.

@derberg
Copy link
Member

derberg commented Aug 1, 2023

@jonaslagoni you need to solve some conflicts

@jonaslagoni
Copy link
Member Author

@derberg done 👍

@derberg
Copy link
Member

derberg commented Aug 1, 2023

@jonaslagoni left one comment

regarding sonar, you manage exclusions through file like https://github.com/asyncapi/parser-js/blob/master/.sonarcloud.properties

@jonaslagoni
Copy link
Member Author

regarding sonar, you manage exclusions through file like https://github.com/asyncapi/parser-js/blob/master/.sonarcloud.properties

@derberg I stopped trying to figure out exactly what rules you need to use here to disable a single rule on a single line, it's way too complicated. Do you know what the rule should say, exactly?

@derberg
Copy link
Member

derberg commented Aug 1, 2023

@jonaslagoni haven't done it is some time but probably you need to add https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md rule with value off to https://github.com/asyncapi/markdown-template/blob/master/.eslintrc#L115 and Sonar should respect that 🤔

@jonaslagoni
Copy link
Member Author

@derberg does not seem to work no

@derberg
Copy link
Member

derberg commented Aug 2, 2023

bolox...then just add entire component to ignore for now https://github.com/asyncapi/markdown-template/blob/master/.sonarcloud.properties#L2

@jonaslagoni
Copy link
Member Author

@derberg done 👍

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found one bug, and also not sure why but:

tested with https://raw.githubusercontent.com/asyncapi/asyncapi/2.0.0/examples/2.0.0/streetlights.yml

with current template release, for message turnOnOff I do not see ` info about content type

with this PR, I get text: * Content type: [application/json](https://www.iana.org/assignments/media-types/application/json)

not sure a bug, but still curious why it shows up now 🤔


we are definitely missing snapshot tests. Maybe I will open a separate PR to add it first, so you update this PR accordingly and we see? Cause now it is manual

@@ -88,8 +91,9 @@ function Operation({ type, asyncapi, operation, channelName, channel }) { // NOS
<ListItem>
Available only on servers:{' '}
{servers.map(s => {
const slug = FormatHelpers.slugify(s);
return `[${s}](#${slug}-server)`;
const serverId = s.id();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested with https://raw.githubusercontent.com/asyncapi/asyncapi/2.0.0/examples/2.0.0/streetlights.yml

with current template release, it is now showing up, as I do not have any info on a channel level that given channel is only or production or somewhere else

with this PR, I get text: * Available only on servers: [production](#production-server) which is not true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically it's true because, without the channel explicitly defining a server, it's every server defined in servers.

Copy link
Member Author

@jonaslagoni jonaslagoni Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the parser-api's doing, because it defaults to all servers, because the channel defines none 🙂

Copy link
Member Author

@jonaslagoni jonaslagoni Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derberg question is, do you want it to be the same as before or with this new display?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but there is just one server, so sentence Available only on servers: production is only confusing, like wait are there any other servers available?. It's like with a warning on a plastic bag to not put it on your head, like why would I even try 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do it in the US 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I know 🤣 but markdown-template is not used only in the US 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, changed the implementation to only show the servers the application is operating on when it is NOT all servers 🙂

@sonarcloud
Copy link

sonarcloud bot commented Aug 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@derberg
Copy link
Member

derberg commented Aug 2, 2023

we are definitely missing snapshot tests. Maybe I will open a separate PR to add it first, so you update this PR accordingly and we see? Cause now it is manual

wdyt, do you mind to wait until I do it

@jonaslagoni
Copy link
Member Author

@derberg what exactly is missing? Full end-to-end tests?

Cause @magicmatatjahu did update the tests accordingly as well, although they are not snapshots of course.

@jonaslagoni
Copy link
Member Author

We also had a test for #349 (comment), but it was updated to expect a server, which I reverted in beebb69

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, then forget it

lgtm, thanks 🚀

@jonaslagoni
Copy link
Member Author

/rtm

@asyncapi-bot asyncapi-bot merged commit 8a43454 into asyncapi:master Aug 2, 2023
11 checks passed
@jonaslagoni jonaslagoni deleted the new-parser-js branch August 2, 2023 16:53
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 1.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to new JS parser API
4 participants