All files / backend/dist/ssg-providers provider-factory.js

0% Statements 0/17
100% Branches 0/0
0% Functions 0/11
0% Lines 0/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86                                                                                                                                                                           
/**
 * Provider Factory
 *
 * Factory for creating SSG provider instances and components.
 * Similar to SyncFactory pattern.
 */
import { ProviderRegistry } from './provider-registry.js';
/**
 * Provider Factory - Main entry point for working with SSG providers
 */
export class ProviderFactory {
    registry;
    initPromise;
    constructor(dependencies) {
        this.registry = new ProviderRegistry(dependencies);
        // Register built-in providers (Hugo, etc.) - async to handle dynamic imports
        this.initPromise = this.registry.registerBuiltInProviders();
    }
    /**
     * Set container reference after construction (to break circular dependency)
     */
    setContainer(container) {
        this.registry.setContainer(container);
    }
    /**
     * Ensure providers are initialized
     * Called internally before provider access
     */
    async ensureInitialized() {
        await this.initPromise;
    }
    /**
     * Get provider instance by type
     */
    async getProvider(ssgType) {
        await this.ensureInitialized();
        return this.registry.getProvider(ssgType);
    }
    /**
     * Get provider registry for advanced operations
     */
    getRegistry() {
        return this.registry;
    }
    /**
     * Create a dev server for the given SSG type
     */
    async createDevServer(ssgType, config) {
        const provider = await this.getProvider(ssgType);
        return provider.createDevServer(config);
    }
    /**
     * Create a builder for the given SSG type
     */
    async createBuilder(ssgType, config) {
        const provider = await this.getProvider(ssgType);
        return provider.createBuilder(config);
    }
    /**
     * Get binary manager for the given SSG type (if applicable)
     */
    async getBinaryManager(ssgType) {
        const provider = await this.getProvider(ssgType);
        return provider.getBinaryManager();
    }
    /**
     * Auto-detect SSG type from workspace
     */
    async detectSSGType(workspacePath) {
        return this.registry.detectSSGType(workspacePath);
    }
    /**
     * Get all available provider metadata
     */
    getAllProviderMetadata() {
        return this.registry.getAllProviderMetadata();
    }
    /**
     * Check if a provider type is available
     */
    async hasProvider(ssgType) {
        await this.ensureInitialized();
        return this.registry.hasProvider(ssgType);
    }
}