File tree Expand file tree Collapse file tree
packages/cli/src/migration Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -530,8 +530,11 @@ async function collectMigrationPlan(
530530 const frameworkShimFrameworks : Framework [ ] = [ ] ;
531531 for ( const framework of allDetectedFrameworks ) {
532532 const anyMissingShim =
533- ! hasFrameworkShim ( rootDir , framework ) ||
534- ( packages ?? [ ] ) . some ( ( pkg ) => ! hasFrameworkShim ( path . join ( rootDir , pkg . path ) , framework ) ) ;
533+ ( detectFramework ( rootDir ) . includes ( framework ) && ! hasFrameworkShim ( rootDir , framework ) ) ||
534+ ( packages ?? [ ] ) . some ( ( pkg ) => {
535+ const pkgPath = path . join ( rootDir , pkg . path ) ;
536+ return detectFramework ( pkgPath ) . includes ( framework ) && ! hasFrameworkShim ( pkgPath , framework ) ;
537+ } ) ;
535538 if ( anyMissingShim ) {
536539 const addShim = await confirmFrameworkShim ( framework , options . interactive ) ;
537540 if ( addShim ) {
Original file line number Diff line number Diff line change @@ -732,16 +732,32 @@ function getEnvDtsPath(projectPath: string): string {
732732}
733733
734734export function hasFrameworkShim ( projectPath : string , framework : Framework ) : boolean {
735- const envDtsPath = getEnvDtsPath ( projectPath ) ;
736- if ( ! fs . existsSync ( envDtsPath ) ) {
737- return false ;
738- }
739-
740- const content = fs . readFileSync ( envDtsPath , 'utf-8' ) ;
741- if ( framework === 'astro' ) {
742- return content . includes ( 'astro/client' ) ;
735+ const dirsToScan = [ projectPath , path . join ( projectPath , 'src' ) ] ;
736+ for ( const dir of dirsToScan ) {
737+ if ( ! fs . existsSync ( dir ) ) {
738+ continue ;
739+ }
740+ let entries : string [ ] ;
741+ try {
742+ entries = fs . readdirSync ( dir ) ;
743+ } catch {
744+ continue ;
745+ }
746+ for ( const entry of entries ) {
747+ if ( ! entry . endsWith ( '.d.ts' ) ) {
748+ continue ;
749+ }
750+ const content = fs . readFileSync ( path . join ( dir , entry ) , 'utf-8' ) ;
751+ if ( framework === 'astro' ) {
752+ if ( content . includes ( 'astro/client' ) ) {
753+ return true ;
754+ }
755+ } else if ( content . includes ( `'*.${ framework } '` ) || content . includes ( `"*.${ framework } "` ) ) {
756+ return true ;
757+ }
758+ }
743759 }
744- return content . includes ( `'*. ${ framework } '` ) || content . includes ( `"*. ${ framework } "` ) ;
760+ return false ;
745761}
746762
747763export function addFrameworkShim (
You can’t perform that action at this time.
0 commit comments