@veecode-platform/plugin-kong-service-manager
Version:
44 lines (41 loc) • 1.49 kB
JavaScript
import { parseGitUrl } from '../utils/helpers/parseGitUrl.esm.js';
import { GithubManager } from './git-providers/Github.esm.js';
import { GitLabManager } from './git-providers/Gitlab.esm.js';
class GitManager {
constructor(scmAuthApi, configApi) {
this.scmAuthApi = scmAuthApi;
this.configApi = configApi;
this.githubManager = new GithubManager(this.scmAuthApi, this.configApi);
this.gitlabManager = new GitLabManager(this.scmAuthApi, this.configApi);
}
githubManager;
gitlabManager;
async getContentSpec(location, filePath) {
const url = parseGitUrl(location);
switch (true) {
case url.includes("github"): {
return this.githubManager.getContent(url, filePath);
}
case url.includes("gitlab"): {
return this.gitlabManager.getContent(url, filePath);
}
default:
throw new Error("Git provider error: unimplemented!");
}
}
async createPullRequest(filePath, location, fileContent, title, message) {
const url = parseGitUrl(location);
switch (true) {
case url.includes("github"): {
return this.githubManager.createPullRequest(filePath, url, fileContent, title, message);
}
case url.includes("gitlab"): {
return this.gitlabManager.createPullRequest(filePath, url, fileContent, title, message);
}
default:
throw new Error("Git provider error: unimplemented!");
}
}
}
export { GitManager };
//# sourceMappingURL=GitManager.esm.js.map