From 59817981f2e8b991c8df281df06581aa196a0792 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 5 Jun 2022 03:18:54 +0300 Subject: [PATCH 01/11] fix: auto-install-peers --- .../src/resolveDependencies.ts | 123 ++++++++++++------ .../src/resolveDependencyTree.ts | 5 +- 2 files changed, 88 insertions(+), 40 deletions(-) diff --git a/packages/resolve-dependencies/src/resolveDependencies.ts b/packages/resolve-dependencies/src/resolveDependencies.ts index b34a117e1fb..27e347db1b4 100644 --- a/packages/resolve-dependencies/src/resolveDependencies.ts +++ b/packages/resolve-dependencies/src/resolveDependencies.ts @@ -163,6 +163,7 @@ export type PkgAddress = { updated: boolean rootDir: string missingPeers: Record + resolvedPeers: Record } & ({ isLinkedDependency: true version: string @@ -206,7 +207,7 @@ export interface ResolvedPackage { type ParentPkg = Pick -type ParentPkgAliases = Record +type ParentPkgAliases = Record interface ResolvedDependenciesOptions { currentDepth: number @@ -222,47 +223,76 @@ interface ResolvedDependenciesOptions { workspacePackages?: WorkspacePackages } -type PostponedResolutionFunction = (preferredVersions: PreferredVersions, parentPkgAliases: ParentPkgAliases) => Promise +type PostponedResolutionFunction = (preferredVersions: PreferredVersions, parentPkgAliases: ParentPkgAliases) => Promise<{ + missingPeers: Record + resolvedPeers: Record +}> -export default async function resolveDependencies ( +export async function resolveRootDependencies ( ctx: ResolutionContext, preferredVersions: PreferredVersions, wantedDependencies: Array, options: ResolvedDependenciesOptions ): Promise> { - let extendedWantedDeps: ExtendedWantedDependency[] = [] - const postponedResolutionsQueue: PostponedResolutionFunction[] = [] - const pkgAddresses: PkgAddress[] = [] + const pkgAddresses: Array = [] while (true) { - extendedWantedDeps = getDepsToResolve(wantedDependencies, ctx.wantedLockfile, { - preferredDependencies: options.preferredDependencies, - prefix: ctx.prefix, - proceed: options.proceed || ctx.forceFullResolution, - registries: ctx.registries, - resolvedDependencies: options.resolvedDependencies, - }) - const newPkgAddresses = ( - await Promise.all( - extendedWantedDeps.map(async (extendedWantedDep) => resolveDependenciesOfDependency( - postponedResolutionsQueue, - ctx, - preferredVersions, - options, - extendedWantedDep - )) - ) - ).filter(Boolean) as PkgAddress[] - pkgAddresses.push(...newPkgAddresses) + const result = await resolveDependencies(ctx, preferredVersions, wantedDependencies, options) + pkgAddresses.push(...result.pkgAddresses) if (!ctx.autoInstallPeers) break - const allMissingPeers = mergePkgsDeps(newPkgAddresses.map(({ missingPeers }) => missingPeers).filter(Boolean)) - if (!Object.keys(allMissingPeers).length) break - wantedDependencies = getNonDevWantedDependencies({ dependencies: allMissingPeers }) + // all the missing peers should get installed in the root!!! + // otherwise pending nodes will not work + // even those peers should be hoisted that are not autoinstalled + if (!Object.keys(result.missingPeers).length) break + wantedDependencies = getNonDevWantedDependencies({ dependencies: result.missingPeers }) } + return pkgAddresses +} + +type ResolvedDependenciesResult = { + pkgAddresses: Array + missingPeers: Record + resolvedPeers: Record +} + +export async function resolveDependencies ( + ctx: ResolutionContext, + preferredVersions: PreferredVersions, + wantedDependencies: Array, + options: ResolvedDependenciesOptions +): Promise { + let extendedWantedDeps: ExtendedWantedDependency[] = [] + const postponedResolutionsQueue: PostponedResolutionFunction[] = [] + const pkgAddresses: PkgAddress[] = [] + extendedWantedDeps = getDepsToResolve(wantedDependencies, ctx.wantedLockfile, { + preferredDependencies: options.preferredDependencies, + prefix: ctx.prefix, + proceed: options.proceed || ctx.forceFullResolution, + registries: ctx.registries, + resolvedDependencies: options.resolvedDependencies, + }) + const newPkgAddresses = ( + await Promise.all( + extendedWantedDeps.map(async (extendedWantedDep) => resolveDependenciesOfDependency( + postponedResolutionsQueue, + ctx, + preferredVersions, + options, + extendedWantedDep + )) + ) + ).filter(Boolean) as PkgAddress[] + pkgAddresses.push(...newPkgAddresses) + // if (!ctx.autoInstallPeers) break + // all the missing peers should get installed in the root!!! + // otherwise pending nodes will not work + // even those peers should be hoisted that are not autoinstalled + // if (!Object.keys(allMissingPeers).length) break + // wantedDependencies = getNonDevWantedDependencies({ dependencies: allMissingPeers }) const newPreferredVersions = { ...preferredVersions } const newParentPkgAliases = { ...options.parentPkgAliases } for (const pkgAddress of pkgAddresses) { - newParentPkgAliases[pkgAddress.alias] = true + newParentPkgAliases[pkgAddress.alias] = pkgAddress.pkg if (pkgAddress.updated) { ctx.updatedSet.add(pkgAddress.alias) } @@ -273,9 +303,19 @@ export default async function resolveDependencies ( } newPreferredVersions[resolvedPackage.name][resolvedPackage.version] = 'version' } - await Promise.all(postponedResolutionsQueue.map(async (postponedResolution) => postponedResolution(newPreferredVersions, newParentPkgAliases))) + const results = await Promise.all(postponedResolutionsQueue.map(async (postponedResolution) => postponedResolution(newPreferredVersions, newParentPkgAliases))) + const allMissingPeers = mergePkgsDeps( + [ + ...newPkgAddresses.map(({ missingPeers }) => missingPeers).filter(Boolean), + ...results.map((r) => r.missingPeers), + ] + ) - return pkgAddresses + return { + missingPeers: allMissingPeers, + pkgAddresses, + resolvedPeers: [...pkgAddresses, ...results].reduce((acc, { resolvedPeers }) => Object.assign(acc, resolvedPeers), {}), + } } function mergePkgsDeps (pkgsDeps: Array>): Record { @@ -402,7 +442,7 @@ async function resolveChildren ( ).length ) const wantedDependencies = getNonDevWantedDependencies(parentPkg.pkg) - const children = await resolveDependencies(ctx, preferredVersions, wantedDependencies, + const result = await resolveDependencies(ctx, preferredVersions, wantedDependencies, { currentDepth: parentDepth + 1, parentPkg, @@ -416,12 +456,12 @@ async function resolveChildren ( workspacePackages, } ) - ctx.childrenByParentDepPath[parentPkg.depPath] = children.map((child) => ({ + ctx.childrenByParentDepPath[parentPkg.depPath] = result.pkgAddresses.map((child) => ({ alias: child.alias, depPath: child.depPath, })) ctx.dependenciesTree[parentPkg.nodeId] = { - children: children.reduce((chn, child) => { + children: result.pkgAddresses.reduce((chn, child) => { chn[child.alias] = child['nodeId'] ?? child.pkgId return chn }, {}), @@ -429,6 +469,10 @@ async function resolveChildren ( installable: parentPkg.installable, resolvedPackage: ctx.resolvedPackagesByDepPath[parentPkg.depPath], } + return { + missingPeers: result.missingPeers, + resolvedPeers: result.resolvedPeers, + } } function getDepsToResolve ( @@ -885,7 +929,7 @@ async function resolveDependency ( normalizedPref: options.currentDepth === 0 ? pkgResponse.body.normalizedPref : undefined, pkgId: pkgResponse.body.id, rootDir, - missingPeers: getMissingPeers(pkg, options.parentPkgAliases), + ...getMissingPeers(pkg, options.parentPkgAliases), // Next fields are actually only needed when isNew = true installable, @@ -907,14 +951,17 @@ async function getManifestFromResponse ( } } -function getMissingPeers (pkg: PackageManifest, parentPkgAliases: ParentPkgAliases): Record { +function getMissingPeers (pkg: PackageManifest, parentPkgAliases: ParentPkgAliases) { const missingPeers = {} as Record + const resolvedPeers = {} as Record for (const [peerName, peerVersion] of Object.entries(pkg.peerDependencies ?? {})) { - if (!parentPkgAliases[peerName] && !pkg.peerDependenciesMeta?.[peerName]?.optional) { + if (parentPkgAliases[peerName]) { + resolvedPeers[peerName] = parentPkgAliases[peerName] + } else if (!pkg.peerDependenciesMeta?.[peerName]?.optional) { missingPeers[peerName] = peerVersion } } - return missingPeers + return { missingPeers, resolvedPeers } } function pkgIsLeaf (pkg: PackageManifest) { diff --git a/packages/resolve-dependencies/src/resolveDependencyTree.ts b/packages/resolve-dependencies/src/resolveDependencyTree.ts index 3c10be99a6f..0335efc8c11 100644 --- a/packages/resolve-dependencies/src/resolveDependencyTree.ts +++ b/packages/resolve-dependencies/src/resolveDependencyTree.ts @@ -12,12 +12,13 @@ import { createNodeId, nodeIdContainsSequence, } from './nodeIdUtils' -import resolveDependencies, { +import { ChildrenByParentDepPath, DependenciesTree, LinkedDependency, PendingNode, PkgAddress, + resolveRootDependencies, ResolvedPackage, ResolvedPackagesByDepPath, } from './resolveDependencies' @@ -147,7 +148,7 @@ export default async function ( updateDepth: -1, workspacePackages: opts.workspacePackages, } - directDepsByImporterId[importer.id] = await resolveDependencies( + directDepsByImporterId[importer.id] = await resolveRootDependencies( resolveCtx, importer.preferredVersions ?? {}, importer.wantedDependencies, From 2f4382939dddc41181d6264107ad67a60388f7a5 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 5 Jun 2022 12:24:56 +0300 Subject: [PATCH 02/11] style: fix --- packages/resolve-dependencies/src/resolveDependencies.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/resolve-dependencies/src/resolveDependencies.ts b/packages/resolve-dependencies/src/resolveDependencies.ts index 27e347db1b4..28d7bce0a78 100644 --- a/packages/resolve-dependencies/src/resolveDependencies.ts +++ b/packages/resolve-dependencies/src/resolveDependencies.ts @@ -248,7 +248,7 @@ export async function resolveRootDependencies ( return pkgAddresses } -type ResolvedDependenciesResult = { +interface ResolvedDependenciesResult { pkgAddresses: Array missingPeers: Record resolvedPeers: Record From 65a72cae3690b317ed388fe61929deab3f3377bb Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 5 Jun 2022 13:15:49 +0300 Subject: [PATCH 03/11] fix: auto-install-peers --- packages/core/test/install/autoInstallPeers.ts | 17 +++++++++++++++++ .../src/resolveDependencies.ts | 17 +++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/packages/core/test/install/autoInstallPeers.ts b/packages/core/test/install/autoInstallPeers.ts index 217f31ecd86..048ecd17831 100644 --- a/packages/core/test/install/autoInstallPeers.ts +++ b/packages/core/test/install/autoInstallPeers.ts @@ -61,3 +61,20 @@ test('don\'t fail on linked package, when peers are auto installed', async () => const updatedManifest = await addDependenciesToPackage(pkgManifest, ['peer-b'], await testDefaults({ autoInstallPeers: true })) expect(Object.keys(updatedManifest.dependencies ?? {})).toStrictEqual(['linked', 'peer-b']) }) + +test('hoist a peer dependency in order to reuse it by other dependencies, when it satisfies them', async () => { + const project = prepareEmpty() + await addDependenciesToPackage({}, ['@pnpm/xyz-parent-parent-parent-parent', '@pnpm/xyz-parent-parent-with-xyz'], await testDefaults({ autoInstallPeers: true })) + const lockfile = await project.readLockfile() + expect(Object.keys(lockfile.packages)).toStrictEqual([ + '/@pnpm/x/1.0.0', + '/@pnpm/xyz-parent-parent-parent-parent/1.0.0_e5suan7fvtov6fikg25btc2odi', + '/@pnpm/xyz-parent-parent-parent/1.0.0_e5suan7fvtov6fikg25btc2odi', + '/@pnpm/xyz-parent-parent-with-xyz/1.0.0', + '/@pnpm/xyz-parent-parent/1.0.0_e5suan7fvtov6fikg25btc2odi', + '/@pnpm/xyz-parent/1.0.0_e5suan7fvtov6fikg25btc2odi', + '/@pnpm/xyz/1.0.0_e5suan7fvtov6fikg25btc2odi', + '/@pnpm/y/1.0.0', + '/@pnpm/z/1.0.0', + ]) +}) diff --git a/packages/resolve-dependencies/src/resolveDependencies.ts b/packages/resolve-dependencies/src/resolveDependencies.ts index 28d7bce0a78..27d555cd4f2 100644 --- a/packages/resolve-dependencies/src/resolveDependencies.ts +++ b/packages/resolve-dependencies/src/resolveDependencies.ts @@ -163,7 +163,7 @@ export type PkgAddress = { updated: boolean rootDir: string missingPeers: Record - resolvedPeers: Record + resolvedPeers: Record } & ({ isLinkedDependency: true version: string @@ -207,7 +207,7 @@ export interface ResolvedPackage { type ParentPkg = Pick -type ParentPkgAliases = Record +type ParentPkgAliases = Record interface ResolvedDependenciesOptions { currentDepth: number @@ -225,7 +225,7 @@ interface ResolvedDependenciesOptions { type PostponedResolutionFunction = (preferredVersions: PreferredVersions, parentPkgAliases: ParentPkgAliases) => Promise<{ missingPeers: Record - resolvedPeers: Record + resolvedPeers: Record }> export async function resolveRootDependencies ( @@ -242,6 +242,11 @@ export async function resolveRootDependencies ( // all the missing peers should get installed in the root!!! // otherwise pending nodes will not work // even those peers should be hoisted that are not autoinstalled + for (const [resolvedPeerName, resolvedPeerAddress] of Object.entries(result.resolvedPeers ?? {})) { + if (!result.missingPeers[resolvedPeerName]) { + pkgAddresses.push(resolvedPeerAddress) + } + } if (!Object.keys(result.missingPeers).length) break wantedDependencies = getNonDevWantedDependencies({ dependencies: result.missingPeers }) } @@ -251,7 +256,7 @@ export async function resolveRootDependencies ( interface ResolvedDependenciesResult { pkgAddresses: Array missingPeers: Record - resolvedPeers: Record + resolvedPeers: Record } export async function resolveDependencies ( @@ -292,7 +297,7 @@ export async function resolveDependencies ( const newPreferredVersions = { ...preferredVersions } const newParentPkgAliases = { ...options.parentPkgAliases } for (const pkgAddress of pkgAddresses) { - newParentPkgAliases[pkgAddress.alias] = pkgAddress.pkg + newParentPkgAliases[pkgAddress.alias] = pkgAddress if (pkgAddress.updated) { ctx.updatedSet.add(pkgAddress.alias) } @@ -953,7 +958,7 @@ async function getManifestFromResponse ( function getMissingPeers (pkg: PackageManifest, parentPkgAliases: ParentPkgAliases) { const missingPeers = {} as Record - const resolvedPeers = {} as Record + const resolvedPeers = {} as Record for (const [peerName, peerVersion] of Object.entries(pkg.peerDependencies ?? {})) { if (parentPkgAliases[peerName]) { resolvedPeers[peerName] = parentPkgAliases[peerName] From 0cfd9756e802f0a295ec26efe37708fcec87ef3f Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 5 Jun 2022 15:36:28 +0300 Subject: [PATCH 04/11] fix: auto-install-peers --- .../core/test/install/autoInstallPeers.ts | 24 +++++++++++++++++++ .../src/resolveDependencies.ts | 22 +++++++++++++---- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/packages/core/test/install/autoInstallPeers.ts b/packages/core/test/install/autoInstallPeers.ts index 048ecd17831..6f7c2e1a8f5 100644 --- a/packages/core/test/install/autoInstallPeers.ts +++ b/packages/core/test/install/autoInstallPeers.ts @@ -78,3 +78,27 @@ test('hoist a peer dependency in order to reuse it by other dependencies, when i '/@pnpm/z/1.0.0', ]) }) + +test('don\'t hoist a peer dependency when there is a root dependency by that name', async () => { + const project = prepareEmpty() + await addDependenciesToPackage({}, [ + '@pnpm/xyz-parent-parent-parent-parent', + '@pnpm/xyz-parent-parent-with-xyz', + '@pnpm/x@npm:peer-a@1.0.0', + ], await testDefaults({ autoInstallPeers: true })) + const lockfile = await project.readLockfile() + expect(Object.keys(lockfile.packages)).toStrictEqual([ + '/@pnpm/x/1.0.0', + '/@pnpm/xyz-parent-parent-parent-parent/1.0.0_dlsfm7gqtoviaae3daicurxwra', + '/@pnpm/xyz-parent-parent-parent/1.0.0_dlsfm7gqtoviaae3daicurxwra', + '/@pnpm/xyz-parent-parent-with-xyz/1.0.0', + '/@pnpm/xyz-parent-parent/1.0.0_dlsfm7gqtoviaae3daicurxwra', + '/@pnpm/xyz-parent/1.0.0_dlsfm7gqtoviaae3daicurxwra', + '/@pnpm/xyz-parent/1.0.0_e5suan7fvtov6fikg25btc2odi', + '/@pnpm/xyz/1.0.0_dlsfm7gqtoviaae3daicurxwra', + '/@pnpm/xyz/1.0.0_e5suan7fvtov6fikg25btc2odi', + '/@pnpm/y/1.0.0', + '/@pnpm/z/1.0.0', + '/peer-a/1.0.0', + ]) +}) diff --git a/packages/resolve-dependencies/src/resolveDependencies.ts b/packages/resolve-dependencies/src/resolveDependencies.ts index 27d555cd4f2..46cd823ea0b 100644 --- a/packages/resolve-dependencies/src/resolveDependencies.ts +++ b/packages/resolve-dependencies/src/resolveDependencies.ts @@ -207,7 +207,7 @@ export interface ResolvedPackage { type ParentPkg = Pick -type ParentPkgAliases = Record +type ParentPkgAliases = Record interface ResolvedDependenciesOptions { currentDepth: number @@ -235,8 +235,18 @@ export async function resolveRootDependencies ( options: ResolvedDependenciesOptions ): Promise> { const pkgAddresses: Array = [] + const parentPkgAliases: ParentPkgAliases = {} + for (const wantedDep of wantedDependencies) { + if (wantedDep.alias) { + parentPkgAliases[wantedDep.alias] = true + } + } + console.log(parentPkgAliases) while (true) { - const result = await resolveDependencies(ctx, preferredVersions, wantedDependencies, options) + const result = await resolveDependencies(ctx, preferredVersions, wantedDependencies, { + ...options, + parentPkgAliases, + }) pkgAddresses.push(...result.pkgAddresses) if (!ctx.autoInstallPeers) break // all the missing peers should get installed in the root!!! @@ -297,7 +307,9 @@ export async function resolveDependencies ( const newPreferredVersions = { ...preferredVersions } const newParentPkgAliases = { ...options.parentPkgAliases } for (const pkgAddress of pkgAddresses) { - newParentPkgAliases[pkgAddress.alias] = pkgAddress + if (newParentPkgAliases[pkgAddress.alias] !== true) { + newParentPkgAliases[pkgAddress.alias] = pkgAddress + } if (pkgAddress.updated) { ctx.updatedSet.add(pkgAddress.alias) } @@ -961,7 +973,9 @@ function getMissingPeers (pkg: PackageManifest, parentPkgAliases: ParentPkgAlias const resolvedPeers = {} as Record for (const [peerName, peerVersion] of Object.entries(pkg.peerDependencies ?? {})) { if (parentPkgAliases[peerName]) { - resolvedPeers[peerName] = parentPkgAliases[peerName] + if (parentPkgAliases[peerName] !== true) { + resolvedPeers[peerName] = parentPkgAliases[peerName] as PkgAddress + } } else if (!pkg.peerDependenciesMeta?.[peerName]?.optional) { missingPeers[peerName] = peerVersion } From 7b9e2c752cbc0f0f2a7e91356b8ee4800dd8dfd9 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 5 Jun 2022 17:21:04 +0300 Subject: [PATCH 05/11] fix: auto-install-peers --- packages/core/test/install/autoInstallPeers.ts | 14 ++++++++------ .../src/resolveDependencies.ts | 5 ++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/core/test/install/autoInstallPeers.ts b/packages/core/test/install/autoInstallPeers.ts index 6f7c2e1a8f5..8a2e4278167 100644 --- a/packages/core/test/install/autoInstallPeers.ts +++ b/packages/core/test/install/autoInstallPeers.ts @@ -1,6 +1,6 @@ import { addDependenciesToPackage } from '@pnpm/core' import { prepareEmpty, preparePackages } from '@pnpm/prepare' -import { addDistTag } from '@pnpm/registry-mock' +import { addDistTag, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' import { testDefaults } from '../utils' test('auto install non-optional peer dependencies', async () => { @@ -85,19 +85,21 @@ test('don\'t hoist a peer dependency when there is a root dependency by that nam '@pnpm/xyz-parent-parent-parent-parent', '@pnpm/xyz-parent-parent-with-xyz', '@pnpm/x@npm:peer-a@1.0.0', + `http://localhost:${REGISTRY_MOCK_PORT}/@pnpm/y/-/y-2.0.0.tgz`, ], await testDefaults({ autoInstallPeers: true })) const lockfile = await project.readLockfile() expect(Object.keys(lockfile.packages)).toStrictEqual([ '/@pnpm/x/1.0.0', - '/@pnpm/xyz-parent-parent-parent-parent/1.0.0_dlsfm7gqtoviaae3daicurxwra', - '/@pnpm/xyz-parent-parent-parent/1.0.0_dlsfm7gqtoviaae3daicurxwra', + '/@pnpm/xyz-parent-parent-parent-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li', + '/@pnpm/xyz-parent-parent-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li', '/@pnpm/xyz-parent-parent-with-xyz/1.0.0', - '/@pnpm/xyz-parent-parent/1.0.0_dlsfm7gqtoviaae3daicurxwra', - '/@pnpm/xyz-parent/1.0.0_dlsfm7gqtoviaae3daicurxwra', + '/@pnpm/xyz-parent-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li', + '/@pnpm/xyz-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li', '/@pnpm/xyz-parent/1.0.0_e5suan7fvtov6fikg25btc2odi', - '/@pnpm/xyz/1.0.0_dlsfm7gqtoviaae3daicurxwra', + '/@pnpm/xyz/1.0.0_c3hmehglzcfufab5hu6m6d76li', '/@pnpm/xyz/1.0.0_e5suan7fvtov6fikg25btc2odi', '/@pnpm/y/1.0.0', + '/@pnpm/y/2.0.0', '/@pnpm/z/1.0.0', '/peer-a/1.0.0', ]) diff --git a/packages/resolve-dependencies/src/resolveDependencies.ts b/packages/resolve-dependencies/src/resolveDependencies.ts index 46cd823ea0b..65d1e6bf078 100644 --- a/packages/resolve-dependencies/src/resolveDependencies.ts +++ b/packages/resolve-dependencies/src/resolveDependencies.ts @@ -249,11 +249,14 @@ export async function resolveRootDependencies ( }) pkgAddresses.push(...result.pkgAddresses) if (!ctx.autoInstallPeers) break + for (const pkgAddress of result.pkgAddresses) { + parentPkgAliases[pkgAddress.alias] = true + } // all the missing peers should get installed in the root!!! // otherwise pending nodes will not work // even those peers should be hoisted that are not autoinstalled for (const [resolvedPeerName, resolvedPeerAddress] of Object.entries(result.resolvedPeers ?? {})) { - if (!result.missingPeers[resolvedPeerName]) { + if (!result.missingPeers[resolvedPeerName] && !parentPkgAliases[resolvedPeerName]) { pkgAddresses.push(resolvedPeerAddress) } } From 3fbe681becb4b4206bc7455cccdc6d9e1efcc9d1 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 5 Jun 2022 17:28:47 +0300 Subject: [PATCH 06/11] fix: update @pnpm/registry-mock --- package.json | 2 +- packages/core/package.json | 2 +- packages/headless/package.json | 2 +- packages/package-requester/package.json | 2 +- .../plugin-commands-installation/package.json | 2 +- packages/plugin-commands-listing/package.json | 2 +- .../plugin-commands-outdated/package.json | 2 +- .../plugin-commands-publishing/package.json | 2 +- packages/plugin-commands-rebuild/package.json | 2 +- .../package.json | 2 +- packages/plugin-commands-store/package.json | 2 +- packages/pnpm/package.json | 2 +- .../src/resolveDependencies.ts | 1 - pnpm-lock.yaml | 127 +++++++++++++----- privatePackages/assert-project/package.json | 2 +- privatePackages/assert-store/package.json | 2 +- 16 files changed, 108 insertions(+), 48 deletions(-) diff --git a/package.json b/package.json index f5eeed2cea1..e80f8812909 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@commitlint/prompt-cli": "^16.0.0", "@pnpm/eslint-config": "workspace:*", "@pnpm/meta-updater": "0.0.6", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "@pnpm/tsconfig": "workspace:*", "@types/jest": "^27.4.0", "@types/node": "^14.17.32", diff --git a/packages/core/package.json b/packages/core/package.json index 1fb9f82c224..8dae8647b4e 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -74,7 +74,7 @@ "@pnpm/logger": "^4.0.0", "@pnpm/package-store": "workspace:13.0.6", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "@pnpm/store-path": "workspace:6.0.0", "@pnpm/test-fixtures": "workspace:*", "@types/fs-extra": "^9.0.5", diff --git a/packages/headless/package.json b/packages/headless/package.json index cd7c82973c8..6ba5bf54ba6 100644 --- a/packages/headless/package.json +++ b/packages/headless/package.json @@ -22,7 +22,7 @@ "@pnpm/package-store": "workspace:13.0.6", "@pnpm/prepare": "workspace:*", "@pnpm/read-projects-context": "workspace:6.0.3", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "@pnpm/store-path": "workspace:6.0.0", "@pnpm/test-fixtures": "workspace:*", "@types/fs-extra": "^9.0.5", diff --git a/packages/package-requester/package.json b/packages/package-requester/package.json index 30ce8962e65..ec0b5ac5613 100644 --- a/packages/package-requester/package.json +++ b/packages/package-requester/package.json @@ -65,7 +65,7 @@ "@pnpm/create-cafs-store": "workspace:1.0.2", "@pnpm/logger": "^4.0.0", "@pnpm/package-requester": "workspace:18.0.6", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "@pnpm/test-fixtures": "workspace:*", "@types/normalize-path": "^3.0.0", "@types/ramda": "0.27.39", diff --git a/packages/plugin-commands-installation/package.json b/packages/plugin-commands-installation/package.json index e798b067f85..c1fc46c21eb 100644 --- a/packages/plugin-commands-installation/package.json +++ b/packages/plugin-commands-installation/package.json @@ -39,7 +39,7 @@ "@pnpm/modules-yaml": "workspace:10.0.1", "@pnpm/plugin-commands-installation": "workspace:10.0.11", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "@pnpm/test-fixtures": "workspace:*", "@types/is-ci": "^3.0.0", "@types/proxyquire": "^1.3.28", diff --git a/packages/plugin-commands-listing/package.json b/packages/plugin-commands-listing/package.json index 439561ded59..2776718da16 100644 --- a/packages/plugin-commands-listing/package.json +++ b/packages/plugin-commands-listing/package.json @@ -38,7 +38,7 @@ "@pnpm/plugin-commands-installation": "workspace:10.0.11", "@pnpm/plugin-commands-listing": "workspace:5.0.10", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "@types/ramda": "0.27.39", "execa": "npm:safe-execa@^0.1.1", "strip-ansi": "^6.0.0", diff --git a/packages/plugin-commands-outdated/package.json b/packages/plugin-commands-outdated/package.json index 05ed4eb9ce8..3635a800045 100644 --- a/packages/plugin-commands-outdated/package.json +++ b/packages/plugin-commands-outdated/package.json @@ -38,7 +38,7 @@ "@pnpm/plugin-commands-installation": "workspace:10.0.11", "@pnpm/plugin-commands-outdated": "workspace:6.0.10", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "@types/lru-cache": "^5.1.0", "@types/ramda": "0.27.39", "@types/wrap-ansi": "^3.0.0", diff --git a/packages/plugin-commands-publishing/package.json b/packages/plugin-commands-publishing/package.json index 190b26dab81..0648e8c3cda 100644 --- a/packages/plugin-commands-publishing/package.json +++ b/packages/plugin-commands-publishing/package.json @@ -39,7 +39,7 @@ "@pnpm/logger": "^4.0.0", "@pnpm/plugin-commands-publishing": "workspace:5.0.11", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "@types/cross-spawn": "^6.0.2", "@types/is-ci": "^3.0.0", "@types/is-windows": "^1.0.0", diff --git a/packages/plugin-commands-rebuild/package.json b/packages/plugin-commands-rebuild/package.json index eaad6c2433d..774ed3960cf 100644 --- a/packages/plugin-commands-rebuild/package.json +++ b/packages/plugin-commands-rebuild/package.json @@ -37,7 +37,7 @@ "@pnpm/logger": "^4.0.0", "@pnpm/plugin-commands-rebuild": "workspace:6.1.9", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "@pnpm/test-fixtures": "workspace:*", "@types/ramda": "0.27.39", "@types/semver": "^7.3.4", diff --git a/packages/plugin-commands-script-runners/package.json b/packages/plugin-commands-script-runners/package.json index 572040d048e..24677e05b7d 100644 --- a/packages/plugin-commands-script-runners/package.json +++ b/packages/plugin-commands-script-runners/package.json @@ -38,7 +38,7 @@ "@pnpm/logger": "^4.0.0", "@pnpm/plugin-commands-script-runners": "workspace:5.0.12", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "@types/is-windows": "^1.0.0", "@types/ramda": "0.27.39", "is-windows": "^1.0.2", diff --git a/packages/plugin-commands-store/package.json b/packages/plugin-commands-store/package.json index 24d01064dcd..ce70befa1e4 100644 --- a/packages/plugin-commands-store/package.json +++ b/packages/plugin-commands-store/package.json @@ -38,7 +38,7 @@ "@pnpm/logger": "^4.0.0", "@pnpm/plugin-commands-store": "workspace:5.1.9", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "@types/archy": "0.0.31", "@types/ramda": "0.27.39", "@types/ssri": "^7.1.0", diff --git a/packages/pnpm/package.json b/packages/pnpm/package.json index c845aede381..6566a9e0a14 100644 --- a/packages/pnpm/package.json +++ b/packages/pnpm/package.json @@ -55,7 +55,7 @@ "@pnpm/prepare": "workspace:*", "@pnpm/read-package-json": "workspace:6.0.2", "@pnpm/read-project-manifest": "workspace:3.0.2", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "@pnpm/run-npm": "workspace:4.0.1", "@pnpm/tabtab": "^0.1.2", "@pnpm/types": "workspace:8.0.1", diff --git a/packages/resolve-dependencies/src/resolveDependencies.ts b/packages/resolve-dependencies/src/resolveDependencies.ts index 65d1e6bf078..fdced774c05 100644 --- a/packages/resolve-dependencies/src/resolveDependencies.ts +++ b/packages/resolve-dependencies/src/resolveDependencies.ts @@ -241,7 +241,6 @@ export async function resolveRootDependencies ( parentPkgAliases[wantedDep.alias] = true } } - console.log(parentPkgAliases) while (true) { const result = await resolveDependencies(ctx, preferredVersions, wantedDependencies, { ...options, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5dced384c9e..cd9a1c9e075 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,7 +41,7 @@ importers: '@commitlint/prompt-cli': ^16.0.0 '@pnpm/eslint-config': workspace:* '@pnpm/meta-updater': 0.0.6 - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/tsconfig': workspace:* '@types/jest': ^27.4.0 '@types/node': ^14.17.32 @@ -72,7 +72,7 @@ importers: '@commitlint/prompt-cli': 16.3.0 '@pnpm/eslint-config': link:utils/eslint-config '@pnpm/meta-updater': 0.0.6 - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/tsconfig': link:utils/tsconfig '@types/jest': 27.5.1 '@types/node': 14.18.20 @@ -426,7 +426,7 @@ importers: '@pnpm/read-modules-dir': workspace:4.0.0 '@pnpm/read-package-json': workspace:6.0.2 '@pnpm/read-project-manifest': workspace:3.0.2 - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/remove-bins': workspace:3.0.2 '@pnpm/resolve-dependencies': workspace:27.1.3 '@pnpm/resolver-base': workspace:9.0.1 @@ -531,7 +531,7 @@ importers: '@pnpm/logger': 4.0.0 '@pnpm/package-store': link:../package-store '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/store-path': link:../store-path '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/fs-extra': 9.0.13 @@ -1117,7 +1117,7 @@ importers: '@pnpm/read-project-manifest': workspace:3.0.2 '@pnpm/read-projects-context': workspace:6.0.3 '@pnpm/real-hoist': workspace:0.2.3 - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/store-controller-types': workspace:13.0.2 '@pnpm/store-path': workspace:6.0.0 '@pnpm/symlink-dependency': workspace:5.0.1 @@ -1178,7 +1178,7 @@ importers: '@pnpm/package-store': link:../package-store '@pnpm/prepare': link:../../privatePackages/prepare '@pnpm/read-projects-context': link:../read-projects-context - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/store-path': link:../store-path '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/fs-extra': 9.0.13 @@ -1871,7 +1871,7 @@ importers: '@pnpm/package-is-installable': workspace:6.0.3 '@pnpm/package-requester': workspace:18.0.6 '@pnpm/read-package-json': workspace:6.0.2 - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/resolver-base': workspace:9.0.1 '@pnpm/store-controller-types': workspace:13.0.2 '@pnpm/test-fixtures': workspace:* @@ -1922,7 +1922,7 @@ importers: '@pnpm/create-cafs-store': link:../create-cafs-store '@pnpm/logger': 4.0.0 '@pnpm/package-requester': 'link:' - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/normalize-path': 3.0.0 '@types/ramda': 0.27.39 @@ -2194,7 +2194,7 @@ importers: '@pnpm/pnpmfile': workspace:2.0.2 '@pnpm/prepare': workspace:* '@pnpm/read-project-manifest': workspace:3.0.2 - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/resolver-base': workspace:9.0.1 '@pnpm/semver-diff': ^1.0.2 '@pnpm/sort-packages': workspace:3.0.2 @@ -2291,7 +2291,7 @@ importers: '@pnpm/modules-yaml': link:../modules-yaml '@pnpm/plugin-commands-installation': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/is-ci': 3.0.0 '@types/proxyquire': 1.3.28 @@ -2322,7 +2322,7 @@ importers: '@pnpm/plugin-commands-installation': workspace:10.0.11 '@pnpm/plugin-commands-listing': workspace:5.0.10 '@pnpm/prepare': workspace:* - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/types': workspace:8.0.1 '@types/ramda': 0.27.39 execa: npm:safe-execa@^0.1.1 @@ -2346,7 +2346,7 @@ importers: '@pnpm/plugin-commands-installation': link:../plugin-commands-installation '@pnpm/plugin-commands-listing': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@types/ramda': 0.27.39 execa: /safe-execa/0.1.1 strip-ansi: 6.0.1 @@ -2370,7 +2370,7 @@ importers: '@pnpm/plugin-commands-installation': workspace:10.0.11 '@pnpm/plugin-commands-outdated': workspace:6.0.10 '@pnpm/prepare': workspace:* - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/semver-diff': ^1.0.2 '@pnpm/store-path': workspace:6.0.0 '@pnpm/types': workspace:8.0.1 @@ -2413,7 +2413,7 @@ importers: '@pnpm/plugin-commands-installation': link:../plugin-commands-installation '@pnpm/plugin-commands-outdated': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@types/lru-cache': 5.1.1 '@types/ramda': 0.27.39 '@types/wrap-ansi': 3.0.0 @@ -2433,7 +2433,7 @@ importers: '@pnpm/pick-registry-for-package': workspace:3.0.1 '@pnpm/plugin-commands-publishing': workspace:5.0.11 '@pnpm/prepare': workspace:* - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/resolver-base': workspace:9.0.1 '@pnpm/run-npm': workspace:4.0.1 '@pnpm/sort-packages': workspace:3.0.2 @@ -2496,7 +2496,7 @@ importers: '@pnpm/logger': 4.0.0 '@pnpm/plugin-commands-publishing': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@types/cross-spawn': 6.0.2 '@types/is-ci': 3.0.0 '@types/is-windows': 1.0.0 @@ -2534,7 +2534,7 @@ importers: '@pnpm/normalize-registries': workspace:3.0.1 '@pnpm/plugin-commands-rebuild': workspace:6.1.9 '@pnpm/prepare': workspace:* - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/sort-packages': workspace:3.0.2 '@pnpm/store-connection-manager': workspace:4.1.8 '@pnpm/store-controller-types': workspace:13.0.2 @@ -2593,7 +2593,7 @@ importers: '@pnpm/logger': 4.0.0 '@pnpm/plugin-commands-rebuild': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/ramda': 0.27.39 '@types/semver': 7.3.9 @@ -2619,7 +2619,7 @@ importers: '@pnpm/prepare': workspace:* '@pnpm/read-package-json': workspace:6.0.2 '@pnpm/read-project-manifest': workspace:3.0.2 - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/sort-packages': workspace:3.0.2 '@pnpm/store-path': workspace:6.0.0 '@pnpm/types': workspace:8.0.1 @@ -2662,7 +2662,7 @@ importers: '@pnpm/logger': 4.0.0 '@pnpm/plugin-commands-script-runners': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@types/is-windows': 1.0.0 '@types/ramda': 0.27.39 is-windows: 1.0.2 @@ -2752,7 +2752,7 @@ importers: '@pnpm/pick-registry-for-package': workspace:3.0.1 '@pnpm/plugin-commands-store': workspace:5.1.9 '@pnpm/prepare': workspace:* - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/store-connection-manager': workspace:4.1.8 '@pnpm/store-controller-types': workspace:13.0.2 '@pnpm/store-path': workspace:6.0.0 @@ -2799,7 +2799,7 @@ importers: '@pnpm/logger': 4.0.0 '@pnpm/plugin-commands-store': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@types/archy': 0.0.31 '@types/ramda': 0.27.39 '@types/ssri': 7.1.1 @@ -2847,7 +2847,7 @@ importers: '@pnpm/prepare': workspace:* '@pnpm/read-package-json': workspace:6.0.2 '@pnpm/read-project-manifest': workspace:3.0.2 - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/run-npm': workspace:4.0.1 '@pnpm/tabtab': ^0.1.2 '@pnpm/types': workspace:8.0.1 @@ -2935,7 +2935,7 @@ importers: '@pnpm/prepare': link:../../privatePackages/prepare '@pnpm/read-package-json': link:../read-package-json '@pnpm/read-project-manifest': link:../read-project-manifest - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/run-npm': link:../run-npm '@pnpm/tabtab': 0.1.2 '@pnpm/types': link:../types @@ -3533,7 +3533,7 @@ importers: '@pnpm/constants': workspace:6.1.0 '@pnpm/lockfile-types': workspace:4.0.1 '@pnpm/modules-yaml': workspace:10.0.1 - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/types': workspace:8.0.1 '@types/is-windows': ^1.0.0 '@types/isexe': 2.0.0 @@ -3548,7 +3548,7 @@ importers: '@pnpm/constants': link:../../packages/constants '@pnpm/lockfile-types': link:../../packages/lockfile-types '@pnpm/modules-yaml': link:../../packages/modules-yaml - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 '@pnpm/types': link:../../packages/types is-windows: 1.0.2 isexe: 2.0.0 @@ -3565,11 +3565,11 @@ importers: specifiers: '@pnpm/assert-store': workspace:* '@pnpm/cafs': workspace:4.0.3 - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 path-exists: ^4.0.0 dependencies: '@pnpm/cafs': link:../../packages/cafs - '@pnpm/registry-mock': 2.17.0 + '@pnpm/registry-mock': 2.18.0 path-exists: 4.0.0 devDependencies: '@pnpm/assert-store': 'link:' @@ -5183,8 +5183,8 @@ packages: strip-bom: 4.0.0 dev: true - /@pnpm/registry-mock/2.17.0: - resolution: {integrity: sha512-vZuWSJaixugxz0Y39VIEKeyYm69TG3/8qXkgMXjLjRWtE/4EezKKGfiAEhuJasSdvVoYUQWY2Ng0nEkWihTN9w==} + /@pnpm/registry-mock/2.18.0: + resolution: {integrity: sha512-hj5LwD6tGsUjA9l++2ucFeAb4nhYryvK1i7+h3/a7IwkqvJKKSaJYb+wkYuAzIYOCjYK9BYQNAfBz1Rkq03Ayw==} engines: {node: '>=10.13'} hasBin: true dependencies: @@ -5194,7 +5194,7 @@ packages: read-yaml-file: 2.1.0 rimraf: 3.0.2 tempy: 1.0.1 - verdaccio: 5.10.3 + verdaccio: 5.11.0 write-yaml-file: 4.2.0 transitivePeerDependencies: - bufferutil @@ -5366,7 +5366,7 @@ packages: /@types/byline/4.2.33: resolution: {integrity: sha512-LJYez7wrWcJQQDknqZtrZuExMGP0IXmPl1rOOGDqLbu+H7UNNRfKNuSxCBcQMLH1EfjeWidLedC/hCc5dDfBog==} dependencies: - '@types/node': 17.0.38 + '@types/node': 17.0.40 dev: true /@types/cacheable-request/6.0.2: @@ -5540,6 +5540,10 @@ packages: /@types/node/17.0.38: resolution: {integrity: sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g==} + /@types/node/17.0.40: + resolution: {integrity: sha512-UXdBxNGqTMtm7hCwh9HtncFVLrXoqA3oJW30j6XWp5BH/wu3mVeaxo7cq5benFdBw34HB3XDT2TRPI7rXZ+mDg==} + dev: true + /@types/normalize-package-data/2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} dev: true @@ -11735,6 +11739,7 @@ packages: resolution: {integrity: sha512-olTJRgUtAb/hOXG0E93wZDs5YiJlgbXxTwQAFHyNlRsXQnYzUaF2aGgujZbw+hR8aF4ZG/rST57bWMWD16jr9w==} engines: {node: '>= 10.12.0'} hasBin: true + requiresBuild: true dependencies: env-paths: 2.2.1 glob: 7.2.3 @@ -11876,6 +11881,7 @@ packages: /npmlog/4.1.2: resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==} + requiresBuild: true dependencies: are-we-there-yet: 1.1.7 console-control-strings: 1.1.0 @@ -14776,6 +14782,61 @@ packages: - encoding - supports-color - utf-8-validate + dev: true + + /verdaccio/5.11.0: + resolution: {integrity: sha512-wKQ4dVBuUm+sHTakxlGPyOQSvJtpkzk7FTUKfGP92LV8AdQSyNflXomiP3KK7WfoG6Er18+aC+sDhosTs02l6g==} + engines: {node: '>=12', npm: '>=6'} + hasBin: true + dependencies: + '@verdaccio/commons-api': 10.2.0 + '@verdaccio/local-storage': 10.2.1 + '@verdaccio/readme': 10.3.4 + '@verdaccio/streams': 10.2.0 + '@verdaccio/ui-theme': 6.0.0-6-next.24 + async: 3.2.3 + body-parser: 1.20.0 + clipanion: 3.2.0-rc.6 + compression: 1.7.4 + cookies: 0.8.0 + cors: 2.8.5 + dayjs: 1.11.2 + debug: 4.3.4 + envinfo: 7.8.1 + eslint-import-resolver-node: 0.3.6 + express: 4.18.1 + express-rate-limit: 5.5.1 + fast-safe-stringify: 2.1.1 + handlebars: 4.7.7 + http-errors: 1.8.1 + js-yaml: /@zkochan/js-yaml/0.0.6 + JSONStream: 1.3.5 + jsonwebtoken: 8.5.1 + kleur: 4.1.4 + lodash: 4.17.21 + lru-cache: 7.9.0 + lunr-mutable-indexes: 2.3.2 + marked: 4.0.16 + memoizee: 0.4.15 + mime: 3.0.0 + minimatch: 5.0.1 + mkdirp: 1.0.4 + mv: 2.1.1 + pino: 6.14.0 + pkginfo: 0.4.1 + prettier-bytes: 1.0.4 + pretty-ms: 7.0.1 + request: 2.88.0 + semver: 7.3.7 + validator: 13.7.0 + verdaccio-audit: 10.2.2 + verdaccio-htpasswd: 10.3.0 + transitivePeerDependencies: + - bufferutil + - canvas + - encoding + - supports-color + - utf-8-validate /verror/1.10.0: resolution: {integrity: sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=} @@ -14963,7 +15024,7 @@ packages: /wide-align/1.1.5: resolution: {integrity: sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==} dependencies: - string-width: 4.2.3 + string-width: 1.0.2 /widest-line/3.1.0: resolution: {integrity: sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==} diff --git a/privatePackages/assert-project/package.json b/privatePackages/assert-project/package.json index eddcef8a3eb..e0f11184d9f 100644 --- a/privatePackages/assert-project/package.json +++ b/privatePackages/assert-project/package.json @@ -44,7 +44,7 @@ "@pnpm/constants": "workspace:6.1.0", "@pnpm/lockfile-types": "workspace:4.0.1", "@pnpm/modules-yaml": "workspace:10.0.1", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "@pnpm/types": "workspace:8.0.1", "is-windows": "^1.0.2", "isexe": "2.0.0", diff --git a/privatePackages/assert-store/package.json b/privatePackages/assert-store/package.json index f195de6db45..900a3cdc3df 100644 --- a/privatePackages/assert-store/package.json +++ b/privatePackages/assert-store/package.json @@ -41,7 +41,7 @@ }, "dependencies": { "@pnpm/cafs": "workspace:4.0.3", - "@pnpm/registry-mock": "2.17.0", + "@pnpm/registry-mock": "2.18.0", "path-exists": "^4.0.0" }, "devDependencies": { From 3c939accbe4281898a15916ebff4109e68561a3e Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 5 Jun 2022 22:57:21 +0300 Subject: [PATCH 07/11] fix: auto-install-peers --- .../core/test/install/autoInstallPeers.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/core/test/install/autoInstallPeers.ts b/packages/core/test/install/autoInstallPeers.ts index 8a2e4278167..2f06740f78c 100644 --- a/packages/core/test/install/autoInstallPeers.ts +++ b/packages/core/test/install/autoInstallPeers.ts @@ -104,3 +104,23 @@ test('don\'t hoist a peer dependency when there is a root dependency by that nam '/peer-a/1.0.0', ]) }) + +test('don\'t auto-install a peer dependency, when that dependency is in the root', async () => { + const project = prepareEmpty() + await addDependenciesToPackage({}, [ + '@pnpm/xyz-parent-parent-parent-parent', + '@pnpm/x@npm:peer-a@1.0.0', + `http://localhost:${REGISTRY_MOCK_PORT}/@pnpm/y/-/y-2.0.0.tgz`, + ], await testDefaults({ autoInstallPeers: true })) + const lockfile = await project.readLockfile() + expect(Object.keys(lockfile.packages)).toStrictEqual([ + '/@pnpm/xyz-parent-parent-parent-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li', + '/@pnpm/xyz-parent-parent-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li', + '/@pnpm/xyz-parent-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li', + '/@pnpm/xyz-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li', + '/@pnpm/xyz/1.0.0_c3hmehglzcfufab5hu6m6d76li', + '/@pnpm/y/2.0.0', + '/@pnpm/z/1.0.0', + '/peer-a/1.0.0', + ]) +}) From c4b0e3d923f334cd8a4a9eb239eb9b6336e44e2e Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 5 Jun 2022 23:23:41 +0300 Subject: [PATCH 08/11] refactor: resolve-deps --- package.json | 3 +- .../src/resolveDependencies.ts | 40 ++++++++----------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index e80f8812909..56db43b8ccc 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "preinstall": "npx only-allow pnpm", "prepare": "husky install", "pretest": "pnpm run compile-only && pnpm --dir=fixtures run prepareFixtures", - "lint": "pnpm lint:meta && syncpack list-mismatches && eslint **/src/**/*.ts **/test/**/*.ts", + "lint": "pnpm lint:meta && syncpack list-mismatches && pnpm run lint:ts", + "lint:ts": "eslint **/src/**/*.ts **/test/**/*.ts", "test-main": "pnpm pretest && pnpm lint --quiet && run-p -r verdaccio test-pkgs-main", "remove-temp-dir": "shx rm -rf ../pnpm_tmp", "test-pkgs-main": "pnpm remove-temp-dir && cross-env PNPM_REGISTRY_MOCK_UPLINK=http://localhost:7348 pnpm --filter=./packages/** --filter=./privatePackages/** run --no-sort --workspace-concurrency=2 _test", diff --git a/packages/resolve-dependencies/src/resolveDependencies.ts b/packages/resolve-dependencies/src/resolveDependencies.ts index fdced774c05..e694f97ea87 100644 --- a/packages/resolve-dependencies/src/resolveDependencies.ts +++ b/packages/resolve-dependencies/src/resolveDependencies.ts @@ -148,6 +148,10 @@ export interface ResolutionContext { updateMatching?: (pkgName: string) => boolean } +export type MissingPeers = Record + +export type ResolvedPeers = Record + export type PkgAddress = { alias: string depIsLinked: boolean @@ -162,8 +166,8 @@ export type PkgAddress = { version?: string updated: boolean rootDir: string - missingPeers: Record - resolvedPeers: Record + missingPeers: MissingPeers + resolvedPeers: ResolvedPeers } & ({ isLinkedDependency: true version: string @@ -224,8 +228,8 @@ interface ResolvedDependenciesOptions { } type PostponedResolutionFunction = (preferredVersions: PreferredVersions, parentPkgAliases: ParentPkgAliases) => Promise<{ - missingPeers: Record - resolvedPeers: Record + missingPeers: MissingPeers + resolvedPeers: ResolvedPeers }> export async function resolveRootDependencies ( @@ -251,8 +255,8 @@ export async function resolveRootDependencies ( for (const pkgAddress of result.pkgAddresses) { parentPkgAliases[pkgAddress.alias] = true } - // all the missing peers should get installed in the root!!! - // otherwise pending nodes will not work + // All the missing peers should get installed in the root. + // Otherwise, pending nodes will not work. // even those peers should be hoisted that are not autoinstalled for (const [resolvedPeerName, resolvedPeerAddress] of Object.entries(result.resolvedPeers ?? {})) { if (!result.missingPeers[resolvedPeerName] && !parentPkgAliases[resolvedPeerName]) { @@ -267,8 +271,8 @@ export async function resolveRootDependencies ( interface ResolvedDependenciesResult { pkgAddresses: Array - missingPeers: Record - resolvedPeers: Record + missingPeers: MissingPeers + resolvedPeers: ResolvedPeers } export async function resolveDependencies ( @@ -277,17 +281,15 @@ export async function resolveDependencies ( wantedDependencies: Array, options: ResolvedDependenciesOptions ): Promise { - let extendedWantedDeps: ExtendedWantedDependency[] = [] const postponedResolutionsQueue: PostponedResolutionFunction[] = [] - const pkgAddresses: PkgAddress[] = [] - extendedWantedDeps = getDepsToResolve(wantedDependencies, ctx.wantedLockfile, { + const extendedWantedDeps = getDepsToResolve(wantedDependencies, ctx.wantedLockfile, { preferredDependencies: options.preferredDependencies, prefix: ctx.prefix, proceed: options.proceed || ctx.forceFullResolution, registries: ctx.registries, resolvedDependencies: options.resolvedDependencies, }) - const newPkgAddresses = ( + const pkgAddresses = ( await Promise.all( extendedWantedDeps.map(async (extendedWantedDep) => resolveDependenciesOfDependency( postponedResolutionsQueue, @@ -298,14 +300,6 @@ export async function resolveDependencies ( )) ) ).filter(Boolean) as PkgAddress[] - pkgAddresses.push(...newPkgAddresses) - // if (!ctx.autoInstallPeers) break - // all the missing peers should get installed in the root!!! - // otherwise pending nodes will not work - // even those peers should be hoisted that are not autoinstalled - // if (!Object.keys(allMissingPeers).length) break - // wantedDependencies = getNonDevWantedDependencies({ dependencies: allMissingPeers }) - const newPreferredVersions = { ...preferredVersions } const newParentPkgAliases = { ...options.parentPkgAliases } for (const pkgAddress of pkgAddresses) { @@ -325,7 +319,7 @@ export async function resolveDependencies ( const results = await Promise.all(postponedResolutionsQueue.map(async (postponedResolution) => postponedResolution(newPreferredVersions, newParentPkgAliases))) const allMissingPeers = mergePkgsDeps( [ - ...newPkgAddresses.map(({ missingPeers }) => missingPeers).filter(Boolean), + ...pkgAddresses.map(({ missingPeers }) => missingPeers).filter(Boolean), ...results.map((r) => r.missingPeers), ] ) @@ -971,8 +965,8 @@ async function getManifestFromResponse ( } function getMissingPeers (pkg: PackageManifest, parentPkgAliases: ParentPkgAliases) { - const missingPeers = {} as Record - const resolvedPeers = {} as Record + const missingPeers = {} as MissingPeers + const resolvedPeers = {} as ResolvedPeers for (const [peerName, peerVersion] of Object.entries(pkg.peerDependencies ?? {})) { if (parentPkgAliases[peerName]) { if (parentPkgAliases[peerName] !== true) { From 1de2e3ddeb418fe6c30dd5a1747d8f9a99c9da97 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 5 Jun 2022 23:34:31 +0300 Subject: [PATCH 09/11] refactor: resolve-deps --- .../src/resolveDependencies.ts | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/packages/resolve-dependencies/src/resolveDependencies.ts b/packages/resolve-dependencies/src/resolveDependencies.ts index e694f97ea87..3139203931b 100644 --- a/packages/resolve-dependencies/src/resolveDependencies.ts +++ b/packages/resolve-dependencies/src/resolveDependencies.ts @@ -316,18 +316,24 @@ export async function resolveDependencies ( } newPreferredVersions[resolvedPackage.name][resolvedPackage.version] = 'version' } - const results = await Promise.all(postponedResolutionsQueue.map(async (postponedResolution) => postponedResolution(newPreferredVersions, newParentPkgAliases))) + const childrenResults = await Promise.all(postponedResolutionsQueue.map(async (postponedResolution) => postponedResolution(newPreferredVersions, newParentPkgAliases))) + if (!ctx.autoInstallPeers) { + return { + missingPeers: {}, + pkgAddresses, + resolvedPeers: {}, + } + } const allMissingPeers = mergePkgsDeps( [ - ...pkgAddresses.map(({ missingPeers }) => missingPeers).filter(Boolean), - ...results.map((r) => r.missingPeers), - ] + ...pkgAddresses, + ...childrenResults, + ].map(({ missingPeers }) => missingPeers).filter(Boolean) ) - return { missingPeers: allMissingPeers, pkgAddresses, - resolvedPeers: [...pkgAddresses, ...results].reduce((acc, { resolvedPeers }) => Object.assign(acc, resolvedPeers), {}), + resolvedPeers: [...pkgAddresses, ...childrenResults].reduce((acc, { resolvedPeers }) => Object.assign(acc, resolvedPeers), {}), } } @@ -455,7 +461,11 @@ async function resolveChildren ( ).length ) const wantedDependencies = getNonDevWantedDependencies(parentPkg.pkg) - const result = await resolveDependencies(ctx, preferredVersions, wantedDependencies, + const { + pkgAddresses, + missingPeers, + resolvedPeers, + } = await resolveDependencies(ctx, preferredVersions, wantedDependencies, { currentDepth: parentDepth + 1, parentPkg, @@ -469,12 +479,12 @@ async function resolveChildren ( workspacePackages, } ) - ctx.childrenByParentDepPath[parentPkg.depPath] = result.pkgAddresses.map((child) => ({ + ctx.childrenByParentDepPath[parentPkg.depPath] = pkgAddresses.map((child) => ({ alias: child.alias, depPath: child.depPath, })) ctx.dependenciesTree[parentPkg.nodeId] = { - children: result.pkgAddresses.reduce((chn, child) => { + children: pkgAddresses.reduce((chn, child) => { chn[child.alias] = child['nodeId'] ?? child.pkgId return chn }, {}), @@ -483,8 +493,8 @@ async function resolveChildren ( resolvedPackage: ctx.resolvedPackagesByDepPath[parentPkg.depPath], } return { - missingPeers: result.missingPeers, - resolvedPeers: result.resolvedPeers, + missingPeers, + resolvedPeers, } } From f64d05a8c5e5a7df733eddd90f5dd600e09ed2e7 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Mon, 6 Jun 2022 02:59:47 +0300 Subject: [PATCH 10/11] refactor: resolve-deps --- package.json | 2 +- packages/core/package.json | 2 +- .../core/test/install/autoInstallPeers.ts | 14 +++++ packages/headless/package.json | 2 +- packages/package-requester/package.json | 2 +- .../plugin-commands-installation/package.json | 2 +- packages/plugin-commands-listing/package.json | 2 +- .../plugin-commands-outdated/package.json | 2 +- .../plugin-commands-publishing/package.json | 2 +- packages/plugin-commands-rebuild/package.json | 2 +- .../package.json | 2 +- packages/plugin-commands-store/package.json | 2 +- packages/pnpm/package.json | 2 +- .../src/resolveDependencies.ts | 5 +- pnpm-lock.yaml | 62 +++++++++---------- privatePackages/assert-project/package.json | 2 +- privatePackages/assert-store/package.json | 2 +- 17 files changed, 63 insertions(+), 46 deletions(-) diff --git a/package.json b/package.json index 56db43b8ccc..9f0b71a28ed 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@commitlint/prompt-cli": "^16.0.0", "@pnpm/eslint-config": "workspace:*", "@pnpm/meta-updater": "0.0.6", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "@pnpm/tsconfig": "workspace:*", "@types/jest": "^27.4.0", "@types/node": "^14.17.32", diff --git a/packages/core/package.json b/packages/core/package.json index 8dae8647b4e..8b5777c1901 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -74,7 +74,7 @@ "@pnpm/logger": "^4.0.0", "@pnpm/package-store": "workspace:13.0.6", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "@pnpm/store-path": "workspace:6.0.0", "@pnpm/test-fixtures": "workspace:*", "@types/fs-extra": "^9.0.5", diff --git a/packages/core/test/install/autoInstallPeers.ts b/packages/core/test/install/autoInstallPeers.ts index 2f06740f78c..b7c4dab0ceb 100644 --- a/packages/core/test/install/autoInstallPeers.ts +++ b/packages/core/test/install/autoInstallPeers.ts @@ -124,3 +124,17 @@ test('don\'t auto-install a peer dependency, when that dependency is in the root '/peer-a/1.0.0', ]) }) + +test('don\'t install the same missing peer dependency twice', async () => { + await addDistTag({ package: '@pnpm/y', version: '2.0.0', distTag: 'latest' }) + const project = prepareEmpty() + await addDependenciesToPackage({}, [ + 'has-has-y-peer-peer', + ], await testDefaults({ autoInstallPeers: true })) + const lockfile = await project.readLockfile() + expect(Object.keys(lockfile.packages)).toStrictEqual([ + '/@pnpm/y/1.0.0', + '/has-has-y-peer-peer/1.0.0_c7ewbmm644hn6ztbh6kbjiyhkq', + '/has-y-peer/1.0.0_@pnpm+y@1.0.0', + ]) +}) diff --git a/packages/headless/package.json b/packages/headless/package.json index 6ba5bf54ba6..14b05d46285 100644 --- a/packages/headless/package.json +++ b/packages/headless/package.json @@ -22,7 +22,7 @@ "@pnpm/package-store": "workspace:13.0.6", "@pnpm/prepare": "workspace:*", "@pnpm/read-projects-context": "workspace:6.0.3", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "@pnpm/store-path": "workspace:6.0.0", "@pnpm/test-fixtures": "workspace:*", "@types/fs-extra": "^9.0.5", diff --git a/packages/package-requester/package.json b/packages/package-requester/package.json index ec0b5ac5613..53c3f7def22 100644 --- a/packages/package-requester/package.json +++ b/packages/package-requester/package.json @@ -65,7 +65,7 @@ "@pnpm/create-cafs-store": "workspace:1.0.2", "@pnpm/logger": "^4.0.0", "@pnpm/package-requester": "workspace:18.0.6", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "@pnpm/test-fixtures": "workspace:*", "@types/normalize-path": "^3.0.0", "@types/ramda": "0.27.39", diff --git a/packages/plugin-commands-installation/package.json b/packages/plugin-commands-installation/package.json index c1fc46c21eb..d113fc6cdce 100644 --- a/packages/plugin-commands-installation/package.json +++ b/packages/plugin-commands-installation/package.json @@ -39,7 +39,7 @@ "@pnpm/modules-yaml": "workspace:10.0.1", "@pnpm/plugin-commands-installation": "workspace:10.0.11", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "@pnpm/test-fixtures": "workspace:*", "@types/is-ci": "^3.0.0", "@types/proxyquire": "^1.3.28", diff --git a/packages/plugin-commands-listing/package.json b/packages/plugin-commands-listing/package.json index 2776718da16..ed27e227e2f 100644 --- a/packages/plugin-commands-listing/package.json +++ b/packages/plugin-commands-listing/package.json @@ -38,7 +38,7 @@ "@pnpm/plugin-commands-installation": "workspace:10.0.11", "@pnpm/plugin-commands-listing": "workspace:5.0.10", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "@types/ramda": "0.27.39", "execa": "npm:safe-execa@^0.1.1", "strip-ansi": "^6.0.0", diff --git a/packages/plugin-commands-outdated/package.json b/packages/plugin-commands-outdated/package.json index 3635a800045..9dd57475378 100644 --- a/packages/plugin-commands-outdated/package.json +++ b/packages/plugin-commands-outdated/package.json @@ -38,7 +38,7 @@ "@pnpm/plugin-commands-installation": "workspace:10.0.11", "@pnpm/plugin-commands-outdated": "workspace:6.0.10", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "@types/lru-cache": "^5.1.0", "@types/ramda": "0.27.39", "@types/wrap-ansi": "^3.0.0", diff --git a/packages/plugin-commands-publishing/package.json b/packages/plugin-commands-publishing/package.json index 0648e8c3cda..93f8b18833b 100644 --- a/packages/plugin-commands-publishing/package.json +++ b/packages/plugin-commands-publishing/package.json @@ -39,7 +39,7 @@ "@pnpm/logger": "^4.0.0", "@pnpm/plugin-commands-publishing": "workspace:5.0.11", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "@types/cross-spawn": "^6.0.2", "@types/is-ci": "^3.0.0", "@types/is-windows": "^1.0.0", diff --git a/packages/plugin-commands-rebuild/package.json b/packages/plugin-commands-rebuild/package.json index 774ed3960cf..b9a13eb140b 100644 --- a/packages/plugin-commands-rebuild/package.json +++ b/packages/plugin-commands-rebuild/package.json @@ -37,7 +37,7 @@ "@pnpm/logger": "^4.0.0", "@pnpm/plugin-commands-rebuild": "workspace:6.1.9", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "@pnpm/test-fixtures": "workspace:*", "@types/ramda": "0.27.39", "@types/semver": "^7.3.4", diff --git a/packages/plugin-commands-script-runners/package.json b/packages/plugin-commands-script-runners/package.json index 24677e05b7d..12b7ecad649 100644 --- a/packages/plugin-commands-script-runners/package.json +++ b/packages/plugin-commands-script-runners/package.json @@ -38,7 +38,7 @@ "@pnpm/logger": "^4.0.0", "@pnpm/plugin-commands-script-runners": "workspace:5.0.12", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "@types/is-windows": "^1.0.0", "@types/ramda": "0.27.39", "is-windows": "^1.0.2", diff --git a/packages/plugin-commands-store/package.json b/packages/plugin-commands-store/package.json index ce70befa1e4..3cd3653881a 100644 --- a/packages/plugin-commands-store/package.json +++ b/packages/plugin-commands-store/package.json @@ -38,7 +38,7 @@ "@pnpm/logger": "^4.0.0", "@pnpm/plugin-commands-store": "workspace:5.1.9", "@pnpm/prepare": "workspace:*", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "@types/archy": "0.0.31", "@types/ramda": "0.27.39", "@types/ssri": "^7.1.0", diff --git a/packages/pnpm/package.json b/packages/pnpm/package.json index 6566a9e0a14..b1d5e75ec55 100644 --- a/packages/pnpm/package.json +++ b/packages/pnpm/package.json @@ -55,7 +55,7 @@ "@pnpm/prepare": "workspace:*", "@pnpm/read-package-json": "workspace:6.0.2", "@pnpm/read-project-manifest": "workspace:3.0.2", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "@pnpm/run-npm": "workspace:4.0.1", "@pnpm/tabtab": "^0.1.2", "@pnpm/types": "workspace:8.0.1", diff --git a/packages/resolve-dependencies/src/resolveDependencies.ts b/packages/resolve-dependencies/src/resolveDependencies.ts index 3139203931b..8a5721498a2 100644 --- a/packages/resolve-dependencies/src/resolveDependencies.ts +++ b/packages/resolve-dependencies/src/resolveDependencies.ts @@ -255,11 +255,14 @@ export async function resolveRootDependencies ( for (const pkgAddress of result.pkgAddresses) { parentPkgAliases[pkgAddress.alias] = true } + for (const missingPeerName of Object.keys(result.missingPeers ?? {})) { + parentPkgAliases[missingPeerName] = true + } // All the missing peers should get installed in the root. // Otherwise, pending nodes will not work. // even those peers should be hoisted that are not autoinstalled for (const [resolvedPeerName, resolvedPeerAddress] of Object.entries(result.resolvedPeers ?? {})) { - if (!result.missingPeers[resolvedPeerName] && !parentPkgAliases[resolvedPeerName]) { + if (!parentPkgAliases[resolvedPeerName]) { pkgAddresses.push(resolvedPeerAddress) } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cd9a1c9e075..aad88832e84 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,7 +41,7 @@ importers: '@commitlint/prompt-cli': ^16.0.0 '@pnpm/eslint-config': workspace:* '@pnpm/meta-updater': 0.0.6 - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/tsconfig': workspace:* '@types/jest': ^27.4.0 '@types/node': ^14.17.32 @@ -72,7 +72,7 @@ importers: '@commitlint/prompt-cli': 16.3.0 '@pnpm/eslint-config': link:utils/eslint-config '@pnpm/meta-updater': 0.0.6 - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/tsconfig': link:utils/tsconfig '@types/jest': 27.5.1 '@types/node': 14.18.20 @@ -426,7 +426,7 @@ importers: '@pnpm/read-modules-dir': workspace:4.0.0 '@pnpm/read-package-json': workspace:6.0.2 '@pnpm/read-project-manifest': workspace:3.0.2 - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/remove-bins': workspace:3.0.2 '@pnpm/resolve-dependencies': workspace:27.1.3 '@pnpm/resolver-base': workspace:9.0.1 @@ -531,7 +531,7 @@ importers: '@pnpm/logger': 4.0.0 '@pnpm/package-store': link:../package-store '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/store-path': link:../store-path '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/fs-extra': 9.0.13 @@ -1117,7 +1117,7 @@ importers: '@pnpm/read-project-manifest': workspace:3.0.2 '@pnpm/read-projects-context': workspace:6.0.3 '@pnpm/real-hoist': workspace:0.2.3 - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/store-controller-types': workspace:13.0.2 '@pnpm/store-path': workspace:6.0.0 '@pnpm/symlink-dependency': workspace:5.0.1 @@ -1178,7 +1178,7 @@ importers: '@pnpm/package-store': link:../package-store '@pnpm/prepare': link:../../privatePackages/prepare '@pnpm/read-projects-context': link:../read-projects-context - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/store-path': link:../store-path '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/fs-extra': 9.0.13 @@ -1871,7 +1871,7 @@ importers: '@pnpm/package-is-installable': workspace:6.0.3 '@pnpm/package-requester': workspace:18.0.6 '@pnpm/read-package-json': workspace:6.0.2 - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/resolver-base': workspace:9.0.1 '@pnpm/store-controller-types': workspace:13.0.2 '@pnpm/test-fixtures': workspace:* @@ -1922,7 +1922,7 @@ importers: '@pnpm/create-cafs-store': link:../create-cafs-store '@pnpm/logger': 4.0.0 '@pnpm/package-requester': 'link:' - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/normalize-path': 3.0.0 '@types/ramda': 0.27.39 @@ -2194,7 +2194,7 @@ importers: '@pnpm/pnpmfile': workspace:2.0.2 '@pnpm/prepare': workspace:* '@pnpm/read-project-manifest': workspace:3.0.2 - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/resolver-base': workspace:9.0.1 '@pnpm/semver-diff': ^1.0.2 '@pnpm/sort-packages': workspace:3.0.2 @@ -2291,7 +2291,7 @@ importers: '@pnpm/modules-yaml': link:../modules-yaml '@pnpm/plugin-commands-installation': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/is-ci': 3.0.0 '@types/proxyquire': 1.3.28 @@ -2322,7 +2322,7 @@ importers: '@pnpm/plugin-commands-installation': workspace:10.0.11 '@pnpm/plugin-commands-listing': workspace:5.0.10 '@pnpm/prepare': workspace:* - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/types': workspace:8.0.1 '@types/ramda': 0.27.39 execa: npm:safe-execa@^0.1.1 @@ -2346,7 +2346,7 @@ importers: '@pnpm/plugin-commands-installation': link:../plugin-commands-installation '@pnpm/plugin-commands-listing': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@types/ramda': 0.27.39 execa: /safe-execa/0.1.1 strip-ansi: 6.0.1 @@ -2370,7 +2370,7 @@ importers: '@pnpm/plugin-commands-installation': workspace:10.0.11 '@pnpm/plugin-commands-outdated': workspace:6.0.10 '@pnpm/prepare': workspace:* - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/semver-diff': ^1.0.2 '@pnpm/store-path': workspace:6.0.0 '@pnpm/types': workspace:8.0.1 @@ -2413,7 +2413,7 @@ importers: '@pnpm/plugin-commands-installation': link:../plugin-commands-installation '@pnpm/plugin-commands-outdated': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@types/lru-cache': 5.1.1 '@types/ramda': 0.27.39 '@types/wrap-ansi': 3.0.0 @@ -2433,7 +2433,7 @@ importers: '@pnpm/pick-registry-for-package': workspace:3.0.1 '@pnpm/plugin-commands-publishing': workspace:5.0.11 '@pnpm/prepare': workspace:* - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/resolver-base': workspace:9.0.1 '@pnpm/run-npm': workspace:4.0.1 '@pnpm/sort-packages': workspace:3.0.2 @@ -2496,7 +2496,7 @@ importers: '@pnpm/logger': 4.0.0 '@pnpm/plugin-commands-publishing': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@types/cross-spawn': 6.0.2 '@types/is-ci': 3.0.0 '@types/is-windows': 1.0.0 @@ -2534,7 +2534,7 @@ importers: '@pnpm/normalize-registries': workspace:3.0.1 '@pnpm/plugin-commands-rebuild': workspace:6.1.9 '@pnpm/prepare': workspace:* - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/sort-packages': workspace:3.0.2 '@pnpm/store-connection-manager': workspace:4.1.8 '@pnpm/store-controller-types': workspace:13.0.2 @@ -2593,7 +2593,7 @@ importers: '@pnpm/logger': 4.0.0 '@pnpm/plugin-commands-rebuild': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/ramda': 0.27.39 '@types/semver': 7.3.9 @@ -2619,7 +2619,7 @@ importers: '@pnpm/prepare': workspace:* '@pnpm/read-package-json': workspace:6.0.2 '@pnpm/read-project-manifest': workspace:3.0.2 - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/sort-packages': workspace:3.0.2 '@pnpm/store-path': workspace:6.0.0 '@pnpm/types': workspace:8.0.1 @@ -2662,7 +2662,7 @@ importers: '@pnpm/logger': 4.0.0 '@pnpm/plugin-commands-script-runners': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@types/is-windows': 1.0.0 '@types/ramda': 0.27.39 is-windows: 1.0.2 @@ -2752,7 +2752,7 @@ importers: '@pnpm/pick-registry-for-package': workspace:3.0.1 '@pnpm/plugin-commands-store': workspace:5.1.9 '@pnpm/prepare': workspace:* - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/store-connection-manager': workspace:4.1.8 '@pnpm/store-controller-types': workspace:13.0.2 '@pnpm/store-path': workspace:6.0.0 @@ -2799,7 +2799,7 @@ importers: '@pnpm/logger': 4.0.0 '@pnpm/plugin-commands-store': 'link:' '@pnpm/prepare': link:../../privatePackages/prepare - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@types/archy': 0.0.31 '@types/ramda': 0.27.39 '@types/ssri': 7.1.1 @@ -2847,7 +2847,7 @@ importers: '@pnpm/prepare': workspace:* '@pnpm/read-package-json': workspace:6.0.2 '@pnpm/read-project-manifest': workspace:3.0.2 - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/run-npm': workspace:4.0.1 '@pnpm/tabtab': ^0.1.2 '@pnpm/types': workspace:8.0.1 @@ -2935,7 +2935,7 @@ importers: '@pnpm/prepare': link:../../privatePackages/prepare '@pnpm/read-package-json': link:../read-package-json '@pnpm/read-project-manifest': link:../read-project-manifest - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/run-npm': link:../run-npm '@pnpm/tabtab': 0.1.2 '@pnpm/types': link:../types @@ -3533,7 +3533,7 @@ importers: '@pnpm/constants': workspace:6.1.0 '@pnpm/lockfile-types': workspace:4.0.1 '@pnpm/modules-yaml': workspace:10.0.1 - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/types': workspace:8.0.1 '@types/is-windows': ^1.0.0 '@types/isexe': 2.0.0 @@ -3548,7 +3548,7 @@ importers: '@pnpm/constants': link:../../packages/constants '@pnpm/lockfile-types': link:../../packages/lockfile-types '@pnpm/modules-yaml': link:../../packages/modules-yaml - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 '@pnpm/types': link:../../packages/types is-windows: 1.0.2 isexe: 2.0.0 @@ -3565,11 +3565,11 @@ importers: specifiers: '@pnpm/assert-store': workspace:* '@pnpm/cafs': workspace:4.0.3 - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 path-exists: ^4.0.0 dependencies: '@pnpm/cafs': link:../../packages/cafs - '@pnpm/registry-mock': 2.18.0 + '@pnpm/registry-mock': 2.19.0 path-exists: 4.0.0 devDependencies: '@pnpm/assert-store': 'link:' @@ -5183,8 +5183,8 @@ packages: strip-bom: 4.0.0 dev: true - /@pnpm/registry-mock/2.18.0: - resolution: {integrity: sha512-hj5LwD6tGsUjA9l++2ucFeAb4nhYryvK1i7+h3/a7IwkqvJKKSaJYb+wkYuAzIYOCjYK9BYQNAfBz1Rkq03Ayw==} + /@pnpm/registry-mock/2.19.0: + resolution: {integrity: sha512-nPrpSr6PWl150NIY26FsXKqlk4NL6dR29HC+4H4pVUS6GZloQU/NUlwvLCJ6FrV16YyV6cOvbDMCxVjri1rltg==} engines: {node: '>=10.13'} hasBin: true dependencies: @@ -12346,7 +12346,7 @@ packages: dev: false /performance-now/2.1.0: - resolution: {integrity: sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=} + resolution: {integrity: sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==} /picocolors/1.0.0: resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} diff --git a/privatePackages/assert-project/package.json b/privatePackages/assert-project/package.json index e0f11184d9f..5e964b43839 100644 --- a/privatePackages/assert-project/package.json +++ b/privatePackages/assert-project/package.json @@ -44,7 +44,7 @@ "@pnpm/constants": "workspace:6.1.0", "@pnpm/lockfile-types": "workspace:4.0.1", "@pnpm/modules-yaml": "workspace:10.0.1", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "@pnpm/types": "workspace:8.0.1", "is-windows": "^1.0.2", "isexe": "2.0.0", diff --git a/privatePackages/assert-store/package.json b/privatePackages/assert-store/package.json index 900a3cdc3df..d58032abc8d 100644 --- a/privatePackages/assert-store/package.json +++ b/privatePackages/assert-store/package.json @@ -41,7 +41,7 @@ }, "dependencies": { "@pnpm/cafs": "workspace:4.0.3", - "@pnpm/registry-mock": "2.18.0", + "@pnpm/registry-mock": "2.19.0", "path-exists": "^4.0.0" }, "devDependencies": { From 4a018578a641b4886ce9c65aebc1d63a0f4399c7 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Mon, 6 Jun 2022 03:02:27 +0300 Subject: [PATCH 11/11] docs: add changesets --- .changeset/strange-ants-remain.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/strange-ants-remain.md diff --git a/.changeset/strange-ants-remain.md b/.changeset/strange-ants-remain.md new file mode 100644 index 00000000000..c11fe74723c --- /dev/null +++ b/.changeset/strange-ants-remain.md @@ -0,0 +1,6 @@ +--- +"pnpm": patch +"@pnpm/resolve-dependencies": patch +--- + +When the same package is found several times in the dependency graph, correctly autoinstall its missing peer dependencies at all times [#4820](https://github.com/pnpm/pnpm/issues/4820).