Workiva / dependency_validator

A tool to help you find missing, under-promoted, over-promoted, and unused dependencies.
Other
59 stars 18 forks source link

Support for mono repo #119

Open SAGARSURI opened 6 months ago

SAGARSURI commented 6 months ago

Hey, I have a mono-repo setup with around 100+ local packages. Can you provide a solution on how to have a single dart_dependency_validator.yaml across the project?

devilbuddy commented 5 months ago

Just being able to pass exclude/ignore on command line instead of via per-package yaml configuration would go a long way.

matthewnitschke-wk commented 5 months ago

Configuring options via cli args seems like a good solution to this, but I can't commit to any timeline on when this could be implemented. I'd be happy to review something if you'd like to take a stab at what that would look like

One immediate workaround could be to symlink to a root dart_dependency_validator.yaml file from within each of the nested local packages. That way updates to the root, would automatically be reflected in each of the nested packages

renefloor commented 2 months ago

I wonder if there is any plan to support dart workspaces

It's still quite early, but I expect this to become the standard for mono-repos very soon. Current Flutter stable already supports dart packages and I expect the next stable to support flutter packages as well.

When creating a workspace you add a pubspec.yaml in the root of a mono repo. In the pubspec.yaml of the package you add resolution: workspace to indicate the dependency resolution should happen on the workspace level instead of the package level. The result is that the package won't have a pubspec.lock file or a separate analyzer context.

When running the dependency_validator in a workspace package you will get the following error:

No .dart_tool/package_config.json file found, please run "pub get" first.

That's because the .dart_tool folder is missing some files

image

The workspace_ref.json indicates the root of the workspace.

The dependency_validator should validate how you define dependencies on the workspace level, for example if you allow pinned dependencies, but it should still validate unused/missing and under/over promoted dependencies on the package level.