Externalize the repository containing the quickstarts to be cloned to avoid to hard code it as this is the case today.
NOTE: We could accept to use others git quickstart repositories at the condition that they respect the same conventions as we use for quarkus quickstart
const quickstartDir = path.join(cloneDir, ctx.input.values.quickstartName);
fs.copySync(quickstartDir, ctx.workspacePath);
// replace the artifactId in the pom.xml
const pomPath = path.join(outputDir, 'pom.xml');
const xml = fs.readFileSync(pomPath, 'utf8');
const parser = new DOMParser();
const doc = parser.parseFromString(xml, 'text/xml');
if(groupId!==undefined) {
doc.getElementsByTagName('groupId')[0].textContent = groupId;
}
if(artifactId!==undefined) {
doc.getElementsByTagName('artifactId')[0].textContent = artifactId;
}
if(version!==undefined) {
doc.getElementsByTagName('version')[0].textContent = version;
}
const serializer = new XMLSerializer();
// write doc as XML back to file
fs.writeFileSync(pomPath, serializer.serializeToString(doc));
// If present, append additional properties to src/main/resources/application.properties
if (ctx.input.values.additionalProperties) {
const propertiesPath = path.join(outputDir, 'src/main/resources/application.properties');
const propertiesContent = fs.readFileSync(propertiesPath, 'utf8');
const updatedPropertiesContent = `${propertiesContent}\n${ctx.input.values.additionalProperties}`;
fs.writeFileSync(propertiesPath, `${updatedPropertiesContent}`);
}
Proposition
Externalize the repository containing the quickstarts to be cloned to avoid to hard code it as this is the case today.
NOTE: We could accept to use others git
quickstart
repositories at the condition that they respect the same conventions as we use for quarkus quickstart