Electron Updater API
설치 단계와 이 플러그인의 전체 마크다운 가이드를 포함하여 설정 명령을 복사할 수 있습니다.
이 페이지에서는 Electron Updater의 모든 사용 가능한 메서드, 이벤트 및 구성 옵션을 문서화합니다.
핵심 메서드
Core MethodsnotifyAppReady()
앱 준비 알림notifyAppReady() 각 앱 런칭마다 호출해야 함
await updater.notifyAppReady();업데이트 실패로 간주하고 이전 버전으로 롤백
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 | 문자열 | 예 | 다운로드할 번들의 URL |
version | 문자열 | 예 | 버전 식별자 |
checksum | 문자열 | 아니오 | SHA256 체크섬 |
sessionKey | 문자열 | 아니오 | 암호화된 버블에 대한 세션 키 |
반환: BundleInfo 객체 id, version, status
다음(options)
다음(options) 섹션다음 앱 재시작 시 로드할 버블을 큐에 추가합니다.
await updater.next({ id: 'bundle-id' });매개 변수:
| 옵션 | 타입 | 필수 | 설명 |
|---|---|---|---|
id | 문자열 | 네 | Bundle ID를 큐에 추가 |
set(options)
set(options) 섹션즉시 앱을 재로드하고 Bundle로 Switch합니다.
await updater.set({ id: 'bundle-id' });매개 변수:
| 옵션 | 타입 | 필수 | 설명 |
|---|---|---|---|
id | 문자열 | 네 | 활성화할 번들 ID |
재로드
재로드앱을 현재 번들과 재로드합니다.
await updater.reload();삭제(options)
삭제(options) 섹션스토리지에서 패키지를 삭제합니다.
await updater.delete({ id: 'bundle-id' });매개 변수:
| 옵션 | 타입 | 필수 | 설명 |
|---|---|---|---|
id | 문자열 | 네 | 삭제할 번들 ID |
reset(options)
reset(options) 섹션빌트인 버전 또는 마지막 성공 번들을 재설정합니다.
// Reset to builtinawait updater.reset({ toLastSuccessful: false });
// Reset to last successful bundleawait updater.reset({ toLastSuccessful: true });매개 변수:
| 옵션 | 타입 | 필수 | 설명 |
|---|---|---|---|
toLastSuccessful | boolean | 아니오 | true로 설정하면 마지막 성공한 버블 대신 빌트인으로 초기화합니다. |
버블 정보
버블 정보현재()
현재()현재 버블 및 네이티브 버전에 대한 정보를 가져옵니다.
const info = await updater.current();// { bundle: { id, version, status }, native: '1.0.0' }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 | 문자열 | 다운로드 URL (업데이트가 없으면 빈 문자열) |
version | 문자열 | 사용 가능한 버전 |
checksum | 문자열 | SHA256 체크섬 |
sessionKey | 문자열 | 암호화 세션 키 |
error | 문자열 | 체크 실패 시 오류 메시지 |
message | 문자열 | 서버 메시지 |
채널 관리
채널 관리 섹션setChannel(옵션)
Section titled “채널 설정하기(options)”장치에 특정 채널 assignment.
await updater.setChannel({ channel: 'beta' });unsetChannel(옵션)
unsetChannel(옵션)기본 채널 사용을 위해 채널 assignment 제거.
await updater.unsetChannel();getChannel()
채널 가져오기현재 채널 assignment 가져오기.
const channel = await updater.getChannel();// { channel: 'production', status: 'set' }listChannels()
listChannels()이 앱의 모든 채널을 목록화합니다.
const channels = await updater.listChannels();// ['production', 'beta', 'staging']Delay Conditions
다운로드된 업데이트가 적용되는 시기를 제어합니다.setMultiDelay(options)
Delay Conditions
업데이트가 적용되기 전에 충족해야 하는 조건을 설정합니다.Delay Condition Types:
// 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' } ]});종류
| Kind | 값 | 설명 |
|---|---|---|
background | 선택적 지속 시간 (ms) | 앱이 백그라운드에 있기를 기다립니다. |
kill | - | 앱이 죽고 다시 시작될 때까지 기다립니다. |
date | ISO 날짜 문자열 | 특정 날짜/시간까지 기다립니다. |
nativeVersion | 버전 문자열 | 원시 앱 업데이트를 기다립니다. |
cancelDelay()
cancelDelay() 제목모든 지연 조건을 취소하고 다음 체크 시 즉시 업데이트를 적용합니다.
await updater.cancelDelay();기기 식별
기기 식별getDeviceId()
getDeviceId()기기 고유 식별자를 가져옵니다.
const deviceId = await updater.getDeviceId();// 'uuid-xxxx-xxxx-xxxx'setCustomId(options)
기기 식별자에 사용할 수 있는 분석을 위한 사용자 정의 식별자를 설정합니다.설정
await updater.setCustomId({ customId: 'user-123' });기기 식별
설정설정 URL 설정
설정 URL 설정런타임에 업데이트 서버 URL을 변경합니다.
await updater.setUpdateUrl({ url: 'https://my-server.com/updates' });통계 URL 설정
설정 URL 설정통계 보고 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(옵션)
setAppId(options) 섹션실행 중에 App ID를 변경합니다.
await updater.setAppId({ appId: 'com.example.newapp' });getAppId()
getAppId() 섹션현재 앱 ID를 가져옵니다.
const appId = await updater.getAppId();디버그
디버그 섹션설정 메뉴 디버그( setDebugMenu(options) )
디버그 메뉴 섹션디버그 메뉴를 활성화하거나 비활성화합니다.
await updater.setDebugMenu({ enabled: true });isDebugMenuEnabled()
debug 메뉴가 활성화되어 있는지 확인합니다.debug 메뉴가 활성화되어 있는지 확인합니다.
const enabled = await updater.isDebugMenuEnabled();이벤트
이벤트업데이트 이벤트를 듣기 위해 사용하는 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() 호출되었습니다 |
예제: 전체 이벤트 처리
제목이 "예제: 전체 이벤트 처리"인 섹션// 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);});생성자 옵션
생성자 옵션 섹션생성자 옵션의 전체 구성 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 참조에서 계속하기 섹션Electron Updater __CAPGO_KEEP_0__ 참조를 사용하여 Electron Updater API 참조 Electron Updater API 참조를 사용하여 대시보드와 API 작업을 계획하고 연결하세요. Electron Updater capgo/electron-updater를 사용하여 Electron Updater capgo/electron-updater를 사용하여 native 기능을 사용합니다. Electron Updater API 개요 API 개요에 대한 구현 세부 정보를 위해 소개 __CAPGO_KEEP_0__ 키에 대한 구현 세부 정보를 위해 API 키 for API 구현 세부 사항에 대한 Devices __CAPGO_KEEP_0__에 대한 구현 세부 정보를 위해