cz-customizable 项目使用教程

cz-customizable 项目使用教程

cz-customizable项目地址:https://gitcode.com/gh_mirrors/czc/cz-customizable

1. 项目的目录结构及介绍

cz-customizable 项目的目录结构如下:

cz-customizable/
├── LICENSE
├── README.md
├── index.js
├── package.json
├── cz-config-EXAMPLE.js
└── test/
    ├── cz-config-test.js
    └── index.test.js
  • LICENSE: 项目的许可证文件。
  • README.md: 项目的主要说明文档。
  • index.js: 项目的主入口文件。
  • package.json: 项目的依赖和配置文件。
  • cz-config-EXAMPLE.js: 自定义提交信息的配置示例文件。
  • test/: 项目的测试目录,包含测试文件。

2. 项目的启动文件介绍

项目的启动文件是 index.js,它主要负责加载和应用自定义的提交信息配置。以下是 index.js 的主要内容:

const path = require('path');
const fs = require('fs');
const configLoader = require('commitizen').configLoader;
const customUtils = require('./customUtils');

module.exports = {
  prompter: function (cz, commit) {
    const config = configLoader.load();
    const czConfig = config.path ? path.join(config.path, config.config) : path.resolve(process.cwd(), '.cz-config.js');

    if (!fs.existsSync(czConfig)) {
      customUtils.errorMessage();
      process.exit(1);
    }

    const options = {
      config: czConfig
    };

    require('cz-customizable').prompter(cz, commit, options);
  }
};

该文件主要功能是加载自定义配置文件 .cz-config.js,并调用 cz-customizable 的 prompter 方法来生成提交信息。

3. 项目的配置文件介绍

项目的配置文件是 cz-config-EXAMPLE.js,它定义了自定义提交信息的格式和选项。以下是 cz-config-EXAMPLE.js 的主要内容:

module.exports = {
  types: [
    { value: 'feat', name: 'feat:     A new feature' },
    { value: 'fix', name: 'fix:      A bug fix' },
    { value: 'docs', name: 'docs:     Documentation only changes' },
    { value: 'style', name: 'style:    Changes that do not affect the meaning of the code' },
    { value: 'refactor', name: 'refactor: A code change that neither fixes a bug nor adds a feature' },
    { value: 'perf', name: 'perf:     A code change that improves performance' },
    { value: 'test', name: 'test:     Adding missing tests' },
    { value: 'chore', name: 'chore:    Changes to the build process or auxiliary tools and libraries such as documentation generation' },
    { value: 'revert', name: 'revert:   Revert to a commit' },
    { value: 'WIP', name: 'WIP:      Work in progress' }
  ],

  scopes: [
    { name: 'accounts' },
    { name: 'admin' },
    { name: 'exampleScope' },
    { name: 'changeMe' }
  ],

  allowCustomScopes: true,
  allowBreakingChanges: ['feat', 'fix'],
  skipQuestions: ['body', 'footer'],

  subjectLimit: 100,
  breaklineChar: '|',
  footerPrefix: 'ISSUES CLOSED:',
  askForBreakingChangeFirst: true
};

该配置文件定义了提交信息的类型、范围、是否允许自定义范围、是否允许破坏性变更等选项。通过修改该文件,可以自定义提交信息的格式和内容。

cz-customizable项目地址:https://gitcode.com/gh_mirrors/czc/cz-customizable

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宋韵庚

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值