fix: issues with storybook and the new lockfile format (#5998)

close #5976
This commit is contained in:
Zoltan Kochan
2023-01-30 17:28:20 +02:00
committed by GitHub
parent 587c4a2bb6
commit 9247f6781b
3 changed files with 13 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/dependency-path": patch
"pnpm": patch
---
Directories inside the virtual store should not contain the ( or ) chars. This is to fix issues with storybook and the new v6 `pnpm-lock.yaml` lockfile format [#5976](https://github.com/pnpm/pnpm/issues/5976).

View File

@@ -143,7 +143,12 @@ export function parse (dependencyPath: string) {
}
export function depPathToFilename (depPath: string) {
const filename = depPathToFilenameUnescaped(depPath).replace(/[\\/:*?"<>|]/g, '+')
let filename = depPathToFilenameUnescaped(depPath).replace(/[\\/:*?"<>|]/g, '+')
if (filename.includes('(')) {
filename = filename
.replace(/(\)\()|\(/g, '_')
.replace(/\)$/, '')
}
if (filename.length > 120 || filename !== filename.toLowerCase() && !filename.startsWith('file+')) {
return `${filename.substring(0, 50)}_${createBase32Hash(filename)}`
}

View File

@@ -154,6 +154,7 @@ test('depPathToFilename()', () => {
expect(depPathToFilename('/@foo/bar/1.0.0')).toBe('@foo+bar@1.0.0')
expect(depPathToFilename('github.com/something/foo/0000?v=1')).toBe('github.com+something+foo@0000+v=1')
expect(depPathToFilename('\\//:*?"<>|')).toBe('++@+++++++')
expect(depPathToFilename('/foo/1.0.0(react@16.0.0)(react-dom@16.0.0)')).toBe('foo@1.0.0_react@16.0.0_react-dom@16.0.0')
const filename = depPathToFilename('file:test/foo-1.0.0.tgz_foo@2.0.0')
expect(filename).toBe('file+test+foo-1.0.0.tgz_foo@2.0.0')