@@ -24,6 +24,7 @@ import { RushConstants } from '../../logic/RushConstants';
2424import { IRushLinkJson } from '../../api/RushConfiguration' ;
2525import { RushConfigurationProject } from '../../api/RushConfigurationProject' ;
2626import { PnpmShrinkwrapFile } from './PnpmShrinkwrapFile' ;
27+ import { PnpmProjectDependencyManifest } from './PnpmProjectDependencyManifest' ;
2728
2829// special flag for debugging, will print extra diagnostic information,
2930// but comes with performance cost
@@ -72,7 +73,8 @@ export class PnpmLinkManager extends BaseLinkManager {
7273 private _linkProject (
7374 project : RushConfigurationProject ,
7475 rushLinkJson : IRushLinkJson ,
75- pnpmShrinkwrapFile : PnpmShrinkwrapFile ) : Promise < void > {
76+ pnpmShrinkwrapFile : PnpmShrinkwrapFile
77+ ) : Promise < void > {
7678
7779 // first, read the temp package.json information
7880
@@ -87,8 +89,12 @@ export class PnpmLinkManager extends BaseLinkManager {
8789 const packageJsonFilename : string = path . join ( extractedFolder , FileConstants . PackageJson ) ;
8890
8991 // Example: "C:\MyRepo\common\temp\node_modules\@rush-temp\project1"
90- const installFolderName : string = path . join ( this . _rushConfiguration . commonTempFolder ,
91- RushConstants . nodeModulesFolderName , RushConstants . rushTempNpmScope , unscopedTempProjectName ) ;
92+ const installFolderName : string = path . join (
93+ this . _rushConfiguration . commonTempFolder ,
94+ RushConstants . nodeModulesFolderName ,
95+ RushConstants . rushTempNpmScope ,
96+ unscopedTempProjectName
97+ ) ;
9298
9399 const commonPackage : BasePackage = BasePackage . createVirtualTempPackage ( packageJsonFilename , installFolderName ) ;
94100
@@ -102,7 +108,6 @@ export class PnpmLinkManager extends BaseLinkManager {
102108
103109 // first, start with the rush dependencies, we just need to link to the project folder
104110 for ( const dependencyName of Object . keys ( commonPackage . packageJson ! . rushDependencies || { } ) ) {
105-
106111 const matchedRushPackage : RushConfigurationProject | undefined =
107112 this . _rushConfiguration . getProjectByName ( dependencyName ) ;
108113
@@ -130,8 +135,9 @@ export class PnpmLinkManager extends BaseLinkManager {
130135 newLocalPackage . symlinkTargetFolderPath = matchedRushPackage . projectFolder ;
131136 localPackage . children . push ( newLocalPackage ) ;
132137 } else {
133- throw new InternalError ( `Cannot find dependency "${ dependencyName } " for "${ project . packageName } " in `
134- + ` the Rush configuration` ) ;
138+ throw new InternalError (
139+ `Cannot find dependency "${ dependencyName } " for "${ project . packageName } " in the Rush configuration`
140+ ) ;
135141 }
136142 }
137143
@@ -155,8 +161,9 @@ export class PnpmLinkManager extends BaseLinkManager {
155161 // file:projects/bentleyjs-core.tgz
156162 // file:projects/build-tools.tgz_dc21d88642e18a947127a751e00b020a
157163 // file:projects/imodel-from-geojson.tgz_request@2.88.0
158- const tempProjectDependencyKey : string | undefined =
159- pnpmShrinkwrapFile . getTempProjectDependencyKey ( project . tempProjectName ) ;
164+ const tempProjectDependencyKey : string | undefined = pnpmShrinkwrapFile . getTempProjectDependencyKey (
165+ project . tempProjectName
166+ ) ;
160167
161168 if ( ! tempProjectDependencyKey ) {
162169 throw new Error ( `Cannot get dependency key for temp project: ${ project . tempProjectName } ` ) ;
@@ -188,8 +195,9 @@ export class PnpmLinkManager extends BaseLinkManager {
188195 // '' [empty string]
189196 // _jsdom@11.12.0
190197 // _2a665c89609864b4e75bc5365d7f8f56
191- const folderNameSuffix : string = ( tarballEntry && tarballEntry . length < tempProjectDependencyKey . length ?
192- tempProjectDependencyKey . slice ( tarballEntry . length ) : '' ) ;
198+ const folderNameSuffix : string = tarballEntry && tarballEntry . length < tempProjectDependencyKey . length
199+ ? tempProjectDependencyKey . slice ( tarballEntry . length )
200+ : '' ;
193201
194202 // e.g.:
195203 // C%3A%2Fwbt%2Fcommon%2Ftemp%2Fprojects%2Fapi-documenter.tgz
@@ -205,7 +213,13 @@ export class PnpmLinkManager extends BaseLinkManager {
205213 RushConstants . nodeModulesFolderName ,
206214 '.local' ,
207215 folderNameInLocalInstallationRoot ,
208- RushConstants . nodeModulesFolderName ) ;
216+ RushConstants . nodeModulesFolderName
217+ ) ;
218+
219+ const pnpmProjectDependencyManifest : PnpmProjectDependencyManifest = new PnpmProjectDependencyManifest ( {
220+ pnpmShrinkwrapFile,
221+ project
222+ } ) ;
209223
210224 for ( const dependencyName of Object . keys ( commonPackage . packageJson ! . dependencies || { } ) ) {
211225 // the dependency we are looking for should have already created a symlink here
@@ -233,24 +247,25 @@ export class PnpmLinkManager extends BaseLinkManager {
233247 // it pointed, rather than linking to a link.
234248 const dependencyLocalInstallationRealpath : string = FileSystem . getRealPath ( dependencyLocalInstallationSymlink ) ;
235249
236- const newLocalFolderPath : string = path . join (
237- localPackage . folderPath , 'node_modules' , dependencyName ) ;
250+ const newLocalFolderPath : string = path . join ( localPackage . folderPath , 'node_modules' , dependencyName ) ;
238251
239252 let version : string | undefined = undefined ;
240- if ( DEBUG ) {
253+ // if (DEBUG) {
241254 // read the version number for diagnostic purposes
242255 const packageJsonForDependency : IPackageJson = JsonFile . load (
243256 path . join ( dependencyLocalInstallationRealpath , FileConstants . PackageJson ) ) ;
244257
245258 version = packageJsonForDependency . version ;
246- }
259+ // }
247260
248261 const newLocalPackage : BasePackage = BasePackage . createLinkedPackage (
249262 dependencyName ,
250263 version ,
251264 newLocalFolderPath
252265 ) ;
253266
267+ pnpmProjectDependencyManifest . addDependency ( newLocalPackage ) ;
268+
254269 newLocalPackage . symlinkTargetFolderPath = dependencyLocalInstallationRealpath ;
255270 localPackage . addChild ( newLocalPackage ) ;
256271 }
@@ -261,6 +276,8 @@ export class PnpmLinkManager extends BaseLinkManager {
261276
262277 PnpmLinkManager . _createSymlinksForTopLevelProject ( localPackage ) ;
263278
279+ pnpmProjectDependencyManifest . save ( ) ;
280+
264281 // Also symlink the ".bin" folder
265282 const projectFolder : string = path . join ( localPackage . folderPath , 'node_modules' ) ;
266283 const projectBinFolder : string = path . join ( localPackage . folderPath , 'node_modules' , '.bin' ) ;
0 commit comments