Zhengqbbb / cz-git

cz-git | czg 🛠️ DX first and more engineered, lightweight, customizable, standard output format Commitizen adapter and CLI
https://cz-git.qbb.sh
MIT License
1.11k stars 41 forks source link

[Bug report] `Rules` field don't appear to be respected in `czg` config #171

Closed jamischarles closed 5 months ago

jamischarles commented 5 months ago

✅ Checklist

📄 System Info

System:
    OS: macOS 14.4
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.14 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.2 - ~/.volta/tools/image/node/18.20.2/bin/node
    Yarn: 1.22.19 - ~/.volta/bin/yarn
    npm: 8.19.4 - ~/.volta/tools/image/npm/8.19.4/bin/npm
    bun: 1.0.22 - /opt/homebrew/bin/bun

🔎 Description

Loving czg btw!!

Concise Description

I'm trying to disallow an empty body in the commit message. No matter what I do I can't get that to work. So I tried any rules definition and couldn't get any rules to work at all.

Expected behavior

passing "subject-min-length": [2, "always", 2] should enforce the minimum subject length

Steps to reproduce

npx czg

Screenshots or Screen Recording(if possible)

czg

My config

export default {
  alias: { fd: 'docs: fix typos' },
  rules: {
    // @see: https://commitlint.js.org/#/reference-rules
    'subject-min-length': [2, 'always', 20],
  },
  messages: {
    type: "Select the type of change that you're committing:",
    scope: 'Denote the SCOPE of this change:',
    customScope: 'Denote the SCOPE of this change:',
    subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
    body: 'Explain the WHAT and WHY for this commit. Use "|" to break new line:\n',
    breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
    footerPrefixSelect: 'Select the ISSUES type of changeList by this change (optional):',
    customFooterPrefix: 'Input ISSUES prefix:',
    footer: 'List any ISSUES by this change. E.g.: #31, #34:\n',
    generatingByAI: 'Generating your AI commit subject...',
    generatedSelectByAI: 'Select suitable subject by AI generated:',
    confirmCommit: 'Are you sure you want to proceed with the commit above?',
  },

  types: [
    { value: 'feat', name: 'feat:     A new feature', emoji: '✨' },
    { value: 'fix', name: 'fix:      A bug fix', emoji: '🐛' },
    { value: 'docs', name: 'docs:     Documentation only changes', emoji: '📚' },
    {
      value: 'style',
      name: 'style:    Changes that do not affect the meaning of the code',
      emoji: '💎',
    },
    {
      value: 'refactor',
      name: 'refactor: A code change that neither fixes a bug nor adds a feature',
      emoji: '📦',
    },
    { value: 'perf', name: 'perf:     A code change that improves performance', emoji: '🚀' },
    {
      value: 'test',
      name: 'test:     Adding missing tests or correcting existing tests',
      emoji: '🚨',
    },
    {
      value: 'build',
      name: 'build:    Changes that affect the build system or external dependencies',
      emoji: '🛠',
    },
    {
      value: 'ci',
      name: 'ci:       Changes to our CI configuration files and scripts',
      emoji: '⚙️',
    },
    {
      value: 'chore',
      name: "chore:    Other changes that don't modify src or test files",
      emoji: '♻️',
    },
    { value: 'revert', name: 'revert:   Reverts a previous commit', emoji: '🗑' },
  ],
  useEmoji: false,
  emojiAlign: 'center',
  useAI: false,
  aiNumber: 1,
  themeColorCode: '',
  scopes: ['core', 'dev-logger', 'state', 'actions', 'listeners', 'emitter'],
  allowCustomScopes: true,
  allowEmptyScopes: true,
  customScopesAlign: 'bottom',
  customScopesAlias: 'custom',
  emptyScopesAlias: 'empty',
  upperCaseSubject: false,
  markBreakingChangeMode: false,
  allowBreakingChanges: ['feat', 'fix'],
  breaklineNumber: 100,
  breaklineChar: '|',
  skipQuestions: [],
  issuePrefixes: [{ value: 'closed', name: 'closed:   ISSUES has been processed' }],
  customIssuePrefixAlign: 'top',
  emptyIssuePrefixAlias: 'skip',
  customIssuePrefixAlias: 'custom',
  allowCustomIssuePrefix: true,
  allowEmptyIssuePrefix: true,
  confirmColorize: true,
  maxHeaderLength: Infinity,
  maxSubjectLength: Infinity,
  minSubjectLength: 0,
  scopeOverrides: undefined,
  defaultBody: '',
  defaultIssues: '',
  defaultScope: '',
  defaultSubject: '',
};

