()
| 49 | } |
| 50 | |
| 51 | async function installXcodemake(): Promise<boolean> { |
| 52 | const tempDir = os.tmpdir(); |
| 53 | const xcodemakeDir = path.join(tempDir, 'xcodebuildmcp'); |
| 54 | const xcodemakePath = path.join(xcodemakeDir, 'xcodemake'); |
| 55 | |
| 56 | log('info', `Attempting to install xcodemake to ${xcodemakePath}`); |
| 57 | |
| 58 | try { |
| 59 | await fs.mkdir(xcodemakeDir, { recursive: true }); |
| 60 | |
| 61 | log('info', 'Downloading xcodemake from GitHub...'); |
| 62 | const response = await fetch( |
| 63 | 'https://raw.githubusercontent.com/cameroncooke/xcodemake/main/xcodemake', |
| 64 | ); |
| 65 | |
| 66 | if (!response.ok) { |
| 67 | throw new Error(`Failed to download xcodemake: ${response.status} ${response.statusText}`); |
| 68 | } |
| 69 | |
| 70 | const scriptContent = await response.text(); |
| 71 | await fs.writeFile(xcodemakePath, scriptContent, 'utf8'); |
| 72 | |
| 73 | await fs.chmod(xcodemakePath, 0o755); |
| 74 | log('info', 'Made xcodemake executable'); |
| 75 | |
| 76 | overrideXcodemakeCommand(xcodemakePath); |
| 77 | |
| 78 | return true; |
| 79 | } catch (error) { |
| 80 | log( |
| 81 | 'error', |
| 82 | `Error installing xcodemake: ${error instanceof Error ? error.message : String(error)}`, |
| 83 | ); |
| 84 | return false; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | export async function isXcodemakeAvailable(): Promise<boolean> { |
| 89 | if (!isXcodemakeEnabled()) { |
no test coverage detected