UNPKG

@interopio/desktop-cli

Version:

CLI tool for setting up, building and packaging io.Connect Desktop projects

111 lines 3.7 kB
export interface TemplateOptions { productSlug: string; productName: string; company: string; copyright: string; version: string; folderName: string; targetDirectory: string; features: string[]; } export interface TemplateVariable { key: string; value: string; description?: string; } export interface TemplateMetadata { name: string; displayName?: string; description: string; version: string; type: 'base' | 'feature'; setupUI?: { text?: string; separate?: boolean; selected?: boolean; }; } /** * TemplateService handles the generation of io.Connect Desktop projects using a modular template system. * * This service supports two types of templates: * - Base templates: Core project structure and essential files (e.g., ioconnect-desktop) * - Feature templates: Optional functionality modules that extend the base template * * The service processes templates by: * 1. Copying base template files to the target directory * 2. Applying variable substitutions ({{variable}} patterns) * 3. Conditionally applying feature templates based on user selection: * - Validates that requested features exist as separate template directories * - Only processes features that are explicitly selected by the user * - Each feature template contains its own template.json with type: "feature" * - Features are independent and can be combined in any combination * 4. Merging feature-specific files into the project structure: * - Feature templates overlay their files onto the base project structure * - Files from features are copied to their corresponding paths in the target * - Directory structures are preserved (e.g., modifications/iocd/assets/feature/) * - No conflicts occur since features target different subdirectories * - Variable substitution is applied to feature files just like base template files * * Key capabilities: * - Template discovery and validation from filesystem * - Variable interpolation for dynamic content generation * - Modular feature system for extensible project setup * - Comprehensive error handling and logging * - Support for nested directory structures and file copying */ export declare class TemplateService { private logger; private templatesPath; constructor(); /** * Get the path to embedded templates */ getTemplatesPath(): string; /** * List available templates */ getAvailableTemplates(): string[]; /** * Check if a template exists */ templateExists(templateName: string): boolean; /** * Generate a project from a template */ generateProject(templateName: string, options: TemplateOptions): Promise<void>; /** * Prepare template variables for replacement */ private prepareTemplateVariables; /** * Generate NPM-compatible package name from product name */ private generatePackageName; /** * Recursively copy template files with variable replacement */ private copyTemplateFiles; /** * Copy a single file with variable replacement */ private copyFileWithReplacement; private copyFileNoReplacement; /** * Process feature-specific templates */ private processFeatureFiles; /** * Escape special regex characters */ private escapeRegExp; /** * Get template information */ getTemplateInfo(templateName: string): TemplateMetadata; /** * Get available feature templates with their metadata */ getAvailableFeatureTemplates(): TemplateMetadata[]; } //# sourceMappingURL=template.service.d.ts.map