dmu 1.1.0
dmu: ^1.1.0 copied to clipboard
A command-line tool to manage Git dependencies as local packages in Dart/Flutter projects. Streamline your multi-repo development workflow.
DMU - Dart Multi-Repo Utility #
A powerful command-line tool to streamline local development of Git dependencies in Dart and Flutter projects. DMU makes it easy to clone, manage, and override dependencies for debugging and feature development.
🚀 Features #
- 🔧 Local Development: Clone Git dependencies locally for easier debugging and development
- ⚡ Automatic Override: Automatically configure
dependency_overridesin pubspec.yaml - 📦 Multi-Package Support: Manage dependencies across multiple packages in your workspace
- 🎯 FVM Compatible: Automatically detects and uses FVM if
.fvmrcis present - ✨ Clean & Simple: Intuitive commands with helpful error messages
- 🔄 Workspace Management: Run pub get on all packages in your project with a single command
📦 Installation #
Install DMU globally using pub:
dart pub global activate dmu
Make sure to add the pub cache bin directory to your PATH:
# Add this to your ~/.zshrc or ~/.bashrc
export PATH="$PATH:$HOME/.pub-cache/bin"
Shell Completion (Optional) #
DMU supports tab-completion for package names in both zsh and bash.
Quick Install (Recommended)
If you have the repository cloned:
cd /path/to/dmu/completions
./install-completions.sh
The script will automatically detect your shell and configure completions.
Manual Setup
Click to expand manual installation instructions
Zsh Setup
- Install the completion script:
# Create completions directory if it doesn't exist
mkdir -p ~/.zsh/completions
# Copy the completion script
curl -o ~/.zsh/completions/_dmu https://raw.githubusercontent.com/pretodev/dmu/main/completions/_dmu
# Or if you have the repo cloned:
cp /path/to/dmu/completions/_dmu ~/.zsh/completions/
- Add completions directory to fpath in your ~/.zshrc:
# Add this to your ~/.zshrc before compinit
fpath=(~/.zsh/completions $fpath)
- Reload your shell configuration:
# Remove cached completions and reload
rm -f ~/.zcompdump
exec zsh
Bash Setup
- Install the completion script:
# Download the completion script
curl -o ~/.dmu-completion.bash https://raw.githubusercontent.com/pretodev/dmu/main/completions/dmu-completion.bash
# Or if you have the repo cloned:
cp /path/to/dmu/completions/dmu-completion.bash ~/.dmu-completion.bash
- Add to your ~/.bashrc:
# Add this to your ~/.bashrc
source ~/.dmu-completion.bash
- Reload your shell configuration:
source ~/.bashrc
Using Tab-Completion
Now you can use tab-completion:
dmu add <TAB>- Lists all Git dependencies that can be addeddmu remove <TAB>- Lists all packages currently in dependency_overridesdmu add my_pack<TAB>- Auto-completes package names starting with "my_pack"
🎯 Usage #
Add a Package #
Clone a Git dependency locally and set it up for local development:
dmu add <package-name> [--path <directory>]
Options:
--path: Directory where package will be cloned (default:packages)
Example:
dmu add my_package
dmu add my_package --path libs
What it does:
- Verifies package exists in dependencies as Git repo
- Clones repository to specified path
- Adds
dependency_overrideto pubspec.yaml - Runs flutter clean && flutter pub get
- Updates .gitignore to exclude packages directory
Remove a Package #
Remove local override and delete the cloned package:
dmu remove <package-name>
Example:
dmu remove my_package
What it does:
- Verifies package is in dependency_overrides
- Removes override from pubspec.yaml
- Deletes local package directory
- Runs flutter clean && flutter pub get
⚠️ Warning: Uncommitted changes in the local package will be lost!
Download Dependencies #
Run pub get on all Dart/Flutter packages in the project:
dmu pub-get
Requirements:
fdcommand-line tool must be installed- macOS:
brew install fd - Linux:
apt install fd-find
- macOS:
What it does:
- Searches for all pubspec.yaml files in the project
- Runs flutter pub get (or dart pub get) on each package
- Uses fvm flutter if .fvmrc file is detected
Clean Build Artifacts #
Clean build artifacts and caches from all packages:
dmu clean [--deep]
Options:
-d, --deep: Also removes pubspec.lock files for complete dependency resolution reset
Examples:
dmu clean # Standard clean
dmu clean --deep # Deep clean with lock file removal
What it does:
- Standard clean: Runs flutter clean on all packages
- Deep clean: Also removes all pubspec.lock files
📋 Requirements #
- Dart SDK 3.9.0 or higher
- Git (for cloning repositories)
fdtool (for pub-get and clean commands)- Install on macOS:
brew install fd - Install on Linux:
apt install fd-find
- Install on macOS:
🌐 Supported Git Providers #
DMU supports multiple Git hosting providers with automatic SSH URL conversion:
- GitHub -
https://github.com/owner/repo.git - GitLab -
https://gitlab.com/owner/repo.git(including self-hosted) - Bitbucket -
https://bitbucket.org/owner/repo.git - Azure DevOps -
https://dev.azure.com/org/project/_git/repo - Gitea -
https://gitea.example.com/owner/repo.git - Generic Git - Any standard Git hosting provider
How It Works #
When cloning repositories, DMU:
- Attempts to clone using SSH (converted from HTTPS URL)
- Falls back to HTTPS if SSH fails (e.g., no SSH keys configured)
This ensures maximum compatibility regardless of your Git configuration.
See lib/src/git/README.md for detailed information about URL conversion and adding custom providers.
🔧 How It Works #
DMU simplifies the workflow of developing multiple interconnected Dart/Flutter packages:
- Normal Setup: Your packages use Git URLs in dependencies
- Local Development: Use
dmu addto work on packages locally - Override Management: DMU manages dependency_overrides automatically
- Clean Integration: Packages directory is automatically added to .gitignore
Example pubspec.yaml #
Before:
dependencies:
my_package:
git:
url: https://github.com/user/my_package.git
ref: main
After dmu add my_package:
dependencies:
my_package:
git:
url: https://github.com/user/my_package.git
ref: main
dependency_overrides:
my_package:
path: packages/my_package
🆘 Getting Help #
For general help:
dmu --help
For command-specific help:
dmu <command> --help
Examples:
dmu add --help
dmu remove --help
dmu pub-get --help
dmu clean --help
� License #
MIT License - see LICENSE file for details.
🤝 Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
📚 Additional Resources #
💡 Use Cases #
Multi-Package Workspace Development #
Perfect for teams working on multiple interconnected packages where you need to test changes across packages before publishing.
Package Development & Testing #
Ideal for package authors who need to test their packages in real-world applications before releasing new versions.
Debugging Dependencies #
Makes it easy to dive into dependency source code, add debug prints, and understand issues without forking repositories.