mg is a cross-ecosystem package management tool that supports multiple package managers (such as cargo, npm, pnpm, yarn, pip, pdm, and poetry), providing a unified command-line interface. By automatically detecting project types, mg intelligently invokes the corresponding package manager, simplifying package management operations in cross-language development.
- Cross-ecosystem support: Supports package managers for ecosystems like Rust, Node.js, and Python.
- Automatic project type detection: Automatically selects the package manager based on project files (e.g., Cargo.toml, package.json, pyproject.toml, etc.).
- Unified command interface: Provides unified commands such as add, remove, upgrade, and analyze.
- Dynamic parameter support: Allows passing arbitrary package manager parameters and supports native command formats.
- Colored output: Uses colored terminal output to enhance readability.
cargo install mg
# Clone the repository
git clone https://github.com/mcgeq/mg.git
cd mg
# Build and install
cargo install --path .
# Add a package
mg add <package> [options]
# Remove a package
mg remove <package> [options]
# Upgrade a package
mg upgrade <package> [options]
# Analyze dependencies
mg analyze [package] [options]
mg add serde -F derive
# Equivalent to: cargo add serde --features derive
mg remove serde
# Equivalent to: cargo remove serde
mg upgrade serde
# Equivalent to: cargo upgrade serde
mg analyze
# Equivalent to: cargo tree
mg add lodash -D
# Equivalent to: npm install lodash --save-dev
mg remove lodash
# Equivalent to: npm uninstall lodash
mg upgrade lodash
# Equivalent to: npm update lodash
mg analyze --depth=0
# Equivalent to: npm list --depth=0
mg add requests -G dev
# Equivalent to: poetry add requests --group dev
mg upgrade requests
# Equivalent to: poetry update requests
mg analyze requests
# Equivalent to: poetry show requests
Package Manager | Supported Commands | Detection Files |
---|---|---|
Cargo | add,remove,upgrade,analyze | Cargo.toml |
npm | add,remove,upgrade,analyze | package.json, package-lock.json |
pnpm | add,remove,upgrade,analyze | pnpm-lock.yaml |
yarn | add,remove,upgrade,analyze | yarn.lock |
pip | add,remove,upgrade,analyze | requirements.txt |
pdm | add,remove,upgrade,analyze | pdm.lock, pyproject.toml |
poetry | add,remove,upgrade,analyze | pyproject.toml |
mg supports passing arbitrary package manager parameters, and all parameters are directly passed to the underlying package manager.
# Cargo
mg add serde -F derive --no-default-features
# Equivalent to: cargo add serde --features derive --no-default-features
# npm
mg add react --legacy-peer-deps
# Equivalent to: npm install react --legacy-peer-deps
# Poetry
mg add pytest -G dev --extras coverage
# Equivalent to: poetry add pytest --group dev --extras coverage
mg uses colored terminal output to enhance readability:
- Package manager name: Cyan
- Executed command: Yellow
- Success message: Green
- Dependency analysis title: Cyan
$ mg add serde
Using cargo package manager
Executing: cargo add serde
✓ Packages added successfully
This project is open-sourced under the MIT License.
If you encounter any issues or have suggestions, please submit an Issue or contact via email: [email protected].
Thanks to the following open-source projects for their support:
- clap: Command-line argument parsing library.
- colored: Colored terminal output library.
- anyhow: Error handling library.
Happy coding with mg! 🚀