-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3908 from jeremymeng/fix-pnpm-v7-local-path-3652
[rush-lib] react to pnpm v7 local install path breaking change
- Loading branch information
Showing
6 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
common/changes/@microsoft/rush/fix-pnpm-v7-local-path-3652_2023-01-19-22-06.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@microsoft/rush", | ||
"comment": "Fix linking error due to PNPM v7 local install path breaking change", | ||
"type": "none" | ||
} | ||
], | ||
"packageName": "@microsoft/rush" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. | ||
{ | ||
"pnpmShrinkwrapHash": "2b28a3b0d2c74bd1a0a620cb83c8e67329d0d13e", | ||
"pnpmShrinkwrapHash": "63cf094bd4876739348f39843a52fae39798f004", | ||
"preferredVersionsHash": "5222ca779ae69ebfd201e39c17f48ce9eaf8c3c2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import * as crypto from 'crypto'; | |
import uriEncode from 'strict-uri-encode'; | ||
import pnpmLinkBins from '@pnpm/link-bins'; | ||
import * as semver from 'semver'; | ||
import { depPathToFilename } from 'dependency-path'; | ||
import colors from 'colors/safe'; | ||
|
||
import { | ||
|
@@ -217,6 +218,7 @@ export class PnpmLinkManager extends BaseLinkManager { | |
|
||
// e.g.: C:\wbt\common\temp\node_modules\.local\C%3A%2Fwbt%2Fcommon%2Ftemp%2Fprojects%2Fapi-documenter.tgz\node_modules | ||
const pathToLocalInstallation: string = this._getPathToLocalInstallation( | ||
tarballEntry, | ||
absolutePathToTgzFile, | ||
folderNameSuffix | ||
); | ||
|
@@ -272,8 +274,12 @@ export class PnpmLinkManager extends BaseLinkManager { | |
}); | ||
} | ||
|
||
private _getPathToLocalInstallation(absolutePathToTgzFile: string, folderSuffix: string): string { | ||
if (this._pnpmVersion.major >= 6) { | ||
private _getPathToLocalInstallation( | ||
tarballEntry: string, | ||
absolutePathToTgzFile: string, | ||
folderSuffix: string | ||
): string { | ||
if (this._pnpmVersion.major === 6) { | ||
// PNPM 6 changed formatting to replace all ':' and '/' chars with '+'. Additionally, folder names > 120 | ||
// are trimmed and hashed. NOTE: PNPM internally uses fs.realpath.native, which will cause additional | ||
// issues in environments that do not support long paths. | ||
|
@@ -294,6 +300,20 @@ export class PnpmLinkManager extends BaseLinkManager { | |
.digest('hex')}`; | ||
} | ||
|
||
return path.join( | ||
this._rushConfiguration.commonTempFolder, | ||
RushConstants.nodeModulesFolderName, | ||
'.pnpm', | ||
folderName, | ||
RushConstants.nodeModulesFolderName | ||
); | ||
} else if (this._pnpmVersion.major >= 7) { | ||
// PNPM 7 changed the local path format again and the hashing algorithm | ||
// See https://github.com/pnpm/pnpm/releases/tag/v7.0.0 | ||
// e.g.: | ||
// [email protected] | ||
const escapedLocalPath: string = depPathToFilename(tarballEntry); | ||
const folderName: string = `${escapedLocalPath}${folderSuffix}`; | ||
return path.join( | ||
this._rushConfiguration.commonTempFolder, | ||
RushConstants.nodeModulesFolderName, | ||
|