自动 git add/commit/push/打 tag,最后 publish npm 包,用的挺顺手的,一行命令解决很多事

2022-10-22 11:43:16 +08:00
 hc990902

最近的时间一直投入concis组件库的开发工作,每次改完 bug 或者是新增完一些组件功能后都需要去发包、更新线上文档,这样一步步下来其实是比较麻烦的。

发一个新的 NPM 包你可能需要这些步骤:

是不是很麻烦?这就是cimi的由来。

Cimi

cimi是一款全自动 npm 发包工具,一行命令帮助你 git replase 、创建 git tag 、发布 npm 包。

Cimi 自动生成新版本号,自动生成 commit message ,创建 tag ,push 到 github ,最后发布到 npm 中,整个过程只需要一行命令,解放你的双手!

示例如下:

可以看到,通过一行cimi patch master,完成了手改版本号git add/commitgit pushgit tapsnpm publish所有任务。

结合实际项目,你也可以像这样去配合cimi使用:

 "scripts": {
    "build": "rollup -c ./rollup.config.js",
    "replase": "npm run build && cimi patch master",
 }

自认为还是真香的

使用

安装cimi:

# 全局安装 cimi
npm i cimi -g
# 本地安装 cimi
npm i cimi -D

以下是cimi -h的输出:

Usage: cimi [options]

Options:
  -v, --version  output the version number
  patch          patch your new npm package
  minor          minor your new npm package
  major          major your new npm package
  -h, --help     display help for command

  Tip:

    You should run this script in the root directory of you project or run by npm scripts.

  Examples:

    $ cimi patch [branch] (default: master)
    $ cimi minor [branch] (default: master)
    $ cimi major [branch] (default: master)

具体的介绍看 readme 吧,有建议或改善请留言。

cimi github

2318 次点击
所在节点    JavaScript
16 条回复
learningman
2022-10-22 12:21:15 +08:00
semantic-release 警告
zbinlin
2022-10-22 12:55:34 +08:00
npm 不是有命令生成新的版本吗?

```
npm version {major,minor,patch}
git push --follow-tags
```
zbinlin
2022-10-22 12:56:02 +08:00
npm pushlish
zbinlin
2022-10-22 12:56:59 +08:00
@zbinlin /pushlish/publish
wonderfulcxm
2022-10-22 12:58:18 +08:00
不错,我尝试一下
justan
2022-10-22 13:03:10 +08:00
有类似功能的有 lerna/changesets ,不知道有没特点
masker
2022-10-22 13:06:27 +08:00
前端圈确实喜欢造轮子。
Opportunity
2022-10-22 17:40:39 +08:00
yarn 也自带这功能吧,yarn version 和 yarn publish 都可以自动改版本号和 git tag
hc990902
2022-10-22 22:43:11 +08:00
@Opportunity 刚试了一下 yarn publish ,确实也挺方便,对比 cimi ,总结了区别:

1.不能指定分支 commit 并推送;
2.远程仓库没有 new version tag (可能需要其他命令辅助);

yarn publish 可以直接指定新的版本,还是挺方便的。
hc990902
2022-10-22 22:44:27 +08:00
@zbinlin npm publish 对比 yarn publish 就逊色很多了,你需要手动改 package.json 的 version ,再去 publish ,当然也需要去 git add/commit/push/打 tag ,帖子上的工具就是对于 npm publish 的不足才做的。
hc990902
2022-10-22 22:46:27 +08:00
@zbinlin 嗯,帖子的工具原理也很简单,从我司业务方便自己而写的,只不过是一步步执行 npm version/add/commit/push/create tags ,仅此而已,在此基础上再多了一些交互,或者是原有的 patch 、major 、minor ,这些当然也都是基于版本协议的。
hc990902
2022-10-22 22:46:57 +08:00
@wonderfulcxm 感谢支持,有意见请留言
hc990902
2022-10-22 22:47:46 +08:00
@masker 有些人类确实抗拒创造,喜欢原地踏步躺平
hc990902
2022-10-22 22:49:09 +08:00
@learningman 之前没听说过,看起来还不错
masker
2022-10-22 22:50:04 +08:00
@hc990902 当然啦,相同的轮子重复造就是创造,所以说是前端圈🤣
alanhe421
2022-10-23 10:14:07 +08:00

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/888909

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX