dart-code-metrics icon indicating copy to clipboard operation
dart-code-metrics copied to clipboard

[FEATURE REQUEST] Export CliRunner

Open ookami-kb opened this issue 4 years ago • 6 comments

It would be useful to have CliRunner exported.

Use case

We have a package where we customize analyzer rules to share the settings across our products. Recently we've added dart_code_metrics as a dependency to share its configuration as well. The only problem so far is that we cannot use the CLI analyzer because of the restriction "Cannot run executables in transitive dependencies".

Exporting CliRunner would allow creating an executable in our package and proxy all the calls to CliRunner.

ookami-kb avatar Sep 14 '21 11:09 ookami-kb

@ookami-kb could you share, why you don't want to call dart_code_metrics executable in target packages directly?

incendial avatar Sep 15 '21 17:09 incendial

@incendial we add dependency for dart_code_metrics to our mews_pedantic package. It means that for our product apps (they depend on mews_pedantic) dart_code_metrics is a transitive dependency. It means that in this product app I cannot just run flutter pub run dart_code_metrics:metrics lib since it will give an error: "Cannot run executables in transitive dependencies".

ookami-kb avatar Sep 15 '21 19:09 ookami-kb

Ah, I see, thanks. Have you tried global activate or it's less convenient for you? I'm asking, because I think we should avoid exporting CliRunner since it's more like our internal implementation and it's better to avoid a situation when we'll need to create major package updates to update it.

incendial avatar Sep 16 '21 08:09 incendial

Yeah, it's less convenient since:

  • We cannot enforce some specific package version if needed;
  • We need another step in CI pipeline.

But I can understand your point as well.

ookami-kb avatar Sep 16 '21 09:09 ookami-kb

I've checked Dart SDK repo and it looks like this limitation for execution of transitive dependencies is intentional: https://github.com/dart-lang/sdk/issues/23426

How do you solve this problem right now? Maybe you can start with src imports and see how it goes?

incendial avatar Sep 20 '21 15:09 incendial

Maybe you can start with src imports and see how it goes?

Yes, it's exactly what I did for now.

ookami-kb avatar Sep 20 '21 15:09 ookami-kb

@ookami-kb cli runner will become a part of public API. It's occurred, that this use-case is pretty common, so we'll support it officially

incendial avatar Oct 16 '22 10:10 incendial

Available in 5.0.0 🚀

incendial avatar Oct 31 '22 19:10 incendial