2026-05-31 05:07:08 +09:00
|
|
|
import { execFile } from "node:child_process"
|
|
|
|
|
import { promisify } from "node:util"
|
|
|
|
|
|
2026-05-30 19:12:11 +09:00
|
|
|
export const STAR_REPOSITORIES = [
|
|
|
|
|
"code-yeongyu/oh-my-openagent",
|
|
|
|
|
"code-yeongyu/lazycodex",
|
|
|
|
|
] as const
|
|
|
|
|
|
2026-05-31 05:07:08 +09:00
|
|
|
const execFileAsync = promisify(execFile)
|
|
|
|
|
|
|
|
|
|
export interface GitHubStarResult {
|
|
|
|
|
readonly repository: string
|
|
|
|
|
readonly ok: boolean
|
|
|
|
|
readonly error?: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type GitHubStarCommandRunner = (repository: string) => Promise<void>
|
|
|
|
|
|
2026-05-30 19:12:11 +09:00
|
|
|
export function formatGitHubStarCommand(repository: string): string {
|
|
|
|
|
return `gh api --silent --method PUT /user/starred/${repository} >/dev/null 2>&1 || true`
|
|
|
|
|
}
|
2026-05-31 05:07:08 +09:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|