mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Use .flutter-plugins-dependencies
for crash reporting. (#169319)
Closes https://github.com/flutter/flutter/issues/169318.
This commit is contained in:
parent
6d8184e21e
commit
151011f7b4
@ -143,26 +143,62 @@ ${_projectMetadataInformation()}
|
||||
..writeln('**Creation channel**: ${metadata.versionChannel}')
|
||||
..writeln('**Creation framework version**: ${metadata.versionRevision}');
|
||||
|
||||
final File file = project.flutterPluginsFile;
|
||||
final File file = project.flutterPluginsDependenciesFile;
|
||||
if (file.existsSync()) {
|
||||
description.writeln('### Plugins');
|
||||
// Format is:
|
||||
// camera=/path/to/.pub-cache/hosted/pub.dartlang.org/camera-0.5.7+2/
|
||||
for (final String plugin in project.flutterPluginsFile.readAsLinesSync()) {
|
||||
final List<String> pluginParts = plugin.split('=');
|
||||
if (pluginParts.length != 2) {
|
||||
continue;
|
||||
}
|
||||
// Write the last part of the path, which includes the plugin name and version.
|
||||
// Example: camera-0.5.7+2
|
||||
final List<String> pathParts = _fileSystem.path.split(pluginParts[1]);
|
||||
description.writeln(pathParts.isEmpty ? pluginParts.first : pathParts.last);
|
||||
}
|
||||
_writePlugins(description, file);
|
||||
}
|
||||
|
||||
return description.toString();
|
||||
} on Exception catch (exception) {
|
||||
return exception.toString();
|
||||
}
|
||||
}
|
||||
|
||||
void _writePlugins(StringBuffer description, File file) {
|
||||
description.writeln('### Plugins');
|
||||
// Format is:
|
||||
// {
|
||||
// "plugins": {
|
||||
// "ios": [
|
||||
// {
|
||||
// "path": "/path/to/.pub-cache/hosted/pub.dartlang.org/camera-0.5.7+2/",
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
final Object? json = jsonDecode(file.readAsStringSync());
|
||||
if (json is! Map<String, Object?>) {
|
||||
return;
|
||||
}
|
||||
final Object? plugins = json['plugins'];
|
||||
if (plugins is! Map<String, Object?>) {
|
||||
return;
|
||||
}
|
||||
final Set<String> pluginPaths = <String>{};
|
||||
for (final Object? pluginList in plugins.values) {
|
||||
if (pluginList is! List<Object?>) {
|
||||
continue;
|
||||
}
|
||||
for (final Object? plugin in pluginList) {
|
||||
if (plugin is! Map<String, Object?>) {
|
||||
continue;
|
||||
}
|
||||
final String? path = plugin['path'] as String?;
|
||||
if (path != null) {
|
||||
pluginPaths.add(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pluginPaths.isEmpty) {
|
||||
return;
|
||||
}
|
||||
for (final String path in pluginPaths) {
|
||||
// Write the last part of the path, which includes the plugin name and version.
|
||||
// Example: camera-0.5.7+2
|
||||
final List<String> pathParts = _fileSystem.path.split(path);
|
||||
if (pathParts.isEmpty) {
|
||||
continue;
|
||||
}
|
||||
description.writeln(pathParts.last);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,33 @@ import 'package:flutter_tools/src/reporting/github_template.dart';
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
||||
const String _kPluginsFile = '''
|
||||
{
|
||||
"plugins": {
|
||||
"ios": [
|
||||
{
|
||||
"name": "camera",
|
||||
"path": "/fake/pub.dartlang.org/camera-0.5.7+2/"
|
||||
},
|
||||
{
|
||||
"name": "device_info",
|
||||
"path": "/fake/pub.dartlang.org/device_info-0.4.1+4/"
|
||||
}
|
||||
],
|
||||
"android": [
|
||||
{
|
||||
"name": "camera",
|
||||
"path": "/fake/pub.dartlang.org/camera-0.5.7+2/"
|
||||
},
|
||||
{
|
||||
"name": "device_info",
|
||||
"path": "/fake/pub.dartlang.org/device_info-0.4.1+4/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
''';
|
||||
|
||||
void main() {
|
||||
late BufferLogger logger;
|
||||
late FileSystem fs;
|
||||
@ -199,11 +226,8 @@ flutter:
|
||||
iosBundleIdentifier: com.example.failing.ios
|
||||
''');
|
||||
|
||||
final File pluginsFile = projectDirectory.childFile('.flutter-plugins');
|
||||
pluginsFile.writeAsStringSync('''
|
||||
camera=/fake/pub.dartlang.org/camera-0.5.7+2/
|
||||
device_info=/fake/pub.dartlang.org/pub.dartlang.org/device_info-0.4.1+4/
|
||||
''');
|
||||
final File pluginsFile = projectDirectory.childFile('.flutter-plugins-dependencies');
|
||||
pluginsFile.writeAsStringSync(_kPluginsFile);
|
||||
|
||||
final File metadataFile = projectDirectory.childFile('.metadata');
|
||||
metadataFile.writeAsStringSync('''
|
||||
|
Loading…
Reference in New Issue
Block a user