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

Delete directories between workspace package and workspace root #4446

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

sigurdm
Copy link
Contributor

@sigurdm sigurdm commented Nov 26, 2024

Fixes #4445
Also makes resolution error if there are any pubspec.yaml's in such directories.

Comment on lines 1356 to 1357
deleteEntry(p.join(dir, 'pubspec.lock'));
deleteEntry(p.join(dir, '.dart_tool', 'package_config.json'));
Copy link
Member

Choose a reason for hiding this comment

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

Should we write a warning message or something to logs.

Maybe something that includes a dart.dev/go/-link, so that we can explain why we deleted these folders.

If someone has workspace packages nested inside non-workspace packages inside a root, that could cause this, right? or probably it'll cause an error when trying to resolve the workspaces packages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we write a warning message or something to logs.

I'm not completely against this, but I think it might confuse more than it benefits...

Maybe something that includes a dart.dev/go/-link,

I think that would be slightly overdoing it... But maybe we can fit a paragraph in somewhere on the workspaces documentation...

so that we can explain why we deleted these folders.

We are deleting files, not folders.

If someone has workspace packages nested inside non-workspace packages inside a root,

We should probably detect if someone attempts this (by detecting a pubspec.yaml), and give an error message.
That scenario is not supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok - now displaying a warning and a doc reference.

Also added an error check if there are stray pubspec.yaml files between a package and the root.

@sigurdm sigurdm requested a review from jonasfj November 29, 2024 13:15
}
}
if (deletedAny) {
log.warning(
'See https://dart.dev/go/workspaces-no-inbetween-packages for details.',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'See https://dart.dev/go/workspaces-no-inbetween-packages for details.',
'See https://dart.dev/go/workspace-packages-in-other-package for details.',

I'm not sure this is better, just an idea.

}

// Check for pubspec.yaml files between the root and any workspace package.
final visited = <String>{};
Copy link
Member

Choose a reason for hiding this comment

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

Just an idea, feel free to ignore.

Suggested change
final visited = <String>{};
final visited = <String>{root.dir};

Then you won't need p.equals(dir, root.dir), but then again, maybe this is just too smart. 🤣

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like it!

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.

Delete stray .dart_tool/package_config.json files between root and package dirs.
2 participants