[CP-stable]Use .flutter-plugins-dependencies
for crash reporting. (#169484)
This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. ### Issue Link: What is the link to the issue this cherry-pick is addressing? https://github.com/flutter/flutter/pull/169319 ### Changelog Description: Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples Fixed a bug where the `flutter` tool crash reporting did not include what plugins were being used by the current project. ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch) Tool crash reports are missing plugins in use. ### Workaround: Is there a workaround for this issue? Yes, `flutter config --no-explicit-package-dependencies`, but that has other project impact, or copying and pasting the plugins manually. ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: What are the steps to validate that this fix works? See unit tests.
This commit is contained in:
parent
6e07e1f4bd
commit
9057717ebc
@ -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;
|
||||
_writePlugins(description, file);
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
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…
x
Reference in New Issue
Block a user