[英]How to publish multiple versions of same package to gitlab registry
I am working on a usecase where there is a requirement to publish multiple versions of same package.我正在研究一个需要发布相同 package 的多个版本的用例。
I have to publish these version of package in to my gitlab npm registry.我必须将这些版本的 package 发布到我的 gitlab npm 注册表中。 I have searched on this but everyone is telling to use scopes which is not possible in my requirement.
我已经对此进行了搜索,但每个人都在告诉我使用范围,这在我的要求中是不可能的。 Is there a way that i can publish both these versions to my gitlab registry?
有没有办法可以将这两个版本发布到我的 gitlab 注册表?
when i try to publish first version its publishing fine but for second version its giving me an error -当我尝试发布第一个版本时,它的发布很好,但是对于第二个版本,它给了我一个错误-
Unfortunately, you are forced to use scopes in the GitLab npm registry.不幸的是,您被迫在 GitLab npm 注册表中使用范围。 See the documentation: Link
请参阅文档: 链接
So the issue you are facing is not about the multiple Versions (that should work) but that you are not providing any scope.因此,您面临的问题不是关于多个版本(应该可以工作),而是您没有提供任何 scope。
On a side note: It seems like you are trying to proxy the actual entities
package, while you try to use some private packages?附带说明:您似乎正在尝试代理实际
entities
package,而您尝试使用一些私有包? You don't need to do so and I would recommend against that.你不需要这样做,我建议不要这样做。 Some solutions:
一些解决方案:
Alialising is the life saver if you want to publish multiple versions of same package in gitlab, especially if you are trying to publish unscoped packages.如果您想在 gitlab 中发布相同 package 的多个版本,则别名化是救命稻草,尤其是在您尝试发布无范围的软件包时。
#!/bin/sh
list=$(npm ll --json | jq -r 'recurse(.dependencies[]) | [.name+"@"+.version] |@csv' | sed 's/"//g'| sort -u)
for i in $list; do
version_num=$(echo $i | rev | awk -F'@' '{print $1}' | tr '\.' '.'| rev);
name=$(echo $i | perl -pne 's/@[0-9]+(\.[0-9]+)+$//');
npm install $name-$version_num@npm:$i;
done
dirs=$(ls node_modules | grep -Eo ".*\-[0-9]+\.[0-9]+\.[0-9]+")
for i in $dirs; do
echo $i
npm publish node_modules/$i --registry https://gitlabserver.com/api/v4/projects/8/packages/npm/
done
atdirs=$(ls node_modules | grep "@")
for k in $atdirs; do
indirs=$(ls node_modules/$k | grep -Eo ".*\-[0-9]+\.[0-9]+\.[0-9]+")
for j in $indirs;do
echo $k/$j
npm publish node_modules/$k/$j --registry https://gitlabserver.com/api/v4/projects/8/packages/npm/
done
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.