Unverified Commit ff8203dc authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate usage value plugin count off .flutter-plugins (#72538)

parent 9a9339fb
...@@ -12,6 +12,7 @@ import '../cache.dart'; ...@@ -12,6 +12,7 @@ import '../cache.dart';
import '../dart/generate_synthetic_packages.dart'; import '../dart/generate_synthetic_packages.dart';
import '../dart/pub.dart'; import '../dart/pub.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../plugins.dart';
import '../project.dart'; import '../project.dart';
import '../reporting/reporting.dart'; import '../reporting/reporting.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
...@@ -79,10 +80,10 @@ class PackagesGetCommand extends FlutterCommand { ...@@ -79,10 +80,10 @@ class PackagesGetCommand extends FlutterCommand {
return usageValues; return usageValues;
} }
final FlutterProject rootProject = FlutterProject.fromPath(target); final FlutterProject rootProject = FlutterProject.fromPath(target);
final bool hasPlugins = rootProject.flutterPluginsFile.existsSync(); final bool hasPlugins = rootProject.flutterPluginsDependenciesFile.existsSync();
if (hasPlugins) { if (hasPlugins) {
final int numberOfPlugins = (rootProject.flutterPluginsFile.readAsLinesSync()).length; final List<Plugin> plugins = await findPlugins(rootProject);
usageValues[CustomDimensions.commandPackagesNumberPlugins] = '$numberOfPlugins'; usageValues[CustomDimensions.commandPackagesNumberPlugins] = plugins.length.toString();
} else { } else {
usageValues[CustomDimensions.commandPackagesNumberPlugins] = '0'; usageValues[CustomDimensions.commandPackagesNumberPlugins] = '0';
} }
......
...@@ -227,7 +227,7 @@ void main() { ...@@ -227,7 +227,7 @@ void main() {
), ),
}); });
testUsingContext('set the number of plugins as usage value', () async { testUsingContext('set no plugins as usage value', () async {
final String projectPath = await createProject(tempDir, final String projectPath = await createProject(tempDir,
arguments: <String>['--no-pub', '--template=module']); arguments: <String>['--no-pub', '--template=module']);
removeGeneratedFiles(projectPath); removeGeneratedFiles(projectPath);
...@@ -248,6 +248,31 @@ void main() { ...@@ -248,6 +248,31 @@ void main() {
), ),
}); });
testUsingContext('set the number of plugins as usage value', () async {
final String projectPath = await createProject(
tempDir,
arguments: <String>['--template=plugin', '--no-pub', '--platforms=ios,android,macos,windows'],
);
final String exampleProjectPath = globals.fs.path.join(projectPath, 'example');
final PackagesCommand command = await runCommandIn(exampleProjectPath, 'get');
final PackagesGetCommand getCommand = command.subcommands['get'] as PackagesGetCommand;
// Should be 1 instead of 2, but integration_test is always included.
// https://github.com/flutter/flutter/issues/56591
expect(await getCommand.usageValues,
containsPair(CustomDimensions.commandPackagesNumberPlugins, '2'));
}, overrides: <Type, Generator>{
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('indicate that the project is not a module in usage value', () async { testUsingContext('indicate that the project is not a module in usage value', () async {
final String projectPath = await createProject(tempDir, final String projectPath = await createProject(tempDir,
arguments: <String>['--no-pub']); arguments: <String>['--no-pub']);
......
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