UNPKG

ds-sfcoe-ailabs

Version:

AI-powered code review tool with static analysis integration for comprehensive code quality assessment.

47 lines (46 loc) 1.45 kB
import { GitHub } from './index.js'; /** * Factory class for creating Git provider instances * * Provides a centralized way to create appropriate Git provider implementations * based on the specified provider type. Currently supports GitHub providers. * * @example * ```typescript * const provider = GitProviderFactory.createProvider('github', 'owner', 'repo', 'token'); * await provider.upsertPRComment({ * pullRequestId: 123, * message: 'Review complete' * }); * ``` */ export default class GitProviderFactory { /** * Gets a git provider instance * * @param type - The type of Git provider to create * @param token - The authentication token for the provider * @param owner - The repository owner/organization name * @param repo - The repository name * @returns An instance of the specified Git provider * @throws Error when the provider type is unsupported * @example * ```typescript * const provider = GitProviderFactory.getInstance( * GitProviderType.GitHub, * 'token123', * 'myorg', * 'myrepo' * ); * await provider.upsertPRComment({...}); * ``` */ static getInstance(type, token, owner, repo) { switch (type) { case 'GitHub': return new GitHub(token, owner, repo); default: throw new Error(`Unsupported git provider type: ${type}`); } } }