refactor(pr): rely on selected CLI for PR creation
This commit is contained in:
@@ -124,50 +124,6 @@ export async function getRemoteHostname(): Promise<string | null> {
|
||||
}
|
||||
}
|
||||
|
||||
export function checkCLI(platform: Platform): string | null {
|
||||
const bin =
|
||||
platform === "github" ? "gh" : platform === "gitlab" ? "glab" : "tea";
|
||||
const path = Bun.which(bin);
|
||||
if (!path) {
|
||||
if (platform === "github") {
|
||||
return "GitHub CLI (gh) not found. Install: brew install gh";
|
||||
}
|
||||
if (platform === "gitlab") {
|
||||
return "GitLab CLI (glab) not found. Install: brew install glab";
|
||||
}
|
||||
return "Gitea CLI (tea) not found. Install from: https://gitea.com/gitea/tea";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function checkAuth(platform: Platform): Promise<string | null> {
|
||||
if (platform === "github") {
|
||||
try {
|
||||
await Bun.$`gh auth status`.quiet();
|
||||
return null;
|
||||
} catch {
|
||||
return "Not authenticated with GitHub CLI. Run: gh auth login";
|
||||
}
|
||||
}
|
||||
|
||||
if (platform === "gitlab") {
|
||||
try {
|
||||
await Bun.$`glab auth status`.quiet();
|
||||
return null;
|
||||
} catch {
|
||||
return "Not authenticated with GitLab CLI. Run: glab auth login";
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await Bun.$`tea logins list`.quiet().text();
|
||||
if (result.trim()) return null;
|
||||
return "Not authenticated with Gitea CLI. Run: tea login add";
|
||||
} catch {
|
||||
return "Not authenticated with Gitea CLI. Run: tea login add";
|
||||
}
|
||||
}
|
||||
|
||||
export async function createPR(
|
||||
platform: Platform,
|
||||
title: string,
|
||||
|
||||
Reference in New Issue
Block a user