import { XcodeBuilder } from './operations/XcodeBuilder.js';
import { XcodeTester } from './operations/XcodeTester.js';
import { XcodeCleaner } from './operations/XcodeCleaner.js';
import { createModuleLogger } from '../../logger.js';
import * as pathModule from 'path';
const logger = createModuleLogger('XcodeProject');
/**
 * Represents an Xcode project (.xcodeproj) or workspace (.xcworkspace)
 * Implements Project, Buildable, Testable, and Cleanable interfaces
 */
export class XcodeProject {
    path;
    name;
    type;
    isWorkspace;
    // Composed operations (Single Responsibility for each)
    builder;
    tester;
    cleaner;
    constructor(path, type, operations) {
        this.path = path;
        // Set type
        this.type = type === 'workspace' ? 'xcworkspace' : 'xcodeproj';
        this.isWorkspace = type === 'workspace';
        // Extract name from path
        const ext = type === 'workspace' ? '.xcworkspace' : '.xcodeproj';
        this.name = pathModule.basename(this.path, ext);
        // Initialize operations (Dependency Injection)
        this.builder = operations?.builder || new XcodeBuilder();
        this.tester = operations?.tester || new XcodeTester();
        this.cleaner = operations?.cleaner || new XcodeCleaner();
        logger.debug({ path: this.path, type, name: this.name }, 'XcodeProject created');
    }
    /**
     * Build the project
     */
    async build(options) {
        logger.info({ path: this.path, options }, 'Building Xcode project');
        return await this.builder.build(this.path, this.isWorkspace, options);
    }
    /**
     * Run tests for the project
     */
    async test(options) {
        logger.info({ path: this.path, options }, 'Testing Xcode project');
        return await this.tester.test(this.path, this.isWorkspace, options);
    }
    /**
     * Clean build artifacts
     */
    async clean(options) {
        logger.info({ path: this.path, options }, 'Cleaning Xcode project');
        await this.cleaner.clean(this.path, this.isWorkspace, options);
    }
}
//# sourceMappingURL=XcodeProject.js.map