Skip to content

Commit

Permalink
Merge pull request #23591 from mshima/skip_ci-micronaut-blueprint
Browse files Browse the repository at this point in the history
Improve blueprint support.
  • Loading branch information
mshima authored Sep 22, 2023
2 parents 8e265f3 + 1cb940b commit b1e893e
Show file tree
Hide file tree
Showing 363 changed files with 804 additions and 560 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ Sub templates should be named with the `ejs` extension because it's the default

<%- include('../common/field_validators', {field, reactive}); -%>

This statement means that [_PersistClass_.java.jhi.jakarta_validation.ejs](generators/server/templates/entity/src/main/java/package/domain/_PersistClass_.java.jhi.jakarta_validation.ejs) template includes [field_validators.ejs](generators/server/templates/entity/src/main/java/package/common/field_validators.ejs) sub template.
This statement means that [_persistClass_.java.jhi.jakarta_validation.ejs](generators/server/templates/entity/src/main/java/package/domain/_persistClass_.java.jhi.jakarta_validation.ejs) template includes [field_validators.ejs](generators/server/templates/entity/src/main/java/package/common/field_validators.ejs) sub template.

Sub templates can be unit tested.

Expand Down
11 changes: 11 additions & 0 deletions cli/jhipster-command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import chalk from 'chalk';
import { Command, Option } from 'commander';
import lodash from 'lodash';
import { convertConfigToOption } from '../lib/internal/index.mjs';

const { kebabCase } = lodash;

Expand Down Expand Up @@ -177,6 +178,16 @@ export default class JHipsterCommand extends Command {
return this;
}

addJHipsterConfigs(configs = {}, blueprintOptionDescription) {
Object.entries(configs).forEach(([name, config]) => {
if (config.cli) {
const option = convertConfigToOption(name, config);
this._addGeneratorOption(kebabCase(option.name), option, blueprintOptionDescription);
}
});
return this;
}

