- Add repository URL validation for GitHub, GitLab, Bitbucket, and custom hosts - Add git provider layer (listDirectory, downloadRawFile) for all providers - Wire githubJsonService and scriptDownloader to use provider; sync/download from any supported source - Update GeneralSettingsModal placeholder and help text; .env.example and env schema for GITLAB_TOKEN, BITBUCKET_APP_PASSWORD Closes #406
29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import type { DirEntry, GitProvider } from "./types";
|
|
import { getRepoProvider } from "../repositoryUrlValidation";
|
|
import { GitHubProvider } from "./github";
|
|
import { GitLabProvider } from "./gitlab";
|
|
import { BitbucketProvider } from "./bitbucket";
|
|
import { CustomProvider } from "./custom";
|
|
|
|
const providers: Record<string, GitProvider> = {
|
|
github: new GitHubProvider(),
|
|
gitlab: new GitLabProvider(),
|
|
bitbucket: new BitbucketProvider(),
|
|
custom: new CustomProvider(),
|
|
};
|
|
|
|
export type { DirEntry, GitProvider };
|
|
export { getRepoProvider };
|
|
|
|
export function getGitProvider(repoUrl: string): GitProvider {
|
|
return providers[getRepoProvider(repoUrl)]!;
|
|
}
|
|
|
|
export async function listDirectory(repoUrl: string, path: string, branch: string): Promise<DirEntry[]> {
|
|
return getGitProvider(repoUrl).listDirectory(repoUrl, path, branch);
|
|
}
|
|
|
|
export async function downloadRawFile(repoUrl: string, filePath: string, branch: string): Promise<string> {
|
|
return getGitProvider(repoUrl).downloadRawFile(repoUrl, filePath, branch);
|
|
}
|