Unverified Commit c589a0c3 authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

Revert "[flutter_tools] show only supported sub commands (#85125)" (#86131)

This reverts commit 84e57678.
parent 456fe1ab
...@@ -24,31 +24,25 @@ import 'build_winuwp.dart'; ...@@ -24,31 +24,25 @@ import 'build_winuwp.dart';
class BuildCommand extends FlutterCommand { class BuildCommand extends FlutterCommand {
BuildCommand({ bool verboseHelp = false }) { BuildCommand({ bool verboseHelp = false }) {
_addSubcommand(BuildAarCommand(verboseHelp: verboseHelp)); addSubcommand(BuildAarCommand(verboseHelp: verboseHelp));
_addSubcommand(BuildApkCommand(verboseHelp: verboseHelp)); addSubcommand(BuildApkCommand(verboseHelp: verboseHelp));
_addSubcommand(BuildAppBundleCommand(verboseHelp: verboseHelp)); addSubcommand(BuildAppBundleCommand(verboseHelp: verboseHelp));
_addSubcommand(BuildIOSCommand(verboseHelp: verboseHelp)); addSubcommand(BuildIOSCommand(verboseHelp: verboseHelp));
_addSubcommand(BuildIOSFrameworkCommand( addSubcommand(BuildIOSFrameworkCommand(
buildSystem: globals.buildSystem, buildSystem: globals.buildSystem,
verboseHelp: verboseHelp, verboseHelp: verboseHelp,
)); ));
_addSubcommand(BuildIOSArchiveCommand(verboseHelp: verboseHelp)); addSubcommand(BuildIOSArchiveCommand(verboseHelp: verboseHelp));
_addSubcommand(BuildBundleCommand(verboseHelp: verboseHelp)); addSubcommand(BuildBundleCommand(verboseHelp: verboseHelp));
_addSubcommand(BuildWebCommand(verboseHelp: verboseHelp)); addSubcommand(BuildWebCommand(verboseHelp: verboseHelp));
_addSubcommand(BuildMacosCommand(verboseHelp: verboseHelp)); addSubcommand(BuildMacosCommand(verboseHelp: verboseHelp));
_addSubcommand(BuildLinuxCommand( addSubcommand(BuildLinuxCommand(
operatingSystemUtils: globals.os, operatingSystemUtils: globals.os,
verboseHelp: verboseHelp verboseHelp: verboseHelp
)); ));
_addSubcommand(BuildWindowsCommand(verboseHelp: verboseHelp)); addSubcommand(BuildWindowsCommand(verboseHelp: verboseHelp));
_addSubcommand(BuildWindowsUwpCommand(verboseHelp: verboseHelp)); addSubcommand(BuildWindowsUwpCommand(verboseHelp: verboseHelp));
_addSubcommand(BuildFuchsiaCommand(verboseHelp: verboseHelp)); addSubcommand(BuildFuchsiaCommand(verboseHelp: verboseHelp));
}
void _addSubcommand(BuildSubCommand command) {
if (command.supported) {
addSubcommand(command);
}
} }
@override @override
...@@ -69,8 +63,6 @@ abstract class BuildSubCommand extends FlutterCommand { ...@@ -69,8 +63,6 @@ abstract class BuildSubCommand extends FlutterCommand {
@override @override
bool get reportNullSafety => true; bool get reportNullSafety => true;
bool get supported => true;
/// Display a message describing the current null safety runtime mode /// Display a message describing the current null safety runtime mode
/// that was selected. /// that was selected.
/// ///
......
...@@ -58,9 +58,6 @@ class BuildFuchsiaCommand extends BuildSubCommand { ...@@ -58,9 +58,6 @@ class BuildFuchsiaCommand extends BuildSubCommand {
@override @override
String get description => 'Build the Fuchsia target (Experimental).'; String get description => 'Build the Fuchsia target (Experimental).';
@override
bool get supported => globals.platform.isLinux || globals.platform.isMacOS;
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
if (!featureFlags.isFuchsiaEnabled) { if (!featureFlags.isFuchsiaEnabled) {
...@@ -71,7 +68,7 @@ class BuildFuchsiaCommand extends BuildSubCommand { ...@@ -71,7 +68,7 @@ class BuildFuchsiaCommand extends BuildSubCommand {
} }
final BuildInfo buildInfo = await getBuildInfo(); final BuildInfo buildInfo = await getBuildInfo();
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
if (!supported) { if (!globals.platform.isLinux && !globals.platform.isMacOS) {
throwToolExit('"build fuchsia" is only supported on Linux and MacOS hosts.'); throwToolExit('"build fuchsia" is only supported on Linux and MacOS hosts.');
} }
if (!flutterProject.fuchsia.existsSync()) { if (!flutterProject.fuchsia.existsSync()) {
......
...@@ -224,15 +224,12 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand { ...@@ -224,15 +224,12 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
Directory _outputAppDirectory(String xcodeResultOutput); Directory _outputAppDirectory(String xcodeResultOutput);
@override
bool get supported => globals.platform.isMacOS;
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
defaultBuildMode = forSimulator ? BuildMode.debug : BuildMode.release; defaultBuildMode = forSimulator ? BuildMode.debug : BuildMode.release;
final BuildInfo buildInfo = await getBuildInfo(); final BuildInfo buildInfo = await getBuildInfo();
if (!supported) { if (!globals.platform.isMacOS) {
throwToolExit('Building for iOS is only supported on macOS.'); throwToolExit('Building for iOS is only supported on macOS.');
} }
if (forSimulator && !buildInfo.supportsSimulator) { if (forSimulator && !buildInfo.supportsSimulator) {
......
...@@ -141,14 +141,11 @@ class BuildIOSFrameworkCommand extends BuildSubCommand { ...@@ -141,14 +141,11 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
return buildInfos; return buildInfos;
} }
@override
bool get supported => _platform.isMacOS;
@override @override
Future<void> validateCommand() async { Future<void> validateCommand() async {
await super.validateCommand(); await super.validateCommand();
_project = FlutterProject.current(); _project = FlutterProject.current();
if (!supported) { if (!_platform.isMacOS) {
throwToolExit('Building frameworks for iOS is only supported on the Mac.'); throwToolExit('Building frameworks for iOS is only supported on the Mac.');
} }
......
...@@ -39,9 +39,6 @@ class BuildMacosCommand extends BuildSubCommand { ...@@ -39,9 +39,6 @@ class BuildMacosCommand extends BuildSubCommand {
@override @override
String get description => 'Build a macOS desktop application.'; String get description => 'Build a macOS desktop application.';
@override
bool get supported => globals.platform.isMacOS;
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
final BuildInfo buildInfo = await getBuildInfo(); final BuildInfo buildInfo = await getBuildInfo();
...@@ -49,7 +46,7 @@ class BuildMacosCommand extends BuildSubCommand { ...@@ -49,7 +46,7 @@ class BuildMacosCommand extends BuildSubCommand {
if (!featureFlags.isMacOSEnabled) { if (!featureFlags.isMacOSEnabled) {
throwToolExit('"build macos" is not currently supported. To enable, run "flutter config --enable-macos-desktop".'); throwToolExit('"build macos" is not currently supported. To enable, run "flutter config --enable-macos-desktop".');
} }
if (!supported) { if (!globals.platform.isMacOS) {
throwToolExit('"build macos" only supported on macOS hosts.'); throwToolExit('"build macos" only supported on macOS hosts.');
} }
displayNullSafetyMode(buildInfo); displayNullSafetyMode(buildInfo);
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
// @dart = 2.8 // @dart = 2.8
import 'package:args/command_runner.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart'; import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
...@@ -112,7 +111,7 @@ void main() { ...@@ -112,7 +111,7 @@ void main() {
expect( expect(
createTestCommandRunner(command).run(const <String>['build', 'fuchsia']), createTestCommandRunner(command).run(const <String>['build', 'fuchsia']),
throwsA(isA<UsageException>()), throwsToolExit(),
); );
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Platform: () => windowsPlatform, Platform: () => windowsPlatform,
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
// @dart = 2.8 // @dart = 2.8
import 'package:args/command_runner.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
...@@ -163,7 +162,7 @@ void main() { ...@@ -163,7 +162,7 @@ void main() {
expect(createTestCommandRunner(command).run( expect(createTestCommandRunner(command).run(
const <String>['build', 'ios', '--no-pub'] const <String>['build', 'ios', '--no-pub']
), throwsA(isA<UsageException>())); ), throwsToolExit());
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Platform: () => notMacosPlatform, Platform: () => notMacosPlatform,
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
// @dart = 2.8 // @dart = 2.8
import 'package:args/command_runner.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
...@@ -158,7 +157,7 @@ void main() { ...@@ -158,7 +157,7 @@ void main() {
expect(createTestCommandRunner(command).run( expect(createTestCommandRunner(command).run(
const <String>['build', 'ipa', '--no-pub'] const <String>['build', 'ipa', '--no-pub']
), throwsA(isA<UsageException>())); ), throwsToolExit());
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Platform: () => notMacosPlatform, Platform: () => notMacosPlatform,
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
......
...@@ -149,7 +149,7 @@ void main() { ...@@ -149,7 +149,7 @@ void main() {
expect(createTestCommandRunner(command).run( expect(createTestCommandRunner(command).run(
const <String>['build', 'macos', '--no-pub'] const <String>['build', 'macos', '--no-pub']
), throwsA(isA<UsageException>())); ), throwsToolExit(message: '"build macos" only supported on macOS hosts.'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Platform: () => notMacosPlatform, Platform: () => notMacosPlatform,
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
...@@ -391,7 +391,7 @@ void main() { ...@@ -391,7 +391,7 @@ void main() {
final CommandRunner<void> runner = createTestCommandRunner(BuildCommand()); final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
expect(() => runner.run(<String>['build', 'macos', '--no-pub']), expect(() => runner.run(<String>['build', 'macos', '--no-pub']),
throwsA(isA<UsageException>())); throwsToolExit());
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false), FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false),
}); });
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
// @dart = 2.8 // @dart = 2.8
import 'package:args/args.dart'; import 'package:args/args.dart';
import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/commands/attach.dart'; import 'package:flutter_tools/src/commands/attach.dart';
import 'package:flutter_tools/src/commands/build.dart'; import 'package:flutter_tools/src/commands/build.dart';
...@@ -76,13 +75,6 @@ void main() { ...@@ -76,13 +75,6 @@ void main() {
FakeBuildSubCommand().test(sound); FakeBuildSubCommand().test(sound);
expect(testLogger.statusText, contains('💪 Building with sound null safety 💪')); expect(testLogger.statusText, contains('💪 Building with sound null safety 💪'));
}); });
testUsingContext('Include only supported sub commands', () {
final BuildCommand command = BuildCommand();
for (final Command<void> x in command.subcommands.values) {
expect((x as BuildSubCommand).supported, isTrue);
}
});
} }
class FakeBuildSubCommand extends BuildSubCommand { class FakeBuildSubCommand extends BuildSubCommand {
......
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