JJ *_*kar 5 command-line-interface yeoman yeoman-generator jhipster
我一直在使用一些提示我进行用户输入的 Yeoman 生成器。不过,我更愿意将我的输入放在 JSON 文件中。我可以看到它是yo-rc.json在之后生成的,但我想使用它(或类似的文件)作为 Yeoman 的输入。
使用JHipster 的示例:
$ 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
Run Code Online (Sandbox Code Playgroud)
$ 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
Run Code Online (Sandbox Code Playgroud)
听起来我应该能够利用Yeoman Storage API,但我个人没有成功地使用这条路线,也找不到任何类似的例子。
接下来,我想自动生成具有复杂关系的实体(https://jhipster.github.io/managing_relationships.html)。我发现这是一个两步过程:
./.jhipster/MyEntity.json yo jhipster:entity MyEntity.jsonJhipster 已经做到了,请参阅我对您问题的评论。下面是 jhipster 读取 .yo-rc.json 的地方,如果你真的想要任何其他名称,也可以完成,你只需要使用文件 api 读取该文件,但我建议你将 json 命名为 .yo- rc.json 的兼容性
代码来自 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'); // this is enabled by default to avoid conflicts for existing applications
this.packagejs = packagejs;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
955 次 |
| 最近记录: |