or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

build-distribution.mddevelopment-workflow.mdindex.mdproject-management.mdutilities.md
tile.json

tessl/npm-electron-forge--cli

A complete tool for building modern Electron applications

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@electron-forge/cli@7.8.x

To install, run

npx @tessl/cli install tessl/npm-electron-forge--cli@7.8.0

index.mddocs/

Electron Forge CLI

Electron Forge CLI is a complete command-line tool for building modern Electron applications. It provides a unified toolchain that simplifies the entire Electron development workflow from project creation to distribution, offering commands for initializing projects, starting development servers, building applications, packaging for distribution, and publishing to various platforms.

Package Information

  • Package Name: @electron-forge/cli
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install -g @electron-forge/cli

Core Imports

Electron Forge CLI is primarily used as a command-line tool via the electron-forge binary. For programmatic usage:

import { getMakeOptions } from "@electron-forge/cli/dist/electron-forge-make";
import { resolveWorkingDir } from "@electron-forge/cli/dist/util/resolve-working-dir";
import { checkSystem, checkPackageManager, SystemCheckContext } from "@electron-forge/cli/dist/util/check-system";
const { getMakeOptions } = require("@electron-forge/cli/dist/electron-forge-make");
const { resolveWorkingDir } = require("@electron-forge/cli/dist/util/resolve-working-dir");
const { checkSystem, checkPackageManager } = require("@electron-forge/cli/dist/util/check-system");

Basic Usage

# Install globally
npm install -g @electron-forge/cli

# Initialize a new Electron app
electron-forge init my-app

# Start development server
electron-forge start

# Package the application
electron-forge package

# Create distributables
electron-forge make

# Publish to distribution platforms
electron-forge publish

Architecture

Electron Forge CLI is built around several key components:

  • Command System: Built on Commander.js with separate files for each major command
  • System Validation: Pre-flight checks for git, package manager compatibility, and Node.js version
  • Core API Integration: Delegates all operations to @electron-forge/core API functions
  • Process Management: Handles Electron process lifecycle for development mode
  • Error Handling: Comprehensive error reporting and graceful process termination

Capabilities

Project Management

Core commands for creating and importing Electron projects with template support and configuration options.

// Init command options
interface InitOptions {
  dir: string;
  interactive: boolean;
  copyCIFiles?: boolean;
  force?: boolean;
  skipGit?: boolean;
  template?: string;
}

// Import command options  
interface ImportOptions {
  dir: string;
  interactive: boolean;
  skipGit?: boolean;
}

Project Management

Development Workflow

Development server and build commands for packaging and creating distributables.

// Start command options
interface StartOptions {
  dir: string;
  interactive: boolean;
  enableLogging?: boolean;
  runAsNode?: boolean;
  inspect?: boolean;
  inspectBrk?: boolean;
  appPath?: string;
  args?: string[];
}

// Package command options
interface PackageOptions {
  dir: string;
  interactive: boolean;
  arch?: string;
  platform?: string;
}

Development Workflow

Build and Distribution

Commands for creating distributables and publishing to various platforms.

// Make command options
interface MakeOptions {
  dir: string;
  interactive: boolean;
  skipPackage?: boolean;
  overrideTargets?: string[];
  arch?: string;
  platform?: string;
}

// Publish command options
interface PublishOptions {
  dir: string;
  interactive: boolean;
  dryRun?: boolean;
  dryRunResume?: boolean;
  publishTargets?: string[];
  makeOptions?: MakeOptions;
}

Build and Distribution

Utility Functions

Helper functions for directory resolution and system validation.

/**
 * Resolves the directory in which to use a CLI command
 * @param dir - Directory specified by user (relative or absolute)
 * @param checkExisting - Check if directory exists, fallback to cwd if not
 * @returns Resolved absolute directory path
 */
function resolveWorkingDir(dir: string, checkExisting?: boolean): string;

/**
 * System validation context for pre-flight checks
 */
interface SystemCheckContext {
  command: string;
  git: boolean;
  node: boolean;
  packageManager: boolean;
}

/**
 * Validates system requirements before command execution
 * @param callerTask - Listr task for progress reporting
 * @returns Promise resolving to validation result
 */
function checkSystem(callerTask: ForgeListrTask<SystemCheckContext>): Promise<any>;

Utility Functions

Global Options

All CLI commands support these global options:

  • -V, --version - Output the current version
  • -h, --help - Output usage information

System Requirements

  • Node.js: Version ">= 16.4.0" as specified in package.json engines field
  • Package Manager: Compatible versions of npm (^3.0.0 || ^4.0.0 || ~5.1.0 || ~5.2.0 || >= 5.4.2), yarn (>= 1.0.0), or pnpm (>= 8.0.0)
  • Git: Required for init and import commands unless --skip-git is used

Binary Executables

The package provides three executable binaries:

// Main CLI binary
"electron-forge": "dist/electron-forge.js"

// VSCode integration scripts
"electron-forge-vscode-nix": "script/vscode.sh"  // Unix-like systems
"electron-forge-vscode-win": "script/vscode.cmd" // Windows