or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

auto-updater.mdconfiguration.mdcore-updaters.mdevents.mdindex.mdplatform-updaters.mdproviders.mdtypes.md
tile.json

platform-updaters.mddocs/

Platform-Specific Updaters

Platform-specific updater implementations for different operating systems and package formats. Each updater is optimized for its target platform's update mechanisms and conventions.

Capabilities

NsisUpdater (Windows)

Windows NSIS installer updater with support for differential downloads and code signature verification.

/**
 * Windows NSIS installer updater
 * Supports differential downloads and code signature verification
 */
class NsisUpdater extends BaseUpdater {
  // Custom installation directory (optional)
  installDirectory?: string;
  
  // Code signature verification function
  verifyUpdateCodeSignature: VerifyUpdateCodeSignature;
}

/**
 * Function type for verifying code signatures
 * @param publisherName Array of expected publisher names
 * @param path Path to the executable to verify
 * @returns Promise resolving to null if verification succeeds, error message if it fails
 */
type VerifyUpdateCodeSignature = (publisherName: string[], path: string) => Promise<string | null>;

Usage Examples:

import { NsisUpdater } from "electron-updater";

const updater = new NsisUpdater({
  provider: "github",
  owner: "myorg",
  repo: "myapp"
});

// Custom installation directory
updater.installDirectory = "C:\\Program Files\\MyApp";

// Enable code signature verification
updater.verifyUpdateCodeSignature = async (publisherNames, executablePath) => {
  try {
    const signature = await verifyExecutableSignature(executablePath);
    if (publisherNames.includes(signature.publisherName)) {
      return null; // Verification successful
    }
    return `Untrusted publisher: ${signature.publisherName}`;
  } catch (error) {
    return `Signature verification failed: ${error.message}`;
  }
};

// Configure differential downloads
updater.disableDifferentialDownload = false; // Enable for faster updates

// Install silently without user interaction
updater.on("update-downloaded", () => {
  updater.quitAndInstall(true, true); // silent=true, forceRunAfter=true
});

MacUpdater (macOS)

macOS application updater using the Squirrel.Mac framework for seamless app updates.

/**
 * macOS application updater using Squirrel.Mac
 * Handles .zip and .dmg update packages
 */
class MacUpdater extends BaseUpdater {
  // Inherits all BaseUpdater functionality
  // No additional public properties or methods
}

Usage Examples:

import { MacUpdater } from "electron-updater";

const updater = new MacUpdater({
  provider: "github",
  owner: "myorg", 
  repo: "myapp"
});

// macOS-specific behavior
updater.autoRunAppAfterInstall = true; // Run app after update

updater.on("update-downloaded", () => {
  // Show macOS notification
  new Notification("Update Ready", {
    body: "Your app will be updated when you restart."
  });
  
  updater.quitAndInstall(); // Restart and install
});

AppImageUpdater (Linux)

Linux AppImage updater with support for SNAP environment detection.

/**
 * Linux AppImage updater
 * Supports SNAP environment and standard Linux distributions
 */
class AppImageUpdater extends BaseUpdater {
  /**
   * Check if updater is active (running as AppImage or in SNAP environment)
   * @returns true if running as AppImage or SNAP_NAME is set
   */
  isUpdaterActive(): boolean;
}

Usage Examples:

import { AppImageUpdater } from "electron-updater";

const updater = new AppImageUpdater({
  provider: "generic",
  url: "https://releases.myapp.com"
});

// Check if running as AppImage
if (!updater.isUpdaterActive()) {
  console.log("Not running as AppImage, updates disabled");
  return;
}

// AppImage-specific behavior
updater.on("appimage-filename-updated", (path) => {
  console.log("AppImage path updated:", path);
});

updater.on("update-downloaded", () => {
  // AppImage updates replace the current file
  updater.quitAndInstall();
});

LinuxUpdater (Abstract Base)

Abstract base class for Linux package manager updaters with root permission handling.

/**
 * Abstract base class for Linux package manager updaters
 */
abstract class LinuxUpdater extends BaseUpdater {
  /**
   * Check if running as root user
   * @returns true if process.getuid() === 0
   */
  protected isRunningAsRoot(): boolean;
  
  /**
   * Execute command with sudo if not running as root
   * @param commandWithArgs Array of command and arguments
   * @returns Command output
   */
  protected runCommandWithSudoIfNeeded(commandWithArgs: string[]): string;
}

DebUpdater (Debian Packages)

Debian package (.deb) updater for Ubuntu, Debian, and derivatives.

/**
 * Debian package (.deb) updater
 * Uses dpkg for installation, requires root privileges
 */
