-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restructured server, added common sub-generator (#83)
- Loading branch information
Showing
11 changed files
with
342 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const chalk = require('chalk'); | ||
|
||
const EntityServerGenerator = require('generator-jhipster/generators/common'); | ||
|
||
const entandoBlueprintWritingPhase = require('./phases/writing'); | ||
|
||
module.exports = class extends EntityServerGenerator { | ||
constructor(args, opts) { | ||
super(args, { fromBlueprint: true, ...opts }); // fromBlueprint variable is important | ||
|
||
this.jhipsterContext = this.options.jhipsterContext; | ||
const jhContext = this.jhipsterContext; | ||
|
||
if (!jhContext) { | ||
this.error( | ||
`This is a JHipster blueprint and should be used only like ${chalk.yellow( | ||
'jhipster --blueprints entando', | ||
)}`, | ||
); | ||
} | ||
|
||
this.configOptions = jhContext.configOptions || {}; | ||
// This sets up options for this sub generator and is being reused from JHipster | ||
jhContext.setupClientOptions(this, jhContext); | ||
|
||
if (jhContext.databaseType === 'cassandra') { | ||
this.pkType = 'UUID'; | ||
} | ||
const jhipsterConfig = this.getAllJhipsterConfig(); | ||
this.serverPort = jhipsterConfig.serverPort; | ||
} | ||
|
||
get initializing() { | ||
// initializing - Your initialization methods (checking current project state, getting configs, etc) | ||
|
||
return super._initializing(); | ||
} | ||
|
||
get default() { | ||
// default - If the method name doesn’t match a priority, it will be pushed to this group. | ||
return super._default(); | ||
} | ||
|
||
get writing() { | ||
// writing - Where you write the generator specific files (routes, controllers, etc) | ||
const jhipsterWritingPhase = super._writing(); | ||
|
||
// return entandoBlueprintWritingPhase; | ||
return { ...jhipsterWritingPhase, ...entandoBlueprintWritingPhase }; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const commonFiles = { | ||
global: [ | ||
{ | ||
templates: [ | ||
{ | ||
file: 'gitignore', | ||
renameTo: () => '.gitignore', | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
function writeCommonFiles() { | ||
this.writeFilesToDisk(commonFiles, this, false, null); | ||
} | ||
|
||
module.exports = { | ||
writeCommonFiles, | ||
commonFiles, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { writeCommonFiles } = require('./files'); | ||
|
||
module.exports = { | ||
writeCommonFiles, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
###################### | ||
# Project Specific | ||
######################<% if (!skipClient) { %> | ||
/<%= CLIENT_MAIN_SRC_DIR %>content/css/main.css<% } %> | ||
/<%= CLIENT_DIST_DIR %>** | ||
/<%= TEST_DIR %>javascript/coverage/ | ||
|
||
###################### | ||
# Node | ||
###################### | ||
/node/ | ||
node_tmp/ | ||
node_modules/ | ||
npm-debug.log.* | ||
/.awcache/* | ||
/.cache-loader/* | ||
|
||
###################### | ||
# SASS | ||
###################### | ||
.sass-cache/ | ||
|
||
###################### | ||
# Eclipse | ||
###################### | ||
*.pydevproject | ||
.project | ||
.metadata | ||
tmp/ | ||
tmp/**/* | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.classpath | ||
.settings/ | ||
.loadpath | ||
.factorypath | ||
/<%= SERVER_MAIN_RES_DIR %>rebel.xml | ||
|
||
# External tool builders | ||
.externalToolBuilders/** | ||
|
||
# Locally stored "Eclipse launch configurations" | ||
*.launch | ||
|
||
# CDT-specific | ||
.cproject | ||
|
||
# PDT-specific | ||
.buildpath | ||
|
||
# STS-specific | ||
/.sts4-cache/* | ||
|
||
###################### | ||
# IntelliJ | ||
###################### | ||
.idea/ | ||
*.iml | ||
*.iws | ||
*.ipr | ||
*.ids | ||
*.orig | ||
classes/ | ||
out/ | ||
|
||
###################### | ||
# Visual Studio Code | ||
###################### | ||
.vscode/ | ||
|
||
###################### | ||
# Maven | ||
###################### | ||
/log/ | ||
/target/ | ||
|
||
###################### | ||
# Gradle | ||
###################### | ||
.gradle/ | ||
/build/ | ||
|
||
###################### | ||
# Package Files | ||
###################### | ||
*.jar | ||
*.war | ||
*.ear | ||
*.db | ||
|
||
###################### | ||
# Windows | ||
###################### | ||
# Windows image file caches | ||
Thumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
###################### | ||
# Mac OSX | ||
###################### | ||
.DS_Store | ||
.svn | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear on external disk | ||
.Spotlight-V100 | ||
.Trashes | ||
|
||
###################### | ||
# Directories | ||
###################### | ||
/bin/ | ||
/deploy/ | ||
|
||
###################### | ||
# Logs | ||
###################### | ||
*.log* | ||
|
||
###################### | ||
# Others | ||
###################### | ||
*.class | ||
*.*~ | ||
*~ | ||
.merge_file* | ||
|
||
###################### | ||
# Gradle Wrapper | ||
###################### | ||
!gradle/wrapper/gradle-wrapper.jar | ||
|
||
###################### | ||
# Maven Wrapper | ||
###################### | ||
!.mvn/wrapper/maven-wrapper.jar | ||
|
||
###################### | ||
# ESLint | ||
###################### | ||
.eslintcache | ||
|
||
###################### | ||
# Entando bundles | ||
###################### | ||
bundle/ | ||
# !/bundle/descriptor.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
function askForMfeGeneration(meta) { | ||
// defaulting to asking about MFE generation | ||
const serverSetting = this.config.get('generateMicroFrontends') || 'ask'; | ||
// defaulting to asking about MFE generation | ||
const serverSetting = this.config.get('generateMicroFrontends') || 'ask'; | ||
|
||
if (!meta && this.existingProject) { | ||
return; | ||
} | ||
if (!meta && this.existingProject) { | ||
return; | ||
} | ||
|
||
if (serverSetting === 'ask') { | ||
const done = this.async(); | ||
const prompts = [ | ||
{ | ||
type: 'confirm', | ||
name: 'generateMfeForEntity', | ||
message: 'Do you want to generate micro frontends?', | ||
default: true, | ||
}, | ||
]; | ||
this.prompt(prompts).then(prompt => { | ||
this.configOptions.generateMfeForEntity = prompt.generateMfeForEntity; | ||
done(); | ||
}); | ||
} else { | ||
if (serverSetting === 'never') { | ||
this.configOptions.generateMfeForEntity = false; | ||
} | ||
if (serverSetting === 'always') { | ||
this.configOptions.generateMfeForEntity = true; | ||
} | ||
if (serverSetting === 'ask') { | ||
const done = this.async(); | ||
const prompts = [ | ||
{ | ||
type: 'confirm', | ||
name: 'generateMfeForEntity', | ||
message: 'Do you want to generate micro frontends?', | ||
default: true, | ||
}, | ||
]; | ||
this.prompt(prompts).then(prompt => { | ||
this.configOptions.generateMfeForEntity = prompt.generateMfeForEntity; | ||
done(); | ||
}); | ||
} else { | ||
if (serverSetting === 'never') { | ||
this.configOptions.generateMfeForEntity = false; | ||
} | ||
if (serverSetting === 'always') { | ||
this.configOptions.generateMfeForEntity = true; | ||
} | ||
} | ||
} | ||
|
||
module.exports = { askForMfeGeneration }; |
Oops, something went wrong.