In generator-jhipster repository, specifically files.js in ../generators/server/files.js, it generates java source files and directories based on some conditions.
For example:
{
condition: generator => generator.databaseType === 'cassandra',
path: SERVER_MAIN_SRC_DIR,
templates: [
{
file: 'package/config/cassandra/CassandraConfiguration.java',
renameTo: generator => `${generator.javaDir}config/cassandra/CassandraConfiguration.java`
}
]
}
This will take the template file CassandraConfiguration.java.ejs in the package/config/cassandra directory and generate the java source file CassandraConfiguration.java upon running the jhipster application successfully.
My question: is it possible to generate multiple CassandraConfiguration.java files (suppose with different names, such as: CassandraConfiguration0.java, CassandraConfiguration1.java, etc...) inside this template with a "LOOP"? I know I could run a loop with make directories (mkdirp), but I'm not sure how to apply it on making files, because it wouldn't let me create a loop inside the templates: [].
Is this possible? (I'm not familiar with the syntax of yeoman):
{
for(var i = 0; i < 3; i++) {
condition: generator => generator.databaseType === 'cassandra',
path: SERVER_MAIN_SRC_DIR,
templates: [
{
file: 'package/config/cassandra/CassandraConfiguration.java',
renameTo: generator => `${generator.javaDir}config/cassandra/CassandraConfiguration[i].java`
}
]
}
}
This should generate: CassandraConfiguration0.java, CassandraConfiguration1.java and CassandraConfiguration2.java respectively.