Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prompt: reimplement with ink #86

Closed
marionebl opened this issue Oct 4, 2017 · 12 comments · Fixed by #2697
Closed

prompt: reimplement with ink #86

marionebl opened this issue Oct 4, 2017 · 12 comments · Fixed by #2697

Comments

@marionebl
Copy link
Contributor

The current implementation of @commitlint/prompt is tied to vorpal.

While vorpal provides great UX in a lot of ways it limits the adaptability of @commitlint/prompt in important ways, e.g. #46, #63.

marionebl pushed a commit that referenced this issue Nov 29, 2017
JSX transform is needed to enable ink as CLI tool.
Plugin and plugin options are recommended by ink as part of the package
setup process.
<https://github.com/vadimdemedes/ink#getting-started>

first step toward #86
@huy-nguyen
Copy link

I'm interested in helping.

@marionebl
Copy link
Contributor Author

@huy-nguyen Awesome! You can ping me in the #commitlint slack channel if questions pop up: https://yargs.slack.com/messages/C7M8XJ4RL/

@marionebl marionebl changed the title Reimplement @commitlint/prompt with ink prompt: reimplement with ink Dec 7, 2017
@marionebl
Copy link
Contributor Author

Looks like ink is rewritten with flex-box support via yoga-layout. Should make pulling this off easier: https://github.com/vadimdemedes/ink/tree/ef103e0e98f8f04d156834085699ed46a3874eae

bpedersen pushed a commit to bpedersen/commitlint that referenced this issue Oct 15, 2019
…upport-deprecated-license-object-properties

fix: 83 support deprecated license object properties
@armano2
Copy link
Contributor

armano2 commented Feb 6, 2020

i started looking into this and Ink seems nice, but using react to create cli seems like overkill to me

@marionebl
Copy link
Contributor Author

i started looking into this and Ink seems nice, but using react to create cli seems like overkill to me

I beg to differ in this case - prompt has a lot of in-place updates based on a central state so it is well suited for implementation via an immediate mode UI pattern (such as React).

Do you have a different approach in mind?

@beetcb
Copy link
Contributor

beetcb commented May 2, 2021

I actually have a hobby project doing interactive commitlint

Looks ok (I think 🤔):

Commitlive

It is more concerned with typing than choosing(The design of commitzen, for example, focuses on making choices)

If you guys think it's good, I'd be happy to rewrite it in ts and integrate it into this great project
@armano2 @marionebl @escapedcat

@escapedcat
Copy link
Member

Hey @beetcb thanks for your suggestion!

This was just merged: #2547
Maybe have a look if what @curly210102 did is similar?
Maybe there a possibility to work on the @commitlint/cz-commitlint together?

@beetcb
Copy link
Contributor

beetcb commented May 2, 2021

There are too many conflicts between these two implementations 💔.Let's see what @curly210102 thinks first

@escapedcat

@curly210102
Copy link
Contributor

curly210102 commented May 2, 2021

@beetcb Glad you has the same needs and also taken actions.

It is unlikely to merge code directly, I think the point is that these two implementations are from different motivation.

cz-commitlint vs @commitlint/prompt

The motivation of cz-commitlint is to provide commitizen adapter, help commitizen works with commitlint.config.js.
cz-commitlint replaces the role of @commitlint/prompt. I think users who try to use @commitlint/prompt in combination with commitizen(instead of using @commitlint/prompt-cli), want to benefit by commitizen's good interaction and commitlint configuration. But @commitlint/prompt using vorpal instead of inquirer, so the combination is meaningless. cz-commitlint is work for this, based on inquirer, friendlier to commitizen users.

commitlive vs @commitlint/prompt-cli

commitlive is an independent commit tool, provides interactive CLI and message committer. The motivation is same with @commitlint/prompt-cli. We need a commit tool which is good enough to replace commitizen + cz-commitlint. And commitlive has taken the first step, I think there is one thing need to be considered firstly: the reasons to use repll instead of inquirer.

@beetcb
Copy link
Contributor

beetcb commented May 3, 2021

@curly210102 Thank you for clearly demostrating the difference to me.

< why choose repll instead of inquirer ?>

The answer

inquirer is a powerful command line interaction tool, but repll outperforms inquirer in these cases:

  1. repll is small(no deps) and great for instant interaction

  2. repll does not interfere with user input and can simplify user input with tab completions, what you see is what you get; whereas inquirer uses the select function to simplify input, which interferes with the commit process, and it is not intuitive enough

  3. repll can instantly lint and update the output, I'm not sure if inquirer has this ability, maybe the validate function can do this

    3

  4. when using inquirer to prompt the help message, the prompt will become very bloated; repll can use three helpers to avoid this problem: prompt + placeholder + output

    image


Cons of repll

But as the author of repll, I admit that repll has many shortcomings: poor API design, no DTS files, not well tested, etc. I will work on it in due time though, as I improve commitlive, repll will also be improved

@curly210102
Copy link
Contributor

curly210102 commented May 17, 2021

@escapedcat @beetcb Hi, sorry for the late reply. I have surveyed some interactive CLI tools and got some ideas, might help.
Inquirer.js has stable and abstract API system, developers can create and use custom prompts, e.g. inquirer-autocomplete-prompt.
But, the extension system is not easy to use, without development document and need to learn rxjs.
Developing prompt-cli based on Inquirer.js is not a good idea, it will become another commitizen eventually.

Let's clearify the goal: Rewrite @commitlint/prompt-cli for better usability.

Plan A: Relay on interactive CLI tool which is stable, extensible and maintainable

  • vorpal is not be maintained anymore
  • prompts is not extensible
  • enquirer is the best chooice, but the latest commit is on Sep 7, 2020

Plan B: Targeted, Create prompt CLI from zero to one
Focus on implementing the features of @commitlint/prompt-cli, just like commitlive has done.
The advantage:

  • Without lots of built-in prompts, keep lightweight
  • Based on Node.js, avoid the limitations of tools

The risk:

  • Need long-term maintenance
  • Have to fix bugs on different platforms
  • Maybe there is a need for extensible in the future

conclusion

To rewrite @commitlint/prompt-cli, I wouldn't recommend inquirer.js.
cz-commitlint will match the usage style of commitizen, focus on being a good alternative to commitlint/prompt
Although maintain the code separately, but two packages can use the same prompt configuration in commitlint.config.js

@escapedcat
Copy link
Member

escapedcat commented May 17, 2021

We have no numbers on who is using prompt-cli at the moment. I didn't try but can imagine it's not in a good state.
Would it be a option to deprecate it and point people at cz-commitlint?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment