@@ -34,7 +34,7 @@ enum LinkType {
3434}
3535
3636interface IRushLinkFileState {
37- [ consumerPackageName : string ] : {
37+ [ subspaceName : string ] : {
3838 linkedPackagePath : string ;
3939 linkedPackageName : string ;
4040 linkType : LinkType ;
@@ -52,6 +52,7 @@ interface ILinkedPackageInfo {
5252interface IConsumerPackageInfo {
5353 consumerPackageNodeModulesPath : string ;
5454 consumerPackagePnpmDependenciesFolderPath : string ;
55+ consumerSubspaceName : string ;
5556}
5657
5758interface IRushLinkOptions {
@@ -107,9 +108,8 @@ export class RushConnect {
107108 await JsonFile . saveAsync ( linkState , this . _rushLinkStateFilePath ) ;
108109 }
109110
110- public async isProjectDependencyLinkedAsync ( project : RushConfigurationProject ) : Promise < boolean > {
111- const projectName : string = project . packageName ;
112- if ( ! this . _rushLinkState || ! this . _rushLinkState [ projectName ] ?. length ) {
111+ public async isSubspaceDependencyLinkedAsync ( subspaceName : string ) : Promise < boolean > {
112+ if ( ! this . _rushLinkState || ! this . _rushLinkState [ subspaceName ] ?. length ) {
113113 return false ;
114114 }
115115
@@ -118,16 +118,16 @@ export class RushConnect {
118118 } ;
119119
120120 await this . _modifyAndSaveLinkStateAsync ( async ( linkState ) => {
121- const rushLinkFileState : IRushLinkFileState [ number ] = linkState [ projectName ] ?? [ ] ;
121+ const rushLinkFileState : IRushLinkFileState [ number ] = linkState [ subspaceName ] ?? [ ] ;
122122 await Async . forEachAsync ( rushLinkFileState , async ( { linkedPackagePath } ) => {
123123 await pnpmSyncUpdateFileAsync ( {
124124 sourceProjectFolder : linkedPackagePath ,
125125 targetFolders : [ ] ,
126- lockfileId : project . subspace . subspaceName ,
126+ lockfileId : subspaceName ,
127127 logMessageCallback
128128 } ) ;
129129 } ) ;
130- delete linkState [ projectName ] ;
130+ delete linkState [ subspaceName ] ;
131131 } ) ;
132132
133133 return true ;
@@ -171,6 +171,7 @@ export class RushConnect {
171171 }
172172
173173 private _getConsumerPackageInfo ( consumerPackage : RushConfigurationProject ) : IConsumerPackageInfo {
174+ const consumerSubspaceName : string = consumerPackage . subspace . subspaceName ;
174175 const consumerPackageNodeModulesPath : string = path . resolve (
175176 consumerPackage . projectFolder ,
176177 RushConstants . nodeModulesFolderName
@@ -182,6 +183,7 @@ export class RushConnect {
182183 ) ;
183184 return {
184185 consumerPackageNodeModulesPath,
186+ consumerSubspaceName,
185187 consumerPackagePnpmDependenciesFolderPath
186188 } ;
187189 }
@@ -250,8 +252,11 @@ export class RushConnect {
250252 linkedPackageNodeModulesPath
251253 } = await this . _getLinkedPackageInfoAsync ( linkedPackagePath ) ;
252254
253- const { consumerPackageNodeModulesPath, consumerPackagePnpmDependenciesFolderPath } =
254- this . _getConsumerPackageInfo ( consumerPackage ) ;
255+ const {
256+ consumerPackageNodeModulesPath,
257+ consumerPackagePnpmDependenciesFolderPath,
258+ consumerSubspaceName
259+ } = this . _getConsumerPackageInfo ( consumerPackage ) ;
255260
256261 if ( replace ) {
257262 if ( ! ( await FileSystem . existsAsync ( path . resolve ( consumerPackageNodeModulesPath , packageName ) ) ) ) {
@@ -260,11 +265,7 @@ export class RushConnect {
260265 const sourcePath : string = await FileSystem . getRealPathAsync (
261266 path . resolve ( consumerPackageNodeModulesPath , packageName )
262267 ) ;
263- await this . _hardLinkToLinkedPackageAsync (
264- linkedPackagePath ,
265- sourcePath ,
266- consumerPackage . subspace . subspaceName
267- ) ;
268+ await this . _hardLinkToLinkedPackageAsync ( linkedPackagePath , sourcePath , consumerSubspaceName ) ;
268269 } else {
269270 // Generate unique destination path for linked package
270271 const linkedPackageDestination : string = path . resolve (
@@ -293,7 +294,7 @@ export class RushConnect {
293294 await this . _hardLinkToLinkedPackageAsync (
294295 linkedPackagePath ,
295296 path . resolve ( linkedPackageDestination , packageName ) ,
296- consumerPackage . subspace . subspaceName
297+ consumerSubspaceName
297298 ) ;
298299
299300 // Create a symbolic link pointing to the directory.
@@ -319,7 +320,7 @@ export class RushConnect {
319320
320321 // Record the link information between the consumer package and the linked package
321322 await this . _modifyAndSaveLinkStateAsync ( ( linkState ) => {
322- const consumerPackageLinks : IRushLinkFileState [ number ] = linkState [ consumerPackage . packageName ] ?? [ ] ;
323+ const consumerPackageLinks : IRushLinkFileState [ number ] = linkState [ consumerSubspaceName ] ?? [ ] ;
323324 const existingLinkIndex : number = consumerPackageLinks . findIndex (
324325 ( link ) => link . linkedPackageName === packageName
325326 ) ;
@@ -335,7 +336,7 @@ export class RushConnect {
335336 } ) ;
336337 }
337338
338- linkState [ consumerPackage . packageName ] = consumerPackageLinks ;
339+ linkState [ consumerSubspaceName ] = consumerPackageLinks ;
339340 } ) ;
340341
341342 this . _terminal . writeLine (
@@ -385,7 +386,8 @@ export class RushConnect {
385386
386387 // Record the link information between the consumer package and the linked package
387388 await this . _modifyAndSaveLinkStateAsync ( ( linkState ) => {
388- const consumerPackageLinks : IRushLinkFileState [ number ] = linkState [ consumerPackageName ] ?? [ ] ;
389+ const subspaceName : string = consumerPackage . subspace . subspaceName ;
390+ const consumerPackageLinks : IRushLinkFileState [ number ] = linkState [ subspaceName ] ?? [ ] ;
389391 const existingLinkIndex : number = consumerPackageLinks . findIndex (
390392 ( link ) => link . linkedPackageName === linkedPackageName
391393 ) ;
@@ -401,7 +403,7 @@ export class RushConnect {
401403 } ) ;
402404 }
403405
404- linkState [ consumerPackageName ] = consumerPackageLinks ;
406+ linkState [ subspaceName ] = consumerPackageLinks ;
405407 } ) ;
406408
407409 this . _terminal . writeLine (
0 commit comments