CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-electron-forge--maker-deb

Deb maker for Electron Forge that creates Debian packages for Linux distribution

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

Electron Forge Maker Deb

Electron Forge Maker Deb is a TypeScript library that creates Debian (.deb) packages for Electron applications. It provides a maker plugin for the Electron Forge build system, enabling developers to package their Electron apps for Debian-based Linux distributions like Ubuntu. The package integrates with the electron-installer-debian tool and handles architecture mapping, external dependencies, and comprehensive Debian package configuration.

Package Information

  • Package Name: @electron-forge/maker-deb
  • Package Type: npm
  • Language: TypeScript
  • Installation: yarn add @electron-forge/maker-deb or npm install @electron-forge/maker-deb

Core Imports

import MakerDeb, { debianArch, MakerDebConfig } from "@electron-forge/maker-deb";

Named imports:

import { MakerDeb, debianArch, MakerDebConfig } from "@electron-forge/maker-deb";

For CommonJS:

const MakerDeb = require("@electron-forge/maker-deb");
const { MakerDeb: NamedMakerDeb, debianArch } = require("@electron-forge/maker-deb");

Basic Usage

import MakerDeb from "@electron-forge/maker-deb";

// Configure the maker in your forge.config.js
const config = {
  makers: [
    {
      name: '@electron-forge/maker-deb',
      config: {
        options: {
          maintainer: 'The Forgers',
          homepage: 'https://example.com',
          icon: 'path/to/icon.svg',
          section: 'utils',
          priority: 'optional'
        }
      }
    }
  ]
};

// Or use programmatically
const maker = new MakerDeb({
  options: {
    maintainer: 'Your Name',
    homepage: 'https://yourapp.com',
    icon: './assets/icon.png'
  }
});

Architecture

The Maker Deb package is built around several key components:

  • MakerDeb Class: Extends the base Maker class from @electron-forge/maker-base and implements Debian-specific packaging logic
  • Architecture Mapping: Converts Node.js architecture names to Debian package architecture conventions
  • Configuration System: Comprehensive options for customizing Debian package metadata and behavior
  • External Dependencies: Requires system binaries (dpkg, fakeroot) and optional electron-installer-debian package
  • Platform Support: Designed specifically for Linux platform with cross-platform development support

Capabilities

Debian Package Creation

Core functionality for creating .deb packages from Electron applications, with full Debian package specification compliance.

class MakerDeb extends MakerBase<MakerDebConfig> {
  /** Maker identifier */
  name: string;
  
  /** Supported platforms for this maker */
  defaultPlatforms: ForgePlatform[];
  
  /** Required external system binaries */
  requiredExternalBinaries: string[];
  
  /** Check if maker is supported on current platform */
  isSupportedOnCurrentPlatform(): boolean;
  
  /** Create Debian package from Electron application */
  make(options: MakerOptions): Promise<string[]>;
}

Inherited Methods

The MakerDeb class inherits additional utility methods from MakerBase:

class MakerDeb extends MakerBase<MakerDebConfig> {
  /** Helper method to ensure directory exists and is empty */
  ensureDirectory(dir: string): Promise<void>;
  
  /** Helper method to ensure file path exists and file does not exist */
  ensureFile(file: string): Promise<void>;
  
  /** Check if external binaries exist on the system */
  externalBinariesExist(): boolean;
  
  /** Throw error if external binaries don't exist */
  ensureExternalBinariesExist(): void;
  
  /** Check if a Node.js module is installed */
  isInstalled(module: string): boolean;
  
  /** Normalize semver version to 4-part Windows format */
  normalizeWindowsVersion(version: string): string;
}

Architecture Conversion

Utility function for converting Node.js architecture names to Debian package architecture conventions.

/**
 * Convert Node.js architecture to Debian package architecture
 * @param nodeArch - Node.js architecture identifier
 * @returns Debian architecture string
 */
function debianArch(nodeArch: ForgeArch): string;

Usage Examples:

import { debianArch } from "@electron-forge/maker-deb";

// Architecture conversions
console.log(debianArch('x64'));     // 'amd64'
console.log(debianArch('ia32'));    // 'i386'
console.log(debianArch('armv7l'));  // 'armhf'
console.log(debianArch('arm'));     // 'armel'
console.log(debianArch('arm64'));   // 'arm64' (passed through)

Package Configuration

Comprehensive configuration options for customizing Debian package metadata, dependencies, and behavior.

interface MakerDebConfig {
  /** Configuration options for Debian package creation */
  options?: MakerDebConfigOptions;
}

interface MakerDebConfigOptions {
  /** Package name for Debian control specification */
  name?: string;
  
  /** Application name for desktop specification */
  productName?: string;
  
  /** Generic application name for desktop specification */
  genericName?: string;
  
  /** Short description for control specification */
  description?: string;
  
  /** Long description for control specification */
  productDescription?: string;
  
  /** Package version for control specification */
  version?: string;
  
  /** Package revision for control specification */
  revision?: string;
  
  /** Application category for Debian package classification */
  section?: 'admin' | 'cli-mono' | 'comm' | 'database' | 'debian-installer' | 'debug' | 'devel' | 'doc' | 'editors' | 'education' | 'electronics' | 'embedded' | 'fonts' | 'games' | 'gnome' | 'gnu-r' | 'gnustep' | 'graphics' | 'hamradio' | 'haskell' | 'httpd' | 'interpreters' | 'introspection' | 'java' | 'javascript' | 'kde' | 'kernel' | 'libdevel' | 'libs' | 'lisp' | 'localization' | 'mail' | 'math' | 'metapackages' | 'misc' | 'net' | 'news' | 'ocaml' | 'oldlibs' | 'otherosfs' | 'perl' | 'php' | 'python' | 'ruby' | 'rust' | 'science' | 'shells' | 'sound' | 'tasks' | 'tex' | 'text' | 'utils' | 'vcs' | 'video' | 'virtual' | 'web' | 'x11' | 'xfce' | 'zope';
  
