1 个不稳定版本
0.1.1 | 2021年12月26日 |
---|
#27 in #elm
72KB
980 行
elm 生态系统的依赖求解
此 elm-solve-deps
程序为 elm 生态系统提供了一个专门的依赖求解器,作为命令行可执行文件。它基于 elm-solve-deps 包,以 Rust 库的形式提供相同的功能。
依赖求解的主要目标是从一个依赖约束集合开始,例如,由包的 elm.json
提供
{
...,
"dependencies": {
"elm/core": "1.0.2 <= v < 2.0.0",
"elm/http": "2.0.0 <= v < 3.0.0",
"elm/json": "1.1.2 <= v < 2.0.0"
},
"test-dependencies": {
"elm-explorations/test": "1.2.0 <= v < 2.0.0"
}
}
然后找到一组满足这些约束的包版本。通常我们还想有一些优先级,例如选择兼容的最新版本。在这个案例和这个日期,不考虑测试依赖项,最新的解决方案是
{
"direct": {
"elm/core": "1.0.5",
"elm/http": "2.0.0",
"elm/json": "1.1.3"
},
"indirect": {
"elm/bytes": "1.0.8",
"elm/file": "1.0.5",
"elm/time": "1.0.0"
}
}
如果我们还考虑测试依赖项,我们将得到以下结果
{
"direct": {
"elm/core": "1.0.5",
"elm/http": "2.0.0",
"elm/json": "1.1.3",
"elm-explorations/test": "1.2.2"
},
"indirect": {
"elm/bytes": "1.0.8",
"elm/file": "1.0.5",
"elm/html": "1.0.0",
"elm/random": "1.0.0",
"elm/time": "1.0.0",
"elm/virtual-dom": "1.0.2"
}
}
安装
您可以从 最新发布版本 的构建工件中下载适用于您系统的可执行文件。或者,如果您在机器上安装了 Rust 和 Cargo,可以使用 cargo install elm-solve-deps-bin
编译和安装此程序。
此 elm-solve-deps
CLI 的用法。
以下是 CLI 程序的帮助信息(可能已过时),显示了其大部分功能。您可以通过运行 elm-solve-deps --help
获取此输出的最新版本。
elm-solve-deps
Solve dependencies of an Elm project or published package.
By default, try in offline mode first
and switch to online mode if that fails.
USAGE:
elm-solve-deps [FLAGS...] [author/package@version]
For example:
elm-solve-deps
elm-solve-deps --help
elm-solve-deps --offline
elm-solve-deps ianmackenzie/[email protected]
elm-solve-deps --offline jxxcarlson/[email protected]
elm-solve-deps --online-newest w0rm/[email protected]
elm-solve-deps --online-oldest lucamug/[email protected]
elm-solve-deps --test
elm-solve-deps --extra "elm/json: 1.1.3 <= v < 2.0.0"
FLAGS:
--help Print this message and exit
--offline No network request, use only installed packages
--online-newest Use the newest compatible version
--online-oldest Use the oldest compatible version
--test Solve with both normal and test dependencies
--extra "author/package: constraint"
Additional package version constraint
Need one --extra per additional constraint
MUST be placed before an eventual package to solve
依赖项
~2.6–4MB
~102K SLoC