cargo-autodd

Crates.iocargo-autodd
lib.rscargo-autodd
version
sourcesrc
created_at2025-02-16 14:17:37.973746+00
updated_at2025-03-05 01:41:17.548497+00
descriptionAutomatically update dependencies in Cargo.toml
homepagehttps://github.com/nwiizo/cargo-autodd
repositoryhttps://github.com/nwiizo/cargo-autodd
max_upload_size
id1557775
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
nwiizo (nwiizo)

documentation

https://github.com/nwiizo/cargo-autodd

README

๐Ÿ“ฆ cargo-autodd

A Cargo subcommand that automatically manages dependencies in your Rust projects.

๐Ÿ” Overview

cargo-autodd simplifies Rust dependency management by automatically adding required crates to your Cargo.toml based on use statements and extern crate declarations in your code.

cargo-autodd demo

โœจ Features

  • ๐Ÿ”Ž Scans Rust source files for imports
  • ๐Ÿค– Automatically detects required dependencies
  • โฌ†๏ธ Updates Cargo.toml with the latest stable versions
  • ๐Ÿ—‘๏ธ Removes unused dependencies
  • ๐Ÿ› ๏ธ Leverages rust-analyzer for better code analysis (when available)
  • ๐Ÿงน Removes unused dependencies
  • ๐Ÿ“Š Generates dependency usage reports
  • ๐Ÿ”’ Checks for security vulnerabilities
  • ๐Ÿข Supports Cargo workspaces and monorepo structures
  • ๐Ÿ›ก๏ธ Handles internal crates with path dependencies correctly
  • ๐Ÿ› Debug mode for detailed analysis

๐Ÿ“ฅ Installation

cargo install cargo-autodd

โš™๏ธ Requirements

  • ๐Ÿฆ€ Rust 1.56.0 or later
  • ๐Ÿ“ฆ Cargo
  • ๐Ÿ”ง rust-analyzer (optional, but recommended)

๐Ÿš€ Usage

Automatic Dependency Management

# Analyze and update dependencies in the current project
cargo autodd

# Run with debug mode for detailed analysis
cargo autodd --debug
# or
cargo autodd -d

Update Dependencies

# Check and update all dependencies to their latest versions
cargo autodd update

Generate Reports

# Generate a detailed dependency usage report
cargo autodd report

Security Check

# Check for known security vulnerabilities
cargo autodd security

Monorepo Usage

# Run in the root of your workspace to analyze all crates
cargo autodd

# Run in a specific crate directory within the workspace
cd crates/my-crate
cargo autodd

When using cargo-autodd in a monorepo:

  • Internal crates with path dependencies are automatically detected
  • The tool respects publish = false settings
  • Dependencies are correctly managed across the workspace

Debug Mode

In debug mode, the following detailed information is displayed:

  • ๐Ÿ” Path of detected Rust files
  • ๐Ÿ“ Content of each line being processed
  • ๐Ÿ”Ž Detected use statements and base crate names
  • ๐Ÿ“ฆ Details of nested imports
  • ๐Ÿ”ง Detection of extern crate statements
  • ๐Ÿ“Š Analysis results of each file
  • ๐Ÿ“‹ Final list of crate references

๐Ÿ”„ How It Works

  1. ๐Ÿ“ Analyzes your Rust source files
  2. ๐Ÿ” Detects import statements and external crate declarations
  3. โšก Updates Cargo.toml with required dependencies
  4. โœ… Verifies changes with cargo check
  5. ๐Ÿ”’ Checks for security vulnerabilities using the RustSec Advisory Database
  6. ๐Ÿ“Š Generates detailed reports about dependency usage

๐Ÿข Monorepo Support

cargo-autodd fully supports Cargo workspaces and monorepo structures:

  • ๐Ÿ”„ Correctly detects and handles internal crates within a workspace
  • ๐Ÿ›ก๏ธ Respects publish = false settings for internal crates
  • ๐Ÿ”— Properly handles path dependencies in both standard and inline table formats:
    # Both formats are supported:
    internal-crate = { path = "../internal-crate" }
    
    [dependencies.another-internal-crate]
    path = "../another-internal-crate"
    
  • ๐Ÿšซ Avoids searching for internal crates on crates.io
  • ๐Ÿงฉ Works with workspace inheritance for dependency management

This ensures that your internal crates that aren't meant to be published to crates.io are handled correctly, avoiding errors like Crate 'internal_crate' not found on crates.io.

๐Ÿ‘ฅ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘ค Author

nwiizo (@nwiizo)

๐ŸŽ‰ Related Projects

Commit count: 11

cargo fmt