UNPKG

node-msix-packager

Version:

A utility to create MSIX packages from Node.js applications with MCP server support, Node.js Single Executable Application (SEA) bundling using @vercel/ncc and postject, and enhanced build options

133 lines (113 loc) 3.79 kB
/** * Constants for MSIX package creation */ const CONSTANTS = { // Default configuration values DEFAULT_VERSION: '1.0.0.0', DEFAULT_ARCHITECTURE: 'x64', DEFAULT_EXECUTABLE: 'node.exe', DEFAULT_TIMESTAMP_URL: 'http://timestamp.digicert.com', DEFAULT_BACKGROUND_COLOR: 'transparent', // Package requirements MIN_VERSION_PARTS: 4, MAX_PACKAGE_NAME_LENGTH: 50, // File paths and extensions MANIFEST_FILE: 'AppxManifest.xml', ASSETS_FOLDER: 'Assets', APP_FOLDER: 'app', // Asset file names ASSET_FILES: [ 'Square150x150Logo.png', 'Square44x44Logo.png', 'StoreLogo.png', 'Wide310x150Logo.png', 'SplashScreen.png' ], // Windows SDK paths (ordered by preference) WINDOWS_SDK_PATHS: [ 'C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.26100.0\\x64', 'C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.22621.0\\x64', 'C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.19041.0\\x64', 'C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.18362.0\\x64', 'C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.17763.0\\x64', 'C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.8 Tools\\x64' ], // Certificate stores to search CERTIFICATE_STORES: [ { location: 'CurrentUser', store: 'My' }, { location: 'CurrentUser', store: 'TrustedPublisher' }, { location: 'CurrentUser', store: 'TrustedPeople' }, { location: 'LocalMachine', store: 'My' }, { location: 'LocalMachine', store: 'TrustedPublisher' }, { location: 'LocalMachine', store: 'TrustedPeople' } ], // Default capabilities DEFAULT_CAPABILITIES: ['internetClient', 'runFullTrust'], // Supported architectures SUPPORTED_ARCHITECTURES: ['x64', 'x86', 'arm64'], // Validation patterns PUBLISHER_PATTERN: /^CN=/, VERSION_PATTERN: /^\d+\.\d+\.\d+\.\d+$/, // Files and directories to exclude when copying COPY_EXCLUDE_PATTERNS: [ 'node_modules/.cache', '.git', '.gitignore', '.npm', '.nyc_output', 'coverage', '*.log', 'npm-debug.log*', 'yarn-debug.log*', 'yarn-error.log*', '.DS_Store', 'Thumbs.db' ], // Configuration file name CONFIG_FILENAME: 'msix-config.json', // Package size limits MAX_PACKAGE_SIZE: 500 * 1024 * 1024, // 500MB // Default 1x1 transparent PNG (base64) DEFAULT_PNG_BASE64: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChAI9jU77zgAAAABJRU5ErkJggg==' }; // Error types for better error handling class MsixError extends Error { constructor(message, code, details) { super(message); this.name = 'MsixError'; this.code = code; this.details = details; } } class ValidationError extends MsixError { constructor(field, value, expected) { super(`Validation failed for field '${field}': expected ${expected}, got ${value}`, 'VALIDATION_ERROR', { field, value, expected }); this.name = 'ValidationError'; } } class ToolNotFoundError extends MsixError { constructor(tool, suggestions = []) { super(`Required tool '${tool}' not found`, 'TOOL_NOT_FOUND', { tool, suggestions }); this.name = 'ToolNotFoundError'; } } class CertificateError extends MsixError { constructor(message, details) { super(message, 'CERTIFICATE_ERROR', details); this.name = 'CertificateError'; } } class SigningError extends MsixError { constructor(message, details) { super(message, 'SIGNING_ERROR', details); this.name = 'SigningError'; } } module.exports = { CONSTANTS, MSIXError: MsixError, ValidationError, ToolNotFoundError, CertificateError, SigningError };