Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: should not output warning info with non-top-level directory structure #7382

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lovely-wombats-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@pnpm/workspace.find-packages": patch
---

fix: should not output warning info when "pnpm" or "resolutions" is configured in a non-root workspace project with non-top-level directory structure
5 changes: 2 additions & 3 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"idempotency",
"imurmurhash",
"ionicons",
"isequal",
"isexe",
"istvan",
"italiano",
Expand Down Expand Up @@ -166,7 +167,6 @@
"postshrinkwrap",
"poststart",
"poststop",
"poststop",
"posttest",
"postuninstall",
"postversion",
Expand All @@ -179,7 +179,6 @@
"prerestart",
"preshrinkwrap",
"prestart",
"prestart",
"prestop",
"preuninstall",
"preversion",
Expand Down Expand Up @@ -254,6 +253,6 @@
"xmarw",
"zkochan",
"zoli",
"zoltan"
"zoltan"
]
}
22 changes: 19 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions workspace/find-packages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@
"@pnpm/fs.find-packages": "workspace:*",
"@pnpm/types": "workspace:*",
"@pnpm/util.lex-comparator": "1.0.0",
"@pnpm/workspace.read-manifest": "workspace:*"
"@pnpm/workspace.read-manifest": "workspace:*",
"lodash.isequal": "4.5.0"
},
"funding": "https://opencollective.com/pnpm",
"devDependencies": {
"@pnpm/workspace.find-packages": "workspace:*"
"@pnpm/workspace.find-packages": "workspace:*",
"@types/lodash.isequal": "4.5.8"
},
"peerDependencies": {
"@pnpm/logger": "^5.0.0"
Expand Down
11 changes: 7 additions & 4 deletions workspace/find-packages/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { packageIsInstallable } from '@pnpm/cli-utils'
import { packageIsInstallable, readProjectManifest } from '@pnpm/cli-utils'
import { type ProjectManifest, type Project, type SupportedArchitectures } from '@pnpm/types'
import { readWorkspaceManifest } from '@pnpm/workspace.read-manifest'
import { lexCompare } from '@pnpm/util.lex-comparator'
import { findPackages } from '@pnpm/fs.find-packages'
import { logger } from '@pnpm/logger'
import isEqual from 'lodash.isequal'

export type { Project }

Expand All @@ -18,6 +19,7 @@ export async function findWorkspacePackages (
}
): Promise<Project[]> {
const pkgs = await findWorkspacePackagesNoCheck(workspaceRoot, opts)
const { manifest: rootProjectManifest } = await readProjectManifest(workspaceRoot)
for (const pkg of pkgs) {
packageIsInstallable(pkg.dir, pkg.manifest, opts ?? {
supportedArchitectures: {
Expand All @@ -28,7 +30,7 @@ export async function findWorkspacePackages (
})
// When setting shared-workspace-lockfile=false, `pnpm` can be set in sub-project's package.json.
if (opts?.sharedWorkspaceLockfile && pkg.dir !== workspaceRoot) {
checkNonRootProjectManifest(pkg)
checkNonRootProjectManifest(pkg, rootProjectManifest)
}
}

Expand Down Expand Up @@ -68,9 +70,10 @@ export function arrayOfWorkspacePackagesToMap (
}, {} as ArrayOfWorkspacePackagesToMapResult)
}

function checkNonRootProjectManifest ({ manifest, dir }: Project) {
function checkNonRootProjectManifest ({ manifest, dir }: Project, rootProjectManifest: ProjectManifest) {
for (const rootOnlyField of ['pnpm', 'resolutions']) {
if (manifest?.[rootOnlyField as keyof ProjectManifest]) {
const workspaceProjectField = manifest?.[rootOnlyField as keyof ProjectManifest]
if (workspaceProjectField && !isEqual(workspaceProjectField, rootProjectManifest?.[rootOnlyField as keyof ProjectManifest])) {
logger.warn({
message: `The field "${rootOnlyField}" was found in ${dir}/package.json. This will not take effect. You should configure "${rootOnlyField}" at the root of the workspace instead.`,
prefix: dir,
Expand Down