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:
# 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 injectionWhen 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.
| Flag | Abbr | Description |
|---|---|---|
--version | -v | Version constraint (e.g., ^2.4.0) |
--category | -c | Barrel file category to add the export to |
deps remove
Removes a dependency from the shared/dependencies package and cleans up all barrel file exports:
dart run monorepo_toolkit deps remove freezed_annotation| Flag | Abbr | Description |
|---|---|---|
--force | -f | Skip confirmation prompt |
deps internal
Adds one workspace package as a dependency of another. Automatically calculates the relative path between the two packages:
# Add network_sdk_api as a dependency of auth_impl
dart run monorepo_toolkit deps internal auth_impl network_sdk_apiThe 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):
# 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| Flag | Abbr | Description |
|---|---|---|
--version | -v | Version constraint |
--dev | -d | Add 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 centralizedshared/dependenciespackage.deps external-- For packages only one or two packages need (e.g.,dioinnetwork_sdk_dio).deps internal-- For wiring workspace packages together (e.g., makingauth_impldepend onauth_api).deps remove-- For cleaning up unused shared dependencies.