1. 21
    Add prompts to an Nx Workspace Generator
    52s

Add prompts to an Nx Workspace Generator

Share this video with your friends

Social Share Links

Send Tweet

To improve the execution of our Nx workspace generator we can add prompts to our generator configuration. In that way, when users run the workspace generator and some argument is missing, it would prompt the user with a question we can define. This leads to a much-improved experience.

Prefer to read along as well? Here's the accompanying article.

Instructor: [0:00] Right now, if we invoke our custom workspace generator and we forget to provide some of the required information, for instance, let's say yet-another-article, but we don't provide the author, Nx correctly fails and provides information that the author is missing.

[0:17] Now, we can improve this whole developer experience by providing some prompts for all of these properties. We can go here and add the x-prompt property and add some question, which the user can answer to, "Title of your new article?" Similarly, we can add here, "What's the name of the author?"

[0:36] If we save this now and retry to execute the workspace generator -- we can even remove the title -- we will get a question, "What's the title of your article?" so, Hello Egghead. "What's the name of the author?" Yuri. We go ahead and create my new Hello Egghead article.