|
| 1 | +# @sqliteai/sqlite-sync-expo Generator |
| 2 | + |
| 3 | +This directory contains the generator script for the `@sqliteai/sqlite-sync-expo` npm package. |
| 4 | + |
| 5 | +## How It Works |
| 6 | + |
| 7 | +The `generate-expo-package.js` script creates a complete npm package from CI build artifacts: |
| 8 | + |
| 9 | +1. Generates `package.json`, `app.plugin.js`, `src/index.js`, `src/index.d.ts`, `README.md` |
| 10 | +2. Copies iOS `CloudSync.xcframework` from artifacts |
| 11 | +3. Copies Android `cloudsync.so` files for each architecture |
| 12 | + |
| 13 | +## Usage (CI) |
| 14 | + |
| 15 | +This script is called automatically during the release workflow: |
| 16 | + |
| 17 | +```bash |
| 18 | +node generate-expo-package.js <version> <artifacts-dir> <output-dir> |
| 19 | +``` |
| 20 | + |
| 21 | +Example: |
| 22 | + |
| 23 | +```bash |
| 24 | +node generate-expo-package.js 0.8.57 ../../artifacts ./expo-package |
| 25 | +cd expo-package && npm publish --provenance --access public |
| 26 | +``` |
| 27 | + |
| 28 | +## Generated Package Structure |
| 29 | + |
| 30 | +``` |
| 31 | +expo-package/ |
| 32 | +├── package.json |
| 33 | +├── src/ |
| 34 | +│ ├── index.js |
| 35 | +│ └── index.d.ts |
| 36 | +├── app.plugin.js |
| 37 | +├── ios/ |
| 38 | +│ └── CloudSync.xcframework/ |
| 39 | +├── android/ |
| 40 | +│ └── jniLibs/ |
| 41 | +│ ├── arm64-v8a/cloudsync.so |
| 42 | +│ ├── armeabi-v7a/cloudsync.so |
| 43 | +│ └── x86_64/cloudsync.so |
| 44 | +├── README.md |
| 45 | +└── LICENSE.md |
| 46 | +``` |
| 47 | + |
| 48 | +## Testing Locally |
| 49 | + |
| 50 | +To test the generator locally, you need to set up mock artifacts that simulate what CI produces. |
| 51 | + |
| 52 | +### Step 1: Get binaries |
| 53 | + |
| 54 | +**Option A: Download from latest release** |
| 55 | + |
| 56 | +```bash |
| 57 | +VERSION="0.8.57" # or latest version |
| 58 | + |
| 59 | +mkdir -p artifacts/cloudsync-apple-xcframework |
| 60 | +mkdir -p artifacts/cloudsync-android-arm64-v8a |
| 61 | +mkdir -p artifacts/cloudsync-android-armeabi-v7a |
| 62 | +mkdir -p artifacts/cloudsync-android-x86_64 |
| 63 | + |
| 64 | +# Download xcframework |
| 65 | +curl -L "https://github.com/sqliteai/sqlite-sync/releases/download/${VERSION}/cloudsync-apple-xcframework-${VERSION}.zip" -o xcframework.zip |
| 66 | +unzip xcframework.zip -d artifacts/cloudsync-apple-xcframework/ |
| 67 | +rm xcframework.zip |
| 68 | + |
| 69 | +# Download Android binaries |
| 70 | +for arch in arm64-v8a armeabi-v7a x86_64; do |
| 71 | + curl -L "https://github.com/sqliteai/sqlite-sync/releases/download/${VERSION}/cloudsync-android-${arch}-${VERSION}.zip" -o android-${arch}.zip |
| 72 | + unzip android-${arch}.zip -d artifacts/cloudsync-android-${arch}/ |
| 73 | + rm android-${arch}.zip |
| 74 | +done |
| 75 | +``` |
| 76 | + |
| 77 | +**Option B: Build from source** |
| 78 | + |
| 79 | +```bash |
| 80 | +# Build xcframework (macOS only) |
| 81 | +make xcframework |
| 82 | + |
| 83 | +# Build Android (requires Android NDK) |
| 84 | +export ANDROID_NDK=/path/to/ndk |
| 85 | +make extension PLATFORM=android ARCH=arm64-v8a |
| 86 | +make extension PLATFORM=android ARCH=armeabi-v7a |
| 87 | +make extension PLATFORM=android ARCH=x86_64 |
| 88 | + |
| 89 | +# Move to artifacts structure |
| 90 | +mkdir -p artifacts/cloudsync-apple-xcframework |
| 91 | +mkdir -p artifacts/cloudsync-android-arm64-v8a |
| 92 | +mkdir -p artifacts/cloudsync-android-armeabi-v7a |
| 93 | +mkdir -p artifacts/cloudsync-android-x86_64 |
| 94 | + |
| 95 | +cp -r dist/CloudSync.xcframework artifacts/cloudsync-apple-xcframework/ |
| 96 | +# Copy .so files similarly... |
| 97 | +``` |
| 98 | + |
| 99 | +### Step 2: Run the generator |
| 100 | + |
| 101 | +```bash |
| 102 | +cd packages/expo |
| 103 | +node generate-expo-package.js 0.8.57 ../../artifacts ./expo-package |
| 104 | +``` |
| 105 | + |
| 106 | +### Step 3: Test in a React Native app |
| 107 | + |
| 108 | +```bash |
| 109 | +# In your RN/Expo app |
| 110 | +npm install /path/to/sqlite-sync/packages/expo/expo-package |
| 111 | + |
| 112 | +# Or use file: reference in package.json |
| 113 | +# "@sqliteai/sqlite-sync-expo": "file:/path/to/sqlite-sync/packages/expo/expo-package" |
| 114 | +``` |
| 115 | + |
| 116 | +Update `app.json`: |
| 117 | + |
| 118 | +```json |
| 119 | +{ |
| 120 | + "expo": { |
| 121 | + "plugins": ["@sqliteai/sqlite-sync-expo"] |
| 122 | + } |
| 123 | +} |
| 124 | +``` |
| 125 | + |
| 126 | +Run prebuild and verify: |
| 127 | + |
| 128 | +```bash |
| 129 | +npx expo prebuild --clean |
| 130 | + |
| 131 | +# Check iOS |
| 132 | +ls ios/<YourApp>/CloudSync.xcframework |
| 133 | + |
| 134 | +# Check Android |
| 135 | +ls android/app/src/main/jniLibs/arm64-v8a/cloudsync.so |
| 136 | +``` |
0 commit comments