_addGeneratorOption(optionName, optionDefinition, additionalDescription = '') {
if (optionName === 'help') {
return undefined;
Expand Down
2 changes: 2 additions & 0 deletions cli/program.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const addCommandGeneratorOptions = async (command, generatorMeta, { root, bluepr
const generatorModule = await generatorMeta.importModule();
if (generatorModule.command) {
command.addJHipsterOptions(generatorModule.command.options, blueprintOptionDescription);
command.addJHipsterConfigs(generatorModule.command.configs, blueprintOptionDescription);
}
try {
if (root || !generatorModule.command || generatorModule.command.loadGeneratorOptions) {
Expand Down Expand Up @@ -152,6 +153,7 @@ export const createProgram = ({ executableName = CLI_NAME, executableVersion } =
.option('--skip-regenerate', "Don't regenerate identical files", false)
.option('--skip-yo-resolve', 'Ignore .yo-resolve files', false)
.addJHipsterOptions(command.options)
.addJHipsterConfigs(command.configs)
);
};

Expand Down
40 changes: 20 additions & 20 deletions generators/angular/entity-files-angular.mts
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,37 @@ export const angularFiles = {
client: [
{
...clientApplicationTemplatesBlock(),
templates: ['entities/_entityFolder/_entityFile.model.ts', 'entities/_entityFolder/_entityFile.test-samples.ts'],
templates: ['entities/_entityFolder_/_entityFile_.model.ts', 'entities/_entityFolder_/_entityFile_.test-samples.ts'],
},
{
condition: generator => !generator.embedded,
...clientApplicationTemplatesBlock(),
templates: [
'entities/_entityFolder/_entityFile.routes.ts',
'entities/_entityFolder/detail/_entityFile-detail.component.html',
'entities/_entityFolder/detail/_entityFile-detail.component.ts',
'entities/_entityFolder/detail/_entityFile-detail.component.spec.ts',
'entities/_entityFolder/list/_entityFile.component.html',
'entities/_entityFolder/list/_entityFile.component.ts',
'entities/_entityFolder/list/_entityFile.component.spec.ts',
'entities/_entityFolder/route/_entityFile-routing-resolve.service.ts',
'entities/_entityFolder/route/_entityFile-routing-resolve.service.spec.ts',
'entities/_entityFolder/service/_entityFile.service.ts',
'entities/_entityFolder/service/_entityFile.service.spec.ts',
'entities/_entityFolder_/_entityFile_.routes.ts',
'entities/_entityFolder_/detail/_entityFile_-detail.component.html',
'entities/_entityFolder_/detail/_entityFile_-detail.component.ts',
'entities/_entityFolder_/detail/_entityFile_-detail.component.spec.ts',
'entities/_entityFolder_/list/_entityFile_.component.html',
'entities/_entityFolder_/list/_entityFile_.component.ts',
'entities/_entityFolder_/list/_entityFile_.component.spec.ts',
'entities/_entityFolder_/route/_entityFile_-routing-resolve.service.ts',
'entities/_entityFolder_/route/_entityFile_-routing-resolve.service.spec.ts',
'entities/_entityFolder_/service/_entityFile_.service.ts',
'entities/_entityFolder_/service/_entityFile_.service.spec.ts',
],
},
{
condition: generator => !generator.readOnly && !generator.embedded,
...clientApplicationTemplatesBlock(),
templates: [
'entities/_entityFolder/update/_entityFile-form.service.ts',
'entities/_entityFolder/update/_entityFile-form.service.spec.ts',
'entities/_entityFolder/update/_entityFile-update.component.html',
'entities/_entityFolder/update/_entityFile-update.component.spec.ts',
'entities/_entityFolder/delete/_entityFile-delete-dialog.component.html',
'entities/_entityFolder/update/_entityFile-update.component.ts',
'entities/_entityFolder/delete/_entityFile-delete-dialog.component.ts',
'entities/_entityFolder/delete/_entityFile-delete-dialog.component.spec.ts',
'entities/_entityFolder_/update/_entityFile_-form.service.ts',
'entities/_entityFolder_/update/_entityFile_-form.service.spec.ts',
'entities/_entityFolder_/update/_entityFile_-update.component.html',
'entities/_entityFolder_/update/_entityFile_-update.component.spec.ts',
'entities/_entityFolder_/delete/_entityFile_-delete-dialog.component.html',
'entities/_entityFolder_/update/_entityFile_-update.component.ts',
'entities/_entityFolder_/delete/_entityFile_-delete-dialog.component.ts',
'entities/_entityFolder_/delete/_entityFile_-delete-dialog.component.spec.ts',
],
},
],
Expand Down
54 changes: 45 additions & 9 deletions generators/app/__snapshots__/generator.spec.mts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ exports[`generator - app help should print expected information 1`] = `
Options:
--auto-crlf Detect line endings
--defaults Execute jhipster with default config
--application-type <value> Application type to generate
--skip-client Skip the client-side application generation
--skip-server Skip the server-side application generation
--skip-commit-hook Skip adding husky commit hooks
Expand All @@ -29,8 +28,8 @@ Options:
-l, --language <value...> Language to be added to application (existing languages are not removed)
--pk-type <value> Default primary key type (beta)
--client-package-manager <value> Force an unsupported client package manager
--microfrontend Force generation of experimental microfrontend support
--test-frameworks <value...> Test frameworks to be generated
--application-type <value> Application type to generate (choices: "monolith", "gateway", "microservice")
--skip-cache Do not remember prompt answers (default: false)
--skip-install Do not automatically install dependencies (default: false)
--force-install Fail on install dependencies error (default: false)
Expand All @@ -48,9 +47,10 @@ Options:
--jhipster-dependencies-version <value> jhipster-dependencies version to use, this option is not persisted (env: JHIPSTER_DEPENDENCIES_VERSION)
--with-generated-flag Add a GeneratedByJHipster annotation to all generated java classes and interfaces
--dev-database-type <value> Development database
--client-framework <value> Provide client framework for the application
--prettier-tab-width <value> Default tab width for prettier
--client-framework <value> Provide client framework for the application (choices: "angular", "react", "vue", "no")
--microfrontend Enable microfrontend support
--with-admin-ui Generate administrative user interface
--prettier-tab-width <value> Default tab width for prettier
--skip-git Skip git repository initialization
--monorepository Use monorepository
--cypress-coverage Enable Cypress code coverage report generation
Expand Down Expand Up @@ -94,6 +94,8 @@ exports[`generator - app with default config should match snapshot 1`] = `
"authenticationTypeSession": false,
"authenticationUsesCsrf": false,
"backendType": "Java",
"backendTypeJavaAny": true,
"backendTypeSpringBoot": true,
"baseName": "jhipster",
"blueprints": [],
"buildTool": "maven",
Expand Down Expand Up @@ -154,6 +156,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
"devDatabaseTypeMysql": false,
"devDatabaseTypeOracle": false,
"devDatabaseTypePostgres": true,
"devDatabaseTypePostgresql": true,
"devDatabaseUsername": "jhipster",
"devHibernateDialect": "org.hibernate.dialect.PostgreSQLDialect",
"devJdbcDriver": "org.postgresql.Driver",
Expand Down Expand Up @@ -313,6 +316,13 @@ exports[`generator - app with default config should match snapshot 1`] = `
"humanizedBaseName": "JHipster",
"imperativeOrReactive": "imperative",
"incrementalChangelog": undefined,
"javaCompatibleVersions": [
"17",
"18",
"19",
"20",
"21",
],
"javaDependencies": {
"archunit-junit5": "'ARCHUNIT-JUNIT-5-VERSION'",
"awaitility": "'AWAITILITY-VERSION'",
Expand Down Expand Up @@ -375,6 +385,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
},
"javaPackageSrcDir": "src/main/java/com/mycompany/myapp/",
"javaPackageTestDir": "src/test/java/com/mycompany/myapp/",
"javaVersion": "JAVA_VERSION",
"jhiPrefix": "jhi",
"jhiPrefixCapitalized": "Jhi",
"jhiPrefixDashed": "jhi",
Expand Down Expand Up @@ -409,6 +420,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
"rtl": false,
},
],
"liquibaseAddH2Properties": false,
"liquibaseDefaultSchemaName": "",
"lowercaseBaseName": "jhipster",
"mainClass": "JhipsterApp",
Expand Down Expand Up @@ -550,7 +562,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
"prodDatabaseTypeMssql": false,
"prodDatabaseTypeMysql": false,
"prodDatabaseTypeOracle": false,
"prodDatabaseTypePostgres": true,
"prodDatabaseTypePostgresql": true,
"prodDatabaseUsername": "jhipster",
"prodHibernateDialect": "org.hibernate.dialect.PostgreSQLDialect",
"prodJdbcDriver": "org.postgresql.Driver",
Expand All @@ -571,7 +583,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
"serviceDiscoveryEureka": false,
"serviceDiscoveryType": "no",
"skipCheckLengthOfIdentifier": false,
"skipClient": false,
"skipClient": undefined,
"skipCommitHook": undefined,
"skipFakeData": false,
"skipJhipsterDependencies": false,
Expand Down Expand Up @@ -634,6 +646,8 @@ exports[`generator - app with gateway should match snapshot 1`] = `
"authenticationTypeSession": false,
"authenticationUsesCsrf": false,
"backendType": "Java",
"backendTypeJavaAny": true,
"backendTypeSpringBoot": true,
"baseName": "jhipster",
"blueprints": [],
"buildTool": "maven",
Expand Down Expand Up @@ -694,6 +708,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
"devDatabaseTypeMysql": false,
"devDatabaseTypeOracle": false,
"devDatabaseTypePostgres": true,
"devDatabaseTypePostgresql": true,
"devDatabaseUsername": "jhipster",
"devHibernateDialect": "org.hibernate.dialect.PostgreSQLDialect",
"devJdbcDriver": "org.postgresql.Driver",
Expand Down Expand Up @@ -853,6 +868,13 @@ exports[`generator - app with gateway should match snapshot 1`] = `
"humanizedBaseName": "JHipster",
"imperativeOrReactive": "reactive",
"incrementalChangelog": undefined,
"javaCompatibleVersions": [
"17",
"18",
"19",
"20",
"21",
],
"javaDependencies": {
"archunit-junit5": "'ARCHUNIT-JUNIT-5-VERSION'",
"awaitility": "'AWAITILITY-VERSION'",
Expand Down Expand Up @@ -915,6 +937,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
},
"javaPackageSrcDir": "src/main/java/com/mycompany/myapp/",
"javaPackageTestDir": "src/test/java/com/mycompany/myapp/",
"javaVersion": "JAVA_VERSION",
"jhiPrefix": "jhi",
"jhiPrefixCapitalized": "Jhi",
"jhiPrefixDashed": "jhi",
Expand Down Expand Up @@ -949,6 +972,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
"rtl": false,
},
],
"liquibaseAddH2Properties": false,
"liquibaseDefaultSchemaName": "",
"lowercaseBaseName": "jhipster",
"mainClass": "JhipsterApp",
Expand Down Expand Up @@ -1090,7 +1114,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
"prodDatabaseTypeMssql": false,
"prodDatabaseTypeMysql": false,
"prodDatabaseTypeOracle": false,
"prodDatabaseTypePostgres": true,
"prodDatabaseTypePostgresql": true,
"prodDatabaseUsername": "jhipster",
"prodHibernateDialect": "org.hibernate.dialect.PostgreSQLDialect",
"prodJdbcDriver": "org.postgresql.Driver",
Expand All @@ -1112,7 +1136,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
"serviceDiscoveryEureka": false,
"serviceDiscoveryType": "consul",
"skipCheckLengthOfIdentifier": false,
"skipClient": false,
"skipClient": undefined,
"skipCommitHook": undefined,
"skipFakeData": false,
"skipJhipsterDependencies": false,
Expand Down Expand Up @@ -1174,6 +1198,8 @@ exports[`generator - app with microservice should match snapshot 1`] = `
"authenticationTypeSession": false,
"authenticationUsesCsrf": false,
"backendType": "Java",
"backendTypeJavaAny": true,
"backendTypeSpringBoot": true,
"baseName": "jhipster",
"blueprints": [],
"buildTool": "maven",
Expand Down Expand Up @@ -1234,6 +1260,7 @@ exports[`generator - app with microservice should match snapshot 1`] = `
"devDatabaseTypeMysql": false,
"devDatabaseTypeOracle": false,
"devDatabaseTypePostgres": true,
"devDatabaseTypePostgresql": true,
"devDatabaseUsername": "jhipster",
"devHibernateDialect": "org.hibernate.dialect.PostgreSQLDialect",
"devJdbcDriver": "org.postgresql.Driver",
Expand Down Expand Up @@ -1393,6 +1420,13 @@ exports[`generator - app with microservice should match snapshot 1`] = `
"humanizedBaseName": "JHipster",
"imperativeOrReactive": "imperative",
"incrementalChangelog": undefined,
"javaCompatibleVersions": [
"17",
"18",
"19",
"20",
"21",
],
"javaDependencies": {
"archunit-junit5": "'ARCHUNIT-JUNIT-5-VERSION'",
"awaitility": "'AWAITILITY-VERSION'",
Expand Down Expand Up @@ -1455,6 +1489,7 @@ exports[`generator - app with microservice should match snapshot 1`] = `
},
"javaPackageSrcDir": "src/main/java/com/mycompany/myapp/",
"javaPackageTestDir": "src/test/java/com/mycompany/myapp/",
"javaVersion": "JAVA_VERSION",
"jhiPrefix": "jhi",
"jhiPrefixCapitalized": "Jhi",
"jhiPrefixDashed": "jhi",
Expand Down Expand Up @@ -1489,6 +1524,7 @@ exports[`generator - app with microservice should match snapshot 1`] = `
"rtl": false,
},
],
"liquibaseAddH2Properties": false,
"liquibaseDefaultSchemaName": "",
"lowercaseBaseName": "jhipster",
"mainClass": "JhipsterApp",
Expand Down Expand Up @@ -1575,7 +1611,7 @@ exports[`generator - app with microservice should match snapshot 1`] = `
"prodDatabaseTypeMssql": false,
"prodDatabaseTypeMysql": false,
"prodDatabaseTypeOracle": false,
"prodDatabaseTypePostgres": true,
"prodDatabaseTypePostgresql": true,
"prodDatabaseUsername": "jhipster",
"prodHibernateDialect": "org.hibernate.dialect.PostgreSQLDialect",
"prodJdbcDriver": "org.postgresql.Driver",
Expand Down
25 changes: 15 additions & 10 deletions generators/app/command.mts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import chalk from 'chalk';
import { JHipsterCommandDefinition } from '../base/api.mjs';
import {
GENERATOR_BOOTSTRAP,
Expand All @@ -26,18 +27,14 @@ import {
GENERATOR_LANGUAGES,
GENERATOR_SERVER,
} from '../generator-list.mjs';
import { APPLICATION_TYPE_GATEWAY, APPLICATION_TYPE_MICROSERVICE, APPLICATION_TYPE_MONOLITH } from '../../jdl/index.js';

const command: JHipsterCommandDefinition = {
options: {
defaults: {
description: 'Execute jhipster with default config',
type: Boolean,
},
applicationType: {
description: 'Application type to generate',
type: String,
scope: 'storage',
},
skipClient: {
description: 'Skip the client-side application generation',
type: Boolean,
Expand Down Expand Up @@ -136,16 +133,24 @@ const command: JHipsterCommandDefinition = {
type: String,
scope: 'storage',
},
microfrontend: {
description: 'Force generation of experimental microfrontend support',
type: Boolean,
scope: 'storage',
},
testFrameworks: {
description: 'Test frameworks to be generated',
type: Array,
},
},
configs: {
applicationType: {
description: 'Application type to generate',
cli: {
type: String,
},
prompt: {
type: 'list',
message: `Which ${chalk.yellow('*type*')} of application would you like to create?`,
},
choices: [APPLICATION_TYPE_MONOLITH, APPLICATION_TYPE_GATEWAY, APPLICATION_TYPE_MICROSERVICE],
},
},
loadGeneratorOptions: true,
import: [
GENERATOR_BOOTSTRAP,
Expand Down
Loading

0 comments on commit b1e893e

Please sign in to comment.