Skip to content

Commit 037e3a5

Browse files
committed
docs: add expo package workflow and README documentation
1 parent 1fc2f21 commit 037e3a5

File tree

3 files changed

+191
-0
lines changed

3 files changed

+191
-0
lines changed

.github/workflows/main.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,19 @@ jobs:
419419
echo " Platform packages: 7"
420420
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
421421
422+
- name: build and publish expo package
423+
if: steps.tag.outputs.version != ''
424+
run: |
425+
cd packages/expo
426+
427+
echo "Generating @sqliteai/sqlite-sync-expo package..."
428+
node generate-expo-package.js "${{ steps.tag.outputs.version }}" "../../artifacts" "./expo-package"
429+
430+
echo "Publishing @sqliteai/sqlite-sync-expo to npm..."
431+
cd expo-package
432+
npm publish --provenance --access public
433+
echo "✓ Published @sqliteai/sqlite-sync-expo@${{ steps.tag.outputs.version }}"
434+
422435
- uses: softprops/[email protected]
423436
if: steps.tag.outputs.version != ''
424437
with:
@@ -427,6 +440,7 @@ jobs:
427440
428441
[**Node**](https://www.npmjs.com/package/@sqliteai/sqlite-sync): `npm install @sqliteai/sqlite-sync`
429442
[**WASM**](https://www.npmjs.com/package/@sqliteai/sqlite-wasm): `npm install @sqliteai/sqlite-wasm`
443+
[**Expo/React Native**](https://www.npmjs.com/package/@sqliteai/sqlite-sync-expo): `npm install @sqliteai/sqlite-sync-expo`
430444
[**Android**](https://central.sonatype.com/artifact/ai.sqlite/sync): `ai.sqlite:sync:${{ steps.tag.outputs.version }}`
431445
[**Swift**](https://github.com/sqliteai/sqlite-sync#swift-package): [Installation Guide](https://github.com/sqliteai/sqlite-sync#swift-package)
432446

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,47 @@ SQLiteDatabase db = SQLiteDatabase.openDatabase(config, null, null);
176176

177177
**Note:** Additional settings and configuration are required for a complete setup. For full implementation details, see the [complete Android example](https://github.com/sqliteai/sqlite-extensions-guide/blob/main/examples/android/README.md).
178178

179+
### React Native / Expo
180+
181+
Install the Expo package:
182+
183+
```bash
184+
npm install @sqliteai/sqlite-sync-expo
185+
```
186+
187+
Add to your `app.json`:
188+
189+
```json
190+
{
191+
"expo": {
192+
"plugins": ["@sqliteai/sqlite-sync-expo"]
193+
}
194+
}
195+
```
196+
197+
Run prebuild:
198+
199+
```bash
200+
npx expo prebuild --clean
201+
```
202+
203+
Load the extension:
204+
205+
```typescript
206+
import { open } from '@op-engineering/op-sqlite';
207+
import { Platform } from 'react-native';
208+
209+
const db = open({ name: 'mydb.db' });
210+
211+
// Load SQLite Sync extension
212+
if (Platform.OS === 'ios') {
213+
const path = db.getDylibPath('ai.sqlite.cloudsync', 'CloudSync');
214+
db.loadExtension(path);
215+
} else {
216+
db.loadExtension('cloudsync');
217+
}
218+
```
219+
179220
## Getting Started
180221

181222
Here's a quick example to get started with SQLite Sync:

packages/expo/README.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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

Comments
 (0)