[flutter_tools] update message for flutter create -t plugin when no --platforms specified (#71962)

This commit is contained in:
Chris Yang 2020-12-10 15:15:55 -08:00 committed by GitHub
parent 78cbfbff42
commit d447141bac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 8 deletions

View file

@ -294,8 +294,9 @@ class CreateCommand extends CreateBase {
if (!creatingNewProject && requestedPlatforms.isNotEmpty) {
_printPluginUpdatePubspecMessage(relativePluginPath, platformsString);
} else if (_getSupportedPlatformsInPlugin(projectDir).isEmpty){
globals.printError(_kNoPlatformsArgMessage);
_printNoPluginMessage();
}
_printAddPlatformMessage(relativePluginPath);
} else {
// Tell the user the next steps.
final FlutterProject project = FlutterProject.fromPath(projectDirPath);
@ -489,15 +490,22 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
void _printPluginUpdatePubspecMessage(String pluginPath, String platformsString) {
globals.printStatus('''
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);
}
const String _kNoPlatformsArgMessage = '''
void _printNoPluginMessage() {
globals.printError('''
You've created a plugin project that doesn't yet support any platforms.
Must specify at least one platform using --platforms.
For more information, see https://flutter.dev/go/developing-plugins.
''';
''');
}
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.
''');
}

View file

@ -32,7 +32,7 @@ import '../../src/context.dart';
import '../../src/pubspec_schema.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 frameworkChannel = 'omega';
// TODO(fujino): replace FakePlatform.fromPlatform() with FakePlatform()
@ -2315,6 +2315,8 @@ void main() {
await runner.run(<String>['create', '--no-pub', '--template=plugin', projectDir.path]);
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>{
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: false),