@@ -524,10 +524,8 @@ export class ProjectChangeAnalyzer {
524524 changedProjects : Set < RushConfigurationProject >
525525 ) : Promise < void > {
526526 const pnpmOptions : PnpmOptionsConfiguration | undefined = subspace . getPnpmOptions ( ) ;
527- const currentCatalogs : Record < string , Record < string , string > > | undefined = pnpmOptions ?. globalCatalogs ;
528- if ( ! currentCatalogs ) {
529- return ;
530- }
527+ // Default to an empty object if no global catalogs are configured, handle case of globalCatalogs being deleted
528+ const currentCatalogs : Record < string , Record < string , string > > = pnpmOptions ?. globalCatalogs ?? { } ;
531529
532530 const pnpmConfigRelativePath : string = Path . convertToSlashes (
533531 path . relative ( repoRoot , subspace . getPnpmConfigFilePath ( ) )
@@ -539,17 +537,35 @@ export class ProjectChangeAnalyzer {
539537
540538 // Determine which specific packages changed within each catalog namespace
541539 // Maps catalogNamespace (e.g. "default", "react17") → Set of changed package names
542- let changedCatalogPackages : Map < string , Set < string > > ;
540+ let oldCatalogs : Record < string , Record < string , string > > | undefined ;
543541 try {
544542 const oldPnpmConfigText : string = await this . _git . getBlobContentAsync ( {
545543 blobSpec : `${ mergeCommit } :${ pnpmConfigRelativePath } ` ,
546544 repositoryRoot : repoRoot
547545 } ) ;
548546 const oldPnpmConfig : IPnpmOptionsJson = JSON . parse ( oldPnpmConfigText ) ;
549- const oldCatalogs : Record < string , Record < string , string > > = oldPnpmConfig . globalCatalogs ?? { } ;
547+ oldCatalogs = oldPnpmConfig . globalCatalogs ?? { } ;
548+ } catch {
549+ // Old file didn't exist or was unparseable — treat all packages in all current catalogs as changed
550+ if ( rushConfiguration . subspacesFeatureEnabled ) {
551+ terminal . writeLine (
552+ `"${ subspace . subspaceName } " subspace pnpm-config.json was created or unparseable. Assuming all projects are affected.`
553+ ) ;
554+ } else {
555+ terminal . writeLine (
556+ `pnpm-config.json was created or unparseable. Assuming all projects are affected.`
557+ ) ;
558+ }
559+ }
550560
551- changedCatalogPackages = new Map < string , Set < string > > ( ) ;
561+ const changedCatalogPackages : Map < string , Set < string > > = new Map < string , Set < string > > ( ) ;
552562
563+ if ( oldCatalogs === undefined ) {
564+ // Could not load old catalogs — treat all packages in all current catalogs as changed
565+ for ( const [ catalogName , packages ] of Object . entries ( currentCatalogs ) ) {
566+ changedCatalogPackages . set ( catalogName , new Set ( Object . keys ( packages ) ) ) ;
567+ }
568+ } else {
553569 // Check current catalogs for new or modified package entries
554570 for ( const [ catalogName , packages ] of Object . entries ( currentCatalogs ) ) {
555571 const oldPackages : Record < string , string > | undefined = oldCatalogs [ catalogName ] ;
@@ -581,32 +597,18 @@ export class ProjectChangeAnalyzer {
581597 changedCatalogPackages . set ( catalogName , new Set ( Object . keys ( oldPackages ) ) ) ;
582598 }
583599 }
584- } catch {
585- // Old file didn't exist or was unparseable — treat all packages in all current catalogs as changed
586- changedCatalogPackages = new Map < string , Set < string > > ( ) ;
587- for ( const [ catalogName , packages ] of Object . entries ( currentCatalogs ) ) {
588- changedCatalogPackages . set ( catalogName , new Set ( Object . keys ( packages ) ) ) ;
589- }
590- if ( rushConfiguration . subspacesFeatureEnabled ) {
591- terminal . writeLine (
592- `"${ subspace . subspaceName } " subspace pnpm-config.json was created or unparseable. Assuming all projects are affected.`
593- ) ;
594- } else {
595- terminal . writeLine (
596- `pnpm-config.json was created or unparseable. Assuming all projects are affected.`
597- ) ;
598- }
599600 }
600601
601602 if ( changedCatalogPackages . size > 0 ) {
602603 // Check each project in the subspace to see if it depends on a changed catalog package
603604 const subspaceProjects : RushConfigurationProject [ ] = subspace . getProjects ( ) ;
604605 for ( const project of subspaceProjects ) {
605- const { dependencies, devDependencies, optionalDependencies } = project . packageJson ;
606+ const { dependencies, devDependencies, optionalDependencies, peerDependencies } = project . packageJson ;
606607 const allDeps : Record < string , string > [ ] = [
607608 dependencies ?? { } ,
608609 devDependencies ?? { } ,
609- optionalDependencies ?? { }
610+ optionalDependencies ?? { } ,
611+ peerDependencies ?? { }
610612 ] ;
611613
612614 let isAffected : boolean = false ;
0 commit comments