import { API , FileInfo , Options , ImportDeclaration , ASTPath } from 'jscodeshift' ; const renameDefaultMap = { '@workday/canvas-kit-react/button' : 'Button' , '@workday/canvas-kit-react/card' : 'Card' , } ; export default function transformer ( file , api , options ) { const j = api . jscodeshift ; const root = j ( file . source ) ; root . find ( j . ImportDefaultSpecifier ) . forEach ( nodePath => { const parent = nodePath . parent as ASTPath < ImportDeclaration > ; const importSource = String ( parent . node . source . value ) as keyof typeof renameDefaultMap ; const localName = nodePath . value . local ?. name ; if ( Object . keys ( renameDefaultMap ) . includes ( importSource ) && localName ) { nodePath . replace ( j . importSpecifier ( j . identifier ( renameDefaultMap [ importSource ] ) , j . identifier ( localName ) ) ) ; } } ) ; return root . toSource ( ) ; }