Unverified Commit 83a88058 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

use dart pub deps to analyze consumer dependencies (#99079)

parent 281f1421
......@@ -17,18 +17,13 @@
/// unless the additions are cleared as described above.
const Set<String> kCorePackageAllowList = <String>{
// Please keep this list in alphabetical order.
'_fe_analyzer_shared',
'analyzer',
'archive',
'args',
'async',
'boolean_selector',
'characters',
'charcode',
'clock',
'collection',
'convert',
'coverage',
'crypto',
'fake_async',
'file',
......@@ -36,45 +31,25 @@ const Set<String> kCorePackageAllowList = <String>{
'flutter_driver',
'flutter_localizations',
'flutter_test',
'frontend_server_client',
'glob',
'http_multi_server',
'http_parser',
'fuchsia_remote_debug_protocol',
'integration_test',
'intl',
'io',
'js',
'logging',
'matcher',
'material_color_utilities',
'meta',
'mime',
'node_preamble',
'package_config',
'path',
'pool',
'pub_semver',
'shelf',
'shelf_packages_handler',
'shelf_static',
'shelf_web_socket',
'source_map_stack_trace',
'source_maps',
'platform',
'process',
'sky_engine',
'source_span',
'stack_trace',
'stream_channel',
'string_scanner',
'sync_http',
'term_glyph',
'test',
'test_api',
'test_core',
'typed_data',
'vector_math',
'vm_service',
'watcher',
'web_socket_channel',
'webdriver',
'webkit_inspection_protocol',
'yaml',
};
......@@ -1565,24 +1565,50 @@ Future<EvalResult> _evalCommand(String executable, List<String> arguments, {
}
Future<void> _checkConsumerDependencies() async {
final ProcessResult result = await Process.run(flutter, <String>[
'update-packages',
'--transitive-closure',
'--consumer-only',
]);
if (result.exitCode != 0) {
print(result.stdout as Object);
print(result.stderr as Object);
exit(result.exitCode);
}
const List<String> kCorePackages = <String>[
'flutter',
'flutter_test',
'flutter_driver',
'flutter_localizations',
'integration_test',
'fuchsia_remote_debug_protocol',
];
final Set<String> dependencies = <String>{};
for (final String line in result.stdout.toString().split('\n')) {
if (!line.contains('->')) {
continue;
// Parse the output of pub deps --json to determine all of the
// current packages used by the core set of flutter packages.
for (final String package in kCorePackages) {
final ProcessResult result = await Process.run(dart, <String>[
'pub',
'deps',
'--json',
'--directory=${path.join(flutterRoot, 'packages', package)}'
]);
if (result.exitCode != 0) {
print(result.stdout as Object);
print(result.stderr as Object);
exit(result.exitCode);
}
final Map<String, Object?> rawJson = json.decode(result.stdout as String) as Map<String, Object?>;
final Map<String, Map<String, Object?>> dependencyTree = <String, Map<String, Object?>>{
for (final Map<String, Object?> package in (rawJson['packages']! as List<Object?>).cast<Map<String, Object?>>())
package['name']! as String : package,
};
final List<Map<String, Object?>> workset = <Map<String, Object?>>[];
workset.add(dependencyTree[package]!);
while (workset.isNotEmpty) {
final Map<String, Object?> currentPackage = workset.removeLast();
if (currentPackage['kind'] == 'dev') {
continue;
}
dependencies.add(currentPackage['name']! as String);
final List<String> currentDependencies = (currentPackage['dependencies']! as List<Object?>).cast<String>();
for (final String dependency in currentDependencies) {
workset.add(dependencyTree[dependency]!);
}
}
final List<String> parts = line.split('->');
final String name = parts[0].trim();
dependencies.add(name);
}
final Set<String> removed = kCorePackageAllowList.difference(dependencies);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment