import BaseApplicationGenerator from "../base-simple-application/index.js";
import { ciCdGeneratorNamespace } from "./support/providers.js";
export default class CiCdGenerator extends BaseApplicationGenerator {
    async beforeQueue() {
        if (!this.fromBlueprint) {
            await this.composeWithBlueprints();
        }
        await this.dependsOnBootstrap('ci-cd');
        if (!this.delegateToBlueprint && this.options.commandName === 'ci-cd') {
            const { backendType = 'Java' } = this.jhipsterConfig;
            if (['Java', 'SpringBoot'].includes(backendType)) {
                await this.dependsOnBootstrap('java');
            }
        }
    }
    get composing() {
        return this.asComposingTaskGroup({
            async composeProviders() {
                if (this.context.ciCd?.length) {
                    const common = await this.composeWithJHipster('jhipster:ci-cd:common');
                    common.ciCd.push(...this.context.ciCd);
                    for (const ciCd of this.context.ciCd ?? []) {
                        await this.composeWithJHipster(ciCdGeneratorNamespace(ciCd));
                    }
                }
            },
        });
    }
    get [BaseApplicationGenerator.COMPOSING]() {
        return this.delegateTasksToBlueprint(() => this.composing);
    }
    get preparing() {
        return this.asPreparingTaskGroup({
            preparing({ applicationDefaults }) {
                applicationDefaults({
                    gitLabIndent: ({ sendBuildToGitlab }) => (sendBuildToGitlab ? '    ' : ''),
                    indent: ({ insideDocker, gitLabIndent }) => {
                        let indent = insideDocker ? '    ' : '';
                        indent += gitLabIndent;
                        return indent;
                    },
                    cypressTests: ({ testFrameworks }) => testFrameworks?.includes('cypress') ?? false,
                });
            },
        });
    }
    get [BaseApplicationGenerator.PREPARING]() {
        return this.delegateTasksToBlueprint(() => this.preparing);
    }
    shouldAskForPrompts() {
        return true;
    }
}
