Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: don't include registry URL in package ID #7476

Merged
merged 9 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: fix
  • Loading branch information
zkochan committed Jan 1, 2024
commit 5712ba2d6889a1667c8171689166eb3f18ea47d8
18 changes: 9 additions & 9 deletions pkg-manager/headless/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { headlessInstall } from '@pnpm/headless'
import { readWantedLockfile } from '@pnpm/lockfile-file'
import { readModulesManifest } from '@pnpm/modules-yaml'
import { tempDir } from '@pnpm/prepare'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { getIntegrity } from '@pnpm/registry-mock'
import { fixtures } from '@pnpm/test-fixtures'
import rimraf from '@zkochan/rimraf'
import loadJsonFile from 'load-json-file'
Expand Down Expand Up @@ -72,7 +72,7 @@ test('installing a simple project', async () => {
} as StageLog)).toBeTruthy()
expect(reporter.calledWithMatch({
level: 'debug',
packageId: `localhost+${REGISTRY_MOCK_PORT}/is-negative@2.1.0`,
packageId: '/is-negative@2.1.0',
requester: prefix,
status: 'resolved',
})).toBeTruthy()
Expand Down Expand Up @@ -422,13 +422,13 @@ test('available packages are used when node_modules is not clean', async () => {

expect(reporter.calledWithMatch({
level: 'debug',
packageId: `localhost+${REGISTRY_MOCK_PORT}/balanced-match@1.0.2`,
packageId: '/balanced-match@1.0.2',
requester: projectDir,
status: 'resolved',
})).toBeFalsy()
expect(reporter.calledWithMatch({
level: 'debug',
packageId: `localhost+${REGISTRY_MOCK_PORT}/rimraf@2.7.1`,
packageId: '/rimraf@2.7.1',
requester: projectDir,
status: 'resolved',
})).toBeTruthy()
Expand Down Expand Up @@ -459,13 +459,13 @@ test('available packages are relinked during forced install', async () => {

expect(reporter.calledWithMatch({
level: 'debug',
packageId: `localhost+${REGISTRY_MOCK_PORT}/balanced-match@1.0.2`,
packageId: '/balanced-match@1.0.2',
requester: projectDir,
status: 'resolved',
})).toBeTruthy()
expect(reporter.calledWithMatch({
level: 'debug',
packageId: `localhost+${REGISTRY_MOCK_PORT}/rimraf@2.7.1`,
packageId: '/rimraf@2.7.1',
requester: projectDir,
status: 'resolved',
})).toBeTruthy()
Expand Down Expand Up @@ -582,7 +582,7 @@ test('installing with hoistPattern=*', async () => {
} as StageLog))
expect(reporter).toBeCalledWith(expect.objectContaining({
level: 'debug',
packageId: `localhost+${REGISTRY_MOCK_PORT}/is-negative@2.1.0`,
packageId: '/is-negative@2.1.0',
requester: prefix,
status: 'resolved',
}))
Expand Down Expand Up @@ -638,7 +638,7 @@ test('installing with publicHoistPattern=*', async () => {
} as StageLog)).toBeTruthy()
expect(reporter.calledWithMatch({
level: 'debug',
packageId: `localhost+${REGISTRY_MOCK_PORT}/is-negative@2.1.0`,
packageId: '/is-negative@2.1.0',
requester: prefix,
status: 'resolved',
})).toBeTruthy()
Expand Down Expand Up @@ -721,7 +721,7 @@ test.skip('using side effects cache and hoistPattern=*', async () => {
const project = assertProject(lockfileDir)
await project.has('.pnpm/node_modules/es6-promise') // verifying that a flat node_modules was created

const cacheBuildDir = path.join(opts.storeDir, `localhost+${REGISTRY_MOCK_PORT}/diskusage@1.1.3/side_effects/${ENGINE_DIR}/package/build`)
const cacheBuildDir = path.join(opts.storeDir, `diskusage@1.1.3/side_effects/${ENGINE_DIR}/package/build`)
writeFileSync(path.join(cacheBuildDir, 'new-file.txt'), 'some new content')

await rimraf(path.join(lockfileDir, 'node_modules'))
Expand Down
22 changes: 11 additions & 11 deletions pkg-manager/package-requester/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test('request package', async () => {
expect(pkgResponse).toBeTruthy()
expect(pkgResponse.body).toBeTruthy()

expect(pkgResponse.body.id).toBe(`localhost+${REGISTRY_MOCK_PORT}/is-positive@1.0.0`)
expect(pkgResponse.body.id).toBe('/is-positive@1.0.0')
expect(pkgResponse.body.resolvedVia).toBe('npm-registry')
expect(pkgResponse.body.isLocal).toBe(false)
expect(typeof pkgResponse.body.latest).toBe('string')
Expand Down Expand Up @@ -96,7 +96,7 @@ test('request package but skip fetching', async () => {
expect(pkgResponse).toBeTruthy()
expect(pkgResponse.body).toBeTruthy()

expect(pkgResponse.body.id).toBe(`localhost+${REGISTRY_MOCK_PORT}/is-positive@1.0.0`)
expect(pkgResponse.body.id).toBe('/is-positive@1.0.0')
expect(pkgResponse.body.isLocal).toBe(false)
expect(typeof pkgResponse.body.latest).toBe('string')
expect(pkgResponse.body.manifest?.name).toBe('is-positive')
Expand Down Expand Up @@ -125,7 +125,7 @@ test('request package but skip fetching, when resolution is already available',
const projectDir = tempy.directory()
const pkgResponse = await requestPackage({ alias: 'is-positive', pref: '1.0.0' }, {
currentPkg: {
id: `localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0`,
id: '/is-positive/1.0.0',
resolution: {
integrity: 'sha512-xxzPGZ4P2uN6rROUa5N9Z7zTX6ERuE0hs6GUOc/cKBLF2NqKc16UwqHMt3tFg4CO6EBTE5UecUasg+3jZx3Ckg==',
tarball: `http://localhost:${REGISTRY_MOCK_PORT}/is-positive/-/is-positive-1.0.0.tgz`,
Expand All @@ -148,7 +148,7 @@ test('request package but skip fetching, when resolution is already available',
expect(pkgResponse).toBeTruthy()
expect(pkgResponse.body).toBeTruthy()

expect(pkgResponse.body.id).toBe(`localhost+${REGISTRY_MOCK_PORT}/is-positive@1.0.0`)
expect(pkgResponse.body.id).toBe('/is-positive@1.0.0')
expect(pkgResponse.body.isLocal).toBe(false)
expect(typeof pkgResponse.body.latest).toBe('string')
expect(pkgResponse.body.manifest.name).toBe('is-positive')
Expand Down Expand Up @@ -356,7 +356,7 @@ test('fetchPackageToStore()', async () => {
verifyStoreIntegrity: true,
})

const pkgId = `localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0`
const pkgId = '/is-positive/1.0.0'
const fetchResult = packageRequester.fetchPackageToStore({
force: false,
lockfileDir: tempy.directory(),
Expand Down Expand Up @@ -421,7 +421,7 @@ test('fetchPackageToStore() concurrency check', async () => {
verifyStoreIntegrity: true,
})

const pkgId = `localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0`
const pkgId = '/is-positive/1.0.0'
const projectDir1 = tempy.directory()
const projectDir2 = tempy.directory()
const fetchResults = await Promise.all([
Expand Down Expand Up @@ -506,7 +506,7 @@ test('fetchPackageToStore() does not cache errors', async () => {
verifyStoreIntegrity: true,
})

const pkgId = `localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0`
const pkgId = '/is-positive/1.0.0'

const badRequest = packageRequester.fetchPackageToStore({
force: false,
Expand Down Expand Up @@ -575,7 +575,7 @@ test('always return a package manifest in the response', async () => {
{
const pkgResponse = await requestPackage({ alias: 'is-positive', pref: '1.0.0' }, {
currentPkg: {
id: `localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0`,
id: '/is-positive/1.0.0',
resolution: {
integrity: 'sha512-xxzPGZ4P2uN6rROUa5N9Z7zTX6ERuE0hs6GUOc/cKBLF2NqKc16UwqHMt3tFg4CO6EBTE5UecUasg+3jZx3Ckg==',
tarball: `http://localhost:${REGISTRY_MOCK_PORT}/is-positive/-/is-positive-1.0.0.tgz`,
Expand Down Expand Up @@ -619,7 +619,7 @@ test('fetchPackageToStore() fetch raw manifest of cached package', async () => {
verifyStoreIntegrity: true,
})

const pkgId = `localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0`
const pkgId = '/is-positive/1.0.0'
const resolution = {
tarball: `http://localhost:${REGISTRY_MOCK_PORT}/is-positive/-/is-positive-1.0.0.tgz`,
}
Expand Down Expand Up @@ -656,7 +656,7 @@ test('refetch package to store if it has been modified', async () => {
const storeDir = tempy.directory()
const lockfileDir = tempy.directory()

const pkgId = `localhost+${REGISTRY_MOCK_PORT}/magic-hook/2.0.0`
const pkgId = '/magic-hook/2.0.0'
const resolution = {
tarball: `http://localhost:${REGISTRY_MOCK_PORT}/magic-hook/-/magic-hook-2.0.0.tgz`,
}
Expand Down Expand Up @@ -764,7 +764,7 @@ test('do not fetch an optional package that is not installable', async () => {
expect(pkgResponse.body).toBeTruthy()

expect(pkgResponse.body.isInstallable).toBe(false)
expect(pkgResponse.body.id).toBe(`localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/not-compatible-with-any-os@1.0.0`)
expect(pkgResponse.body.id).toBe('/@pnpm.e2e/not-compatible-with-any-os@1.0.0')

expect(pkgResponse.fetching).toBeFalsy()
})
Expand Down
2 changes: 1 addition & 1 deletion store/plugin-commands-store/src/storeStatus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function storeStatus (maybeOpts: StoreStatusOptions) {
const pkgs = Object.entries(wantedLockfile.packages ?? {})
.filter(([depPath]) => !skipped.has(depPath))
.map(([depPath, pkgSnapshot]) => {
const id = packageIdFromSnapshot(depPath, pkgSnapshot, registries)
const id = packageIdFromSnapshot(depPath, pkgSnapshot)
return {
depPath,
id,
Expand Down
Loading