import { SERVER_MAIN_SRC_DIR, SERVER_TEST_SRC_DIR, GRADLE_BUILD_SRC_MAIN_DIR } from '../generator-constants.js';
import { moveToJavaPackageSrcDir, moveToJavaPackageTestDir } from '../server/support/index.js';
export const kafkaFiles = {
    config: [
        {
            condition: data => data.buildToolGradle,
            path: GRADLE_BUILD_SRC_MAIN_DIR,
            templates: ['jhipster.kafka-conventions.gradle'],
        },
        {
            path: `${SERVER_MAIN_SRC_DIR}_package_/`,
            renameTo: moveToJavaPackageSrcDir,
            templates: [data => `broker/KafkaConsumer_${data.imperativeOrReactive}.java`, 'broker/KafkaProducer.java'],
        },
    ],
    resources: [
        {
            path: `${SERVER_MAIN_SRC_DIR}_package_/`,
            to: moveToJavaPackageSrcDir,
            templates: [
                {
                    sourceFile: data => `web/rest/KafkaResource_${data.imperativeOrReactive}.java`,
                    destinationFile: data => `web/rest/${data.upperFirstCamelCaseBaseName}KafkaResource.java`,
                },
            ],
        },
    ],
    test: [
        {
            path: `${SERVER_TEST_SRC_DIR}_package_/`,
            renameTo: moveToJavaPackageTestDir,
            templates: [
                'config/KafkaTestContainer.java',
                'config/EmbeddedKafka.java',
                'config/KafkaTestContainersSpringContextCustomizerFactory.java',
            ],
        },
        {
            path: `${SERVER_TEST_SRC_DIR}_package_/`,
            to: moveToJavaPackageTestDir,
            templates: [
                {
                    sourceFile: data => `web/rest/KafkaResourceIT_${data.imperativeOrReactive}.java`,
                    destinationFile: data => `web/rest/${data.upperFirstCamelCaseBaseName}KafkaResourceIT.java`,
                },
            ],
        },
    ],
};
export const pulsarFiles = {
    config: [
        {
            condition: data => data.buildToolGradle,
            path: GRADLE_BUILD_SRC_MAIN_DIR,
            templates: ['jhipster.pulsar-conventions.gradle'],
        },
    ],
    test: [
        {
            path: `${SERVER_TEST_SRC_DIR}_package_/`,
            renameTo: moveToJavaPackageTestDir,
            templates: [
                'broker/PulsarIT.java',
                'config/BrokerConfiguration.java',
                'config/EmbeddedPulsar.java',
                'config/PulsarTestContainer.java',
                'config/PulsarTestContainersSpringContextCustomizerFactory.java',
            ],
        },
    ],
};
export default async function writeFilesTask({ application }) {
    if (application.messageBrokerKafka) {
        await this.writeFiles({
            sections: kafkaFiles,
            context: application,
        });
    }
    if (application.messageBrokerPulsar) {
        await this.writeFiles({
            sections: pulsarFiles,
            context: application,
        });
    }
}
