mirror of
https://github.com/flutter/flutter
synced 2024-10-13 03:32:55 +00:00
[flutter_tools] update message for flutter create -t plugin
when no --platforms
specified (#71962)
This commit is contained in:
parent
78cbfbff42
commit
d447141bac
|
@ -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.
|
||||
|
||||
''');
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue