loopbackio / loopback-next

LoopBack makes it easy to build modern API applications that require complex integrations.
https://loopback.io
Other
4.94k stars 1.06k forks source link

[CLI] Get rid of Yeoman #844

Open bajtos opened 6 years ago

bajtos commented 6 years ago

Refactor the CLI package to use inquirer and ejs directly, get rid of the dependency on Yeoman.

This will allow us to use TypeScript too, we should migrate the CLI codebase to the standard TypeScript project as part of this task.

UPDATE 2020-02-11: Let's not limit ourselves to inquirer and ejs only. The ecosystem offers many more alternatives for building CLI tools, we should research the options and pick the best one. See the comments below for inspiration.

Related:

List of issues compiled from the discussion:

privateOmega commented 6 years ago

@bajtos I would like to help however I can on this issue.

bajtos commented 6 years ago

@raymondfeng Here are the issues I was experiencing in the old generator-loopback frequently:

@privateOmega thank you for chiming in! Right now, we are debating whether we actually want to drop Yeoman or whether it's perhaps not that bad. Once we reach consensus, I can show you pointers where to start.

bajtos commented 6 years ago

AFAICT, there is no way how to test non-trivial prompting logic - for example the loop asking for multiple properties. A mocked prompt can define only a single set of answers. Running the generator/CLI end-to-end and parsing stdout is brittle because Inquirer uses lots of ANSI control codes to control what's displayed on the screen.

Another missing feature is inability to verify configuration of individual prompts. For example when using a choices question populated dynamically (e.g. the datasource prompt showing all datasources known by the app), we want to verify the list of choices offered.

bajtos commented 6 years ago

I also find the necessity to pepper our generator actions with if (this.shouldExit()) return false; as a horrible code smell. (See e.g. here and here and here). I was took a quick glance at other generators, not all actions start with shouldExit check, so we may already have subtle bugs there!

shimks commented 6 years ago

I feel like this is something that should be done ASAP before we pile on more features onto our CLI tool. I'm for replacing Yeoman if we can come up with a prototype that addresses the problems that Yeoman faces.

raymondfeng commented 6 years ago

I suggest that we don't rush into a conclusion. It's probably the best choice to have a time-boxed spike to:

  1. Verify the pain points that @bajtos has listed and see there are fixes/solutions without abandoning Yeoman.

  2. Identify what's needed to build our CLIs using inquirer and ejs directly.

  3. Build a PoC for a simple generator such as app.

bajtos commented 6 years ago

+1 for starting with a spike.

virkt25 commented 6 years ago

+1 for spike. Aside from verifying the pain points listed above and the plan outlined by @raymondfeng, are there any additional questions we want to answer in this spike?

dhmlau commented 6 years ago

With the spike #1187 created, I'm not sure what's the best way to handle this issue. Keep it open? change it to be an epic?

shimks commented 6 years ago

An issue that arose from #1578:

bajtos commented 4 years ago

A module we could use for interactive prompts: https://github.com/terkelg/prompts

I especially like autocomplete prompt, I think it will give much better UX for large projects.

bajtos commented 4 years ago

https://oclif.io seems to be a popular library used e.g. by Heroku CLI.

dougal83 commented 4 years ago

https://oclif.io seems to be a popular library used e.g. by Heroku CLI.

Looks very good. +1 for plugins @oclif/plugin-not-found (e.g. "did you mean?") @oclif/plugin-autocomplete (add bash autocomplete).

bajtos commented 4 years ago

Added another pain point:

We need to call process.chdir in our tests, which makes it impossible to run the tests in parallel via worker threads. See https://github.com/mochajs/mocha/issues/2839

bajtos commented 4 years ago

Related reading: https://getstream.io/blog/crafting-a-command-line-experience-that-developers-love/

mdbetancourt commented 3 years ago

some tools https://github.com/infinitered/gluegun https://caporal.io/