안내
Electron Updater에 대한 튜토리얼
@capgo/electron-updater를 사용하면 Electron 앱에 capgo 라이브 업데이트 모델을 제공합니다.
@capgo/electron-updater Electron 앱에서 Capgo 라이브 업데이트 모델을 사용하려면 메인 프로세스에서 초기화하고 렌더러 브리지를 프리로드를 통해 노출하고 런치할 때마다 호출해야 합니다. @capgo/capacitor-updater설치 notifyAppReady() 메인 프로세스 설정
프리로드 브리지
bun add @capgo/electron-updater
설치
import { app, BrowserWindow } from 'electron';
import path from 'node:path';
import { ElectronUpdater, setupEventForwarding, setupIPCHandlers } from '@capgo/electron-updater';
const updater = new ElectronUpdater({
appId: 'com.example.desktop',
autoUpdate: true,
});
app.whenReady().then(async () => {
const window = new BrowserWindow({
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true,
},
});
const builtinPath = path.join(__dirname, 'www/index.html');
await updater.initialize(window, builtinPath);
setupIPCHandlers(updater);
setupEventForwarding(updater, window);
await window.loadFile(updater.getCurrentBundlePath());
});
메인 프로세스 설정
import { exposeUpdaterAPI } from '@capgo/electron-updater/preload';
exposeUpdaterAPI();
Renderer 사용
import { requireUpdater } from '@capgo/electron-updater/renderer';
const updater = requireUpdater();
await updater.notifyAppReady();
const latest = await updater.getLatest();
if (latest.url && !latest.error) {
const bundle = await updater.download({
url: latest.url,
version: latest.version,
checksum: latest.checksum,
});
await updater.next({ id: bundle.id });
}
업데이트 이벤트를 듣기
updater.addListener('download', ({ percent }) => {
console.log('Download progress', percent);
});
updater.addListener('updateFailed', ({ bundle }) => {
console.error('Update failed', bundle.version);
});
새로운 번들을 배포
bun run build
bunx @capgo/cli@latest bundle upload --channel=production
실용적인 조언
- 항상
notifyAppReady()renderer에서 rollback 보호가 작동하도록 의도된대로 호출하세요. - 빌드된 경로를 안정적으로 유지하고 업데이터가 shipped 번들을 로드하거나 다운로드한 번들을 로드할지 결정하도록 하세요.
- Capgo 채널과 롤아웃 모델을 재사용하세요. 이 채널과 롤아웃 모델은 이미 모바일에서 사용 중인 것과 동일해야 합니다. Electron 앱이 백엔드 릴리스 PIPELINE을 공유할 때입니다.
Using @capgo/electron-updater
이러한 Using @capgo/electron-updater native 플러그인 작업을 계획할 때, 이를 capgo/electron-updater capgo/electron-updater 구현 세부 사항에 대해 에레クト론 업데이터 시작하기 에레クト론 업데이터 시작하기 구현 세부 사항에 대해 Capgo 플러그인 디렉토리 Capgo 플러그인 디렉토리에서 제품 워크플로에 대해 Capacitor Capgo의 플러그인 Capacitor Capgo의 플러그인 구현 세부 사항에 대해, 그리고 플러그인 추가 또는 업데이트 플러그인 추가 또는 업데이트 구현 세부 사항에 대해