use dart pub deps to analyze consumer dependencies (#99079)
This commit is contained in:
parent
281f1421df
commit
83a88058d6
@ -17,18 +17,13 @@
|
|||||||
/// unless the additions are cleared as described above.
|
/// unless the additions are cleared as described above.
|
||||||
const Set<String> kCorePackageAllowList = <String>{
|
const Set<String> kCorePackageAllowList = <String>{
|
||||||
// Please keep this list in alphabetical order.
|
// Please keep this list in alphabetical order.
|
||||||
'_fe_analyzer_shared',
|
|
||||||
'analyzer',
|
|
||||||
'archive',
|
'archive',
|
||||||
'args',
|
|
||||||
'async',
|
'async',
|
||||||
'boolean_selector',
|
'boolean_selector',
|
||||||
'characters',
|
'characters',
|
||||||
'charcode',
|
'charcode',
|
||||||
'clock',
|
'clock',
|
||||||
'collection',
|
'collection',
|
||||||
'convert',
|
|
||||||
'coverage',
|
|
||||||
'crypto',
|
'crypto',
|
||||||
'fake_async',
|
'fake_async',
|
||||||
'file',
|
'file',
|
||||||
@ -36,45 +31,25 @@ const Set<String> kCorePackageAllowList = <String>{
|
|||||||
'flutter_driver',
|
'flutter_driver',
|
||||||
'flutter_localizations',
|
'flutter_localizations',
|
||||||
'flutter_test',
|
'flutter_test',
|
||||||
'frontend_server_client',
|
'fuchsia_remote_debug_protocol',
|
||||||
'glob',
|
|
||||||
'http_multi_server',
|
|
||||||
'http_parser',
|
|
||||||
'integration_test',
|
'integration_test',
|
||||||
'intl',
|
'intl',
|
||||||
'io',
|
|
||||||
'js',
|
|
||||||
'logging',
|
|
||||||
'matcher',
|
'matcher',
|
||||||
'material_color_utilities',
|
'material_color_utilities',
|
||||||
'meta',
|
'meta',
|
||||||
'mime',
|
|
||||||
'node_preamble',
|
|
||||||
'package_config',
|
|
||||||
'path',
|
'path',
|
||||||
'pool',
|
'platform',
|
||||||
'pub_semver',
|
'process',
|
||||||
'shelf',
|
'sky_engine',
|
||||||
'shelf_packages_handler',
|
|
||||||
'shelf_static',
|
|
||||||
'shelf_web_socket',
|
|
||||||
'source_map_stack_trace',
|
|
||||||
'source_maps',
|
|
||||||
'source_span',
|
'source_span',
|
||||||
'stack_trace',
|
'stack_trace',
|
||||||
'stream_channel',
|
'stream_channel',
|
||||||
'string_scanner',
|
'string_scanner',
|
||||||
'sync_http',
|
'sync_http',
|
||||||
'term_glyph',
|
'term_glyph',
|
||||||
'test',
|
|
||||||
'test_api',
|
'test_api',
|
||||||
'test_core',
|
|
||||||
'typed_data',
|
'typed_data',
|
||||||
'vector_math',
|
'vector_math',
|
||||||
'vm_service',
|
'vm_service',
|
||||||
'watcher',
|
|
||||||
'web_socket_channel',
|
|
||||||
'webdriver',
|
'webdriver',
|
||||||
'webkit_inspection_protocol',
|
|
||||||
'yaml',
|
|
||||||
};
|
};
|
||||||
|
@ -1565,24 +1565,50 @@ Future<EvalResult> _evalCommand(String executable, List<String> arguments, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _checkConsumerDependencies() async {
|
Future<void> _checkConsumerDependencies() async {
|
||||||
final ProcessResult result = await Process.run(flutter, <String>[
|
const List<String> kCorePackages = <String>[
|
||||||
'update-packages',
|
'flutter',
|
||||||
'--transitive-closure',
|
'flutter_test',
|
||||||
'--consumer-only',
|
'flutter_driver',
|
||||||
|
'flutter_localizations',
|
||||||
|
'integration_test',
|
||||||
|
'fuchsia_remote_debug_protocol',
|
||||||
|
];
|
||||||
|
final Set<String> dependencies = <String>{};
|
||||||
|
|
||||||
|
// 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) {
|
if (result.exitCode != 0) {
|
||||||
print(result.stdout as Object);
|
print(result.stdout as Object);
|
||||||
print(result.stderr as Object);
|
print(result.stderr as Object);
|
||||||
exit(result.exitCode);
|
exit(result.exitCode);
|
||||||
}
|
}
|
||||||
final Set<String> dependencies = <String>{};
|
final Map<String, Object?> rawJson = json.decode(result.stdout as String) as Map<String, Object?>;
|
||||||
for (final String line in result.stdout.toString().split('\n')) {
|
final Map<String, Map<String, Object?>> dependencyTree = <String, Map<String, Object?>>{
|
||||||
if (!line.contains('->')) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
final List<String> parts = line.split('->');
|
dependencies.add(currentPackage['name']! as String);
|
||||||
final String name = parts[0].trim();
|
|
||||||
dependencies.add(name);
|
final List<String> currentDependencies = (currentPackage['dependencies']! as List<Object?>).cast<String>();
|
||||||
|
for (final String dependency in currentDependencies) {
|
||||||
|
workset.add(dependencyTree[dependency]!);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Set<String> removed = kCorePackageAllowList.difference(dependencies);
|
final Set<String> removed = kCorePackageAllowList.difference(dependencies);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user