为 NPM 依赖矩阵确定最小数量的公共依赖包

问题描述 投票:0回答:0

假设我有一些 NPM 包规范(一个规范就像

@scope/package-name@version
),它们共享一些共同的依赖项,以及每个包的版本列表。所以,如果
a
b
都依赖于
dep-a
dep-b
,在不同的版本:

[email protected]
[email protected]
[email protected]
[email protected]

我需要生成最少数量的共享依赖项的 semver 兼容包。为此,我需要一个函数,为矩阵中的每个包组合返回最高语义版本兼容的依赖规范列表:

所以例如,如果

[email protected]
[email protected]
都依赖于
dep-a@^1.2.3
dep-b@^1.1.0
,我可能会得到这个结果:

getDeps('[email protected]', '[email protected]');
// ['[email protected]', '[email protected]']

如果

a
的下一个补丁和
b
的下一个次要版本没有改变依赖版本,我可以得到相同的结果:

getDeps('[email protected]', '[email protected]');
// ['[email protected]', '[email protected]']

但是,如果

[email protected]
以与
b
semver 兼容的方式改变它的依赖版本,那么我会得到不同的结果:

getDeps('[email protected]', '[email protected]');
// ['[email protected]', '[email protected]']

是否已经有可以做到这一点的工具?

npm dependency-management
© www.soinside.com 2019 - 2024. All rights reserved.