Giter VIP home page Giter VIP logo

cargo-dependency-inheritor's Introduction

Cargo Workspace Dependency Inheritor

Utility that inherits dependencies from the main workspace if they occur n or more times in the workspace.

Workspace Inheritance was stabilized in version 1.64. See [workspace.package], [workspace.dependencies], and inheriting-a-dependency-from-a-workspace for more information.

How to Use

To inherit a dependency that occurs five or more times in the workspace, use the following command:

cargo install cargo-dependency-inheritor
cargo dependency-inheritor --workspace-path "path/to/workspace/Cargo.toml" -n 5

This command edits your toml files, make sure to have a back up

Process

Dependencies can be inherited from a workspace by specifying the dependency in the workspace's [workspace.dependencies] table. After that, add it to the [dependencies] table with workspace = true. This crate automates the process.

  1. Read packages defined in [workspace] section of the workspace-file.
  2. Note which dependencies occur n or more times.
  3. Update all dependencies that occurred n or more times:
    1. Turn dependency = "0.1.3" into inline tables.
    2. Add workspace = true key-value to the dependency inline table.
    3. Remove version from inline table if exists (this will be specified in the workspace file).
  4. Add [workspace.dependencies] table to root workspace file with all the dependencies that occurred n times and their version.

Result:

# in a project
[dependencies]
tokio = { workspace = true }

# in the workspace
[workspace.dependencies]
tokio = "1.0"

cargo-dependency-inheritor's People

Contributors

marijns95 avatar timonpost avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

marijns95

cargo-dependency-inheritor's Issues

Path dependencies shouldn't specify a version

Currently dependencies with a path attribute are also specifying a version when auto generated, i.e. version = "*". It's better to omit this, the only restriction it adds is that it prevents you from using pre-release versions of a crate that you have vendored in. This can result in the path attribute being ignored, leading to some very confusing builds.

Add license

Should add a license to the repo (not just the crate Cargo.toml), would recommend Rust standard MIT OR Apache-2.0 over only MIT

git dependency data lost

before:

dep = { git = "https://github.com/org/repo", rev = "longhexstring" }

after:

dep = "*"

Needless to say, this doesn't work :)

dependency registry is discarded

I have some dependencies which use a different registry.

e.g.

foobar = { version = "=0.20.1", registry = "my-private-registry" }

Running cargo-dependency-inheritor causes them to be deleted.

Update dev-dependencies

I think dev-dependencies are ignored in the released version on crates.io , but installing from git fixes that.

cargo subcommand doesn't invoke this program correctly

$ cargo +beta dependency-inherit -n 2
error: no such subcommand: `dependency-inherit`

        Did you mean `dependency-inheritor`?

        View all installed commands with `cargo --list`

$ cargo +beta dependency-inheritor -n 2
error: The subcommand 'dependency-inheritor' wasn't recognized

        Did you mean 'dependency-inherit'?

If you believe you received this message in error, try re-running with 'cargo -- dependency-inheritor'

USAGE:
    cargo <SUBCOMMAND>

For more information try --help

$ cargo +beta --version
cargo 1.65.0-beta.1 (082503982 2022-09-13)

System is Windows 11 with MSVC target.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.