|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +React Native CodePush is a native module that enables over-the-air updates for React Native apps. It consists of native implementations for iOS (Objective-C), Android (Java), and Windows (C++), unified through a JavaScript bridge layer. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Testing |
| 12 | +- `npm test` - Run all tests with TypeScript compilation |
| 13 | +- `npm run test:android` - Run Android-specific tests |
| 14 | +- `npm run test:ios` - Run iOS-specific tests |
| 15 | +- `npm run test:setup-android` - Set up Android emulator for testing |
| 16 | +- `npm run test:setup-ios` - Set up iOS simulator for testing |
| 17 | + |
| 18 | +### Build |
| 19 | +- `npm run build` - Build TypeScript tests to bin/ directory |
| 20 | +- `npm run tsc` - TypeScript compilation |
| 21 | + |
| 22 | +### Platform Testing |
| 23 | +- Tests run on actual emulators/simulators with real React Native apps |
| 24 | +- Test apps are created dynamically in `test/` directory |
| 25 | +- Both old and new React Native architecture testing supported |
| 26 | + |
| 27 | +## Architecture |
| 28 | + |
| 29 | +### Core Components |
| 30 | +- **JavaScript Bridge** (`CodePush.js`): Main API layer exposing update methods |
| 31 | +- **Native Modules**: Platform-specific implementations handling file operations, bundle management |
| 32 | +- **Update Manager**: Handles download, installation, and rollback logic |
| 33 | +- **Acquisition SDK**: Manages server communication and update metadata |
| 34 | + |
| 35 | +### Platform Structure |
| 36 | +- **iOS**: `ios/` - Objective-C implementation with CocoaPods integration |
| 37 | +- **Android**: `android/` - Java implementation with Gradle plugin |
| 38 | +- **Windows**: `windows/` - C++ implementation for Windows React Native |
| 39 | +- **JavaScript**: Root level - TypeScript definitions and bridge code |
| 40 | + |
| 41 | +### Key Patterns |
| 42 | +- **Higher-Order Component**: `codePush()` wrapper for automatic update management |
| 43 | +- **Promise-based Native Bridge**: All native operations return promises |
| 44 | +- **Platform Abstraction**: Unified JavaScript API with platform-specific implementations |
| 45 | +- **Error Handling**: Automatic rollback on failed updates with telemetry |
| 46 | + |
| 47 | +### Testing Framework |
| 48 | +- **Custom Test Runner**: TypeScript-based test framework in `test/` |
| 49 | +- **Emulator Management**: Automated setup and teardown of test environments |
| 50 | +- **Real App Testing**: Creates actual React Native apps for integration testing |
| 51 | +- **Scenario Testing**: Update, rollback, and error scenarios |
| 52 | + |
| 53 | +### Build Integration |
| 54 | +- **Android Gradle Plugin**: Automatically generates bundle hashes and processes assets |
| 55 | +- **iOS CocoaPods**: Manages native dependencies and build configuration |
| 56 | +- **Bundle Processing**: Automated zip creation and hash calculation for OTA updates |
| 57 | + |
| 58 | +## Development Workflow |
| 59 | + |
| 60 | +1. **Making Changes**: Edit native code or JavaScript bridge |
| 61 | +2. **Testing**: Run platform-specific tests with real emulators |
| 62 | +3. **Integration**: Test with actual React Native apps via test framework |
| 63 | +4. **Validation**: Ensure compatibility with both RN architectures |
| 64 | + |
| 65 | +## Key Files |
| 66 | +- `CodePush.js` - Main JavaScript API |
| 67 | +- `test/TestRunner.ts` - Test framework entry point |
| 68 | +- `android/build.gradle` - Android build configuration |
| 69 | +- `ios/CodePush.podspec` - iOS CocoaPods specification |
| 70 | +- `plugin.xml` - Cordova plugin configuration |
| 71 | + |
| 72 | +## Special Considerations |
| 73 | +- Native module requires platform-specific knowledge (iOS/Android/Windows) |
| 74 | +- Testing requires emulator setup and can be time-intensive |
| 75 | +- Updates must be backward compatible with existing app installations |
| 76 | +- Bundle hash calculation is critical for update integrity |
0 commit comments