-
Notifications
You must be signed in to change notification settings - Fork 5
Break pub tools out into their own support mixin #82
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
base: main
Are you sure you want to change the base?
Conversation
PR HealthChangelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. |
import '../utils/process_manager.dart'; | ||
|
||
// TODO: migrate the analyze files tool to use this mixin and run the | ||
// `dart analyze` command instead of the analyzer package. |
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.
This is old and can be removed
// TODO: migrate the analyze files tool to use this mixin and run the | ||
// `dart analyze` command instead of the analyzer package. | ||
|
||
/// Mix this in to any MCPServer to add support for running Dart CLI commands |
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.
Update comment
implements ProcessManagerSupport { | ||
@override | ||
FutureOr<InitializeResult> initialize(InitializeRequest request) { | ||
if (request.capabilities.roots == null) { |
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.
We don't necessarily have to do this now, but I do think we should trend more in the direction of just logging a warning, and then not registering the pub tools. See the analyzer support mixin for an example.
Note that warnings have to be logged after initialization completes.
Basically the goal is to still allow the functionality that does work instead of failing initialization entirely.
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.
Actually, on second look this does not require roots anyways (unless we wanted to make "roots" be optional, and by default run commands in all known roots, but this doesn't actually list the roots today).
|
||
final paths = (rootConfig['paths'] as List?)?.cast<String>(); | ||
if (paths != null) { | ||
command.addAll(paths); |
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.
I don't think we should modify the input parameter like this - generally that isn't idiomatic dart style.
I would just copy the input list and then add the paths to the copy.
/// Helper to run a command in multiple project roots. | ||
/// | ||
/// [defaultPaths] may be specified if one or more path arguments are required | ||
/// for the command (e.g. `dart format <default paths>`). |
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.
I would mention here a bit more about the expected argument structure and the implicit handling of paths
.
This refactors the pub support to be part of its own support mixin instead of being part of the Dart CLI tools mixin. This is because once #81 is resolved, this tool won't necessarily be using the Dart CLI or the Flutter CLI, but may use either.
This PR pulls out a utility method
runCommandInRoots
from the Dart CLI support mixin for reuse.