Skip to content

Resolve workspace: protocol dependencies when using package_file#2775

Draft
laura-mlg wants to merge 1 commit into
mainfrom
fix/workspace-protocol-resolution
Draft

Resolve workspace: protocol dependencies when using package_file#2775
laura-mlg wants to merge 1 commit into
mainfrom
fix/workspace-protocol-resolution

Conversation

@laura-mlg
Copy link
Copy Markdown
Contributor

Summary

When a plugin's package_file points to a package.json in a pnpm monorepo, dependencies using the workspace:* protocol were silently ignored — npm couldn't resolve them in the tool's sandbox, causing tools like knip to fail loading config files that import workspace packages.

This fix detects workspace: references in update_file_dependencies, locates the package on disk by walking up to pnpm-workspace.yaml and scanning the declared workspace directories, then replaces workspace:* with an absolute file: path npm can resolve.

Closes qltysh/support#295

Test plan

  • Existing test_update_package_file_based_dependency still passes (file: protocol unaffected)
  • New test_update_workspace_protocol_dependency covers pnpm workspace resolution
  • No changes when pnpm-workspace.yaml is absent (non-monorepo projects unaffected)

When a plugin's package_file references a package.json that contains
workspace:* dependencies (pnpm monorepo), resolve them to file: paths
by locating the package on disk via pnpm-workspace.yaml.

Fixes #2774

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@qltysh
Copy link
Copy Markdown
Contributor

qltysh Bot commented Apr 30, 2026

Analysis for project qlty

❌ 1 blocking issue (4 total)

Tool Category Rule Count
rustfmt Style Incorrect formatting, autoformat by running qlty fmt. 1
qlty Structure High total complexity (count = 90) 1
qlty Structure Function with high complexity (count = 36): find_workspace_packages 1
qlty Structure Deeply nested control flow (level = 5) 1

@qltysh one-click actions:

  • Auto-fix formatting (qlty fmt && git push)

}
}

Ok(packages)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function with high complexity (count = 36): find_workspace_packages [qlty:function-complexity]

if let Some(pkg_dir) = entry.path().to_str() {
packages.insert(name.to_string(), pkg_dir.to_string());
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deeply nested control flow (level = 5) [qlty:nested-control-flow]

@qltysh
Copy link
Copy Markdown
Contributor

qltysh Bot commented Apr 30, 2026

Qlty


Coverage Impact - ubuntu-latest

⬆️ Merging this pull request will increase total coverage on main by 0.01%.

Modified Files with Diff Coverage (1)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
qlty-check/src/tool/node/package_json.rs91.3%176-179, 203-205...
Total91.3%
🤖 Increase coverage with AI coding...
In the `fix/workspace-protocol-resolution` branch, add test coverage for this new code:

- `qlty-check/src/tool/node/package_json.rs` -- Lines 176-179, 203-205, 408, 415, and 428

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@qltysh
Copy link
Copy Markdown
Contributor

qltysh Bot commented Apr 30, 2026

Qlty


Coverage Impact - macos-15

⬆️ Merging this pull request will increase total coverage on main by 0.01%.

Modified Files with Diff Coverage (1)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
qlty-check/src/tool/node/package_json.rs91.3%176-179, 203-205...
Total91.3%
🤖 Increase coverage with AI coding...
In the `fix/workspace-protocol-resolution` branch, add test coverage for this new code:

- `qlty-check/src/tool/node/package_json.rs` -- Lines 176-179, 203-205, 408, 415, and 428

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants