I've been using a few Yeoman Generators that prompt me for user input. I'd prefer to put my inputs in a JSON file though. I can see that yo-rc.json
gets generated afterwards, but I'd like to use that (or a file like it) as an input to Yeoman.
Example using JHipster:
Current Behavior
$ yo jhipster
Welcome to the JHipster Generator v2.16.1
? (1/15) What is the base name of your application? (jhipster) helpme
? (2/15) What is your default Java package name? com.mycompany.helpme
...
# Yeoman Generator creates project via user inputs
Desired Behavior
$ cat my-custom.json
{
"generator-jhipster": {
"baseName": "helpme",
"packageName": "com.mycompany.helpme",
...
$ yo jhipster --file my-custom.json
...
# Yeoman Generator creates project via input file
It sounds like I should be able to leverage the Yeoman Storage API, but I haven't personally succeeded with that route, nor can I find any similar examples.
[Edit] Next Steps
Next I wanted to generate entities, unprompted, with complex relationships per (https://jhipster.github.io/managing_relationships.html). I found this to be a 2-step process:
- Create
./.jhipster/MyEntity.json
yo jhipster:entity MyEntity.json
- Profit
Jhipster already does that see my comment on your question. Below is where jhipster reads the .yo-rc.json, if you really want any other name it can be done as well, you just need to read that file using file api, but I would suggest you keep your json named .yo-rc.json for compatibility
Code from app/index.js