import { CacheManager } from '../cache/cache-manager'; import { GitCloner } from '../git/git-cloner'; import { Templatizer } from '../template/templatizer'; import { TemplateScaffolderConfig, ScaffoldOptions, ScaffoldResult, BoilerplatesConfig, BoilerplateConfig, InspectOptions, InspectResult } from './types'; import { ScannedBoilerplate, ScanBoilerplatesOptions } from './scan-boilerplates'; /** * High-level orchestrator for template scaffolding operations. * Combines CacheManager, GitCloner, and Templatizer into a single, easy-to-use API. * * @example * ```typescript * const scaffolder = new TemplateScaffolder({ * toolName: 'my-cli', * defaultRepo: 'https://github.com/org/templates.git', * ttlMs: 7 * 24 * 60 * 60 * 1000, // 1 week * }); * * await scaffolder.scaffold({ * outputDir: './my-project', * fromPath: 'starter', * answers: { name: 'my-project' }, * }); * ``` */ export declare class TemplateScaffolder { private config; private cacheManager; private gitCloner; private templatizer; constructor(config: TemplateScaffolderConfig); /** * Scaffold a new project from a template. * * Handles both local directories and remote git repositories. * For remote repos, caching is used to avoid repeated cloning. * * @param options - Scaffold options * @returns Scaffold result with output path and metadata */ scaffold(options: ScaffoldOptions): Promise; /** * Inspect a template without scaffolding. * Clones/caches the template and reads its .boilerplate.json configuration * without copying any files to an output directory. * * This is useful for metadata-driven workflows where you need to know * the template's type or other configuration before deciding how to handle it. * * @param options - Inspect options * @returns Inspect result with template metadata */ inspect(options: InspectOptions): InspectResult; /** * Read the .boilerplates.json configuration from a template repository root. */ readBoilerplatesConfig(templateDir: string): BoilerplatesConfig | null; /** * Read the .boilerplate.json configuration from a boilerplate directory. */ readBoilerplateConfig(boilerplatePath: string): BoilerplateConfig | null; /** * Get the underlying CacheManager instance for advanced cache operations. */ getCacheManager(): CacheManager; /** * Get the underlying GitCloner instance for advanced git operations. */ getGitCloner(): GitCloner; /** * Get the underlying Templatizer instance for advanced template operations. */ getTemplatizer(): Templatizer; /** * Scan a template directory recursively for all boilerplates. * * A boilerplate is any directory containing a `.boilerplate.json` file. * This method recursively searches the entire directory tree and returns * all discovered boilerplates with their relative paths. * * This is useful when: * - The user specifies `--dir .` to bypass `.boilerplates.json` * - You want to discover all available boilerplates regardless of nesting * - You need to present a list of available boilerplates to the user * * @param templateDir - The root directory to scan * @param options - Scanning options (maxDepth, skipDirectories) * @returns Array of discovered boilerplates with relative paths * * @example * ```typescript * const scaffolder = new TemplateScaffolder({ toolName: 'my-cli' }); * const inspection = scaffolder.inspect({ template: 'org/repo' }); * const boilerplates = scaffolder.scanBoilerplates(inspection.templateDir); * // Returns: [{ relativePath: 'default/module', ... }, { relativePath: 'default/workspace', ... }] * ``` */ scanBoilerplates(templateDir: string, options?: ScanBoilerplatesOptions): ScannedBoilerplate[]; private inspectLocal; private inspectRemote; private scaffoldFromLocal; private scaffoldFromRemote; /** * Resolve the fromPath using .boilerplates.json convention and recursive scanning. * * Resolution order: * 1. If explicit fromPath is provided and exists, use it directly * 2. If useBoilerplatesConfig is true and .boilerplates.json exists with a dir field, prepend it to fromPath * 3. Recursively scan for boilerplates and try to match fromPath (exact match, then basename match if unambiguous) * 4. Return the fromPath as-is (will likely fail later if path doesn't exist) * * @param templateDir - The template repository root directory * @param fromPath - The subdirectory path to resolve * @param useBoilerplatesConfig - Whether to use .boilerplates.json for fallback resolution (default: true) */ private resolveFromPath; private isLocalPath; private resolveTemplatePath; }