@@ -6,12 +6,18 @@ import * as colors from 'colors';
66
77import {
88 getPackageDeps ,
9+ gitHashFiles ,
910 IPackageDeps
1011} from '@microsoft/package-deps-hash' ;
11- import { Path } from '@microsoft/node-core-library' ;
12+ import {
13+ Path ,
14+ InternalError
15+ } from '@microsoft/node-core-library' ;
1216
1317import { RushConfiguration } from '../api/RushConfiguration' ;
1418import { Git } from './Git' ;
19+ import { PnpmProjectDependencyManifest } from './pnpm/PnpmProjectDependencyManifest' ;
20+ import { RushConfigurationProject } from '../api/RushConfigurationProject' ;
1521
1622export class PackageChangeAnalyzer {
1723 // Allow this function to be overwritten during unit tests
@@ -125,19 +131,48 @@ export class PackageChangeAnalyzer {
125131 // });
126132 // }
127133
128- // Determine the current variant from the link JSON.
129- const variant : string | undefined = this . _rushConfiguration . currentInstalledVariant ;
130-
131- // Add the shrinkwrap file to every project's dependencies
132- const shrinkwrapFile : string = path . relative (
133- this . _rushConfiguration . rushJsonFolder ,
134- this . _rushConfiguration . getCommittedShrinkwrapFilename ( variant )
135- ) . replace ( / \\ / g, '/' ) ;
134+ if ( this . _rushConfiguration . packageManager === 'pnpm' ) {
135+ const projects : RushConfigurationProject [ ] = [ ] ;
136+ const projectDependencyManifestPaths : string [ ] = [ ] ;
137+
138+ for ( const project of this . _rushConfiguration . projects ) {
139+ const dependencyManifestFilePath : string = PnpmProjectDependencyManifest . getFilePathForProject ( project ) ;
140+ const relativeDependencyManifestFilePath : string = path . relative (
141+ this . _rushConfiguration . rushJsonFolder ,
142+ dependencyManifestFilePath
143+ ) . replace ( / \\ / g, '/' ) ;
144+ projects . push ( project ) ;
145+ projectDependencyManifestPaths . push ( relativeDependencyManifestFilePath ) ;
146+ }
136147
137- for ( const project of this . _rushConfiguration . projects ) {
138- const shrinkwrapHash : string | undefined = noProjectHashes [ shrinkwrapFile ] ;
139- if ( shrinkwrapHash ) {
140- projectHashDeps . get ( project . packageName ) ! . files [ shrinkwrapFile ] = shrinkwrapHash ;
148+ const hashes : Map < string , string > = gitHashFiles (
149+ projectDependencyManifestPaths ,
150+ this . _rushConfiguration . rushJsonFolder
151+ ) ;
152+ for ( let i : number = 0 ; i < projects . length ; i ++ ) {
153+ const project : RushConfigurationProject = projects [ i ] ;
154+ const projectDependencyManifestPath : string = projectDependencyManifestPaths [ i ] ;
155+ if ( ! hashes . has ( projectDependencyManifestPath ) ) {
156+ throw new InternalError ( `Expected to get a hash for ${ projectDependencyManifestPath } ` ) ;
157+ }
158+ const hash : string = hashes . get ( projectDependencyManifestPath ) ! ;
159+ projectHashDeps . get ( project . packageName ) ! . files [ projectDependencyManifestPath ] = hash ;
160+ }
161+ } else {
162+ // Determine the current variant from the link JSON.
163+ const variant : string | undefined = this . _rushConfiguration . currentInstalledVariant ;
164+
165+ // Add the shrinkwrap file to every project's dependencies
166+ const shrinkwrapFile : string = path . relative (
167+ this . _rushConfiguration . rushJsonFolder ,
168+ this . _rushConfiguration . getCommittedShrinkwrapFilename ( variant )
169+ ) . replace ( / \\ / g, '/' ) ;
170+
171+ for ( const project of this . _rushConfiguration . projects ) {
172+ const shrinkwrapHash : string | undefined = noProjectHashes [ shrinkwrapFile ] ;
173+ if ( shrinkwrapHash ) {
174+ projectHashDeps . get ( project . packageName ) ! . files [ shrinkwrapFile ] = shrinkwrapHash ;
175+ }
141176 }
142177 }
143178
0 commit comments