diff --git a/.blueprint/generate-generator/templates/command.ts.ejs b/.blueprint/generate-generator/templates/command.ts.ejs index 2dbdefa750df..b014bcbaa807 100644 --- a/.blueprint/generate-generator/templates/command.ts.ejs +++ b/.blueprint/generate-generator/templates/command.ts.ejs @@ -18,9 +18,9 @@ */ import type { JHipsterCommandDefinition } from '<%- generatorRelativePath %>base/api.js'; -const command: JHipsterCommandDefinition = { +const command = { configs: {}, import: [], -}; +} as const satisfies JHipsterCommandDefinition; export default command; diff --git a/eslint.config.js b/eslint.config.js index 6d01d6c24ac2..906b9c489982 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -29,6 +29,7 @@ export default ts.config( }, rules: { '@typescript-eslint/consistent-type-imports': 'error', + '@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/ban-ts-comment': ['off', { 'ts-nocheck': true }], '@typescript-eslint/consistent-type-definitions': 'off', '@typescript-eslint/no-empty-function': 'off', diff --git a/generators/angular/generator.ts b/generators/angular/generator.ts index b3ea7497a819..5e8cd9047611 100644 --- a/generators/angular/generator.ts +++ b/generators/angular/generator.ts @@ -234,8 +234,8 @@ export default class AngularGenerator extends BaseApplicationGenerator { get writing() { return this.asWritingTaskGroup({ - cleanup({ control }) { - control.cleanupFiles({ + async cleanup({ control }) { + await control.cleanupFiles({ '8.6.1': ['.eslintrc.json', '.eslintignore'], }); }, diff --git a/generators/base-core/generator.ts b/generators/base-core/generator.ts index b6e8226729b2..f44adcd8fb83 100644 --- a/generators/base-core/generator.ts +++ b/generators/base-core/generator.ts @@ -196,7 +196,7 @@ export default class CoreGenerator extends YeomanGenerator { - pool.destroy(); + async () => { + await pool.destroy(); }, ); }; diff --git a/generators/bootstrap/support/java-unused-imports-transform.ts b/generators/bootstrap/support/java-unused-imports-transform.ts index a3a240b0f7e3..b7c1352e34cf 100644 --- a/generators/bootstrap/support/java-unused-imports-transform.ts +++ b/generators/bootstrap/support/java-unused-imports-transform.ts @@ -44,8 +44,8 @@ export const createRemoveUnusedImportsTransform = function ( } } }, - () => { - pool.destroy(); + async () => { + await pool.destroy(); }, ); }; diff --git a/generators/bootstrap/support/prettier-support.ts b/generators/bootstrap/support/prettier-support.ts index 945c97c33e8a..3ff4947130bd 100644 --- a/generators/bootstrap/support/prettier-support.ts +++ b/generators/bootstrap/support/prettier-support.ts @@ -92,8 +92,8 @@ export const createPrettierTransform = async function ( this?.log?.warn?.(errorMessage); } }, - () => { - pool?.destroy(); + async () => { + await pool?.destroy(); }, ); }; diff --git a/generators/common/generator.ts b/generators/common/generator.ts index 32c10acbed31..6bda63fd4519 100644 --- a/generators/common/generator.ts +++ b/generators/common/generator.ts @@ -196,8 +196,8 @@ export default class CommonGenerator extends BaseApplicationGenerator { // Public API method used by the getter and also by Blueprints get writing() { return this.asWritingTaskGroup({ - cleanup({ application, control }) { - control.cleanupFiles({ + async cleanup({ application, control }) { + await control.cleanupFiles({ '7.1.1': [[!application.skipCommitHook, '.huskyrc']], '7.6.1': [[application.skipClient, 'npmw', 'npmw.cmd']], '8.0.0-rc.2': [[!application.skipCommitHook, '.lintstagedrc.js']], diff --git a/generators/docker-compose/generator.ts b/generators/docker-compose/generator.ts index 1d767c02ef2b..3d73977b185e 100644 --- a/generators/docker-compose/generator.ts +++ b/generators/docker-compose/generator.ts @@ -135,10 +135,10 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { get loadingWorkspaces() { return { - loadBaseDeployment({ deployment }) { + async loadBaseDeployment({ deployment }) { deployment.jwtSecretKey = this.jhipsterConfig.jwtSecretKey; - loadDockerDependenciesTask.call(this, { context: deployment }); + await loadDockerDependenciesTask.call(this, { context: deployment }); }, loadPlatformConfig({ deployment }) { this.loadDeploymentConfig({ deployment }); diff --git a/generators/generate-blueprint/command.ts b/generators/generate-blueprint/command.ts index 4d6ae7721a0e..4973b0446df6 100644 --- a/generators/generate-blueprint/command.ts +++ b/generators/generate-blueprint/command.ts @@ -31,7 +31,7 @@ import { SUB_GENERATORS, } from './constants.js'; -const command: JHipsterCommandDefinition = { +const command = { configs: { recreatePackageLock: { description: 'Recreate package lock', @@ -106,6 +106,6 @@ const command: JHipsterCommandDefinition = { }, }, import: [GENERATOR_INIT], -}; +} as const satisfies JHipsterCommandDefinition; export default command; diff --git a/generators/generate-blueprint/generator.ts b/generators/generate-blueprint/generator.ts index 389123b2195c..d2f29cbed949 100644 --- a/generators/generate-blueprint/generator.ts +++ b/generators/generate-blueprint/generator.ts @@ -144,6 +144,9 @@ export default class extends BaseGenerator { get composing() { return this.asComposingTaskGroup({ + storeCurrentVersion() { + this.storeCurrentJHipsterVersion(); + }, async compose() { if (this.jhipsterConfig[LOCAL_BLUEPRINT_OPTION]) return; const initGenerator = await this.composeWithJHipster(GENERATOR_INIT, { generatorOptions: { packageJsonType: 'module' } }); @@ -344,7 +347,7 @@ export default class extends BaseGenerator { get postInstall() { return this.asPostInstallTaskGroup({ - async addSnapshot() { + async addSnapshot({ control }) { const { [LOCAL_BLUEPRINT_OPTION]: localBlueprint } = this.jhipsterConfig; const { skipInstall, @@ -377,6 +380,21 @@ This is a new blueprint, executing '${chalk.yellow('npm run update-snapshot')}' } this.log.warn('Fail to generate snapshots'); } + + if (control.jhipsterOldVersion) { + // Apply prettier and eslint to fix non generated files on upgrade. + try { + await this.spawnCommand('npm', ['run', 'prettier-format']); + } catch { + // Ignore error + } + + try { + await this.spawnCommand('npm', ['run', 'lint-fix']); + } catch { + // Ignore error + } + } }, }); } diff --git a/generators/java/generators/openapi-generator/generator.ts b/generators/java/generators/openapi-generator/generator.ts index b98a3d3c35d8..752d70a9d304 100644 --- a/generators/java/generators/openapi-generator/generator.ts +++ b/generators/java/generators/openapi-generator/generator.ts @@ -34,8 +34,8 @@ export default class OpenapiGeneratorGenerator extends BaseApplicationGenerator get writing() { return this.asWritingTaskGroup({ - cleanup({ application, control }) { - control.cleanupFiles({ + async cleanup({ application, control }) { + await control.cleanupFiles({ '8.6.1': [[application.buildToolGradle!, 'gradle/swagger.gradle']], }); }, diff --git a/generators/javascript/generators/bootstrap/command.ts b/generators/javascript/generators/bootstrap/command.ts index 28de8ab124fc..cfdbedb71364 100644 --- a/generators/javascript/generators/bootstrap/command.ts +++ b/generators/javascript/generators/bootstrap/command.ts @@ -18,7 +18,7 @@ */ import type { JHipsterCommandDefinition } from '../../../../lib/command/index.js'; -const command: JHipsterCommandDefinition = { +const command = { configs: { packageJsonNodeEngine: { cli: { @@ -39,6 +39,6 @@ const command: JHipsterCommandDefinition = { }, }, import: [], -}; +} as const satisfies JHipsterCommandDefinition; export default command; diff --git a/generators/javascript/types.d.ts b/generators/javascript/types.d.ts index ddddcd46d69f..190c9ca53965 100644 --- a/generators/javascript/types.d.ts +++ b/generators/javascript/types.d.ts @@ -1,3 +1,8 @@ +import type { ExportApplicationPropertiesFromCommand } from '../../lib/command/types.js'; +import type JavascriptBootstrapCommand from './generators/bootstrap/command.ts'; + +type JavascriptBootstrapProperties = ExportApplicationPropertiesFromCommand; + export type JavaScriptSourceType = { mergePrettierConfig?: (config: Record) => void; addPrettierIgnore?: (newContent: string) => void; @@ -6,9 +11,8 @@ export type JavaScriptSourceType = { addEslintConfig?: (opts: { import?: string | string[]; config?: string | string[] }) => void; }; -export type JavaScriptApplication = { +export type JavaScriptApplication = JavascriptBootstrapProperties & { packageJsonNodeEngine?: boolean | string; - packageJsonType?: string; eslintConfigFile?: string; addPrettierExtensions?: (extensions: string[]) => void; diff --git a/generators/react/generator.ts b/generators/react/generator.ts index 24d041e48de8..ebf61fb5a8bc 100644 --- a/generators/react/generator.ts +++ b/generators/react/generator.ts @@ -155,8 +155,8 @@ export default class ReactGenerator extends BaseApplicationGenerator { get writing() { return this.asWritingTaskGroup({ - cleanup({ control }) { - control.cleanupFiles({ + async cleanup({ control }) { + await control.cleanupFiles({ '8.6.1': ['.eslintrc.json', '.eslintignore'], }); }, diff --git a/generators/spring-boot/cleanup.ts b/generators/spring-boot/cleanup.ts index 846cdcf7b078..9303515105f3 100644 --- a/generators/spring-boot/cleanup.ts +++ b/generators/spring-boot/cleanup.ts @@ -25,7 +25,7 @@ import cleanupOauth2 from './cleanup-oauth2.js'; * Removes server files that where generated in previous JHipster versions and therefore * need to be removed. */ -export default asWritingTask(function cleanupTask(this, taskParam) { +export default asWritingTask(async function cleanupTask(this, taskParam) { const { application, control } = taskParam; if (application.authenticationTypeOauth2) { cleanupOauth2.call(this, taskParam); @@ -209,7 +209,7 @@ export default asWritingTask(function cleanupTask(this, taskParam) { this.removeFile(`${application.javaPackageSrcDir}config/LocaleConfiguration.java`); } - control.cleanupFiles({ + await control.cleanupFiles({ '8.6.1': [[application.authenticationTypeOauth2!, `${application.javaPackageSrcDir}security/oauth2/JwtGrantedAuthorityConverter.java`]], }); }); diff --git a/generators/spring-cloud/generators/gateway/generator.ts b/generators/spring-cloud/generators/gateway/generator.ts index d95dbac395c1..285692171d29 100644 --- a/generators/spring-cloud/generators/gateway/generator.ts +++ b/generators/spring-cloud/generators/gateway/generator.ts @@ -70,8 +70,8 @@ export default class GatewayGenerator extends BaseApplicationGenerator { get writing() { return this.asWritingTaskGroup({ - cleanup({ control, application }) { - control.cleanupFiles({ + async cleanup({ control, application }) { + await control.cleanupFiles({ '8.6.1': [ [ application.reactive && (application as any).serviceDiscoveryAny, diff --git a/generators/vue/generator.ts b/generators/vue/generator.ts index e2d65daa2091..8e174c41bdf0 100644 --- a/generators/vue/generator.ts +++ b/generators/vue/generator.ts @@ -145,8 +145,8 @@ export default class VueGenerator extends BaseApplicationGenerator { get writing() { return this.asWritingTaskGroup({ - cleanup({ control }) { - control.cleanupFiles({ + async cleanup({ control }) { + await control.cleanupFiles({ '8.6.1': ['.eslintrc.json', '.eslintignore'], }); }, diff --git a/lib/types/application/options.d.ts b/lib/types/application/options.d.ts index f65aeab19a61..a089c1ed9a1d 100644 --- a/lib/types/application/options.d.ts +++ b/lib/types/application/options.d.ts @@ -9,6 +9,7 @@ export type ApplicationOptions = Simplify< ExportGeneratorOptionsFromCommand & ExportGeneratorOptionsFromCommand & ExportGeneratorOptionsFromCommand & + ExportGeneratorOptionsFromCommand & ExportGeneratorOptionsFromCommand & ExportGeneratorOptionsFromCommand & ExportGeneratorOptionsFromCommand & diff --git a/lib/types/application/yo-rc.d.ts b/lib/types/application/yo-rc.d.ts index 9f67e2ee4604..909ba4e572e4 100644 --- a/lib/types/application/yo-rc.d.ts +++ b/lib/types/application/yo-rc.d.ts @@ -18,6 +18,7 @@ export type ApplicationConfiguration = Simplify< ExportStoragePropertiesFromCommand & ExportStoragePropertiesFromCommand & ExportStoragePropertiesFromCommand & + ExportStoragePropertiesFromCommand & ExportStoragePropertiesFromCommand & ExportStoragePropertiesFromCommand & ExportStoragePropertiesFromCommand &