command line interface - Yeoman Generator: CLI+File Instead of Prompt -


i've been using few yeoman generators prompt me user input. i'd prefer put inputs in json file though. can see yo-rc.json gets generated afterwards, i'd use (or file it) input yeoman.

example using jhipster:

current behavior

$ yo jhipster  welcome jhipster generator v2.16.1 ? (1/15) base name of application? (jhipster) helpme ? (2/15) 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 should able leverage yeoman storage api, haven't succeeded route, nor can find similar examples.

[edit] next steps

next wanted generate entities, unprompted, complex relationships per (https://jhipster.github.io/managing_relationships.html). found 2-step process:

  1. create ./.jhipster/myentity.json
  2. yo jhipster:entity myentity.json
  3. profit

jhipster see comment on question. below jhipster reads .yo-rc.json, if want other name can done well, need read file using file api, suggest keep json named .yo-rc.json compatibility

code app/index.js

this.basename = this.config.get('basename');    this.packagename = this.config.get('packagename');    this.authenticationtype =  this.config.get('authenticationtype');    this.clusteredhttpsession = this.config.get('clusteredhttpsession');    this.searchengine = this.config.get('searchengine');    this.websocket = this.config.get('websocket');    this.databasetype = this.config.get('databasetype');    if (this.databasetype == 'mongodb') {        this.devdatabasetype = 'mongodb';        this.proddatabasetype = 'mongodb';        this.hibernatecache = 'no';    } else if (this.databasetype == 'cassandra') {        this.devdatabasetype = 'cassandra';        this.proddatabasetype = 'cassandra';        this.hibernatecache = 'no';    } else { // sql        this.devdatabasetype = this.config.get('devdatabasetype');        this.proddatabasetype = this.config.get('proddatabasetype');        this.hibernatecache = this.config.get('hibernatecache'); }    this.usecompass = this.config.get('usecompass');    this.javaversion = this.config.get('javaversion');    this.buildtool = this.config.get('buildtool');    this.frontendbuilder =   this.config.get('frontendbuilder');    this.remembermekey = this.config.get('remembermekey');    this.enabletranslation = this.config.get('enabletranslation'); // enabled default avoid conflicts existing applications    this.packagejs = packagejs; 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -