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

commitool

v1.0.0

Published

支持自定义 commitizen 提交信息检查工具.

Downloads

2

Readme

commit 信息规范工具

快速开始

到项目跟路径下,安装 npm 包(如果没有node环境,请提前安装node14以上的版本)

npm i -D commitool @commitlint/[email protected] @commitlint/[email protected]  [email protected]  [email protected]

配置工具

修改项目根目录下的package.json,添加配置

  "config": {
    "commitizen": {
      "path": "./node-modules/commitool"
    }
  },

自定义规则

在项目根路径新建文件 .ctc.js,可自定义配置。 现有默认配置如下:

module.exports = {
  types: types || [
    {
      value: 'feat',
      name: '✨  feat: 新增功能'
    },
    {
      value: 'fix',
      name: '🐛 fix: bug修复'
    },
    {
      value: 'tests',
      name: '🚨 tests: 新增测试用例或是更新现有测试'
    },
    {
      value: 'refactor',
      name: '📦 refactor: 重构代码(既没有新增功能,也没有修复 bug)'
    },
    {
      value: 'style',
      name: '💎 style: 不影响程序逻辑的代码修改(修改空白字符,格式缩进,补全缺失的分号等,没有改变代码逻辑)'
    },
    {
      value: 'docs',
      name: '📚 docs: 文档更新'
    },
    {
      value: 'build',
      name: '🛠 build: 修改项目构建系统(例如 glup,webpack,rollup 的配置等)的提交'
    },
    {
      value: 'ci',
      name: '⚙️ ci: 修改项目继续集成流程(例如 Travis,Jenkins,GitLab CI,Circle等)的提交'
    },
    {
      value: 'merge',
      name: '🎏 merge: 分支合并 Merge branch'
    },
    {
      value: 'perf',
      name: '🚀 perf: 性能, 体验优化'
    },
    {
      value: 'revert',
      name: '⏪  revert: 回滚某个更早之前的提交'
    },
    {
      value: 'chore',
      name: '🦠 chore: 不属于以上类型的其他类型'
    },
  ],
  messages: {
    type: "type: 选择你本次提交的类型:",
    scope: 'scope: 表示此更改的范围(可选):', // 如果 allowCustomScopes 是true,会被使用
    customScope: 'scope: 表示此更改的范围:',
    subject: (max) => `subject: 为更改写一个简短的, 命令式的描述(最多 ${max} 个字):\n`,
    body: `body: 为更改提供一个长描述(可选). 可以使用 "|" 换行, \n必须包含--story=${getStoryId()} or --bug=tapdId or --other=其他信息\n`,
    breaking: 'breaking: 列出 BREAKING CHANGES (可选):\n',
    footer: 'footer: 列出此更改关闭的issue(可选),比如#31,#34',
    confirmCommit: '你确定要继续上面的提交吗?',
  },
  defaultValues: {
    body: `--story=${getStoryId()}`
  },
  validators: {
    body: (body, answers) => {
      const lintStoryid = /(--bug=\d{8,10}|--story=\d{8,10}|--other=|Merge)/.test(body);
      if (lintStoryid) {
        return true;
      } else {
        return 'body 中应该包含 --bug=tapdId or --story=tapdId or --other=其他信息 或 Merge关键字';
      }
    }
  }
}

types

用于配置类型的种类和名称,以及选择列表的提示。

   {
      value: 'build',  // 类型 key
      name: '🛠 build: 修改项目构建系统(例如 glup,webpack,rollup 的配置等)的提交'  // 选择提示信息
    }

messages

根据提示写提交信息,每一步需要写的内容的提示。

defaultValues

每一步默认提供的信息内容

validators

可以对每一步的输入内容做校验,如果不通过校验,无法继续提交。 目前仅支持 subject 和 body 的校验。

body: (body, answers) => {
  // body 提示内容
  // answers 输入内容
  
}

subject: (body, answers) => {
  // body 提示内容
  // answers 输入内容
}

其中,参数里, body 是提示的内容, answers 是输入的内容。

函数返回值分两种,

  1. 返回string类型,表明没有通过校验的提示信息
  2. 返回true,表示通过了校验