Unverified Commit d447141b authored by Chris Yang's avatar Chris Yang Committed by GitHub

[flutter_tools] update message for `flutter create -t plugin` when no...

[flutter_tools] update message for `flutter create -t plugin` when no `--platforms` specified (#71962)
parent 78cbfbff
...@@ -294,8 +294,9 @@ class CreateCommand extends CreateBase { ...@@ -294,8 +294,9 @@ class CreateCommand extends CreateBase {
if (!creatingNewProject && requestedPlatforms.isNotEmpty) { if (!creatingNewProject && requestedPlatforms.isNotEmpty) {
_printPluginUpdatePubspecMessage(relativePluginPath, platformsString); _printPluginUpdatePubspecMessage(relativePluginPath, platformsString);
} else if (_getSupportedPlatformsInPlugin(projectDir).isEmpty){ } else if (_getSupportedPlatformsInPlugin(projectDir).isEmpty){
globals.printError(_kNoPlatformsArgMessage); _printNoPluginMessage();
} }
_printAddPlatformMessage(relativePluginPath);
} else { } else {
// Tell the user the next steps. // Tell the user the next steps.
final FlutterProject project = FlutterProject.fromPath(projectDirPath); final FlutterProject project = FlutterProject.fromPath(projectDirPath);
...@@ -489,15 +490,22 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi ...@@ -489,15 +490,22 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
void _printPluginUpdatePubspecMessage(String pluginPath, String platformsString) { void _printPluginUpdatePubspecMessage(String pluginPath, String platformsString) {
globals.printStatus(''' globals.printStatus('''
You need to update $pluginPath/pubspec.yaml to support $platformsString. You need to update $pluginPath/pubspec.yaml to support $platformsString.
For more information, see https://flutter.dev/go/developing-plugins.
''', emphasis: true, color: TerminalColor.red); ''', emphasis: true, color: TerminalColor.red);
} }
const String _kNoPlatformsArgMessage = ''' void _printNoPluginMessage() {
globals.printError('''
You've created a plugin project that doesn't yet support any platforms.
''');
}
void _printAddPlatformMessage(String pluginPath) {
globals.printStatus('''
To add platforms, run `flutter create -t plugin --platforms <platforms> .` under $pluginPath.
For more information, see https://flutter.dev/go/plugin-platforms.
Must specify at least one platform using --platforms. ''');
For more information, see https://flutter.dev/go/developing-plugins. }
''';
...@@ -32,7 +32,7 @@ import '../../src/context.dart'; ...@@ -32,7 +32,7 @@ import '../../src/context.dart';
import '../../src/pubspec_schema.dart'; import '../../src/pubspec_schema.dart';
import '../../src/testbed.dart'; import '../../src/testbed.dart';
const String _kNoPlatformsMessage = 'Must specify at least one platform using --platforms.\n'; const String _kNoPlatformsMessage = 'You\'ve created a plugin project that doesn\'t yet support any platforms.\n';
const String frameworkRevision = '12345678'; const String frameworkRevision = '12345678';
const String frameworkChannel = 'omega'; const String frameworkChannel = 'omega';
// TODO(fujino): replace FakePlatform.fromPlatform() with FakePlatform() // TODO(fujino): replace FakePlatform.fromPlatform() with FakePlatform()
...@@ -2315,6 +2315,8 @@ void main() { ...@@ -2315,6 +2315,8 @@ void main() {
await runner.run(<String>['create', '--no-pub', '--template=plugin', projectDir.path]); await runner.run(<String>['create', '--no-pub', '--template=plugin', projectDir.path]);
expect(logger.errorText, contains(_kNoPlatformsMessage)); expect(logger.errorText, contains(_kNoPlatformsMessage));
expect(logger.statusText, contains('To add platforms, run `flutter create -t plugin --platforms <platforms> .` under ${globals.fs.path.normalize(globals.fs.path.relative(projectDir.path))}.'));
expect(logger.statusText, contains('For more information, see https://flutter.dev/go/plugin-platforms.'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: false), FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: false),
......
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