composer-changelogs icon indicating copy to clipboard operation
composer-changelogs copied to clipboard

Add option to output to Markdown table

Open peterjaap opened this issue 4 years ago • 7 comments

We use Gitlab instead of Github, and Gitlab uses markdown for issues. It would be great to have an option to have the output of this plugin generated as a Markdown table, so we can copy/paste it into an issue.

peterjaap avatar Nov 10 '20 13:11 peterjaap

Hello, thanks for your suggestion.

I like the idea, I don't think implementing it would be too complicated. We could either change the default output or just add an option to allow the choice of the desired output.

Would you like to give it a try?

pyrech avatar Nov 10 '20 14:11 pyrech

Changing the default output to a Markdown table wouldn't look pretty in the console. So I'm in favor of adding an option, although I'm not sure how to pass that option to the plugin without having to pass a flag everytime.

peterjaap avatar Nov 10 '20 14:11 peterjaap

Indeed, let's have another optional table output instead :+1: Speaking of it, which columns do you need? It would be better to have the same columns for the three operations (install, update, uninstall).

About the architecture, I think we could add support for a new option in the plugin section of the composer.json. See this documentation to have a look at the existing config supported by this plugin with the ConfigBuilder and the related Config DTO.

I guess we could add an OutputFormatter interface with 2 implementations (current formatting and table). Then, according to the new config option, we would pass the correct implementation to the OutputFormatter / getOutput method of OperationHandler classes.

Does this sounds good to you?

pyrech avatar Nov 10 '20 15:11 pyrech

Yes, sounds good!

The table columns would preferably be package name, previous version, current version, release notes link, compare link. So something like this; https://github.com/davidrjonas/composer-lock-diff#example-plain-text-table-output

peterjaap avatar Nov 10 '20 15:11 peterjaap

@pyrech come to think of it, your suggestion would mean I'd have to edit the composer.json file in every project I'd like to see a table output, which in our case is a lot (we run an agency). Isn't there a way to store parameters like this somewhere in composer's global scope, like in a file somewhere? I'd rather not touch the repositories themselves.

peterjaap avatar Nov 10 '20 15:11 peterjaap

Yes, that is supported :slightly_smiling_face:. The plugin configuration can also be set in your global location (usually in ~/.composer/composer.json) :wink:. See https://github.com/pyrech/composer-changelogs/blob/master/doc/configuration.md#location

pyrech avatar Nov 10 '20 15:11 pyrech

@pyrech of course, forgot about that one. Perfect!

peterjaap avatar Nov 10 '20 16:11 peterjaap