Capacitor uygulamaları için Over-The-Air (OTA) güncelleme servisi.
npm install capacitor-otaCapacitor uygulamaları için Over-The-Air (OTA) güncelleme servisi.
``
┌──────────────────────────────────────────────────────────────┐
│ ADMIN (Nadir) │
├──────────────────────────────────────────────────────────────┤
│ CLI/Panel → POST /api/versions/upload │
│ ↓ │
│ 1. Bundle → R2: /bundles/app/production/1.0.0.zip │
│ 2. Metadata → PostgreSQL │
└──────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────┐
│ CİHAZ (Sık) │
├──────────────────────────────────────────────────────────────┤
│ App açılış → GET /updates/com.example.app.json │
│ ↓ │
│ Güncelleme var mı? │
│ ↓ evet │
│ GET /bundles/app/production/1.0.0.zip │
│ ↓ │
│ CapacitorUpdater.download() → set() │
└──────────────────────────────────────────────────────────────┘
`
---
`bash`
cd capacitor-ota
pnpm install
#### Login
`bash`
pnpm cli login ~/.ota-cli.json
Token dosyasına kaydedilir.
#### Uygulamaları Listele
`bash`
pnpm cli apps
Çıktı:
`
📱 Apps:
ID Name Created
──────────────────────────────────────────────────
9fa3a103d8d0 MyApp 1/22/2026
`
#### Versiyonları Listele
`bash`
pnpm cli versions
Çıktı:
`
📦 Versions:
ID Version Channel Active Downloads Created
─────────────────────────────────────────────────────────────────
1 1.0.0 production ✅ 150 1/20/2026
2 1.0.1 production 45 1/22/2026
`
#### Yeni Versiyon Yükle
`bash`
pnpm cli upload
bir dizin veya .zip dosyası olabilir. Dizin verilirse CLI otomatik zipleyecektir.
Seçenekler:
| Flag | Kısa | Açıklama | Varsayılan |
|------|------|----------|------------|
| --version | -v | Versiyon numarası | 1.0.0 |--channel
| | -c | Kanal | production |--min-native
| | | Minimum native versiyon | - |--notes
| | | Release notes | - |
Örnekler:
`bashDizin ile (otomatik ziplenir)
pnpm cli upload 9fa3a103d8d0 ./dist -v 1.0.5
Çıktı:
`
📦 Zipping directory: dist...
📤 Uploading...✅ Upload successful!
Version: 1.0.5
Checksum: a1b2c3d4...
`#### Versiyon Sil
`bash
pnpm cli delete
`#### Rollback
`bash
pnpm cli rollback
`
Belirtilen versiyonu aktif yapar.#### Konfigürasyon
`bash
Mevcut ayarları göster
pnpm cli configAPI URL değiştir
pnpm cli set-url https://ota-api.silgi.dev
`---
API Endpoints
$3
| Method | Endpoint | Açıklama |
|--------|----------|----------|
| GET |
/updates/:appId.json | Static update check |
| GET | /bundles/:path | Bundle download |$3
| Method | Endpoint | Açıklama |
|--------|----------|----------|
| POST |
/api/auth/login | Login |
| POST | /api/auth/logout | Logout |
| GET | /api/apps | App listesi |
| POST | /api/apps | App oluştur |
| PUT | /api/apps/:id | App güncelle |
| DELETE | /api/apps/:id | App sil |
| GET | /api/versions | Versiyon listesi |
| POST | /api/versions/upload | Versiyon yükle |
| DELETE | /api/versions/:id | Versiyon sil |
| POST | /api/versions/:id/rollback | Rollback |
| GET | /api/stats | İstatistikler |---
Capacitor Entegrasyonu
$3
`bash
npm install capacitor-ota
npx cap sync
`$3
`typescript
import { initOtaUpdate } from 'capacitor-ota'// App başlangıcında
await initOtaUpdate({
staticUrl: 'https://ota-api.silgi.dev',
appId: 'com.example.app',
appVersion: '1.0.0',
autoApply: true,
showUI: true,
})
`---
Static JSON Format
Güncelleme bilgisi:
`
GET https://ota-api.silgi.dev/updates/com.example.app.json
``json
{
"version": "1.0.5",
"url": "https://ota-api.silgi.dev/bundles/9fa3a103d8d0/production/1.0.5.zip",
"checksum": "a1b2c3d4e5f6...",
"min_native_version": "1.0.0",
"release_notes": "Bug fixes",
"updated_at": "2026-01-22T10:30:00.000Z"
}
`---
Deployment
$3
`bash
pnpm dev
`$3
`bash
pnpm build
node .output/server/index.mjs
`---
Environment Variables
`env
PostgreSQL
DATABASE_URL=postgresql://user:pass@localhost:5432/capacitor_otaCloudflare R2 (S3-compatible)
R2_ACCOUNT_ID=xxx
R2_ACCESS_KEY_ID=xxx
R2_SECRET_ACCESS_KEY=xxx
R2_BUCKET_NAME=ota-bundlesAdmin (generated on first setup)
ADMIN_PASSWORD_HASH=100000:salt:hash
`---
Database Schema
PostgreSQL 18 + Drizzle ORM + UUID v7
-
admins - Admin kullanıcıları
- sessions - Auth sessions
- apps - Uygulamalar
- versions - Versiyon kayıtları`bash
Migration oluştur
pnpm db:generateMigration uygula
pnpm db:migrate
``