가이드
Electron Updater를 Electron에서 사용하는 방법
Electron 앱에 대해 @capgo/electron-updater를 사용하면
@capgo/electron-updater Capgo Live Update 모델을 Electron 앱에 제공합니다. @capgo/capacitor-updaterElectron 앱에서 Live Update 모델을 사용하려면 메인 프로세스에서 초기화하고, 프리로드를 통해 렌더러 브리지를 노출하고, 런칭할 때마다 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();
업데이트 이벤트를 듣기
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
항상
- __CAPGO_KEEP_0__
notifyAppReady()renderer에서 초기화하여 rollback 보호가 의도된대로 작동하도록합니다. - 내장된 경로를 안정적으로 유지하고 업데이터가 shipped bundle 또는 다운로드 한 것을 로드할지 결정하도록합니다.
- Electron 앱이 백엔드 릴리스 PIPELINE을 공유할 때 모바일에서 이미 사용하는 동일한 Capgo 채널과 롤아웃 모델을 재사용하세요.
Using @capgo/electron-updater에서 계속 진행하세요.
이미 @__CAPGO_KEEP_0__/electron-updater를 사용 중이라면 @capgo/전자 업데이터 사용 native 플러그인 작업을 계획하기 위해 연결하세요 @capgo/electron-updater @capgo/전자 업데이트 구현 세부 사항을 위해 Electron Updater 시작하기 __CAPGO_KEEP_0__ Plugin Directory Capgo 플러그인 디렉토리 제품 워크플로우에 대한 Capgo 플러그인 디렉토리에서 Capacitor 플러그인에 대한 Capgo 제품 워크플로우에 대한 Capacitor 플러그인에 대한 Capgo 플러그인을 추가하거나 업데이트 플러그인 추가 또는 업데이트에 대한 구현 세부 사항