
最近的时间一直投入concis组件库的开发工作,每次改完 bug 或者是新增完一些组件功能后都需要去发包、更新线上文档,这样一步步下来其实是比较麻烦的。
发一个新的 NPM 包你可能需要这些步骤:
package.json中的version.git add .、git commit -m "xxxx"生成一个提交.git push origin master 推送到远端.tag.npm publish将代码提交到 NPM.是不是很麻烦?这就是cimi的由来。
cimi是一款全自动 npm 发包工具,一行命令帮助你 git replase 、创建 git tag 、发布 npm 包。
Cimi 自动生成新版本号,自动生成 commit message ,创建 tag ,push 到 github ,最后发布到 npm 中,整个过程只需要一行命令,解放你的双手!
示例如下:
可以看到,通过一行cimi patch master,完成了手改版本号、git add/commit、git push、git taps、npm 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 吧,有建议或改善请留言。
1 learningman 2022-10-22 12:21:15 +08:00 semantic-release 警告 |
2 zbinlin 2022-10-22 12:55:34 +08:00 npm 不是有命令生成新的版本吗? ``` npm version {major,minor,patch} git push --follow-tags ``` |
3 zbinlin 2022-10-22 12:56:02 +08:00 npm pushlish |
5 wonderfulcxm 2022-10-22 12:58:18 +08:00 via iPhone 不错,我尝试一下 |
6 justan 2022-10-22 13:03:10 +08:00 有类似功能的有 lerna/changesets ,不知道有没特点 |
7 masker 2022-10-22 13:06:27 +08:00 via Android 前端圈确实喜欢造轮子。 |
8 Opportunity 2022-10-22 17:40:39 +08:00 yarn 也自带这功能吧,yarn version 和 yarn publish 都可以自动改版本号和 git tag |
9 hc990902 OP @Opportunity 刚试了一下 yarn publish ,确实也挺方便,对比 cimi ,总结了区别: 1.不能指定分支 commit 并推送; 2.远程仓库没有 new version tag (可能需要其他命令辅助); yarn publish 可以直接指定新的版本,还是挺方便的。 |
10 hc990902 OP @zbinlin npm publish 对比 yarn publish 就逊色很多了,你需要手动改 package.json 的 version ,再去 publish ,当然也需要去 git add/commit/push/打 tag ,帖子上的工具就是对于 npm publish 的不足才做的。 |
11 hc990902 OP @zbinlin 嗯,帖子的工具原理也很简单,从我司业务方便自己而写的,只不过是一步步执行 npm version/add/commit/push/create tags ,仅此而已,在此基础上再多了一些交互,或者是原有的 patch 、major 、minor ,这些当然也都是基于版本协议的。 |
12 hc990902 OP @wonderfulcxm 感谢支持,有意见请留言 |
14 hc990902 OP @learningman 之前没听说过,看起来还不错 |
16 alanhe421 2022-10-23 10:14:07 +08:00 |