-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Pub dependencies project validator #106895
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
Pub dependencies project validator #106895
Conversation
| group('PubDependenciesProjectValidator', () { | ||
|
|
||
| setUp(() { | ||
| fileSystem = globals.localFileSystem; |
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.
does this need to use the real file system? and if so, this should probably be in the integration shard.
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.
Not really. I can use a FakeFileSystem here
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.
👍
| fileSystem = globals.localFileSystem; | ||
| }); | ||
|
|
||
| testWithoutContext('success ', () async { |
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.
out of curiosity, why the trailing space in the test name?
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.
That was a typo
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.
👍
| fileSystem = globals.localFileSystem; | ||
| }); | ||
|
|
||
| testWithoutContext('success ', () async { |
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.
also, maybe name this 'success when all dependencies are hosted'
| final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ | ||
| const FakeCommand( | ||
| command: <String>['dart', 'pub', 'deps', '--json'], | ||
| stdout: 'stdout command fail', |
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.
what does this mean?
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.
Just expecting something not a json (eg: if you haven't updated your pub dependencies and the pubspec has changed pub dart deps returns a message to update them. I don't have the exact message so I just fake this)
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.
Also if for some reason dart pub deps --json breaks we will catch that and pass the stacktrace to the validator output
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.
Good thinking. However, if the command breaks any debug messaging should go to STDERR, right?
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 could be wrong, but I would imagine if you pass --json, only valid JSON should be output to stdout, and any diagnostics would go to stderr.
| final List<ProjectValidatorResult> result = await validator.start( | ||
| FlutterProject.fromDirectoryTest(fileSystem.currentDirectory) | ||
| ); | ||
| const String expected = 'All dependencies are hosted'; |
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.
will the user have enough context to understand what this means?
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.
The user will read [✓] Dart dependencies: All dependencies are hosted
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.
will they know what that means?
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 know. Should I add something like [✓] Dart dependencies: All dart dependencies comes from known places or something along those lines?
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.
will they know what "comes from" means?
I guess backing up, what is the high level information that you want to communicate to the user?
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.
If one ore more dependencies do not come from pub.dev eg: they are pointing to a github repo to get it #103614
| final List<ProjectValidatorResult> result = await validator.start( | ||
| FlutterProject.fromDirectoryTest(fileSystem.currentDirectory) | ||
| ); | ||
| const String expected = 'dep1, dep2 are not hosted'; |
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.
same question, will the user have enough context to understand what this means? in other words, are we going to get bug reports that they're getting warnings on their project when everything works?
|
|
||
| final DartPubJson dartPubJson = DartPubJson(jsonResult); | ||
| final List <String> dependencies = <String>[]; | ||
| final Set<String> hostedDependencies = {'hosted', 'root'}; |
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.
what does 'root' mean? please add a comment explaining both hosted and root.
| } | ||
|
|
||
| class PubDependenciesProjectValidator extends ProjectValidator { | ||
| PubDependenciesProjectValidator(this._processManager); |
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.
| PubDependenciesProjectValidator(this._processManager); | |
| const PubDependenciesProjectValidator(this._processManager); |
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 couldn't implement this because of the abstract class
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.
Can you make the super also const?
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.
you'll have to make title final, but i don't think that should be a problem
| @@ -0,0 +1,62 @@ | |||
| import 'dart:collection'; | |||
|
|
|||
| class 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 definitely needs a dartdoc, and maybe a more specific name. Note that since the convention in Dart is to just do import 'foo.dart';, every name gets imported into that library's namespace
| if (items.isEmpty || items.length > 1) { | ||
| throwToolExit('The suggestions flags needs one directory path'); | ||
| if (items.isEmpty) { // user did not specify any path | ||
| _logger.printStatus('Showing suggestions for current directory'); |
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.
| _logger.printStatus('Showing suggestions for current directory'); | |
| _logger.printTrace('Showing suggestions for current directory: ${_fileSystem.currentDirectory.path}'); |
| final List<String> dependencies; | ||
|
|
||
| static Package fromHashMap(dynamic packageInfo) { | ||
| static DartDependencyPackage fromHashMap(dynamic packageInfo) { |
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.
Dart style nit:
| static DartDependencyPackage fromHashMap(dynamic packageInfo) { | |
| factory DartDependencyPackage.fromHashMap(dynamic packageInfo) { |
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 a style nit, this could very well compile to the same machine code
| const String expected = '\n' | ||
| '┌────────────────────────────────────────────────────────────────────────────────────┐\n' | ||
| '│ Pub dependencies │\n' | ||
| '│ [✓] Dart dependencies: All pub dependencies are hosted in https://pub.dartlang.org │\n' |
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.
| '│ [✓] Dart dependencies: All pub dependencies are hosted in https://pub.dartlang.org │\n' | |
| '│ [✓] Dart dependencies: All pub dependencies are hosted on https://pub.dartlang.org │\n' |
christopherfujino
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.
LGTM
|
nit: let's just make these all green, success, since it's not really a problem. Follow-up will be in #107675 |
#2885
Pre-launch Checklist
///).