redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

Drop `--remove-unused-components` bundle parameter in favour of equivalent decorator

Open lornajane opened this issue 2 years ago • 6 comments

Is your feature request related to a problem? Please describe.

We have a few decorators that help with API description quality checks, including https://redocly.com/docs/cli/decorators/remove-unused-components/. However for only this one decorator, we also have a parameter to the bundle command --remove-unused-components. Users might expect other transforms to be available here, when it would be better for these to be managed as decorators, as all the others are.

Describe the solution you'd like

Drop this parameter and replace it with a prompt to enable the decorator to do the same thing instead.

Describe alternatives you've considered

Leave it as it is - I assume we had the bundle command parameter first!

Additional context

The parameter isn't widely used, so only a minority of users would be affected.

lornajane avatar Nov 09 '23 14:11 lornajane

I'm for it. The current behaviour has some implications in the code, which I stumbled upon the other day, and it was hard to figure out what it was about.

tatomyr avatar Nov 10 '23 14:11 tatomyr

I suggested the decorator originally, and my suggested was considered not viable -- they said it had to be the separate flag because of the order in which they run is critical (it has to run last if I recall). @tatomyr pretty sure you were involved in that conversation.

original issue: https://github.com/Redocly/redocly-cli/issues/945

adamaltman avatar Nov 10 '23 14:11 adamaltman

@adamaltman I see. We actually can use the decorator instead of the option (we do put this specific decorator the last in the code no matter is it an option or it comes from the config), so I suppose we can try dropping the option for consistency.

tatomyr avatar Nov 10 '23 14:11 tatomyr

I just tried to use this decorator as the only decorator in a bundle operation, and it did nothing. Bundling with --remove-unused-components did change the file. So I think we need to look at whether this can work as a decorator or not! (the file I was using is attached). unused-components.zip

lornajane avatar Dec 14 '23 15:12 lornajane

@lornajane are you sure it did nothing? I configured redocly.yaml the following way and it removed 15 unused components:

decorators: 
  remove-unused-components: {}

The same result I got using the command line option.

tatomyr avatar Dec 27 '23 13:12 tatomyr

Might be related: https://github.com/Redocly/redocly-cli/issues/1391

tatomyr avatar Jan 12 '24 09:01 tatomyr