  /** Package priority level */
  priority?: 'required' | 'important' | 'standard' | 'optional';
  
  /** Estimated disk space requirement in kilobytes */
  size?: number;
  
  /** Package dependencies */
  depends?: string[];
  
  /** Recommended packages */
  recommends?: string[];
  
  /** Suggested packages */
  suggests?: string[];
  
  /** Enhanced packages */
  enhances?: string[];
  
  /** Pre-dependencies */
  preDepends?: string[];
  
  /** Package maintainer contact information */
  maintainer?: string;
  
  /** Homepage URL for the application */
  homepage?: string;
  
  /** Relative path to executable binary */
  bin?: string;
  
  /** Path to application icon file */
  icon?: string;
  
  /** Desktop application categories */
  categories?: ('AudioVideo' | 'Audio' | 'Video' | 'Development' | 'Education' | 'Game' | 'Graphics' | 'Network' | 'Office' | 'Science' | 'Settings' | 'System' | 'Utility')[];
  
  /** Supported MIME types */
  mimeType?: string[];
  
  /** Lintian override rules */
  lintianOverrides?: string[];
  
  /** Package maintainer scripts */
  scripts?: {
    /** Pre-installation script path */
    preinst?: string;
    /** Post-installation script path */
    postinst?: string;
    /** Pre-removal script path */
    prerm?: string;
    /** Post-removal script path */
    postrm?: string;
  };
  
  /** Custom desktop entry template path */
  desktopTemplate?: string;
}

Configuration Examples:

// Basic configuration
const basicConfig: MakerDebConfig = {
  options: {
    maintainer: 'Your Name <you@example.com>',
    homepage: 'https://yourapp.com',
    description: 'Your awesome Electron application',
    section: 'utils',
    priority: 'optional'
  }
};

// Advanced configuration with dependencies
const advancedConfig: MakerDebConfig = {
  options: {
    maintainer: 'Development Team <dev@company.com>',
    homepage: 'https://company.com/products/app',
    description: 'Professional data analysis tool',
    productDescription: 'A comprehensive data analysis application built with Electron, featuring advanced visualization and reporting capabilities.',
    section: 'science',
    priority: 'optional',
    categories: ['Office', 'Science'],
    depends: ['libnss3', 'libatk-bridge2.0-0'],
    recommends: ['ca-certificates'],
    icon: './assets/app-icon.png',
    scripts: {
      postinst: './debian/postinst',
      prerm: './debian/prerm'
    }
  }
};

Types

/** Forge architecture types from @electron-forge/shared-types */
type ForgeArch = 'ia32' | 'x64' | 'armv7l' | 'arm64' | 'mips64el' | 'universal' | 'arm';

/** Forge platform types from @electron-forge/shared-types */
type ForgePlatform = 'darwin' | 'mas' | 'win32' | 'linux';

/** Maker options interface from @electron-forge/maker-base */
interface MakerOptions {
  /** Directory containing the packaged Electron application */
  dir: string;
  /** Directory for output artifacts */
  makeDir: string;
  /** Human-friendly project name */
  appName: string;
  /** Target platform */
  targetPlatform: ForgePlatform;
  /** Target architecture */
  targetArch: ForgeArch;
  /** Resolved forge configuration */
  forgeConfig: ResolvedForgeConfig;
  /** Application package.json */
  packageJSON: any;
}

/** Resolved forge configuration from @electron-forge/shared-types */
interface ResolvedForgeConfig {
  /** Build identifier for uniquely identifying artifacts */
  buildIdentifier?: string | (() => string);
  /** Output directory (default: './out') */
  outDir?: string;
  /** Forge plugins configuration */
  plugins: ForgeConfigPlugin[];
}

System Requirements

The Maker Deb package requires specific external dependencies to function:

  • dpkg: Debian package management tool for creating .deb files
  • fakeroot: Tool providing fake root privileges for package creation
  • electron-installer-debian: Optional dependency for the underlying packaging functionality

Installation on Ubuntu/Debian:

sudo apt-get install dpkg fakeroot

Installation on macOS (via Homebrew):

brew install dpkg fakeroot

Error Handling

The maker will throw errors in the following scenarios:

  • Missing external binaries: When dpkg or fakeroot are not installed on the system
  • Unsupported platform: When trying to create .deb packages on unsupported platforms
  • Missing electron-installer-debian: When the optional dependency is not available
  • Invalid configuration: When required configuration options are missing or malformed
  • File system errors: When unable to create output directories or write package files

Example error handling:

try {
  const maker = new MakerDeb(config);
  const packagePaths = await maker.make(options);
  console.log('Created packages:', packagePaths);
} catch (error) {
  if (error.message.includes('external binaries')) {
    console.error('Install required system dependencies: dpkg, fakeroot');
  } else if (error.message.includes('electron-installer-debian')) {
    console.error('Install electron-installer-debian package');
  } else {
    console.error('Package creation failed:', error.message);
  }
}

Install with Tessl CLI

npx tessl i tessl/npm-electron-forge--maker-deb
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@electron-forge/maker-deb@7.8.x
Publish Source
CLI
Badge
tessl/npm-electron-forge--maker-deb badge