class DebUpdater extends LinuxUpdater {
  // Inherits LinuxUpdater functionality
  // Uses 'dpkg -i' for installation
}

Usage Examples:

import { DebUpdater } from "electron-updater";

const updater = new DebUpdater({
  provider: "generic",
  url: "https://updates.myapp.com/linux"
});

updater.on("update-downloaded", () => {
  // Will prompt for sudo password if not root
  updater.quitAndInstall(true); // Silent installation
});

// Handle permission errors
updater.on("error", (error) => {
  if (error.message.includes("EACCES")) {
    console.error("Installation requires administrator privileges");
  }
});

RpmUpdater (RPM Packages)

RPM package (.rpm) updater for Red Hat, CentOS, Fedora, and derivatives.

/**
 * RPM package (.rpm) updater  
 * Uses rpm command for installation, requires root privileges
 */
class RpmUpdater extends LinuxUpdater {
  // Inherits LinuxUpdater functionality
  // Uses 'rpm -U' for installation
}

Usage Examples:

import { RpmUpdater } from "electron-updater";

const updater = new RpmUpdater({
  provider: "s3",
  bucket: "myapp-updates",
  region: "us-east-1"
});

updater.logger = console;

updater.on("update-downloaded", () => {
  console.log("RPM package downloaded, installing...");
  updater.quitAndInstall();
});

PacmanUpdater (Arch Packages)

Pacman package updater for Arch Linux and derivatives.

/**
 * Pacman package updater for Arch Linux
 * Uses pacman command for installation, requires root privileges  
 */
class PacmanUpdater extends LinuxUpdater {
  // Inherits LinuxUpdater functionality
  // Uses 'pacman -U' for installation
}

Usage Examples:

import { PacmanUpdater } from "electron-updater";

const updater = new PacmanUpdater({
  provider: "github",
  owner: "myorg",
  repo: "myapp"
});

// Arch Linux specific handling
updater.on("update-downloaded", () => {
  console.log("Package downloaded, will install with pacman");
  updater.quitAndInstall(true); // Install silently
});

Platform Selection Logic

The autoUpdater automatically selects the appropriate platform updater:

// Platform detection logic (internal)
function selectPlatformUpdater(): AppUpdater {
  if (process.platform === "win32") {
    return new NsisUpdater();
  } else if (process.platform === "darwin") {
    return new MacUpdater();
  } else {
    // Linux - default to AppImage
    let updater = new AppImageUpdater();
    
    try {
      // Check for package type indicator
      const packageTypePath = path.join(process.resourcesPath, "package-type");
      if (fs.existsSync(packageTypePath)) {
        const packageType = fs.readFileSync(packageTypePath, "utf8").trim();
        
        switch (packageType) {
          case "deb":
            updater = new DebUpdater();
            break;
          case "rpm": 
            updater = new RpmUpdater();
            break;
          case "pacman":
            updater = new PacmanUpdater();
            break;
        }
      }
    } catch (error) {
      console.warn("Unable to detect package type:", error.message);
    }
    
    return updater;
  }
}

Common Patterns

Error Handling

// Platform-specific error handling
updater.on("error", (error, message) => {
  if (process.platform === "linux") {
    if (error.message.includes("EACCES")) {
      showPermissionDialog();
    } else if (error.message.includes("dpkg") || error.message.includes("rpm")) {
      showPackageManagerError();
    }
  } else if (process.platform === "win32") {
    if (error.message.includes("code signature")) {
      showSecurityWarning();
    }
  }
});

Installation Options

// Platform-specific installation behavior
updater.on("update-downloaded", () => {
  if (process.platform === "win32") {
    // Windows: silent install with app restart
    updater.quitAndInstall(true, true);
  } else if (process.platform === "darwin") {
    // macOS: standard install with user notification
    updater.quitAndInstall();
  } else {
    // Linux: may require sudo, install silently
    updater.quitAndInstall(true);
  }
});

Custom Updater Selection

import { 
  NsisUpdater, 
  MacUpdater, 
  AppImageUpdater, 
  DebUpdater 
} from "electron-updater";

// Manual updater selection based on environment
function createUpdater(config) {
  const platform = process.env.FORCE_PLATFORM || process.platform;
  
  switch (platform) {
    case "win32":
      return new NsisUpdater(config);
    case "darwin":
      return new MacUpdater(config);
    case "linux":
      // Custom Linux detection logic
      if (fs.existsSync("/usr/bin/dpkg")) {
        return new DebUpdater(config);
      } else {
        return new AppImageUpdater(config);
      }
    default:
      throw new Error(`Unsupported platform: ${platform}`);
  }
}

const updater = createUpdater({
  provider: "github",
  owner: "myorg",
  repo: "myapp"
});