or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

dmg-building.mddmg-customization.mderror-handling.mdindex.mdlicense-management.mdvolume-operations.md
tile.json

license-management.mddocs/

License Management

License agreement integration with support for multiple languages and customizable button layouts. Enables DMG files to display license agreements during installation with localized user interface elements.

Capabilities

License Integration

Main function for adding license agreements to DMG files with full localization support.

/**
 * Add license agreement to DMG file with localized button text
 * Processes license files and button configurations for multiple languages
 * @param packager - Platform packager with access to build resources
 * @param dmgPath - Path to the DMG file to modify
 * @returns Promise resolving to license configuration or null if no licenses found
 */
function addLicenseToDmg(
  packager: PlatformPackager<any>, 
  dmgPath: string
): Promise<LicenseConfig | null>;

Usage Examples:

import { addLicenseToDmg } from "dmg-builder";

// Add license to existing DMG
const licenseConfig = await addLicenseToDmg(packager, "/path/to/installer.dmg");

if (licenseConfig) {
  console.log("License added with languages:", 
    licenseConfig.body.map(b => b.lang));
  console.log("Button localizations:", 
    licenseConfig.labels.map(l => l.lang));
}

License Button Management

Functions for managing localized license button text and configurations.

/**
 * Get license button configuration files from build resources
 * Scans for licensebuttons_*.json and licensebuttons_*.yml files
 * @param packager - Platform packager with access to build resources
 * @returns Promise resolving to array of license button file descriptors
 */
function getLicenseButtonsFile(
  packager: PlatformPackager<any>
): Promise<Array<LicenseButtonsFile>>;

/**
 * Generate localized license button resources for specified language
 * Creates AppleScript resource data for license dialog buttons
 * @param licenseButtonFiles - Array of available button configuration files
 * @param langWithRegion - Language code with region (e.g., "en_US", "fr_FR")
 * @param id - Resource ID for the button set
 * @param name - Resource name for the button set
 * @returns Promise resolving to AppleScript resource string
 */
function getLicenseButtons(
  licenseButtonFiles: Array<LicenseButtonsFile>,
  langWithRegion: string,
  id: number,
  name: string
): Promise<string>;

Usage Examples:

import { getLicenseButtonsFile, getLicenseButtons } from "dmg-builder";

// Get available button configurations
const buttonFiles = await getLicenseButtonsFile(packager);

// Generate German button resources
const germanButtons = await getLicenseButtons(
  buttonFiles,
  "de_DE",
  5000,
  "German License Buttons"
);

Default Button Localizations

Comprehensive default license button text for multiple languages.

/**
 * Get default localized license button resources
 * Provides built-in localizations for 15+ languages
 * @param langWithRegion - Language code with region
 * @param id - Resource ID for the button set
 * @param name - Resource name for the button set
 * @returns AppleScript resource string with localized button text
 */
function getDefaultButtons(
  langWithRegion: string, 
  id: number, 
  name: string
): string;

Supported Languages:

  • English (en_US) - Default
  • German (de_DE)
  • French (fr_FR, fr_CA)
  • Spanish (es_ES)
  • Italian (it_IT)
  • Japanese (ja_JP)
  • Dutch (nl_NL)
  • Swedish (sv_SE)
  • Portuguese (br_FR)
  • Chinese Traditional (zh_TW)
  • Chinese Simplified (zh_CN)
  • Danish (da_DK)
  • Finnish (fi_FI)
  • Korean (ko_KR)
  • Norwegian (nb_NO)

License Configuration Types

License Configuration Structure

/**
 * Complete license configuration for dmg-license library
 * Contains license text bodies and localized button configurations
 */
interface LicenseConfig {
  /** JSON schema reference for validation */
  $schema: string;
  /** License text files for different languages */
  body: Array<{
    /** Path to license text file */
    file: string;
    /** Language code with region (e.g., "en-US") */
    lang: string;
  }>;
  /** Localized button text configurations */
  labels: Array<{
    /** Language code with region */
    lang: string;
    /** Button text for agreement */
    agree?: string;
    /** Button text for disagreement */
    disagree?: string;
    /** Button text for printing */
    print?: string;
    /** Button text for saving */
    save?: string;
    /** License description/message text */
    message?: string;
  }>;
}

