feat(installer): prompt before starring repos

This commit is contained in:
YeonGyu-Kim
2026-05-31 05:07:08 +09:00
parent 2530300dec
commit 799a17bc2e
6 changed files with 206 additions and 13 deletions
+33
View File
@@ -1,8 +1,41 @@
import { execFile } from "node:child_process"
import { promisify } from "node:util"
export const STAR_REPOSITORIES = [
"code-yeongyu/oh-my-openagent",
"code-yeongyu/lazycodex",
] as const
const execFileAsync = promisify(execFile)
export interface GitHubStarResult {
readonly repository: string
readonly ok: boolean
readonly error?: string
}
export type GitHubStarCommandRunner = (repository: string) => Promise<void>
export function formatGitHubStarCommand(repository: string): string {
return `gh api --silent --method PUT /user/starred/${repository} >/dev/null 2>&1 || true`
}
export async function runGitHubStarCommand(repository: string): Promise<void> {
await execFileAsync("gh", ["api", "--silent", "--method", "PUT", `/user/starred/${repository}`])
}
export async function starGitHubRepositories(
repositories: readonly string[] = STAR_REPOSITORIES,
runCommand: GitHubStarCommandRunner = runGitHubStarCommand,
): Promise<readonly GitHubStarResult[]> {
const results: GitHubStarResult[] = []
for (const repository of repositories) {
try {
await runCommand(repository)
results.push({ repository, ok: true })
} catch (error) {
results.push({ repository, ok: false, error: error instanceof Error ? error.message : String(error) })
}
}
return results
}