* Install a plugin from GitHub
( repo: string, targetPath: string, ref?: string, sha?: string, )
| 660 | * Install a plugin from GitHub |
| 661 | */ |
| 662 | async function installFromGitHub( |
| 663 | repo: string, |
| 664 | targetPath: string, |
| 665 | ref?: string, |
| 666 | sha?: string, |
| 667 | ): Promise<void> { |
| 668 | if (!/^[a-zA-Z0-9-_.]+\/[a-zA-Z0-9-_.]+$/.test(repo)) { |
| 669 | throw new Error( |
| 670 | `Invalid GitHub repository format: ${repo}. Expected format: owner/repo`, |
| 671 | ) |
| 672 | } |
| 673 | // Use HTTPS for CCR (no SSH keys), SSH for normal CLI |
| 674 | const gitUrl = isEnvTruthy(process.env.CLAUDE_CODE_REMOTE) |
| 675 | ? `https://github.com/${repo}.git` |
| 676 | : `git@github.com:${repo}.git` |
| 677 | return installFromGit(gitUrl, targetPath, ref, sha) |
| 678 | } |
| 679 | |
| 680 | /** |
| 681 | * Resolve a git-subdir `url` field to a clonable git URL. |
no test coverage detected