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.12k stars 41 forks source link

[Bug report] `allowEmptyScopes` option not work when not provide `scopes` #109

Closed laterdayi closed 1 year ago

laterdayi commented 1 year ago

✅ Checklist

📄 System Info

windows

🔎 Description

Concise Description

How can scope be mandatory instead of empty or Custom every time

Expected behavior

    allowEmptyScopes: false,
    allowCustomScopes: false

Steps to reproduce

Screenshots or Screen Recording(if possible)

🔗 Reproduction link / repo:

No response

Zhengqbbb commented 1 year ago

Could you provide more examples or descriptions?

If you set

allowEmptyScopes: false,
allowCustomScopes: false

What other UI requirements are there or what requirements are not met ? or these two configuration items don't work ?

laterdayi commented 1 year ago

图片 scope still needs to be selected

laterdayi commented 1 year ago

@Zhengqbbb

Zhengqbbb commented 1 year ago

No scopes provide.

Yes, there was a problem with this logic, if there was no data in the scopes it would have skipped the logic with empty

/** @type {import('cz-git').UserConfig} */
module.exports = {
  //  继承的规则
  extends: ['@commitlint/config-conventional'],
  rules: {
    // type类型定义:提交的type必须在以下的类型范围内
    'type-enum': [
      // 错误级别
      2,
      // 在什么情况下验证
      'always',
      [
        // 新功能 feature
        'feat',
        // 修复 bug
        'fix',
        // 文档更新
        'docs',
        // 代码格式(不影响代码运行的变动)
        'style',
        // 代码重构
        'refactor',
        // 性能优化
        'perf',
        // 测试相关
        'test',
        // 构建相关
        'build',
        // 持续集成
        'ci',
        // 代码回退
        'revert',
        // 其他修改
        'chore'
      ]
    ],
    'scope-empty': [2, 'never'],
    'scope-case': [2, 'always', 'kebab-case'],
    'scope-max-length': [2, 'always', '30'],
    'scope-min-length': [2, 'always', '2'],
    'subject-empty': [2, 'never'],
    'subject-case': [0],
    'subject-min-length': [2, 'always', '4']
  },
  prompt: {
    messages: {
      type: '选择提交的类型 :',
      scope: '选择修改范围(可选):',
      subject: '填写简短精炼的变更描述 :\n',
      customFooterPrefixs: '输入自定义issue前缀 :',
      footer: '列举关联issue (可选) 例如: #31, #101 :\n',
      confirmCommit: '是否提交或修改commit ?'
    },
    types: [
      { value: 'feat', name: 'feat:     ✨  新增功能 | A new feature', emoji: ':sparkles:' },
      { value: 'fix', name: 'fix:      🐛  修复缺陷 | A bug fix', emoji: ':bug:' },
      {
        value: 'docs',
        name: 'docs:     📝  文档更新 | Documentation only changes',
        emoji: ':memo:'
      },
      {
        value: 'style',
        name: 'style:    💄  代码格式 | Changes that do not affect the meaning of the code',
        emoji: ':lipstick:'
      },
      {
        value: 'refactor',
        name: 'refactor: ♻️   代码重构 | A code change that neither fixes a bug nor adds a feature',
        emoji: ':recycle:'
      },
      {
        value: 'perf',
        name: 'perf:     ⚡️  性能提升 | A code change that improves performance',
        emoji: ':zap:'
      },
      {
        value: 'test',
        name: 'test:     ✅  测试相关 | Adding missing tests or correcting existing tests',
        emoji: ':white_check_mark:'
      },
      {
        value: 'build',
        name: 'build:    📦️  构建相关 | Changes that affect the build system or external dependencies',
        emoji: ':package:'
      },
      {
        value: 'ci',
        name: 'ci:       🎡  持续集成 | Changes to our CI configuration files and scripts',
        emoji: ':ferris_wheel:'
      },
      { value: 'revert', name: 'revert:   ⏪️  代码回退 | Revert to a commit', emoji: ':hammer:' },
      {
        value: 'chore',
        name: 'chore:    🔨  其他修改 | Other changes that do not modify src or test files',
        emoji: ':rewind:'
      }
    ],
    useEmoji: true,
    scopes: ['hello', 'world'],
    customScopesAlign: 'top',
    allowBreakingChanges: ['feat', 'fix', 'refactor', 'chore', 'ci', 'perf', 'revert'],
    skipQuestions: ['body', 'footerPrefix', 'customFooterPrefixs'],
  }
};
laterdayi commented 1 year ago

ok, Ok, looking forward to repair, in fact, there is a scene that must fill in the scope, so the scope select appears to be unnecessary

is there any time to release

laterdayi commented 1 year ago

thanks

Zhengqbbb commented 1 year ago

cz-git ⭐v1.6.1⭐ have been release. should be resolve this ISSUE

Zhengqbbb commented 1 year ago

If you don't want to, you can skipQuestion but there must be an option

laterdayi commented 1 year ago

@Zhengqbbb There's no way to type it directly like a subject, right?

Zhengqbbb commented 1 year ago

Yep, I prefer to search for options to avoid duplicate input

Zhengqbbb commented 1 year ago

If you really don't like the search option and prefer a simple input I'll find a way to make the custom input display directly in the next version. But that's not now maybe next week. It need refactor some question logic.

laterdayi commented 1 year ago

@Zhengqbbb ok thank you