본문 바로가기
@capgo/electron-updater 업데이트 오픈 소스

Electron Updater Electron 플러그인

capacitor-updater와 동일한 API surface를 제공하는 Electron 앱용 OTA 라이브 업데이트

설치

bun add @capgo/electron-updater
npm, pnpm 또는 yarn
  • npm install @capgo/electron-updater
  • pnpm add @capgo/electron-updater
  • yarn add @capgo/electron-updater

가이드

Electron에서 Electron Updater 사용 방법

@capgo/electron-updater 사용하기

@capgo/electron-updater Electron 앱에 Capgo와 동일한 Live Update 모델을 제공합니다. @capgo/capacitor-updater메인 프로세스에서 초기화하고, preload를 통해 renderer bridge를 노출한 뒤 호출하세요. notifyAppReady() 번들이 정상인지 rollback protection이 확인할 수 있도록 실행 시마다 수행합니다.

설치

bun add @capgo/electron-updater

Main process 설정

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());
});

Preload bridge

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() rollback protection이 의도대로 작동하도록 renderer 초기 단계에서 실행합니다.
  • 내장된 경로는 고정하고, 업데이트 도구가 배포된 번들을 로드할지 다운로드된 번들을 로드할지 결정하게 합니다.
  • Electron 앱이 백엔드 릴리스 파이프라인을 공유한다면, 모바일에서 사용 중인 Capgo 채널과 롤아웃 모델을 그대로 재사용하세요.

@capgo/electron-updater 사용하기 단계부터 계속 진행하세요

사용 중이라면 @capgo/electron-updater 사용하기 네이티브 플러그인 작업을 계획하려면, 이를 다음 항목과 연결하세요: @capgo/electron-updater @capgo/electron-updater의 구현 세부 사항은 Electron Updater 시작하기 Electron Updater 시작하기에서의 구현 세부 사항은 Capgo 플러그인 디렉토리 Capgo Plugin Directory의 제품 워크플로우에 맞춰, Capgo의 Capacitor 플러그인 Capgo의 Capacitor Plugins 구현 세부 사항 및 플러그인 추가 또는 업데이트 플러그인 추가 또는 업데이트의 구현 세부 사항은.

자주 묻는 질문

Electron Updater 플러그인 FAQ

Electron 앱에 Electron Updater 플러그인을 어떻게 설치하나요?

"bun add @capgo/electron-updater" (또는 "npm install @capgo/electron-updater")를 실행한 다음, 가이드와 GitHub README에 있는 Electron 설정 단계를 따르세요.

@capgo/electron-updater가 React, Vue, Angular와 호환되나요?

네. Electron Updater는 Electron 패키지이므로 Electron에서 실행되는 React, Vue, Angular, Svelte 및 일반 JavaScript 등 모든 웹 프레임워크와 호환됩니다.

@capgo/electron-updater는 무료 오픈 소스인가요?

네. code 소스 코드는 GitHub의 https://github.com/Cap-go/electron-updater/에서 공개되어 있으며, npm에서 무료로 설치할 수 있습니다. 버그 리포트와 pull request를 환영합니다.

앱 심사 대기 없이 Electron Updater 변경 사항 배포

스토어 빌드에 플러그인이 포함되면, Capgo live updates로 JavaScript, HTML, CSS 변경 사항을 몇 분 만에 사용자에게 푸시할 수 있습니다.

Capgo로 시작하기