License Button File Descriptor

/**
 * Descriptor for license button configuration files
 * Used to locate and process localized button text
 */
interface LicenseButtonsFile {
  /** Full path to the button configuration file */
  file: string;
  /** Base language code (e.g., "en", "fr") */
  lang: string;
  /** Language with region code (e.g., "en_US", "fr_FR") */
  langWithRegion: string;
  /** Human-readable language name */
  langName: string;
}

License File Management

License File Detection

The system automatically detects license files using the getLicenseFiles function from app-builder-lib:

Supported File Patterns:

  • license*.txt
  • license*.md
  • LICENSE*
  • COPYING*

Language Detection:

  • Files with language suffixes: license_en.txt, license_fr.txt
  • Region-specific files: license_en_US.txt, license_fr_CA.txt
  • Fallback to default language for files without language indicators

Button Configuration Files

License button text can be customized using configuration files:

File Naming Convention:

  • licensebuttons_en.json - English buttons
  • licensebuttons_fr.yml - French buttons (YAML format)
  • licensebuttons_de_DE.json - German (Germany) buttons

Button Configuration Format:

{
  "lang": "English",
  "agree": "Agree", 
  "disagree": "Disagree",
  "print": "Print",
  "save": "Save...",
  "message": "If you agree with the terms of this license, press \"Agree\" to install the software. If you do not agree, press \"Disagree\"."
}
# YAML format alternative
lang: "Français"
agree: "Accepter"
disagree: "Refuser" 
print: "Imprimer"
save: "Enregistrer..."
message: "Si vous acceptez les termes de cette license..."

Character Encoding and Localization

Mac Encoding Support

The system handles character encoding for different languages using appropriate Mac code pages:

/**
 * Mac code page mappings for proper character encoding
 * Ensures correct display of non-ASCII characters in license dialogs
 */
const macCodePages = {
  ja: ["euc-jp"],           // Japanese
  zh: ["gb2312", "big5"],   // Chinese (Simplified/Traditional)
  ko: ["euc-kr"],           // Korean
  ar: ["macarabic"],        // Arabic
  he: ["machebrew"],        // Hebrew
  el: ["macgreek"],         // Greek
  ru: ["maccyrillic"],      // Russian/Cyrillic
  th: ["macthai"],          // Thai
  // ... additional encodings
};

Text Processing

License button text undergoes several processing steps:

  1. Character Encoding: Converts Unicode text to appropriate Mac encoding
  2. Hex Encoding: Converts text to hexadecimal format for AppleScript resources
  3. Length Prefixing: Adds length prefixes for proper resource formatting
  4. Resource Generation: Creates complete AppleScript resource blocks

Integration with dmg-license

DMG Builder uses the external dmg-license library for the actual license embedding:

// Internal implementation
import { dmgLicenseFromJSON } from "dmg-license";

await dmgLicenseFromJSON(dmgPath, licenseConfig, {
  onNonFatalError: log.warn.bind(log)
});

Features:

  • Multiple Languages: Support for multiple license languages in single DMG
  • Button Customization: Full control over license dialog button text
  • Error Handling: Graceful handling of license processing errors
  • Resource Optimization: Efficient resource generation and embedding

Error Handling

Common Error Scenarios

  • Missing License Files: Returns null if no license files found
  • Invalid Button Configurations: Falls back to default button text
  • Character Encoding Issues: Uses fallback character (?) for unsupported characters
  • File Access Errors: Logs warnings and continues with available resources

Debug Support

Enable detailed license processing logs:

// Enable debug logging for license processing
process.env.DEBUG_LICENSE = "true";

This provides detailed information about:

  • License file detection and processing
  • Button configuration loading and processing
  • Character encoding operations
  • Resource generation steps