0

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

 1 year ago
source link: https://www.v2ex.com/t/888909
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  JavaScript

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

  hc990902 · 2 小时 17 分钟前 · 307 次点击

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

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

  • 手动修改package.json中的version.
  • git add .git commit -m "xxxx"生成一个提交.
  • git push origin master 推送到远端.
  • 在 github 中打一个新tag.
  • npm publish将代码提交到 NPM.

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

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

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

示例如下:

image.png

可以看到,通过一行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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK