mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 21:11:55 -04:00
fix(license-scanner): handle git repo names with capital letters (#7488)
--------- Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
committed by
Zoltan Kochan
parent
d9564e3546
commit
dcf3ef7e4f
7
.changeset/silly-dryers-pull.md
Normal file
7
.changeset/silly-dryers-pull.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-licenses": patch
|
||||
"@pnpm/license-scanner": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Handle Git repository names containing capital letters [#7488](https://github.com/pnpm/pnpm/pull/7488).
|
||||
@@ -158,7 +158,7 @@ async function readLicenseFileFromCafs (cafsDir: string, { integrity, mode }: Pa
|
||||
*/
|
||||
export async function readPackageIndexFile (
|
||||
packageResolution: Resolution,
|
||||
depPath: string,
|
||||
id: string,
|
||||
opts: { cafsDir: string, storeDir: string, lockfileDir: string }
|
||||
): Promise<
|
||||
| {
|
||||
@@ -195,10 +195,7 @@ export async function readPackageIndexFile (
|
||||
'index'
|
||||
)
|
||||
} else if (!packageResolution.type && packageResolution.tarball) {
|
||||
// If the package resolution has a tarball then we need to clean up
|
||||
// the return value to depPathToFilename as it adds peer deps(e.g. a@1.0.0_peer-foo@18.0.0_peer-bar@18.0.0) or patch hash(a@1.0.0_patch_hash=xxxx) part to the
|
||||
// directory for the package in the content-addressable store
|
||||
const packageDirInStore = depPathToFilename(depPath).split('_')[0]
|
||||
const packageDirInStore = depPathToFilename(id)
|
||||
pkgIndexFilePath = path.join(
|
||||
opts.storeDir,
|
||||
packageDirInStore,
|
||||
@@ -207,7 +204,7 @@ export async function readPackageIndexFile (
|
||||
} else {
|
||||
throw new PnpmError(
|
||||
'UNSUPPORTED_PACKAGE_TYPE',
|
||||
`Unsupported package resolution type for ${depPath}`
|
||||
`Unsupported package resolution type for ${id}`
|
||||
)
|
||||
}
|
||||
|
||||
@@ -221,7 +218,7 @@ export async function readPackageIndexFile (
|
||||
if (err.code === 'ENOENT') {
|
||||
throw new PnpmError(
|
||||
'MISSING_PACKAGE_INDEX_FILE',
|
||||
`Failed to find package index file for ${depPath}, please consider running 'pnpm install'`
|
||||
`Failed to find package index file for ${id}, please consider running 'pnpm install'`
|
||||
)
|
||||
}
|
||||
|
||||
@@ -230,6 +227,7 @@ export async function readPackageIndexFile (
|
||||
}
|
||||
|
||||
export interface PackageInfo {
|
||||
id: string
|
||||
name?: string
|
||||
version?: string
|
||||
depPath: string
|
||||
@@ -270,7 +268,7 @@ export async function getPkgInfo (
|
||||
|
||||
const packageFileIndexInfo = await readPackageIndexFile(
|
||||
packageResolution as Resolution,
|
||||
pkg.depPath,
|
||||
pkg.id,
|
||||
{
|
||||
cafsDir,
|
||||
storeDir: opts.storeDir,
|
||||
|
||||
@@ -68,6 +68,7 @@ export async function lockfileToLicenseNode (
|
||||
|
||||
const packageInfo = await getPkgInfo(
|
||||
{
|
||||
id: pkgSnapshot.id ?? depPath,
|
||||
name,
|
||||
version,
|
||||
depPath,
|
||||
|
||||
@@ -11,6 +11,7 @@ describe('licences', () => {
|
||||
{
|
||||
name: 'bogus-package',
|
||||
version: '1.0.0',
|
||||
id: '/bogus-package/1.0.0',
|
||||
depPath: '/bogus-package/1.0.0',
|
||||
snapshot: {
|
||||
resolution: {
|
||||
|
||||
7
reviewing/plugin-commands-licenses/test/fixtures/with-git-protocol-caps/package.json
vendored
Normal file
7
reviewing/plugin-commands-licenses/test/fixtures/with-git-protocol-caps/package.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "with-git-protocol-caps",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"capitalized-repo": "github:pnpm-e2e/Capitalized-Repo"
|
||||
}
|
||||
}
|
||||
@@ -255,3 +255,26 @@ test('pnpm licenses should work with git protocol dep that have peerDependencies
|
||||
|
||||
expect(exitCode).toBe(0)
|
||||
})
|
||||
|
||||
test('pnpm licenses should work git repository name containing capital letters', async () => {
|
||||
const workspaceDir = tempDir()
|
||||
f.copy('with-git-protocol-caps', workspaceDir)
|
||||
|
||||
const storeDir = path.join(workspaceDir, 'store')
|
||||
await install.handler({
|
||||
...DEFAULT_OPTS,
|
||||
dir: workspaceDir,
|
||||
pnpmHomeDir: '',
|
||||
storeDir,
|
||||
})
|
||||
|
||||
const { exitCode } = await licenses.handler({
|
||||
...DEFAULT_OPTS,
|
||||
dir: workspaceDir,
|
||||
pnpmHomeDir: '',
|
||||
long: false,
|
||||
storeDir: path.resolve(storeDir, 'v3'),
|
||||
}, ['list'])
|
||||
|
||||
expect(exitCode).toBe(0)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user