Skip to content

Commit

Permalink
more lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Tcharl committed Sep 14, 2024
1 parent 55d8df8 commit 371ef8f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
6 changes: 3 additions & 3 deletions generators/spring-boot/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ export default asWritingTask(function cleanupTask(this, taskParam) {
}
if (
application.databaseTypeSql ||
(application as any).cacheProviderRedis ||
application.cacheProviderRedis ||
application.databaseTypeMongodb ||
application.databaseTypeCassandra ||
(application as any).searchEngineElasticsearch ||
application.searchEngineElasticsearch ||
application.databaseTypeCouchbase ||
(application as any).searchEngineCouchbase ||
application.searchEngineCouchbase ||
application.databaseTypeNeo4j
) {
// The condition is too complated, delete and recreate.
Expand Down
20 changes: 11 additions & 9 deletions generators/spring-boot/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ import chalk from 'chalk';
import type { JHipsterCommandDefinition } from '../../lib/command/index.js';
import { GENERATOR_JAVA, GENERATOR_LIQUIBASE, GENERATOR_SPRING_DATA_RELATIONAL } from '../generator-list.js';
import { createBase64Secret, createSecret } from '../base/support/secret.js';
import { applicationTypes, authenticationTypes } from '../../lib/jhipster/index.js';
import { applicationTypes, authenticationTypes, databaseTypes, serviceDiscoveryTypes } from '../../lib/jhipster/index.js';

const { OAUTH2, SESSION, JWT } = authenticationTypes;
const { CONSUL, EUREKA, NO: NO_SERVICE_DISCOVERY } = serviceDiscoveryTypes;
const { GATEWAY, MICROSERVICE } = applicationTypes;
const { SQL, NO: NO_DATABASE, MONGODB, COUCHBASE, CASSANDRA, NEO4J } = databaseTypes;

const command = {
options: {
Expand Down Expand Up @@ -73,12 +75,12 @@ const command = {
when: () => ['gateway', 'microservice'].includes(gen.jhipsterConfigWithDefaults.applicationType),
type: 'list',
message: 'Which service discovery server do you want to use?',
default: 'consul',
default: CONSUL,
}),
choices: [
{ value: 'consul', name: 'Consul (recommended)' },
{ value: 'eureka', name: 'JHipster Registry (legacy, uses Eureka, provides Spring Cloud Config support)' },
{ value: 'no', name: 'No service discovery' },
{ value: CONSUL, name: 'Consul (recommended)' },
{ value: EUREKA, name: 'JHipster Registry (legacy, uses Eureka, provides Spring Cloud Config support)' },
{ value: NO_SERVICE_DISCOVERY, name: 'No service discovery' },
],
scope: 'storage',
},
Expand All @@ -98,9 +100,9 @@ const command = {
default: () => gen.jhipsterConfigWithDefaults.authenticationType,
}),
choices: [
{ value: 'jwt', name: 'JWT authentication (stateless, with a token)' },
{ value: 'oauth2', name: 'OAuth 2.0 / OIDC Authentication (stateful, works with Keycloak and Okta)' },
{ value: 'session', name: 'HTTP Session Authentication (stateful, default Spring Security mechanism)' },
{ value: JWT, name: 'JWT authentication (stateless, with a token)' },
{ value: OAUTH2, name: 'OAuth 2.0 / OIDC Authentication (stateful, works with Keycloak and Okta)' },
{ value: SESSION, name: 'HTTP Session Authentication (stateful, default Spring Security mechanism)' },
],
configure: gen => {
const { jwtSecretKey, rememberMeKey, authenticationType, applicationType } = gen.jhipsterConfigWithDefaults;
Expand Down Expand Up @@ -177,7 +179,7 @@ const command = {
type: String,
hide: true,
},
choices: ['sql', 'mongodb', 'couchbase', 'cassandra', 'neo4j', 'no'],
choices: [SQL, MONGODB, COUCHBASE, CASSANDRA, NEO4J, NO_DATABASE],
scope: 'storage',
},
},
Expand Down
26 changes: 15 additions & 11 deletions generators/spring-boot/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,14 +430,13 @@ public void set${javaBeanCase(propertyName)}(${propertyType} ${propertyName}) {
}
},
prepareFilters({ application, entity }) {
(entity as any).entityJavaFilterableProperties = [
...entity.fields.filter(field => field.filterableField),
...entity.relationships.filter(rel => !application.reactive || (rel.persistableRelationship && !rel.collection)),
];
(entity as any).entityJavaCustomFilters = sortedUniqBy(
entity.fields.map(field => field.propertyJavaCustomFilter).filter(Boolean),
'type',
);
mutateData(entity, {
entityJavaFilterableProperties: [
...entity.fields.filter(field => field.filterableField),
...entity.relationships.filter(rel => !application.reactive || (rel.persistableRelationship && !rel.collection)),
],
entityJavaCustomFilters: sortedUniqBy(entity.fields.map(field => field.propertyJavaCustomFilter).filter(Boolean), 'type'),
});
},
});
}
Expand Down Expand Up @@ -487,9 +486,14 @@ public void set${javaBeanCase(propertyName)}(${propertyType} ${propertyName}) {
get postWriting() {
return this.asPostWritingTaskGroup({
addJHipsterBomDependencies({ application, source }) {
const { applicationTypeGateway, applicationTypeMicroservice, javaDependencies, jhipsterDependenciesVersion, messageBrokerAny } =
application;
const { serviceDiscoveryAny } = application as any;
const {
applicationTypeGateway,
applicationTypeMicroservice,
javaDependencies,
jhipsterDependenciesVersion,
messageBrokerAny,
serviceDiscoveryAny,
} = application;

source.addJavaDefinitions?.(
{
Expand Down
2 changes: 1 addition & 1 deletion generators/spring-boot/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export async function askForServerSideOpts(this: CoreGenerator, { control }) {
});
}
opts.push({
value: 'couchbase',
value: COUCHBASE,
name: '[BETA] Couchbase',
});
opts.push({
Expand Down

0 comments on commit 371ef8f

Please sign in to comment.