Skip to content

Dependency Manager

The deps command manages dependencies in the monorepo workspace. It handles adding and removing packages from the centralized shared/dependencies package, wiring internal workspace packages together, and adding external pub.dev packages to specific packages.

Subcommands

deps add

Adds a pub.dev dependency to the shared/dependencies package and optionally registers it in a barrel file for re-export:

bash
# Add a package to shared/dependencies
dart run monorepo_toolkit deps add freezed_annotation

# With a version constraint
dart run monorepo_toolkit deps add freezed_annotation -v "^2.4.0"

# Add to a specific barrel file category
dart run monorepo_toolkit deps add get_it -v "^7.6.0" -c injection

When a category is specified, the package export is added to the corresponding barrel file (e.g., lib/injection.dart). If the barrel file does not exist, it is created automatically.

FlagAbbrDescription
--version-vVersion constraint (e.g., ^2.4.0)
--category-cBarrel file category to add the export to

deps remove

Removes a dependency from the shared/dependencies package and cleans up all barrel file exports:

bash
dart run monorepo_toolkit deps remove freezed_annotation
FlagAbbrDescription
--force-fSkip confirmation prompt

deps internal

Adds one workspace package as a dependency of another. Automatically calculates the relative path between the two packages:

bash
# Add network_sdk_api as a dependency of auth_impl
dart run monorepo_toolkit deps internal auth_impl network_sdk_api

The first argument is the source package (the one that needs the dependency), and the second is the target package (the one being depended on).

deps external

Adds a pub.dev dependency directly to a specific internal package (not to shared/dependencies):

bash
# Add dio to network_sdk_dio
dart run monorepo_toolkit deps external network_sdk_dio dio "^5.4.0"

# Add as a dev dependency
dart run monorepo_toolkit deps external auth_impl mockito -v "^5.4.0" --dev
FlagAbbrDescription
--version-vVersion constraint
--dev-dAdd as a dev dependency instead of a regular dependency

When to use each subcommand

  • deps add -- For packages that many features share (GetIt, injectable, auto_route). These go into the centralized shared/dependencies package.
  • deps external -- For packages only one or two packages need (e.g., dio in network_sdk_dio).
  • deps internal -- For wiring workspace packages together (e.g., making auth_impl depend on auth_api).
  • deps remove -- For cleaning up unused shared dependencies.

Built by Banua Coder