import BaseApplicationGenerator from '../base-application/index.mjs';
import { GENERATOR_SPRING_WEBSOCKET, GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs';
import writeTask from './files.mjs';
import cleanupTask from './cleanup.mjs';
export default class SpringWebsocketGenerator extends BaseApplicationGenerator {
    async beforeQueue() {
        if (!this.fromBlueprint) {
            await this.composeWithBlueprints(GENERATOR_SPRING_WEBSOCKET);
        }
        if (!this.delegateToBlueprint) {
            await this.dependsOnJHipster(GENERATOR_BOOTSTRAP_APPLICATION);
        }
    }
    get writing() {
        return this.asWritingTaskGroup({
            cleanupTask,
            writeTask,
        });
    }
    get [BaseApplicationGenerator.WRITING]() {
        return this.delegateTasksToBlueprint(() => this.writing);
    }
    get postWriting() {
        return this.asPostWritingTaskGroup({
            addDependencies({ application, source }) {
                if (application.buildToolMaven) {
                    source.addMavenDefinition?.({
                        dependencies: [
                            { groupId: 'org.springframework.boot', artifactId: 'spring-boot-starter-websocket' },
                            { groupId: 'org.springframework.security', artifactId: 'spring-security-messaging' },
                        ],
                    });
                }
            },
        });
    }
    get [BaseApplicationGenerator.POST_WRITING]() {
        return this.delegateTasksToBlueprint(() => this.postWriting);
    }
}
