capacitor-ota
v1.0.11
Published
Capacitor uygulamaları için Over-The-Air (OTA) güncelleme servisi.
Downloads
1,301
Readme
OTA Service
Capacitor uygulamaları için Over-The-Air (OTA) güncelleme servisi.
Mimari
┌──────────────────────────────────────────────────────────────┐
│ 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() │
└──────────────────────────────────────────────────────────────┘CLI Kullanımı
Kurulum
cd capacitor-ota
pnpm installKomutlar
Login
pnpm cli login <username> <password>Token ~/.ota-cli.json dosyasına kaydedilir.
Uygulamaları Listele
pnpm cli appsÇıktı:
📱 Apps:
ID Name Created
──────────────────────────────────────────────────
9fa3a103d8d0 MyApp 1/22/2026Versiyonları Listele
pnpm cli versions <app_id>Çı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/2026Yeni Versiyon Yükle
pnpm cli upload <app_id> <path> [options]<path> 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:
# Dizin ile (otomatik ziplenir)
pnpm cli upload 9fa3a103d8d0 ./dist -v 1.0.5
# Zip dosyası ile
pnpm cli upload 9fa3a103d8d0 ./bundle.zip -v 1.0.5Çıktı:
📦 Zipping directory: dist...
📤 Uploading...
✅ Upload successful!
Version: 1.0.5
Checksum: a1b2c3d4...Versiyon Sil
pnpm cli delete <version_id>Rollback
pnpm cli rollback <version_id>Belirtilen versiyonu aktif yapar.
Konfigürasyon
# Mevcut ayarları göster
pnpm cli config
# API URL değiştir
pnpm cli set-url https://ota-api.silgi.devAPI Endpoints
Public (Auth Gerektirmez)
| Method | Endpoint | Açıklama |
|--------|----------|----------|
| GET | /updates/:appId.json | Static update check |
| GET | /bundles/:path | Bundle download |
Protected (Auth Gerektirir)
| 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
1. Plugin Kur
npm install capacitor-ota
npx cap sync2. App.vue
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{
"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
Development
pnpm devProduction Build
pnpm build
node .output/server/index.mjsEnvironment Variables
# PostgreSQL
DATABASE_URL=postgresql://user:pass@localhost:5432/capacitor_ota
# Cloudflare R2 (S3-compatible)
R2_ACCOUNT_ID=xxx
R2_ACCESS_KEY_ID=xxx
R2_SECRET_ACCESS_KEY=xxx
R2_BUCKET_NAME=ota-bundles
# Admin (generated on first setup)
ADMIN_PASSWORD_HASH=100000:salt:hashDatabase Schema
PostgreSQL 18 + Drizzle ORM + UUID v7
admins- Admin kullanıcılarısessions- Auth sessionsapps- Uygulamalarversions- Versiyon kayıtları
# Migration oluştur
pnpm db:generate
# Migration uygula
pnpm db:migrate