cli icon indicating copy to clipboard operation
cli copied to clipboard

feat: integrate asyncapi optimize library using the optimize command

Open alceil opened this issue 3 years ago • 9 comments

Description

This PR integrates the asyncapi-optimize library using the optimize command.

At the moment, the command looks something like this.

asyncapi optimize <context/filepath/url>

And it has flag: --format which determines the show the report or not.

Related issue(s) Fixes #218

alceil avatar Mar 11 '22 04:03 alceil

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
No Duplication information No Duplication information

sonarqubecloud[bot] avatar Mar 11 '22 04:03 sonarqubecloud[bot]

Thanks, @alceil looks great. just some inputs from my side:

when I use the optimize command, I expect it to show me the changes that are going to be applied and I should be able to chose between those changes.

this is the flow that I expect to go through:

# asyncapi optimize document.yml
Here is a list of optimizations that can be done on document.yml:

Remove the following components:
 - components.messages.foo
 - components.schemas.bar
...
 
Reuse the following components:
 - components.schemas.foo in channels.someMessge.publish.message.payload
 - components.schemas.bar in channels.someMessge.publish.message.payload
...

Move the following components to the components section:
 - channels.foo.publish.message to channels.someMessge.publish.message.payload
 - channels.foo.subscribe.headers[0] to components.schemas.schema_1
...

Select your desired optimization to be applied:
   Delete Components
   Remove Components
   Reuse Components
> All of them

select your desired output:
   Update the current file
> Create document_optimized.yml (Recommended)
   Log to console

document_optimized.yml has been created!

we definitely need some input about the UX from others here. cc: @derberg @magicmatatjahu @Souvikns

KhudaDad414 avatar Mar 11 '22 08:03 KhudaDad414

Can I also get some inputs on the Ux as well. @KhudaDad414 . Im pretty new to this so I need some pointers as well on how to approach it

alceil avatar Mar 12 '22 06:03 alceil

from the UX perspective we need to support 2 ways of doing things:

  • interactivity, step by step guiding user. As shown by @KhudaDad414, that you show what can be optimized and user can select what changes should be applied
  • flags to skip interactivity in case CLI is used on a CI/CD. So user should be able to specify with flags desired out come + should be powered by defaults. So for example, default should be that if --no-tty is passed document is optimized, but the result is logged to terminal, and you can as alternative specify --override or --output flags to save optimized document into file.

does it make sense?

derberg avatar Mar 14 '22 12:03 derberg

Okay got it @derberg

alceil avatar Mar 17 '22 03:03 alceil

@alceil do you plan to continue working on it? Open Force ended but since you started during the event, it is ok if you complete work later

derberg avatar Apr 04 '22 16:04 derberg

Sure i wish to complete it .

alceil avatar Apr 04 '22 16:04 alceil

Can I also get some inputs on the Ux as well. @KhudaDad414 . Im pretty new to this so I need some pointers as well on how to approach it

@alceil for UX, we are following CLIG, as mentioned in readme.

As @KhudaDad414 mentioned, @alceil . I guess you are working on it, feel free if you feeling stuck anywhere. An idea that you can think for the implementation is using a stepper design.

  1. First step is to just look on the optimizations possible and show users a list of possible optimizations in tabular format(more readable way).

  2. Second step is to let the user choose from the given four options, reuse, remove, move, and All of them

  3. Third step is to ask the updated file preferences with these options Update the current file, Create document_optimized.yml (Recommended) and Log to console

imabp avatar Apr 20 '22 05:04 imabp

@alceil hey, this PR is opened for some time already, maybe we should close and you create new when ready?

derberg avatar Jul 05 '22 08:07 derberg

This pull request has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation.

There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this pull request forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar Nov 03 '22 00:11 github-actions[bot]

@KhudaDad414 hey, looks like oryginal contributor do not plan to continue with this one. Did you plan to integrate optimizer here in the CLI?

derberg avatar Nov 17 '22 15:11 derberg

I am putting it on my to-do list. thanks for reminding @derberg.

KhudaDad414 avatar Nov 17 '22 15:11 KhudaDad414

I guess we should close this PR in favour of https://github.com/asyncapi/cli/pull/397

KhudaDad414 avatar Nov 21 '22 16:11 KhudaDad414

closing since @alceil is no longer active here and @KhudaDad414 opened new PR

derberg avatar Nov 22 '22 09:11 derberg