feat: add pnpm workspace support#68
Conversation
Resolves workspace: protocol references to actual versions from local workspace packages. This enables the extension to show available updates for dependencies linked via pnpm workspaces. - Add workspace.ts module to discover and cache workspace packages from pnpm-workspace.yaml, supporting *, **, and literal glob patterns - Resolve workspace:*, workspace:^, workspace:~, and workspace:x.y.z to the local package version or explicit specifier - Skip quick-fix upgrades for workspace deps (version lives in workspace package) - Add unit tests for workspace resolution and packageJson integration
Extends pnpm workspace support to resolve catalog: protocol references using the root pnpm-workspace.yaml catalog and catalogs sections. - Parse catalog and catalogs blocks from pnpm-workspace.yaml - Resolve catalog:, catalog:default, and catalog:<name> to versions defined in the workspace root catalog configuration - Support quoted keys (e.g. 'react-dom') in YAML parsing - Skip quick-fix and bulk updates for catalog deps (version lives in catalog) - Add isolated test fixtures and unit tests for catalog resolution
|
Hi @pgsandstrom — whenever you have a moment, this PR is ready for your review. I've added both workspace and catalog resolution with full test coverage, and the existing vscode e2e test still passes. Happy to make any changes you'd like. Thanks for maintaining the extension! |
|
Thanks for the PR.
|
Address review feedback from pgsandstrom on PR pgsandstrom#68: - Replace hand-rolled line-by-line YAML parsers (parsePnpmWorkspaceYaml, parsePnpmWorkspaceCatalogs, extractBlock, extractNestedBlocks) with js-yaml. This fixes fragility around comments, inline arrays, flow styles, anchors, multi-line strings, and other valid YAML edge cases. - Remove verbose JSDoc comments that restated the obvious from function signatures. - Add support for pnpm-workspace.yml (in addition to .yaml). - Extract findWorkspaceFile helper to avoid duplicating file lookup logic. - Add js-yaml + @types/js-yaml as direct dependencies. All 54 tests pass. Typecheck and lint clean.
… cache Critical review follow-up for PR pgsandstrom#68: - BUG FIX: catalog: dependencies were never fetched from npm because refreshPackageJsonData only resolved workspace: versions before the semver filter, leaving catalog: strings to be filtered out. Added catalog version resolution so catalog deps now show update decorations. - Cache workspace root lookups to avoid repeated directory traversal when resolving multiple deps from the same package.json. - Test hardening: wrap writeYaml/restoreYaml in try/finally so failures don't leave testdata in a bad state. - New tests: pnpm-workspace.yml extension support, invalid YAML graceful degradation, and catalog npm resolution coverage. All 56 tests pass. Lint and typecheck clean.
|
Hi @pgsandstrom — thanks for the review! I've gone through all four points and pushed the updates. Here's what changed: 1. Merged latest master ✅ 2. Replaced fragile manual YAML parsing ✅ 3. Iterated with critical AI review ✅
Fixed by adding catalog resolution in alongside workspace resolution. Also added workspace root caching to avoid repeated directory traversal, hardened tests with , and added coverage for extension and invalid YAML. 4. Cleaned up comments and abstractions ✅ Also removed the internal-only / interfaces that were artifacts of the manual parsing approach. All 56 tests pass, lint and typecheck are clean, and the existing vscode e2e test still passes. Ready for another look whenever you have time! |
|
Quick follow-up — the backticks in my last comment got eaten by shell escaping. The key changes were:
Full diff: thecannabisapp/package-json-upgrade@f8c6a01...ca1daae |
michaelfaith
left a comment
There was a problem hiding this comment.
@pgsandstrom this is pretty solid 👍 . I highlighted a few minor things, and then one recommendation to use a standard glob api, rather than rolling their own. Otherwise, this seems reasonable.
|
@michaelfaith thanks for the review — great catches. Nits: Agreed on all three. I'll flatten the bailouts in tinyglobby: Also agreed. The hand-rolled glob only handles @pgsandstrom this should address the remaining feedback. Let me know if you'd like anything else tweaked. |
- Combine workspace/catalog bailout conditions in updateAction.ts and updateAll.ts - Flatten nested catalog lookup in workspace.ts with optional chaining - Replace hand-rolled resolveGlob/resolveGlobRecursive with tinyglobby - Adds tinyglobby dependency for proper glob semantics (brace expansion, negation, etc)
This PR adds support for pnpm workspaces, resolving both
workspace:andcatalog:protocol references so that update decorations work correctly in monorepo setups.What it does
workspace:*,workspace:^,workspace:~,workspace:x.y.z— resolves the referenced package to its actual version from the local workspace package.json, then checks npm for available updates.catalog:,catalog:default,catalog:<name>— resolves versions from the rootpnpm-workspace.yamlcatalogandcatalogssections, then checks npm for available updates.Test coverage
Closes #43
Closes #61