import { join } from 'node:path';
export class WriteInitConfigUseCase {
    deps;
    constructor(deps) {
        this.deps = deps;
    }
    execute(input) {
        this.deps.mkdirSync(input.configDir, { recursive: true });
        const configPath = join(input.configDir, 'config.json');
        const envPath = join(input.configDir, '.env');
        const config = {
            server: { port: input.port },
            user: {
                gitlabUsername: input.gitlabUsername,
                githubUsername: input.githubUsername,
            },
            queue: {
                maxConcurrent: 2,
                deduplicationWindowMs: 300000,
            },
            repositories: input.repositories.map(repo => ({
                name: repo.name,
                localPath: repo.localPath,
                enabled: repo.enabled,
            })),
        };
        this.deps.writeFileSync(configPath, JSON.stringify(config, null, 2));
        const envContent = [
            `GITLAB_WEBHOOK_TOKEN=${input.gitlabWebhookSecret}`,
            `GITHUB_WEBHOOK_SECRET=${input.githubWebhookSecret}`,
            '',
        ].join('\n');
        this.deps.writeFileSync(envPath, envContent);
        return { configPath, envPath };
    }
}
//# sourceMappingURL=writeInitConfig.usecase.js.map