@@ -71,7 +71,8 @@ export interface IRushRepositoryJson {
7171 */
7272export interface IRushConfigurationJson {
7373 $schema : string ;
74- npmVersion : string ;
74+ npmVersion ?: string ;
75+ pnpmVersion ?: string ;
7576 rushMinimumVersion : string ;
7677 repository ?: IRushRepositoryJson ;
7778 nodeSupportedVersionRange ?: string ;
@@ -108,14 +109,15 @@ export default class RushConfiguration {
108109 private _commonFolder : string ;
109110 private _commonTempFolder : string ;
110111 private _commonRushConfigFolder : string ;
111- private _npmCacheFolder : string ;
112- private _npmTmpFolder : string ;
112+ private _packageManager : 'pnpm' | 'npm' ;
113+ private _packageManagerCacheFolder : string ;
114+ private _packageManagerTmpFolder : string ;
113115 private _committedShrinkwrapFilename : string ;
114116 private _tempShrinkwrapFilename : string ;
115117 private _homeFolder : string ;
116118 private _rushLinkJsonFilename : string ;
117- private _npmToolVersion : string ;
118- private _npmToolFilename : string ;
119+ private _packageManagerToolVersion : string ;
120+ private _packageManagerToolFilename : string ;
119121 private _projectFolderMinDepth : number ;
120122 private _projectFolderMaxDepth : number ;
121123
@@ -261,6 +263,10 @@ export default class RushConfiguration {
261263 }
262264 }
263265
266+ public get packageManager ( ) : 'pnpm' | 'npm' {
267+ return this . _packageManager ;
268+ }
269+
264270 /**
265271 * The Rush configuration file
266272 */
@@ -321,7 +327,7 @@ export default class RushConfiguration {
321327 * Example: "C:\MyRepo\common\temp\npm-cache"
322328 */
323329 public get npmCacheFolder ( ) : string {
324- return this . _npmCacheFolder ;
330+ return this . _packageManagerCacheFolder ;
325331 }
326332
327333 /**
@@ -332,14 +338,14 @@ export default class RushConfiguration {
332338 * Example: "C:\MyRepo\common\temp\npm-tmp"
333339 */
334340 public get npmTmpFolder ( ) : string {
335- return this . _npmTmpFolder ;
341+ return this . _packageManagerTmpFolder ;
336342 }
337343
338344 /**
339345 * The filename of the NPM shrinkwrap file that is tracked e.g. by Git. (The "rush install"
340346 * command uses a temporary copy, whose path is tempShrinkwrapFilename.)
341347 * This property merely reports the filename; the file itself may not actually exist.
342- * Example: "C:\MyRepo\common\npm-shrinkwrap.json"
348+ * Example: "C:\MyRepo\common\npm-shrinkwrap.json" or "C:\MyRepo\common\shrinkwrap.yaml"
343349 */
344350 public get committedShrinkwrapFilename ( ) : string {
345351 return this . _committedShrinkwrapFilename ;
@@ -349,7 +355,7 @@ export default class RushConfiguration {
349355 * The filename of the temporary NPM shrinkwrap file that is used by "rush install".
350356 * (The master copy is tempShrinkwrapFilename.)
351357 * This property merely reports the filename; the file itself may not actually exist.
352- * Example: "C:\MyRepo\common\temp\npm-shrinkwrap.json"
358+ * Example: "C:\MyRepo\common\temp\npm-shrinkwrap.json" or "C:\MyRepo\common\temp\shrinkwrap.yaml"
353359 */
354360 public get tempShrinkwrapFilename ( ) : string {
355361 return this . _tempShrinkwrapFilename ;
@@ -378,7 +384,7 @@ export default class RushConfiguration {
378384 * The version of the locally installed NPM tool. (Example: "1.2.3")
379385 */
380386 public get npmToolVersion ( ) : string {
381- return this . _npmToolVersion ;
387+ return this . _packageManagerToolVersion ;
382388 }
383389
384390 /**
@@ -387,7 +393,7 @@ export default class RushConfiguration {
387393 * Example: "C:\MyRepo\common\temp\npm-local\node_modules\.bin\npm"
388394 */
389395 public get npmToolFilename ( ) : string {
390- return this . _npmToolFilename ;
396+ return this . _packageManagerToolFilename ;
391397 }
392398
393399 /**
@@ -559,14 +565,11 @@ export default class RushConfiguration {
559565 RushConfiguration . _validateCommonRushConfigFolder ( this . _commonRushConfigFolder ) ;
560566
561567 this . _commonTempFolder = path . join ( this . _commonFolder , RushConstants . rushTempFolderName ) ;
562- this . _npmCacheFolder = path . resolve ( path . join ( this . _commonTempFolder , 'npm -cache' ) ) ;
563- this . _npmTmpFolder = path . resolve ( path . join ( this . _commonTempFolder , 'npm -tmp' ) ) ;
568+ this . _packageManagerCacheFolder = path . resolve ( path . join ( this . _commonTempFolder , 'packages -cache' ) ) ;
569+ this . _packageManagerTmpFolder = path . resolve ( path . join ( this . _commonTempFolder , 'packages -tmp' ) ) ;
564570
565571 this . _changesFolder = path . join ( this . _commonFolder , RushConstants . changeFilesFolderName ) ;
566572
567- this . _committedShrinkwrapFilename = path . join ( this . _commonRushConfigFolder , RushConstants . npmShrinkwrapFilename ) ;
568- this . _tempShrinkwrapFilename = path . join ( this . _commonTempFolder , RushConstants . npmShrinkwrapFilename ) ;
569-
570573 const unresolvedUserFolder : string = process . env [ ( process . platform === 'win32' ) ? 'USERPROFILE' : 'HOME' ] ;
571574 this . _homeFolder = path . resolve ( unresolvedUserFolder ) ;
572575 if ( ! fsx . existsSync ( this . _homeFolder ) ) {
@@ -575,9 +578,29 @@ export default class RushConfiguration {
575578
576579 this . _rushLinkJsonFilename = path . join ( this . _commonTempFolder , 'rush-link.json' ) ;
577580
578- this . _npmToolVersion = rushConfigurationJson . npmVersion ;
579- this . _npmToolFilename = path . resolve ( path . join ( this . _commonTempFolder ,
580- 'npm-local' , 'node_modules' , '.bin' , 'npm' ) ) ;
581+ if ( rushConfigurationJson . npmVersion ) {
582+ this . _packageManager = 'npm' ;
583+
584+ this . _committedShrinkwrapFilename = path . join ( this . _commonRushConfigFolder , RushConstants . npmShrinkwrapFilename ) ;
585+ this . _tempShrinkwrapFilename = path . join ( this . _commonTempFolder , RushConstants . npmShrinkwrapFilename ) ;
586+
587+ this . _packageManagerToolVersion = rushConfigurationJson . npmVersion ;
588+ this . _packageManagerToolFilename = path . resolve ( path . join ( this . _commonTempFolder ,
589+ 'npm-local' , 'node_modules' , '.bin' , 'npm' ) ) ;
590+
591+ } else if ( rushConfigurationJson . pnpmVersion ) {
592+ this . _packageManager = 'pnpm' ;
593+
594+ this . _committedShrinkwrapFilename = path . join ( this . _commonRushConfigFolder , RushConstants . pnpmShrinkwrapFilename ) ;
595+ this . _tempShrinkwrapFilename = path . join ( this . _commonTempFolder , RushConstants . pnpmShrinkwrapFilename ) ;
596+
597+ this . _packageManagerToolVersion = rushConfigurationJson . pnpmVersion ;
598+ this . _packageManagerToolFilename = path . resolve ( path . join ( this . _commonTempFolder ,
599+ 'pnpm-local' , 'node_modules' , '.bin' , 'pnpm' ) ) ;
600+
601+ } else {
602+ throw new Error ( `Neither "npmVersion" nor "pnpmVersion" was defined in the rush configuration.` ) ;
603+ }
581604
582605 this . _projectFolderMinDepth = rushConfigurationJson . projectFolderMinDepth !== undefined
583606 ? rushConfigurationJson . projectFolderMinDepth : 1 ;
0 commit comments