Skip to content

Electron Project Integration Reference Using Official electron-updater Component

1. Introduction to Official electron-updater Component

The official electron-updater component provided by Electron supports automatic application updates through update servers or static files, with core features including:

  • Version checking compatible with Electron update protocol
  • Cross-platform installation package download and installation process
  • Flexible update strategy configuration

Core Resources

Overall Logic: By calling the upgrade strategy API provided by UpgradeLink, the electron-updater component executes the specific update process, achieving seamless integration with the official update system.

Integration Flowchart

2. Integration Core Steps

Reference electron-demo project address

1. Install Official Update Component

2. Read Official Dynamic Update Server Documentation, Understand Integration Process. Documentation Address

UpgradeLink provides update API that fully complies with the request parameters and response structure required by the official specification, allowing for seamless replacement.

3. Add dev-update.yml File to Configure Update Package Download Address

yaml
provider: generic
updaterCacheDirName: electron-demo-updater # Download directory

4. Code Replacement, Adjust Check Update Method

Based on the official check update code, we only need to replace the interface address in the official checkForUpdates method with the address provided by UpgradeLink.

javascript
// Print related parameters
console.log(app.getVersion());
console.log(process.platform);
console.log(process.arch);

const FeedURL = `https://api.upgrade.toolsetlink.com/v1/electron/upgrade?electronKey=kPUtUMDIjBhS48q5771pow&versionName=${app.getVersion()}&appointVersionName=&devModelKey=&devKey=&platform=${process.platform}&arch=${process.arch}`;
autoUpdater.setFeedURL({
    url: FeedURL,
    provider: 'generic',
});
autoUpdater.requestHeaders = {
    'X-AccessKey': 'mui2W50H1j-OC4xD6PgQag',
};

const result = await autoUpdater.checkForUpdates();
// Print return result
console.log("result: ", result);

5. Code Replacement, Adjust Download and Update Method, Adjust Download Address to the Address Returned by Check Update Interface

javascript
const FeedURL = `https://api.upgrade.toolsetlink.com/v1/electron/upgrade?electronKey=kPUtUMDIjBhS48q5771pow&versionName=${app.getVersion()}&appointVersionName=&devModelKey=&devKey=&platform=${process.platform}&arch=${process.arch}`;
autoUpdater.setFeedURL({
    url: FeedURL,
    provider: 'generic',
});
autoUpdater.requestHeaders = {
    'X-AccessKey': 'mui2W50H1j-OC4xD6PgQag',
};
const result = await autoUpdater.checkForUpdates();

// Print check update interface return result
console.log(result);

autoUpdater.setFeedURL({
    url: result.updateInfo.path,
    provider: 'generic',
});
console.log('[Process] Download update started, URL:', result.updateInfo.path);
try {
    await autoUpdater.downloadUpdate();
    console.log('[Process] Download update completed');
} catch (e) {
    console.error('[Process] Download update failed:', e);
    console.error('[DEBUG] Error stack:', e.stack);
    throw e;
}

The update protocol request parameters (such as platform, arch) and response structure are fully compatible with the official specification by UpgradeLink, allowing direct replacement.

The above is the integration guide. If you need to adjust content details or supplement specific scenario descriptions, please inform specific requirements.

toolsetlink@163.com