()
| 4 | import { DevSetupHelper } from './DevSetupHelper'; |
| 5 | |
| 6 | export async function macOSSetup(): Promise<void> { |
| 7 | const devSetup = new DevSetupHelper(); |
| 8 | |
| 9 | // Check if xcode-select command exists |
| 10 | if (!checkCommandExists('xcode-select')) { |
| 11 | throw new CliError( |
| 12 | 'Xcode command line tools are not installed.\n\n' + |
| 13 | 'Please install Xcode from the App Store, then run:\n' + |
| 14 | ' sudo xcode-select -s /Applications/Xcode.app\n\n' + |
| 15 | 'After installation, run valdi dev_setup again.', |
| 16 | ); |
| 17 | } |
| 18 | |
| 19 | // Verify Xcode is properly configured |
| 20 | try { |
| 21 | const xcodePathResult = await runCliCommand('xcode-select -p'); |
| 22 | const xcodePath = xcodePathResult.stdout.trim(); |
| 23 | |
| 24 | if (!xcodePath || !fs.existsSync(xcodePath)) { |
| 25 | throw new CliError( |
| 26 | 'Xcode command line tools path is not configured correctly.\n\n' + |
| 27 | 'Please run:\n' + |
| 28 | ' sudo xcode-select -s /Applications/Xcode.app\n\n' + |
| 29 | 'Or if you have Xcode with a different name (e.g., beta versions):\n' + |
| 30 | ' sudo xcode-select -s /Applications/YourXcode.app\n\n' + |
| 31 | 'After configuration, run valdi dev_setup again.', |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | // Extract Xcode.app path from the Developer path |
| 36 | const xcodeAppPath = xcodePath.replace(/\/Contents\/Developer\/?$/, ''); |
| 37 | |
| 38 | // Verify the Xcode app exists |
| 39 | if (!fs.existsSync(xcodeAppPath) || !xcodeAppPath.includes('Xcode')) { |
| 40 | throw new CliError( |
| 41 | 'Xcode installation not found.\n\n' + |
| 42 | `xcode-select points to ${xcodePath}\n` + |
| 43 | `but Xcode app not found at ${xcodeAppPath}\n\n` + |
| 44 | 'Please install Xcode from the App Store:\n' + |
| 45 | ' https://apps.apple.com/us/app/xcode/id497799835\n\n' + |
| 46 | 'Then configure it with:\n' + |
| 47 | ' sudo xcode-select -s /Applications/Xcode.app\n\n' + |
| 48 | 'After installation, run valdi dev_setup again.', |
| 49 | ); |
| 50 | } |
| 51 | } catch (error) { |
| 52 | if (error instanceof CliError) { |
| 53 | throw error; |
| 54 | } |
| 55 | throw new CliError( |
| 56 | 'Failed to verify Xcode installation.\n\n' + |
| 57 | 'Please ensure Xcode is installed from the App Store and properly configured:\n' + |
| 58 | ' sudo xcode-select -s /Applications/Xcode.app\n\n' + |
| 59 | 'After setup, run valdi dev_setup again.', |
| 60 | ); |
| 61 | } |
| 62 | |
| 63 | if (!checkCommandExists('brew')) { |
no test coverage detected