/** * @angular-modernizer/plugin-angular - Library Extraction Transform Rule * * Extracts Angular artifacts from shared folders into dedicated Angular libraries * with secondary entry points. Triggered by 'library-extraction' transformation type. * * Rule ID: refactor:library-extraction * Category: refactoring * * This is a thin rule — all business logic lives in LibraryExtractionOrchestrator * and its 5 collaborating classes. * * @example MCP usage: * ```json * { * "transformation": "library-extraction", * "options": { * "libraryName": "ui", * "libraryPrefix": "@myapp", * "artifacts": ["src/shared/ui/button.component.ts"], * "secondaryEntryPoints": ["button"], * "dryRun": false * } * } * ``` */ import type { TransformRule, TransformContext, TransformResult, } from '@angular-modernizer/plugin-system'; import type { PublicApi } from '@angular-modernizer/api'; import { LibraryExtractionOrchestrator } from '../orchestrators/library-extraction/library-extraction.orchestrator.js'; /** * Library Extraction Transform Rule. * * Extracts cohesive artifact groups into dedicated Angular libraries with * secondary entry points, updating all imports and build configs automatically. * * Options (passed via context.config / MCP 'options' field): * - libraryName: string (required) — e.g. 'ui' * - libraryPrefix: string (required) — e.g. '@myapp' * - artifacts: string[] (required) — file paths to migrate * - secondaryEntryPoints?: string[] — sub-library names * - libraryType?: 'angular-library' | 'folder-move' * - outputFolder?: string — default 'projects/' * - dryRun?: boolean — preview only (default false) */ export class LibraryExtractionTransformRule implements TransformRule { public readonly id = 'refactor:library-extraction'; public readonly name = 'Library Extraction'; public readonly description = 'Extracts Angular artifacts into dedicated libraries with secondary entry points'; public readonly category = 'refactoring'; public readonly tags = [ 'refactoring', 'library-extraction', 'monorepo', 'angular', ]; private readonly orchestrator = new LibraryExtractionOrchestrator(); async transform( context: TransformContext, ): Promise { return this.orchestrator.run(context); } }