-
Notifications
You must be signed in to change notification settings - Fork 241
feat: recursively discover packages in nested workspaces #968
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
feat: recursively discover packages in nested workspaces #968
Conversation
This commit adds support for recursively discovering packages in nested workspaces, fixing the issue where melos would not discover packages nested within workspace root directories. Changes: - Modified _resolvePubspecFiles to detect and recurse into nested workspaces - Added _isWorkspacePubspec helper to check if a pubspec.yaml defines a workspace - Added _discoverNestedWorkspacePackages to recursively discover packages in nested workspaces - Added comprehensive test cases for nested workspace discovery Fixes the issue where packages like forui_example, forui_assets, etc. were not discovered when they were nested within a workspace root. Test cases cover: - Basic nested workspace discovery - Deeply nested workspaces (multiple levels) - Nested workspaces with example packages - Ignore patterns for nested packages - Complex nested workspace structures
|
To view this pull requests documentation preview, visit the following URL: Documentation is deployed and generated using docs.page. |
spydon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! This is a breaking change, because now packages that are listed under another nested workspace will be included in run etc even though they are not listed in the root workspace list, which serves to show which packages that Melos should handle currently. So I think we need to introduce a bool config, like discoverNestedWorkspaces that checks whether the user wants the new behaviour.
done. |
spydon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
Description
This PR adds support for recursively discovering packages in nested workspaces, fixing the issue where
fvm dart pub workspace listandfvm dart run melos listproduce inconsistent results.Problem
Currently, when a workspace root directory itself contains a
workspace:configuration in itspubspec.yaml, melos does not recursively discover the packages listed in that nested workspace. This causesfvm dart run melos listto have different results compared tofvm dart pub workspace list.Example
In a monorepo structure like:
Current behavior:
fvm dart pub workspace listdiscovers all packages including nested ones:ui,core,components,examplefvm dart run melos listonly discovers the workspace root:packages/base/uiThis inconsistency makes it difficult to manage packages in monorepos with nested workspace structures.
Solution
_resolvePubspecFilesto detect and recurse into nested workspaces_isWorkspacePubspechelper to check if a pubspec.yaml defines a workspace_discoverNestedWorkspacePackagesto recursively discover packages in nested workspacesThe implementation now matches
dart pub workspace listbehavior by recursively discovering all packages in nested workspaces.Changes
packages/melos/lib/src/package.dart: Added recursive workspace discovery logic (353 lines added)packages/melos/test/package_test.dart: Added 5 new test cases for nested workspace discoveryTesting
All existing tests pass, and 5 new test cases have been added:
Verification
After this fix,
fvm dart run melos listandfvm dart pub workspace listwill produce consistent results for nested workspace structures.Related
Fixes the inconsistency between
melos listanddart pub workspace listcommands when dealing with nested workspaces.Type of Change
feat-- New feature (non-breaking change which adds functionality)fix-- Bug fix (non-breaking change which fixes an issue)!-- Breaking change (fix or feature that would cause existing functionality to change)refactor-- Code refactorci-- Build configuration changedocs-- Documentationchore-- Chore