UNPKG

@re-shell/cli

Version:

Full-stack development platform uniting microservices and microfrontends. Build complete applications with .NET (ASP.NET Core Web API, Minimal API), Java (Spring Boot, Quarkus, Micronaut, Vert.x), Rust (Actix-Web, Warp, Rocket, Axum), Python (FastAPI, Dja

181 lines (180 loc) 5.26 kB
import { EventEmitter } from 'events'; export interface Template { id: string; name: string; version: string; description: string; author?: string; license?: string; repository?: string; tags: string[]; category: TemplateCategory; extends?: string[]; implements?: string[]; requires?: TemplateRequirement[]; variables: TemplateVariable[]; files: TemplateFile[]; hooks: TemplateHook[]; metadata: { created: Date; updated: Date; downloads?: number; rating?: number; verified?: boolean; }; } export declare enum TemplateCategory { MICROFRONTEND = "microfrontend", BACKEND = "backend", FULLSTACK = "fullstack", LIBRARY = "library", APPLICATION = "application", SERVICE = "service", COMPONENT = "component", CONFIGURATION = "configuration", INFRASTRUCTURE = "infrastructure", TESTING = "testing", DOCUMENTATION = "documentation", CUSTOM = "custom" } export interface TemplateVariable { name: string; type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'choice'; description: string; default?: any; required: boolean; choices?: any[]; pattern?: string; transform?: string; when?: string; validate?: string; group?: string; } export interface TemplateFile { source: string; destination: string; condition?: string; transform?: 'handlebars' | 'ejs' | 'none'; permissions?: string; encoding?: string; merge?: boolean; mergeStrategy?: 'override' | 'append' | 'prepend' | 'deep' | 'custom'; mergeCustom?: string; } export interface TemplateHook { type: HookType; name: string; description?: string; command?: string; script?: string; condition?: string; timeout?: number; allowFailure?: boolean; environment?: Record<string, string>; } export declare enum HookType { BEFORE_INSTALL = "before_install", AFTER_INSTALL = "after_install", BEFORE_PROCESS = "before_process", AFTER_PROCESS = "after_process", BEFORE_FILE = "before_file", AFTER_FILE = "after_file", VALIDATE = "validate", CLEANUP = "cleanup" } export interface TemplateRequirement { type: 'template' | 'package' | 'command' | 'file' | 'environment'; name: string; version?: string; condition?: string; message?: string; } export interface TemplateContext { variables: Record<string, any>; template: Template; parentTemplates?: Template[]; interfaces?: Template[]; projectPath: string; timestamp: Date; user?: { name?: string; email?: string; }; system: { platform: string; arch: string; nodeVersion: string; }; } export interface ProcessedTemplate { template: Template; mergedVariables: Record<string, any>; processedFiles: Array<{ source: string; destination: string; content?: string; processed: boolean; error?: string; }>; executedHooks: Array<{ hook: TemplateHook; success: boolean; output?: string; error?: string; duration: number; }>; inheritanceChain: string[]; warnings: string[]; errors: string[]; } export declare class TemplateEngine extends EventEmitter { private templatePaths; private options; private templates; private templateCache; private handlebarsInstance; constructor(templatePaths?: string[], options?: { enableCache?: boolean; enableRemoteTemplates?: boolean; templateRegistry?: string; customHelpers?: Record<string, (...args: any[]) => any>; strictMode?: boolean; }); private registerBuiltinHelpers; private registerCustomHelpers; private loadTemplates; private loadTemplatesFromDirectory; private loadRemoteTemplates; registerTemplate(template: Template): Promise<void>; processTemplate(templateId: string, context: Partial<TemplateContext>): Promise<ProcessedTemplate>; private buildContext; private resolveInheritance; private resolveInterfaces; private mergeTemplates; private mergeArrays; private mergeVariables; private transformValue; private validateVariable; private processFile; private mergeFileContent; private deepMerge; private executeHooks; private createHookEnvironment; private evaluateCondition; private resolvePath; private getCacheKey; validateTemplate(template: Template): Promise<{ valid: boolean; errors: string[]; }>; getTemplate(id: string): Template | undefined; getAllTemplates(): Template[]; getTemplatesByCategory(category: TemplateCategory): Template[]; getTemplatesByTag(tag: string): Template[]; searchTemplates(query: string): Template[]; getInheritanceHierarchy(templateId: string): string[]; clearCache(): void; } export declare function createTemplateEngine(templatePaths?: string[], options?: ConstructorParameters<typeof TemplateEngine>[1]): TemplateEngine; export declare function getGlobalTemplateEngine(): TemplateEngine; export declare function setGlobalTemplateEngine(engine: TemplateEngine): void;