diff --git a/generators/app/command.ts b/generators/app/command.ts index ad62dbdc56c..cc8e50bdec6 100644 --- a/generators/app/command.ts +++ b/generators/app/command.ts @@ -28,7 +28,7 @@ import { GENERATOR_SERVER, } from '../generator-list.js'; -const command: JHipsterCommandDefinition = { +const command = { options: { defaults: { description: 'Execute jhipster with default config', @@ -97,6 +97,6 @@ const command: JHipsterCommandDefinition = { GENERATOR_CYPRESS, GENERATOR_LANGUAGES, ], -}; +} as const satisfies JHipsterCommandDefinition; export default command; diff --git a/generators/base-application/generator.ts b/generators/base-application/generator.ts index 6c7ec2d5842..a799a9faa05 100644 --- a/generators/base-application/generator.ts +++ b/generators/base-application/generator.ts @@ -33,6 +33,7 @@ import type { TaskTypes as DefaultTaskTypes } from '../../lib/types/application/ import type { ApplicationType } from '../../lib/types/application/application.js'; import type { Entity } from '../../lib/types/application/entity.js'; import type { GenericTaskGroup } from '../../lib/types/base/tasks.js'; +import type { ApplicationConfiguration } from '../../lib/types/application/yo-rc.js'; import { getEntitiesFromDir } from './support/index.js'; import { CUSTOM_PRIORITIES, PRIORITY_NAMES, QUEUES } from './priorities.js'; @@ -93,6 +94,8 @@ export default class BaseApplicationGenerator< static POST_WRITING_ENTITIES = asPriority(POST_WRITING_ENTITIES); + declare jhipsterConfig: ApplicationConfiguration & Record; + constructor(args: string | string[], options: JHipsterGeneratorOptions, features: JHipsterGeneratorFeatures) { super(args, options, features); diff --git a/generators/base-core/generator.ts b/generators/base-core/generator.ts index 747fe1241ab..ca7b61f42db 100644 --- a/generators/base-core/generator.ts +++ b/generators/base-core/generator.ts @@ -68,6 +68,7 @@ import { getConfigWithDefaults } from '../../jdl/jhipster/index.js'; import { extractArgumentsFromConfigs } from '../../lib/command/index.js'; import type { Entity } from '../../lib/types/base/entity.js'; import type BaseApplicationGenerator from '../base-application/generator.js'; +import type { ApplicationConfiguration } from '../../lib/types/application/yo-rc.js'; const { INITIALIZING, @@ -246,7 +247,7 @@ export default class CoreGenerator extends YeomanGenerator> { const configWithDefaults = getConfigWithDefaults(removeFieldsWithNullishValues(this.config.getAll())); defaults(configWithDefaults, { skipFakeData: false, diff --git a/generators/client/command.ts b/generators/client/command.ts index 5247c1bb65b..3e6ea73ddd4 100644 --- a/generators/client/command.ts +++ b/generators/client/command.ts @@ -135,8 +135,6 @@ const command = { }, }, import: [GENERATOR_COMMON], -} as const; +} as const satisfies JHipsterCommandDefinition; -export type Command = typeof command; - -export default command as JHipsterCommandDefinition; +export default command; diff --git a/generators/client/prompts.ts b/generators/client/prompts.ts index 0438d5bf65d..c256cf44e73 100644 --- a/generators/client/prompts.ts +++ b/generators/client/prompts.ts @@ -29,7 +29,7 @@ export const askForClientTheme = asPromptingTask(async function askForClientThem { type: 'list', name: 'clientTheme', - when: () => ['angular', 'react', 'vue'].includes(config.clientFramework), + when: () => ['angular', 'react', 'vue'].includes(config.clientFramework!), message: 'Would you like to use a Bootswatch theme (https://bootswatch.com/)?', choices: async () => { const bootswatchChoices = await retrieveOnlineBootswatchThemes().catch(errorMessage => { diff --git a/generators/client/types.d.ts b/generators/client/types.d.ts index f34232071d5..9ff5815d95a 100644 --- a/generators/client/types.d.ts +++ b/generators/client/types.d.ts @@ -1,13 +1,12 @@ import type { addIconImport, addItemToMenu, addRoute } from '../angular/support/needles.js'; import type { AngularApplication } from '../angular/types.js'; -import type { ExportApplicationPropertiesFromCommand, ExportStoragePropertiesFromCommand } from '../../lib/command/index.js'; +import type { ExportApplicationPropertiesFromCommand } from '../../lib/command/index.js'; import type { CypressApplication } from '../cypress/types.js'; import type { JavaScriptApplication, JavaScriptSourceType } from '../javascript/types.js'; import type { PostWritingEntitiesTaskParam } from '../../lib/types/application/tasks.js'; -import type { Command } from './command.ts'; +import type Command from './command.ts'; -export type StoredClientProperties = ExportStoragePropertiesFromCommand; -type ApplicationClientProperties = ExportApplicationPropertiesFromCommand; +type ApplicationClientProperties = ExportApplicationPropertiesFromCommand; export type ClientApplication = ApplicationClientProperties & JavaScriptApplication & diff --git a/generators/spring-boot/command.ts b/generators/spring-boot/command.ts index e6941e57bef..bb7e28157e7 100644 --- a/generators/spring-boot/command.ts +++ b/generators/spring-boot/command.ts @@ -25,7 +25,7 @@ import { applicationTypes, authenticationTypes } from '../../jdl/jhipster/index. const { OAUTH2, SESSION, JWT } = authenticationTypes; const { GATEWAY, MICROSERVICE } = applicationTypes; -const command: JHipsterCommandDefinition = { +const command = { options: { fakeKeytool: { description: 'Add a fake certificate store file for test purposes', @@ -46,6 +46,7 @@ const command: JHipsterCommandDefinition = { type: 'confirm', message: 'Do you want to make it reactive with Spring WebFlux?', }), + scope: 'storage', }, serverPort: { prompt: gen => ({ @@ -61,6 +62,7 @@ const command: JHipsterCommandDefinition = { gen.jhipsterConfig.serverPort = 8080 + gen.jhipsterConfig.applicationIndex; } }, + scope: 'storage', }, serviceDiscoveryType: { cli: { @@ -78,6 +80,7 @@ const command: JHipsterCommandDefinition = { { value: 'eureka', name: 'JHipster Registry (legacy, uses Eureka, provides Spring Cloud Config support)' }, { value: 'no', name: 'No service discovery' }, ], + scope: 'storage', }, authenticationType: { cli: { @@ -112,6 +115,7 @@ const command: JHipsterCommandDefinition = { gen.jhipsterConfig.jwtSecretKey = createBase64Secret(64, gen.options.reproducibleTests); } }, + scope: 'storage', }, feignClient: { description: 'Generate a feign client', @@ -130,6 +134,7 @@ const command: JHipsterCommandDefinition = { tokenType: 'BOOLEAN', }, default: false, + scope: 'storage', }, syncUserWithIdp: { description: 'Allow relationships with User for oauth2 applications', @@ -150,6 +155,7 @@ const command: JHipsterCommandDefinition = { throw new Error('syncUserWithIdp is only supported with authenticationType oauth2'); } }, + scope: 'storage', }, defaultPackaging: { description: 'Default packaging for the application', @@ -168,6 +174,6 @@ const command: JHipsterCommandDefinition = { }, }, import: [GENERATOR_JAVA, GENERATOR_LIQUIBASE, GENERATOR_SPRING_DATA_RELATIONAL], -}; +} as const satisfies JHipsterCommandDefinition; export default command; diff --git a/lib/command/types.d.ts b/lib/command/types.d.ts index 0e333b3fde3..b114b354b12 100644 --- a/lib/command/types.d.ts +++ b/lib/command/types.d.ts @@ -198,7 +198,7 @@ type ExplodeCommandChoicesNoInference = { }; type PrepareConfigsWithType = Simplify<{ - [K in keyof U]?: U[K] extends Record<'choices', JHispterChoices> + -readonly [K in keyof U]?: U[K] extends Record<'choices', JHispterChoices> ? TupleToUnion> : WrapperToPrimitive>> extends infer T ? T extends undefined diff --git a/lib/types/application/yo-rc.d.ts b/lib/types/application/yo-rc.d.ts new file mode 100644 index 00000000000..0c20dfe7e28 --- /dev/null +++ b/lib/types/application/yo-rc.d.ts @@ -0,0 +1,11 @@ +/* eslint-disable @typescript-eslint/consistent-type-imports */ +import { Simplify } from 'type-fest'; +import type { ExportStoragePropertiesFromCommand } from '../../command/types.js'; + +export type ApplicationConfiguration = Simplify< + { + jhipsterVersion: string; + baseName: string; + } & ExportStoragePropertiesFromCommand & + ExportStoragePropertiesFromCommand +>;