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

[Feature Request] Support for multiple scopes #14

Closed jaklan closed 2 years ago

jaklan commented 2 years ago

πŸ’­ Describe the feature

commitlint provides support for multiple scopes: https://commitlint.js.org/#/concepts-commit-conventions?id=multiple-scopes

When you use @commitlint/cz-commitlint adapter, you can enable support for that in commitizen as well by providing the following options in commitlint config:

  prompt: {
    settings: {
      enableMultipleScopes: true
      scopeEnumSeparator: ","
    },
  }

https://commitlint.js.org/#/reference-prompt?id=settings

Then, you can select multiple scopes in commitizen with space and confirm with enter. If empty scopes are forbidden, if no scope is selected you get the hint you need to select at least one to continue.

πŸ’‘ Proposed Solution

To respect the above configuration. The one issue I see is the fact that in cz-git space is used as input to search, but imho in that case we can "override" its behaviour to select the scope instead - scopes with spaces are rather rare use-case, so imho such a compromise should be quite acceptable. Or we can just think about another keystroke to trigger scope selection / unselection (right arrow to select, left arrow to unselect?).

Zhengqbbb commented 2 years ago

commitlint provides support for multiple scopes: https://commitlint.js.org/#/concepts-commit-conventions?id=multiple-scopes

Yeah ! I checked their source code is done using inquirer/checkbox And we are currently using inquirer-autocomplete-prompt.It experience is very nice but currently does not support multiple selection

Then, you can select multiple scopes in commitizen with space and confirm with enter. If empty scopes are forbidden, if no scope is selected you get the hint you need to select at least one to continue.

If he doesn't choose he can't go to the next question

πŸ’‘ Proposed Solution

To respect the above configuration. The one issue I see is the fact that in cz-git space is used as input to search, but imho in that case we can "override" its behaviour to select the scope instead - scopes with spaces are rather rare use-case, so imho such a compromise should be quite acceptable. Or we can just think about another keystroke to trigger scope selection / unselection (right arrow to select, left arrow to unselect?).

I think borrowing can be done with inquirer-checkbox-plus-prompt, but then I have to write one myself. 🀣

jaklan commented 2 years ago

@Zhengqbbb https://github.com/faressoft/inquirer-checkbox-plus-prompt - such library actually already exists πŸ˜ƒ (or maybe I just misunderstood your comment about "writing the one myself" πŸ™ˆ)

Zhengqbbb commented 2 years ago

@Zhengqbbb https://github.com/faressoft/inquirer-checkbox-plus-prompt - such library actually already exists πŸ˜ƒ (or maybe I just misunderstood your comment about "writing the one myself" πŸ™ˆ)

LOL, once my own personality starts, I will write all the inquirers myself 🀯.

Zhengqbbb commented 2 years ago

Hey bro ! @jaklan The latest version 🌟(v1.2.9)🌟 is support for multiple scopes . πŸ’ͺ

demo

Now yet I haven't added tests yet to make sure the checkboxes work, I need to add tests later πŸ‘€ Please have a try. Let me know if there are still any issues. Thanks for reporting it! πŸŽ‰

Zhengqbbb commented 2 years ago

@jaklan Hi, The latest version 🌟(v1.3.1)🌟 You can enable multiple scopes mode without configuration Try it !

checkbox=1 cz
# same it can turn on emoji mode
emoji=1 cz
jaklan commented 2 years ago

Hello @Zhengqbbb, sorry for a late response, I've finally found some time to test multiple scopes - and they work really nice, thank you!

Zhengqbbb commented 2 years ago

Hello @Zhengqbbb, sorry for a late response, I've finally found some time to test multiple scopes - and they work really nice, thank you!

Great πŸ€— Thx u response ~