41 个版本 (14 个破坏性更新)

0.15.0 2024 年 2 月 26 日
0.14.0 2023 年 11 月 2 日
0.13.1 2023 年 6 月 19 日
0.11.2 2023 年 1 月 22 日
0.1.3 2015 年 11 月 14 日

#9Cargo 插件

Download history 2647/week @ 2024-04-25 2498/week @ 2024-05-02 2328/week @ 2024-05-09 2438/week @ 2024-05-16 2324/week @ 2024-05-23 2558/week @ 2024-05-30 2954/week @ 2024-06-06 2425/week @ 2024-06-13 2289/week @ 2024-06-20 2238/week @ 2024-06-27 2235/week @ 2024-07-04 2137/week @ 2024-07-11 2438/week @ 2024-07-18 2366/week @ 2024-07-25 2365/week @ 2024-08-01 1886/week @ 2024-08-08

9,436 每月下载量

MIT 许可证

84KB
1.5K SLoC

cargo-outdated

加入聊天 https://gitter.im/kbknapp/cargo-outdated crates.io Linux: 构建状态

Cargo 子命令,用于显示 Rust 依赖何时过时

关于

cargo-outdated 用于显示依赖项何时有可用的新版本。

工作原理

cargo-outdated 的功能在很大程度上依赖于 cargo 内置命令 cargo update

要检索可用 SemVer 兼容依赖项的列表,cargo-outdated 首先创建一个临时工作空间,然后对其执行 cargo update,最后将临时依赖树与原始依赖树进行比较。

同样,要检查最新的依赖项,cargo-outdated 将直接依赖项的 SemVer 要求替换为通配符,然后执行相同的流程。

演示

一旦安装(见下文),在项目目录中运行 cargo outdated 的样子如下

$ cargo outdated
Name             Project  Compat  Latest   Kind         Platform
----             -------  ------  ------   ----         --------
clap             2.20.0   2.20.5  2.26.0   Normal       ---
clap->bitflags   0.7.0    ---     0.9.1    Normal       ---
clap->libc       0.2.18   0.2.29  Removed  Normal       ---
clap->term_size  0.2.1    0.2.3   0.3.0    Normal       ---
clap->vec_map    0.6.0    ---     0.8.0    Normal       ---
num_cpus         1.6.0    ---     1.6.2    Development  ---
num_cpus->libc   0.2.18   0.2.29  0.2.29   Normal       ---
pkg-config       0.3.8    0.3.9   0.3.9    Build        ---
term             0.4.5    ---     0.4.6    Normal       ---
term_size->libc  0.2.18   0.2.29  0.2.29   Normal       cfg(not(target_os = "windows"))

安装

Packaging status

最新版本的 cargo-outdated 可以使用以下命令安装或更新:cargo install

cargo install --locked cargo-outdated

或者

cargo install --locked --git https://github.com/kbknapp/cargo-outdated

编译

按照以下说明编译 cargo-outdated,然后跳到安装部分。

  1. 请确保您已安装当前版本的 cargoRust
  2. 克隆项目 $ git clone https://github.com/kbknapp/cargo-outdated && cd cargo-outdated
  3. 构建项目 $ cargo build --release
  4. 构建完成后,二进制文件将位于 target/release/cargo-outdated

安装和使用

您只需将 cargo-outdated 放置在您的 $PATH 变量的某个位置。然后在您的项目目录中的任何位置运行 cargo outdated。详细信息请见下文。

Linux / OS X

您有两个选择:将 cargo-outdated 放入已存在于您的 $PATH 变量中的目录,或者您可以将自定义目录添加到您的 $PATH

选项 1 如果您有对 $PATH 中目录的写入权限,或者您有 root 权限(或通过 sudo),只需将 cargo-outdated 复制到该目录 # sudo cp cargo-outdated /usr/local/bin

选项 2 如果您没有 root 权限、sudo 或对 $PATH 中任何目录的写入权限,您可以在您的家目录内创建一个目录,并将该目录添加。许多人使用 $HOME/.bin 来保持其隐藏(并且不会使您的家目录变得杂乱),或者如果您希望它始终可见,可以使用 $HOME/bin。以下是一个示例,创建目录,将其添加到 $PATH,并将 cargo-outdated 复制到那里。

只需将 bin 修改为您想要的目录名,并将 .bashrc 修改为您自己的 shell 启动文件(通常是 .bashrc.bash_profile.zshrc

mkdir ~/bin
echo "export PATH=$PATH:$HOME/bin" >> ~/.bashrc
cp cargo-outdated ~/bin
source ~/.bashrc

MacOS

此库依赖于 OpenSSL。在 MacOS 上,需要比默认安装的 OpenSSL 更新版本。可以通过 Homebrew 使用以下命令安装:brew install openssl,或者可以通过 --features vendored-openssl 将 openssl 作为依赖项添加。更多关于构建 OpenSSL 的信息,请参阅此处

Windows

在 Windows 7/8 上,您可以通过以管理员身份打开命令行并运行以下命令将目录添加到 PATH 变量中:

setx path "%path%;C:\path\to\cargo-outdated\binary"

否则,请确保您在当前命令行操作目录中拥有 cargo-outdated 二进制文件,因为 Windows 会自动将您的当前目录添加到 PATH 中(即如果您打开命令行到 C:\my_project\ 以使用 cargo-outdated,请确保 cargo-outdated.exe 也在该目录中)。

选项

cargo-outdated 有几个选项可以使用,应该相对容易理解。

Displays information about project dependency versions

USAGE:
    cargo outdated [options]

Options:
    -a, --aggressive            Ignores channels for latest updates
    -h, --help                  Prints help information
        --format FORMAT         Output formatting [default: list]
                                [values: list, json]
    -i, --ignore DEPENDENCIES   Comma separated list of dependencies to not print in the output
    -x, --exclude DEPENDENCIES  Comma separated list of dependencies to exclude from building
    -q, --quiet                 Suppresses warnings
    -R, --root-deps-only        Only check root dependencies (Equivalent to --depth=1)
    -V, --version               Prints version information
    -v, --verbose ...           Use verbose output
    -w, --workspace             Checks updates for all workspace members rather than
                                only the root package
        --color COLOR           Coloring: auto, always, never [default: auto]
                                [values: auto, always, never]
    -d, --depth NUM             How deep in the dependency chain to search
                                (Defaults to all dependencies when omitted)
        --exit-code NUM         The exit code to return on new versions found [default: 0]
        --features FEATURES     Space-separated list of features
    -m, --manifest-path FILE    Path to the Cargo.toml file to use
                                (Defaults to Cargo.toml in project root)
    -p, --packages PKGS         Packages to inspect for updates
    -r, --root ROOT             Package to treat as the root package

最低支持的 Rust 版本 (MSRV)

此 crate 的 MSRV 是运行 cargo outdated 所需的版本,您可能在更早版本的 Rust 上编译 cargo outdated。然而,因为 cargo outdated 在内部使用 cargo,因此它需要特定最低版本才能成功运行。

当前 MSRV 可以在 Cargo.toml 下的 package.rust-version 字段中找到。

许可

cargo-outdated 根据 MIT 或 Apache 2.0 许可协议发布。有关详细信息,请参阅 LICENSE-MIT 或 LICENSE-APACHE 文件。

依赖项

~63MB
~1.5M SLoC