🔗 Reproduction link / repo:

No response

Zhengqbbb commented 5 months ago

Thank you for your likes and support.

cz.config.js => .commitlintrc.cjs

image image

cz.config.js not support commitlint rule

Btw, The npx is too slow to launch ...

Zhengqbbb commented 5 months ago

CleanShot 2024-04-30 at 03 23 43@2x

cz-git prompt configure priority over rules

.commitlintrc.cjs

/** @type {import('cz-git').UserConfig} */
module.exports = {
  rules: {
    // @see: https://commitlint.js.org/#/reference-rules
    'subject-min-length': [2, 'always', 20],
  },
  prompt: {
      alias: { fd: 'docs: fix typos' },
      messages: {
        type: "Select the type of change that you're committing:",
        scope: 'Denote the SCOPE of this change:',
        customScope: 'Denote the SCOPE of this change:',
        subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
        body: 'Explain the WHAT and WHY for this commit. Use "|" to break new line:\n',
        breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
        footerPrefixSelect: 'Select the ISSUES type of changeList by this change (optional):',
        customFooterPrefix: 'Input ISSUES prefix:',
        footer: 'List any ISSUES by this change. E.g.: #31, #34:\n',
        generatingByAI: 'Generating your AI commit subject...',
        generatedSelectByAI: 'Select suitable subject by AI generated:',
        confirmCommit: 'Are you sure you want to proceed with the commit above?',
      },

      types: [
        { value: 'feat', name: 'feat:     A new feature', emoji: '✨' },
        { value: 'fix', name: 'fix:      A bug fix', emoji: '🐛' },
        { value: 'docs', name: 'docs:     Documentation only changes', emoji: '📚' },
        {
          value: 'style',
          name: 'style:    Changes that do not affect the meaning of the code',
          emoji: '💎',
        },
        {
          value: 'refactor',
          name: 'refactor: A code change that neither fixes a bug nor adds a feature',
          emoji: '📦',
        },
        { value: 'perf', name: 'perf:     A code change that improves performance', emoji: '🚀' },
        {
          value: 'test',
          name: 'test:     Adding missing tests or correcting existing tests',
          emoji: '🚨',
        },
        {
          value: 'build',
          name: 'build:    Changes that affect the build system or external dependencies',
          emoji: '🛠',
        },
        {
          value: 'ci',
          name: 'ci:       Changes to our CI configuration files and scripts',
          emoji: '⚙️',
        },
        {
          value: 'chore',
          name: "chore:    Other changes that don't modify src or test files",
          emoji: '♻️',
        },
        { value: 'revert', name: 'revert:   Reverts a previous commit', emoji: '🗑' },
      ],
      useEmoji: false,
      emojiAlign: 'center',
      useAI: false,
      aiNumber: 1,
      themeColorCode: '',
      scopes: ['core', 'dev-logger', 'state', 'actions', 'listeners', 'emitter'],
      allowCustomScopes: true,
      allowEmptyScopes: true,
      customScopesAlign: 'bottom',
      customScopesAlias: 'custom',
      emptyScopesAlias: 'empty',
      upperCaseSubject: false,
      markBreakingChangeMode: false,
      allowBreakingChanges: ['feat', 'fix'],
      breaklineNumber: 100,
      breaklineChar: '|',
      skipQuestions: [],
      issuePrefixes: [{ value: 'closed', name: 'closed:   ISSUES has been processed' }],
      customIssuePrefixAlign: 'top',
      emptyIssuePrefixAlias: 'skip',
      customIssuePrefixAlias: 'custom',
      allowCustomIssuePrefix: true,
      allowEmptyIssuePrefix: true,
      confirmColorize: true,
      scopeOverrides: undefined,
      defaultBody: '',
      defaultIssues: '',
      defaultScope: '',
      defaultSubject: '',
  },
}
Zhengqbbb commented 5 months ago

Aha ~ It seems that the default configuration of the document needs to be changed, which is misleading.