Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lerna 发布失败后的解决方案 #67

Open
huruji opened this issue May 21, 2019 · 0 comments
Open

lerna 发布失败后的解决方案 #67

huruji opened this issue May 21, 2019 · 0 comments

Comments

@huruji
Copy link
Owner

huruji commented May 21, 2019

lerna 作为多个包依赖的管理解决方案,确实解决了很多痛点,我目前在工作和生活中已经大量使用了lerna,但同时也会遇到一些问题,发布失败后的问题是遇到比较频繁的问题,因此记录一下

lerna publish 主要做了以下几件事:

  • 检查从上一个 git tag 之后是否有提交,没有提交就会显示 No changed packages to publish 的信息,然后退出

  • 检查依赖了修改过的包的包,并更新依赖信息

  • 提交相应版本的 git tag

  • 发布修改的包及依赖它们的包

看上去非常理想,但是使用起来可能很蛋疼,往往出问题的可能就是最后一步,发布包的问题,有可能你的网络情况有问题,有可能你没有登录npm(包括公司内部的 registry ),如果你需要发布到指定的 registry 上,你可以在 lerna.json 上指定:

"command": {
    "publish": {
      "message": "chore(release): publish",
      "registry": "http://legos.wq.jd.com/legosv5/registry/"
    }
  },

我已经遇到了好几次这个问题,如下:

关于这个问题,社区也有相应的讨论,可以在 lerna 项目的issue中找到,如 524、1894

对此,lerna 到目前为止并没有提供很好的解决方案。

你可以在你这次失败之后使用 from-git 参数,即lerna publish from-git

或者我们可以手动回退 git 到 release 之前的版本,并删除相应的 git tag,如下:

git reset --hard HEAD~1 && git tag -d $(git log --date-order --tags --simplify-by-decoration --pretty=format:'%d' | head -1 | tr -d '()' | sed 's/,* tag://g')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant