npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

commitlint-cli

v1.1.3

Published

代码提交检查规范

Downloads

1,622

Readme

commitlint-cli · GitHub license npm version

前言

最近在公司内部需要引入commit规范以及相关配置,但是项目工程过多,一个个单独引用太过于麻烦,后续修改配置、升级想想就头大,于是花了几个小时找了以下资料,再结合自身的思考,写了一个简单的cli工具来完成自动引入commit配置,并把相关规范也写入工具中,以后只需要升级规范,重新运行命令即可更新配置😄。

commitlint-cli介绍

用于在项目中快速引入 commit message 规范和 commitlint 相关配置规范

实现了自动引入 git-cz commitizen commitlint conventional-changelog-cli husky 依赖以及封装好的commit规范和commitlint相关配置,开箱即用,只需要安装commitlint-cli后,运行commitlint-cli命令后就能生成相关配套设置,简单粗暴。

附上Github地址:commitlint-cli

commit规范和相关配置可以去另外一篇文章看一下: commit规范及自动生成changelog

再说明一下,让我自己一行一行去写规范的代码,太花时间了,直接借用了别人写好的代码,稍微简单修改了一下,附上连接:开箱即用的代码提交规范

功能列表

  1. 自动检测 commit 是否规范,不规范不允许提交
  2. 自动提示 commit 填写格式。不怕忘记规范怎么写
  3. 集成 git add . && git commit 不需要在执行两个命令
  4. 自动生成 changelog
  5. 自动生成以上配置

使用

安装 commitlint-cli

npm i commitlint-cli -D

执行npx init-commitlint

npx init-commitlint

会自动在 package.json 中添加相关配置和命令

{
  "scripts": {
    "log": "conventional-changelog --config ./node_modules/commitlint-cli/lib/log -i CHANGELOG.md -s -r 0",
    "commit": "npm log && git add . && git-cz"
  },
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  },
  "config": {
    "commitizen": {
      "path": "./node_modules/commitlint-cli/lib/cz"
    }
  }
}

会自动增加 commitlint.config.js 文件

module.exports = {
  extends: ['./node_modules/commitlint-cli/lib/lint']
};

命令介绍

npm run commit  # npm run log && git add . && git-cz
npm run log # 生成 CHANGELOG

commit type 规则简单说明

  • feat: 一个新特性
  • fix: 修了一个 Bug
  • docs: 更新了文档(比如改了 Readme)
  • style: 代码的样式美化,不涉及到功能修改(比如改了缩进)
  • refactor: 一些代码结构上优化,既不是新特性也不是修 Bug(比如函数改个名字)
  • perf: 优化了性能的代码改动
  • test: 新增或者修改已有的测试代码
  • chore: 跟仓库主要业务无关的构建/工程依赖/工具等功能改动(比如新增一个文档生成工具)

参考资源

有问题欢迎指出,有用欢迎点个赞😊