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). diff --git a/package.json b/package.json index f5eeed2cea1..9f0b71a28ed 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", @@ -38,7 +39,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.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 1fb9f82c224..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.17.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 217f31ecd86..b7c4dab0ceb 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 () => { @@ -61,3 +61,80 @@ 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', + ]) +}) + +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', + `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_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_c3hmehglzcfufab5hu6m6d76li', + '/@pnpm/xyz-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li', + '/@pnpm/xyz-parent/1.0.0_e5suan7fvtov6fikg25btc2odi', + '/@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', + ]) +}) + +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', + ]) +}) + +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 cd7c82973c8..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.17.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 30ce8962e65..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.17.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 e798b067f85..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.17.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 439561ded59..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.17.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 05ed4eb9ce8..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.17.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 190b26dab81..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.17.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 eaad6c2433d..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.17.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 572040d048e..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.17.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 24d01064dcd..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.17.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 c845aede381..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.17.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 b34a117e1fb..8a5721498a2 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,7 +166,8 @@ export type PkgAddress = { version?: string updated: boolean rootDir: string - missingPeers: Record + missingPeers: MissingPeers + resolvedPeers: ResolvedPeers } & ({ isLinkedDependency: true version: string @@ -206,7 +211,7 @@ export interface ResolvedPackage { type ParentPkg = Pick -type ParentPkgAliases = Record +type ParentPkgAliases = Record interface ResolvedDependenciesOptions { currentDepth: number @@ -222,47 +227,88 @@ interface ResolvedDependenciesOptions { workspacePackages?: WorkspacePackages } -type PostponedResolutionFunction = (preferredVersions: PreferredVersions, parentPkgAliases: ParentPkgAliases) => Promise +type PostponedResolutionFunction = (preferredVersions: PreferredVersions, parentPkgAliases: ParentPkgAliases) => Promise<{ + missingPeers: MissingPeers + resolvedPeers: ResolvedPeers +}> -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 = [] + const parentPkgAliases: ParentPkgAliases = {} + for (const wantedDep of wantedDependencies) { + if (wantedDep.alias) { + parentPkgAliases[wantedDep.alias] = true + } + } 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 result = await resolveDependencies(ctx, preferredVersions, wantedDependencies, { + ...options, + parentPkgAliases, }) - const newPkgAddresses = ( - await Promise.all( - extendedWantedDeps.map(async (extendedWantedDep) => resolveDependenciesOfDependency( - postponedResolutionsQueue, - ctx, - preferredVersions, - options, - extendedWantedDep - )) - ) - ).filter(Boolean) as PkgAddress[] - pkgAddresses.push(...newPkgAddresses) + 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 }) + 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 (!parentPkgAliases[resolvedPeerName]) { + pkgAddresses.push(resolvedPeerAddress) + } + } + if (!Object.keys(result.missingPeers).length) break + wantedDependencies = getNonDevWantedDependencies({ dependencies: result.missingPeers }) } + return pkgAddresses +} +interface ResolvedDependenciesResult { + pkgAddresses: Array + missingPeers: MissingPeers + resolvedPeers: ResolvedPeers +} + +export async function resolveDependencies ( + ctx: ResolutionContext, + preferredVersions: PreferredVersions, + wantedDependencies: Array, + options: ResolvedDependenciesOptions +): Promise { + const postponedResolutionsQueue: PostponedResolutionFunction[] = [] + const extendedWantedDeps = getDepsToResolve(wantedDependencies, ctx.wantedLockfile, { + preferredDependencies: options.preferredDependencies, + prefix: ctx.prefix, + proceed: options.proceed || ctx.forceFullResolution, + registries: ctx.registries, + resolvedDependencies: options.resolvedDependencies, + }) + const pkgAddresses = ( + await Promise.all( + extendedWantedDeps.map(async (extendedWantedDep) => resolveDependenciesOfDependency( + postponedResolutionsQueue, + ctx, + preferredVersions, + options, + extendedWantedDep + )) + ) + ).filter(Boolean) as PkgAddress[] const newPreferredVersions = { ...preferredVersions } const newParentPkgAliases = { ...options.parentPkgAliases } for (const pkgAddress of pkgAddresses) { - newParentPkgAliases[pkgAddress.alias] = true + if (newParentPkgAliases[pkgAddress.alias] !== true) { + newParentPkgAliases[pkgAddress.alias] = pkgAddress + } if (pkgAddress.updated) { ctx.updatedSet.add(pkgAddress.alias) } @@ -273,9 +319,25 @@ export default async function resolveDependencies ( } newPreferredVersions[resolvedPackage.name][resolvedPackage.version] = 'version' } - await Promise.all(postponedResolutionsQueue.map(async (postponedResolution) => postponedResolution(newPreferredVersions, newParentPkgAliases))) - - return pkgAddresses + const childrenResults = await Promise.all(postponedResolutionsQueue.map(async (postponedResolution) => postponedResolution(newPreferredVersions, newParentPkgAliases))) + if (!ctx.autoInstallPeers) { + return { + missingPeers: {}, + pkgAddresses, + resolvedPeers: {}, + } + } + const allMissingPeers = mergePkgsDeps( + [ + ...pkgAddresses, + ...childrenResults, + ].map(({ missingPeers }) => missingPeers).filter(Boolean) + ) + return { + missingPeers: allMissingPeers, + pkgAddresses, + resolvedPeers: [...pkgAddresses, ...childrenResults].reduce((acc, { resolvedPeers }) => Object.assign(acc, resolvedPeers), {}), + } } function mergePkgsDeps (pkgsDeps: Array>): Record { @@ -402,7 +464,11 @@ async function resolveChildren ( ).length ) const wantedDependencies = getNonDevWantedDependencies(parentPkg.pkg) - const children = await resolveDependencies(ctx, preferredVersions, wantedDependencies, + const { + pkgAddresses, + missingPeers, + resolvedPeers, + } = await resolveDependencies(ctx, preferredVersions, wantedDependencies, { currentDepth: parentDepth + 1, parentPkg, @@ -416,12 +482,12 @@ async function resolveChildren ( workspacePackages, } ) - ctx.childrenByParentDepPath[parentPkg.depPath] = children.map((child) => ({ + ctx.childrenByParentDepPath[parentPkg.depPath] = pkgAddresses.map((child) => ({ alias: child.alias, depPath: child.depPath, })) ctx.dependenciesTree[parentPkg.nodeId] = { - children: children.reduce((chn, child) => { + children: pkgAddresses.reduce((chn, child) => { chn[child.alias] = child['nodeId'] ?? child.pkgId return chn }, {}), @@ -429,6 +495,10 @@ async function resolveChildren ( installable: parentPkg.installable, resolvedPackage: ctx.resolvedPackagesByDepPath[parentPkg.depPath], } + return { + missingPeers, + resolvedPeers, + } } function getDepsToResolve ( @@ -885,7 +955,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 +977,19 @@ async function getManifestFromResponse ( } } -function getMissingPeers (pkg: PackageManifest, parentPkgAliases: ParentPkgAliases): Record { - const missingPeers = {} as Record +function getMissingPeers (pkg: PackageManifest, parentPkgAliases: ParentPkgAliases) { + const missingPeers = {} as MissingPeers + const resolvedPeers = {} as ResolvedPeers for (const [peerName, peerVersion] of Object.entries(pkg.peerDependencies ?? {})) { - if (!parentPkgAliases[peerName] && !pkg.peerDependenciesMeta?.[peerName]?.optional) { + if (parentPkgAliases[peerName]) { + if (parentPkgAliases[peerName] !== true) { + resolvedPeers[peerName] = parentPkgAliases[peerName] as PkgAddress + } + } 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, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5dced384c9e..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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.0 + '@pnpm/registry-mock': 2.19.0 path-exists: ^4.0.0 dependencies: '@pnpm/cafs': link:../../packages/cafs - '@pnpm/registry-mock': 2.17.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.17.0: - resolution: {integrity: sha512-vZuWSJaixugxz0Y39VIEKeyYm69TG3/8qXkgMXjLjRWtE/4EezKKGfiAEhuJasSdvVoYUQWY2Ng0nEkWihTN9w==} + /@pnpm/registry-mock/2.19.0: + resolution: {integrity: sha512-nPrpSr6PWl150NIY26FsXKqlk4NL6dR29HC+4H4pVUS6GZloQU/NUlwvLCJ6FrV16YyV6cOvbDMCxVjri1rltg==} 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 @@ -12340,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==} @@ -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..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.17.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 f195de6db45..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.17.0", + "@pnpm/registry-mock": "2.19.0", "path-exists": "^4.0.0" }, "devDependencies": {