Electron Updater API 레퍼런스
이 플러그인의 설치 단계와 전체 마크다운 가이드가 포함된 설정 프롬프트를 복사하세요.
이 페이지에서는 Electron Updater에서 사용할 수 있는 모든 메서드, 이벤트 및 설정 옵션을 설명합니다.
핵심 메서드
“Core Methods” 섹션notifyAppReady()
“notifyAppReady()” 섹션앱을 실행할 때마다 반드시 호출해야 합니다. 번들이 성공적으로 로드되었음을 확인하고 자동 롤백을 방지합니다.
await updater.notifyAppReady();download(options)
“download(options)” 섹션URL에서 번들을 다운로드합니다.
const bundle = await updater.download({ url: 'https://example.com/bundle.zip', version: '1.0.1', checksum: 'sha256-hash', // Optional but recommended sessionKey: '...', // For encrypted bundles});파라미터:
| 옵션 | 유형 | 필수 | 설명 |
|---|---|---|---|
url | string | 지원 | bundle를 다운로드할 URL |
version | string | 지원 | bundle의 버전 식별자 |
checksum | string | 아니요 | 검증을 위한 SHA256 체크섬 |
sessionKey | string | 아니요 | 암호화된 번들의 세션 키 |
반환값: BundleInfo 다음 항목을 포함하는 object id, version, status
next(options)
“next(options)” 섹션다음 앱 재시작 시 로드할 번들을 큐에 추가합니다.
await updater.next({ id: 'bundle-id' });파라미터:
| 옵션 | 유형 | 필수 | 설명 |
|---|---|---|---|
id | string | 지원 | 큐에 추가할 Bundle ID |
set(options)
“set(options)” 섹션즉시 번들로 전환하고 앱을 다시 로드합니다.
await updater.set({ id: 'bundle-id' });파라미터:
| 옵션 | 유형 | 필수 | 설명 |
|---|---|---|---|
id | string | 지원 | 활성화할 Bundle ID |
reload()
“reload()” 섹션현재 번들로 앱을 수동으로 다시 로드합니다.
await updater.reload();delete(options)
“delete(options)” 섹션스토리지에서 번들을 삭제합니다.
await updater.delete({ id: 'bundle-id' });파라미터:
| 옵션 | 유형 | 필수 | 설명 |
|---|---|---|---|
id | string | 지원 | 삭제할 Bundle ID |
reset(options)
“reset(options)” 섹션내장 버전 또는 마지막으로 성공한 bundle로 리셋합니다.
// Reset to builtinawait updater.reset({ toLastSuccessful: false });
// Reset to last successful bundleawait updater.reset({ toLastSuccessful: true });파라미터:
| 옵션 | 유형 | 필수 | 설명 |
|---|---|---|---|
toLastSuccessful | boolean | 아니요 | true이면 builtin 대신 마지막으로 성공한 bundle로 재설정합니다. |
current()
“current()” 섹션현재 번들과 네이티브 버전 정보를 가져옵니다.
const info = await updater.current();// { bundle: { id, version, status }, native: '1.0.0' }list(options)
“list(options)” 섹션다운로드된 모든 번들을 나열합니다.
const bundles = await updater.list();// [{ id, version, status, downloaded, checksum }, ...]getNextBundle()
“getNextBundle()” 섹션다음 재시작을 위해 대기 중인 번들을 가져옵니다.
const next = await updater.getNextBundle();// { id, version, status } or nullgetFailedUpdate()
“getFailedUpdate()” 섹션마지막으로 실패한 업데이트 정보를 가져옵니다 (롤백 디버깅 시 유용합니다).
const failed = await updater.getFailedUpdate();// { id, version, reason } or nullgetBuiltinVersion()
“getBuiltinVersion()” 섹션앱 바이너리에 포함된 버전을 가져옵니다.
const version = await updater.getBuiltinVersion();// '1.0.0'업데이트 확인
“업데이트 확인” 섹션getLatest(options)
“getLatest(options)” 섹션서버에서 사용 가능한 최신 버전을 확인합니다.
const latest = await updater.getLatest();
if (latest.url && !latest.error) { // Update available console.log('New version:', latest.version); console.log('Download URL:', latest.url);} else if (latest.error) { console.error('Error checking updates:', latest.error);}반환값:
| 속성 | 유형 | 설명 |
|---|---|---|
url | string | 다운로드 URL (업데이트가 없으면 빈 값) |
version | string | 사용 가능한 버전 |
checksum | string | SHA256 체크섬 |
sessionKey | string | 암호화 세션 키 |
error | string | 체크 실패 시 에러 메시지 |
message | string | 서버 메시지 |
setChannel(options)
“setChannel(options)” 섹션디바이스를 특정 채널에 할당합니다.
await updater.setChannel({ channel: 'beta' });unsetChannel(options)
“unsetChannel(options)” 섹션채널 할당을 해제하고 기본값을 사용합니다.
await updater.unsetChannel();getChannel()
“getChannel()” 섹션현재 할당된 채널을 가져옵니다.
const channel = await updater.getChannel();// { channel: 'production', status: 'set' }listChannels()
“listChannels()” 섹션이 앱에서 사용 가능한 모든 채널 목록을 가져옵니다.
const channels = await updater.listChannels();// ['production', 'beta', 'staging']다운로드된 업데이트가 적용되는 시점을 제어합니다.
setMultiDelay(options)
“setMultiDelay(options)” 섹션업데이트를 적용하기 전에 충족되어야 하는 조건을 설정합니다.
// Wait for app to be backgroundedawait updater.setMultiDelay({ delayConditions: [{ kind: 'background' }]});
// Wait until specific dateawait updater.setMultiDelay({ delayConditions: [{ kind: 'date', value: '2024-12-25T00:00:00Z' }]});
// Wait for app to be killed and restartedawait updater.setMultiDelay({ delayConditions: [{ kind: 'kill' }]});
// Multiple conditions (all must be met)await updater.setMultiDelay({ delayConditions: [ { kind: 'background' }, { kind: 'date', value: '2024-12-25T00:00:00Z' } ]});Delay Condition 유형:
| 종류 | 값 | 설명 |
|---|---|---|
background | 선택 사항 (ms) | 앱이 백그라운드로 전환될 때까지 대기 |
kill | - | 앱 종료 및 재시작 대기 |
date | ISO 날짜 문자열 | 특정 날짜/시간까지 대기 |
nativeVersion | 버전 문자열 | Native Build 업데이트 대기 |
cancelDelay()
“cancelDelay()” 섹션모든 지연 조건을 해제하고 다음 체크 시 즉시 업데이트를 적용합니다.
await updater.cancelDelay();기기 식별
“기기 식별” 섹션getDeviceId()
“getDeviceId()” 섹션고유한 디바이스 식별자를 가져옵니다.
const deviceId = await updater.getDeviceId();// 'uuid-xxxx-xxxx-xxxx'setCustomId(options)
“setCustomId(options)” 섹션디바이스에 사용자 정의 식별자를 설정합니다 (분석용으로 유용함).
await updater.setCustomId({ customId: 'user-123' });setUpdateUrl(options)
“setUpdateUrl(options)” 섹션런타임에 업데이트 서버 URL을 변경합니다.
await updater.setUpdateUrl({ url: 'https://my-server.com/updates' });setStatsUrl(options)
“setStatsUrl(options)” 섹션통계 보고 URL을 변경합니다.
await updater.setStatsUrl({ url: 'https://my-server.com/stats' });setChannelUrl(options)
“setChannelUrl(options)” 섹션채널 관리 URL을 변경합니다.
await updater.setChannelUrl({ url: 'https://my-server.com/channel' });setAppId(options)
“setAppId(options)” 섹션런타임에 App ID를 변경합니다.
await updater.setAppId({ appId: 'com.example.newapp' });getAppId()
“getAppId()” 섹션현재 App ID를 가져옵니다.
const appId = await updater.getAppId();디버그
“Debug” 섹션setDebugMenu(options)
“setDebugMenu(options)” 섹션디버그 메뉴를 활성화하거나 비활성화합니다.
await updater.setDebugMenu({ enabled: true });isDebugMenuEnabled()
“isDebugMenuEnabled()” 섹션디버그 메뉴가 활성화되어 있는지 확인합니다.
const enabled = await updater.isDebugMenuEnabled();이벤트
“Events” 섹션다음 명령어를 사용하여 업데이트 이벤트를 수신하세요: addListener:
updater.addListener('eventName', (event) => { // Handle event});사용 가능한 이벤트
“사용 가능한 이벤트” 섹션| 이벤트 | 페이로드 | 설명 |
|---|---|---|
download | { percent, status } | 다운로드 진행 상태 업데이트 |
updateAvailable | { bundle } | 새 업데이트 사용 가능 |
noNeedUpdate | { message } | 이미 최신 버전입니다 |
downloadComplete | { bundle } | 다운로드 완료 |
downloadFailed | { bundle, error } | 다운로드 실패 |
breakingAvailable | { bundle } | 호환되지 않는 업데이트가 있습니다 (네이티브 업데이트 필요) |
updateFailed | { bundle, reason } | 업데이트 설치 실패 |
appReloaded | {} | 앱이 다시 로드되었습니다 |
appReady | {} | notifyAppReady() 호출됨 |
예제: 전체 이벤트 핸들링
“Example: Full Event Handling” 섹션// Progress trackingupdater.addListener('download', (event) => { updateProgressBar(event.percent);});
// Update available notificationupdater.addListener('updateAvailable', (event) => { showNotification(`Update ${event.bundle.version} available!`);});
// Handle completionupdater.addListener('downloadComplete', async (event) => { // Queue for next restart await updater.next({ id: event.bundle.id }); showNotification('Update will apply on next restart');});
// Handle failuresupdater.addListener('updateFailed', (event) => { console.error('Update failed:', event.reason); reportError(event);});생성자 옵션
“Constructor Options” 섹션다음의 전체 구성 옵션 ElectronUpdater:
const updater = new ElectronUpdater({ // Required appId: 'com.example.app',
// Version override version: '1.0.0', // Override builtin version detection
// Server URLs updateUrl: 'https://plugin.capgo.app/updates', channelUrl: 'https://plugin.capgo.app/channel_self', statsUrl: 'https://plugin.capgo.app/stats',
// Behavior autoUpdate: true, // Enable automatic update checks appReadyTimeout: 10000, // Milliseconds before rollback (default: 10000) autoDeleteFailed: true, // Auto-delete failed bundles autoDeletePrevious: true, // Auto-delete old bundles resetWhenUpdate: true, // Reset to builtin on native update
// Channels defaultChannel: 'production',
// Direct Update Mode directUpdate: false, // 'atInstall' | 'onLaunch' | 'always' | false
// Security publicKey: '...', // RSA public key for E2E encryption
// Dynamic Configuration allowModifyUrl: false, // Allow runtime URL changes allowModifyAppId: false, // Allow runtime App ID changes persistCustomId: false, // Persist custom ID across updates persistModifyUrl: false, // Persist URL changes
// Debug debugMenu: false, // Enable debug menu (Ctrl+Shift+D) disableJSLogging: false, // Disable console logs
// Periodic Updates periodCheckDelay: 0, // Seconds between auto-checks (0 = disabled, min 600)});Electron Updater API 레퍼런스에서 계속하기
“Electron Updater API Reference 계속하기” 섹션사용 중이라면 Electron Updater API 레퍼런스 대시보드 및 API 운영을 계획하려면, 이를 다음과 연결하세요 @capgo/electron-updater 사용하기 @capgo/electron-updater 사용하기에서 네이티브 기능을 위해, API 개요 구현 세부 사항은 API 개요에서 소개 구현 세부 사항은 소개에서 API 키 API Keys의 구현 세부 사항은, 기기 Devices의 구현 세부 사항은.