11import type {
2+ FileVisitor ,
23 Rule ,
34 SchematicContext ,
45 Tree
56} from '@angular-devkit/schematics' ;
67import * as ts from 'typescript' ;
7- import * as path from 'path' ;
88
99const version = '21.0.0' ;
1010
@@ -114,7 +114,7 @@ function migrateImportDeclaration(node: ts.ImportDeclaration, sourceFile: ts.Sou
114114 }
115115
116116 const importPath = moduleSpecifier . text ;
117-
117+
118118 // Only process igniteui-angular imports (not already using entry points)
119119 if ( importPath !== 'igniteui-angular' ) {
120120 return null ;
@@ -131,24 +131,24 @@ function migrateImportDeclaration(node: ts.ImportDeclaration, sourceFile: ts.Sou
131131
132132 // Group imports by entry point
133133 const entryPointGroups = new Map < string , string [ ] > ( ) ;
134-
134+
135135 for ( const element of importClause . namedBindings . elements ) {
136136 const name = element . name . text ;
137137 const alias = element . propertyName ?. text ;
138138 const importName = alias || name ;
139139 let actualImportName = importName ;
140-
140+
141141 // Check if this is a renamed type
142142 if ( TYPE_RENAMES . has ( importName ) ) {
143143 const rename = TYPE_RENAMES . get ( importName ) ! ;
144144 actualImportName = rename . newName ;
145145 }
146-
146+
147147 const fullImport = alias ? `${ actualImportName } as ${ name } ` : actualImportName ;
148148
149149 // Determine target entry point
150150 let targetEntryPoint = 'core' ; // Default to core
151-
151+
152152 // Check if it's a renamed type first
153153 if ( TYPE_RENAMES . has ( importName ) ) {
154154 targetEntryPoint = TYPE_RENAMES . get ( importName ) ! . entryPoint ;
@@ -194,7 +194,7 @@ function migrateFile(filePath: string, content: string): string {
194194 const change = migrateImportDeclaration ( node , sourceFile ) ;
195195 if ( change ) {
196196 changes . push ( change ) ;
197-
197+
198198 // Track old type names that were imported
199199 const moduleSpecifier = node . moduleSpecifier ;
200200 if ( ts . isStringLiteral ( moduleSpecifier ) && moduleSpecifier . text === 'igniteui-angular' ) {
@@ -214,7 +214,7 @@ function migrateFile(filePath: string, content: string): string {
214214 else if ( ts . isIdentifier ( node ) && importedOldTypes . has ( node . text ) ) {
215215 const oldName = node . text ;
216216 const rename = TYPE_RENAMES . get ( oldName ) ! ;
217-
217+
218218 // Check if this identifier is part of an import statement
219219 // We don't want to rename it there as we already handled it
220220 let isInImport = false ;
@@ -226,7 +226,7 @@ function migrateFile(filePath: string, content: string): string {
226226 }
227227 parent = parent . parent ;
228228 }
229-
229+
230230 if ( ! isInImport ) {
231231 changes . push ( {
232232 start : node . getStart ( sourceFile ) ,
@@ -235,15 +235,15 @@ function migrateFile(filePath: string, content: string): string {
235235 } ) ;
236236 }
237237 }
238-
238+
239239 ts . forEachChild ( node , visit ) ;
240240 }
241241
242242 visit ( sourceFile ) ;
243243
244244 // Apply changes in reverse order to maintain positions
245245 changes . sort ( ( a , b ) => b . start - a . start ) ;
246-
246+
247247 let result = content ;
248248 for ( const change of changes ) {
249249 result = result . substring ( 0 , change . start ) + change . replacement + result . substring ( change . end ) ;
@@ -273,22 +273,22 @@ export default (): Rule => async (host: Tree, context: SchematicContext) => {
273273 }
274274
275275 const originalContent = content . toString ( ) ;
276-
276+
277277 // Check if file has igniteui-angular imports
278278 if ( ! originalContent . includes ( "from 'igniteui-angular'" ) && ! originalContent . includes ( 'from "igniteui-angular"' ) ) {
279279 return ;
280280 }
281281
282282 const migratedContent = migrateFile ( filePath , originalContent ) ;
283-
283+
284284 if ( migratedContent !== originalContent ) {
285285 host . overwrite ( filePath , migratedContent ) ;
286286 context . logger . info ( ` ✓ Migrated ${ filePath } ` ) ;
287287 }
288288 } ;
289289
290290 host . visit ( visit ) ;
291-
291+
292292 context . logger . info ( 'Migration complete!' ) ;
293293 context . logger . info ( 'Breaking changes:' ) ;
294294 context . logger . info ( ' - Input directives moved to igniteui-angular/input-group' ) ;
0 commit comments