mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-15 01:24:07 -05:00
feat!: remove the registry field from the lockfile (#6107)
This commit is contained in:
8
.changeset/clean-pants-cheat.md
Normal file
8
.changeset/clean-pants-cheat.md
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
"@pnpm/lockfile-types": major
|
||||
"@pnpm/lockfile-utils": major
|
||||
"@pnpm/resolve-dependencies": major
|
||||
"pnpm": major
|
||||
---
|
||||
|
||||
The registry field is removed from the `resolution` object in `pnpm-lock.yaml`.
|
||||
@@ -57,10 +57,6 @@ export interface TarballResolution {
|
||||
type?: undefined
|
||||
tarball: string
|
||||
integrity?: string
|
||||
// needed in some cases to get the auth token
|
||||
// sometimes the tarball URL is under a different path
|
||||
// and the auth token is specified for the registry only
|
||||
registry?: string
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,9 +18,7 @@ export function pkgSnapshotToResolution (
|
||||
return pkgSnapshot.resolution as Resolution
|
||||
}
|
||||
const { name } = nameVerFromPkgSnapshot(depPath, pkgSnapshot)
|
||||
const registry: string = (pkgSnapshot.resolution as TarballResolution).registry || // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing
|
||||
(name[0] === '@' && registries[name.split('/')[0]]) ||
|
||||
registries.default
|
||||
const registry: string = (name[0] === '@' && registries[name.split('/')[0]]) || registries.default
|
||||
let tarball!: string
|
||||
if (!(pkgSnapshot.resolution as TarballResolution).tarball) {
|
||||
tarball = getTarball(registry)
|
||||
@@ -42,5 +40,4 @@ export function pkgSnapshotToResolution (
|
||||
}
|
||||
return getNpmTarballUrl(name, version, { registry })
|
||||
}
|
||||
/* eslint-enable @typescript-eslint/dot-notation */
|
||||
}
|
||||
|
||||
@@ -32,16 +32,4 @@ test('pkgSnapshotToResolution()', () => {
|
||||
registry: 'https://mycompany.jfrog.io/mycompany/api/npm/npm-local',
|
||||
tarball: 'https://mycompany.jfrog.io/mycompany/api/npm/npm-local/@mycompany/mypackage/-/@mycompany/mypackage-2.0.0.tgz',
|
||||
})
|
||||
|
||||
expect(pkgSnapshotToResolution('/foo/1.0.0', {
|
||||
resolution: {
|
||||
integrity: 'AAAA',
|
||||
registry: 'https://npm.pkg.github.com/',
|
||||
tarball: 'https://npm.pkg.github.com/download/@foo/bar/1.0.0/aaa',
|
||||
},
|
||||
}, { default: 'https://registry.npmjs.org/' })).toEqual({
|
||||
integrity: 'AAAA',
|
||||
registry: 'https://npm.pkg.github.com/',
|
||||
tarball: 'https://npm.pkg.github.com/download/@foo/bar/1.0.0/aaa',
|
||||
})
|
||||
})
|
||||
|
||||
@@ -188,7 +188,6 @@ function toLockfileDependency (
|
||||
if (!requiresBuildIsKnown && !pending) {
|
||||
(pkg.requiresBuild as SafePromiseDefer<boolean>).resolve(result.requiresBuild ?? false)
|
||||
}
|
||||
/* eslint-enable @typescript-eslint/dot-notation */
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -239,10 +238,8 @@ function toLockfileResolution (
|
||||
if (dp.isAbsolute(depPath) || resolution.type !== undefined || !resolution['integrity']) {
|
||||
return resolution as LockfileResolution
|
||||
}
|
||||
const base = registry !== resolution['registry'] ? { registry: resolution['registry'] } : {}
|
||||
if (lockfileIncludeTarballUrl) {
|
||||
return {
|
||||
...base,
|
||||
integrity: resolution['integrity'],
|
||||
tarball: resolution['tarball'],
|
||||
}
|
||||
@@ -254,16 +251,13 @@ function toLockfileResolution (
|
||||
const actualTarball = resolution['tarball'].replace('%2f', '/')
|
||||
if (removeProtocol(expectedTarball) !== removeProtocol(actualTarball)) {
|
||||
return {
|
||||
...base,
|
||||
integrity: resolution['integrity'],
|
||||
tarball: relativeTarball(resolution['tarball'], registry),
|
||||
}
|
||||
}
|
||||
return {
|
||||
...base,
|
||||
integrity: resolution['integrity'],
|
||||
}
|
||||
/* eslint-enable @typescript-eslint/dot-notation */
|
||||
}
|
||||
|
||||
function removeProtocol (url: string) {
|
||||
|
||||
Reference in New Issue
Block a user